@melony/react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,2371 @@
1
+ 'use strict';
2
+
3
+ var React9 = require('react');
4
+ var clsx = require('clsx');
5
+ var tailwindMerge = require('tailwind-merge');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var client = require('melony/client');
8
+ var separator = require('@base-ui/react/separator');
9
+ var ICONS = require('@tabler/icons-react');
10
+ var mergeProps = require('@base-ui/react/merge-props');
11
+ var useRender = require('@base-ui/react/use-render');
12
+ var classVarianceAuthority = require('class-variance-authority');
13
+ var input = require('@base-ui/react/input');
14
+ var select = require('@base-ui/react/select');
15
+ var button = require('@base-ui/react/button');
16
+ var alertDialog = require('@base-ui/react/alert-dialog');
17
+ var menu = require('@base-ui/react/menu');
18
+
19
+ function _interopNamespace(e) {
20
+ if (e && e.__esModule) return e;
21
+ var n = Object.create(null);
22
+ if (e) {
23
+ Object.keys(e).forEach(function (k) {
24
+ if (k !== 'default') {
25
+ var d = Object.getOwnPropertyDescriptor(e, k);
26
+ Object.defineProperty(n, k, d.get ? d : {
27
+ enumerable: true,
28
+ get: function () { return e[k]; }
29
+ });
30
+ }
31
+ });
32
+ }
33
+ n.default = e;
34
+ return Object.freeze(n);
35
+ }
36
+
37
+ var React9__namespace = /*#__PURE__*/_interopNamespace(React9);
38
+ var ICONS__namespace = /*#__PURE__*/_interopNamespace(ICONS);
39
+
40
+ // src/providers/melony-provider.tsx
41
+ function cn(...inputs) {
42
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
43
+ }
44
+ function groupEventsToMessages(events) {
45
+ if (events.length === 0) return [];
46
+ const messages = [];
47
+ let currentMessage = null;
48
+ for (const event of events) {
49
+ const role = event.role || "assistant";
50
+ const runId = event.runId;
51
+ if (!currentMessage || currentMessage.role !== role || runId && currentMessage.runId && runId !== currentMessage.runId) {
52
+ currentMessage = {
53
+ role,
54
+ content: [event],
55
+ runId
56
+ };
57
+ messages.push(currentMessage);
58
+ } else {
59
+ currentMessage.content.push(event);
60
+ if (!currentMessage.runId && runId) {
61
+ currentMessage.runId = runId;
62
+ }
63
+ }
64
+ }
65
+ return messages;
66
+ }
67
+ var MelonyContext = React9.createContext(void 0);
68
+ var MelonyProvider = ({
69
+ children,
70
+ client
71
+ }) => {
72
+ const [state, setState] = React9.useState(client.getState());
73
+ React9.useEffect(() => {
74
+ setState(client.getState());
75
+ return () => {
76
+ client.subscribe(setState);
77
+ };
78
+ }, [client]);
79
+ const sendEvent = React9.useCallback(
80
+ async (event, options) => {
81
+ const generator = client.sendEvent(event, options);
82
+ for await (const _ of generator) {
83
+ }
84
+ },
85
+ [client]
86
+ );
87
+ const clear = React9.useCallback(() => client.clear(), [client]);
88
+ const value = React9.useMemo(
89
+ () => ({
90
+ ...state,
91
+ messages: groupEventsToMessages(state.events),
92
+ sendEvent,
93
+ clear,
94
+ client
95
+ }),
96
+ [state, sendEvent, clear, client]
97
+ );
98
+ return /* @__PURE__ */ jsxRuntime.jsx(MelonyContext.Provider, { value, children });
99
+ };
100
+ var AuthContext = React9.createContext(
101
+ void 0
102
+ );
103
+ var AuthProvider = ({
104
+ children,
105
+ service
106
+ }) => {
107
+ const [user, setUser] = React9.useState(null);
108
+ const [isLoading, setIsLoading] = React9.useState(true);
109
+ const fetchMe = React9.useCallback(async () => {
110
+ setIsLoading(true);
111
+ try {
112
+ const userData = await service.getMe();
113
+ setUser(userData);
114
+ } catch (error) {
115
+ console.error("Failed to fetch user:", error);
116
+ setUser(null);
117
+ } finally {
118
+ setIsLoading(false);
119
+ }
120
+ }, [service]);
121
+ React9.useEffect(() => {
122
+ fetchMe();
123
+ }, [fetchMe]);
124
+ const login = React9.useCallback(() => {
125
+ service.login();
126
+ }, [service]);
127
+ const logout = React9.useCallback(async () => {
128
+ try {
129
+ await service.logout();
130
+ setUser(null);
131
+ } catch (error) {
132
+ console.error("Failed to logout:", error);
133
+ }
134
+ }, [service]);
135
+ const value = {
136
+ user,
137
+ isAuthenticated: !!user,
138
+ isLoading,
139
+ login,
140
+ logout,
141
+ getToken: service.getToken
142
+ };
143
+ if (isLoading) {
144
+ return /* @__PURE__ */ jsxRuntime.jsx(
145
+ "div",
146
+ {
147
+ style: {
148
+ height: "100vh",
149
+ width: "100vw",
150
+ display: "flex",
151
+ justifyContent: "center",
152
+ alignItems: "center",
153
+ fontSize: "0.875rem",
154
+ letterSpacing: "0.01em"
155
+ },
156
+ className: "text-muted-foreground animate-pulse",
157
+ children: "Loading..."
158
+ }
159
+ );
160
+ }
161
+ return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children });
162
+ };
163
+ var ThreadContext = React9.createContext(void 0);
164
+ var ThreadProvider = ({
165
+ children,
166
+ service,
167
+ initialThreadId: providedInitialThreadId
168
+ }) => {
169
+ const defaultInitialThreadId = React9.useMemo(() => client.generateId(), []);
170
+ const initialThreadId = providedInitialThreadId || defaultInitialThreadId;
171
+ const [threads, setThreads] = React9.useState([]);
172
+ const [activeThreadId, setActiveThreadId] = React9.useState(
173
+ initialThreadId
174
+ );
175
+ const [isLoading, setIsLoading] = React9.useState(true);
176
+ const [error, setError] = React9.useState(null);
177
+ const [threadEvents, setThreadEvents] = React9.useState([]);
178
+ const [isLoadingEvents, setIsLoadingEvents] = React9.useState(false);
179
+ const fetchThreads = React9.useCallback(async () => {
180
+ setIsLoading(true);
181
+ setError(null);
182
+ try {
183
+ const processedThreads = await service.getThreads();
184
+ setThreads(processedThreads);
185
+ } catch (err) {
186
+ const error2 = err instanceof Error ? err : new Error("Failed to fetch threads");
187
+ setError(error2);
188
+ console.error("Failed to fetch threads:", error2);
189
+ } finally {
190
+ setIsLoading(false);
191
+ }
192
+ }, [service]);
193
+ React9.useEffect(() => {
194
+ fetchThreads();
195
+ }, [fetchThreads]);
196
+ const selectThread = React9.useCallback((threadId) => {
197
+ setActiveThreadId(threadId);
198
+ }, []);
199
+ const createThread = React9.useCallback(async () => {
200
+ const newId = service.createThread ? await service.createThread() : client.generateId();
201
+ const newThread = {
202
+ id: newId,
203
+ updatedAt: /* @__PURE__ */ new Date()
204
+ };
205
+ setThreads((prev) => [newThread, ...prev]);
206
+ setActiveThreadId(newId);
207
+ return newId;
208
+ }, [service]);
209
+ const deleteThread = React9.useCallback(
210
+ async (threadId) => {
211
+ try {
212
+ await service.deleteThread(threadId);
213
+ setThreads((prev) => {
214
+ const remainingThreads = prev.filter((t) => t.id !== threadId);
215
+ setActiveThreadId((current) => {
216
+ if (current === threadId) {
217
+ return remainingThreads.length > 0 ? remainingThreads[0].id : null;
218
+ }
219
+ return current;
220
+ });
221
+ return remainingThreads;
222
+ });
223
+ } catch (err) {
224
+ const error2 = err instanceof Error ? err : new Error("Failed to delete thread");
225
+ setError(error2);
226
+ throw error2;
227
+ }
228
+ },
229
+ [service]
230
+ );
231
+ const refreshThreads = React9.useCallback(async () => {
232
+ await fetchThreads();
233
+ }, [fetchThreads]);
234
+ const threadMessages = React9.useMemo(() => {
235
+ return groupEventsToMessages(threadEvents);
236
+ }, [threadEvents]);
237
+ React9.useEffect(() => {
238
+ if (!activeThreadId) {
239
+ setThreadEvents([]);
240
+ setIsLoadingEvents(false);
241
+ return;
242
+ }
243
+ let cancelled = false;
244
+ const fetchEvents = async () => {
245
+ setIsLoadingEvents(true);
246
+ try {
247
+ const events = await service.getEvents(activeThreadId);
248
+ if (!cancelled) {
249
+ setThreadEvents(events);
250
+ }
251
+ } catch (err) {
252
+ if (!cancelled) {
253
+ console.error("Failed to fetch events:", err);
254
+ setThreadEvents([]);
255
+ }
256
+ } finally {
257
+ if (!cancelled) {
258
+ setIsLoadingEvents(false);
259
+ }
260
+ }
261
+ };
262
+ fetchEvents();
263
+ return () => {
264
+ cancelled = true;
265
+ };
266
+ }, [activeThreadId, service]);
267
+ const value = React9.useMemo(
268
+ () => ({
269
+ threads,
270
+ activeThreadId,
271
+ isLoading,
272
+ error,
273
+ selectThread,
274
+ createThread,
275
+ deleteThread,
276
+ refreshThreads,
277
+ threadEvents,
278
+ threadMessages,
279
+ isLoadingEvents
280
+ }),
281
+ [
282
+ threads,
283
+ activeThreadId,
284
+ isLoading,
285
+ error,
286
+ selectThread,
287
+ createThread,
288
+ deleteThread,
289
+ refreshThreads,
290
+ threadEvents,
291
+ threadMessages,
292
+ isLoadingEvents
293
+ ]
294
+ );
295
+ return /* @__PURE__ */ jsxRuntime.jsx(ThreadContext.Provider, { value, children });
296
+ };
297
+ var useMelony = () => {
298
+ const context = React9.useContext(MelonyContext);
299
+ if (context === void 0) {
300
+ throw new Error("useMelony must be used within a MelonyProvider");
301
+ }
302
+ return context;
303
+ };
304
+ var useAuth = () => {
305
+ const context = React9.useContext(AuthContext);
306
+ if (context === void 0) {
307
+ throw new Error("useAuth must be used within an AuthProvider");
308
+ }
309
+ return context;
310
+ };
311
+ var useThreads = () => {
312
+ const context = React9.useContext(ThreadContext);
313
+ if (context === void 0) {
314
+ throw new Error("useThreads must be used within a ThreadProvider");
315
+ }
316
+ return context;
317
+ };
318
+ function Card({
319
+ className,
320
+ size = "default",
321
+ ...props
322
+ }) {
323
+ return /* @__PURE__ */ jsxRuntime.jsx(
324
+ "div",
325
+ {
326
+ "data-slot": "card",
327
+ "data-size": size,
328
+ className: cn("ring-foreground/10 bg-card text-card-foreground gap-6 overflow-hidden rounded-2xl py-6 text-sm ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-4 data-[size=sm]:py-4 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col", className),
329
+ ...props
330
+ }
331
+ );
332
+ }
333
+ function CardHeader({ className, ...props }) {
334
+ return /* @__PURE__ */ jsxRuntime.jsx(
335
+ "div",
336
+ {
337
+ "data-slot": "card-header",
338
+ className: cn(
339
+ "gap-2 rounded-t-xl px-6 group-data-[size=sm]/card:px-4 [.border-b]:pb-6 group-data-[size=sm]/card:[.border-b]:pb-4 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",
340
+ className
341
+ ),
342
+ ...props
343
+ }
344
+ );
345
+ }
346
+ function CardTitle({ className, ...props }) {
347
+ return /* @__PURE__ */ jsxRuntime.jsx(
348
+ "div",
349
+ {
350
+ "data-slot": "card-title",
351
+ className: cn("text-base font-medium", className),
352
+ ...props
353
+ }
354
+ );
355
+ }
356
+ function CardDescription({ className, ...props }) {
357
+ return /* @__PURE__ */ jsxRuntime.jsx(
358
+ "div",
359
+ {
360
+ "data-slot": "card-description",
361
+ className: cn("text-muted-foreground text-sm", className),
362
+ ...props
363
+ }
364
+ );
365
+ }
366
+ function CardContent({ className, ...props }) {
367
+ return /* @__PURE__ */ jsxRuntime.jsx(
368
+ "div",
369
+ {
370
+ "data-slot": "card-content",
371
+ className: cn("px-6 group-data-[size=sm]/card:px-4", className),
372
+ ...props
373
+ }
374
+ );
375
+ }
376
+ var Card2 = ({
377
+ children,
378
+ title,
379
+ subtitle,
380
+ className,
381
+ style
382
+ }) => {
383
+ return /* @__PURE__ */ jsxRuntime.jsxs(
384
+ Card,
385
+ {
386
+ className: cn("w-full max-w-2xl shadow-sm", className),
387
+ style,
388
+ children: [
389
+ (title || subtitle) && /* @__PURE__ */ jsxRuntime.jsxs(CardHeader, { className: "pb-3", children: [
390
+ title && /* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-lg", children: title }),
391
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx(CardDescription, { children: subtitle })
392
+ ] }),
393
+ /* @__PURE__ */ jsxRuntime.jsx(CardContent, { className: "flex flex-col gap-4", children })
394
+ ]
395
+ }
396
+ );
397
+ };
398
+ var Row = ({
399
+ children,
400
+ gap = "md",
401
+ align = "start",
402
+ justify = "start",
403
+ wrap = false,
404
+ className,
405
+ style
406
+ }) => {
407
+ const gapClasses = {
408
+ xs: "gap-0",
409
+ sm: "gap-1",
410
+ md: "gap-2",
411
+ lg: "gap-4",
412
+ xl: "gap-6"
413
+ };
414
+ const alignClasses = {
415
+ start: "items-start",
416
+ center: "items-center",
417
+ end: "items-end",
418
+ stretch: "items-stretch"
419
+ };
420
+ const justifyClasses = {
421
+ start: "justify-start",
422
+ center: "justify-center",
423
+ end: "justify-end",
424
+ between: "justify-between",
425
+ around: "justify-around"
426
+ };
427
+ return /* @__PURE__ */ jsxRuntime.jsx(
428
+ "div",
429
+ {
430
+ className: cn(
431
+ "flex flex-row w-full",
432
+ gapClasses[gap] || "gap-4",
433
+ alignClasses[align] || "items-start",
434
+ justifyClasses[justify] || "justify-start",
435
+ wrap ? "flex-wrap" : "flex-nowrap",
436
+ className
437
+ ),
438
+ style,
439
+ children
440
+ }
441
+ );
442
+ };
443
+ var Col = ({
444
+ children,
445
+ gap = "sm",
446
+ align = "start",
447
+ justify = "start",
448
+ wrap = "nowrap",
449
+ flex = 1,
450
+ width,
451
+ height,
452
+ padding,
453
+ overflow,
454
+ position = "static",
455
+ className,
456
+ style
457
+ }) => {
458
+ const gapClasses = {
459
+ xs: "gap-1",
460
+ sm: "gap-2",
461
+ md: "gap-4",
462
+ lg: "gap-6",
463
+ xl: "gap-8"
464
+ };
465
+ const alignClasses = {
466
+ start: "items-start",
467
+ center: "items-center",
468
+ end: "items-end",
469
+ stretch: "items-stretch"
470
+ };
471
+ const justifyClasses = {
472
+ start: "justify-start",
473
+ center: "justify-center",
474
+ end: "justify-end",
475
+ between: "justify-between",
476
+ around: "justify-around"
477
+ };
478
+ const overflowClasses = {
479
+ auto: "overflow-auto",
480
+ hidden: "overflow-hidden",
481
+ scroll: "overflow-scroll",
482
+ visible: "overflow-visible"
483
+ };
484
+ const positionClasses = {
485
+ static: "static",
486
+ relative: "relative",
487
+ absolute: "absolute",
488
+ fixed: "fixed",
489
+ sticky: "sticky"
490
+ };
491
+ return /* @__PURE__ */ jsxRuntime.jsx(
492
+ "div",
493
+ {
494
+ className: cn(
495
+ "flex flex-col",
496
+ gapClasses[gap] || "gap-2",
497
+ alignClasses[align] || "items-start",
498
+ justifyClasses[justify] || "justify-start",
499
+ wrap === "wrap" ? "flex-wrap" : "flex-nowrap",
500
+ overflow && overflowClasses[overflow],
501
+ position && positionClasses[position],
502
+ className
503
+ ),
504
+ style: {
505
+ flex,
506
+ width,
507
+ height,
508
+ padding,
509
+ ...style
510
+ },
511
+ children
512
+ }
513
+ );
514
+ };
515
+ var Box = ({
516
+ children,
517
+ padding = "md",
518
+ margin,
519
+ background,
520
+ border = false,
521
+ borderRadius,
522
+ width,
523
+ height,
524
+ overflow = "visible",
525
+ className,
526
+ style
527
+ }) => {
528
+ const paddingClasses = {
529
+ xs: "p-1",
530
+ sm: "p-2",
531
+ md: "p-4",
532
+ lg: "p-6",
533
+ xl: "p-8"
534
+ };
535
+ const overflowClasses = {
536
+ auto: "overflow-auto",
537
+ hidden: "overflow-hidden",
538
+ scroll: "overflow-scroll",
539
+ visible: "overflow-visible"
540
+ };
541
+ return /* @__PURE__ */ jsxRuntime.jsx(
542
+ "div",
543
+ {
544
+ className: cn(
545
+ paddingClasses[padding] || "p-4",
546
+ border && "border rounded-md",
547
+ overflowClasses[overflow],
548
+ className
549
+ ),
550
+ style: {
551
+ margin,
552
+ background: background ?? void 0,
553
+ borderRadius,
554
+ width,
555
+ height,
556
+ ...style
557
+ },
558
+ children
559
+ }
560
+ );
561
+ };
562
+ var Spacer = ({
563
+ size = "md",
564
+ direction = "vertical",
565
+ className,
566
+ style
567
+ }) => {
568
+ const sizeClasses = {
569
+ xs: "p-0.5",
570
+ sm: "p-1",
571
+ md: "p-2",
572
+ lg: "p-4",
573
+ xl: "p-8"
574
+ };
575
+ return /* @__PURE__ */ jsxRuntime.jsx(
576
+ "div",
577
+ {
578
+ className: cn(
579
+ direction === "vertical" ? "w-full" : "h-full",
580
+ sizeClasses[size] || "p-2",
581
+ className
582
+ ),
583
+ style
584
+ }
585
+ );
586
+ };
587
+ function Separator({
588
+ className,
589
+ orientation = "horizontal",
590
+ ...props
591
+ }) {
592
+ return /* @__PURE__ */ jsxRuntime.jsx(
593
+ separator.Separator,
594
+ {
595
+ "data-slot": "separator",
596
+ orientation,
597
+ className: cn(
598
+ "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",
599
+ className
600
+ ),
601
+ ...props
602
+ }
603
+ );
604
+ }
605
+ var Divider = ({
606
+ orientation = "horizontal",
607
+ className,
608
+ style
609
+ }) => {
610
+ return /* @__PURE__ */ jsxRuntime.jsx(
611
+ Separator,
612
+ {
613
+ orientation,
614
+ className: cn("my-4", className),
615
+ style
616
+ }
617
+ );
618
+ };
619
+ var List = ({ children, width, className, style }) => {
620
+ return /* @__PURE__ */ jsxRuntime.jsx(
621
+ "div",
622
+ {
623
+ className: cn("flex flex-col list-none p-0 m-0", className),
624
+ style: {
625
+ width,
626
+ ...style
627
+ },
628
+ children
629
+ }
630
+ );
631
+ };
632
+ var ListItem = ({
633
+ children,
634
+ orientation = "horizontal",
635
+ gap = "md",
636
+ align,
637
+ justify = "start",
638
+ onClickAction,
639
+ width,
640
+ padding = "md",
641
+ className,
642
+ style
643
+ }) => {
644
+ const { sendEvent } = useMelony();
645
+ const paddingClasses = {
646
+ xs: "px-1.5 py-1",
647
+ sm: "px-2 py-1.5",
648
+ md: "px-3 py-2",
649
+ lg: "px-4 py-3",
650
+ xl: "px-6 py-4"
651
+ };
652
+ const isInteractive = !!onClickAction;
653
+ const gapClasses = {
654
+ xs: "gap-1",
655
+ sm: "gap-2",
656
+ md: "gap-3",
657
+ lg: "gap-4",
658
+ xl: "gap-6"
659
+ };
660
+ const resolvedAlign = align ?? (orientation === "vertical" ? "start" : "center");
661
+ const alignClasses = {
662
+ start: "items-start",
663
+ center: "items-center",
664
+ end: "items-end",
665
+ stretch: "items-stretch"
666
+ };
667
+ const justifyClasses = {
668
+ start: "justify-start",
669
+ center: "justify-center",
670
+ end: "justify-end",
671
+ between: "justify-between",
672
+ around: "justify-around"
673
+ };
674
+ const handleClick = () => {
675
+ if (onClickAction) {
676
+ sendEvent(onClickAction);
677
+ }
678
+ };
679
+ return /* @__PURE__ */ jsxRuntime.jsx(
680
+ "div",
681
+ {
682
+ onClick: isInteractive ? handleClick : void 0,
683
+ className: cn(
684
+ "flex rounded-md transition-colors",
685
+ orientation === "horizontal" ? "flex-row" : "flex-col",
686
+ gapClasses[gap] || "gap-3",
687
+ alignClasses[resolvedAlign],
688
+ justifyClasses[justify],
689
+ paddingClasses[padding] || "px-3 py-2",
690
+ isInteractive ? "cursor-pointer hover:bg-muted" : "cursor-default",
691
+ className
692
+ ),
693
+ style: {
694
+ width,
695
+ ...style
696
+ },
697
+ children
698
+ }
699
+ );
700
+ };
701
+ var Image = ({
702
+ src,
703
+ alt,
704
+ size = "sm",
705
+ className,
706
+ style
707
+ }) => {
708
+ const [hasError, setHasError] = React9.useState(false);
709
+ const [isLoading, setIsLoading] = React9.useState(true);
710
+ const sizes = {
711
+ sm: "h-11 w-11",
712
+ md: "h-22 w-22",
713
+ lg: "h-44 w-44"
714
+ };
715
+ const handleError = () => {
716
+ setHasError(true);
717
+ setIsLoading(false);
718
+ };
719
+ const handleLoad = () => {
720
+ setIsLoading(false);
721
+ };
722
+ if (hasError) {
723
+ return /* @__PURE__ */ jsxRuntime.jsx(
724
+ "div",
725
+ {
726
+ className: cn(
727
+ "flex items-center justify-center rounded-md border bg-muted text-muted-foreground",
728
+ sizes[size] || "h-11 w-11",
729
+ className
730
+ ),
731
+ style,
732
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px]", children: "Error" })
733
+ }
734
+ );
735
+ }
736
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("relative overflow-hidden rounded-md border", className), style, children: [
737
+ /* @__PURE__ */ jsxRuntime.jsx(
738
+ "img",
739
+ {
740
+ src,
741
+ alt,
742
+ onError: handleError,
743
+ onLoad: handleLoad,
744
+ className: cn(
745
+ "block h-auto w-full transition-opacity duration-200",
746
+ isLoading ? "opacity-0" : "opacity-100",
747
+ sizes[size]
748
+ )
749
+ }
750
+ ),
751
+ isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-muted animate-pulse" })
752
+ ] });
753
+ };
754
+ var Icon = ({
755
+ name,
756
+ size,
757
+ color,
758
+ className,
759
+ style
760
+ }) => {
761
+ const IconComponent = ICONS__namespace[name];
762
+ if (!IconComponent) return null;
763
+ const sizeMap = {
764
+ xs: 12,
765
+ sm: 16,
766
+ md: 20,
767
+ lg: 24,
768
+ xl: 28,
769
+ xxl: 32
770
+ };
771
+ const resolvedSize = typeof size === "string" && size in sizeMap ? sizeMap[size] : typeof size === "number" ? size : 20;
772
+ return /* @__PURE__ */ jsxRuntime.jsx(
773
+ "div",
774
+ {
775
+ className: cn("inline-flex items-center justify-center", className),
776
+ style,
777
+ children: /* @__PURE__ */ jsxRuntime.jsx(
778
+ IconComponent,
779
+ {
780
+ size: resolvedSize,
781
+ color: color || "currentColor",
782
+ strokeWidth: 1.5
783
+ }
784
+ )
785
+ }
786
+ );
787
+ };
788
+ var badgeVariants = classVarianceAuthority.cva(
789
+ "h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",
790
+ {
791
+ variants: {
792
+ variant: {
793
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
794
+ secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
795
+ destructive: "bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",
796
+ outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/30",
797
+ ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
798
+ link: "text-primary underline-offset-4 hover:underline"
799
+ }
800
+ },
801
+ defaultVariants: {
802
+ variant: "default"
803
+ }
804
+ }
805
+ );
806
+ function Badge({
807
+ className,
808
+ variant = "default",
809
+ render,
810
+ ...props
811
+ }) {
812
+ return useRender.useRender({
813
+ defaultTagName: "span",
814
+ props: mergeProps.mergeProps(
815
+ {
816
+ className: cn(badgeVariants({ className, variant }))
817
+ },
818
+ props
819
+ ),
820
+ render,
821
+ state: {
822
+ slot: "badge",
823
+ variant
824
+ }
825
+ });
826
+ }
827
+ var Badge2 = ({
828
+ label,
829
+ variant = "primary",
830
+ className,
831
+ style
832
+ }) => {
833
+ const variantMap = {
834
+ primary: "default",
835
+ secondary: "secondary",
836
+ danger: "destructive",
837
+ success: "default",
838
+ // Mapping success to default/primary
839
+ warning: "secondary"
840
+ // Mapping warning to secondary
841
+ };
842
+ return /* @__PURE__ */ jsxRuntime.jsx(
843
+ Badge,
844
+ {
845
+ variant: variantMap[variant] || "default",
846
+ className,
847
+ style,
848
+ children: label
849
+ }
850
+ );
851
+ };
852
+ var Chart = ({
853
+ data,
854
+ chartType = "bar",
855
+ size = "md",
856
+ showValues = false,
857
+ showGrid = false,
858
+ showTooltips = true,
859
+ className,
860
+ style
861
+ }) => {
862
+ const [tooltip, setTooltip] = React9.useState(null);
863
+ if (!Array.isArray(data)) {
864
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-destructive border border-destructive/20 rounded-md bg-destructive/5", children: "Error: Chart data must be an array" });
865
+ }
866
+ const maxValue = Math.max(...data.map((d) => d.value), 1);
867
+ const padding = { top: 40, right: 20, bottom: 40, left: 20 };
868
+ const chartWidth = size === "sm" ? 300 : size === "md" ? 450 : size === "lg" ? 600 : 800;
869
+ const chartHeight = size === "sm" ? 150 : size === "md" ? 250 : size === "lg" ? 350 : 450;
870
+ const defaultColors = [
871
+ "hsl(var(--primary))",
872
+ "hsl(var(--chart-1, 217 91% 60%))",
873
+ "hsl(var(--chart-2, 142 71% 45%))",
874
+ "hsl(var(--chart-3, 31 92% 55%))",
875
+ "hsl(var(--chart-4, 346 84% 61%))",
876
+ "hsl(var(--chart-5, 271 81% 56%))"
877
+ ];
878
+ const getColor = (index, color) => {
879
+ if (color) return color;
880
+ return defaultColors[index % defaultColors.length];
881
+ };
882
+ const renderGrid = () => {
883
+ if (!showGrid) return null;
884
+ return [0, 0.25, 0.5, 0.75, 1].map((fraction, i) => /* @__PURE__ */ jsxRuntime.jsx(
885
+ "line",
886
+ {
887
+ x1: padding.left,
888
+ y1: padding.top + chartHeight * (1 - fraction),
889
+ x2: chartWidth - padding.right,
890
+ y2: padding.top + chartHeight * (1 - fraction),
891
+ stroke: "currentColor",
892
+ className: "text-border",
893
+ strokeDasharray: "4,4",
894
+ strokeOpacity: 0.5
895
+ },
896
+ i
897
+ ));
898
+ };
899
+ const renderTooltip = () => {
900
+ if (!tooltip || !tooltip.visible) return null;
901
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "pointer-events-none", children: [
902
+ /* @__PURE__ */ jsxRuntime.jsx(
903
+ "rect",
904
+ {
905
+ x: tooltip.x - 40,
906
+ y: tooltip.y - 45,
907
+ width: 80,
908
+ height: 40,
909
+ fill: "hsl(var(--popover))",
910
+ stroke: "hsl(var(--border))",
911
+ strokeWidth: 1,
912
+ rx: 6,
913
+ className: "shadow-md"
914
+ }
915
+ ),
916
+ /* @__PURE__ */ jsxRuntime.jsx(
917
+ "text",
918
+ {
919
+ x: tooltip.x,
920
+ y: tooltip.y - 28,
921
+ textAnchor: "middle",
922
+ className: "fill-popover-foreground text-[10px] font-semibold",
923
+ children: tooltip.value
924
+ }
925
+ ),
926
+ /* @__PURE__ */ jsxRuntime.jsx(
927
+ "text",
928
+ {
929
+ x: tooltip.x,
930
+ y: tooltip.y - 14,
931
+ textAnchor: "middle",
932
+ className: "fill-muted-foreground text-[9px]",
933
+ children: tooltip.label
934
+ }
935
+ )
936
+ ] });
937
+ };
938
+ const renderBarChart = () => {
939
+ const totalBarSpace = chartWidth - padding.left - padding.right;
940
+ const barSpacing = data.length > 1 ? totalBarSpace * 0.1 / data.length : 0;
941
+ const actualBarWidth = (totalBarSpace - barSpacing * (data.length + 1)) / data.length;
942
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: chartWidth, height: chartHeight + padding.bottom, className: "overflow-visible", children: [
943
+ renderGrid(),
944
+ data.map((item, index) => {
945
+ const barHeight = item.value / maxValue * chartHeight;
946
+ const x = padding.left + barSpacing + index * (actualBarWidth + barSpacing);
947
+ const y = padding.top + chartHeight - barHeight;
948
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
949
+ /* @__PURE__ */ jsxRuntime.jsx(
950
+ "rect",
951
+ {
952
+ x,
953
+ y,
954
+ width: actualBarWidth,
955
+ height: barHeight,
956
+ fill: getColor(index, item.color),
957
+ rx: 4,
958
+ onMouseEnter: () => showTooltips && setTooltip({ visible: true, x: x + actualBarWidth / 2, y: y - 5, label: item.label, value: item.value }),
959
+ onMouseLeave: () => setTooltip({ visible: false, x: 0, y: 0, label: "", value: 0 }),
960
+ className: "transition-all hover:opacity-80 cursor-pointer"
961
+ }
962
+ ),
963
+ /* @__PURE__ */ jsxRuntime.jsx(
964
+ "text",
965
+ {
966
+ x: x + actualBarWidth / 2,
967
+ y: padding.top + chartHeight + 20,
968
+ textAnchor: "middle",
969
+ className: "fill-muted-foreground text-[10px]",
970
+ children: item.label
971
+ }
972
+ )
973
+ ] }, index);
974
+ }),
975
+ showTooltips && renderTooltip()
976
+ ] });
977
+ };
978
+ const renderLineChart = () => {
979
+ const points = data.map((item, index) => ({
980
+ x: padding.left + index / Math.max(data.length - 1, 1) * (chartWidth - padding.left - padding.right),
981
+ y: padding.top + chartHeight - item.value / maxValue * chartHeight,
982
+ ...item
983
+ }));
984
+ const pathData = points.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`).join(" ");
985
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: chartWidth, height: chartHeight + padding.bottom, className: "overflow-visible", children: [
986
+ renderGrid(),
987
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: pathData, fill: "none", stroke: getColor(0), strokeWidth: 3, className: "transition-all" }),
988
+ points.map((point, index) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
989
+ /* @__PURE__ */ jsxRuntime.jsx(
990
+ "circle",
991
+ {
992
+ cx: point.x,
993
+ cy: point.y,
994
+ r: 5,
995
+ fill: getColor(index, point.color),
996
+ stroke: "hsl(var(--background))",
997
+ strokeWidth: 2,
998
+ onMouseEnter: () => showTooltips && setTooltip({ visible: true, x: point.x, y: point.y - 5, label: point.label, value: point.value }),
999
+ onMouseLeave: () => setTooltip({ visible: false, x: 0, y: 0, label: "", value: 0 }),
1000
+ className: "hover:r-6 transition-all cursor-pointer"
1001
+ }
1002
+ ),
1003
+ /* @__PURE__ */ jsxRuntime.jsx(
1004
+ "text",
1005
+ {
1006
+ x: point.x,
1007
+ y: padding.top + chartHeight + 20,
1008
+ textAnchor: "middle",
1009
+ className: "fill-muted-foreground text-[10px]",
1010
+ children: point.label
1011
+ }
1012
+ )
1013
+ ] }, index)),
1014
+ showTooltips && renderTooltip()
1015
+ ] });
1016
+ };
1017
+ const renderChart = () => {
1018
+ switch (chartType) {
1019
+ case "line":
1020
+ return renderLineChart();
1021
+ case "bar":
1022
+ default:
1023
+ return renderBarChart();
1024
+ }
1025
+ };
1026
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("py-4 overflow-x-auto", className), style, children: renderChart() });
1027
+ };
1028
+ var Text = ({
1029
+ value,
1030
+ size = "md",
1031
+ weight = "normal",
1032
+ align = "start",
1033
+ className,
1034
+ style
1035
+ }) => {
1036
+ const sizeClasses = {
1037
+ xs: "text-xs",
1038
+ sm: "text-sm",
1039
+ md: "text-base",
1040
+ lg: "text-lg",
1041
+ xl: "text-xl"
1042
+ };
1043
+ const weightClasses = {
1044
+ light: "font-light",
1045
+ normal: "font-normal",
1046
+ medium: "font-medium",
1047
+ semibold: "font-semibold",
1048
+ bold: "font-bold"
1049
+ };
1050
+ const alignClasses = {
1051
+ start: "text-left",
1052
+ center: "text-center",
1053
+ end: "text-right",
1054
+ stretch: "text-justify"
1055
+ };
1056
+ return /* @__PURE__ */ jsxRuntime.jsx(
1057
+ "span",
1058
+ {
1059
+ className: cn(
1060
+ sizeClasses[size] || "text-base",
1061
+ weightClasses[weight] || "font-normal",
1062
+ alignClasses[align] || "text-left",
1063
+ className
1064
+ ),
1065
+ style,
1066
+ children: value
1067
+ }
1068
+ );
1069
+ };
1070
+ var Heading = ({
1071
+ value,
1072
+ level = 2,
1073
+ className,
1074
+ style
1075
+ }) => {
1076
+ const Tag = `h${level}`;
1077
+ const levelClasses = {
1078
+ h1: "text-3xl font-bold tracking-tight",
1079
+ h2: "text-2xl font-semibold tracking-tight",
1080
+ h3: "text-xl font-semibold tracking-tight",
1081
+ h4: "text-lg font-semibold tracking-tight",
1082
+ h5: "text-base font-semibold",
1083
+ h6: "text-sm font-semibold"
1084
+ };
1085
+ return /* @__PURE__ */ jsxRuntime.jsx(
1086
+ Tag,
1087
+ {
1088
+ className: cn(
1089
+ levelClasses[Tag] || levelClasses.h2,
1090
+ "text-foreground",
1091
+ className
1092
+ ),
1093
+ style,
1094
+ children: value
1095
+ }
1096
+ );
1097
+ };
1098
+ function Input({ className, type, ...props }) {
1099
+ return /* @__PURE__ */ jsxRuntime.jsx(
1100
+ input.Input,
1101
+ {
1102
+ type,
1103
+ "data-slot": "input",
1104
+ className: cn(
1105
+ "bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 h-9 rounded-4xl border px-3 py-1 text-base transition-colors file:h-7 file:text-sm file:font-medium focus-visible:ring-[3px] aria-invalid:ring-[3px] md:text-sm file:text-foreground placeholder:text-muted-foreground w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
1106
+ className
1107
+ ),
1108
+ ...props
1109
+ }
1110
+ );
1111
+ }
1112
+ function Label({ className, ...props }) {
1113
+ return /* @__PURE__ */ jsxRuntime.jsx(
1114
+ "label",
1115
+ {
1116
+ "data-slot": "label",
1117
+ className: cn(
1118
+ "gap-2 text-sm leading-none font-medium group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed",
1119
+ className
1120
+ ),
1121
+ ...props
1122
+ }
1123
+ );
1124
+ }
1125
+ var fieldVariants = classVarianceAuthority.cva("data-[invalid=true]:text-destructive gap-3 group/field flex w-full", {
1126
+ variants: {
1127
+ orientation: {
1128
+ vertical: "flex-col [&>*]:w-full [&>.sr-only]:w-auto",
1129
+ horizontal: "flex-row items-center [&>[data-slot=field-label]]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
1130
+ responsive: "flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto @md/field-group:[&>[data-slot=field-label]]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
1131
+ }
1132
+ },
1133
+ defaultVariants: {
1134
+ orientation: "vertical"
1135
+ }
1136
+ });
1137
+ function Field({
1138
+ className,
1139
+ orientation = "vertical",
1140
+ ...props
1141
+ }) {
1142
+ return /* @__PURE__ */ jsxRuntime.jsx(
1143
+ "div",
1144
+ {
1145
+ role: "group",
1146
+ "data-slot": "field",
1147
+ "data-orientation": orientation,
1148
+ className: cn(fieldVariants({ orientation }), className),
1149
+ ...props
1150
+ }
1151
+ );
1152
+ }
1153
+ function FieldTitle({ className, ...props }) {
1154
+ return /* @__PURE__ */ jsxRuntime.jsx(
1155
+ "div",
1156
+ {
1157
+ "data-slot": "field-label",
1158
+ className: cn(
1159
+ "gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center leading-snug",
1160
+ className
1161
+ ),
1162
+ ...props
1163
+ }
1164
+ );
1165
+ }
1166
+ var Input2 = ({
1167
+ inputType = "text",
1168
+ placeholder,
1169
+ defaultValue,
1170
+ value,
1171
+ label,
1172
+ name,
1173
+ disabled,
1174
+ onChangeAction,
1175
+ className,
1176
+ style
1177
+ }) => {
1178
+ const { sendEvent } = useMelony();
1179
+ const handleChange = (e) => {
1180
+ if (onChangeAction) {
1181
+ sendEvent({
1182
+ ...onChangeAction,
1183
+ data: {
1184
+ name: name || "",
1185
+ value: e.target.value
1186
+ }
1187
+ });
1188
+ }
1189
+ };
1190
+ return /* @__PURE__ */ jsxRuntime.jsxs(Field, { className: cn("w-full", className), style, children: [
1191
+ label && /* @__PURE__ */ jsxRuntime.jsx(FieldTitle, { children: label }),
1192
+ /* @__PURE__ */ jsxRuntime.jsx(
1193
+ Input,
1194
+ {
1195
+ type: inputType,
1196
+ name,
1197
+ id: name,
1198
+ placeholder,
1199
+ defaultValue,
1200
+ value,
1201
+ disabled,
1202
+ onChange: handleChange
1203
+ }
1204
+ )
1205
+ ] });
1206
+ };
1207
+ function Textarea({ className, ...props }) {
1208
+ return /* @__PURE__ */ jsxRuntime.jsx(
1209
+ "textarea",
1210
+ {
1211
+ "data-slot": "textarea",
1212
+ className: cn(
1213
+ "border-input bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 resize-none rounded-xl border px-3 py-3 text-base transition-colors focus-visible:ring-[3px] aria-invalid:ring-[3px] md:text-sm placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-50",
1214
+ className
1215
+ ),
1216
+ ...props
1217
+ }
1218
+ );
1219
+ }
1220
+ var Textarea2 = ({
1221
+ placeholder,
1222
+ defaultValue,
1223
+ value,
1224
+ label,
1225
+ name,
1226
+ disabled,
1227
+ rows,
1228
+ onChangeAction,
1229
+ className,
1230
+ style
1231
+ }) => {
1232
+ const { sendEvent } = useMelony();
1233
+ const handleChange = (e) => {
1234
+ if (onChangeAction) {
1235
+ sendEvent({
1236
+ ...onChangeAction,
1237
+ data: {
1238
+ name: name || "",
1239
+ value: e.target.value
1240
+ }
1241
+ });
1242
+ }
1243
+ };
1244
+ return /* @__PURE__ */ jsxRuntime.jsxs(Field, { className: cn("w-full", className), style, children: [
1245
+ label && /* @__PURE__ */ jsxRuntime.jsx(FieldTitle, { children: label }),
1246
+ /* @__PURE__ */ jsxRuntime.jsx(
1247
+ Textarea,
1248
+ {
1249
+ name,
1250
+ id: name,
1251
+ placeholder,
1252
+ defaultValue,
1253
+ value,
1254
+ disabled,
1255
+ rows,
1256
+ onChange: handleChange
1257
+ }
1258
+ )
1259
+ ] });
1260
+ };
1261
+ var Select = select.Select.Root;
1262
+ function SelectValue({ className, ...props }) {
1263
+ return /* @__PURE__ */ jsxRuntime.jsx(
1264
+ select.Select.Value,
1265
+ {
1266
+ "data-slot": "select-value",
1267
+ className: cn("flex flex-1 text-left", className),
1268
+ ...props
1269
+ }
1270
+ );
1271
+ }
1272
+ function SelectTrigger({
1273
+ className,
1274
+ size = "default",
1275
+ children,
1276
+ ...props
1277
+ }) {
1278
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1279
+ select.Select.Trigger,
1280
+ {
1281
+ "data-slot": "select-trigger",
1282
+ "data-size": size,
1283
+ className: cn(
1284
+ "border-input data-[placeholder]:text-muted-foreground bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 gap-1.5 rounded-4xl border px-3 py-2 text-sm transition-colors focus-visible:ring-[3px] aria-invalid:ring-[3px] data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:flex *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-4 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
1285
+ className
1286
+ ),
1287
+ ...props,
1288
+ children: [
1289
+ children,
1290
+ /* @__PURE__ */ jsxRuntime.jsx(
1291
+ select.Select.Icon,
1292
+ {
1293
+ render: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconSelector, { className: "text-muted-foreground size-4 pointer-events-none" })
1294
+ }
1295
+ )
1296
+ ]
1297
+ }
1298
+ );
1299
+ }
1300
+ function SelectContent({
1301
+ className,
1302
+ children,
1303
+ side = "bottom",
1304
+ sideOffset = 4,
1305
+ align = "center",
1306
+ alignOffset = 0,
1307
+ alignItemWithTrigger = true,
1308
+ ...props
1309
+ }) {
1310
+ return /* @__PURE__ */ jsxRuntime.jsx(select.Select.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1311
+ select.Select.Positioner,
1312
+ {
1313
+ side,
1314
+ sideOffset,
1315
+ align,
1316
+ alignOffset,
1317
+ alignItemWithTrigger,
1318
+ className: "isolate z-50",
1319
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1320
+ select.Select.Popup,
1321
+ {
1322
+ "data-slot": "select-content",
1323
+ className: cn("bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/5 min-w-36 rounded-2xl shadow-2xl ring-1 duration-100 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto", className),
1324
+ ...props,
1325
+ children: [
1326
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
1327
+ /* @__PURE__ */ jsxRuntime.jsx(select.Select.List, { children }),
1328
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton, {})
1329
+ ]
1330
+ }
1331
+ )
1332
+ }
1333
+ ) });
1334
+ }
1335
+ function SelectItem({
1336
+ className,
1337
+ children,
1338
+ ...props
1339
+ }) {
1340
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1341
+ select.Select.Item,
1342
+ {
1343
+ "data-slot": "select-item",
1344
+ className: cn(
1345
+ "focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground gap-2.5 rounded-xl py-2 pr-8 pl-3 text-sm [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
1346
+ className
1347
+ ),
1348
+ ...props,
1349
+ children: [
1350
+ /* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemText, { className: "flex flex-1 gap-2 shrink-0 whitespace-nowrap", children }),
1351
+ /* @__PURE__ */ jsxRuntime.jsx(
1352
+ select.Select.ItemIndicator,
1353
+ {
1354
+ render: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center" }),
1355
+ children: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconCheck, { className: "pointer-events-none" })
1356
+ }
1357
+ )
1358
+ ]
1359
+ }
1360
+ );
1361
+ }
1362
+ function SelectScrollUpButton({
1363
+ className,
1364
+ ...props
1365
+ }) {
1366
+ return /* @__PURE__ */ jsxRuntime.jsx(
1367
+ select.Select.ScrollUpArrow,
1368
+ {
1369
+ "data-slot": "select-scroll-up-button",
1370
+ className: cn("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4 top-0 w-full", className),
1371
+ ...props,
1372
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1373
+ ICONS.IconChevronUp,
1374
+ {}
1375
+ )
1376
+ }
1377
+ );
1378
+ }
1379
+ function SelectScrollDownButton({
1380
+ className,
1381
+ ...props
1382
+ }) {
1383
+ return /* @__PURE__ */ jsxRuntime.jsx(
1384
+ select.Select.ScrollDownArrow,
1385
+ {
1386
+ "data-slot": "select-scroll-down-button",
1387
+ className: cn("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4 bottom-0 w-full", className),
1388
+ ...props,
1389
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1390
+ ICONS.IconChevronDown,
1391
+ {}
1392
+ )
1393
+ }
1394
+ );
1395
+ }
1396
+ var Select2 = ({
1397
+ options,
1398
+ defaultValue,
1399
+ value,
1400
+ label,
1401
+ name,
1402
+ disabled,
1403
+ placeholder,
1404
+ onChangeAction,
1405
+ className,
1406
+ style
1407
+ }) => {
1408
+ const { sendEvent } = useMelony();
1409
+ const handleValueChange = (val) => {
1410
+ if (onChangeAction) {
1411
+ sendEvent({
1412
+ ...onChangeAction,
1413
+ data: {
1414
+ name: name || "",
1415
+ value: val
1416
+ }
1417
+ });
1418
+ }
1419
+ };
1420
+ return /* @__PURE__ */ jsxRuntime.jsxs(Field, { className: cn("w-full", className), style, children: [
1421
+ label && /* @__PURE__ */ jsxRuntime.jsx(FieldTitle, { children: label }),
1422
+ /* @__PURE__ */ jsxRuntime.jsxs(
1423
+ Select,
1424
+ {
1425
+ defaultValue,
1426
+ value,
1427
+ disabled,
1428
+ onValueChange: handleValueChange,
1429
+ children: [
1430
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: placeholder || "Select an option" }) }),
1431
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
1432
+ ]
1433
+ }
1434
+ )
1435
+ ] });
1436
+ };
1437
+ var Label2 = ({
1438
+ value,
1439
+ htmlFor,
1440
+ required,
1441
+ className,
1442
+ style
1443
+ }) => {
1444
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1445
+ Label,
1446
+ {
1447
+ htmlFor,
1448
+ className: cn("flex items-center gap-1", className),
1449
+ style,
1450
+ children: [
1451
+ value,
1452
+ required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive", children: "*" })
1453
+ ]
1454
+ }
1455
+ );
1456
+ };
1457
+ var Checkbox = ({
1458
+ label,
1459
+ name,
1460
+ value = "on",
1461
+ checked,
1462
+ defaultChecked,
1463
+ disabled,
1464
+ onChangeAction,
1465
+ className,
1466
+ style
1467
+ }) => {
1468
+ const { sendEvent } = useMelony();
1469
+ const handleChange = (e) => {
1470
+ if (onChangeAction) {
1471
+ sendEvent({
1472
+ ...onChangeAction,
1473
+ data: {
1474
+ name: name || "",
1475
+ value,
1476
+ checked: e.target.checked
1477
+ }
1478
+ });
1479
+ }
1480
+ };
1481
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1482
+ "div",
1483
+ {
1484
+ className: cn("flex items-center gap-2", className),
1485
+ style,
1486
+ children: [
1487
+ /* @__PURE__ */ jsxRuntime.jsx(
1488
+ "input",
1489
+ {
1490
+ type: "checkbox",
1491
+ name,
1492
+ id: name,
1493
+ value,
1494
+ checked,
1495
+ defaultChecked,
1496
+ disabled,
1497
+ onChange: handleChange,
1498
+ className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50"
1499
+ }
1500
+ ),
1501
+ label && /* @__PURE__ */ jsxRuntime.jsx(
1502
+ Label2,
1503
+ {
1504
+ htmlFor: name,
1505
+ value: label,
1506
+ className: cn(
1507
+ "cursor-pointer select-none text-sm font-medium leading-none",
1508
+ disabled && "cursor-not-allowed opacity-50"
1509
+ )
1510
+ }
1511
+ )
1512
+ ]
1513
+ }
1514
+ );
1515
+ };
1516
+ var RadioGroup = ({
1517
+ name,
1518
+ options,
1519
+ defaultValue,
1520
+ value,
1521
+ label,
1522
+ disabled,
1523
+ orientation = "vertical",
1524
+ onChangeAction,
1525
+ className,
1526
+ style
1527
+ }) => {
1528
+ const { sendEvent } = useMelony();
1529
+ const handleChange = (e) => {
1530
+ if (onChangeAction) {
1531
+ sendEvent({
1532
+ ...onChangeAction,
1533
+ data: {
1534
+ name,
1535
+ value: e.target.value
1536
+ }
1537
+ });
1538
+ }
1539
+ };
1540
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-3", className), style, children: [
1541
+ label && /* @__PURE__ */ jsxRuntime.jsx(Label2, { value: label, className: "text-sm font-semibold" }),
1542
+ /* @__PURE__ */ jsxRuntime.jsx(
1543
+ "div",
1544
+ {
1545
+ className: cn(
1546
+ "flex",
1547
+ orientation === "horizontal" ? "flex-row gap-4" : "flex-col gap-2"
1548
+ ),
1549
+ children: options.map((option, index) => {
1550
+ const radioId = `${name}-${index}`;
1551
+ const isDisabled = disabled || option.disabled;
1552
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1553
+ "div",
1554
+ {
1555
+ className: "flex items-center gap-2",
1556
+ children: [
1557
+ /* @__PURE__ */ jsxRuntime.jsx(
1558
+ "input",
1559
+ {
1560
+ type: "radio",
1561
+ name,
1562
+ id: radioId,
1563
+ value: option.value,
1564
+ defaultChecked: defaultValue === option.value ? true : void 0,
1565
+ checked: value === option.value,
1566
+ disabled: isDisabled,
1567
+ onChange: handleChange,
1568
+ className: "h-4 w-4 border-gray-300 text-primary focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50"
1569
+ }
1570
+ ),
1571
+ /* @__PURE__ */ jsxRuntime.jsx(
1572
+ Label2,
1573
+ {
1574
+ htmlFor: radioId,
1575
+ value: option.label,
1576
+ className: cn(
1577
+ "cursor-pointer select-none text-sm font-medium leading-none",
1578
+ isDisabled && "cursor-not-allowed opacity-50"
1579
+ )
1580
+ }
1581
+ )
1582
+ ]
1583
+ },
1584
+ index
1585
+ );
1586
+ })
1587
+ }
1588
+ )
1589
+ ] });
1590
+ };
1591
+ var buttonVariants = classVarianceAuthority.cva(
1592
+ "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-4xl border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-[3px] aria-invalid:ring-[3px] [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none",
1593
+ {
1594
+ variants: {
1595
+ variant: {
1596
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
1597
+ outline: "border-border bg-input/30 hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",
1598
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
1599
+ ghost: "hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground",
1600
+ destructive: "bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30",
1601
+ link: "text-primary underline-offset-4 hover:underline"
1602
+ },
1603
+ size: {
1604
+ default: "h-9 gap-1.5 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5",
1605
+ xs: "h-6 gap-1 px-2.5 text-xs has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",
1606
+ sm: "h-8 gap-1 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
1607
+ lg: "h-10 gap-1.5 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
1608
+ icon: "size-9",
1609
+ "icon-xs": "size-6 [&_svg:not([class*='size-'])]:size-3",
1610
+ "icon-sm": "size-8",
1611
+ "icon-lg": "size-10"
1612
+ }
1613
+ },
1614
+ defaultVariants: {
1615
+ variant: "default",
1616
+ size: "default"
1617
+ }
1618
+ }
1619
+ );
1620
+ function Button({
1621
+ className,
1622
+ variant = "default",
1623
+ size = "default",
1624
+ ...props
1625
+ }) {
1626
+ return /* @__PURE__ */ jsxRuntime.jsx(
1627
+ button.Button,
1628
+ {
1629
+ "data-slot": "button",
1630
+ className: cn(buttonVariants({ variant, size, className })),
1631
+ ...props
1632
+ }
1633
+ );
1634
+ }
1635
+ var Button2 = ({
1636
+ label,
1637
+ variant = "primary",
1638
+ size = "default",
1639
+ disabled = false,
1640
+ fullWidth = false,
1641
+ onClickAction,
1642
+ className,
1643
+ style
1644
+ }) => {
1645
+ const { sendEvent } = useMelony();
1646
+ const variantMap = {
1647
+ primary: "default",
1648
+ secondary: "secondary",
1649
+ danger: "destructive",
1650
+ outline: "outline",
1651
+ success: "default"
1652
+ // Success doesn't have a direct shadcn mapping in base variant, default is usually primary
1653
+ };
1654
+ return /* @__PURE__ */ jsxRuntime.jsx(
1655
+ Button,
1656
+ {
1657
+ variant: variantMap[variant] || "default",
1658
+ size: size === "md" ? "default" : size,
1659
+ disabled,
1660
+ className: cn(fullWidth ? "w-full" : void 0, className),
1661
+ style,
1662
+ onClick: () => {
1663
+ if (onClickAction) {
1664
+ sendEvent(onClickAction);
1665
+ }
1666
+ },
1667
+ children: label
1668
+ }
1669
+ );
1670
+ };
1671
+ var Form = ({ children, onSubmitAction, className, style }) => {
1672
+ const { sendEvent } = useMelony();
1673
+ const [isSubmitted, setIsSubmitted] = React9.useState(false);
1674
+ const handleSubmit = (e) => {
1675
+ e.preventDefault();
1676
+ if (isSubmitted) return;
1677
+ const formData = new FormData(e.currentTarget);
1678
+ const data = {};
1679
+ formData.forEach((value, key) => {
1680
+ data[key] = value;
1681
+ });
1682
+ if (onSubmitAction) {
1683
+ setIsSubmitted(true);
1684
+ sendEvent({
1685
+ ...onSubmitAction,
1686
+ data: {
1687
+ ...onSubmitAction.data || {},
1688
+ ...data
1689
+ }
1690
+ });
1691
+ }
1692
+ };
1693
+ return /* @__PURE__ */ jsxRuntime.jsx(
1694
+ "form",
1695
+ {
1696
+ onSubmit: handleSubmit,
1697
+ className: cn("w-full", className),
1698
+ style,
1699
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1700
+ "fieldset",
1701
+ {
1702
+ disabled: isSubmitted,
1703
+ className: "m-0 border-0 p-0",
1704
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1705
+ "div",
1706
+ {
1707
+ className: cn(
1708
+ "flex flex-col gap-4 transition-opacity",
1709
+ isSubmitted && "opacity-60 pointer-events-none"
1710
+ ),
1711
+ children
1712
+ }
1713
+ )
1714
+ }
1715
+ )
1716
+ }
1717
+ );
1718
+ };
1719
+ function UIRenderer({ node }) {
1720
+ const { type, props, children } = node;
1721
+ const typeMap = {
1722
+ card: Card2,
1723
+ button: Button2,
1724
+ row: Row,
1725
+ col: Col,
1726
+ text: Text,
1727
+ heading: Heading,
1728
+ badge: Badge2,
1729
+ input: Input2,
1730
+ textarea: Textarea2,
1731
+ select: Select2,
1732
+ checkbox: Checkbox,
1733
+ radioGroup: RadioGroup,
1734
+ spacer: Spacer,
1735
+ divider: Divider,
1736
+ box: Box,
1737
+ image: Image,
1738
+ icon: Icon,
1739
+ list: List,
1740
+ listItem: ListItem,
1741
+ form: Form,
1742
+ chart: Chart,
1743
+ label: Label2
1744
+ };
1745
+ const Component = typeMap[type];
1746
+ if (!Component) {
1747
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-destructive italic text-sm p-2 border border-dashed rounded border-destructive/50 bg-destructive/5", children: [
1748
+ "[Unknown component: ",
1749
+ type,
1750
+ "]"
1751
+ ] });
1752
+ }
1753
+ const renderedChildren = children?.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(UIRenderer, { node: child }, i));
1754
+ const componentProps = { ...props };
1755
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...componentProps, children: renderedChildren });
1756
+ }
1757
+ function Composer({
1758
+ value,
1759
+ onChange,
1760
+ onSubmit,
1761
+ placeholder = "Type a message...",
1762
+ isLoading,
1763
+ className
1764
+ }) {
1765
+ const handleKeyDown = (e) => {
1766
+ if (e.key === "Enter" && !e.shiftKey) {
1767
+ e.preventDefault();
1768
+ onSubmit();
1769
+ }
1770
+ };
1771
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("relative flex flex-col w-full", className), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex flex-col w-full border-input border-[1.5px] rounded-3xl bg-background shadow-sm focus-within:border-ring transition-all p-2", children: [
1772
+ /* @__PURE__ */ jsxRuntime.jsx(
1773
+ Textarea,
1774
+ {
1775
+ value,
1776
+ onChange: (e) => onChange(e.target.value),
1777
+ onKeyDown: handleKeyDown,
1778
+ placeholder,
1779
+ className: "min-h-[44px] max-h-[200px] border-none bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 px-3 py-2 text-[15px] resize-none"
1780
+ }
1781
+ ),
1782
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end items-center px-2 pb-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(
1783
+ Button,
1784
+ {
1785
+ type: "submit",
1786
+ disabled: !value.trim() && !isLoading || isLoading,
1787
+ size: "icon",
1788
+ onClick: () => onSubmit(),
1789
+ className: cn(
1790
+ "h-8 w-8 rounded-full transition-all shrink-0",
1791
+ value.trim() ? "bg-foreground text-background hover:bg-foreground/90" : "bg-muted-foreground/20 text-muted-foreground/40"
1792
+ ),
1793
+ children: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconArrowUp, { className: "h-5 w-5" })
1794
+ }
1795
+ ) })
1796
+ ] }) });
1797
+ }
1798
+ function Thread({
1799
+ className,
1800
+ placeholder = "Type a message...",
1801
+ starterPrompts,
1802
+ onStarterPromptClick
1803
+ }) {
1804
+ const { messages, isLoading, error, sendEvent } = useMelony();
1805
+ const [input, setInput] = React9.useState("");
1806
+ const messagesEndRef = React9.useRef(null);
1807
+ React9.useEffect(() => {
1808
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
1809
+ }, [messages]);
1810
+ const handleSubmit = async (e, overrideInput) => {
1811
+ e?.preventDefault();
1812
+ const text = (overrideInput ?? input).trim();
1813
+ if (!text || isLoading) return;
1814
+ if (!overrideInput) setInput("");
1815
+ await sendEvent({
1816
+ type: "text",
1817
+ role: "user",
1818
+ data: { content: text }
1819
+ });
1820
+ };
1821
+ const handleStarterPromptClick = (prompt) => {
1822
+ if (onStarterPromptClick) {
1823
+ onStarterPromptClick(prompt);
1824
+ } else {
1825
+ handleSubmit(void 0, prompt);
1826
+ }
1827
+ };
1828
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col h-full bg-background", className), children: [
1829
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 overflow-y-auto p-4 space-y-6", children: [
1830
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-4xl mx-auto w-full", children: [
1831
+ messages.length === 0 && starterPrompts && starterPrompts.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center min-h-[300px] space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500", children: [
1832
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center space-y-2", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-semibold tracking-tight", children: "What can I help with today?" }) }),
1833
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3 w-full max-w-2xl px-4", children: starterPrompts.map((item, i) => /* @__PURE__ */ jsxRuntime.jsxs(
1834
+ "button",
1835
+ {
1836
+ onClick: () => handleStarterPromptClick(item.prompt),
1837
+ className: "flex items-center gap-3 p-4 rounded-xl border bg-card hover:bg-muted/50 transition-all text-left group",
1838
+ children: [
1839
+ item.icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 rounded-lg bg-muted group-hover:bg-background transition-colors", children: item.icon }),
1840
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: item.label })
1841
+ ]
1842
+ },
1843
+ i
1844
+ )) })
1845
+ ] }),
1846
+ messages.map((message, i) => /* @__PURE__ */ jsxRuntime.jsx(
1847
+ "div",
1848
+ {
1849
+ className: cn(
1850
+ "flex flex-col",
1851
+ message.role === "user" ? "items-end" : "items-start"
1852
+ ),
1853
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1854
+ "div",
1855
+ {
1856
+ className: cn(
1857
+ "max-w-[85%] rounded-2xl px-4 py-2 space-y-2",
1858
+ message.role === "user" ? "bg-primary text-primary-foreground" : "px-0 py-0 text-foreground"
1859
+ ),
1860
+ children: message.content.map((event, j) => {
1861
+ if (event.type === "text-delta")
1862
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { children: event.data?.delta }, j);
1863
+ if (event.type === "text")
1864
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { children: event.data?.content || event.data?.text }, j);
1865
+ if (event.ui) return /* @__PURE__ */ jsxRuntime.jsx(UIRenderer, { node: event.ui }, j);
1866
+ return null;
1867
+ })
1868
+ }
1869
+ )
1870
+ },
1871
+ i
1872
+ )),
1873
+ isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground animate-pulse", children: "Thinking..." }),
1874
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-destructive p-2 border border-destructive rounded-md bg-destructive/10", children: error.message })
1875
+ ] }),
1876
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
1877
+ ] }),
1878
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 border-t w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-4xl mx-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
1879
+ Composer,
1880
+ {
1881
+ value: input,
1882
+ onChange: setInput,
1883
+ onSubmit: handleSubmit,
1884
+ placeholder,
1885
+ isLoading
1886
+ }
1887
+ ) }) })
1888
+ ] });
1889
+ }
1890
+ var ThreadList = ({
1891
+ className,
1892
+ emptyState,
1893
+ onThreadSelect
1894
+ }) => {
1895
+ const {
1896
+ threads,
1897
+ activeThreadId,
1898
+ selectThread,
1899
+ createThread,
1900
+ deleteThread
1901
+ } = useThreads();
1902
+ const handleThreadClick = (threadId) => {
1903
+ if (threadId !== activeThreadId) {
1904
+ selectThread(threadId);
1905
+ }
1906
+ onThreadSelect?.(threadId);
1907
+ };
1908
+ const handleDelete = async (e, threadId) => {
1909
+ e.stopPropagation();
1910
+ try {
1911
+ await deleteThread(threadId);
1912
+ } catch (error) {
1913
+ console.error("Failed to delete thread:", error);
1914
+ }
1915
+ };
1916
+ const handleNewThread = async () => {
1917
+ try {
1918
+ await createThread();
1919
+ } catch (error) {
1920
+ console.error("Failed to create thread:", error);
1921
+ }
1922
+ };
1923
+ const formatDate = (date) => {
1924
+ if (!date) return "";
1925
+ const d = typeof date === "string" ? new Date(date) : date;
1926
+ if (isNaN(d.getTime())) return "";
1927
+ const now = /* @__PURE__ */ new Date();
1928
+ const diffMs = now.getTime() - d.getTime();
1929
+ const diffMins = Math.floor(diffMs / 6e4);
1930
+ const diffHours = Math.floor(diffMs / 36e5);
1931
+ const diffDays = Math.floor(diffMs / 864e5);
1932
+ if (diffMins < 1) return "Just now";
1933
+ if (diffMins < 60) return `${diffMins}m ago`;
1934
+ if (diffHours < 24) return `${diffHours}h ago`;
1935
+ if (diffDays < 7) return `${diffDays}d ago`;
1936
+ return d.toLocaleDateString();
1937
+ };
1938
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col h-full", className), children: [
1939
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 border-b", children: /* @__PURE__ */ jsxRuntime.jsxs(
1940
+ Button,
1941
+ {
1942
+ variant: "outline",
1943
+ size: "sm",
1944
+ onClick: handleNewThread,
1945
+ className: "w-full justify-start",
1946
+ children: [
1947
+ /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconPlus, { className: "mr-2 size-4" }),
1948
+ "New Thread"
1949
+ ]
1950
+ }
1951
+ ) }),
1952
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto", children: threads.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center text-muted-foreground", children: emptyState || /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1953
+ /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconMessage, { className: "size-8 mx-auto opacity-50" }),
1954
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: "No threads yet" }),
1955
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", size: "sm", onClick: handleNewThread, children: "Start a conversation" })
1956
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 space-y-1", children: threads.map((thread) => {
1957
+ const isActive = thread.id === activeThreadId;
1958
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1959
+ "div",
1960
+ {
1961
+ onClick: () => handleThreadClick(thread.id),
1962
+ className: cn(
1963
+ "group relative flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors",
1964
+ isActive ? "bg-primary text-primary-foreground" : "hover:bg-muted"
1965
+ ),
1966
+ children: [
1967
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1968
+ /* @__PURE__ */ jsxRuntime.jsx(
1969
+ "p",
1970
+ {
1971
+ className: cn(
1972
+ "text-sm font-medium truncate",
1973
+ isActive && "text-primary-foreground"
1974
+ ),
1975
+ children: thread.title || `Thread ${thread.id.slice(0, 8)}`
1976
+ }
1977
+ ),
1978
+ thread.updatedAt && /* @__PURE__ */ jsxRuntime.jsx(
1979
+ "span",
1980
+ {
1981
+ className: cn(
1982
+ "text-xs shrink-0",
1983
+ isActive ? "text-primary-foreground/70" : "text-muted-foreground"
1984
+ ),
1985
+ children: formatDate(thread.updatedAt)
1986
+ }
1987
+ )
1988
+ ] }) }),
1989
+ /* @__PURE__ */ jsxRuntime.jsx(
1990
+ Button,
1991
+ {
1992
+ variant: "ghost",
1993
+ size: "icon-xs",
1994
+ onClick: (e) => handleDelete(e, thread.id),
1995
+ className: cn(
1996
+ "opacity-0 group-hover:opacity-100 transition-opacity shrink-0",
1997
+ isActive && "hover:bg-primary-foreground/20"
1998
+ ),
1999
+ children: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconTrash, { className: "size-3" })
2000
+ }
2001
+ )
2002
+ ]
2003
+ },
2004
+ thread.id
2005
+ );
2006
+ }) }) })
2007
+ ] });
2008
+ };
2009
+ function ChatPopup({
2010
+ title = "Chat",
2011
+ placeholder = "Message the AI",
2012
+ starterPrompts,
2013
+ defaultOpen = false
2014
+ }) {
2015
+ const [isOpen, setIsOpen] = React9.useState(defaultOpen);
2016
+ const [view, setView] = React9.useState("chat");
2017
+ const { createThread } = useThreads();
2018
+ const handleNewChat = async () => {
2019
+ try {
2020
+ await createThread();
2021
+ setView("chat");
2022
+ } catch (error) {
2023
+ console.error("Failed to create new chat:", error);
2024
+ }
2025
+ };
2026
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed bottom-6 right-6 z-50 flex flex-col items-end gap-4 font-sans", children: [
2027
+ isOpen && /* @__PURE__ */ jsxRuntime.jsxs(Card, { className: "py-0 w-[440px] h-[640px] flex flex-col overflow-hidden border bg-background/95 backdrop-blur supports-backdrop-filter:bg-background/60 shadow-2xl animate-in fade-in zoom-in-95 duration-200 origin-bottom-right", children: [
2028
+ /* @__PURE__ */ jsxRuntime.jsxs(CardHeader, { className: "p-4 border-b flex flex-row items-center justify-between space-y-0 h-14 shrink-0", children: [
2029
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2030
+ view === "history" && /* @__PURE__ */ jsxRuntime.jsx(
2031
+ Button,
2032
+ {
2033
+ variant: "ghost",
2034
+ size: "icon-xs",
2035
+ onClick: () => setView("chat"),
2036
+ className: "text-muted-foreground hover:text-foreground",
2037
+ children: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconArrowLeft, { className: "size-4" })
2038
+ }
2039
+ ),
2040
+ /* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-sm font-semibold", children: view === "history" ? "History" : title })
2041
+ ] }),
2042
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
2043
+ view === "chat" && /* @__PURE__ */ jsxRuntime.jsx(
2044
+ Button,
2045
+ {
2046
+ variant: "ghost",
2047
+ size: "icon-xs",
2048
+ onClick: () => setView("history"),
2049
+ className: "text-muted-foreground hover:text-foreground",
2050
+ title: "History",
2051
+ children: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconHistory, { className: "size-4" })
2052
+ }
2053
+ ),
2054
+ /* @__PURE__ */ jsxRuntime.jsx(
2055
+ Button,
2056
+ {
2057
+ variant: "ghost",
2058
+ size: "icon-xs",
2059
+ onClick: handleNewChat,
2060
+ className: "text-muted-foreground hover:text-foreground",
2061
+ title: "New Chat",
2062
+ children: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconPlus, { className: "size-4" })
2063
+ }
2064
+ ),
2065
+ /* @__PURE__ */ jsxRuntime.jsx(
2066
+ Button,
2067
+ {
2068
+ variant: "ghost",
2069
+ size: "icon-xs",
2070
+ onClick: () => setIsOpen(false),
2071
+ className: "text-muted-foreground hover:text-foreground",
2072
+ children: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconX, { className: "size-4" })
2073
+ }
2074
+ )
2075
+ ] })
2076
+ ] }),
2077
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: view === "chat" ? /* @__PURE__ */ jsxRuntime.jsx(
2078
+ Thread,
2079
+ {
2080
+ placeholder,
2081
+ starterPrompts,
2082
+ className: "h-full"
2083
+ }
2084
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
2085
+ ThreadList,
2086
+ {
2087
+ onThreadSelect: () => setView("chat"),
2088
+ className: "h-full"
2089
+ }
2090
+ ) })
2091
+ ] }),
2092
+ /* @__PURE__ */ jsxRuntime.jsx(
2093
+ Button,
2094
+ {
2095
+ size: "icon-lg",
2096
+ className: cn(
2097
+ "h-14 w-14 rounded-full shadow-2xl transition-all hover:scale-105 active:scale-95",
2098
+ isOpen ? "bg-muted text-muted-foreground hover:bg-muted/80" : "bg-primary text-primary-foreground"
2099
+ ),
2100
+ onClick: () => setIsOpen(!isOpen),
2101
+ children: isOpen ? /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconX, { className: "size-6" }) : /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconMessage, { className: "size-6" })
2102
+ }
2103
+ )
2104
+ ] });
2105
+ }
2106
+ function ChatSidebar({
2107
+ title = "Chat",
2108
+ placeholder = "Message the AI",
2109
+ starterPrompts,
2110
+ className
2111
+ }) {
2112
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col h-full border-r bg-background w-80", className), children: [
2113
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 border-b h-14 flex items-center shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-sm font-semibold", children: title }) }),
2114
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
2115
+ Thread,
2116
+ {
2117
+ placeholder,
2118
+ starterPrompts,
2119
+ className: "h-full"
2120
+ }
2121
+ ) })
2122
+ ] });
2123
+ }
2124
+ function ChatFull({
2125
+ title = "Chat",
2126
+ placeholder = "Message the AI",
2127
+ starterPrompts,
2128
+ className
2129
+ }) {
2130
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col h-full w-full bg-background", className), children: [
2131
+ title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 border-b h-14 flex items-center shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-sm font-semibold", children: title }) }),
2132
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { placeholder, starterPrompts }) })
2133
+ ] });
2134
+ }
2135
+ function AlertDialog({ ...props }) {
2136
+ return /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialog.Root, { "data-slot": "alert-dialog", ...props });
2137
+ }
2138
+ function AlertDialogPortal({ ...props }) {
2139
+ return /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialog.Portal, { "data-slot": "alert-dialog-portal", ...props });
2140
+ }
2141
+ function AlertDialogOverlay({
2142
+ className,
2143
+ ...props
2144
+ }) {
2145
+ return /* @__PURE__ */ jsxRuntime.jsx(
2146
+ alertDialog.AlertDialog.Backdrop,
2147
+ {
2148
+ "data-slot": "alert-dialog-overlay",
2149
+ className: cn(
2150
+ "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50",
2151
+ className
2152
+ ),
2153
+ ...props
2154
+ }
2155
+ );
2156
+ }
2157
+ function AlertDialogContent({
2158
+ className,
2159
+ size = "default",
2160
+ ...props
2161
+ }) {
2162
+ return /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogPortal, { children: [
2163
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDialogOverlay, {}),
2164
+ /* @__PURE__ */ jsxRuntime.jsx(
2165
+ alertDialog.AlertDialog.Popup,
2166
+ {
2167
+ "data-slot": "alert-dialog-content",
2168
+ "data-size": size,
2169
+ className: cn(
2170
+ "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-background ring-foreground/5 gap-6 rounded-4xl p-6 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-md group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none",
2171
+ className
2172
+ ),
2173
+ ...props
2174
+ }
2175
+ )
2176
+ ] });
2177
+ }
2178
+ function AlertDialogHeader({
2179
+ className,
2180
+ ...props
2181
+ }) {
2182
+ return /* @__PURE__ */ jsxRuntime.jsx(
2183
+ "div",
2184
+ {
2185
+ "data-slot": "alert-dialog-header",
2186
+ className: cn("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]", className),
2187
+ ...props
2188
+ }
2189
+ );
2190
+ }
2191
+ function AlertDialogTitle({
2192
+ className,
2193
+ ...props
2194
+ }) {
2195
+ return /* @__PURE__ */ jsxRuntime.jsx(
2196
+ alertDialog.AlertDialog.Title,
2197
+ {
2198
+ "data-slot": "alert-dialog-title",
2199
+ className: cn("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2", className),
2200
+ ...props
2201
+ }
2202
+ );
2203
+ }
2204
+ function AlertDialogDescription({
2205
+ className,
2206
+ ...props
2207
+ }) {
2208
+ return /* @__PURE__ */ jsxRuntime.jsx(
2209
+ alertDialog.AlertDialog.Description,
2210
+ {
2211
+ "data-slot": "alert-dialog-description",
2212
+ className: cn("text-muted-foreground *:[a]:hover:text-foreground text-sm text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3", className),
2213
+ ...props
2214
+ }
2215
+ );
2216
+ }
2217
+ function DropdownMenu({ ...props }) {
2218
+ return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Root, { "data-slot": "dropdown-menu", ...props });
2219
+ }
2220
+ function DropdownMenuTrigger({ ...props }) {
2221
+ return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Trigger, { "data-slot": "dropdown-menu-trigger", ...props });
2222
+ }
2223
+ function DropdownMenuContent({
2224
+ align = "start",
2225
+ alignOffset = 0,
2226
+ side = "bottom",
2227
+ sideOffset = 4,
2228
+ className,
2229
+ ...props
2230
+ }) {
2231
+ return /* @__PURE__ */ jsxRuntime.jsx(menu.Menu.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
2232
+ menu.Menu.Positioner,
2233
+ {
2234
+ className: "isolate z-50 outline-none",
2235
+ align,
2236
+ alignOffset,
2237
+ side,
2238
+ sideOffset,
2239
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2240
+ menu.Menu.Popup,
2241
+ {
2242
+ "data-slot": "dropdown-menu-content",
2243
+ className: cn("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/5 bg-popover text-popover-foreground min-w-48 rounded-2xl p-1 shadow-2xl ring-1 duration-100 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden", className),
2244
+ ...props
2245
+ }
2246
+ )
2247
+ }
2248
+ ) });
2249
+ }
2250
+ function DropdownMenuItem({
2251
+ className,
2252
+ inset,
2253
+ variant = "default",
2254
+ ...props
2255
+ }) {
2256
+ return /* @__PURE__ */ jsxRuntime.jsx(
2257
+ menu.Menu.Item,
2258
+ {
2259
+ "data-slot": "dropdown-menu-item",
2260
+ "data-inset": inset,
2261
+ "data-variant": variant,
2262
+ className: cn(
2263
+ "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground gap-2.5 rounded-xl px-3 py-2 text-sm [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",
2264
+ className
2265
+ ),
2266
+ ...props
2267
+ }
2268
+ );
2269
+ }
2270
+ var AccountDialog = ({
2271
+ className,
2272
+ variant,
2273
+ size
2274
+ }) => {
2275
+ const { isLoading, isAuthenticated, login, logout } = useAuth();
2276
+ const [open, setOpen] = React9__namespace.useState(false);
2277
+ const [error, setError] = React9__namespace.useState(null);
2278
+ const handleGoogleSignIn = async () => {
2279
+ login();
2280
+ };
2281
+ if (isAuthenticated) {
2282
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
2283
+ /* @__PURE__ */ jsxRuntime.jsx(
2284
+ DropdownMenuTrigger,
2285
+ {
2286
+ render: (props) => /* @__PURE__ */ jsxRuntime.jsxs(
2287
+ Button,
2288
+ {
2289
+ variant,
2290
+ size,
2291
+ ...props,
2292
+ className,
2293
+ children: [
2294
+ /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconUser, { className: "mr-2 size-4" }),
2295
+ "Account"
2296
+ ]
2297
+ }
2298
+ )
2299
+ }
2300
+ ),
2301
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuContent, { children: [
2302
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { children: [
2303
+ /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconUser, { className: "mr-2 size-4" }),
2304
+ "Account"
2305
+ ] }),
2306
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: logout, children: [
2307
+ /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconLogout, { className: "mr-2 size-4" }),
2308
+ "Logout"
2309
+ ] })
2310
+ ] })
2311
+ ] });
2312
+ }
2313
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2314
+ /* @__PURE__ */ jsxRuntime.jsxs(
2315
+ Button,
2316
+ {
2317
+ variant,
2318
+ size,
2319
+ onClick: () => setOpen(true),
2320
+ className,
2321
+ children: [
2322
+ /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconBrandGoogle, { className: "mr-2 size-4" }),
2323
+ "Sign in with Google"
2324
+ ]
2325
+ }
2326
+ ),
2327
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogContent, { className: "sm:max-w-md", children: [
2328
+ /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogHeader, { children: [
2329
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDialogTitle, { children: "Sign in to continue" }),
2330
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDialogDescription, { children: "Choose your preferred sign-in method to access your account." })
2331
+ ] }),
2332
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 py-4", children: [
2333
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-destructive/10 p-3 text-sm text-destructive", children: error }),
2334
+ /* @__PURE__ */ jsxRuntime.jsxs(
2335
+ Button,
2336
+ {
2337
+ onClick: handleGoogleSignIn,
2338
+ disabled: isLoading,
2339
+ variant: "outline",
2340
+ className: "w-full",
2341
+ size: "lg",
2342
+ children: [
2343
+ /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconBrandGoogle, { className: "mr-2 size-5" }),
2344
+ isLoading ? "Signing in..." : "Continue with Google"
2345
+ ]
2346
+ }
2347
+ )
2348
+ ] })
2349
+ ] }) })
2350
+ ] });
2351
+ };
2352
+
2353
+ exports.AccountDialog = AccountDialog;
2354
+ exports.AuthContext = AuthContext;
2355
+ exports.AuthProvider = AuthProvider;
2356
+ exports.ChatFull = ChatFull;
2357
+ exports.ChatPopup = ChatPopup;
2358
+ exports.ChatSidebar = ChatSidebar;
2359
+ exports.Composer = Composer;
2360
+ exports.MelonyContext = MelonyContext;
2361
+ exports.MelonyProvider = MelonyProvider;
2362
+ exports.Thread = Thread;
2363
+ exports.ThreadContext = ThreadContext;
2364
+ exports.ThreadList = ThreadList;
2365
+ exports.ThreadProvider = ThreadProvider;
2366
+ exports.UIRenderer = UIRenderer;
2367
+ exports.useAuth = useAuth;
2368
+ exports.useMelony = useMelony;
2369
+ exports.useThreads = useThreads;
2370
+ //# sourceMappingURL=index.cjs.map
2371
+ //# sourceMappingURL=index.cjs.map