@gentiq/ui 1.0.0-alpha.4 → 1.0.0-alpha.6

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/index.es.js CHANGED
@@ -1,2066 +1,49 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as s, Fragment as fe } from "react/jsx-runtime";
3
- import * as Q from "react";
4
- import { useRef as Ae, useState as S, useEffect as R, createElement as Ct, useContext as We, useMemo as O, useLayoutEffect as _t, forwardRef as Tt, useCallback as Le, memo as It, useId as Fe, createContext as qt, useSyncExternalStore as Lt, Suspense as Mt } from "react";
5
- import { useMessage as Pt, useOptionsStore as At, useServerConfig as Et, createOptionsStore as Xe, Message as Ye, useGentiqTranslation as q, References as Ee, useTheme as se, useGentiqLanguage as J, useGentiqOptions as H, useThreadSelection as Ze, ThreadSelectionProvider as Je, useThread as zt, Thread as et, GentiqRuntimeProvider as Rt, useLoginCodeExchange as Dt, useAuthSession as Ft, useGentiqApi as ze, useGentiqQueryClient as tt, getLocalizedErrorMessage as re, useGentiqKeys as Ot, useGentiqEntitlement as $t, ThreadList as G, ThreadRename as ye, useThreadListItem as Re, useGentiqStatus as Ut } from "@gentiq/react";
6
- import { Slot as jt } from "@radix-ui/react-slot";
7
- import { cva as Bt } from "class-variance-authority";
8
- import { QuoteIcon as Gt, Loader2Icon as Ht, OctagonXIcon as Vt, TriangleAlertIcon as Kt, InfoIcon as Qt, CircleCheckIcon as Wt, PanelLeftIcon as Xt, User as Yt, Palette as Zt, ShieldCheck as Jt, Settings as Me, AtSign as ea, Mail as ta, Smartphone as aa, Lock as na, Save as ra, Coins as sa, Infinity as ia, Zap as oa, LogOut as la, SquarePen as at, Check as ca, X as da, MoreVertical as ua, PinOff as ma, Pin as nt, Share2 as ha, Link2Off as ga, Pencil as pa, Trash as fa, Search as ba } from "lucide-react";
9
- import { E as rt, u as ie, R as va, U as Oe, r as st, m as xa, a as ya, S as Na, b as wa, P as Sa, c as x, d as ee, C as ka, e as Ca, L as A, I as F, B as $, f as we, g as Se, h as ke, i as Ce, j as _e, k as _a, l as it, T as ot, n as Ta, o as Ia, p as qa, q as La, s as Ma, t as lt, v as ct, w as dt, x as ut, y as $e, z as Pa, A as mt, D as Aa, F as Ea, G as ht, H as za, J as gt, K as Ra, M as Da, N as Fa, O as Oa, Q as $a, V as Ua, W as ja, X as Ba, Y as Ga, Z as he } from "./shared-MFlvTavE.js";
10
- import { _ as Cr, $ as _r, a0 as Tr, a1 as Ir, a2 as qr, a3 as Lr, a4 as Mr, a5 as Pr, a6 as Ar, a7 as Er, a8 as zr, a9 as Rr, aa as Dr, ab as Fr, ac as Or, ad as $r, ae as Ur, af as jr, ag as Br, ah as Gr, ai as Hr, aj as Vr } from "./shared-MFlvTavE.js";
11
- import { Toaster as Ha, toast as E } from "sonner";
12
- import { getToolName as pt, isToolUIPart as ft } from "ai";
13
- import { createPortal as Va } from "react-dom";
14
- import { textOrKey as Ka, evaluateCondition as Te, getAvailableLanguages as Qa, getLanguageNativeName as Wa, isGentiqError as Xa, withAttachmentUrls as Ya, toGentiqMessages as Za } from "@gentiq/core";
15
- function Ja() {
16
- const t = Ae(null), [a, n] = S(0);
17
- return R(() => {
18
- const r = t.current;
19
- if (!r) return;
20
- const i = () => {
21
- const m = r.offsetHeight;
22
- n((u) => Math.abs(u - m) < 1 ? u : m);
23
- };
24
- i();
25
- const o = typeof ResizeObserver > "u" ? null : new ResizeObserver(i);
26
- return o?.observe(r), () => o?.disconnect();
27
- }, []), [t, a];
28
- }
29
- const Ue = (t) => {
30
- if (!t || typeof t != "object") return null;
31
- const a = Object.values(t).filter((n) => ["string", "number", "boolean"].includes(typeof n)).slice(0, 3).map(String);
32
- return a.length > 0 ? a.join(" · ") : null;
33
- };
34
- function en(t) {
35
- return typeof t.output == "string" ? t.output : Ue(t.output) ?? Ue(t.input) ?? pt(t);
36
- }
37
- function tn({
38
- part: t,
39
- index: a,
40
- component: n
41
- }) {
42
- const r = /* @__PURE__ */ e(n, { part: t, index: a });
43
- return (
44
- // resetKeys: a streamed part can be malformed for a token and valid on the next. Without it
45
- // the boundary would latch for good, since the part's key never changes.
46
- /* @__PURE__ */ e(rt, { resetKeys: [t], children: ft(t) || t.type === "file" ? /* @__PURE__ */ e(an, { part: t, index: a, children: r }) : r })
47
- );
48
- }
49
- function an({
50
- part: t,
51
- index: a,
52
- children: n
53
- }) {
54
- const r = Pt((u) => u.message), { referenceAdapters: i } = ie(), o = { messageId: r.id, partIndex: a, role: r.role, data: t };
55
- let m;
56
- if (ft(t)) {
57
- const u = pt(t), g = {
58
- ...o,
59
- kind: "tool",
60
- sourceId: `${r.id}-${a}-tool`,
61
- label: u,
62
- excerpt: en(t)
63
- }, c = i?.[u]?.({ part: t, message: r, toolName: u }) || {};
64
- m = {
65
- ...g,
66
- ...c,
67
- sourceId: c.sourceId || g.sourceId,
68
- messageId: c.messageId || g.messageId,
69
- partIndex: c.partIndex ?? g.partIndex,
70
- role: c.role || g.role,
71
- kind: c.kind || g.kind
72
- };
73
- } else if (t.type === "file")
74
- m = {
75
- ...o,
76
- kind: "file",
77
- sourceId: `${r.id}-${a}-file`,
78
- label: t.filename || t.mediaType,
79
- excerpt: t.filename || t.mediaType
80
- };
81
- else
82
- return n;
83
- return /* @__PURE__ */ e(va, { reference: m, children: n });
84
- }
85
- const je = /* @__PURE__ */ new WeakMap();
86
- function nn(t) {
87
- let a = je.get(t);
88
- if (!a) {
89
- const n = t;
90
- a = ({ part: i, index: o }) => Ct(tn, { part: i, index: o, component: n }), je.set(t, a);
91
- }
92
- return a;
93
- }
94
- function bt(t) {
95
- const a = {};
96
- for (const [n, r] of Object.entries(t))
97
- a[n] = r && nn(r);
98
- return a;
99
- }
100
- const rn = Xe(st({}, null));
101
- function De({
102
- components: t,
103
- children: a,
104
- history: n,
105
- welcome: r,
106
- threadActions: i,
107
- composer: o,
108
- disclaimer: m,
109
- settings: u
110
- }) {
111
- const g = We(Oe) ?? rn, c = At(g, (k) => k.configured), h = ie(), p = Et(), f = O(
112
- () => st(
113
- xa(c, {
114
- history: n,
115
- welcome: r,
116
- threadActions: i,
117
- composer: o,
118
- disclaimer: m,
119
- settings: u
120
- }),
121
- p
122
- ),
123
- [c, p, n, r, i, o, m, u]
124
- ), [b] = S(() => Xe(f));
125
- _t(() => b.setState(f), [b, f]);
126
- const _ = O(() => ya(h, t), [h, t]), v = O(() => bt(_.parts), [_.parts]);
127
- return /* @__PURE__ */ e(Na.Provider, { value: _, children: /* @__PURE__ */ e(Oe.Provider, { value: b, children: /* @__PURE__ */ e(Ye.PartsProvider, { components: v, children: a }) }) });
128
- }
129
- const sn = {
130
- top: "max(0.5rem, calc(var(--gentiq-selection-top) - 2.625rem))",
131
- left: "calc(var(--gentiq-selection-left) + var(--gentiq-selection-width) / 2)"
132
- };
133
- function on() {
134
- const { t } = q(["chat"]), a = wa();
135
- return a ? Va(
136
- /* @__PURE__ */ e(
137
- Ee.SelectionQuote,
138
- {
139
- style: sn,
140
- className: "fixed z-50 flex size-9 -translate-x-1/2 items-center justify-center rounded-lg bg-background text-foreground shadow-lg ring-1 ring-border/60 transition hover:bg-muted",
141
- "aria-label": t("reference_selection"),
142
- title: t("reference_selection"),
143
- children: /* @__PURE__ */ e(Gt, { className: "size-4" })
144
- }
145
- ),
146
- a
147
- ) : null;
148
- }
149
- function ln(t, a) {
150
- if (typeof t != "object" || t === null) return t || void 0;
151
- const n = a.split("-")[0];
152
- return t[a] || t[n] || t.en || Object.values(t)[0];
153
- }
154
- function cn({
155
- accent: t,
156
- radius: a,
157
- fontFamily: n,
158
- userBubbleAccent: r
159
- }) {
160
- const i = {};
161
- if (t && (i["--gentiq-primary"] = t), r && (i["--gentiq-bubble"] = "var(--gentiq-primary)", i["--gentiq-bubble-foreground"] = "var(--gentiq-primary-foreground)"), a && (i["--gentiq-radius"] = a), n) {
162
- const o = n.includes(" ") && !/^['"]/.test(n) ? `"${n}"` : n;
163
- i["--gentiq-font-family"] = `${o}, var(--gentiq-font-script)`;
164
- }
165
- return i;
166
- }
167
- const W = Tt(function({ className: a, style: n, children: r, ...i }, o) {
168
- const { resolvedTheme: m, accent: u, radius: g } = se(), { language: c, dir: h } = J(), p = H((v) => v.theme.typography?.fontFamily), f = H((v) => v.theme.userBubbleAccent), [b, _] = S(null);
169
- return /* @__PURE__ */ s(
170
- "div",
171
- {
172
- ref: o,
173
- ...i,
174
- className: x("gentiq", m, a),
175
- lang: c,
176
- dir: h,
177
- style: {
178
- ...cn({
179
- accent: u,
180
- radius: g,
181
- fontFamily: ln(p, c),
182
- userBubbleAccent: f
183
- }),
184
- ...n
185
- },
186
- children: [
187
- /* @__PURE__ */ e(Sa.Provider, { value: b, children: r }),
188
- /* @__PURE__ */ e("div", { ref: _, "data-gentiq-portal": "", className: "contents" })
189
- ]
190
- }
191
- );
192
- });
193
- function dn({ classNames: t = {} }) {
194
- const { t: a, i18n: n } = q(["chat"]), { threadId: r, messages: i, status: o, send: m, addToolOutput: u } = zt(), g = Le((z) => {
195
- m({ text: z });
196
- }, [m]), { MessageList: c, PromptInput: h, WelcomeScreen: p } = ie(), f = ee((z) => z.composer), b = ee((z) => z.disclaimer), _ = H((z) => z.app.cacheNamespace), v = n.exists("chat:disclaimer") ? a("chat:disclaimer") : null, k = typeof b == "string" ? Ka(b, a, n, ["chat"]) : b ?? v, I = i[i.length - 1], y = I?.role === "assistant" && (o === "ready" || I.parts.some((z) => z.type === "data-chat-finished")), U = o === "error", D = r === null && i.length === 0 && o !== "submitted", T = O(() => It(h), [h]), [te, V] = Ja(), X = O(
197
- () => V ? { "--gentiq-composer-inset": `${V}px` } : void 0,
198
- [V]
199
- );
200
- return /* @__PURE__ */ s(
201
- Ee.Root,
202
- {
203
- enabled: f?.references?.enabled ?? !0,
204
- maxItems: f?.references?.maxItems,
205
- maxExcerptLength: f?.references?.maxExcerptLength,
206
- children: [
207
- /* @__PURE__ */ e(
208
- ka,
209
- {
210
- message: I,
211
- disabled: !y || o !== "ready",
212
- cacheNamespace: _,
213
- onAnswer: u,
214
- children: /* @__PURE__ */ s(
215
- et.Root,
216
- {
217
- className: x(
218
- "relative flex flex-col h-full overflow-hidden bg-background",
219
- t.container
220
- ),
221
- style: X,
222
- children: [
223
- !D && /* @__PURE__ */ e(rt, { children: /* @__PURE__ */ e(c, { className: x("flex-1", t.messageList) }) }),
224
- /* @__PURE__ */ s("div", { className: "absolute inset-0 z-10 pointer-events-none flex flex-col", children: [
225
- /* @__PURE__ */ e("div", { className: "grow basis-0 shrink-0 min-h-0 flex flex-col items-center justify-end px-4 pb-6 md:pb-8", children: D && /* @__PURE__ */ e(p, { onSuggestionClick: g }) }),
226
- /* @__PURE__ */ s("div", { ref: te, className: "shrink-0 flex flex-col items-stretch", children: [
227
- /* @__PURE__ */ e(
228
- T,
229
- {
230
- onSend: m,
231
- status: o,
232
- isErrorVisible: U,
233
- threadId: r,
234
- newChat: D,
235
- className: x(
236
- "pointer-events-auto",
237
- t.inputArea,
238
- k && "pb-0 md:pb-0"
239
- )
240
- }
241
- ),
242
- k && /* @__PURE__ */ s("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
243
- /* @__PURE__ */ e("div", { className: "absolute inset-0 bg-background pointer-events-none -z-10" }),
244
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground select-none text-center leading-tight", children: k })
245
- ] })
246
- ] }),
247
- /* @__PURE__ */ e(
248
- "div",
249
- {
250
- className: x(
251
- "basis-0 shrink-0 transition-[flex-grow] duration-500 ease-in-out",
252
- D ? "grow" : "grow-0"
253
- )
254
- }
255
- )
256
- ] })
257
- ]
258
- }
259
- )
260
- }
261
- ),
262
- /* @__PURE__ */ e(on, {})
263
- ]
264
- }
265
- );
266
- }
267
- const un = ({
268
- threadId: t,
269
- onThreadChange: a,
270
- components: n,
271
- welcome: r,
272
- threadActions: i,
273
- composer: o,
274
- disclaimer: m,
275
- ...u
276
- }) => {
277
- const g = Ze(), c = /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(
278
- De,
279
- {
280
- components: n,
281
- welcome: r,
282
- threadActions: i,
283
- composer: o,
284
- disclaimer: m,
285
- children: /* @__PURE__ */ e(dn, { ...u })
286
- }
287
- ) });
288
- return g && t === void 0 && a === void 0 ? c : /* @__PURE__ */ e(
289
- Je,
290
- {
291
- threadId: t,
292
- onThreadChange: a,
293
- getThreadHref: g?.getThreadHref,
294
- children: c
295
- }
296
- );
297
- };
298
- function mn() {
299
- return /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e("div", { className: "min-h-dvh bg-background" }) });
300
- }
301
- const hn = ({ theme: t = "system", ...a }) => /* @__PURE__ */ e(
302
- Ha,
303
- {
304
- theme: t,
305
- className: "toaster group",
306
- icons: {
307
- success: /* @__PURE__ */ e(Wt, { className: "size-4" }),
308
- info: /* @__PURE__ */ e(Qt, { className: "size-4" }),
309
- warning: /* @__PURE__ */ e(Kt, { className: "size-4" }),
310
- error: /* @__PURE__ */ e(Vt, { className: "size-4" }),
311
- loading: /* @__PURE__ */ e(Ht, { className: "size-4 animate-spin" })
312
- },
313
- style: {
314
- "--normal-bg": "var(--gentiq-popover)",
315
- "--normal-text": "var(--gentiq-popover-foreground)",
316
- "--normal-border": "var(--gentiq-border)",
317
- "--border-radius": "var(--gentiq-radius)",
318
- fontFamily: "var(--gentiq-font-family)"
319
- },
320
- ...a
321
- }
322
- );
323
- function gn() {
324
- const { resolvedTheme: t } = se();
325
- return /* @__PURE__ */ e(hn, { richColors: !0, theme: t });
326
- }
327
- const pn = bt(Ca), fn = ({ message: t }) => {
328
- E.error(t);
329
- };
330
- function bn({
331
- toaster: t = !0,
332
- fallback: a,
333
- onConfigUnavailable: n = fn,
334
- children: r,
335
- ...i
336
- }) {
337
- return /* @__PURE__ */ e(
338
- Rt,
339
- {
340
- ...i,
341
- fallback: a ?? /* @__PURE__ */ e(mn, {}),
342
- onConfigUnavailable: n,
343
- overlay: t && /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(gn, {}) }),
344
- children: /* @__PURE__ */ e(Ye.PartsProvider, { components: pn, children: r })
345
- }
346
- );
347
- }
348
- function vn() {
349
- const { language: t, dir: a } = J(), { resolvedTheme: n } = se(), r = H((o) => o.app.name), i = H((o) => o.app.favicon);
350
- return R(() => {
351
- const o = document.documentElement, m = { lang: o.lang, dir: o.dir };
352
- return o.lang = t, o.dir = a, () => {
353
- o.lang = m.lang, o.dir = m.dir;
354
- };
355
- }, [t, a]), R(() => {
356
- const o = document.documentElement, m = o.style.colorScheme, u = o.classList.contains(n);
357
- return o.classList.add(n), o.style.colorScheme = n, () => {
358
- u || o.classList.remove(n), o.style.colorScheme = m;
359
- };
360
- }, [n]), R(() => {
361
- if (!r) return;
362
- const o = document.title;
363
- return document.title = r, () => {
364
- document.title = o;
365
- };
366
- }, [r]), R(() => {
367
- if (!i) return;
368
- const o = document.querySelector("link[rel~='icon']"), m = o ?? Object.assign(document.createElement("link"), { rel: "icon" }), u = m.getAttribute("href");
369
- return m.href = i, o || document.head.appendChild(m), () => {
370
- o ? u === null ? m.removeAttribute("href") : m.setAttribute("href", u) : m.remove();
371
- };
372
- }, [i]), null;
373
- }
374
- function xn({ children: t, fallback: a, loginCode: n, onLoginCodeUsed: r }) {
375
- const i = Dt(), [o, m] = S(
376
- () => n ? "pending" : "idle"
377
- );
378
- R(() => {
379
- if (!n) return;
380
- let c = !1;
381
- return m("pending"), (async () => {
382
- try {
383
- await i(n);
384
- } catch (h) {
385
- if (c) return;
386
- console.error("Could not sign in with the login code:", h), m("failed");
387
- return;
388
- }
389
- c || (r?.(), m("idle"));
390
- })(), () => {
391
- c = !0;
392
- };
393
- }, [n]);
394
- const u = Ft({ enabled: o === "idle" }), g = o === "failed" ? "handoff_failed" : o === "idle" && (u === "signed_out" || u === "session_expired") ? u : null;
395
- return g ? /* @__PURE__ */ e(fe, { children: typeof a == "function" ? a(g) : a }) : o === "pending" || u === "checking" ? /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e("div", { className: "flex h-screen w-full items-center justify-center bg-background", children: /* @__PURE__ */ e("div", { className: "size-8 rounded-full border-4 border-primary border-t-transparent animate-spin" }) }) }) : /* @__PURE__ */ e(fe, { children: t });
396
- }
397
- const Be = (t) => t.replace(/[^0-9]/g, "");
398
- function yn(t) {
399
- return /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(Nn, { ...t }) });
400
- }
401
- function Nn({ onSignedIn: t, reason: a }) {
402
- const { t: n } = q(["login"]), r = H((d) => d.app), i = ze(), o = J().dir === "rtl", m = tt(), [u, g] = S("login"), c = !!r?.disableSignup, h = !!r?.disableAuthPage, p = O(
403
- () => r?.loginFields ?? ["username"],
404
- [r?.loginFields]
405
- ), f = {
406
- username: { labelKey: "username", labelDefault: "Username", inputType: "text" },
407
- email: { labelKey: "email", labelDefault: "Email", inputType: "email" },
408
- phone: { labelKey: "phone", labelDefault: "Phone", inputType: "tel" }
409
- }, b = p.map((d) => n(f[d].labelKey, f[d].labelDefault)).join(" / "), _ = p.length === 1 ? f[p[0]].inputType : "text", v = p.length === 1 && p[0] === "phone", k = (d) => v ? Be(d) : d, [I, y] = S(""), [U, D] = S(""), [T, te] = S({}), V = (d, N) => te((P) => ({ ...P, [d]: N })), [X, z] = S(""), [oe, ve] = S(""), [le, ce] = S(""), Y = O(
410
- () => r?.userMetadataFields?.filter((d) => d.showInSignup) || [],
411
- [r?.userMetadataFields]
412
- ), [L, M] = S(() => {
413
- const d = {};
414
- return Y.forEach((N) => {
415
- N.defaultValue !== void 0 && (d[N.key] = N.defaultValue);
416
- }), d;
417
- });
418
- R(() => {
419
- const d = { ...L };
420
- let N = !1;
421
- Y.forEach((P) => {
422
- P.condition && !Te(P.condition, L) && d[P.key] !== void 0 && (delete d[P.key], N = !0);
423
- }), N && M(d);
424
- }, [L, Y]);
425
- const [j, B] = S(""), [Z, K] = S(!1);
426
- R(() => {
427
- c && u === "register" && g("login");
428
- }, [c, u]);
429
- const de = async (d) => {
430
- d.preventDefault(), B(""), K(!0);
431
- try {
432
- await i.login(I, U), m.clear(), t();
433
- } catch (N) {
434
- B(re(N, n));
435
- } finally {
436
- K(!1);
437
- }
438
- }, Ie = async (d) => {
439
- d.preventDefault(), B("");
440
- const N = {};
441
- for (const P of p) {
442
- const l = T[P]?.trim();
443
- l && (N[P] = l);
444
- }
445
- if (Object.keys(N).length === 0) {
446
- B(n("at_least_one_login_field", "Please provide at least one login field."));
447
- return;
448
- }
449
- K(!0);
450
- try {
451
- await i.register(N, X, oe, le, L), m.clear(), t();
452
- } catch (P) {
453
- B(re(P, n));
454
- } finally {
455
- K(!1);
456
- }
457
- };
458
- if (h) {
459
- const d = a === "handoff_failed";
460
- return /* @__PURE__ */ e(
461
- "div",
462
- {
463
- className: "min-h-screen bg-background flex items-center justify-center p-4",
464
- dir: o ? "rtl" : "ltr",
465
- children: /* @__PURE__ */ s("div", { className: "w-full max-w-lg bg-card border border-border rounded-xl shadow-lg p-8 text-center space-y-4", children: [
466
- /* @__PURE__ */ e("h1", { className: "text-2xl font-bold", children: r?.name }),
467
- /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: d ? n("handoff_failed_title", "This sign-in link has expired or was already used.") : n("auth_page_disabled_title", "The sign-in page is currently disabled.") }),
468
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/80", children: d ? n("handoff_failed_description", "Open the chat again from where you came from.") : n("auth_page_disabled_description", "Please contact the administrator for access.") })
469
- ] })
470
- }
471
- );
472
- }
473
- return /* @__PURE__ */ e(
474
- "div",
475
- {
476
- className: "min-h-screen bg-background flex flex-col items-center justify-center p-4",
477
- dir: o ? "rtl" : "ltr",
478
- children: /* @__PURE__ */ s("div", { className: "w-full max-w-md bg-card border border-border rounded-xl shadow-lg p-6", children: [
479
- /* @__PURE__ */ e("div", { className: "text-center mb-6", children: /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground", children: r?.name }) }),
480
- /* @__PURE__ */ s("div", { className: "flex bg-muted p-1 rounded-lg mb-6", children: [
481
- /* @__PURE__ */ e(
482
- "button",
483
- {
484
- type: "button",
485
- onClick: () => {
486
- g("login"), B("");
487
- },
488
- className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${u === "login" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
489
- children: n("login_tab", "Login")
490
- }
491
- ),
492
- !c && /* @__PURE__ */ e(
493
- "button",
494
- {
495
- type: "button",
496
- onClick: () => {
497
- g("register"), B("");
498
- },
499
- className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${u === "register" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
500
- children: n("signup_tab", "Sign Up")
501
- }
502
- )
503
- ] }),
504
- u === "login" && /* @__PURE__ */ s("form", { onSubmit: de, className: "space-y-4", children: [
505
- /* @__PURE__ */ s("div", { className: "space-y-3", children: [
506
- /* @__PURE__ */ e(A, { htmlFor: "login-identity", children: b }),
507
- /* @__PURE__ */ e(
508
- F,
509
- {
510
- id: "login-identity",
511
- type: _,
512
- value: I,
513
- onChange: (d) => y(k(d.target.value)),
514
- required: !0,
515
- className: "text-start",
516
- placeholder: b,
517
- dir: "ltr"
518
- }
519
- )
520
- ] }),
521
- /* @__PURE__ */ s("div", { className: "space-y-3", children: [
522
- /* @__PURE__ */ e(A, { htmlFor: "login-pass", children: n("password", "Password") }),
523
- /* @__PURE__ */ e(
524
- F,
525
- {
526
- id: "login-pass",
527
- type: "password",
528
- value: U,
529
- onChange: (d) => D(d.target.value),
530
- required: !0,
531
- className: "text-start",
532
- placeholder: "••••••••",
533
- dir: "ltr"
534
- }
535
- )
536
- ] }),
537
- j && /* @__PURE__ */ e("div", { role: "alert", className: "text-sm text-destructive", children: j }),
538
- /* @__PURE__ */ e($, { type: "submit", disabled: Z, className: "w-full font-semibold", children: Z ? n("logging_in", "Logging in...") : n("login_button", "Login") })
539
- ] }),
540
- !c && u === "register" && /* @__PURE__ */ s("form", { onSubmit: Ie, className: "space-y-4", children: [
541
- p.map((d) => {
542
- const N = f[d], P = n(N.labelKey, N.labelDefault), l = (C) => d === "phone" ? Be(C) : C;
543
- return /* @__PURE__ */ s("div", { className: "space-y-3", children: [
544
- /* @__PURE__ */ e(A, { htmlFor: `reg-${d}`, children: P }),
545
- /* @__PURE__ */ e(
546
- F,
547
- {
548
- id: `reg-${d}`,
549
- type: N.inputType,
550
- value: T[d] ?? "",
551
- onChange: (C) => V(d, l(C.target.value)),
552
- required: p.length === 1,
553
- className: "text-start",
554
- placeholder: n(`${N.labelKey}_placeholder`, N.labelDefault),
555
- dir: "ltr"
556
- }
557
- )
558
- ] }, d);
559
- }),
560
- /* @__PURE__ */ s("div", { className: "space-y-3", children: [
561
- /* @__PURE__ */ e(A, { htmlFor: "reg-pass", children: n("password", "Password") }),
562
- /* @__PURE__ */ e(
563
- F,
564
- {
565
- id: "reg-pass",
566
- type: "password",
567
- value: X,
568
- onChange: (d) => z(d.target.value),
569
- required: !0,
570
- className: "text-start",
571
- placeholder: "••••••••",
572
- dir: "ltr"
573
- }
574
- )
575
- ] }),
576
- /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-4", children: [
577
- /* @__PURE__ */ s("div", { className: "space-y-3", children: [
578
- /* @__PURE__ */ e(A, { htmlFor: "reg-name", children: n("name", "Name") }),
579
- /* @__PURE__ */ e(
580
- F,
581
- {
582
- id: "reg-name",
583
- type: "text",
584
- value: oe,
585
- onChange: (d) => ve(d.target.value),
586
- required: !0,
587
- className: "text-start",
588
- placeholder: n("name_placeholder", "First Name")
589
- }
590
- )
591
- ] }),
592
- /* @__PURE__ */ s("div", { className: "space-y-3", children: [
593
- /* @__PURE__ */ e(A, { htmlFor: "reg-surname", children: n("surname", "Surname") }),
594
- /* @__PURE__ */ e(
595
- F,
596
- {
597
- id: "reg-surname",
598
- type: "text",
599
- value: le,
600
- onChange: (d) => ce(d.target.value),
601
- required: !0,
602
- className: "text-start",
603
- placeholder: n("surname_placeholder", "Last Name")
604
- }
605
- )
606
- ] })
607
- ] }),
608
- Y.map((d) => Te(d.condition, L) ? /* @__PURE__ */ s(
609
- "div",
610
- {
611
- className: "space-y-3 animate-in fade-in slide-in-from-top-1 duration-200",
612
- children: [
613
- /* @__PURE__ */ e(A, { htmlFor: `signup-${d.key}`, children: n(d.label) }),
614
- d.type === "select" ? /* @__PURE__ */ s(
615
- we,
616
- {
617
- value: String(L[d.key] || ""),
618
- onValueChange: (N) => M({ ...L, [d.key]: N }),
619
- required: d.required,
620
- dir: o ? "rtl" : "ltr",
621
- children: [
622
- /* @__PURE__ */ e(Se, { className: "bg-background text-start", children: /* @__PURE__ */ e(ke, { placeholder: n(d.placeholder || "select_placeholder") }) }),
623
- /* @__PURE__ */ e(Ce, { className: "rounded-xl", children: d.options?.map((N) => /* @__PURE__ */ e(_e, { value: String(N.value), children: n(N.label) }, String(N.value))) })
624
- ]
625
- }
626
- ) : d.type === "checkbox" ? /* @__PURE__ */ s("div", { className: "flex items-center gap-2 py-2", children: [
627
- /* @__PURE__ */ e(
628
- _a,
629
- {
630
- id: `signup-${d.key}`,
631
- checked: !!L[d.key],
632
- onCheckedChange: (N) => M({ ...L, [d.key]: !!N }),
633
- required: d.required
634
- }
635
- ),
636
- /* @__PURE__ */ e(
637
- "label",
638
- {
639
- htmlFor: `signup-${d.key}`,
640
- className: "text-sm text-muted-foreground cursor-pointer select-none",
641
- children: n(d.placeholder || d.label)
642
- }
643
- )
644
- ] }) : /* @__PURE__ */ e(
645
- F,
646
- {
647
- id: `signup-${d.key}`,
648
- type: d.type,
649
- value: L[d.key] || "",
650
- onChange: (N) => M({ ...L, [d.key]: N.target.value }),
651
- required: d.required,
652
- className: "text-start",
653
- placeholder: n(d.placeholder || "")
654
- }
655
- )
656
- ]
657
- },
658
- d.key
659
- ) : null),
660
- j && /* @__PURE__ */ e("div", { role: "alert", className: "text-sm text-destructive", children: j }),
661
- /* @__PURE__ */ e($, { type: "submit", disabled: Z, className: "w-full font-semibold", children: Z ? n("signing_up", "Signing up...") : n("signup_button", "Sign Up") })
662
- ] })
663
- ] })
664
- }
665
- );
666
- }
667
- const wn = "sidebar_state", Sn = 3600 * 24 * 7, kn = "19rem", Cn = "18rem", _n = "3rem", Tn = "b", vt = Q.createContext(null);
668
- function be() {
669
- const t = Q.useContext(vt);
670
- if (!t)
671
- throw new Error("useSidebar must be used within a SidebarProvider.");
672
- return t;
673
- }
674
- function In({
675
- defaultOpen: t = !0,
676
- open: a,
677
- onOpenChange: n,
678
- className: r,
679
- style: i,
680
- children: o,
681
- ...m
682
- }) {
683
- const u = it(), [g, c] = Q.useState(!1), [h, p] = Q.useState(t), f = a ?? h, b = Q.useCallback(
684
- (I) => {
685
- const y = typeof I == "function" ? I(f) : I;
686
- n ? n(y) : p(y), document.cookie = `${wn}=${y}; path=/; max-age=${Sn}`;
687
- },
688
- [n, f]
689
- ), _ = Q.useCallback(() => {
690
- u ? c((I) => !I) : b((I) => !I);
691
- }, [u, b, c]);
692
- Q.useEffect(() => {
693
- const I = (y) => {
694
- y.key === Tn && (y.metaKey || y.ctrlKey) && (y.preventDefault(), _());
695
- };
696
- return window.addEventListener("keydown", I), () => {
697
- window.removeEventListener("keydown", I);
698
- };
699
- }, [_]);
700
- const v = f ? "expanded" : "collapsed", k = Q.useMemo(
701
- () => ({
702
- state: v,
703
- open: f,
704
- setOpen: b,
705
- isMobile: u,
706
- openMobile: g,
707
- setOpenMobile: c,
708
- toggleSidebar: _
709
- }),
710
- [v, f, b, u, g, c, _]
711
- );
712
- return /* @__PURE__ */ e(vt.Provider, { value: k, children: /* @__PURE__ */ e(ot, { delayDuration: 0, children: /* @__PURE__ */ e(
713
- "div",
714
- {
715
- "data-slot": "sidebar-wrapper",
716
- style: {
717
- "--gentiq-sidebar-width": kn,
718
- "--gentiq-sidebar-width-icon": _n,
719
- ...i
720
- },
721
- className: x("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", r),
722
- ...m,
723
- children: o
724
- }
725
- ) }) });
726
- }
727
- function qn({
728
- side: t = "start",
729
- variant: a = "sidebar",
730
- collapsible: n = "offcanvas",
731
- className: r,
732
- children: i,
733
- ...o
734
- }) {
735
- const { isMobile: m, state: u, openMobile: g, setOpenMobile: c } = be(), { t: h } = q("sidebar");
736
- return n === "none" ? /* @__PURE__ */ e(
737
- "div",
738
- {
739
- "data-slot": "sidebar",
740
- className: x("bg-sidebar text-sidebar-foreground flex h-full w-(--gentiq-sidebar-width) flex-col", r),
741
- ...o,
742
- children: i
743
- }
744
- ) : m ? /* @__PURE__ */ e(Ta, { open: g, onOpenChange: c, ...o, children: /* @__PURE__ */ s(
745
- Ia,
746
- {
747
- onOpenAutoFocus: (p) => p.preventDefault(),
748
- "data-sidebar": "sidebar",
749
- "data-slot": "sidebar",
750
- "data-mobile": "true",
751
- className: "bg-sidebar text-sidebar-foreground w-(--gentiq-sidebar-width) p-0 [&>button]:hidden",
752
- style: {
753
- "--gentiq-sidebar-width": Cn
754
- },
755
- side: t,
756
- children: [
757
- /* @__PURE__ */ s(qa, { className: "sr-only", children: [
758
- /* @__PURE__ */ e(La, { children: h("title") }),
759
- /* @__PURE__ */ e(Ma, { children: h("mobile_description") })
760
- ] }),
761
- /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col", children: i })
762
- ]
763
- }
764
- ) }) : /* @__PURE__ */ s(
765
- "div",
766
- {
767
- className: "group peer text-sidebar-foreground hidden md:block",
768
- "data-state": u,
769
- "data-collapsible": u === "collapsed" ? n : "",
770
- "data-variant": a,
771
- "data-side": t,
772
- "data-slot": "sidebar",
773
- children: [
774
- /* @__PURE__ */ e(
775
- "div",
776
- {
777
- "data-slot": "sidebar-gap",
778
- className: x(
779
- "relative w-(--gentiq-sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
780
- "group-data-[collapsible=offcanvas]:w-0",
781
- a === "floating" || a === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--gentiq-sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--gentiq-sidebar-width-icon)"
782
- )
783
- }
784
- ),
785
- /* @__PURE__ */ e(
786
- "div",
787
- {
788
- "data-slot": "sidebar-container",
789
- className: x(
790
- "fixed inset-y-0 z-10 hidden h-svh w-(--gentiq-sidebar-width) transition-[inset-inline-start,inset-inline-end,width] duration-200 ease-linear md:flex",
791
- t === "start" ? "start-0 group-data-[collapsible=offcanvas]:start-[calc(var(--gentiq-sidebar-width)*-1)]" : "end-0 group-data-[collapsible=offcanvas]:end-[calc(var(--gentiq-sidebar-width)*-1)]",
792
- // Adjust the padding for floating and inset variants.
793
- a === "floating" || a === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--gentiq-sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--gentiq-sidebar-width-icon) group-data-[side=start]:border-e group-data-[side=end]:border-s",
794
- r
795
- ),
796
- ...o,
797
- children: /* @__PURE__ */ e(
798
- "div",
799
- {
800
- "data-sidebar": "sidebar",
801
- "data-slot": "sidebar-inner",
802
- className: "bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",
803
- children: i
804
- }
805
- )
806
- }
807
- )
808
- ]
809
- }
810
- );
811
- }
812
- function Ln({ className: t, onClick: a, ...n }) {
813
- const { toggleSidebar: r } = be(), { t: i } = q("sidebar");
814
- return /* @__PURE__ */ s(
815
- $,
816
- {
817
- "data-sidebar": "trigger",
818
- "data-slot": "sidebar-trigger",
819
- variant: "ghost",
820
- size: "icon",
821
- className: x("size-7", t),
822
- onClick: (o) => {
823
- a?.(o), r();
824
- },
825
- ...n,
826
- children: [
827
- /* @__PURE__ */ e(Xt, {}),
828
- /* @__PURE__ */ e("span", { className: "sr-only", children: i("toggle") })
829
- ]
830
- }
831
- );
832
- }
833
- function Mn({ className: t, ...a }) {
834
- return /* @__PURE__ */ e(
835
- "div",
836
- {
837
- "data-slot": "sidebar-content",
838
- "data-sidebar": "content",
839
- className: x(
840
- "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
841
- t
842
- ),
843
- ...a
844
- }
845
- );
846
- }
847
- function Pn({ className: t, ...a }) {
848
- return /* @__PURE__ */ e(
849
- "div",
850
- {
851
- "data-slot": "sidebar-group",
852
- "data-sidebar": "group",
853
- className: x("relative flex w-full min-w-0 flex-col p-2", t),
854
- ...a
855
- }
856
- );
857
- }
858
- function Ge({ className: t, ...a }) {
859
- return /* @__PURE__ */ e(
860
- "div",
861
- {
862
- "data-slot": "sidebar-group-content",
863
- "data-sidebar": "group-content",
864
- className: x("w-full text-sm", t),
865
- ...a
866
- }
867
- );
868
- }
869
- function xt({ className: t, ...a }) {
870
- return /* @__PURE__ */ e(
871
- "ul",
872
- {
873
- "data-slot": "sidebar-menu",
874
- "data-sidebar": "menu",
875
- className: x("flex w-full min-w-0 flex-col gap-1", t),
876
- ...a
877
- }
878
- );
879
- }
880
- function yt({ className: t, ...a }) {
881
- return /* @__PURE__ */ e(
882
- "li",
883
- {
884
- "data-slot": "sidebar-menu-item",
885
- "data-sidebar": "menu-item",
886
- className: x("group/menu-item relative", t),
887
- ...a
888
- }
889
- );
890
- }
891
- const An = Bt(
892
- "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-start text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pe-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
893
- {
894
- variants: {
895
- variant: {
896
- default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
897
- outline: "bg-background shadow-[0_0_0_1px_hsl(var(--gentiq-sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--gentiq-sidebar-accent))]"
898
- },
899
- size: {
900
- default: "h-8 text-sm",
901
- sm: "h-7 text-xs",
902
- lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
903
- }
904
- },
905
- defaultVariants: {
906
- variant: "default",
907
- size: "default"
908
- }
909
- }
910
- );
911
- function Nt({
912
- asChild: t = !1,
913
- isActive: a = !1,
914
- variant: n = "default",
915
- size: r = "default",
916
- tooltip: i,
917
- className: o,
918
- ...m
919
- }) {
920
- const u = t ? jt : "button", { isMobile: g, state: c } = be(), h = /* @__PURE__ */ e(
921
- u,
922
- {
923
- "data-slot": "sidebar-menu-button",
924
- "data-sidebar": "menu-button",
925
- "data-size": r,
926
- "data-active": a,
927
- className: x(An({ variant: n, size: r }), o),
928
- ...m
929
- }
930
- );
931
- return i ? (typeof i == "string" && (i = {
932
- children: i
933
- }), /* @__PURE__ */ s(lt, { children: [
934
- /* @__PURE__ */ e(ct, { asChild: !0, children: h }),
935
- /* @__PURE__ */ e(dt, { side: "right", align: "center", hidden: c !== "collapsed" || g, ...i })
936
- ] })) : h;
937
- }
938
- function wt({
939
- label: t,
940
- detail: a,
941
- meter: n,
942
- remaining: r,
943
- amount: i,
944
- resetsAt: o,
945
- action: m
946
- }) {
947
- const { t: u, i18n: g } = q(["quota"]), c = Ea(r, i);
948
- return /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
949
- /* @__PURE__ */ s("div", { className: "flex items-baseline justify-between gap-3 text-sm", children: [
950
- /* @__PURE__ */ s("span", { className: "font-medium text-foreground/80", children: [
951
- t,
952
- " ",
953
- a && /* @__PURE__ */ e("span", { className: "text-xs font-normal text-muted-foreground", children: a })
954
- ] }),
955
- /* @__PURE__ */ s("span", { className: "flex items-center gap-2", children: [
956
- /* @__PURE__ */ s("span", { className: "font-semibold tabular-nums text-foreground", children: [
957
- $e(n, r, g.language),
958
- /* @__PURE__ */ s("span", { className: "text-muted-foreground font-normal", children: [
959
- " / ",
960
- $e(n, i, g.language)
961
- ] })
962
- ] }),
963
- m
964
- ] })
965
- ] }),
966
- /* @__PURE__ */ e(
967
- "div",
968
- {
969
- className: "h-2 w-full bg-muted/50 rounded-full overflow-hidden",
970
- role: "meter",
971
- "aria-valuemin": 0,
972
- "aria-valuemax": i,
973
- "aria-valuenow": r,
974
- "aria-label": typeof t == "string" ? t : void 0,
975
- children: /* @__PURE__ */ e(
976
- "div",
977
- {
978
- className: x("h-full rounded-full transition-all duration-700", Pa(c)),
979
- style: { width: `${c}%` }
980
- }
981
- )
982
- }
983
- ),
984
- o && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: u("quota:resets_at", { datetime: mt(o, g.language) }) })
985
- ] });
986
- }
987
- function En({ windows: t, className: a, renderAction: n }) {
988
- const { t: r } = q(["quota"]);
989
- return /* @__PURE__ */ e("div", { className: x("space-y-4", a), children: t.map((i) => /* @__PURE__ */ e(
990
- wt,
991
- {
992
- label: ut(r, i.meter),
993
- detail: Aa(r, i),
994
- meter: i.meter,
995
- remaining: i.remaining,
996
- amount: i.amount,
997
- resetsAt: i.resets_at,
998
- action: n?.(i)
999
- },
1000
- i.key
1001
- )) });
1002
- }
1003
- function zn({ credits: t, action: a }) {
1004
- const { t: n } = q(["quota"]);
1005
- return /* @__PURE__ */ e(
1006
- wt,
1007
- {
1008
- label: n("quota:credits"),
1009
- detail: n("quota:credits_unit", { meter: ut(n, t.meter) }),
1010
- meter: t.meter,
1011
- remaining: t.remaining,
1012
- amount: t.granted,
1013
- action: a
1014
- }
1015
- );
1016
- }
1017
- const Rn = ["system", "light", "dark"], He = "h-11 w-full rounded-xl border-border/50 bg-muted/30 text-base", Ve = "rounded-xl border-border/40 bg-background shadow-xl", Ke = "rounded-lg py-2 text-base focus:bg-primary/10";
1018
- function Dn({
1019
- sectionMode: t = "editable",
1020
- themeMode: a = "editable",
1021
- languageMode: n = "editable"
1022
- } = {}) {
1023
- const { t: r, i18n: i } = q("settings"), o = H((T) => T.app), { theme: m, setTheme: u, locked: g } = se(), { language: c, setLanguage: h, locked: p, dir: f } = J(), b = Fe(), _ = Fe(), v = Qa(i, o?.languages), k = v.find((T) => T === c) ?? c.split("-")[0], I = !g && a !== "hidden", y = !p && n !== "hidden", U = t === "faded" || a === "faded", D = t === "faded" || n === "faded";
1024
- return /* @__PURE__ */ s("div", { className: "grid gap-6", children: [
1025
- I && /* @__PURE__ */ s(
1026
- "div",
1027
- {
1028
- className: `flex flex-col gap-3 ${U ? "opacity-60 pointer-events-none" : ""}`,
1029
- children: [
1030
- /* @__PURE__ */ e(A, { htmlFor: b, className: "px-1", children: r("general.theme") }),
1031
- /* @__PURE__ */ s(
1032
- we,
1033
- {
1034
- value: m,
1035
- onValueChange: (T) => u(T),
1036
- dir: f,
1037
- disabled: U,
1038
- children: [
1039
- /* @__PURE__ */ e(Se, { id: b, className: He, children: /* @__PURE__ */ e(ke, {}) }),
1040
- /* @__PURE__ */ e(Ce, { className: Ve, children: Rn.map((T) => /* @__PURE__ */ e(_e, { value: T, className: Ke, children: r(`general.themes.${T}`) }, T)) })
1041
- ]
1042
- }
1043
- )
1044
- ]
1045
- }
1046
- ),
1047
- y && /* @__PURE__ */ s(
1048
- "div",
1049
- {
1050
- className: `flex flex-col gap-3 ${D ? "opacity-60 pointer-events-none" : ""}`,
1051
- children: [
1052
- /* @__PURE__ */ e(A, { htmlFor: _, className: "px-1", children: r("general.language") }),
1053
- /* @__PURE__ */ s(we, { value: k, onValueChange: h, dir: f, disabled: D, children: [
1054
- /* @__PURE__ */ e(Se, { id: _, className: He, children: /* @__PURE__ */ e(ke, {}) }),
1055
- /* @__PURE__ */ e(Ce, { className: Ve, children: v.map((T) => /* @__PURE__ */ e(_e, { value: T, lang: T, className: Ke, children: Wa(T) }, T)) })
1056
- ] })
1057
- ]
1058
- }
1059
- )
1060
- ] });
1061
- }
1062
- function Fn({ trigger: t }) {
1063
- const { t: a, i18n: n } = q(["settings"]), r = H((l) => l.app), i = ee((l) => l.settings), o = ze(), m = tt(), u = Ot(), [g, c] = S(!1), { data: h, refetch: p } = $t({
1064
- enabled: g
1065
- }), f = Ae(null), { locked: b } = se(), { locked: _ } = J(), v = O(() => [
1066
- { id: "profile", label: a("sections.profile", "Profile"), icon: Yt },
1067
- { id: "general", label: a("sections.general"), icon: Zt },
1068
- { id: "account", label: a("sections.account", "Account"), icon: Jt }
1069
- ].filter((C) => {
1070
- const w = i?.sections?.[C.id];
1071
- if ((w?.mode ?? (w?.enabled === !1 ? "hidden" : "editable")) === "hidden") return !1;
1072
- if (C.id === "general") {
1073
- const me = w?.fields?.theme ?? "editable", xe = w?.fields?.language ?? "editable";
1074
- return !b && me !== "hidden" || !_ && xe !== "hidden";
1075
- }
1076
- return !0;
1077
- }), [a, i, b, _]), [k, I] = S(v[0]?.id || "profile"), y = Le(
1078
- (l, C, w = "editable") => {
1079
- const ue = i?.sections?.[l]?.fields;
1080
- return ue && ue[C] || w;
1081
- },
1082
- [i]
1083
- ), [U, D] = S(""), [T, te] = S(""), [V, X] = S(""), [z, oe] = S(""), [ve, le] = S(""), [ce, Y] = S(""), L = O(
1084
- () => r?.userMetadataFields?.filter((l) => l.showInProfile) || [],
1085
- [r?.userMetadataFields]
1086
- ), [M, j] = S({}), [B, Z] = S(!1), K = J().dir === "rtl", de = Le(async () => {
1087
- try {
1088
- p();
1089
- const l = await o.getMe();
1090
- D(l.name || ""), te(l.surname || ""), X(l.username || ""), oe(l.email || ""), le(l.phone || "");
1091
- const C = {};
1092
- L.forEach((w) => {
1093
- C[w.key] = l.metadata?.[w.key] ?? w.defaultValue ?? "";
1094
- }), j(C);
1095
- } catch (l) {
1096
- console.error("Failed to fetch user:", l), E.error(re(l, a));
1097
- }
1098
- }, [a, L, o, p]);
1099
- R(() => {
1100
- if (!g) {
1101
- f.current = null;
1102
- return;
1103
- }
1104
- (f.current === null || k === "account") && de(), f.current = k;
1105
- }, [g, k, de]), R(() => {
1106
- const l = { ...M };
1107
- let C = !1;
1108
- L.forEach((w) => {
1109
- w.condition && !Te(w.condition, M) && l[w.key] !== void 0 && (delete l[w.key], C = !0);
1110
- }), C && j(l);
1111
- }, [M, L]);
1112
- const Ie = async () => {
1113
- Z(!0);
1114
- try {
1115
- const l = {
1116
- name: U,
1117
- surname: T,
1118
- username: V || void 0,
1119
- email: z || void 0,
1120
- phone: ve || void 0,
1121
- metadata: M
1122
- };
1123
- ce && (l.password = ce);
1124
- const C = await o.updateMe(l);
1125
- m.setQueryData(u.currentUser(), C), E.success(a("profile.success", "Profile updated successfully")), Y(""), de();
1126
- } catch (l) {
1127
- E.error(re(l, a));
1128
- } finally {
1129
- Z(!1);
1130
- }
1131
- }, d = async () => {
1132
- if (window.confirm(a("account.logout_confirm", "Are you sure you want to logout?")))
1133
- try {
1134
- await o.logout(), window.location.reload();
1135
- } catch (l) {
1136
- E.error(re(l, a));
1137
- }
1138
- }, P = i?.sections?.account?.fields?.usage ?? "editable";
1139
- return /* @__PURE__ */ s(ht, { open: g, onOpenChange: c, children: [
1140
- /* @__PURE__ */ e(za, { asChild: !0, children: t || /* @__PURE__ */ e($, { variant: "ghost", size: "icon", className: "rounded-full", children: /* @__PURE__ */ e(Me, { className: "h-5 w-5" }) }) }),
1141
- /* @__PURE__ */ e(
1142
- gt,
1143
- {
1144
- dir: K ? "rtl" : "ltr",
1145
- className: x(
1146
- "w-full sm:w-[95vw] sm:max-w-[700px] p-0 gap-0 overflow-hidden rounded-t-2xl sm:rounded-3xl border-none shadow-lg bg-background h-[90vh] sm:h-[min(750px,90vh)]",
1147
- K && "rtl"
1148
- ),
1149
- children: /* @__PURE__ */ s("div", { className: "flex flex-col h-full w-full min-h-0 overflow-hidden", children: [
1150
- /* @__PURE__ */ s("div", { className: "w-full bg-muted/20 sm:bg-muted/30 border-b border-border/40 pt-12 sm:pt-6 flex flex-col shrink-0", children: [
1151
- /* @__PURE__ */ e("div", { className: "flex items-center justify-between px-4 sm:px-6 mb-2 sm:mb-4", children: /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
1152
- /* @__PURE__ */ e("div", { className: "bg-primary/10 p-1.5 rounded-lg", children: /* @__PURE__ */ e(Me, { className: "h-5 w-5 text-primary" }) }),
1153
- /* @__PURE__ */ e("span", { className: "font-bold text-lg", children: a("title", "Settings") })
1154
- ] }) }),
1155
- /* @__PURE__ */ e("div", { className: "w-full overflow-x-auto no-scrollbar pt-2 px-2 sm:px-4", children: /* @__PURE__ */ e("nav", { className: "flex items-center gap-2 sm:gap-6 w-max", children: v.map((l) => /* @__PURE__ */ s(
1156
- "button",
1157
- {
1158
- onClick: () => I(l.id),
1159
- className: x(
1160
- "flex items-center gap-1.5 sm:gap-2 pb-2 sm:pb-3 pt-1 px-2 sm:px-1 text-sm sm:text-base font-medium transition-all border-b-2 whitespace-nowrap shrink-0",
1161
- k === l.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border",
1162
- l.id !== "general" && i?.sections?.[l.id]?.mode === "faded" && "opacity-50 pointer-events-none select-none"
1163
- ),
1164
- children: [
1165
- /* @__PURE__ */ e(
1166
- l.icon,
1167
- {
1168
- className: x(
1169
- "h-3.5 w-3.5 sm:h-4 sm:w-4 transition-transform",
1170
- k === l.id && "scale-110"
1171
- )
1172
- }
1173
- ),
1174
- l.label
1175
- ]
1176
- },
1177
- l.id
1178
- )) }) })
1179
- ] }),
1180
- /* @__PURE__ */ e("div", { className: "flex-1 relative min-h-0 h-full bg-background", children: /* @__PURE__ */ s("div", { className: "absolute inset-0 overflow-y-auto p-5 sm:p-8 pt-12 sm:pt-12 custom-scrollbar", children: [
1181
- k === "profile" && /* @__PURE__ */ s("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1182
- /* @__PURE__ */ s("div", { children: [
1183
- /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: a("profile.title", "Profile Information") }),
1184
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: a("profile.subtitle", "Update your personal details below.") })
1185
- ] }),
1186
- /* @__PURE__ */ s("div", { className: "grid gap-6", children: [
1187
- /* @__PURE__ */ s("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
1188
- y("profile", "name") !== "hidden" && /* @__PURE__ */ s(
1189
- "div",
1190
- {
1191
- className: x(
1192
- "flex flex-col gap-3",
1193
- y("profile", "name") === "faded" && "opacity-50 pointer-events-none select-none"
1194
- ),
1195
- children: [
1196
- /* @__PURE__ */ e(A, { htmlFor: "name", className: "px-1", children: a("profile.name", "First Name") }),
1197
- /* @__PURE__ */ e(
1198
- F,
1199
- {
1200
- id: "name",
1201
- value: U,
1202
- onChange: (l) => D(l.target.value),
1203
- disabled: y("profile", "name") === "faded",
1204
- className: x(
1205
- "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11",
1206
- "text-start"
1207
- )
1208
- }
1209
- )
1210
- ]
1211
- }
1212
- ),
1213
- y("profile", "surname") !== "hidden" && /* @__PURE__ */ s(
1214
- "div",
1215
- {
1216
- className: x(
1217
- "flex flex-col gap-3",
1218
- y("profile", "surname") === "faded" && "opacity-50 pointer-events-none select-none"
1219
- ),
1220
- children: [
1221
- /* @__PURE__ */ e(A, { htmlFor: "surname", className: "px-1", children: a("profile.surname", "Last Name") }),
1222
- /* @__PURE__ */ e(
1223
- F,
1224
- {
1225
- id: "surname",
1226
- value: T,
1227
- onChange: (l) => te(l.target.value),
1228
- disabled: y("profile", "surname") === "faded",
1229
- className: x(
1230
- "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11",
1231
- "text-start"
1232
- )
1233
- }
1234
- )
1235
- ]
1236
- }
1237
- )
1238
- ] }),
1239
- [
1240
- { key: "username", icon: ea, value: V, set: X },
1241
- { key: "email", icon: ta, value: z, set: oe },
1242
- { key: "phone", icon: aa, value: ve, set: le }
1243
- ].map(({ key: l, icon: C, value: w, set: ue }) => {
1244
- const me = y("profile", l);
1245
- return me === "hidden" ? null : /* @__PURE__ */ s(
1246
- "div",
1247
- {
1248
- className: x(
1249
- "flex flex-col gap-3",
1250
- me === "faded" && "opacity-50 pointer-events-none select-none"
1251
- ),
1252
- children: [
1253
- /* @__PURE__ */ e(A, { htmlFor: l, className: "px-1 text-start", children: a(`profile.${l}`) }),
1254
- /* @__PURE__ */ s("div", { className: "relative", children: [
1255
- /* @__PURE__ */ e(C, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground start-3" }),
1256
- /* @__PURE__ */ e(
1257
- F,
1258
- {
1259
- id: l,
1260
- type: l === "email" ? "email" : "text",
1261
- value: w,
1262
- onChange: (xe) => ue(
1263
- l === "phone" ? xe.target.value.replace(/[^0-9]/g, "") : xe.target.value
1264
- ),
1265
- disabled: me === "faded",
1266
- className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary ps-10 pe-3 text-start",
1267
- dir: "ltr"
1268
- }
1269
- )
1270
- ] })
1271
- ]
1272
- },
1273
- l
1274
- );
1275
- }),
1276
- y("profile", "password") !== "hidden" && /* @__PURE__ */ s(
1277
- "div",
1278
- {
1279
- className: x(
1280
- "flex flex-col gap-3",
1281
- y("profile", "password") === "faded" && "opacity-50 pointer-events-none select-none"
1282
- ),
1283
- children: [
1284
- /* @__PURE__ */ e(A, { htmlFor: "pass", className: "px-1 text-start", children: a("profile.password", "New Password") }),
1285
- /* @__PURE__ */ s("div", { className: "relative", children: [
1286
- /* @__PURE__ */ e(na, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground start-3" }),
1287
- /* @__PURE__ */ e(
1288
- F,
1289
- {
1290
- id: "pass",
1291
- type: "password",
1292
- value: ce,
1293
- onChange: (l) => Y(l.target.value),
1294
- disabled: y("profile", "password") === "faded",
1295
- placeholder: a(
1296
- "profile.password_placeholder",
1297
- "Leave empty to keep current"
1298
- ),
1299
- className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary ps-10 pe-3 text-start",
1300
- dir: "ltr"
1301
- }
1302
- )
1303
- ] })
1304
- ]
1305
- }
1306
- ),
1307
- L.map((l) => {
1308
- const C = y("profile", l.key, l.mode || "editable");
1309
- return C === "hidden" || !Te(l.condition, M) ? null : /* @__PURE__ */ s(
1310
- "div",
1311
- {
1312
- className: x(
1313
- "flex flex-col gap-3 animate-in fade-in slide-in-from-top-1 duration-200",
1314
- C === "faded" && "opacity-50 pointer-events-none select-none"
1315
- ),
1316
- children: [
1317
- /* @__PURE__ */ e(A, { htmlFor: `profile-${l.key}`, className: "px-1", children: a(l.label) }),
1318
- l.type === "select" ? /* @__PURE__ */ s(
1319
- we,
1320
- {
1321
- value: String(M[l.key] || ""),
1322
- onValueChange: (w) => j({ ...M, [l.key]: w }),
1323
- disabled: C === "faded",
1324
- dir: K ? "rtl" : "ltr",
1325
- children: [
1326
- /* @__PURE__ */ e(Se, { className: "bg-muted/30 border-border/50 rounded-xl focus:ring-primary h-11", children: /* @__PURE__ */ e(
1327
- ke,
1328
- {
1329
- placeholder: a(l.placeholder || "profile.select_placeholder")
1330
- }
1331
- ) }),
1332
- /* @__PURE__ */ e(Ce, { className: "rounded-xl border-border/40 shadow-xl bg-background", children: l.options?.map((w) => /* @__PURE__ */ e(
1333
- _e,
1334
- {
1335
- value: String(w.value),
1336
- className: "rounded-lg focus:bg-primary/10",
1337
- children: a(w.label)
1338
- },
1339
- String(w.value)
1340
- )) })
1341
- ]
1342
- }
1343
- ) : l.type === "checkbox" ? /* @__PURE__ */ s("div", { className: "flex items-center gap-3 px-1 py-1", children: [
1344
- /* @__PURE__ */ e(
1345
- "input",
1346
- {
1347
- id: `profile-${l.key}`,
1348
- type: "checkbox",
1349
- checked: !!M[l.key],
1350
- disabled: C === "faded",
1351
- onChange: (w) => j({ ...M, [l.key]: w.target.checked }),
1352
- className: "h-5 w-5 rounded-md border-border/50 bg-muted/30 text-primary focus:ring-primary transition-all cursor-pointer"
1353
- }
1354
- ),
1355
- /* @__PURE__ */ e(
1356
- A,
1357
- {
1358
- htmlFor: `profile-${l.key}`,
1359
- className: "text-sm font-medium text-muted-foreground cursor-pointer",
1360
- children: a(l.placeholder || l.label)
1361
- }
1362
- )
1363
- ] }) : /* @__PURE__ */ e(
1364
- F,
1365
- {
1366
- id: `profile-${l.key}`,
1367
- type: l.type,
1368
- value: M[l.key] || "",
1369
- disabled: C === "faded",
1370
- onChange: (w) => j({ ...M, [l.key]: w.target.value }),
1371
- placeholder: a(l.placeholder || ""),
1372
- className: x(
1373
- "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11",
1374
- "text-start"
1375
- )
1376
- }
1377
- )
1378
- ]
1379
- },
1380
- l.key
1381
- );
1382
- }),
1383
- /* @__PURE__ */ e("div", { className: "pt-4 flex justify-center", children: /* @__PURE__ */ s(
1384
- $,
1385
- {
1386
- onClick: Ie,
1387
- disabled: B,
1388
- className: "w-full sm:w-auto px-8 rounded-xl gap-2 font-semibold h-11 transition-all active:scale-[0.98]",
1389
- children: [
1390
- /* @__PURE__ */ e(ra, { className: "h-4 w-4" }),
1391
- B ? a("profile.saving", "Saving...") : a("profile.save", "Save Changes")
1392
- ]
1393
- }
1394
- ) })
1395
- ] })
1396
- ] }),
1397
- k === "general" && /* @__PURE__ */ s("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1398
- /* @__PURE__ */ s("div", { children: [
1399
- /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: a("general.title") }),
1400
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: a("general.subtitle") })
1401
- ] }),
1402
- /* @__PURE__ */ e(
1403
- Dn,
1404
- {
1405
- sectionMode: i?.sections?.general?.mode ?? "editable",
1406
- themeMode: y("general", "theme"),
1407
- languageMode: y("general", "language")
1408
- }
1409
- )
1410
- ] }),
1411
- k === "account" && /* @__PURE__ */ s("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1412
- /* @__PURE__ */ s("div", { children: [
1413
- /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: a("account.title", "Account & Usage") }),
1414
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: a("account.subtitle", "Monitor your quotas and manage your session.") })
1415
- ] }),
1416
- /* @__PURE__ */ s("div", { className: "space-y-6", children: [
1417
- P !== "hidden" && h && /* @__PURE__ */ s(
1418
- "div",
1419
- {
1420
- className: x(
1421
- "p-6 bg-muted/30 rounded-3xl border border-border/40 space-y-5",
1422
- P === "faded" && "opacity-50"
1423
- ),
1424
- children: [
1425
- /* @__PURE__ */ s("div", { className: "flex items-start justify-between gap-3", children: [
1426
- /* @__PURE__ */ s(A, { className: "text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2", children: [
1427
- h.kind === "credits" ? /* @__PURE__ */ e(sa, { className: "h-4 w-4" }) : h.kind === "unlimited" ? /* @__PURE__ */ e(ia, { className: "h-4 w-4" }) : /* @__PURE__ */ e(oa, { className: "h-4 w-4" }),
1428
- a("account.usage", "Your usage")
1429
- ] }),
1430
- /* @__PURE__ */ s("div", { className: "text-end", children: [
1431
- /* @__PURE__ */ e("p", { className: "text-sm font-semibold text-foreground", children: h.kind === "credits" ? a("account.on_credits", "Credits") : h.kind === "unlimited" ? a("account.unlimited", "No usage limits") : h.plan?.name ?? a("account.custom_plan", "Custom plan") }),
1432
- h.ends_at && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: a("account.plan_until", {
1433
- datetime: mt(h.ends_at, n.language)
1434
- }) })
1435
- ] })
1436
- ] }),
1437
- h.kind === "plan" && (h.windows.length > 0 ? /* @__PURE__ */ e(En, { windows: h.windows }) : /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: a("account.unlimited", "No usage limits") })),
1438
- h.kind === "credits" && h.credits && /* @__PURE__ */ e(zn, { credits: h.credits }),
1439
- h.kind === "unlimited" && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: a(
1440
- "account.unlimited_help",
1441
- "You can use the assistant as much as you like."
1442
- ) })
1443
- ]
1444
- }
1445
- ),
1446
- /* @__PURE__ */ e("div", { className: "pt-2 flex flex-col gap-3", children: y("account", "logout") !== "hidden" && /* @__PURE__ */ s(
1447
- $,
1448
- {
1449
- variant: "destructive",
1450
- onClick: () => {
1451
- d();
1452
- },
1453
- disabled: y("account", "logout") === "faded",
1454
- className: x(
1455
- "rounded-2xl gap-2 font-bold h-12 transition-all active:scale-[0.98]",
1456
- y("account", "logout") === "faded" && "opacity-50 pointer-events-none"
1457
- ),
1458
- children: [
1459
- /* @__PURE__ */ e(la, { className: "h-4 w-4" }),
1460
- a("account.logout", "Logout from Account")
1461
- ]
1462
- }
1463
- ) })
1464
- ] })
1465
- ] })
1466
- ] }) }),
1467
- r?.showVersionInSettings !== !1 && r?.version && /* @__PURE__ */ e("div", { className: "shrink-0 border-t border-border/30 px-5 sm:px-8 py-3 flex justify-center bg-background/80 opacity-70", children: /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground text-center", dir: "ltr", children: /* @__PURE__ */ s("span", { className: "font-mono text-foreground/75", children: [
1468
- "v",
1469
- r.version
1470
- ] }) }) })
1471
- ] })
1472
- }
1473
- )
1474
- ] });
1475
- }
1476
- function St({ hideActions: t = !1 }) {
1477
- const a = Ze(), { t: n } = q(["sidebar", "settings"]), r = H((v) => v.app), i = ee((v) => v.history), o = ee((v) => v.headerActionsEnabled), { HeaderActions: m, headerActions: u, UsageMeter: g } = ie(), c = O(
1478
- () => (u ?? []).filter(
1479
- (v) => o?.[v.id] ?? v.defaultEnabled ?? !0
1480
- ),
1481
- [u, o]
1482
- ), h = it(), { resolvedTheme: p } = se(), f = !t && (i?.enabled ?? !0), b = O(() => r?.logo ? typeof r.logo == "string" ? r.logo : p === "dark" ? r.logo.dark : r.logo.light : Ra, [r?.logo, p]), _ = r?.name || "Gentiq";
1483
- return /* @__PURE__ */ s("header", { className: "relative flex items-center justify-between px-3 md:px-4 h-14 sticky top-0 z-40 w-full bg-background border-b border-border/30 transition-all duration-300", children: [
1484
- /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5 md:gap-2 min-w-[36px] md:min-w-[80px]", children: [
1485
- f && /* @__PURE__ */ e(Ln, { className: "hover:bg-accent/60 transition-all duration-200 active:scale-95 rounded-lg size-9" }),
1486
- !t && /* @__PURE__ */ s(lt, { children: [
1487
- /* @__PURE__ */ e(ct, { asChild: !0, children: /* @__PURE__ */ e(
1488
- "button",
1489
- {
1490
- type: "button",
1491
- className: x(
1492
- "flex items-center justify-center size-9 rounded-lg hover:bg-accent/60 transition-all duration-200 active:scale-95 text-muted-foreground hover:text-primary",
1493
- f && "md:hidden"
1494
- ),
1495
- onClick: () => a?.selectThread(null),
1496
- "aria-label": n("new_chat"),
1497
- children: /* @__PURE__ */ e(at, { className: "size-5" })
1498
- }
1499
- ) }),
1500
- /* @__PURE__ */ e(dt, { side: "bottom", className: "text-xs", children: n("new_chat") })
1501
- ] })
1502
- ] }),
1503
- /* @__PURE__ */ e("div", { className: "absolute inset-0 m-auto size-fit", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2.5 select-none animate-in fade-in zoom-in-95 duration-500", children: /* @__PURE__ */ e("img", { src: b, alt: _, className: "size-8 object-contain" }) }) }),
1504
- /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 min-w-[36px] md:min-w-[80px] justify-end", children: !t && /* @__PURE__ */ s(fe, { children: [
1505
- m && /* @__PURE__ */ e(m, { isMobile: h }),
1506
- c.map(({ id: v, component: k }) => /* @__PURE__ */ e(k, { isMobile: h }, v)),
1507
- r?.showUsageBar && /* @__PURE__ */ e(g, { details: r.showUsageDetails ?? !0, isMobile: h }),
1508
- r?.showSettings !== !1 && /* @__PURE__ */ e(
1509
- Fn,
1510
- {
1511
- trigger: /* @__PURE__ */ e(
1512
- "button",
1513
- {
1514
- type: "button",
1515
- "aria-label": n("settings:title"),
1516
- className: "flex items-center justify-center size-9 rounded-lg hover:bg-accent/60 transition-all duration-200 active:scale-95 text-muted-foreground hover:text-primary",
1517
- children: /* @__PURE__ */ e(Me, { className: "size-5" })
1518
- }
1519
- )
1520
- }
1521
- )
1522
- ] }) })
1523
- ] });
1524
- }
1525
- function On(t) {
1526
- return /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e($n, { ...t }) });
1527
- }
1528
- function $n({ shareId: t }) {
1529
- const [a, n] = S(
1530
- null
1531
- ), [r, i] = S(!0), [o, m] = S(null), { t: u } = q(["chat", "errors"]), { MessageList: g } = ie(), c = ze(), h = Ae(/* @__PURE__ */ new Set());
1532
- return R(() => () => {
1533
- h.current.forEach((p) => URL.revokeObjectURL(p)), h.current.clear();
1534
- }, []), R(() => {
1535
- if (!t) return;
1536
- let p = !1;
1537
- return (async () => {
1538
- try {
1539
- i(!0);
1540
- const b = await c.getSharedThread(t), _ = await Ya(
1541
- Za(b.items),
1542
- async (v) => {
1543
- try {
1544
- const k = await c.getPublicAttachmentBlobUrl(t, v);
1545
- return h.current.add(k), k;
1546
- } catch (k) {
1547
- return console.error("Failed to resolve shared attachment:", v, k), "";
1548
- }
1549
- }
1550
- );
1551
- p || n({ id: b.id, messages: _ });
1552
- } catch (b) {
1553
- if (p) return;
1554
- console.error("Failed to fetch shared chat:", b), m(b);
1555
- } finally {
1556
- p || i(!1);
1557
- }
1558
- })(), () => {
1559
- p = !0;
1560
- };
1561
- }, [t, c]), r ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center bg-background", children: /* @__PURE__ */ e(Da, {}) }) : a ? /* @__PURE__ */ s("div", { className: "relative flex flex-col h-dvh overflow-hidden bg-background", children: [
1562
- /* @__PURE__ */ e(St, { hideActions: !0 }),
1563
- /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 overflow-hidden relative flex flex-col", children: /* @__PURE__ */ e(Ee.Root, { readonly: !0, children: /* @__PURE__ */ e(et.Root, { messages: a.messages, className: "flex min-h-0 flex-1 flex-col", children: /* @__PURE__ */ e(g, { className: "pb-8" }) }) }) })
1564
- ] }) : /* @__PURE__ */ s("div", { className: "flex h-dvh flex-col items-center justify-center p-4 text-center bg-background", children: [
1565
- /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-destructive mb-2 font-display", children: u("shared_not_found_title") }),
1566
- /* @__PURE__ */ e("p", { className: "text-muted-foreground max-w-md", children: Xa(o) ? re(o, u) : u("shared_not_found_description") })
1567
- ] });
1568
- }
1569
- function Un() {
1570
- const { t } = q("sidebar"), { isMobile: a, setOpenMobile: n } = be();
1571
- return /* @__PURE__ */ e(xt, { className: "mt-2 mb-6 px-2 group-data-[collapsible=icon]:px-0", children: /* @__PURE__ */ e(yt, { className: "group-data-[collapsible=icon]:flex group-data-[collapsible=icon]:justify-center", children: /* @__PURE__ */ e(
1572
- Nt,
1573
- {
1574
- asChild: !0,
1575
- tooltip: t("tooltip_new_conversation"),
1576
- className: "h-10 rounded-xl bg-surface border border-border/60 shadow-sm shadow-foreground/[0.03] text-foreground/85 hover:bg-surface hover:border-border hover:text-foreground active:bg-surface transition-[width,height,padding,border-color,color] duration-200 group-data-[collapsible=icon]:mx-auto group/new-chat",
1577
- children: /* @__PURE__ */ s(
1578
- G.New,
1579
- {
1580
- onOpen: () => a && n(!1),
1581
- className: "flex items-center gap-2.5 px-3 group-data-[collapsible=icon]:justify-center",
1582
- children: [
1583
- /* @__PURE__ */ e(
1584
- at,
1585
- {
1586
- "aria-hidden": !0,
1587
- className: "size-4! shrink-0 text-muted-foreground transition-colors group-hover/new-chat:text-foreground"
1588
- }
1589
- ),
1590
- /* @__PURE__ */ e("span", { className: "text-sm font-medium group-data-[collapsible=icon]:hidden", children: t("new_conversation") })
1591
- ]
1592
- }
1593
- )
1594
- }
1595
- ) }) });
1596
- }
1597
- function jn() {
1598
- const { t } = q("sidebar");
1599
- return /* @__PURE__ */ e(G.LoadMore, { className: "group/more min-h-4 w-full", children: /* @__PURE__ */ s(
1600
- "div",
1601
- {
1602
- role: "status",
1603
- className: "hidden group-data-[loading]/more:flex flex-col items-center gap-2 p-4 pt-0 opacity-60",
1604
- children: [
1605
- /* @__PURE__ */ e(
1606
- "div",
1607
- {
1608
- "aria-hidden": !0,
1609
- className: "size-4 border-2 border-primary border-t-transparent rounded-full animate-spin motion-reduce:animate-none"
1610
- }
1611
- ),
1612
- /* @__PURE__ */ e("span", { className: "text-xs uppercase tracking-wider font-medium", children: t("loading_more") })
1613
- ]
1614
- }
1615
- ) });
1616
- }
1617
- function Bn() {
1618
- const { t } = q("sidebar");
1619
- return /* @__PURE__ */ s(
1620
- ye.Root,
1621
- {
1622
- onRenamed: () => E.success(t("rename_success")),
1623
- onRenameFailed: () => E.error(t("rename_failed")),
1624
- className: "flex items-center gap-1 px-2 py-1.5 w-full",
1625
- children: [
1626
- /* @__PURE__ */ e(
1627
- ye.Input,
1628
- {
1629
- "aria-label": t("rename_label"),
1630
- className: "h-8 min-w-0 flex-1 rounded-md border border-input bg-transparent px-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"
1631
- }
1632
- ),
1633
- /* @__PURE__ */ e(ye.Save, { asChild: !0, children: /* @__PURE__ */ e(
1634
- $,
1635
- {
1636
- type: "submit",
1637
- size: "icon",
1638
- variant: "ghost",
1639
- "aria-label": t("save"),
1640
- className: "size-8 shrink-0 text-primary hover:bg-primary/10",
1641
- children: /* @__PURE__ */ e(ca, { "aria-hidden": !0, className: "size-4" })
1642
- }
1643
- ) }),
1644
- /* @__PURE__ */ e(ye.Cancel, { asChild: !0, children: /* @__PURE__ */ e(
1645
- $,
1646
- {
1647
- type: "button",
1648
- size: "icon",
1649
- variant: "ghost",
1650
- "aria-label": t("cancel"),
1651
- className: "size-8 shrink-0 text-destructive hover:bg-destructive/10",
1652
- children: /* @__PURE__ */ e(da, { "aria-hidden": !0, className: "size-4" })
1653
- }
1654
- ) })
1655
- ]
1656
- }
1657
- );
1658
- }
1659
- function Gn({ open: t, onOpenChange: a }) {
1660
- const { t: n } = q(["sidebar", "errors"]), { remove: r } = Re(), i = async () => {
1661
- a(!1);
1662
- try {
1663
- await r();
1664
- } catch {
1665
- E.error(n("errors:thread_delete_failed"));
1666
- return;
1667
- }
1668
- E.success(n("chat_deleted_success"));
1669
- };
1670
- return /* @__PURE__ */ e(ht, { open: t, onOpenChange: a, children: /* @__PURE__ */ s(gt, { children: [
1671
- /* @__PURE__ */ s(Fa, { children: [
1672
- /* @__PURE__ */ e(Oa, { children: n("delete_confirm_title") }),
1673
- /* @__PURE__ */ e($a, { children: n("delete_confirm_description") })
1674
- ] }),
1675
- /* @__PURE__ */ s(Ua, { children: [
1676
- /* @__PURE__ */ e($, { variant: "outline", onClick: () => a(!1), children: n("cancel") }),
1677
- /* @__PURE__ */ e($, { variant: "destructive", onClick: () => {
1678
- i();
1679
- }, autoFocus: !0, children: n("delete") })
1680
- ] })
1681
- ] }) });
1682
- }
1683
- const kt = qt({
1684
- pin: !0,
1685
- share: !0,
1686
- rename: !0,
1687
- delete: !0
1688
- }), ge = "cursor-pointer flex items-center gap-2";
1689
- function Hn() {
1690
- const { t } = q("sidebar"), { dir: a } = J(), n = We(kt), { thread: r, setPinned: i, share: o, unshare: m, startRenaming: u } = Re(), [g, c] = S(!1);
1691
- if (!n.pin && !n.share && !n.rename && !n.delete) return null;
1692
- const h = async () => {
1693
- try {
1694
- await i(!r.pinned), E.success(r.pinned ? t("unpinned_success") : t("pinned_success"));
1695
- } catch {
1696
- E.error(t("pin_failed"));
1697
- }
1698
- }, p = async () => {
1699
- try {
1700
- const b = await o();
1701
- await navigator.clipboard.writeText(`${window.location.origin}${b}`), E.success(t("share_success"), { description: t("share_description") });
1702
- } catch {
1703
- E.error(t("share_failed"));
1704
- }
1705
- }, f = async () => {
1706
- try {
1707
- await m(), E.success(t("unshare_success"));
1708
- } catch {
1709
- E.error(t("unshare_failed"));
1710
- }
1711
- };
1712
- return /* @__PURE__ */ s(fe, { children: [
1713
- /* @__PURE__ */ s(ja, { dir: a, children: [
1714
- /* @__PURE__ */ e(Ba, { asChild: !0, children: /* @__PURE__ */ e(
1715
- $,
1716
- {
1717
- variant: "ghost",
1718
- size: "icon",
1719
- "aria-label": t("thread_actions", { title: r.title ?? t("new_conversation") }),
1720
- className: "size-7 rounded-full opacity-100 md:opacity-0 md:group-hover/sidebar-menu-item:opacity-100 md:group-focus-within/sidebar-menu-item:opacity-100 focus-visible:opacity-100 hover:bg-accent hover:text-accent-foreground data-[state=open]:opacity-100 transition-all",
1721
- children: /* @__PURE__ */ e(ua, { "aria-hidden": !0, className: "size-3.5" })
1722
- }
1723
- ) }),
1724
- /* @__PURE__ */ s(Ga, { align: "end", className: "min-w-[120px] p-1", children: [
1725
- n.pin && /* @__PURE__ */ s(he, { onSelect: () => {
1726
- h();
1727
- }, className: ge, children: [
1728
- r.pinned ? /* @__PURE__ */ e(ma, { "aria-hidden": !0, className: "size-4" }) : /* @__PURE__ */ e(nt, { "aria-hidden": !0, className: "size-4" }),
1729
- /* @__PURE__ */ e("span", { children: r.pinned ? t("unpin_conversation") : t("pin_conversation") })
1730
- ] }),
1731
- n.share && /* @__PURE__ */ s(he, { onSelect: () => {
1732
- p();
1733
- }, className: ge, children: [
1734
- /* @__PURE__ */ e(ha, { "aria-hidden": !0, className: "size-4" }),
1735
- /* @__PURE__ */ e("span", { children: t("share_conversation") })
1736
- ] }),
1737
- n.share && r.shared && /* @__PURE__ */ s(he, { onSelect: () => {
1738
- f();
1739
- }, className: ge, children: [
1740
- /* @__PURE__ */ e(ga, { "aria-hidden": !0, className: "size-4" }),
1741
- /* @__PURE__ */ e("span", { children: t("stop_sharing") })
1742
- ] }),
1743
- n.rename && /* @__PURE__ */ s(he, { onSelect: u, className: ge, children: [
1744
- /* @__PURE__ */ e(pa, { "aria-hidden": !0, className: "size-4" }),
1745
- /* @__PURE__ */ e("span", { children: t("rename_conversation") })
1746
- ] }),
1747
- n.delete && /* @__PURE__ */ s(
1748
- he,
1749
- {
1750
- onSelect: () => c(!0),
1751
- className: `${ge} text-destructive focus:text-destructive focus:bg-destructive/10`,
1752
- children: [
1753
- /* @__PURE__ */ e(fa, { "aria-hidden": !0, className: "size-4" }),
1754
- /* @__PURE__ */ e("span", { children: t("delete_conversation") })
1755
- ]
1756
- }
1757
- )
1758
- ] })
1759
- ] }),
1760
- n.delete && /* @__PURE__ */ e(Gn, { open: g, onOpenChange: c })
1761
- ] });
1762
- }
1763
- function Vn() {
1764
- const { t } = q("sidebar"), { isMobile: a, setOpenMobile: n } = be(), { thread: r, isRenaming: i } = Re();
1765
- return /* @__PURE__ */ e(G.Item, { asChild: !0, children: /* @__PURE__ */ e(yt, { className: "group/sidebar-menu-item relative", children: i ? /* @__PURE__ */ e(Bn, {}) : /* @__PURE__ */ s(fe, { children: [
1766
- /* @__PURE__ */ e(
1767
- Nt,
1768
- {
1769
- asChild: !0,
1770
- className: "h-auto py-2.5 px-3 opacity-70 hover:opacity-100 aria-[current=page]:bg-accent aria-[current=page]:opacity-100 aria-busy:thread-streaming",
1771
- children: /* @__PURE__ */ s(
1772
- G.ItemTrigger,
1773
- {
1774
- onOpen: () => a && n(!1),
1775
- className: "flex flex-col items-start gap-0.5 w-full overflow-hidden pe-16",
1776
- children: [
1777
- /* @__PURE__ */ e(
1778
- G.ItemTitle,
1779
- {
1780
- fallback: t("new_conversation"),
1781
- className: "truncate w-full text-start font-medium text-sm"
1782
- }
1783
- ),
1784
- /* @__PURE__ */ e(G.ItemTime, { className: "w-full text-start text-xs opacity-60" })
1785
- ]
1786
- }
1787
- )
1788
- }
1789
- ),
1790
- /* @__PURE__ */ s("div", { className: "absolute top-1/2 -translate-y-1/2 end-1.5 flex items-center gap-1 z-10", children: [
1791
- r.pinned && /* @__PURE__ */ s("span", { className: "md:absolute md:inset-0 md:m-auto md:size-3.5 md:group-hover/sidebar-menu-item:opacity-0 md:group-focus-within/sidebar-menu-item:opacity-0 transition-opacity pointer-events-none", children: [
1792
- /* @__PURE__ */ e(nt, { "aria-hidden": !0, className: "size-3.5 text-primary opacity-70" }),
1793
- /* @__PURE__ */ e("span", { className: "sr-only", children: t("pinned") })
1794
- ] }),
1795
- /* @__PURE__ */ e(Hn, {})
1796
- ] })
1797
- ] }) }) });
1798
- }
1799
- function Kn() {
1800
- const { t } = q("sidebar");
1801
- return /* @__PURE__ */ s("div", { className: "relative group/search", children: [
1802
- /* @__PURE__ */ e(
1803
- ba,
1804
- {
1805
- "aria-hidden": !0,
1806
- className: "absolute start-3 top-1/2 -translate-y-1/2 size-4 opacity-40 group-focus-within/search:opacity-70 transition-opacity"
1807
- }
1808
- ),
1809
- /* @__PURE__ */ e(
1810
- G.Search,
1811
- {
1812
- "aria-label": t("search_conversations"),
1813
- placeholder: t("search_conversations"),
1814
- className: "flex w-full min-w-0 ps-9 pe-3 h-10 text-base md:text-sm bg-accent/15 border border-border/40 rounded-xl outline-none transition-all placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-primary/20 [&::-webkit-search-cancel-button]:appearance-none"
1815
- }
1816
- )
1817
- ] });
1818
- }
1819
- function Qn({ side: t = "start" }) {
1820
- const { t: a } = q("sidebar"), n = ee((g) => g.history), { showPin: r, showShare: i, showRename: o, showDelete: m } = n, u = O(
1821
- () => ({ pin: r, share: i, rename: o, delete: m }),
1822
- [r, i, o, m]
1823
- );
1824
- return /* @__PURE__ */ e(ot, { children: /* @__PURE__ */ e(qn, { collapsible: "icon", side: t, children: /* @__PURE__ */ e(Mn, { className: "custom-scrollbar", children: /* @__PURE__ */ s(Pn, { children: [
1825
- /* @__PURE__ */ e(Un, {}),
1826
- n.enabled && /* @__PURE__ */ s(G.Root, { className: "group-data-[collapsible=icon]:hidden", children: [
1827
- /* @__PURE__ */ e(Ge, { className: "mb-6 px-2", children: /* @__PURE__ */ e(Kn, {}) }),
1828
- /* @__PURE__ */ s(Ge, { children: [
1829
- /* @__PURE__ */ e(xt, { children: /* @__PURE__ */ e(kt.Provider, { value: u, children: /* @__PURE__ */ e(G.Items, { component: Vn }) }) }),
1830
- /* @__PURE__ */ e(G.Empty, { className: "px-4 py-8 text-center text-sm opacity-60", children: a("no_conversations") }),
1831
- /* @__PURE__ */ e(jn, {})
1832
- ] })
1833
- ] })
1834
- ] }) }) }) });
1835
- }
1836
- function Wn({ components: t, disclaimer: a, welcome: n, ...r }) {
1837
- return /* @__PURE__ */ e(De, { components: t, disclaimer: a, welcome: n, children: /* @__PURE__ */ e(Xn, { ...r }) });
1838
- }
1839
- function Xn({
1840
- threadId: t,
1841
- onThreadChange: a,
1842
- getThreadHref: n,
1843
- getShareHref: r,
1844
- sidebar: i,
1845
- header: o,
1846
- classNames: m
1847
- }) {
1848
- const u = ee((f) => f.history.enabled), { MaintenanceBanner: g, MaintenanceScreen: c } = ie(), h = Ut(), p = h.isUnderMaintenance && h.status ? {
1849
- status: h.status,
1850
- title: h.title,
1851
- message: h.message,
1852
- endsAt: h.endsAt,
1853
- blocksChat: h.blocksChat,
1854
- refresh: h.refresh
1855
- } : null;
1856
- return p && h.display === "fullscreen" && c ? /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(c, { ...p }) }) : /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(
1857
- Je,
1858
- {
1859
- threadId: t,
1860
- onThreadChange: a,
1861
- getThreadHref: n,
1862
- getShareHref: r,
1863
- children: /* @__PURE__ */ s(In, { defaultOpen: u, className: "bg-background", children: [
1864
- i !== void 0 ? i : u ? /* @__PURE__ */ e(Qn, {}) : null,
1865
- /* @__PURE__ */ s("div", { className: "flex flex-col flex-1 h-dvh overflow-hidden relative", children: [
1866
- o !== void 0 ? o : /* @__PURE__ */ e(St, {}),
1867
- p && g && /* @__PURE__ */ e(g, { ...p }),
1868
- /* @__PURE__ */ e("div", { className: "flex flex-col relative w-full flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ e(un, { classNames: m }) })
1869
- ] })
1870
- ] })
1871
- }
1872
- ) });
1873
- }
1874
- const pe = /* @__PURE__ */ new Set();
1875
- let ae = null;
1876
- function Pe() {
1877
- for (const t of pe) t();
1878
- }
1879
- function Yn(t) {
1880
- return pe.size === 0 && window.addEventListener("popstate", Pe), pe.add(t), () => {
1881
- pe.delete(t), pe.size === 0 && window.removeEventListener("popstate", Pe);
1882
- };
1883
- }
1884
- function Zn() {
1885
- const { pathname: t, search: a, hash: n } = window.location, r = window.history.state;
1886
- return (ae?.pathname !== t || ae.search !== a || ae.hash !== n || ae.state !== r) && (ae = { pathname: t, search: a, hash: n, state: r }), ae;
1887
- }
1888
- const Jn = () => null;
1889
- function er() {
1890
- return Lt(Yn, Zn, Jn);
1891
- }
1892
- function Ne(t, { replace: a = !1, state: n = null } = {}) {
1893
- a ? window.history.replaceState(n, "", t) : window.history.pushState(n, "", t), Pe();
1894
- }
1895
- const tr = {
1896
- chat: "/chat",
1897
- login: "/login",
1898
- shared: "/shared",
1899
- admin: "/admin"
1900
- };
1901
- function ne(t) {
1902
- const a = t.replace(/^\/+|\/+$/g, "");
1903
- return a ? `/${a}` : "";
1904
- }
1905
- function ar(t, a = {}) {
1906
- const n = ne(t), r = { ...tr, ...a };
1907
- return {
1908
- chat: n + ne(r.chat),
1909
- login: n + ne(r.login),
1910
- shared: n + ne(r.shared),
1911
- admin: n + ne(r.admin)
1912
- };
1913
- }
1914
- function Qe(t, a) {
1915
- if (t !== a && !t.startsWith(`${a}/`)) return;
1916
- const n = t.slice(a.length).replace(/^\/+|\/+$/g, "");
1917
- if (!n) return null;
1918
- if (!n.includes("/"))
1919
- try {
1920
- return decodeURIComponent(n);
1921
- } catch {
1922
- return;
1923
- }
1924
- }
1925
- function nr(t, a) {
1926
- const n = ne(t);
1927
- if (n === a.admin || n.startsWith(`${a.admin}/`)) return { name: "admin" };
1928
- if (n === a.login) return { name: "login" };
1929
- const r = Qe(n, a.shared);
1930
- return r ? { name: "shared", shareId: r } : { name: "chat", threadId: Qe(n, a.chat) ?? null };
1931
- }
1932
- function qe(t, a) {
1933
- return t === null ? a.chat || "/" : `${a.chat}/${encodeURIComponent(t)}`;
1934
- }
1935
- function wr({
1936
- url: t,
1937
- api: a,
1938
- basePath: n = "/",
1939
- paths: r,
1940
- admin: i,
1941
- components: o,
1942
- history: m,
1943
- welcome: u,
1944
- threadActions: g,
1945
- composer: c,
1946
- disclaimer: h,
1947
- settings: p,
1948
- ...f
1949
- }) {
1950
- const b = er();
1951
- return b ? /* @__PURE__ */ s(bn, { ...f, api: { ...a, basePath: t }, children: [
1952
- /* @__PURE__ */ e(vn, {}),
1953
- /* @__PURE__ */ e(
1954
- De,
1955
- {
1956
- components: o,
1957
- history: m,
1958
- welcome: u,
1959
- threadActions: g,
1960
- composer: c,
1961
- disclaimer: h,
1962
- settings: p,
1963
- children: /* @__PURE__ */ e(rr, { location: b, paths: ar(n, r), admin: i })
1964
- }
1965
- )
1966
- ] }) : null;
1967
- }
1968
- function rr({ location: t, paths: a, admin: n }) {
1969
- const r = nr(t.pathname, a), i = qe(null, a);
1970
- if (r.name === "admin" && n) return /* @__PURE__ */ e(Mt, { fallback: null, children: n });
1971
- if (r.name === "login") {
1972
- const { reason: c, from: h } = or(t.state);
1973
- return /* @__PURE__ */ e(yn, { reason: c, onSignedIn: () => Ne(h ?? i, { replace: !0 }) });
1974
- }
1975
- if (r.name === "shared") return /* @__PURE__ */ e(On, { shareId: r.shareId });
1976
- const o = r.name === "chat" ? r.threadId : null, m = new URLSearchParams(t.search), u = m.get("code");
1977
- return /* @__PURE__ */ e(
1978
- xn,
1979
- {
1980
- loginCode: u,
1981
- onLoginCodeUsed: () => {
1982
- m.delete("code");
1983
- const c = m.toString();
1984
- Ne(t.pathname + (c ? `?${c}` : "") + t.hash, { replace: !0 });
1985
- },
1986
- fallback: (c) => /* @__PURE__ */ e(lr, { to: a.login, reason: c, from: t.pathname + t.search }),
1987
- children: /* @__PURE__ */ e(
1988
- Wn,
1989
- {
1990
- threadId: o,
1991
- onThreadChange: (c) => Ne(qe(c, a)),
1992
- getThreadHref: (c) => qe(c, a),
1993
- getShareHref: (c) => `${a.shared}/${encodeURIComponent(c)}`
1994
- }
1995
- )
1996
- }
1997
- );
1998
- }
1999
- const sr = [
2000
- "signed_out",
2001
- "session_expired",
2002
- "handoff_failed"
2003
- ];
2004
- function ir(t) {
2005
- return typeof t == "string" && sr.includes(t);
2006
- }
2007
- function or(t) {
2008
- if (typeof t != "object" || t === null) return {};
2009
- const { reason: a, from: n } = t;
2010
- return {
2011
- reason: ir(a) ? a : void 0,
2012
- // Only a path on this site: a full URL here would make the sign-in page an open redirect.
2013
- from: typeof n == "string" && n.startsWith("/") && !n.startsWith("//") ? n : void 0
2014
- };
2015
- }
2016
- function lr({ to: t, reason: a, from: n }) {
2017
- return R(() => {
2018
- Ne(t, { replace: !0, state: { reason: a, from: n } });
2019
- }, [t, a, n]), null;
2020
- }
2
+ import { A as s, C as t, b as o, c as i, d as n, e as r, f as u, g, D as c, F as p, h, G as S, i as C, j as P, k as l, M as m, l as d, m as T, n as q, o as Q, P as f, Q as A, p as G, R as M, q as R, r as U, s as x, S as B, t as b, u as v, v as w, w as D, T as I, x as y, U as F, y as L, W, z as j, B as k, E, H as z } from "./shared-Ba-piIUg.js";
3
+ import { T as O, j as V, i as J } from "./shared-BtZa4J_w.js";
2021
4
  export {
2022
- Qn as AppSidebar,
2023
- un as Chat,
2024
- Cr as ChatError,
2025
- Wn as ChatLayout,
2026
- _r as ChoiceQuestionDock,
2027
- Tr as ChoiceQuestionPart,
2028
- ka as ChoiceQuestionProvider,
2029
- zn as CreditsBar,
2030
- vn as DocumentSync,
2031
- Ir as FilePart,
2032
- qr as FollowUpSuggestions,
2033
- wr as GentiqChatApp,
2034
- bn as GentiqProvider,
2035
- W as GentiqRoot,
2036
- De as GentiqUI,
2037
- Lr as MaintenanceBanner,
2038
- Mr as MaintenanceScreen,
2039
- Pr as MessageActions,
2040
- Ar as MessageList,
2041
- Er as PromptInputArea,
2042
- zr as PromptInputButton,
2043
- wt as QuotaBar,
2044
- En as QuotaWindows,
2045
- Rr as ReasoningPart,
2046
- Dr as ReferencePart,
2047
- va as Referenceable,
2048
- xn as RequireAuth,
2049
- Fn as SettingsDialog,
2050
- On as SharedChatView,
2051
- In as SidebarProvider,
2052
- Fr as Suggestion,
2053
- Or as Suggestions,
2054
- $r as TextPart,
2055
- Ur as ToolPart,
2056
- lt as Tooltip,
2057
- dt as TooltipContent,
2058
- ct as TooltipTrigger,
2059
- jr as UsageMeter,
2060
- yn as UserLoginPage,
2061
- Br as WelcomeScreen,
2062
- Gr as useChoiceQuestion,
2063
- ee as useGentiqUIOptions,
2064
- Hr as useSmoothStreamingConfig,
2065
- Vr as useSmoothText
5
+ s as AppSidebar,
6
+ t as Chat,
7
+ o as ChatError,
8
+ i as ChatLayout,
9
+ n as ChoiceQuestionDock,
10
+ r as ChoiceQuestionPart,
11
+ u as ChoiceQuestionProvider,
12
+ g as CreditsBar,
13
+ c as DocumentSync,
14
+ p as FilePart,
15
+ h as FollowUpSuggestions,
16
+ S as GentiqChatApp,
17
+ C as GentiqProvider,
18
+ P as GentiqRoot,
19
+ l as GentiqUI,
20
+ m as MaintenanceBanner,
21
+ d as MaintenanceScreen,
22
+ T as MessageActions,
23
+ q as MessageList,
24
+ Q as PromptInputArea,
25
+ f as PromptInputButton,
26
+ A as QuotaBar,
27
+ G as QuotaWindows,
28
+ M as ReasoningPart,
29
+ R as ReferencePart,
30
+ U as Referenceable,
31
+ x as RequireAuth,
32
+ B as SettingsDialog,
33
+ b as SharedChatView,
34
+ v as SidebarProvider,
35
+ w as Suggestion,
36
+ D as Suggestions,
37
+ I as TextPart,
38
+ y as ToolPart,
39
+ O as Tooltip,
40
+ V as TooltipContent,
41
+ J as TooltipTrigger,
42
+ F as UsageMeter,
43
+ L as UserLoginPage,
44
+ W as WelcomeScreen,
45
+ j as useChoiceQuestion,
46
+ k as useGentiqUIOptions,
47
+ E as useSmoothStreamingConfig,
48
+ z as useSmoothText
2066
49
  };