@versini/sassysaint 8.24.6 → 8.24.8

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.
@@ -0,0 +1,969 @@
1
+ import { jsxs as C, jsx as l } from "react/jsx-runtime";
2
+ import { n as Te, LOCAL_STORAGE_PREFIX as Ne, LOCAL_STORAGE_CHAT_DETAILS as ve, SETTINGS_TITLE as we, S as G, CARDS as U, APP_NAME as _e, C as Z, PROMPTS_DESCRIPTION as Ce, L as Ae, j as ne, isProbablyMobile as Ie, getCurrentGeoLocation as Se } from "./index.CxVK8gmr.js";
3
+ import { useUserPreferences as Le, E as Re, rr as Me, mutateCall as le, SERVICE_TYPES as se } from "./App.CU8DPgBK.js";
4
+ import Oe, { useRef as w, useState as x, useLayoutEffect as $, useMemo as de, useEffect as V, useId as De, useReducer as Pe, useCallback as Be } from "react";
5
+ import i from "clsx";
6
+ const ue = "av-text-area", He = "av-text-area-wrapper", ee = "av-text-area-helper-text", Ge = "av-text-area__control--right", Ue = "av-text-area__control--left";
7
+ function $e() {
8
+ const e = w(!1);
9
+ return V(() => (e.current = !0, () => {
10
+ e.current = !1;
11
+ }), []), Be(() => e.current, []);
12
+ }
13
+ function Ve(e) {
14
+ return de(() => e.every((r) => r == null) ? () => {
15
+ } : (r) => {
16
+ e.forEach((a) => {
17
+ typeof a == "function" ? a(r) : a != null && (a.current = r);
18
+ });
19
+ }, [...e]);
20
+ }
21
+ const Fe = {
22
+ x: 0,
23
+ y: 0,
24
+ width: 0,
25
+ height: 0,
26
+ top: 0,
27
+ left: 0,
28
+ bottom: 0,
29
+ right: 0
30
+ };
31
+ function ce(e) {
32
+ const r = $e(), a = w(0), o = w(null), [t, s] = x(Fe), c = de(() => typeof ResizeObserver > "u" ? null : new ResizeObserver((d) => {
33
+ const m = d[0];
34
+ m && (cancelAnimationFrame(a.current), a.current = requestAnimationFrame(() => {
35
+ o.current && r() && s(m.contentRect);
36
+ }));
37
+ }), [r]);
38
+ return V(() => (o.current && c?.observe(o.current, e), () => {
39
+ c?.disconnect(), a.current && cancelAnimationFrame(a.current);
40
+ }), [c, e]), [o, t];
41
+ }
42
+ function ze({
43
+ value: e,
44
+ defaultValue: r,
45
+ finalValue: a,
46
+ onChange: o = () => {
47
+ },
48
+ initialControlledDelay: t = 0
49
+ }) {
50
+ const [s, c] = x(!1), [d, m] = x(
51
+ r !== void 0 ? r : a
52
+ ), f = (h) => {
53
+ m(h), o?.(h);
54
+ };
55
+ return V(() => {
56
+ (async () => e !== void 0 && !s && t > 0 && (await new Promise(
57
+ (h) => setTimeout(h, t)
58
+ ), c(!0)))();
59
+ }, [e, t, s]), e !== void 0 ? !s && t > 0 ? ["", o, !0] : [e, o, !0] : [d, f, !1];
60
+ }
61
+ function je(e) {
62
+ const r = De();
63
+ if (!e)
64
+ return r;
65
+ if (typeof e == "number" || typeof e == "string")
66
+ return `${e}${r}`;
67
+ if (typeof e == "object") {
68
+ const { id: a, prefix: o = "" } = e;
69
+ return typeof a == "number" || typeof a == "string" ? `${o}${a}` : `${o}${r}`;
70
+ }
71
+ }
72
+ const me = "SET_ANNOUNCEMENT", fe = "CLEAR_ANNOUNCEMENT", Xe = {
73
+ alert: null,
74
+ alertdialog: null,
75
+ log: "polite",
76
+ marquee: null,
77
+ progressbar: null,
78
+ status: "polite",
79
+ timer: "assertive"
80
+ }, Ye = (e, r) => {
81
+ switch (r?.type) {
82
+ case me:
83
+ return {
84
+ ...e,
85
+ announcement: r.payload
86
+ };
87
+ case fe:
88
+ return {
89
+ ...e,
90
+ announcement: null
91
+ };
92
+ default:
93
+ return e;
94
+ }
95
+ }, qe = ({
96
+ onAnnouncementClear: e,
97
+ dispatch: r
98
+ }) => {
99
+ r({
100
+ type: fe
101
+ }), typeof e == "function" && e();
102
+ }, ie = ({
103
+ children: e,
104
+ clearAnnouncementDelay: r,
105
+ clearAnnouncementTimeoutRef: a,
106
+ onAnnouncementClear: o,
107
+ dispatch: t
108
+ }) => {
109
+ clearTimeout(a.current), e !== null && t({
110
+ type: me,
111
+ payload: e
112
+ }), r && (a.current = setTimeout(
113
+ () => qe({
114
+ onAnnouncementClear: o,
115
+ dispatch: t
116
+ }),
117
+ r
118
+ ));
119
+ }, Ke = ({
120
+ children: e,
121
+ announcementTimeoutRef: r,
122
+ announcementDelay: a,
123
+ clearAnnouncementDelay: o,
124
+ clearAnnouncementTimeoutRef: t,
125
+ onAnnouncementClear: s,
126
+ dispatch: c
127
+ }) => {
128
+ clearTimeout(r.current), a ? r.current = setTimeout(ie, a, {
129
+ children: e,
130
+ clearAnnouncementDelay: o,
131
+ clearAnnouncementTimeoutRef: t,
132
+ onAnnouncementClear: s,
133
+ dispatch: c
134
+ }) : ie({
135
+ children: e,
136
+ clearAnnouncementDelay: o,
137
+ clearAnnouncementTimeoutRef: t,
138
+ onAnnouncementClear: s,
139
+ dispatch: c
140
+ });
141
+ };
142
+ function We({
143
+ children: e,
144
+ className: r,
145
+ politeness: a,
146
+ role: o = null,
147
+ announcementDelay: t,
148
+ clearAnnouncementDelay: s,
149
+ onAnnouncementClear: c,
150
+ visible: d,
151
+ ...m
152
+ }) {
153
+ const f = w(null), h = w(null), [E, S] = Pe(Ye, {
154
+ announcement: null
155
+ });
156
+ let _ = a;
157
+ typeof _ > "u" && (_ = o ? Xe[o] : "assertive"), V(() => {
158
+ Ke({
159
+ announcementTimeoutRef: f,
160
+ announcementDelay: t,
161
+ children: e,
162
+ clearAnnouncementDelay: s,
163
+ clearAnnouncementTimeoutRef: h,
164
+ onAnnouncementClear: c,
165
+ dispatch: S
166
+ });
167
+ }, [
168
+ e,
169
+ t,
170
+ s,
171
+ c
172
+ ]);
173
+ const p = i(r, {
174
+ "sr-only": !d
175
+ });
176
+ return /* @__PURE__ */ l(
177
+ "div",
178
+ {
179
+ "aria-live": _,
180
+ ...o && { role: o },
181
+ className: p,
182
+ ...m,
183
+ children: E.announcement
184
+ }
185
+ );
186
+ }
187
+ /*!
188
+ @versini/ui-liveregion v2.0.5
189
+ © 2025 gizmette.com
190
+ */
191
+ try {
192
+ window.__VERSINI_UI_LIVEREGION__ || (window.__VERSINI_UI_LIVEREGION__ = {
193
+ version: "2.0.5",
194
+ buildTime: "06/28/2025 08:58 PM EDT",
195
+ homepage: "https://github.com/aversini/ui-components",
196
+ license: "MIT"
197
+ });
198
+ } catch {
199
+ }
200
+ const Qe = () => "rounded-md text-base h-20 min-h-[80px] resize-none overflow-hidden px-4 py-7", Je = ({ mode: e }) => i({
201
+ "bg-surface-darker text-copy-lighter caret-copy-light": e === "dark",
202
+ "bg-surface-lighter text-copy-dark caret-copy-dark": e === "light",
203
+ "bg-surface-lighter text-copy-dark caret-copy-dark dark:bg-surface-darker dark:text-copy-lighter dark:caret-copy-light": e === "system",
204
+ "bg-surface-darker text-copy-lighter caret-copy-light dark:bg-surface-lighter dark:text-copy-dark dark:caret-copy-dark": e === "alt-system"
205
+ }), Ze = ({
206
+ focusMode: e
207
+ }) => i("focus:outline focus:outline-2 focus:outline-offset-2", {
208
+ "focus:outline-focus-dark": e === "dark",
209
+ "focus:outline-focus-light": e === "light",
210
+ "focus:outline-focus-light dark:focus:outline-focus-dark": e === "alt-system",
211
+ "focus:outline-focus-dark dark:focus:outline-focus-light": e === "system"
212
+ }), et = ({
213
+ noBorder: e,
214
+ error: r
215
+ }) => i("border-2", {
216
+ "border-border-dark": !e && !r,
217
+ "focus:border-border-dark": !e && r,
218
+ "border-border-error-dark": !e && r,
219
+ "border-transparent": e
220
+ }), tt = ({
221
+ disabled: e,
222
+ raw: r,
223
+ error: a,
224
+ mode: o,
225
+ leftElement: t,
226
+ rightElement: s
227
+ }) => {
228
+ if (r)
229
+ return "";
230
+ if (e)
231
+ return i(
232
+ "transform translate-y-0 scale-100 absolute px-2 cursor-not-allowed opacity-50 font-medium",
233
+ {
234
+ "translate-x-[12px]": s === !0 && !t || !s && !t
235
+ }
236
+ );
237
+ if (!a)
238
+ return i(
239
+ "absolute px-2 cursor-text font-medium transform translate-y-0 scale-100",
240
+ {
241
+ "translate-x-[12px]": s === !0 && !t || !s && !t,
242
+ "text-copy-medium": o === "dark",
243
+ "text-copy-dark": o === "light",
244
+ "text-copy-dark dark:text-copy-medium": o === "system",
245
+ "text-copy-medium dark:text-copy-dark": o === "alt-system"
246
+ }
247
+ );
248
+ if (a)
249
+ return i(
250
+ "absolute px-2 cursor-text font-medium transform translate-y-0 scale-100",
251
+ {
252
+ "translate-x-[12px]": s === !0 && !t || !s && !t,
253
+ "text-copy-medium": o === "dark",
254
+ "text-copy-error-dark": o === "light",
255
+ "text-copy-error-dark dark:text-copy-error-light": o === "system",
256
+ "text-copy-medium dark:text-copy-error-dark": o === "alt-system"
257
+ }
258
+ );
259
+ }, rt = ({
260
+ error: e,
261
+ raw: r,
262
+ mode: a,
263
+ disabled: o
264
+ }) => {
265
+ if (r)
266
+ return "";
267
+ if (o)
268
+ return i(
269
+ ee,
270
+ "absolute px-2 cursor-not-allowed opacity-50 font-medium"
271
+ );
272
+ if (!e)
273
+ return i(ee, "absolute px-2 font-medium", {
274
+ "text-copy-medium": a === "dark",
275
+ "text-copy-dark": a === "light",
276
+ "text-copy-dark dark:text-copy-medium": a === "system",
277
+ "text-copy-medium dark:text-copy-dark": a === "alt-system"
278
+ });
279
+ if (e)
280
+ return i(ee, "absolute px-2 font-medium", {
281
+ "text-copy-error-light": a === "dark",
282
+ "text-copy-error-dark": a === "light",
283
+ "text-copy-error-dark dark:text-copy-error-light": a === "system",
284
+ "dark:text-copy-error-dark text-copy-error-light": a === "alt-system"
285
+ });
286
+ }, at = ({
287
+ className: e,
288
+ textAreaClassName: r,
289
+ raw: a,
290
+ focusMode: o,
291
+ disabled: t,
292
+ noBorder: s,
293
+ error: c,
294
+ mode: d,
295
+ leftElement: m,
296
+ rightElement: f
297
+ }) => {
298
+ const h = a ? e : i(
299
+ "relative flex w-full flex-col justify-center",
300
+ He,
301
+ e
302
+ ), E = a ? i(r) : i(
303
+ ue,
304
+ r,
305
+ Qe(),
306
+ Je({ mode: d }),
307
+ Ze({ focusMode: o }),
308
+ et({
309
+ noBorder: s,
310
+ error: c
311
+ }),
312
+ {
313
+ "disabled:cursor-not-allowed disabled:opacity-50": t
314
+ }
315
+ ), S = a ? void 0 : "sr-only", _ = tt({
316
+ disabled: t,
317
+ raw: a,
318
+ error: c,
319
+ mode: d,
320
+ rightElement: f,
321
+ leftElement: m
322
+ }), p = rt({
323
+ error: c,
324
+ raw: a,
325
+ mode: d,
326
+ disabled: t
327
+ }), L = a ? void 0 : i(Ge, "absolute"), T = a ? void 0 : i(Ue, "absolute");
328
+ return {
329
+ wrapper: h,
330
+ textArea: E,
331
+ accessibleLabel: S,
332
+ visibleLabel: _,
333
+ helperText: p,
334
+ rightElement: L,
335
+ leftElement: T
336
+ };
337
+ }, ot = ({
338
+ scrollHeight: e,
339
+ currentHeight: r,
340
+ currentLabelOffset: a = 0,
341
+ currentHelperTextOffset: o = 0
342
+ }) => {
343
+ let t, s;
344
+ if (e > 0 && e !== r) {
345
+ const c = e - r, d = Math.abs(c / 24);
346
+ t = a + -1 * Math.sign(c) * (12 * d), s = o + Math.sign(c) * (12 * d);
347
+ }
348
+ return {
349
+ labelOffset: t,
350
+ helperTextOffset: s,
351
+ scrollHeight: e
352
+ };
353
+ }, te = Oe.forwardRef(
354
+ ({
355
+ id: e,
356
+ name: r,
357
+ label: a,
358
+ error: o = !1,
359
+ raw: t = !1,
360
+ className: s,
361
+ textAreaClassName: c,
362
+ mode: d = "system",
363
+ focusMode: m = "system",
364
+ value: f,
365
+ defaultValue: h,
366
+ disabled: E = !1,
367
+ noBorder: S = !1,
368
+ labelId: _,
369
+ helperText: p = "",
370
+ helperTextOnFocus: L = !1,
371
+ rightElement: T,
372
+ leftElement: A,
373
+ onChange: H,
374
+ onFocus: F,
375
+ onBlur: z,
376
+ ...Y
377
+ }, q) => {
378
+ var j;
379
+ const N = w(null), K = Ve([q, N]), [X, R] = ce(), [n, u] = ce(), I = w(80), D = w(-25), g = w(null), k = w(30), y = w(null), v = je({ id: e, prefix: `${ue}-` }), [P, W] = x(0), [re, pe] = x(0), [he, ae] = x(
380
+ !!(!L && p)
381
+ ), ge = `${r} error, ${p}`, O = at({
382
+ className: s,
383
+ textAreaClassName: c,
384
+ error: o,
385
+ raw: t,
386
+ focusMode: m,
387
+ disabled: E,
388
+ noBorder: S,
389
+ mode: d,
390
+ rightElement: !!T,
391
+ leftElement: !!A
392
+ }), [M, ye] = ze({
393
+ value: f,
394
+ initialControlledDelay: 20,
395
+ defaultValue: h,
396
+ onChange: (b) => {
397
+ H && H({
398
+ target: {
399
+ value: b
400
+ }
401
+ });
402
+ }
403
+ }), be = (b) => {
404
+ ye(b.target.value);
405
+ }, ke = (b) => {
406
+ L && p && ae(!0), F && F(b);
407
+ }, xe = (b) => {
408
+ L && p && !M && ae(!1), z && z(b);
409
+ };
410
+ return $(() => {
411
+ R && R.width && W(R.width + 18 + 10);
412
+ }, [R]), $(() => {
413
+ u && u.width && pe(u.width + 18 + 10);
414
+ }, [u]), $(() => {
415
+ t || N && N.current && M !== void 0 && (N.current.style.height = "inherit", N.current.style.height = N.current.scrollHeight + "px");
416
+ }, [M, t]), $(() => {
417
+ t || setTimeout(() => {
418
+ var b;
419
+ (b = g?.current) == null || b.style.setProperty(
420
+ "--av-text-area-wrapper-transition",
421
+ M ? "none" : "all 0.2s ease-out"
422
+ );
423
+ }, 0);
424
+ }, [M, t]), $(() => {
425
+ var b, oe;
426
+ if (!t && N && N.current && M !== void 0) {
427
+ const { labelOffset: Q, helperTextOffset: J, scrollHeight: Ee } = ot({
428
+ scrollHeight: N.current.scrollHeight,
429
+ currentHeight: I.current,
430
+ currentLabelOffset: D.current,
431
+ currentHelperTextOffset: k.current
432
+ });
433
+ Q && (D.current = Q, (b = g?.current) == null || b.style.setProperty(
434
+ "--av-text-area-label",
435
+ `${Q}px`
436
+ )), J && (k.current = J, (oe = y?.current) == null || oe.style.setProperty(
437
+ "--av-text-area-helper-text",
438
+ `${J}px`
439
+ )), I.current = Ee || I.current;
440
+ }
441
+ }, [M, t]), u.width > 0 && ((j = g?.current) == null || j.style.setProperty(
442
+ "--tw-translate-x",
443
+ `${12 + u.width + 5}px`
444
+ )), /* @__PURE__ */ C("div", { className: O.wrapper, children: [
445
+ /* @__PURE__ */ l(
446
+ "label",
447
+ {
448
+ htmlFor: v,
449
+ id: _,
450
+ className: O.accessibleLabel,
451
+ children: a
452
+ }
453
+ ),
454
+ A && /* @__PURE__ */ l(
455
+ "div",
456
+ {
457
+ ref: n,
458
+ className: O.leftElement,
459
+ children: A
460
+ }
461
+ ),
462
+ /* @__PURE__ */ l(
463
+ "textarea",
464
+ {
465
+ ref: K,
466
+ id: v,
467
+ name: r,
468
+ disabled: E,
469
+ placeholder: t ? void 0 : " ",
470
+ className: O.textArea,
471
+ rows: 1,
472
+ ...p && { "aria-describedby": `${v}-helper` },
473
+ ...o && { "aria-invalid": "true" },
474
+ ...T && !A && !t && { style: { paddingRight: P } },
475
+ ...A && !T && !t && { style: { paddingLeft: re } },
476
+ ...T && A && !t && {
477
+ style: {
478
+ paddingRight: P,
479
+ paddingLeft: re
480
+ }
481
+ },
482
+ value: M,
483
+ onChange: be,
484
+ onFocus: ke,
485
+ onBlur: xe,
486
+ ...Y
487
+ }
488
+ ),
489
+ !t && /* @__PURE__ */ l(
490
+ "label",
491
+ {
492
+ ref: g,
493
+ "aria-hidden": !0,
494
+ htmlFor: v,
495
+ className: `${O.visibleLabel}`,
496
+ children: a
497
+ }
498
+ ),
499
+ he && /* @__PURE__ */ l(
500
+ "div",
501
+ {
502
+ ref: y,
503
+ id: `${v}-helper`,
504
+ className: O.helperText,
505
+ children: p
506
+ }
507
+ ),
508
+ T && /* @__PURE__ */ l(
509
+ "div",
510
+ {
511
+ ref: X,
512
+ className: O.rightElement,
513
+ children: T
514
+ }
515
+ ),
516
+ o && p && /* @__PURE__ */ l(We, { politeness: "polite", clearAnnouncementDelay: 500, children: ge })
517
+ ] });
518
+ }
519
+ );
520
+ te.displayName = "TextArea";
521
+ /*!
522
+ @versini/ui-textarea v4.0.5
523
+ © 2025 gizmette.com
524
+ */
525
+ try {
526
+ window.__VERSINI_UI_TEXTAREA__ || (window.__VERSINI_UI_TEXTAREA__ = {
527
+ version: "4.0.5",
528
+ buildTime: "06/28/2025 08:58 PM EDT",
529
+ homepage: "https://github.com/aversini/ui-components",
530
+ license: "MIT"
531
+ });
532
+ } catch {
533
+ }
534
+ const nt = "av-toggle", lt = () => i("peer", "h-6", "w-11", "rounded-full"), st = ({
535
+ focusMode: e
536
+ }) => i(
537
+ "peer-focus:outline",
538
+ "peer-focus:outline-2",
539
+ "peer-focus:outline-offset-2",
540
+ {
541
+ "peer-focus:outline-focus-dark": e === "dark",
542
+ "peer-focus:outline-focus-light": e === "light",
543
+ "peer-focus:outline-focus-light dark:peer-focus:outline-focus-dark": e === "alt-system",
544
+ "peer-focus:outline-focus-dark dark:peer-focus:outline-focus-light": e === "system"
545
+ }
546
+ ), ct = () => i(
547
+ "peer-checked:after:translate-x-full",
548
+ // background color when checked
549
+ "peer-checked:bg-violet-500",
550
+ // knob circle and border color when checked
551
+ "peer-checked:after:bg-white",
552
+ "peer-checked:after:border-white"
553
+ ), it = () => i(
554
+ "after:left-[2px]",
555
+ "after:top-[2px]",
556
+ "after:border",
557
+ "after:border-surface-light dark:after:border-surface-medium",
558
+ "after:bg-surface-light dark:after:bg-surface-medium",
559
+ "after:absolute",
560
+ "after:h-5",
561
+ "after:w-5",
562
+ "after:rounded-full",
563
+ "after:transition-all",
564
+ "after:content-['']"
565
+ ), dt = ({
566
+ mode: e,
567
+ noBorder: r
568
+ }) => i({
569
+ border: !r,
570
+ "border-border-dark bg-surface-medium": e === "light",
571
+ "border-border-light bg-surface-darker": e === "dark",
572
+ "border-border-light bg-surface-darker dark:border-border-dark dark:bg-surface-medium": e === "alt-system",
573
+ "border-border-dark bg-surface-medium dark:border-border-light dark:bg-surface-darker": e === "system"
574
+ }), ut = ({
575
+ mode: e,
576
+ labelHidden: r
577
+ }) => r ? "sr-only" : i("ml-2 text-sm", {
578
+ "text-copy-dark": e === "light",
579
+ "text-copy-lighter": e === "dark",
580
+ "text-copy-lighter dark:text-copy-dark": e === "alt-system",
581
+ "text-copy-dark dark:text-copy-lighter": e === "system"
582
+ }), mt = ({ className: e }) => i(
583
+ nt,
584
+ "relative flex cursor-pointer items-center",
585
+ e
586
+ ), ft = ({
587
+ mode: e,
588
+ focusMode: r,
589
+ labelHidden: a,
590
+ className: o,
591
+ noBorder: t
592
+ }) => ({
593
+ toggle: i(
594
+ lt(),
595
+ dt({ mode: e, noBorder: t }),
596
+ st({ focusMode: r }),
597
+ it(),
598
+ ct()
599
+ ),
600
+ label: ut({ mode: e, labelHidden: a }),
601
+ input: "peer sr-only",
602
+ wrapper: mt({ className: o })
603
+ }), B = ({
604
+ checked: e = !1,
605
+ onChange: r,
606
+ label: a,
607
+ labelHidden: o = !1,
608
+ name: t,
609
+ mode: s = "system",
610
+ focusMode: c = "system",
611
+ className: d,
612
+ noBorder: m = !1
613
+ }) => {
614
+ const f = ft({
615
+ mode: s,
616
+ focusMode: c,
617
+ labelHidden: o,
618
+ className: d,
619
+ noBorder: m
620
+ }), h = (E) => {
621
+ r?.(E.target.checked);
622
+ };
623
+ return /* @__PURE__ */ C("label", { className: f.wrapper, children: [
624
+ /* @__PURE__ */ l(
625
+ "input",
626
+ {
627
+ name: t,
628
+ checked: e,
629
+ type: "checkbox",
630
+ className: f.input,
631
+ onChange: h
632
+ }
633
+ ),
634
+ /* @__PURE__ */ l("div", { className: f.toggle }),
635
+ /* @__PURE__ */ l("span", { className: f.label, children: a })
636
+ ] });
637
+ };
638
+ /*!
639
+ @versini/ui-toggle v4.0.5
640
+ © 2025 gizmette.com
641
+ */
642
+ try {
643
+ window.__VERSINI_UI_TOGGLE__ || (window.__VERSINI_UI_TOGGLE__ = {
644
+ version: "4.0.5",
645
+ buildTime: "06/28/2025 08:58 PM EDT",
646
+ homepage: "https://github.com/aversini/ui-components",
647
+ license: "MIT"
648
+ });
649
+ } catch {
650
+ }
651
+ const kt = ({
652
+ open: e,
653
+ onOpenChange: r
654
+ }) => {
655
+ const { getAccessToken: a, user: o } = Te(), {
656
+ data: t,
657
+ isSuccess: s,
658
+ refetch: c
659
+ } = Le({
660
+ user: o?.username,
661
+ getAccessToken: a
662
+ }), [d, m] = x({
663
+ loadingLocation: !1
664
+ }), [f, h] = x({
665
+ prompts: []
666
+ }), [E, S] = x(""), [_, p] = x(""), [L, T] = x(!1), [A, H] = x(!1), [F, z] = Re({
667
+ key: Ne + ve,
668
+ initialValue: !1
669
+ }), Y = (n) => {
670
+ z(n);
671
+ }, q = (n) => {
672
+ T(n);
673
+ }, j = (n) => {
674
+ H(n);
675
+ }, N = async (n) => {
676
+ n.preventDefault();
677
+ try {
678
+ await le({
679
+ accessToken: await a(),
680
+ type: se.SET_USER_PREFERENCES,
681
+ params: {
682
+ user: o?.username,
683
+ instructions: E,
684
+ location: _,
685
+ provider: t?.provider,
686
+ tags: f.prompts,
687
+ sendOnEnter: L,
688
+ useMemory: A
689
+ }
690
+ }), c(), m({
691
+ loadingLocation: !1
692
+ });
693
+ } catch {
694
+ }
695
+ }, K = async () => {
696
+ m({
697
+ loadingLocation: !0
698
+ }), p("...");
699
+ try {
700
+ const n = Date.now(), u = await Se(), I = await le({
701
+ accessToken: await a(),
702
+ type: se.GET_LOCATION,
703
+ params: {
704
+ latitude: u.latitude,
705
+ longitude: u.longitude
706
+ }
707
+ }), g = Date.now() - n;
708
+ if (g < 2e3 && await new Promise((k) => setTimeout(k, 2e3 - g)), I.status === 200) {
709
+ const { city: k, state: y, country: v, displayName: P } = I.data, W = k && y && v ? `${k}, ${y}, ${v}` : P;
710
+ m({
711
+ loadingLocation: !1
712
+ }), p(W);
713
+ } else
714
+ m({
715
+ loadingLocation: !1
716
+ });
717
+ } catch {
718
+ }
719
+ }, X = () => {
720
+ c(), r(!1);
721
+ }, R = ({
722
+ enabled: n = !1,
723
+ privateChat: u = !1,
724
+ clipboardAccess: I = !1,
725
+ ...D
726
+ }) => {
727
+ h((g) => {
728
+ const k = g.prompts, y = {
729
+ ...D,
730
+ enabled: n,
731
+ privateChat: u,
732
+ clipboardAccess: I
733
+ };
734
+ I ? y.content = y.content.replace(/{{clipboard}}/g, "") + " {{clipboard}}" : y.content = y.content.replace(/{{clipboard}}/g, "");
735
+ const v = k.findIndex((P) => P.slot === D.slot);
736
+ return v === -1 ? {
737
+ ...g,
738
+ prompts: [...k, { ...y }]
739
+ } : (k[v] = y, {
740
+ ...g,
741
+ prompts: [...k]
742
+ });
743
+ });
744
+ };
745
+ return V(() => {
746
+ t?.instructions && S(t.instructions), t?.location && p(t.location), t?.tags && h({ prompts: t.tags }), t?.sendOnEnter !== void 0 && T(t.sendOnEnter), t?.useMemory !== void 0 && H(t.useMemory);
747
+ }, [t]), s ? /* @__PURE__ */ C(
748
+ Me,
749
+ {
750
+ animation: !Ie(),
751
+ open: e,
752
+ onOpenChange: X,
753
+ title: we,
754
+ footer: /* @__PURE__ */ C(
755
+ Ae,
756
+ {
757
+ columnGap: 2,
758
+ alignHorizontal: "flex-end",
759
+ className: "pb-8 sm:pb-0",
760
+ children: [
761
+ /* @__PURE__ */ l(ne, { children: /* @__PURE__ */ l(
762
+ Z,
763
+ {
764
+ mode: "dark",
765
+ variant: "secondary",
766
+ focusMode: "light",
767
+ onClick: X,
768
+ children: "Cancel"
769
+ }
770
+ ) }),
771
+ /* @__PURE__ */ l(ne, { children: /* @__PURE__ */ l(
772
+ Z,
773
+ {
774
+ mode: "dark",
775
+ variant: "danger",
776
+ focusMode: "light",
777
+ onClick: async (n) => {
778
+ r(!1), await N(n);
779
+ },
780
+ children: "Save"
781
+ }
782
+ ) })
783
+ ]
784
+ }
785
+ ),
786
+ children: [
787
+ /* @__PURE__ */ C(
788
+ G,
789
+ {
790
+ header: U.SETTINGS_DETAILS.TITLE,
791
+ className: "prose-dark dark:prose-lighter",
792
+ children: [
793
+ /* @__PURE__ */ l("p", { className: "text-sm", children: U.SETTINGS_DETAILS.DETAILS }),
794
+ /* @__PURE__ */ l(
795
+ B,
796
+ {
797
+ className: "mt-2",
798
+ noBorder: !0,
799
+ label: "Show Message Statistics",
800
+ name: "show-message-statistics",
801
+ onChange: Y,
802
+ checked: F
803
+ }
804
+ ),
805
+ /* @__PURE__ */ l("p", { className: "text-sm mt-5", children: U.SETTINGS_DETAILS.SEND_ON_ENTER }),
806
+ /* @__PURE__ */ l(
807
+ B,
808
+ {
809
+ className: "mt-2",
810
+ noBorder: !0,
811
+ label: "Send Message on Enter",
812
+ name: "send-message-on-enter",
813
+ onChange: q,
814
+ checked: L
815
+ }
816
+ ),
817
+ /* @__PURE__ */ l("p", { className: "text-sm mt-5", children: U.SETTINGS_DETAILS.USE_MEMORY }),
818
+ /* @__PURE__ */ l(
819
+ B,
820
+ {
821
+ className: "mt-2",
822
+ noBorder: !0,
823
+ label: "Use Memory",
824
+ name: "use-memory",
825
+ onChange: j,
826
+ checked: A
827
+ }
828
+ )
829
+ ]
830
+ }
831
+ ),
832
+ /* @__PURE__ */ C(
833
+ G,
834
+ {
835
+ header: "Custom Instructions",
836
+ className: "prose-dark dark:prose-lighter mt-4",
837
+ children: [
838
+ /* @__PURE__ */ C("p", { className: "text-sm", children: [
839
+ "What would you like ",
840
+ /* @__PURE__ */ l("em", { children: _e }),
841
+ " to know about you to provide better responses?"
842
+ ] }),
843
+ /* @__PURE__ */ l(
844
+ te,
845
+ {
846
+ mode: "alt-system",
847
+ autoCapitalize: "off",
848
+ autoComplete: "off",
849
+ autoCorrect: "off",
850
+ name: "customInstructions",
851
+ label: "Custom Instructions",
852
+ value: E,
853
+ onChange: (n) => {
854
+ S(n.target.value);
855
+ },
856
+ helperText: "Press ENTER to add a new line."
857
+ }
858
+ )
859
+ ]
860
+ }
861
+ ),
862
+ /* @__PURE__ */ C(G, { header: "Location", className: "prose-dark dark:prose-lighter mt-4", children: [
863
+ /* @__PURE__ */ l("p", { className: "text-sm", children: "You can share your location to receive customized responses based on your area." }),
864
+ /* @__PURE__ */ l(
865
+ te,
866
+ {
867
+ mode: "alt-system",
868
+ name: "location",
869
+ label: "Location",
870
+ value: _,
871
+ onChange: (n) => {
872
+ p(n.target.value);
873
+ },
874
+ helperText: "Enter your location or press auto-detect."
875
+ }
876
+ ),
877
+ /* @__PURE__ */ l(
878
+ Z,
879
+ {
880
+ className: "mt-2",
881
+ size: "small",
882
+ noBorder: !0,
883
+ disabled: d.loadingLocation,
884
+ onClick: K,
885
+ children: d.loadingLocation ? "Detecting..." : "Auto-detect"
886
+ }
887
+ )
888
+ ] }),
889
+ /* @__PURE__ */ C(
890
+ G,
891
+ {
892
+ header: U.SETTINGS_PROMPTS.TITLE,
893
+ className: "prose-dark dark:prose-lighter mt-4",
894
+ children: [
895
+ /* @__PURE__ */ l("p", { className: "text-sm", children: Ce }),
896
+ f.prompts && f.prompts.slice(0, 3).map((n) => /* @__PURE__ */ C(
897
+ G,
898
+ {
899
+ mode: "dark",
900
+ noBorder: !0,
901
+ header: n.label.replace("...", ""),
902
+ className: "prose-light mb-2",
903
+ children: [
904
+ /* @__PURE__ */ l("p", { className: "text-sm", children: n.description }),
905
+ /* @__PURE__ */ l(
906
+ B,
907
+ {
908
+ mode: "dark",
909
+ className: "mt-2",
910
+ noBorder: !0,
911
+ label: "Enabled",
912
+ name: n.slot.toString(),
913
+ onChange: (u) => {
914
+ R({
915
+ ...n,
916
+ enabled: u
917
+ });
918
+ },
919
+ checked: n.enabled
920
+ }
921
+ ),
922
+ /* @__PURE__ */ l(
923
+ B,
924
+ {
925
+ mode: "dark",
926
+ className: "mt-2",
927
+ noBorder: !0,
928
+ label: "Private Chat",
929
+ name: `private-${n.slot.toString()}`,
930
+ onChange: (u) => {
931
+ R({
932
+ ...n,
933
+ privateChat: u
934
+ });
935
+ },
936
+ checked: n.privateChat
937
+ }
938
+ ),
939
+ /* @__PURE__ */ l(
940
+ B,
941
+ {
942
+ mode: "dark",
943
+ className: "mt-2",
944
+ noBorder: !0,
945
+ label: "Use Clipboard",
946
+ name: `clipboard-${n.slot.toString()}`,
947
+ onChange: (u) => {
948
+ R({
949
+ ...n,
950
+ clipboardAccess: u
951
+ });
952
+ },
953
+ checked: n.clipboardAccess
954
+ }
955
+ )
956
+ ]
957
+ },
958
+ `prompt-slot-${n.slot}`
959
+ ))
960
+ ]
961
+ }
962
+ )
963
+ ]
964
+ }
965
+ ) : null;
966
+ };
967
+ export {
968
+ kt as SettingsPanel
969
+ };