@leanmcp/ui 0.3.3 → 0.3.4

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.js DELETED
@@ -1,3751 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk2HRO6CFU_js = require('./chunk-2HRO6CFU.js');
4
- var React26 = require('react');
5
- var extApps = require('@modelcontextprotocol/ext-apps');
6
- var lucideReact = require('lucide-react');
7
- var nextThemes = require('next-themes');
8
- var sonner = require('sonner');
9
- var reactSlot = require('@radix-ui/react-slot');
10
- var classVarianceAuthority = require('class-variance-authority');
11
- var clsx = require('clsx');
12
- var tailwindMerge = require('tailwind-merge');
13
- var DialogPrimitive = require('@radix-ui/react-dialog');
14
- var SelectPrimitive = require('@radix-ui/react-select');
15
- var cmdk = require('cmdk');
16
- var PopoverPrimitive = require('@radix-ui/react-popover');
17
- var LabelPrimitive = require('@radix-ui/react-label');
18
- var CheckboxPrimitive = require('@radix-ui/react-checkbox');
19
- var SliderPrimitive = require('@radix-ui/react-slider');
20
- var SwitchPrimitive = require('@radix-ui/react-switch');
21
- var ProgressPrimitive = require('@radix-ui/react-progress');
22
- var reactHookForm = require('react-hook-form');
23
- var TabsPrimitive2 = require('@radix-ui/react-tabs');
24
- var SeparatorPrimitive = require('@radix-ui/react-separator');
25
- var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
26
- var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
27
- var TooltipPrimitive = require('@radix-ui/react-tooltip');
28
- var reactTable = require('@tanstack/react-table');
29
- var chart_js = require('chart.js');
30
- var reactChartjs2 = require('react-chartjs-2');
31
- var prismReactRenderer = require('prism-react-renderer');
32
- var appBridge = require('@modelcontextprotocol/ext-apps/app-bridge');
33
-
34
- function _interopNamespace(e) {
35
- if (e && e.__esModule) return e;
36
- var n = Object.create(null);
37
- if (e) {
38
- Object.keys(e).forEach(function (k) {
39
- if (k !== 'default') {
40
- var d = Object.getOwnPropertyDescriptor(e, k);
41
- Object.defineProperty(n, k, d.get ? d : {
42
- enumerable: true,
43
- get: function () { return e[k]; }
44
- });
45
- }
46
- });
47
- }
48
- n.default = e;
49
- return Object.freeze(n);
50
- }
51
-
52
- var React26__namespace = /*#__PURE__*/_interopNamespace(React26);
53
- var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
54
- var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
55
- var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
56
- var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
57
- var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
58
- var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
59
- var SwitchPrimitive__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitive);
60
- var ProgressPrimitive__namespace = /*#__PURE__*/_interopNamespace(ProgressPrimitive);
61
- var TabsPrimitive2__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive2);
62
- var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
63
- var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
64
- var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
65
- var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
66
-
67
- var McpAppContext = /* @__PURE__ */ React26.createContext(null);
68
- function AppProvider({ appInfo, capabilities = {}, options = {
69
- autoResize: true
70
- }, onTeardown, children }) {
71
- const [app, setApp] = React26.useState(null);
72
- const [isConnected, setIsConnected] = React26.useState(false);
73
- const [error, setError] = React26.useState(null);
74
- const [hostContext, setHostContext] = React26.useState({});
75
- const [toolInput, setToolInput] = React26.useState(null);
76
- const [toolInputPartial, setToolInputPartial] = React26.useState(null);
77
- const [toolResult, setToolResult] = React26.useState(null);
78
- const [toolCancelled, setToolCancelled] = React26.useState({
79
- cancelled: false
80
- });
81
- const stylesApplied = React26.useRef(false);
82
- const applyHostStyles = React26.useCallback((context) => {
83
- if (context.theme) {
84
- extApps.applyDocumentTheme(context.theme);
85
- }
86
- if (context.styles?.variables) {
87
- extApps.applyHostStyleVariables(context.styles.variables);
88
- }
89
- if (context.styles?.css?.fonts) {
90
- extApps.applyHostFonts(context.styles.css.fonts);
91
- }
92
- }, []);
93
- React26.useEffect(() => {
94
- let mounted = true;
95
- let appInstance = null;
96
- async function connect() {
97
- try {
98
- const transport = new extApps.PostMessageTransport(window.parent);
99
- appInstance = new extApps.App(appInfo, capabilities, options);
100
- appInstance.ontoolinput = (params) => {
101
- if (mounted) {
102
- setToolInput(params.arguments);
103
- setToolCancelled({
104
- cancelled: false
105
- });
106
- }
107
- };
108
- appInstance.ontoolinputpartial = (params) => {
109
- if (mounted) {
110
- setToolInputPartial(params.arguments);
111
- }
112
- };
113
- appInstance.ontoolresult = (params) => {
114
- if (mounted) {
115
- setToolResult(params);
116
- }
117
- };
118
- appInstance.ontoolcancelled = (params) => {
119
- if (mounted) {
120
- setToolCancelled({
121
- cancelled: true,
122
- reason: params.reason
123
- });
124
- }
125
- };
126
- appInstance.onhostcontextchanged = (params) => {
127
- if (mounted) {
128
- setHostContext((prev) => ({
129
- ...prev,
130
- ...params
131
- }));
132
- applyHostStyles(params);
133
- }
134
- };
135
- if (onTeardown) {
136
- appInstance.onteardown = async () => {
137
- await onTeardown();
138
- return {};
139
- };
140
- }
141
- await appInstance.connect(transport);
142
- if (mounted) {
143
- setApp(appInstance);
144
- setIsConnected(true);
145
- setError(null);
146
- const initialContext = appInstance.getHostContext();
147
- if (initialContext) {
148
- setHostContext(initialContext);
149
- if (!stylesApplied.current) {
150
- applyHostStyles(initialContext);
151
- stylesApplied.current = true;
152
- }
153
- }
154
- }
155
- } catch (err) {
156
- if (mounted) {
157
- setError(err instanceof Error ? err : new Error(String(err)));
158
- setIsConnected(false);
159
- }
160
- }
161
- }
162
- chunk2HRO6CFU_js.__name(connect, "connect");
163
- connect();
164
- return () => {
165
- mounted = false;
166
- if (appInstance) {
167
- appInstance.close();
168
- }
169
- };
170
- }, [
171
- appInfo.name,
172
- appInfo.version,
173
- applyHostStyles,
174
- onTeardown
175
- ]);
176
- const callTool = React26.useCallback(async (name, args = {}) => {
177
- if (!app) {
178
- throw new Error("Not connected to host");
179
- }
180
- setToolCancelled({
181
- cancelled: false
182
- });
183
- const result = await app.callServerTool({
184
- name,
185
- arguments: args
186
- });
187
- setToolResult(result);
188
- return result;
189
- }, [
190
- app
191
- ]);
192
- const sendMessage = React26.useCallback(async (text) => {
193
- if (!app) {
194
- console.warn("[AppProvider] Not connected - cannot send message");
195
- return;
196
- }
197
- await app.sendMessage({
198
- role: "user",
199
- content: [
200
- {
201
- type: "text",
202
- text
203
- }
204
- ]
205
- });
206
- }, [
207
- app
208
- ]);
209
- const sendLog = React26.useCallback(async (level, data) => {
210
- if (!app) {
211
- console.log(`[MCP App] ${level}:`, data);
212
- return;
213
- }
214
- await app.sendLog({
215
- level,
216
- data
217
- });
218
- }, [
219
- app
220
- ]);
221
- const openLink = React26.useCallback(async (url) => {
222
- if (!app) {
223
- window.open(url, "_blank", "noopener,noreferrer");
224
- return;
225
- }
226
- await app.openLink({
227
- url
228
- });
229
- }, [
230
- app
231
- ]);
232
- const requestDisplayMode = React26.useCallback(async (mode) => {
233
- if (!app) {
234
- console.warn("[AppProvider] Not connected - cannot request display mode");
235
- return "inline";
236
- }
237
- const result = await app.requestDisplayMode({
238
- mode
239
- });
240
- return result.mode;
241
- }, [
242
- app
243
- ]);
244
- const value = {
245
- app,
246
- isConnected,
247
- error,
248
- hostContext,
249
- toolInput,
250
- toolInputPartial,
251
- toolResult,
252
- toolCancelled,
253
- callTool,
254
- sendMessage,
255
- sendLog,
256
- openLink,
257
- requestDisplayMode
258
- };
259
- const theme = hostContext.theme ?? "light";
260
- return /* @__PURE__ */ React26__namespace.default.createElement(McpAppContext.Provider, {
261
- value
262
- }, /* @__PURE__ */ React26__namespace.default.createElement("div", {
263
- className: "lui-root",
264
- "data-theme": theme
265
- }, children));
266
- }
267
- chunk2HRO6CFU_js.__name(AppProvider, "AppProvider");
268
- var ssrDefaultContext = {
269
- app: null,
270
- isConnected: false,
271
- error: null,
272
- hostContext: {},
273
- toolInput: null,
274
- toolInputPartial: null,
275
- toolResult: null,
276
- toolCancelled: {
277
- cancelled: false
278
- },
279
- callTool: /* @__PURE__ */ chunk2HRO6CFU_js.__name(async () => {
280
- throw new Error("callTool not available during SSR");
281
- }, "callTool"),
282
- sendMessage: /* @__PURE__ */ chunk2HRO6CFU_js.__name(async () => {
283
- console.warn("sendMessage not available during SSR");
284
- }, "sendMessage"),
285
- sendLog: /* @__PURE__ */ chunk2HRO6CFU_js.__name(async () => {
286
- console.warn("sendLog not available during SSR");
287
- }, "sendLog"),
288
- openLink: /* @__PURE__ */ chunk2HRO6CFU_js.__name(async () => {
289
- console.warn("openLink not available during SSR");
290
- }, "openLink"),
291
- requestDisplayMode: /* @__PURE__ */ chunk2HRO6CFU_js.__name(async () => {
292
- console.warn("requestDisplayMode not available during SSR");
293
- return "inline";
294
- }, "requestDisplayMode")
295
- };
296
- function useMcpApp() {
297
- const context = React26.useContext(McpAppContext);
298
- if (!context) {
299
- return ssrDefaultContext;
300
- }
301
- return context;
302
- }
303
- chunk2HRO6CFU_js.__name(useMcpApp, "useMcpApp");
304
- var GptAppContext = /* @__PURE__ */ React26.createContext(null);
305
- function GPTAppProvider({ appName, children }) {
306
- const [isConnected, setIsConnected] = React26.useState(false);
307
- const [error, setError] = React26.useState(null);
308
- const [theme, setTheme] = React26.useState("light");
309
- const [displayMode, setDisplayMode] = React26.useState("inline");
310
- const [locale, setLocale] = React26.useState("en");
311
- const [maxHeight, setMaxHeight] = React26.useState(600);
312
- React26.useEffect(() => {
313
- let mounted = true;
314
- let checkAttempts = 0;
315
- const maxAttempts = 50;
316
- function checkConnection() {
317
- if (!mounted) return;
318
- if (window.openai) {
319
- setIsConnected(true);
320
- setError(null);
321
- if (window.openai.theme) setTheme(window.openai.theme);
322
- if (window.openai.displayMode) setDisplayMode(window.openai.displayMode);
323
- if (window.openai.locale) setLocale(window.openai.locale);
324
- if (window.openai.maxHeight) setMaxHeight(window.openai.maxHeight);
325
- } else {
326
- checkAttempts++;
327
- if (checkAttempts < maxAttempts) {
328
- setTimeout(checkConnection, 100);
329
- } else {
330
- setError(new Error("ChatGPT SDK not available"));
331
- setIsConnected(false);
332
- }
333
- }
334
- }
335
- chunk2HRO6CFU_js.__name(checkConnection, "checkConnection");
336
- checkConnection();
337
- return () => {
338
- mounted = false;
339
- };
340
- }, [
341
- appName
342
- ]);
343
- const callTool = React26.useCallback(async (name, args = {}) => {
344
- if (!window.openai?.callTool) {
345
- throw new Error("ChatGPT SDK not available");
346
- }
347
- const result = await window.openai.callTool(name, args);
348
- return result;
349
- }, []);
350
- const value = {
351
- isConnected,
352
- error,
353
- theme,
354
- displayMode,
355
- locale,
356
- maxHeight,
357
- callTool
358
- };
359
- return /* @__PURE__ */ React26__namespace.default.createElement(GptAppContext.Provider, {
360
- value
361
- }, /* @__PURE__ */ React26__namespace.default.createElement("div", {
362
- className: "lui-root",
363
- "data-theme": theme
364
- }, children));
365
- }
366
- chunk2HRO6CFU_js.__name(GPTAppProvider, "GPTAppProvider");
367
- function useGptApp() {
368
- const context = React26.useContext(GptAppContext);
369
- if (!context) {
370
- return {
371
- isConnected: false,
372
- error: new Error("GPTAppProvider not found"),
373
- theme: "light",
374
- displayMode: "inline",
375
- locale: "en",
376
- maxHeight: 600,
377
- callTool: /* @__PURE__ */ chunk2HRO6CFU_js.__name(async () => {
378
- throw new Error("Not connected to ChatGPT");
379
- }, "callTool")
380
- };
381
- }
382
- return context;
383
- }
384
- chunk2HRO6CFU_js.__name(useGptApp, "useGptApp");
385
- function useGptTool(toolName) {
386
- const { callTool, isConnected } = useGptApp();
387
- const [result, setResult] = React26.useState(null);
388
- const [loading, setLoading] = React26.useState(false);
389
- const [error, setError] = React26.useState(null);
390
- const call = React26.useCallback(async (args = {}) => {
391
- if (!isConnected) {
392
- setError(new Error("Not connected to ChatGPT"));
393
- return;
394
- }
395
- setLoading(true);
396
- setError(null);
397
- try {
398
- const res = await callTool(toolName, args);
399
- setResult(res);
400
- return res;
401
- } catch (err) {
402
- setError(err);
403
- throw err;
404
- } finally {
405
- setLoading(false);
406
- }
407
- }, [
408
- callTool,
409
- isConnected,
410
- toolName
411
- ]);
412
- return {
413
- call,
414
- result,
415
- loading,
416
- error,
417
- isConnected
418
- };
419
- }
420
- chunk2HRO6CFU_js.__name(useGptTool, "useGptTool");
421
- var DEFAULT_CONTEXT = {
422
- resultDisplay: {
423
- display: "none"
424
- },
425
- showLoading: true
426
- };
427
- var ToolContext = /* @__PURE__ */ React26.createContext(DEFAULT_CONTEXT);
428
- function ToolProvider({ defaults = {}, children }) {
429
- const parentContext = React26.useContext(ToolContext);
430
- const value = React26.useMemo(() => ({
431
- resultDisplay: defaults.resultDisplay ?? parentContext.resultDisplay,
432
- onError: defaults.onError ?? parentContext.onError,
433
- showLoading: defaults.showLoading ?? parentContext.showLoading
434
- }), [
435
- defaults,
436
- parentContext
437
- ]);
438
- return /* @__PURE__ */ React26__namespace.createElement(ToolContext.Provider, {
439
- value
440
- }, children);
441
- }
442
- chunk2HRO6CFU_js.__name(ToolProvider, "ToolProvider");
443
- function useToolContext() {
444
- return React26.useContext(ToolContext);
445
- }
446
- chunk2HRO6CFU_js.__name(useToolContext, "useToolContext");
447
- var Toaster = /* @__PURE__ */ chunk2HRO6CFU_js.__name(({ ...props }) => {
448
- const { theme = "system" } = nextThemes.useTheme();
449
- return /* @__PURE__ */ React26__namespace.default.createElement(sonner.Toaster, {
450
- theme,
451
- className: "toaster group",
452
- icons: {
453
- success: /* @__PURE__ */ React26__namespace.default.createElement(lucideReact.CircleCheckIcon, {
454
- className: "size-4"
455
- }),
456
- info: /* @__PURE__ */ React26__namespace.default.createElement(lucideReact.InfoIcon, {
457
- className: "size-4"
458
- }),
459
- warning: /* @__PURE__ */ React26__namespace.default.createElement(lucideReact.TriangleAlertIcon, {
460
- className: "size-4"
461
- }),
462
- error: /* @__PURE__ */ React26__namespace.default.createElement(lucideReact.OctagonXIcon, {
463
- className: "size-4"
464
- }),
465
- loading: /* @__PURE__ */ React26__namespace.default.createElement(lucideReact.Loader2Icon, {
466
- className: "size-4 animate-spin"
467
- })
468
- },
469
- style: {
470
- "--normal-bg": "var(--popover)",
471
- "--normal-text": "var(--popover-foreground)",
472
- "--normal-border": "var(--border)",
473
- "--border-radius": "var(--radius)"
474
- },
475
- ...props
476
- });
477
- }, "Toaster");
478
- function cn(...inputs) {
479
- return tailwindMerge.twMerge(clsx.clsx(inputs));
480
- }
481
- chunk2HRO6CFU_js.__name(cn, "cn");
482
-
483
- // src/components/ui/button.tsx
484
- var buttonVariants = classVarianceAuthority.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-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", {
485
- variants: {
486
- variant: {
487
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
488
- destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
489
- outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
490
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
491
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
492
- link: "text-primary underline-offset-4 hover:underline"
493
- },
494
- size: {
495
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
496
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
497
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
498
- icon: "size-9",
499
- "icon-sm": "size-8",
500
- "icon-lg": "size-10"
501
- }
502
- },
503
- defaultVariants: {
504
- variant: "default",
505
- size: "default"
506
- }
507
- });
508
- function Button({ className, variant = "default", size = "default", asChild = false, ...props }) {
509
- const Comp = asChild ? reactSlot.Slot : "button";
510
- return /* @__PURE__ */ React26__namespace.createElement(Comp, {
511
- "data-slot": "button",
512
- "data-variant": variant,
513
- "data-size": size,
514
- className: cn(buttonVariants({
515
- variant,
516
- size,
517
- className
518
- })),
519
- ...props
520
- });
521
- }
522
- chunk2HRO6CFU_js.__name(Button, "Button");
523
- function Dialog({ ...props }) {
524
- return /* @__PURE__ */ React26__namespace.createElement(DialogPrimitive__namespace.Root, {
525
- "data-slot": "dialog",
526
- ...props
527
- });
528
- }
529
- chunk2HRO6CFU_js.__name(Dialog, "Dialog");
530
- function DialogTrigger({ ...props }) {
531
- return /* @__PURE__ */ React26__namespace.createElement(DialogPrimitive__namespace.Trigger, {
532
- "data-slot": "dialog-trigger",
533
- ...props
534
- });
535
- }
536
- chunk2HRO6CFU_js.__name(DialogTrigger, "DialogTrigger");
537
- function DialogPortal({ ...props }) {
538
- return /* @__PURE__ */ React26__namespace.createElement(DialogPrimitive__namespace.Portal, {
539
- "data-slot": "dialog-portal",
540
- ...props
541
- });
542
- }
543
- chunk2HRO6CFU_js.__name(DialogPortal, "DialogPortal");
544
- function DialogClose({ ...props }) {
545
- return /* @__PURE__ */ React26__namespace.createElement(DialogPrimitive__namespace.Close, {
546
- "data-slot": "dialog-close",
547
- ...props
548
- });
549
- }
550
- chunk2HRO6CFU_js.__name(DialogClose, "DialogClose");
551
- function DialogOverlay({ className, ...props }) {
552
- return /* @__PURE__ */ React26__namespace.createElement(DialogPrimitive__namespace.Overlay, {
553
- "data-slot": "dialog-overlay",
554
- className: cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50", className),
555
- ...props
556
- });
557
- }
558
- chunk2HRO6CFU_js.__name(DialogOverlay, "DialogOverlay");
559
- function DialogContent({ className, children, showCloseButton = true, ...props }) {
560
- return /* @__PURE__ */ React26__namespace.createElement(DialogPortal, {
561
- "data-slot": "dialog-portal"
562
- }, /* @__PURE__ */ React26__namespace.createElement(DialogOverlay, null), /* @__PURE__ */ React26__namespace.createElement(DialogPrimitive__namespace.Content, {
563
- "data-slot": "dialog-content",
564
- className: cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg", className),
565
- ...props
566
- }, children, showCloseButton && /* @__PURE__ */ React26__namespace.createElement(DialogPrimitive__namespace.Close, {
567
- "data-slot": "dialog-close",
568
- className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
569
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.XIcon, null), /* @__PURE__ */ React26__namespace.createElement("span", {
570
- className: "sr-only"
571
- }, "Close"))));
572
- }
573
- chunk2HRO6CFU_js.__name(DialogContent, "DialogContent");
574
- function DialogHeader({ className, ...props }) {
575
- return /* @__PURE__ */ React26__namespace.createElement("div", {
576
- "data-slot": "dialog-header",
577
- className: cn("flex flex-col gap-2 text-center sm:text-left", className),
578
- ...props
579
- });
580
- }
581
- chunk2HRO6CFU_js.__name(DialogHeader, "DialogHeader");
582
- function DialogFooter({ className, ...props }) {
583
- return /* @__PURE__ */ React26__namespace.createElement("div", {
584
- "data-slot": "dialog-footer",
585
- className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
586
- ...props
587
- });
588
- }
589
- chunk2HRO6CFU_js.__name(DialogFooter, "DialogFooter");
590
- function DialogTitle({ className, ...props }) {
591
- return /* @__PURE__ */ React26__namespace.createElement(DialogPrimitive__namespace.Title, {
592
- "data-slot": "dialog-title",
593
- className: cn("text-lg leading-none font-semibold", className),
594
- ...props
595
- });
596
- }
597
- chunk2HRO6CFU_js.__name(DialogTitle, "DialogTitle");
598
- function DialogDescription({ className, ...props }) {
599
- return /* @__PURE__ */ React26__namespace.createElement(DialogPrimitive__namespace.Description, {
600
- "data-slot": "dialog-description",
601
- className: cn("text-muted-foreground text-sm", className),
602
- ...props
603
- });
604
- }
605
- chunk2HRO6CFU_js.__name(DialogDescription, "DialogDescription");
606
- function extractResultData(result) {
607
- if ("structuredContent" in result && result.structuredContent) {
608
- return result.structuredContent;
609
- }
610
- if (result.content && result.content.length > 0) {
611
- const textContent = result.content.filter((c) => c.type === "text").map((c) => c.text).join("");
612
- if (textContent) {
613
- try {
614
- const parsed = JSON.parse(textContent);
615
- if (parsed && typeof parsed === "object" && "content" in parsed && Array.isArray(parsed.content)) {
616
- const nested = extractResultData(parsed);
617
- if (nested !== null) {
618
- return nested;
619
- }
620
- }
621
- return parsed;
622
- } catch {
623
- return textContent;
624
- }
625
- }
626
- }
627
- return result;
628
- }
629
- chunk2HRO6CFU_js.__name(extractResultData, "extractResultData");
630
- function useTool(toolName, options = {}) {
631
- const { callTool } = useMcpApp();
632
- const [state, setState] = React26.useState("idle");
633
- const [result, setResult] = React26.useState(null);
634
- const [error, setError] = React26.useState(null);
635
- const abortControllerRef = React26.useRef(null);
636
- const lastArgsRef = React26.useRef(void 0);
637
- const retryCountRef = React26.useRef(0);
638
- const { defaultArgs, transform, retry, onStart, onSuccess, onError, onComplete } = options;
639
- const retryConfig = typeof retry === "number" ? {
640
- count: retry,
641
- delay: 1e3
642
- } : retry ?? {
643
- count: 0,
644
- delay: 1e3
645
- };
646
- const executeCall = React26.useCallback(async (args) => {
647
- const mergedArgs = {
648
- ...defaultArgs,
649
- ...args
650
- };
651
- lastArgsRef.current = mergedArgs;
652
- abortControllerRef.current = new AbortController();
653
- setState("loading");
654
- setError(null);
655
- onStart?.();
656
- try {
657
- const response = await callTool(toolName, mergedArgs);
658
- if (abortControllerRef.current?.signal.aborted) {
659
- throw new Error("Tool call aborted");
660
- }
661
- let data;
662
- if (transform) {
663
- data = transform(response);
664
- } else {
665
- data = extractResultData(response);
666
- }
667
- setState("success");
668
- setResult(data);
669
- retryCountRef.current = 0;
670
- onSuccess?.(data);
671
- onComplete?.();
672
- return data;
673
- } catch (err) {
674
- const error2 = err instanceof Error ? err : new Error(String(err));
675
- if (retryCountRef.current < retryConfig.count) {
676
- retryCountRef.current++;
677
- await new Promise((resolve) => setTimeout(resolve, retryConfig.delay));
678
- return executeCall(args);
679
- }
680
- setState("error");
681
- setError(error2);
682
- retryCountRef.current = 0;
683
- onError?.(error2);
684
- onComplete?.();
685
- throw error2;
686
- }
687
- }, [
688
- callTool,
689
- toolName,
690
- defaultArgs,
691
- transform,
692
- retryConfig,
693
- onStart,
694
- onSuccess,
695
- onError,
696
- onComplete
697
- ]);
698
- const call = React26.useCallback(async (args) => {
699
- retryCountRef.current = 0;
700
- return executeCall(args);
701
- }, [
702
- executeCall
703
- ]);
704
- const mutate = React26.useCallback(async (args) => {
705
- return call(args);
706
- }, [
707
- call
708
- ]);
709
- const reset = React26.useCallback(() => {
710
- setState("idle");
711
- setResult(null);
712
- setError(null);
713
- retryCountRef.current = 0;
714
- abortControllerRef.current?.abort();
715
- }, []);
716
- const retryCall = React26.useCallback(async () => {
717
- if (lastArgsRef.current === void 0 && !defaultArgs) {
718
- return null;
719
- }
720
- retryCountRef.current = 0;
721
- return executeCall(lastArgsRef.current);
722
- }, [
723
- executeCall,
724
- defaultArgs
725
- ]);
726
- const abort = React26.useCallback(() => {
727
- abortControllerRef.current?.abort();
728
- setState("idle");
729
- }, []);
730
- return {
731
- call,
732
- mutate,
733
- state,
734
- loading: state === "loading",
735
- result,
736
- error,
737
- reset,
738
- retry: retryCall,
739
- abort
740
- };
741
- }
742
- chunk2HRO6CFU_js.__name(useTool, "useTool");
743
- function ToolButton({ tool, args = {}, resultDisplay = "none", renderResult, resultDuration = 3e3, successMessage, errorMessage, onToolStart, onToolSuccess, onToolError, onToolComplete, loadingText, loadingIcon, disableWhileLoading = true, confirm, children, className, variant = "default", size = "default", disabled, asChild = false, ...props }) {
744
- const toolConfig = typeof tool === "string" ? {
745
- name: tool
746
- } : tool;
747
- const mergedArgs = {
748
- ...toolConfig.args,
749
- ...args
750
- };
751
- const { call, state, loading, result, error, reset } = useTool(toolConfig.name, {
752
- defaultArgs: mergedArgs,
753
- transform: toolConfig.transform,
754
- onStart: onToolStart,
755
- onSuccess: onToolSuccess,
756
- onError: onToolError,
757
- onComplete: onToolComplete
758
- });
759
- const [showConfirm, setShowConfirm] = React26.useState(false);
760
- const [showResult, setShowResult] = React26.useState(false);
761
- const buttonState = {
762
- loading,
763
- state,
764
- result,
765
- error,
766
- hasResult: result !== null || error !== null
767
- };
768
- const executeCall = React26.useCallback(async () => {
769
- try {
770
- const res = await call();
771
- if (resultDisplay === "toast") {
772
- const message = typeof successMessage === "function" ? successMessage(res) : successMessage ?? "Success";
773
- sonner.toast.success(message);
774
- } else if (resultDisplay === "inline") {
775
- setShowResult(true);
776
- setTimeout(() => setShowResult(false), resultDuration);
777
- }
778
- } catch (err) {
779
- if (resultDisplay === "toast") {
780
- const message = typeof errorMessage === "function" ? errorMessage(err instanceof Error ? err : new Error(String(err))) : errorMessage ?? (err instanceof Error ? err.message : "An error occurred");
781
- sonner.toast.error(message);
782
- } else if (resultDisplay === "inline") {
783
- setShowResult(true);
784
- setTimeout(() => setShowResult(false), resultDuration);
785
- }
786
- }
787
- }, [
788
- call,
789
- resultDisplay,
790
- successMessage,
791
- errorMessage,
792
- resultDuration
793
- ]);
794
- const handleClick = React26.useCallback(() => {
795
- if (confirm) {
796
- setShowConfirm(true);
797
- } else {
798
- executeCall();
799
- }
800
- }, [
801
- confirm,
802
- executeCall
803
- ]);
804
- const handleConfirm = React26.useCallback(() => {
805
- setShowConfirm(false);
806
- executeCall();
807
- }, [
808
- executeCall
809
- ]);
810
- const confirmConfig = typeof confirm === "object" ? confirm : {
811
- title: "Confirm Action",
812
- description: "Are you sure you want to proceed?",
813
- confirmText: "Confirm",
814
- cancelText: "Cancel"
815
- };
816
- const renderChildren = /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => {
817
- if (typeof children === "function") {
818
- return children(buttonState);
819
- }
820
- if (loading) {
821
- return /* @__PURE__ */ React26__namespace.createElement(React26__namespace.Fragment, null, loadingIcon ?? /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
822
- className: "animate-spin"
823
- }), loadingText && /* @__PURE__ */ React26__namespace.createElement("span", null, loadingText), !loadingText && children);
824
- }
825
- if (showResult && resultDisplay === "inline") {
826
- if (error) {
827
- return /* @__PURE__ */ React26__namespace.createElement(React26__namespace.Fragment, null, /* @__PURE__ */ React26__namespace.createElement(lucideReact.X, {
828
- className: "text-destructive"
829
- }), /* @__PURE__ */ React26__namespace.createElement("span", null, error.message));
830
- }
831
- if (renderResult) {
832
- return renderResult(result);
833
- }
834
- return /* @__PURE__ */ React26__namespace.createElement(React26__namespace.Fragment, null, /* @__PURE__ */ React26__namespace.createElement(lucideReact.Check, {
835
- className: "text-success"
836
- }), /* @__PURE__ */ React26__namespace.createElement("span", null, "Done"));
837
- }
838
- return children;
839
- }, "renderChildren");
840
- return /* @__PURE__ */ React26__namespace.createElement(React26__namespace.Fragment, null, /* @__PURE__ */ React26__namespace.createElement(Button, {
841
- type: "button",
842
- variant,
843
- size,
844
- className: cn(className),
845
- disabled: disabled || disableWhileLoading && loading,
846
- onClick: handleClick,
847
- asChild,
848
- ...props
849
- }, renderChildren()), confirm && /* @__PURE__ */ React26__namespace.createElement(Dialog, {
850
- open: showConfirm,
851
- onOpenChange: setShowConfirm
852
- }, /* @__PURE__ */ React26__namespace.createElement(DialogContent, null, /* @__PURE__ */ React26__namespace.createElement(DialogHeader, null, /* @__PURE__ */ React26__namespace.createElement(DialogTitle, null, confirmConfig.title), confirmConfig.description && /* @__PURE__ */ React26__namespace.createElement(DialogDescription, null, confirmConfig.description)), /* @__PURE__ */ React26__namespace.createElement(DialogFooter, null, /* @__PURE__ */ React26__namespace.createElement(Button, {
853
- variant: "outline",
854
- onClick: /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => setShowConfirm(false), "onClick")
855
- }, confirmConfig.cancelText ?? "Cancel"), /* @__PURE__ */ React26__namespace.createElement(Button, {
856
- variant: confirmConfig.confirmVariant ?? (variant === "destructive" ? "destructive" : "default"),
857
- onClick: handleConfirm
858
- }, confirmConfig.confirmText ?? "Confirm")))));
859
- }
860
- chunk2HRO6CFU_js.__name(ToolButton, "ToolButton");
861
- function Select({ ...props }) {
862
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Root, {
863
- "data-slot": "select",
864
- ...props
865
- });
866
- }
867
- chunk2HRO6CFU_js.__name(Select, "Select");
868
- function SelectGroup({ ...props }) {
869
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Group, {
870
- "data-slot": "select-group",
871
- ...props
872
- });
873
- }
874
- chunk2HRO6CFU_js.__name(SelectGroup, "SelectGroup");
875
- function SelectValue({ ...props }) {
876
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Value, {
877
- "data-slot": "select-value",
878
- ...props
879
- });
880
- }
881
- chunk2HRO6CFU_js.__name(SelectValue, "SelectValue");
882
- function SelectTrigger({ className, size = "default", children, ...props }) {
883
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Trigger, {
884
- "data-slot": "select-trigger",
885
- "data-size": size,
886
- className: cn("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground 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:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
887
- ...props
888
- }, children, /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Icon, {
889
- asChild: true
890
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.ChevronDownIcon, {
891
- className: "size-4 opacity-50"
892
- })));
893
- }
894
- chunk2HRO6CFU_js.__name(SelectTrigger, "SelectTrigger");
895
- function SelectContent({ className, children, position = "item-aligned", align = "center", ...props }) {
896
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Portal, null, /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Content, {
897
- "data-slot": "select-content",
898
- className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
899
- position,
900
- align,
901
- ...props
902
- }, /* @__PURE__ */ React26__namespace.createElement(SelectScrollUpButton, null), /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Viewport, {
903
- className: cn("p-1", position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1")
904
- }, children), /* @__PURE__ */ React26__namespace.createElement(SelectScrollDownButton, null)));
905
- }
906
- chunk2HRO6CFU_js.__name(SelectContent, "SelectContent");
907
- function SelectLabel({ className, ...props }) {
908
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Label, {
909
- "data-slot": "select-label",
910
- className: cn("text-muted-foreground px-2 py-1.5 text-xs", className),
911
- ...props
912
- });
913
- }
914
- chunk2HRO6CFU_js.__name(SelectLabel, "SelectLabel");
915
- function SelectItem({ className, children, ...props }) {
916
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Item, {
917
- "data-slot": "select-item",
918
- className: cn("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
919
- ...props
920
- }, /* @__PURE__ */ React26__namespace.createElement("span", {
921
- "data-slot": "select-item-indicator",
922
- className: "absolute right-2 flex size-3.5 items-center justify-center"
923
- }, /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React26__namespace.createElement(lucideReact.CheckIcon, {
924
- className: "size-4"
925
- }))), /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.ItemText, null, children));
926
- }
927
- chunk2HRO6CFU_js.__name(SelectItem, "SelectItem");
928
- function SelectSeparator({ className, ...props }) {
929
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.Separator, {
930
- "data-slot": "select-separator",
931
- className: cn("bg-border pointer-events-none -mx-1 my-1 h-px", className),
932
- ...props
933
- });
934
- }
935
- chunk2HRO6CFU_js.__name(SelectSeparator, "SelectSeparator");
936
- function SelectScrollUpButton({ className, ...props }) {
937
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.ScrollUpButton, {
938
- "data-slot": "select-scroll-up-button",
939
- className: cn("flex cursor-default items-center justify-center py-1", className),
940
- ...props
941
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.ChevronUpIcon, {
942
- className: "size-4"
943
- }));
944
- }
945
- chunk2HRO6CFU_js.__name(SelectScrollUpButton, "SelectScrollUpButton");
946
- function SelectScrollDownButton({ className, ...props }) {
947
- return /* @__PURE__ */ React26__namespace.createElement(SelectPrimitive__namespace.ScrollDownButton, {
948
- "data-slot": "select-scroll-down-button",
949
- className: cn("flex cursor-default items-center justify-center py-1", className),
950
- ...props
951
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.ChevronDownIcon, {
952
- className: "size-4"
953
- }));
954
- }
955
- chunk2HRO6CFU_js.__name(SelectScrollDownButton, "SelectScrollDownButton");
956
- function ToolSelect({ onSelectTool, argName = "value", additionalArgs = {}, optionsTool, optionsArgs = {}, transformOptions, options: staticOptions = [], placeholder = "Select an option", loadingPlaceholder = "Loading...", emptyMessage = "No options available", value: controlledValue, defaultValue, onValueChange, onOptionsLoaded, onSelectionSuccess, onSelectionError, showSuccessToast = false, successMessage, className, disabled = false }) {
957
- const [fetchedOptions, setFetchedOptions] = React26.useState([]);
958
- const [internalValue, setInternalValue] = React26.useState(defaultValue ?? "");
959
- const optionsToolConfig = optionsTool ? typeof optionsTool === "string" ? {
960
- name: optionsTool
961
- } : optionsTool : null;
962
- const selectToolConfig = onSelectTool ? typeof onSelectTool === "string" ? {
963
- name: onSelectTool
964
- } : onSelectTool : null;
965
- const optionsHook = useTool(optionsToolConfig?.name ?? "", {
966
- defaultArgs: {
967
- ...optionsToolConfig?.args,
968
- ...optionsArgs
969
- }
970
- });
971
- const selectHook = useTool(selectToolConfig?.name ?? "", {
972
- onSuccess: /* @__PURE__ */ chunk2HRO6CFU_js.__name((result) => {
973
- onSelectionSuccess?.(result);
974
- if (showSuccessToast) {
975
- const message = typeof successMessage === "function" ? successMessage(result) : successMessage ?? "Selection saved";
976
- sonner.toast.success(message);
977
- }
978
- }, "onSuccess"),
979
- onError: onSelectionError
980
- });
981
- React26.useEffect(() => {
982
- if (optionsToolConfig) {
983
- optionsHook.call().then((result) => {
984
- const options = transformOptions ? transformOptions(result) : result;
985
- setFetchedOptions(options);
986
- onOptionsLoaded?.(options);
987
- }).catch(() => {
988
- });
989
- }
990
- }, [
991
- optionsToolConfig?.name
992
- ]);
993
- const allOptions = [
994
- ...staticOptions,
995
- ...fetchedOptions
996
- ];
997
- const value = controlledValue ?? internalValue;
998
- const handleValueChange = React26.useCallback((newValue) => {
999
- setInternalValue(newValue);
1000
- onValueChange?.(newValue);
1001
- if (selectToolConfig) {
1002
- selectHook.call({
1003
- [argName]: newValue,
1004
- ...additionalArgs
1005
- });
1006
- }
1007
- }, [
1008
- onValueChange,
1009
- selectToolConfig,
1010
- argName,
1011
- additionalArgs,
1012
- selectHook
1013
- ]);
1014
- const isLoading = optionsHook.loading || selectHook.loading;
1015
- const hasError = optionsHook.error || selectHook.error;
1016
- return /* @__PURE__ */ React26__namespace.createElement(Select, {
1017
- value,
1018
- onValueChange: handleValueChange,
1019
- disabled: disabled || isLoading
1020
- }, /* @__PURE__ */ React26__namespace.createElement(SelectTrigger, {
1021
- className: cn("w-full", className)
1022
- }, isLoading ? /* @__PURE__ */ React26__namespace.createElement("div", {
1023
- className: "flex items-center gap-2"
1024
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
1025
- className: "h-4 w-4 animate-spin"
1026
- }), /* @__PURE__ */ React26__namespace.createElement("span", {
1027
- className: "text-muted-foreground"
1028
- }, optionsHook.loading ? loadingPlaceholder : "Saving...")) : /* @__PURE__ */ React26__namespace.createElement(SelectValue, {
1029
- placeholder
1030
- })), /* @__PURE__ */ React26__namespace.createElement(SelectContent, null, allOptions.length === 0 ? /* @__PURE__ */ React26__namespace.createElement("div", {
1031
- className: "py-6 text-center text-sm text-muted-foreground"
1032
- }, hasError ? "Error loading options" : emptyMessage) : allOptions.map((option) => /* @__PURE__ */ React26__namespace.createElement(SelectItem, {
1033
- key: option.value,
1034
- value: option.value,
1035
- disabled: option.disabled
1036
- }, /* @__PURE__ */ React26__namespace.createElement("div", {
1037
- className: "flex items-center gap-2"
1038
- }, option.icon, /* @__PURE__ */ React26__namespace.createElement("div", null, /* @__PURE__ */ React26__namespace.createElement("div", null, option.label), option.description && /* @__PURE__ */ React26__namespace.createElement("div", {
1039
- className: "text-xs text-muted-foreground"
1040
- }, option.description)))))));
1041
- }
1042
- chunk2HRO6CFU_js.__name(ToolSelect, "ToolSelect");
1043
- function Input({ className, type, ...props }) {
1044
- return /* @__PURE__ */ React26__namespace.createElement("input", {
1045
- type,
1046
- "data-slot": "input",
1047
- className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "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", className),
1048
- ...props
1049
- });
1050
- }
1051
- chunk2HRO6CFU_js.__name(Input, "Input");
1052
- function Command({ className, ...props }) {
1053
- return /* @__PURE__ */ React26__namespace.createElement(cmdk.Command, {
1054
- "data-slot": "command",
1055
- className: cn("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md", className),
1056
- ...props
1057
- });
1058
- }
1059
- chunk2HRO6CFU_js.__name(Command, "Command");
1060
- function CommandDialog({ title = "Command Palette", description = "Search for a command to run...", children, className, showCloseButton = true, ...props }) {
1061
- return /* @__PURE__ */ React26__namespace.createElement(Dialog, props, /* @__PURE__ */ React26__namespace.createElement(DialogHeader, {
1062
- className: "sr-only"
1063
- }, /* @__PURE__ */ React26__namespace.createElement(DialogTitle, null, title), /* @__PURE__ */ React26__namespace.createElement(DialogDescription, null, description)), /* @__PURE__ */ React26__namespace.createElement(DialogContent, {
1064
- className: cn("overflow-hidden p-0", className),
1065
- showCloseButton
1066
- }, /* @__PURE__ */ React26__namespace.createElement(Command, {
1067
- className: "[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"
1068
- }, children)));
1069
- }
1070
- chunk2HRO6CFU_js.__name(CommandDialog, "CommandDialog");
1071
- function CommandInput({ className, ...props }) {
1072
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1073
- "data-slot": "command-input-wrapper",
1074
- className: "flex h-9 items-center gap-2 border-b px-3"
1075
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.SearchIcon, {
1076
- className: "size-4 shrink-0 opacity-50"
1077
- }), /* @__PURE__ */ React26__namespace.createElement(cmdk.Command.Input, {
1078
- "data-slot": "command-input",
1079
- className: cn("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50", className),
1080
- ...props
1081
- }));
1082
- }
1083
- chunk2HRO6CFU_js.__name(CommandInput, "CommandInput");
1084
- function CommandList({ className, ...props }) {
1085
- return /* @__PURE__ */ React26__namespace.createElement(cmdk.Command.List, {
1086
- "data-slot": "command-list",
1087
- className: cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto", className),
1088
- ...props
1089
- });
1090
- }
1091
- chunk2HRO6CFU_js.__name(CommandList, "CommandList");
1092
- function CommandEmpty({ ...props }) {
1093
- return /* @__PURE__ */ React26__namespace.createElement(cmdk.Command.Empty, {
1094
- "data-slot": "command-empty",
1095
- className: "py-6 text-center text-sm",
1096
- ...props
1097
- });
1098
- }
1099
- chunk2HRO6CFU_js.__name(CommandEmpty, "CommandEmpty");
1100
- function CommandGroup({ className, ...props }) {
1101
- return /* @__PURE__ */ React26__namespace.createElement(cmdk.Command.Group, {
1102
- "data-slot": "command-group",
1103
- className: cn("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium", className),
1104
- ...props
1105
- });
1106
- }
1107
- chunk2HRO6CFU_js.__name(CommandGroup, "CommandGroup");
1108
- function CommandSeparator({ className, ...props }) {
1109
- return /* @__PURE__ */ React26__namespace.createElement(cmdk.Command.Separator, {
1110
- "data-slot": "command-separator",
1111
- className: cn("bg-border -mx-1 h-px", className),
1112
- ...props
1113
- });
1114
- }
1115
- chunk2HRO6CFU_js.__name(CommandSeparator, "CommandSeparator");
1116
- function CommandItem({ className, ...props }) {
1117
- return /* @__PURE__ */ React26__namespace.createElement(cmdk.Command.Item, {
1118
- "data-slot": "command-item",
1119
- className: cn("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
1120
- ...props
1121
- });
1122
- }
1123
- chunk2HRO6CFU_js.__name(CommandItem, "CommandItem");
1124
- function CommandShortcut({ className, ...props }) {
1125
- return /* @__PURE__ */ React26__namespace.createElement("span", {
1126
- "data-slot": "command-shortcut",
1127
- className: cn("text-muted-foreground ml-auto text-xs tracking-widest", className),
1128
- ...props
1129
- });
1130
- }
1131
- chunk2HRO6CFU_js.__name(CommandShortcut, "CommandShortcut");
1132
- function Popover({ ...props }) {
1133
- return /* @__PURE__ */ React26__namespace.createElement(PopoverPrimitive__namespace.Root, {
1134
- "data-slot": "popover",
1135
- ...props
1136
- });
1137
- }
1138
- chunk2HRO6CFU_js.__name(Popover, "Popover");
1139
- function PopoverTrigger({ ...props }) {
1140
- return /* @__PURE__ */ React26__namespace.createElement(PopoverPrimitive__namespace.Trigger, {
1141
- "data-slot": "popover-trigger",
1142
- ...props
1143
- });
1144
- }
1145
- chunk2HRO6CFU_js.__name(PopoverTrigger, "PopoverTrigger");
1146
- function PopoverContent({ className, align = "center", sideOffset = 4, ...props }) {
1147
- return /* @__PURE__ */ React26__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React26__namespace.createElement(PopoverPrimitive__namespace.Content, {
1148
- "data-slot": "popover-content",
1149
- align,
1150
- sideOffset,
1151
- className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden", className),
1152
- ...props
1153
- }));
1154
- }
1155
- chunk2HRO6CFU_js.__name(PopoverContent, "PopoverContent");
1156
- function PopoverAnchor({ ...props }) {
1157
- return /* @__PURE__ */ React26__namespace.createElement(PopoverPrimitive__namespace.Anchor, {
1158
- "data-slot": "popover-anchor",
1159
- ...props
1160
- });
1161
- }
1162
- chunk2HRO6CFU_js.__name(PopoverAnchor, "PopoverAnchor");
1163
-
1164
- // src/mcp/ToolInput.tsx
1165
- function ToolInput({ searchTool, debounce = 300, minChars = 1, argName = "query", additionalArgs = {}, autocomplete = false, transformSuggestions, onSuggestionSelect, emptyMessage = "No results found", value: controlledValue, onChange, onSearchResults, onSearchError, showSearchIcon = true, showClearButton = true, showLoadingIndicator = true, className, placeholder = "Search...", disabled, ...props }) {
1166
- const [internalValue, setInternalValue] = React26.useState("");
1167
- const [suggestions, setSuggestions] = React26.useState([]);
1168
- const [isOpen, setIsOpen] = React26.useState(false);
1169
- const debounceRef = React26.useRef(null);
1170
- const inputRef = React26.useRef(null);
1171
- const toolConfig = searchTool ? typeof searchTool === "string" ? {
1172
- name: searchTool
1173
- } : searchTool : null;
1174
- const { call, loading, error, reset } = useTool(toolConfig?.name ?? "", {
1175
- defaultArgs: {
1176
- ...toolConfig?.args,
1177
- ...additionalArgs
1178
- },
1179
- onSuccess: /* @__PURE__ */ chunk2HRO6CFU_js.__name((result) => {
1180
- onSearchResults?.(result);
1181
- if (autocomplete && transformSuggestions) {
1182
- const suggestions2 = transformSuggestions(result);
1183
- setSuggestions(suggestions2);
1184
- if (suggestions2.length > 0) {
1185
- setIsOpen(true);
1186
- }
1187
- }
1188
- }, "onSuccess"),
1189
- onError: onSearchError
1190
- });
1191
- const value = controlledValue ?? internalValue;
1192
- const handleChange = React26.useCallback((e) => {
1193
- const newValue = e.target.value;
1194
- setInternalValue(newValue);
1195
- onChange?.(newValue);
1196
- if (debounceRef.current) {
1197
- clearTimeout(debounceRef.current);
1198
- }
1199
- if (newValue.length < minChars) {
1200
- setSuggestions([]);
1201
- setIsOpen(false);
1202
- return;
1203
- }
1204
- if (toolConfig) {
1205
- debounceRef.current = setTimeout(() => {
1206
- call({
1207
- [argName]: newValue
1208
- });
1209
- }, debounce);
1210
- }
1211
- }, [
1212
- onChange,
1213
- minChars,
1214
- toolConfig,
1215
- argName,
1216
- debounce,
1217
- call
1218
- ]);
1219
- const handleClear = React26.useCallback(() => {
1220
- setInternalValue("");
1221
- onChange?.("");
1222
- setSuggestions([]);
1223
- setIsOpen(false);
1224
- reset();
1225
- inputRef.current?.focus();
1226
- }, [
1227
- onChange,
1228
- reset
1229
- ]);
1230
- const handleSelect = React26.useCallback((suggestion) => {
1231
- setInternalValue(suggestion.label);
1232
- onChange?.(suggestion.label);
1233
- setIsOpen(false);
1234
- onSuggestionSelect?.(suggestion);
1235
- }, [
1236
- onChange,
1237
- onSuggestionSelect
1238
- ]);
1239
- React26.useEffect(() => {
1240
- return () => {
1241
- if (debounceRef.current) {
1242
- clearTimeout(debounceRef.current);
1243
- }
1244
- };
1245
- }, []);
1246
- const inputElement = /* @__PURE__ */ React26__namespace.createElement("div", {
1247
- className: cn("relative", className)
1248
- }, showSearchIcon && /* @__PURE__ */ React26__namespace.createElement(lucideReact.Search, {
1249
- className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
1250
- }), /* @__PURE__ */ React26__namespace.createElement(Input, {
1251
- ref: inputRef,
1252
- value,
1253
- onChange: handleChange,
1254
- placeholder,
1255
- disabled,
1256
- className: cn(showSearchIcon && "pl-9", (showClearButton || showLoadingIndicator) && "pr-9"),
1257
- ...props
1258
- }), /* @__PURE__ */ React26__namespace.createElement("div", {
1259
- className: "absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1"
1260
- }, showLoadingIndicator && loading && /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
1261
- className: "h-4 w-4 animate-spin text-muted-foreground"
1262
- }), showClearButton && value && !loading && /* @__PURE__ */ React26__namespace.createElement("button", {
1263
- type: "button",
1264
- onClick: handleClear,
1265
- className: "h-4 w-4 text-muted-foreground hover:text-foreground transition-colors"
1266
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.X, {
1267
- className: "h-4 w-4"
1268
- }))));
1269
- if (!autocomplete) {
1270
- return inputElement;
1271
- }
1272
- return /* @__PURE__ */ React26__namespace.createElement(Popover, {
1273
- open: isOpen,
1274
- onOpenChange: setIsOpen
1275
- }, /* @__PURE__ */ React26__namespace.createElement(PopoverTrigger, {
1276
- asChild: true
1277
- }, inputElement), /* @__PURE__ */ React26__namespace.createElement(PopoverContent, {
1278
- className: "p-0 w-[var(--radix-popover-trigger-width)]",
1279
- align: "start",
1280
- onOpenAutoFocus: /* @__PURE__ */ chunk2HRO6CFU_js.__name((e) => e.preventDefault(), "onOpenAutoFocus")
1281
- }, /* @__PURE__ */ React26__namespace.createElement(Command, null, /* @__PURE__ */ React26__namespace.createElement(CommandList, null, /* @__PURE__ */ React26__namespace.createElement(CommandEmpty, null, emptyMessage), /* @__PURE__ */ React26__namespace.createElement(CommandGroup, null, suggestions.map((suggestion) => /* @__PURE__ */ React26__namespace.createElement(CommandItem, {
1282
- key: suggestion.value,
1283
- value: suggestion.value,
1284
- onSelect: /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => handleSelect(suggestion), "onSelect")
1285
- }, /* @__PURE__ */ React26__namespace.createElement("div", {
1286
- className: "flex items-center gap-2"
1287
- }, suggestion.icon, /* @__PURE__ */ React26__namespace.createElement("div", null, /* @__PURE__ */ React26__namespace.createElement("div", null, suggestion.label), suggestion.description && /* @__PURE__ */ React26__namespace.createElement("div", {
1288
- className: "text-xs text-muted-foreground"
1289
- }, suggestion.description))))))))));
1290
- }
1291
- chunk2HRO6CFU_js.__name(ToolInput, "ToolInput");
1292
- function Label2({ className, ...props }) {
1293
- return /* @__PURE__ */ React26__namespace.createElement(LabelPrimitive__namespace.Root, {
1294
- "data-slot": "label",
1295
- className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
1296
- ...props
1297
- });
1298
- }
1299
- chunk2HRO6CFU_js.__name(Label2, "Label");
1300
- function Textarea({ className, ...props }) {
1301
- return /* @__PURE__ */ React26__namespace.createElement("textarea", {
1302
- "data-slot": "textarea",
1303
- className: cn("border-input placeholder:text-muted-foreground 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:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", className),
1304
- ...props
1305
- });
1306
- }
1307
- chunk2HRO6CFU_js.__name(Textarea, "Textarea");
1308
- function Checkbox({ className, ...props }) {
1309
- return /* @__PURE__ */ React26__namespace.createElement(CheckboxPrimitive__namespace.Root, {
1310
- "data-slot": "checkbox",
1311
- className: cn("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className),
1312
- ...props
1313
- }, /* @__PURE__ */ React26__namespace.createElement(CheckboxPrimitive__namespace.Indicator, {
1314
- "data-slot": "checkbox-indicator",
1315
- className: "grid place-content-center text-current transition-none"
1316
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.CheckIcon, {
1317
- className: "size-3.5"
1318
- })));
1319
- }
1320
- chunk2HRO6CFU_js.__name(Checkbox, "Checkbox");
1321
- function Slider({ className, defaultValue, value, min = 0, max = 100, ...props }) {
1322
- const _values = React26__namespace.useMemo(() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [
1323
- min,
1324
- max
1325
- ], [
1326
- value,
1327
- defaultValue,
1328
- min,
1329
- max
1330
- ]);
1331
- return /* @__PURE__ */ React26__namespace.createElement(SliderPrimitive__namespace.Root, {
1332
- "data-slot": "slider",
1333
- defaultValue,
1334
- value,
1335
- min,
1336
- max,
1337
- className: cn("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col", className),
1338
- ...props
1339
- }, /* @__PURE__ */ React26__namespace.createElement(SliderPrimitive__namespace.Track, {
1340
- "data-slot": "slider-track",
1341
- className: cn("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5")
1342
- }, /* @__PURE__ */ React26__namespace.createElement(SliderPrimitive__namespace.Range, {
1343
- "data-slot": "slider-range",
1344
- className: cn("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")
1345
- })), Array.from({
1346
- length: _values.length
1347
- }, (_, index) => /* @__PURE__ */ React26__namespace.createElement(SliderPrimitive__namespace.Thumb, {
1348
- "data-slot": "slider-thumb",
1349
- key: index,
1350
- className: "border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
1351
- })));
1352
- }
1353
- chunk2HRO6CFU_js.__name(Slider, "Slider");
1354
- function Switch({ className, ...props }) {
1355
- return /* @__PURE__ */ React26__namespace.createElement(SwitchPrimitive__namespace.Root, {
1356
- "data-slot": "switch",
1357
- className: cn("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className),
1358
- ...props
1359
- }, /* @__PURE__ */ React26__namespace.createElement(SwitchPrimitive__namespace.Thumb, {
1360
- "data-slot": "switch-thumb",
1361
- className: cn("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")
1362
- }));
1363
- }
1364
- chunk2HRO6CFU_js.__name(Switch, "Switch");
1365
- var alertVariants = classVarianceAuthority.cva("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current", {
1366
- variants: {
1367
- variant: {
1368
- default: "bg-card text-card-foreground",
1369
- destructive: "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"
1370
- }
1371
- },
1372
- defaultVariants: {
1373
- variant: "default"
1374
- }
1375
- });
1376
- function Alert({ className, variant, ...props }) {
1377
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1378
- "data-slot": "alert",
1379
- role: "alert",
1380
- className: cn(alertVariants({
1381
- variant
1382
- }), className),
1383
- ...props
1384
- });
1385
- }
1386
- chunk2HRO6CFU_js.__name(Alert, "Alert");
1387
- function AlertTitle({ className, ...props }) {
1388
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1389
- "data-slot": "alert-title",
1390
- className: cn("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight", className),
1391
- ...props
1392
- });
1393
- }
1394
- chunk2HRO6CFU_js.__name(AlertTitle, "AlertTitle");
1395
- function AlertDescription({ className, ...props }) {
1396
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1397
- "data-slot": "alert-description",
1398
- className: cn("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed", className),
1399
- ...props
1400
- });
1401
- }
1402
- chunk2HRO6CFU_js.__name(AlertDescription, "AlertDescription");
1403
- function ToolForm({ toolName, fields: manualFields, autoSchema = false, submitText = "Submit", loadingText, onSuccess, onError, showResult = false, showSuccessToast = false, successMessage, resetOnSuccess = false, className, layout = "vertical" }) {
1404
- const { app, isConnected } = useMcpApp();
1405
- const { call, loading, result, error, reset } = useTool(toolName, {
1406
- onSuccess: /* @__PURE__ */ chunk2HRO6CFU_js.__name((result2) => {
1407
- onSuccess?.(result2);
1408
- if (showSuccessToast) {
1409
- const message = typeof successMessage === "function" ? successMessage(result2) : successMessage ?? "Form submitted successfully";
1410
- sonner.toast.success(message);
1411
- }
1412
- if (resetOnSuccess) {
1413
- resetForm();
1414
- }
1415
- }, "onSuccess"),
1416
- onError
1417
- });
1418
- const [fields, setFields] = React26.useState(manualFields ?? []);
1419
- const [schemaLoading, setSchemaLoading] = React26.useState(autoSchema);
1420
- const [formData, setFormData] = React26.useState({});
1421
- const initializeFormData = /* @__PURE__ */ chunk2HRO6CFU_js.__name((fields2) => {
1422
- const initial = {};
1423
- fields2.forEach((field) => {
1424
- if (field.defaultValue !== void 0) {
1425
- initial[field.name] = field.defaultValue;
1426
- } else if (field.type === "checkbox" || field.type === "switch") {
1427
- initial[field.name] = false;
1428
- } else if (field.type === "number" || field.type === "slider") {
1429
- initial[field.name] = field.min ?? 0;
1430
- } else {
1431
- initial[field.name] = "";
1432
- }
1433
- });
1434
- setFormData(initial);
1435
- }, "initializeFormData");
1436
- const resetForm = /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => {
1437
- initializeFormData(fields);
1438
- reset();
1439
- }, "resetForm");
1440
- React26.useEffect(() => {
1441
- if (autoSchema && app && isConnected) {
1442
- setSchemaLoading(true);
1443
- const fetchSchema = /* @__PURE__ */ chunk2HRO6CFU_js.__name(async () => {
1444
- try {
1445
- console.warn("[ToolForm] Auto-schema not fully implemented, use manual fields");
1446
- if (manualFields) {
1447
- setFields(manualFields);
1448
- initializeFormData(manualFields);
1449
- }
1450
- } catch (err) {
1451
- console.error("[ToolForm] Failed to fetch schema:", err);
1452
- } finally {
1453
- setSchemaLoading(false);
1454
- }
1455
- }, "fetchSchema");
1456
- fetchSchema();
1457
- } else if (manualFields) {
1458
- setFields(manualFields);
1459
- initializeFormData(manualFields);
1460
- }
1461
- }, [
1462
- autoSchema,
1463
- app,
1464
- isConnected,
1465
- manualFields,
1466
- toolName
1467
- ]);
1468
- const handleSubmit = /* @__PURE__ */ chunk2HRO6CFU_js.__name(async (e) => {
1469
- e.preventDefault();
1470
- const args = {};
1471
- fields.forEach((field) => {
1472
- let value = formData[field.name];
1473
- if (field.type === "number" || field.type === "slider") {
1474
- value = Number(value);
1475
- }
1476
- args[field.name] = value;
1477
- });
1478
- await call(args);
1479
- }, "handleSubmit");
1480
- const handleChange = /* @__PURE__ */ chunk2HRO6CFU_js.__name((name, value) => {
1481
- setFormData((prev) => ({
1482
- ...prev,
1483
- [name]: value
1484
- }));
1485
- }, "handleChange");
1486
- const renderField = /* @__PURE__ */ chunk2HRO6CFU_js.__name((field) => {
1487
- const value = formData[field.name];
1488
- switch (field.type) {
1489
- case "textarea":
1490
- return /* @__PURE__ */ React26__namespace.createElement(Textarea, {
1491
- id: field.name,
1492
- placeholder: field.placeholder,
1493
- value: value ?? "",
1494
- onChange: /* @__PURE__ */ chunk2HRO6CFU_js.__name((e) => handleChange(field.name, e.target.value), "onChange"),
1495
- disabled: field.disabled || loading,
1496
- required: field.required
1497
- });
1498
- case "select":
1499
- return /* @__PURE__ */ React26__namespace.createElement(Select, {
1500
- value: value ?? "",
1501
- onValueChange: /* @__PURE__ */ chunk2HRO6CFU_js.__name((v) => handleChange(field.name, v), "onValueChange"),
1502
- disabled: field.disabled || loading
1503
- }, /* @__PURE__ */ React26__namespace.createElement(SelectTrigger, null, /* @__PURE__ */ React26__namespace.createElement(SelectValue, {
1504
- placeholder: field.placeholder ?? "Select..."
1505
- })), /* @__PURE__ */ React26__namespace.createElement(SelectContent, null, field.options?.map((option) => /* @__PURE__ */ React26__namespace.createElement(SelectItem, {
1506
- key: option.value,
1507
- value: option.value
1508
- }, option.label))));
1509
- case "checkbox":
1510
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1511
- className: "flex items-center space-x-2"
1512
- }, /* @__PURE__ */ React26__namespace.createElement(Checkbox, {
1513
- id: field.name,
1514
- checked: value ?? false,
1515
- onCheckedChange: /* @__PURE__ */ chunk2HRO6CFU_js.__name((checked) => handleChange(field.name, checked), "onCheckedChange"),
1516
- disabled: field.disabled || loading
1517
- }), /* @__PURE__ */ React26__namespace.createElement("label", {
1518
- htmlFor: field.name,
1519
- className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
1520
- }, field.label));
1521
- case "switch":
1522
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1523
- className: "flex items-center space-x-2"
1524
- }, /* @__PURE__ */ React26__namespace.createElement(Switch, {
1525
- id: field.name,
1526
- checked: value ?? false,
1527
- onCheckedChange: /* @__PURE__ */ chunk2HRO6CFU_js.__name((checked) => handleChange(field.name, checked), "onCheckedChange"),
1528
- disabled: field.disabled || loading
1529
- }), /* @__PURE__ */ React26__namespace.createElement(Label2, {
1530
- htmlFor: field.name
1531
- }, field.label));
1532
- case "slider":
1533
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1534
- className: "space-y-2"
1535
- }, /* @__PURE__ */ React26__namespace.createElement("div", {
1536
- className: "flex justify-between text-sm"
1537
- }, /* @__PURE__ */ React26__namespace.createElement("span", null, field.min ?? 0), /* @__PURE__ */ React26__namespace.createElement("span", null, value ?? field.min ?? 0), /* @__PURE__ */ React26__namespace.createElement("span", null, field.max ?? 100)), /* @__PURE__ */ React26__namespace.createElement(Slider, {
1538
- value: [
1539
- value ?? field.min ?? 0
1540
- ],
1541
- onValueChange: /* @__PURE__ */ chunk2HRO6CFU_js.__name(([v]) => handleChange(field.name, v), "onValueChange"),
1542
- min: field.min ?? 0,
1543
- max: field.max ?? 100,
1544
- step: field.step ?? 1,
1545
- disabled: field.disabled || loading
1546
- }));
1547
- case "number":
1548
- return /* @__PURE__ */ React26__namespace.createElement(Input, {
1549
- id: field.name,
1550
- type: "number",
1551
- placeholder: field.placeholder,
1552
- value: value ?? "",
1553
- onChange: /* @__PURE__ */ chunk2HRO6CFU_js.__name((e) => handleChange(field.name, e.target.value), "onChange"),
1554
- min: field.min,
1555
- max: field.max,
1556
- step: field.step,
1557
- disabled: field.disabled || loading,
1558
- required: field.required
1559
- });
1560
- default:
1561
- return /* @__PURE__ */ React26__namespace.createElement(Input, {
1562
- id: field.name,
1563
- type: field.type ?? "text",
1564
- placeholder: field.placeholder,
1565
- value: value ?? "",
1566
- onChange: /* @__PURE__ */ chunk2HRO6CFU_js.__name((e) => handleChange(field.name, e.target.value), "onChange"),
1567
- disabled: field.disabled || loading,
1568
- required: field.required
1569
- });
1570
- }
1571
- }, "renderField");
1572
- if (schemaLoading) {
1573
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1574
- className: "flex items-center justify-center p-8"
1575
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
1576
- className: "h-6 w-6 animate-spin text-muted-foreground"
1577
- }));
1578
- }
1579
- return /* @__PURE__ */ React26__namespace.createElement("form", {
1580
- className: cn("space-y-4", className),
1581
- onSubmit: handleSubmit
1582
- }, /* @__PURE__ */ React26__namespace.createElement("div", {
1583
- className: cn("space-y-4", layout === "horizontal" && "grid grid-cols-2 gap-4")
1584
- }, fields.map((field) => /* @__PURE__ */ React26__namespace.createElement("div", {
1585
- key: field.name,
1586
- className: "space-y-2"
1587
- }, field.type !== "checkbox" && field.type !== "switch" && /* @__PURE__ */ React26__namespace.createElement(Label2, {
1588
- htmlFor: field.name
1589
- }, field.label, field.required && /* @__PURE__ */ React26__namespace.createElement("span", {
1590
- className: "text-destructive ml-1"
1591
- }, "*")), renderField(field), field.description && /* @__PURE__ */ React26__namespace.createElement("p", {
1592
- className: "text-sm text-muted-foreground"
1593
- }, field.description)))), /* @__PURE__ */ React26__namespace.createElement("div", {
1594
- className: "flex items-center gap-2"
1595
- }, /* @__PURE__ */ React26__namespace.createElement(Button, {
1596
- type: "submit",
1597
- disabled: loading
1598
- }, loading ? /* @__PURE__ */ React26__namespace.createElement(React26__namespace.Fragment, null, /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
1599
- className: "h-4 w-4 animate-spin mr-2"
1600
- }), loadingText ?? "Submitting...") : submitText)), error && /* @__PURE__ */ React26__namespace.createElement(Alert, {
1601
- variant: "destructive"
1602
- }, /* @__PURE__ */ React26__namespace.createElement(AlertDescription, null, error.message)), showResult && result !== null && /* @__PURE__ */ React26__namespace.createElement("div", {
1603
- className: "rounded-md bg-muted p-4"
1604
- }, /* @__PURE__ */ React26__namespace.createElement("pre", {
1605
- className: "text-sm overflow-auto"
1606
- }, JSON.stringify(result, null, 2))));
1607
- }
1608
- chunk2HRO6CFU_js.__name(ToolForm, "ToolForm");
1609
- function useResource(uri, options = {}) {
1610
- const { app, isConnected } = useMcpApp();
1611
- const { refreshInterval, subscribe = false, transform, skip = false } = options;
1612
- const [data, setData] = React26.useState(null);
1613
- const [loading, setLoading] = React26.useState(!skip);
1614
- const [error, setError] = React26.useState(null);
1615
- const [lastUpdated, setLastUpdated] = React26.useState(null);
1616
- const intervalRef = React26.useRef(null);
1617
- const mountedRef = React26.useRef(true);
1618
- const fetchResource = React26.useCallback(async () => {
1619
- if (!app || !isConnected) {
1620
- throw new Error("Not connected to MCP host");
1621
- }
1622
- setLoading(true);
1623
- setError(null);
1624
- try {
1625
- const result = await app.readResource?.({
1626
- uri
1627
- });
1628
- if (!result) {
1629
- throw new Error("readResource not supported by host");
1630
- }
1631
- let resourceData;
1632
- if (result.contents && result.contents.length > 0) {
1633
- const content = result.contents[0];
1634
- if (content.text) {
1635
- try {
1636
- resourceData = JSON.parse(content.text);
1637
- } catch {
1638
- resourceData = content.text;
1639
- }
1640
- } else if (content.blob) {
1641
- resourceData = content.blob;
1642
- } else {
1643
- resourceData = content;
1644
- }
1645
- } else {
1646
- resourceData = result;
1647
- }
1648
- if (transform) {
1649
- resourceData = transform(resourceData);
1650
- }
1651
- if (mountedRef.current) {
1652
- setData(resourceData);
1653
- setLastUpdated(/* @__PURE__ */ new Date());
1654
- setLoading(false);
1655
- }
1656
- return resourceData;
1657
- } catch (err) {
1658
- const error2 = err instanceof Error ? err : new Error(String(err));
1659
- if (mountedRef.current) {
1660
- setError(error2);
1661
- setLoading(false);
1662
- }
1663
- throw error2;
1664
- }
1665
- }, [
1666
- app,
1667
- isConnected,
1668
- uri,
1669
- transform
1670
- ]);
1671
- const refresh = React26.useCallback(async () => {
1672
- return fetchResource();
1673
- }, [
1674
- fetchResource
1675
- ]);
1676
- React26.useEffect(() => {
1677
- mountedRef.current = true;
1678
- if (!skip && isConnected) {
1679
- fetchResource().catch(() => {
1680
- });
1681
- }
1682
- return () => {
1683
- mountedRef.current = false;
1684
- };
1685
- }, [
1686
- uri,
1687
- isConnected,
1688
- skip,
1689
- fetchResource
1690
- ]);
1691
- React26.useEffect(() => {
1692
- if (intervalRef.current) {
1693
- clearInterval(intervalRef.current);
1694
- intervalRef.current = null;
1695
- }
1696
- if (refreshInterval && refreshInterval > 0 && isConnected && !skip) {
1697
- intervalRef.current = setInterval(() => {
1698
- fetchResource().catch(() => {
1699
- });
1700
- }, refreshInterval);
1701
- }
1702
- return () => {
1703
- if (intervalRef.current) {
1704
- clearInterval(intervalRef.current);
1705
- intervalRef.current = null;
1706
- }
1707
- };
1708
- }, [
1709
- refreshInterval,
1710
- isConnected,
1711
- skip,
1712
- fetchResource
1713
- ]);
1714
- React26.useEffect(() => {
1715
- if (subscribe) {
1716
- console.warn("[useResource] Subscription support not yet implemented");
1717
- }
1718
- }, [
1719
- subscribe
1720
- ]);
1721
- return {
1722
- data,
1723
- loading,
1724
- error,
1725
- refresh,
1726
- lastUpdated
1727
- };
1728
- }
1729
- chunk2HRO6CFU_js.__name(useResource, "useResource");
1730
- function Skeleton({ className, ...props }) {
1731
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
1732
- "data-slot": "skeleton",
1733
- className: cn("bg-accent animate-pulse rounded-md", className),
1734
- ...props
1735
- });
1736
- }
1737
- chunk2HRO6CFU_js.__name(Skeleton, "Skeleton");
1738
-
1739
- // src/mcp/ResourceView.tsx
1740
- function DefaultLoading() {
1741
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1742
- className: "flex flex-col gap-3 p-4"
1743
- }, /* @__PURE__ */ React26__namespace.createElement(Skeleton, {
1744
- className: "h-4 w-3/4"
1745
- }), /* @__PURE__ */ React26__namespace.createElement(Skeleton, {
1746
- className: "h-4 w-1/2"
1747
- }), /* @__PURE__ */ React26__namespace.createElement(Skeleton, {
1748
- className: "h-20 w-full"
1749
- }));
1750
- }
1751
- chunk2HRO6CFU_js.__name(DefaultLoading, "DefaultLoading");
1752
- function DefaultError({ error, onRetry }) {
1753
- return /* @__PURE__ */ React26__namespace.createElement(Alert, {
1754
- variant: "destructive"
1755
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.AlertCircle, {
1756
- className: "h-4 w-4"
1757
- }), /* @__PURE__ */ React26__namespace.createElement(AlertTitle, null, "Error loading resource"), /* @__PURE__ */ React26__namespace.createElement(AlertDescription, {
1758
- className: "flex flex-col gap-2"
1759
- }, /* @__PURE__ */ React26__namespace.createElement("span", null, error.message), /* @__PURE__ */ React26__namespace.createElement(Button, {
1760
- variant: "outline",
1761
- size: "sm",
1762
- onClick: onRetry,
1763
- className: "w-fit"
1764
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.RefreshCw, {
1765
- className: "h-4 w-4 mr-2"
1766
- }), "Retry")));
1767
- }
1768
- chunk2HRO6CFU_js.__name(DefaultError, "DefaultError");
1769
- function ResourceView({ uri, refreshInterval, subscribe, transform, loading: loadingContent, error: errorContent, children, className, skip = false }) {
1770
- const { data, loading, error, refresh, lastUpdated } = useResource(uri, {
1771
- refreshInterval,
1772
- subscribe,
1773
- transform,
1774
- skip
1775
- });
1776
- const meta = {
1777
- uri,
1778
- refresh,
1779
- lastUpdated,
1780
- isRefreshing: loading && data !== null
1781
- };
1782
- if (loading && data === null) {
1783
- if (loadingContent) {
1784
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1785
- className
1786
- }, loadingContent);
1787
- }
1788
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1789
- className: cn("flex items-center justify-center p-8", className)
1790
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
1791
- className: "h-8 w-8 animate-spin text-muted-foreground"
1792
- }));
1793
- }
1794
- if (error && data === null) {
1795
- if (errorContent) {
1796
- if (typeof errorContent === "function") {
1797
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1798
- className
1799
- }, errorContent(error, refresh));
1800
- }
1801
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1802
- className
1803
- }, errorContent);
1804
- }
1805
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1806
- className
1807
- }, /* @__PURE__ */ React26__namespace.createElement(DefaultError, {
1808
- error,
1809
- onRetry: refresh
1810
- }));
1811
- }
1812
- if (data !== null) {
1813
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1814
- className
1815
- }, children(data, meta));
1816
- }
1817
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1818
- className
1819
- }, loadingContent ?? /* @__PURE__ */ React26__namespace.createElement(DefaultLoading, null));
1820
- }
1821
- chunk2HRO6CFU_js.__name(ResourceView, "ResourceView");
1822
- function useToolStream(options = {}) {
1823
- const { toolInputPartial, toolInput, toolResult } = useMcpApp();
1824
- const { onPartial, onComplete } = options;
1825
- const [partial, setPartial] = React26.useState(null);
1826
- const [complete, setComplete] = React26.useState(null);
1827
- const [isStreaming, setIsStreaming] = React26.useState(false);
1828
- const [isComplete, setIsComplete] = React26.useState(false);
1829
- React26.useEffect(() => {
1830
- if (toolInputPartial) {
1831
- setPartial(toolInputPartial);
1832
- setIsStreaming(true);
1833
- setIsComplete(false);
1834
- onPartial?.(toolInputPartial);
1835
- }
1836
- }, [
1837
- toolInputPartial,
1838
- onPartial
1839
- ]);
1840
- React26.useEffect(() => {
1841
- if (toolInput) {
1842
- setComplete(toolInput);
1843
- setIsStreaming(false);
1844
- setIsComplete(true);
1845
- onComplete?.(toolInput);
1846
- }
1847
- }, [
1848
- toolInput,
1849
- onComplete
1850
- ]);
1851
- React26.useEffect(() => {
1852
- if (toolResult && !toolResult.isError) {
1853
- setIsStreaming(false);
1854
- setIsComplete(true);
1855
- }
1856
- }, [
1857
- toolResult
1858
- ]);
1859
- return {
1860
- partial,
1861
- complete,
1862
- isStreaming,
1863
- isComplete
1864
- };
1865
- }
1866
- chunk2HRO6CFU_js.__name(useToolStream, "useToolStream");
1867
- function Progress({ className, value, ...props }) {
1868
- return /* @__PURE__ */ React26__namespace.createElement(ProgressPrimitive__namespace.Root, {
1869
- "data-slot": "progress",
1870
- className: cn("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full", className),
1871
- ...props
1872
- }, /* @__PURE__ */ React26__namespace.createElement(ProgressPrimitive__namespace.Indicator, {
1873
- "data-slot": "progress-indicator",
1874
- className: "bg-primary h-full w-full flex-1 transition-all",
1875
- style: {
1876
- transform: `translateX(-${100 - (value || 0)}%)`
1877
- }
1878
- }));
1879
- }
1880
- chunk2HRO6CFU_js.__name(Progress, "Progress");
1881
-
1882
- // src/mcp/StreamingContent.tsx
1883
- function StreamingContent({ fallback, showProgress = false, progress: externalProgress, onPartial, onComplete, children, className, streamingStyle = "opacity" }) {
1884
- const { partial, complete, isStreaming, isComplete } = useToolStream({
1885
- onPartial,
1886
- onComplete
1887
- });
1888
- const data = complete ?? partial;
1889
- if (!data) {
1890
- if (fallback) {
1891
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1892
- className
1893
- }, fallback);
1894
- }
1895
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1896
- className: cn("flex items-center justify-center p-8", className)
1897
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
1898
- className: "h-6 w-6 animate-spin text-muted-foreground"
1899
- }));
1900
- }
1901
- const streamingClasses = cn(streamingStyle === "opacity" && isStreaming && "opacity-70", streamingStyle === "blur" && isStreaming && "blur-[1px]");
1902
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1903
- className: cn("relative", className)
1904
- }, showProgress && isStreaming && /* @__PURE__ */ React26__namespace.createElement("div", {
1905
- className: "absolute top-0 left-0 right-0 z-10"
1906
- }, externalProgress !== void 0 ? /* @__PURE__ */ React26__namespace.createElement(Progress, {
1907
- value: externalProgress,
1908
- className: "h-1"
1909
- }) : /* @__PURE__ */ React26__namespace.createElement("div", {
1910
- className: "h-1 bg-primary/20 overflow-hidden"
1911
- }, /* @__PURE__ */ React26__namespace.createElement("div", {
1912
- className: "h-full w-1/3 bg-primary animate-[shimmer_1s_infinite]"
1913
- }))), isStreaming && /* @__PURE__ */ React26__namespace.createElement("div", {
1914
- className: "absolute top-2 right-2 z-10"
1915
- }, /* @__PURE__ */ React26__namespace.createElement("div", {
1916
- className: "flex items-center gap-1 px-2 py-1 rounded-full bg-muted text-muted-foreground text-xs"
1917
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
1918
- className: "h-3 w-3 animate-spin"
1919
- }), /* @__PURE__ */ React26__namespace.createElement("span", null, "Streaming..."))), /* @__PURE__ */ React26__namespace.createElement("div", {
1920
- className: cn("transition-all duration-200", streamingClasses)
1921
- }, children(data, isComplete)));
1922
- }
1923
- chunk2HRO6CFU_js.__name(StreamingContent, "StreamingContent");
1924
- function Table({ className, ...props }) {
1925
- return /* @__PURE__ */ React26__namespace.createElement("div", {
1926
- "data-slot": "table-container",
1927
- className: "relative w-full overflow-x-auto"
1928
- }, /* @__PURE__ */ React26__namespace.createElement("table", {
1929
- "data-slot": "table",
1930
- className: cn("w-full caption-bottom text-sm", className),
1931
- ...props
1932
- }));
1933
- }
1934
- chunk2HRO6CFU_js.__name(Table, "Table");
1935
- function TableHeader({ className, ...props }) {
1936
- return /* @__PURE__ */ React26__namespace.createElement("thead", {
1937
- "data-slot": "table-header",
1938
- className: cn("[&_tr]:border-b", className),
1939
- ...props
1940
- });
1941
- }
1942
- chunk2HRO6CFU_js.__name(TableHeader, "TableHeader");
1943
- function TableBody({ className, ...props }) {
1944
- return /* @__PURE__ */ React26__namespace.createElement("tbody", {
1945
- "data-slot": "table-body",
1946
- className: cn("[&_tr:last-child]:border-0", className),
1947
- ...props
1948
- });
1949
- }
1950
- chunk2HRO6CFU_js.__name(TableBody, "TableBody");
1951
- function TableFooter({ className, ...props }) {
1952
- return /* @__PURE__ */ React26__namespace.createElement("tfoot", {
1953
- "data-slot": "table-footer",
1954
- className: cn("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className),
1955
- ...props
1956
- });
1957
- }
1958
- chunk2HRO6CFU_js.__name(TableFooter, "TableFooter");
1959
- function TableRow({ className, ...props }) {
1960
- return /* @__PURE__ */ React26__namespace.createElement("tr", {
1961
- "data-slot": "table-row",
1962
- className: cn("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className),
1963
- ...props
1964
- });
1965
- }
1966
- chunk2HRO6CFU_js.__name(TableRow, "TableRow");
1967
- function TableHead({ className, ...props }) {
1968
- return /* @__PURE__ */ React26__namespace.createElement("th", {
1969
- "data-slot": "table-head",
1970
- className: cn("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className),
1971
- ...props
1972
- });
1973
- }
1974
- chunk2HRO6CFU_js.__name(TableHead, "TableHead");
1975
- function TableCell({ className, ...props }) {
1976
- return /* @__PURE__ */ React26__namespace.createElement("td", {
1977
- "data-slot": "table-cell",
1978
- className: cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className),
1979
- ...props
1980
- });
1981
- }
1982
- chunk2HRO6CFU_js.__name(TableCell, "TableCell");
1983
- function TableCaption({ className, ...props }) {
1984
- return /* @__PURE__ */ React26__namespace.createElement("caption", {
1985
- "data-slot": "table-caption",
1986
- className: cn("text-muted-foreground mt-4 text-sm", className),
1987
- ...props
1988
- });
1989
- }
1990
- chunk2HRO6CFU_js.__name(TableCaption, "TableCaption");
1991
- function getNestedValue(obj, path) {
1992
- return path.split(".").reduce((current, key) => {
1993
- if (current && typeof current === "object" && key in current) {
1994
- return current[key];
1995
- }
1996
- return void 0;
1997
- }, obj);
1998
- }
1999
- chunk2HRO6CFU_js.__name(getNestedValue, "getNestedValue");
2000
- function ToolDataGrid({ dataTool, columns, transformData, rowActions = [], pagination = true, pageSizes = [
2001
- 10,
2002
- 25,
2003
- 50,
2004
- 100
2005
- ], defaultPageSize = 10, defaultSort, refreshInterval, showRefresh = true, onDataLoaded, onError, onRowClick, getRowKey, emptyContent, loadingContent, className }) {
2006
- if (!dataTool) {
2007
- throw new Error("ToolDataGrid: dataTool prop is required");
2008
- }
2009
- const toolConfig = typeof dataTool === "string" ? {
2010
- name: dataTool
2011
- } : dataTool;
2012
- const [data, setData] = React26.useState({
2013
- rows: [],
2014
- total: 0
2015
- });
2016
- const [paginationState, setPaginationState] = React26.useState({
2017
- page: 1,
2018
- pageSize: defaultPageSize
2019
- });
2020
- const [sortState, setSortState] = React26.useState(defaultSort ?? {
2021
- column: null,
2022
- direction: "asc"
2023
- });
2024
- const { call, loading, error } = useTool(toolConfig.name, {
2025
- defaultArgs: toolConfig.args,
2026
- onSuccess: /* @__PURE__ */ chunk2HRO6CFU_js.__name((result) => {
2027
- const gridData = transformData ? transformData(result) : result;
2028
- setData(gridData);
2029
- onDataLoaded?.(gridData);
2030
- }, "onSuccess"),
2031
- onError
2032
- });
2033
- const fetchData = React26.useCallback(() => {
2034
- const args = {};
2035
- if (pagination) {
2036
- args.page = paginationState.page;
2037
- args.pageSize = paginationState.pageSize;
2038
- args.offset = (paginationState.page - 1) * paginationState.pageSize;
2039
- args.limit = paginationState.pageSize;
2040
- }
2041
- if (sortState.column) {
2042
- args.sortBy = sortState.column;
2043
- args.sortDirection = sortState.direction;
2044
- args.sort = `${sortState.column}:${sortState.direction}`;
2045
- }
2046
- call(args);
2047
- }, [
2048
- call,
2049
- pagination,
2050
- paginationState,
2051
- sortState
2052
- ]);
2053
- const initialFetchDone = React26__namespace.useRef(false);
2054
- const prevStateRef = React26__namespace.useRef({
2055
- pagination: paginationState,
2056
- sort: sortState
2057
- });
2058
- React26.useEffect(() => {
2059
- if (!initialFetchDone.current) {
2060
- initialFetchDone.current = true;
2061
- fetchData();
2062
- return;
2063
- }
2064
- const prevState = prevStateRef.current;
2065
- const stateChanged = prevState.pagination.page !== paginationState.page || prevState.pagination.pageSize !== paginationState.pageSize || prevState.sort.column !== sortState.column || prevState.sort.direction !== sortState.direction;
2066
- if (stateChanged) {
2067
- prevStateRef.current = {
2068
- pagination: paginationState,
2069
- sort: sortState
2070
- };
2071
- fetchData();
2072
- }
2073
- }, [
2074
- fetchData,
2075
- paginationState,
2076
- sortState
2077
- ]);
2078
- React26.useEffect(() => {
2079
- if (refreshInterval && refreshInterval > 0) {
2080
- const interval = setInterval(fetchData, refreshInterval);
2081
- return () => clearInterval(interval);
2082
- }
2083
- }, [
2084
- refreshInterval,
2085
- fetchData
2086
- ]);
2087
- const handleSort = React26.useCallback((column) => {
2088
- setSortState((prev) => ({
2089
- column,
2090
- direction: prev.column === column && prev.direction === "asc" ? "desc" : "asc"
2091
- }));
2092
- }, []);
2093
- const handlePageChange = React26.useCallback((page) => {
2094
- setPaginationState((prev) => ({
2095
- ...prev,
2096
- page
2097
- }));
2098
- }, []);
2099
- const handlePageSizeChange = React26.useCallback((pageSize) => {
2100
- setPaginationState({
2101
- page: 1,
2102
- pageSize: parseInt(pageSize, 10)
2103
- });
2104
- }, []);
2105
- const totalPages = Math.ceil(data.total / paginationState.pageSize);
2106
- const canPreviousPage = paginationState.page > 1;
2107
- const canNextPage = paginationState.page < totalPages;
2108
- const getSortIcon = /* @__PURE__ */ chunk2HRO6CFU_js.__name((column) => {
2109
- if (sortState.column !== column) {
2110
- return /* @__PURE__ */ React26__namespace.createElement(lucideReact.ArrowUpDown, {
2111
- className: "h-4 w-4"
2112
- });
2113
- }
2114
- return sortState.direction === "asc" ? /* @__PURE__ */ React26__namespace.createElement(lucideReact.ArrowUp, {
2115
- className: "h-4 w-4"
2116
- }) : /* @__PURE__ */ React26__namespace.createElement(lucideReact.ArrowDown, {
2117
- className: "h-4 w-4"
2118
- });
2119
- }, "getSortIcon");
2120
- const renderLoading = /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => {
2121
- if (loadingContent) return loadingContent;
2122
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2123
- className: "space-y-2"
2124
- }, Array.from({
2125
- length: 5
2126
- }).map((_, i) => /* @__PURE__ */ React26__namespace.createElement(Skeleton, {
2127
- key: i,
2128
- className: "h-12 w-full"
2129
- })));
2130
- }, "renderLoading");
2131
- const renderEmpty = /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => {
2132
- if (emptyContent) return emptyContent;
2133
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2134
- className: "flex flex-col items-center justify-center py-12 text-muted-foreground"
2135
- }, /* @__PURE__ */ React26__namespace.createElement("p", {
2136
- className: "text-lg"
2137
- }, "No data found"), /* @__PURE__ */ React26__namespace.createElement(Button, {
2138
- variant: "ghost",
2139
- size: "sm",
2140
- onClick: fetchData,
2141
- className: "mt-2"
2142
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.RefreshCw, {
2143
- className: "h-4 w-4 mr-2"
2144
- }), "Refresh"));
2145
- }, "renderEmpty");
2146
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2147
- className: cn("space-y-4", className)
2148
- }, showRefresh && /* @__PURE__ */ React26__namespace.createElement("div", {
2149
- className: "flex items-center justify-end gap-2"
2150
- }, /* @__PURE__ */ React26__namespace.createElement(Button, {
2151
- variant: "outline",
2152
- size: "sm",
2153
- onClick: fetchData,
2154
- disabled: loading
2155
- }, loading ? /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
2156
- className: "h-4 w-4 animate-spin"
2157
- }) : /* @__PURE__ */ React26__namespace.createElement(lucideReact.RefreshCw, {
2158
- className: "h-4 w-4"
2159
- }), /* @__PURE__ */ React26__namespace.createElement("span", {
2160
- className: "ml-2"
2161
- }, "Refresh"))), /* @__PURE__ */ React26__namespace.createElement("div", {
2162
- className: "rounded-md border"
2163
- }, loading && data.rows.length === 0 ? /* @__PURE__ */ React26__namespace.createElement("div", {
2164
- className: "p-4"
2165
- }, renderLoading()) : data.rows.length === 0 ? renderEmpty() : /* @__PURE__ */ React26__namespace.createElement(Table, null, /* @__PURE__ */ React26__namespace.createElement(TableHeader, null, /* @__PURE__ */ React26__namespace.createElement(TableRow, null, columns.map((column) => /* @__PURE__ */ React26__namespace.createElement(TableHead, {
2166
- key: column.key,
2167
- style: {
2168
- width: column.width
2169
- },
2170
- className: cn(column.align === "center" && "text-center", column.align === "right" && "text-right", column.hideMobile && "hidden md:table-cell")
2171
- }, column.sortable ? /* @__PURE__ */ React26__namespace.createElement(Button, {
2172
- variant: "ghost",
2173
- size: "sm",
2174
- onClick: /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => handleSort(column.key), "onClick"),
2175
- className: "-ml-3"
2176
- }, column.header, getSortIcon(column.key)) : column.header)), rowActions.length > 0 && /* @__PURE__ */ React26__namespace.createElement(TableHead, {
2177
- className: "w-[100px]"
2178
- }, "Actions"))), /* @__PURE__ */ React26__namespace.createElement(TableBody, null, data.rows.map((row, index) => {
2179
- const key = getRowKey?.(row, index) ?? String(index);
2180
- return /* @__PURE__ */ React26__namespace.createElement(TableRow, {
2181
- key,
2182
- onClick: /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => onRowClick?.(row, index), "onClick"),
2183
- className: onRowClick ? "cursor-pointer" : void 0
2184
- }, columns.map((column) => {
2185
- const value = getNestedValue(row, column.key);
2186
- return /* @__PURE__ */ React26__namespace.createElement(TableCell, {
2187
- key: column.key,
2188
- className: cn(column.align === "center" && "text-center", column.align === "right" && "text-right", column.hideMobile && "hidden md:table-cell")
2189
- }, column.render ? column.render(value, row, index) : String(value ?? ""));
2190
- }), rowActions.length > 0 && /* @__PURE__ */ React26__namespace.createElement(TableCell, null, /* @__PURE__ */ React26__namespace.createElement("div", {
2191
- className: "flex items-center gap-1"
2192
- }, rowActions.filter((action) => !action.hidden?.(row)).map((action, actionIndex) => /* @__PURE__ */ React26__namespace.createElement(RowActionButton, {
2193
- key: actionIndex,
2194
- action,
2195
- row,
2196
- onRefresh: fetchData
2197
- })))));
2198
- })))), pagination && data.total > 0 && /* @__PURE__ */ React26__namespace.createElement("div", {
2199
- className: "flex items-center justify-between"
2200
- }, /* @__PURE__ */ React26__namespace.createElement("div", {
2201
- className: "text-sm text-muted-foreground"
2202
- }, "Showing ", (paginationState.page - 1) * paginationState.pageSize + 1, " to", " ", Math.min(paginationState.page * paginationState.pageSize, data.total), " of", " ", data.total, " results"), /* @__PURE__ */ React26__namespace.createElement("div", {
2203
- className: "flex items-center gap-4"
2204
- }, /* @__PURE__ */ React26__namespace.createElement("div", {
2205
- className: "flex items-center gap-2"
2206
- }, /* @__PURE__ */ React26__namespace.createElement("span", {
2207
- className: "text-sm text-muted-foreground"
2208
- }, "Rows per page"), /* @__PURE__ */ React26__namespace.createElement(Select, {
2209
- value: String(paginationState.pageSize),
2210
- onValueChange: handlePageSizeChange
2211
- }, /* @__PURE__ */ React26__namespace.createElement(SelectTrigger, {
2212
- className: "w-[70px]"
2213
- }, /* @__PURE__ */ React26__namespace.createElement(SelectValue, null)), /* @__PURE__ */ React26__namespace.createElement(SelectContent, null, pageSizes.map((size) => /* @__PURE__ */ React26__namespace.createElement(SelectItem, {
2214
- key: size,
2215
- value: String(size)
2216
- }, size))))), /* @__PURE__ */ React26__namespace.createElement("div", {
2217
- className: "flex items-center gap-2"
2218
- }, /* @__PURE__ */ React26__namespace.createElement(Button, {
2219
- variant: "outline",
2220
- size: "sm",
2221
- onClick: /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => handlePageChange(paginationState.page - 1), "onClick"),
2222
- disabled: !canPreviousPage || loading
2223
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.ChevronLeft, {
2224
- className: "h-4 w-4"
2225
- })), /* @__PURE__ */ React26__namespace.createElement("span", {
2226
- className: "text-sm"
2227
- }, "Page ", paginationState.page, " of ", totalPages), /* @__PURE__ */ React26__namespace.createElement(Button, {
2228
- variant: "outline",
2229
- size: "sm",
2230
- onClick: /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => handlePageChange(paginationState.page + 1), "onClick"),
2231
- disabled: !canNextPage || loading
2232
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.ChevronRight, {
2233
- className: "h-4 w-4"
2234
- }))))));
2235
- }
2236
- chunk2HRO6CFU_js.__name(ToolDataGrid, "ToolDataGrid");
2237
- function RowActionButton({ action, row, onRefresh }) {
2238
- if (!action.tool) {
2239
- throw new Error("ToolDataGrid: rowAction.tool is required");
2240
- }
2241
- const toolConfig = typeof action.tool === "string" ? {
2242
- name: action.tool
2243
- } : action.tool;
2244
- const args = action.getArgs?.(row) ?? {
2245
- id: row.id
2246
- };
2247
- const { call, loading } = useTool(toolConfig.name, {
2248
- onSuccess: /* @__PURE__ */ chunk2HRO6CFU_js.__name((result) => {
2249
- action.onSuccess?.(result, row);
2250
- sonner.toast.success("Action completed");
2251
- onRefresh();
2252
- }, "onSuccess"),
2253
- onError: /* @__PURE__ */ chunk2HRO6CFU_js.__name((error) => {
2254
- sonner.toast.error(error.message);
2255
- }, "onError")
2256
- });
2257
- const handleClick = React26.useCallback((e) => {
2258
- e.stopPropagation();
2259
- call(args);
2260
- }, [
2261
- call,
2262
- args
2263
- ]);
2264
- return /* @__PURE__ */ React26__namespace.createElement(Button, {
2265
- variant: action.variant ?? "ghost",
2266
- size: "sm",
2267
- onClick: handleClick,
2268
- disabled: loading
2269
- }, loading ? /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
2270
- className: "h-3 w-3 animate-spin"
2271
- }) : /* @__PURE__ */ React26__namespace.createElement(React26__namespace.Fragment, null, action.icon, /* @__PURE__ */ React26__namespace.createElement("span", {
2272
- className: action.icon ? "ml-1" : ""
2273
- }, action.label)));
2274
- }
2275
- chunk2HRO6CFU_js.__name(RowActionButton, "RowActionButton");
2276
- var Button2 = /* @__PURE__ */ React26.forwardRef(({ className, variant = "primary", size = "md", loading = false, disabled, asChild = false, leftIcon, rightIcon, children, ...props }, ref) => {
2277
- const Comp = asChild ? reactSlot.Slot : "button";
2278
- return /* @__PURE__ */ React26__namespace.default.createElement(Comp, {
2279
- ref,
2280
- className: clsx.clsx("lui-button", `lui-button--${variant}`, `lui-button--${size}`, loading && "lui-button--loading", className),
2281
- disabled: disabled || loading,
2282
- ...props
2283
- }, loading && /* @__PURE__ */ React26__namespace.default.createElement("span", {
2284
- className: "lui-button__spinner",
2285
- "aria-hidden": "true"
2286
- }, /* @__PURE__ */ React26__namespace.default.createElement("svg", {
2287
- viewBox: "0 0 24 24",
2288
- fill: "none",
2289
- className: "lui-spinner-icon"
2290
- }, /* @__PURE__ */ React26__namespace.default.createElement("circle", {
2291
- cx: "12",
2292
- cy: "12",
2293
- r: "10",
2294
- stroke: "currentColor",
2295
- strokeWidth: "3",
2296
- strokeLinecap: "round",
2297
- strokeDasharray: "32",
2298
- strokeDashoffset: "12"
2299
- }))), leftIcon && !loading && /* @__PURE__ */ React26__namespace.default.createElement("span", {
2300
- className: "lui-button__icon"
2301
- }, leftIcon), /* @__PURE__ */ React26__namespace.default.createElement("span", {
2302
- className: "lui-button__content"
2303
- }, children), rightIcon && /* @__PURE__ */ React26__namespace.default.createElement("span", {
2304
- className: "lui-button__icon"
2305
- }, rightIcon));
2306
- });
2307
- Button2.displayName = "Button";
2308
-
2309
- // src/mcp/ActionButton.tsx
2310
- function ActionButton({ toolName, toolArgs = {}, onToolSuccess, onToolError, showResult = false, renderResult, children, ...buttonProps }) {
2311
- const { call, loading, result, error } = useTool(toolName);
2312
- const [hasResult, setHasResult] = React26.useState(false);
2313
- const handleClick = /* @__PURE__ */ chunk2HRO6CFU_js.__name(async () => {
2314
- try {
2315
- const res = await call(toolArgs);
2316
- setHasResult(true);
2317
- onToolSuccess?.(res);
2318
- } catch (err) {
2319
- onToolError?.(err instanceof Error ? err : new Error(String(err)));
2320
- }
2321
- }, "handleClick");
2322
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
2323
- className: "lui-action-button-wrapper"
2324
- }, /* @__PURE__ */ React26__namespace.default.createElement(Button2, {
2325
- ...buttonProps,
2326
- loading,
2327
- onClick: handleClick
2328
- }, children), showResult && hasResult && result !== null && /* @__PURE__ */ React26__namespace.default.createElement("div", {
2329
- className: "lui-action-button-result"
2330
- }, renderResult ? renderResult(result) : /* @__PURE__ */ React26__namespace.default.createElement("pre", null, JSON.stringify(result, null, 2))), error && /* @__PURE__ */ React26__namespace.default.createElement("div", {
2331
- className: "lui-action-button-error"
2332
- }, error.message));
2333
- }
2334
- chunk2HRO6CFU_js.__name(ActionButton, "ActionButton");
2335
- function DefaultLoading2() {
2336
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2337
- className: "flex items-center justify-center p-8"
2338
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.Loader2, {
2339
- className: "h-6 w-6 animate-spin text-muted-foreground"
2340
- }));
2341
- }
2342
- chunk2HRO6CFU_js.__name(DefaultLoading2, "DefaultLoading");
2343
- function DefaultDisconnected() {
2344
- return /* @__PURE__ */ React26__namespace.createElement(Alert, null, /* @__PURE__ */ React26__namespace.createElement(lucideReact.WifiOff, {
2345
- className: "h-4 w-4"
2346
- }), /* @__PURE__ */ React26__namespace.createElement(AlertDescription, null, "Waiting for connection to MCP host..."));
2347
- }
2348
- chunk2HRO6CFU_js.__name(DefaultDisconnected, "DefaultDisconnected");
2349
- function DefaultError2({ error }) {
2350
- return /* @__PURE__ */ React26__namespace.createElement(Alert, {
2351
- variant: "destructive"
2352
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.AlertCircle, {
2353
- className: "h-4 w-4"
2354
- }), /* @__PURE__ */ React26__namespace.createElement(AlertDescription, null, "Connection error: ", error.message));
2355
- }
2356
- chunk2HRO6CFU_js.__name(DefaultError2, "DefaultError");
2357
- function RequireConnection({ loading: loadingContent, error: errorContent, disconnected: disconnectedContent, children, className }) {
2358
- const { isConnected, error, app } = useMcpApp();
2359
- console.log("[RequireConnection] State:", {
2360
- hasApp: !!app,
2361
- isConnected,
2362
- hasError: !!error
2363
- });
2364
- if (!app && !error && !isConnected) {
2365
- console.log("[RequireConnection] Rendering: Initial Loading");
2366
- if (loadingContent) {
2367
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2368
- className
2369
- }, loadingContent);
2370
- }
2371
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2372
- className
2373
- }, /* @__PURE__ */ React26__namespace.createElement(DefaultLoading2, null));
2374
- }
2375
- if (error) {
2376
- console.log("[RequireConnection] Rendering: Error");
2377
- if (errorContent) {
2378
- if (typeof errorContent === "function") {
2379
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2380
- className
2381
- }, errorContent(error));
2382
- }
2383
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2384
- className
2385
- }, errorContent);
2386
- }
2387
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2388
- className
2389
- }, /* @__PURE__ */ React26__namespace.createElement(DefaultError2, {
2390
- error
2391
- }));
2392
- }
2393
- if (!isConnected) {
2394
- console.log("[RequireConnection] Rendering: Disconnected/Loading");
2395
- if (disconnectedContent) {
2396
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2397
- className
2398
- }, disconnectedContent);
2399
- }
2400
- if (loadingContent) {
2401
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2402
- className
2403
- }, loadingContent);
2404
- }
2405
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2406
- className
2407
- }, /* @__PURE__ */ React26__namespace.createElement(DefaultDisconnected, null));
2408
- }
2409
- console.log("[RequireConnection] Rendering: Children (Connected)");
2410
- return /* @__PURE__ */ React26__namespace.createElement(React26__namespace.Fragment, null, children);
2411
- }
2412
- chunk2HRO6CFU_js.__name(RequireConnection, "RequireConnection");
2413
- function DefaultFallback({ error, onRetry }) {
2414
- return /* @__PURE__ */ React26__namespace.createElement(Alert, {
2415
- variant: "destructive"
2416
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.AlertCircle, {
2417
- className: "h-4 w-4"
2418
- }), /* @__PURE__ */ React26__namespace.createElement(AlertTitle, null, "Something went wrong"), /* @__PURE__ */ React26__namespace.createElement(AlertDescription, {
2419
- className: "flex flex-col gap-3"
2420
- }, /* @__PURE__ */ React26__namespace.createElement("p", {
2421
- className: "text-sm"
2422
- }, error.message), /* @__PURE__ */ React26__namespace.createElement(Button, {
2423
- variant: "outline",
2424
- size: "sm",
2425
- onClick: onRetry,
2426
- className: "w-fit"
2427
- }, /* @__PURE__ */ React26__namespace.createElement(lucideReact.RefreshCw, {
2428
- className: "h-4 w-4 mr-2"
2429
- }), "Try Again")));
2430
- }
2431
- chunk2HRO6CFU_js.__name(DefaultFallback, "DefaultFallback");
2432
- var ToolErrorBoundary = class extends React26.Component {
2433
- static {
2434
- chunk2HRO6CFU_js.__name(this, "ToolErrorBoundary");
2435
- }
2436
- constructor(props) {
2437
- super(props);
2438
- this.state = {
2439
- hasError: false,
2440
- error: null
2441
- };
2442
- }
2443
- static getDerivedStateFromError(error) {
2444
- return {
2445
- hasError: true,
2446
- error
2447
- };
2448
- }
2449
- componentDidCatch(error, errorInfo) {
2450
- this.props.onError?.(error, errorInfo);
2451
- }
2452
- componentDidUpdate(prevProps) {
2453
- if (this.state.hasError && this.props.resetKeys && prevProps.resetKeys && this.props.resetKeys.some((key, index) => key !== prevProps.resetKeys?.[index])) {
2454
- this.reset();
2455
- }
2456
- }
2457
- reset = /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => {
2458
- this.setState({
2459
- hasError: false,
2460
- error: null
2461
- });
2462
- }, "reset");
2463
- render() {
2464
- const { hasError, error } = this.state;
2465
- const { fallback, children } = this.props;
2466
- if (hasError && error) {
2467
- if (fallback) {
2468
- if (typeof fallback === "function") {
2469
- return fallback(error, this.reset);
2470
- }
2471
- return fallback;
2472
- }
2473
- return /* @__PURE__ */ React26__namespace.createElement(DefaultFallback, {
2474
- error,
2475
- onRetry: this.reset
2476
- });
2477
- }
2478
- return children;
2479
- }
2480
- };
2481
- function useMessage() {
2482
- const { sendMessage: appSendMessage, isConnected } = useMcpApp();
2483
- const [sending, setSending] = React26.useState(false);
2484
- const [error, setError] = React26.useState(null);
2485
- const send = React26.useCallback(async (text) => {
2486
- if (!isConnected) {
2487
- console.warn("[useMessage] Not connected to host");
2488
- return;
2489
- }
2490
- setSending(true);
2491
- setError(null);
2492
- try {
2493
- await appSendMessage(text);
2494
- } catch (err) {
2495
- const error2 = err instanceof Error ? err : new Error(String(err));
2496
- setError(error2);
2497
- throw error2;
2498
- } finally {
2499
- setSending(false);
2500
- }
2501
- }, [
2502
- appSendMessage,
2503
- isConnected
2504
- ]);
2505
- const sendContent = React26.useCallback(async (content) => {
2506
- if (!isConnected) {
2507
- console.warn("[useMessage] Not connected to host");
2508
- return;
2509
- }
2510
- setSending(true);
2511
- setError(null);
2512
- try {
2513
- const textContent = content.filter((c) => c.type === "text").map((c) => c.text).join("\n");
2514
- await appSendMessage(textContent);
2515
- } catch (err) {
2516
- const error2 = err instanceof Error ? err : new Error(String(err));
2517
- setError(error2);
2518
- throw error2;
2519
- } finally {
2520
- setSending(false);
2521
- }
2522
- }, [
2523
- appSendMessage,
2524
- isConnected
2525
- ]);
2526
- const requestTool = React26.useCallback(async (toolName, args) => {
2527
- let message = `Please call the "${toolName}" tool`;
2528
- if (args && Object.keys(args).length > 0) {
2529
- message += ` with arguments: ${JSON.stringify(args)}`;
2530
- }
2531
- await send(message);
2532
- }, [
2533
- send
2534
- ]);
2535
- return {
2536
- send,
2537
- sendContent,
2538
- requestTool,
2539
- sending,
2540
- error
2541
- };
2542
- }
2543
- chunk2HRO6CFU_js.__name(useMessage, "useMessage");
2544
-
2545
- // src/mcp/useHostContext.ts
2546
- function useHostContext() {
2547
- const { hostContext } = useMcpApp();
2548
- return {
2549
- theme: hostContext.theme ?? "light",
2550
- displayMode: hostContext.displayMode ?? "inline",
2551
- availableDisplayModes: hostContext.availableDisplayModes ?? [],
2552
- viewport: hostContext.viewport ?? null,
2553
- locale: hostContext.locale ?? null,
2554
- timeZone: hostContext.timeZone ?? null,
2555
- platform: hostContext.platform ?? null,
2556
- userAgent: hostContext.userAgent ?? null,
2557
- deviceCapabilities: hostContext.deviceCapabilities ?? null,
2558
- safeAreaInsets: hostContext.safeAreaInsets ?? null,
2559
- styles: hostContext.styles ?? null,
2560
- rawContext: hostContext
2561
- };
2562
- }
2563
- chunk2HRO6CFU_js.__name(useHostContext, "useHostContext");
2564
-
2565
- // src/mcp/useToolResult.ts
2566
- function useToolResult() {
2567
- const { toolResult } = useMcpApp();
2568
- let result = null;
2569
- let textContent = null;
2570
- if (toolResult) {
2571
- if ("structuredContent" in toolResult && toolResult.structuredContent) {
2572
- result = toolResult.structuredContent;
2573
- }
2574
- if (!result && toolResult.content) {
2575
- const textItem = toolResult.content.find((c) => c.type === "text");
2576
- if (textItem) {
2577
- textContent = textItem.text;
2578
- try {
2579
- result = JSON.parse(textItem.text);
2580
- } catch {
2581
- }
2582
- }
2583
- }
2584
- }
2585
- return {
2586
- result,
2587
- rawResult: toolResult,
2588
- hasResult: toolResult !== null,
2589
- textContent
2590
- };
2591
- }
2592
- chunk2HRO6CFU_js.__name(useToolResult, "useToolResult");
2593
-
2594
- // src/mcp/useToolInput.ts
2595
- function useToolInput() {
2596
- const { toolInput } = useMcpApp();
2597
- return {
2598
- input: toolInput,
2599
- hasInput: toolInput !== null
2600
- };
2601
- }
2602
- chunk2HRO6CFU_js.__name(useToolInput, "useToolInput");
2603
-
2604
- // src/mcp/useToolInputPartial.ts
2605
- function useToolInputPartial() {
2606
- const { toolInputPartial } = useMcpApp();
2607
- return {
2608
- partialArgs: toolInputPartial,
2609
- isStreaming: toolInputPartial !== null
2610
- };
2611
- }
2612
- chunk2HRO6CFU_js.__name(useToolInputPartial, "useToolInputPartial");
2613
- function useToolSubscription(toolName, options = {}) {
2614
- const { interval = 1e4, enabled = true, args = {} } = options;
2615
- const toolHook = useTool(toolName);
2616
- const intervalRef = React26.useRef(null);
2617
- const [isPolling, setIsPolling] = React26.useState(false);
2618
- const stop = React26.useCallback(() => {
2619
- if (intervalRef.current) {
2620
- clearInterval(intervalRef.current);
2621
- intervalRef.current = null;
2622
- }
2623
- setIsPolling(false);
2624
- }, []);
2625
- const start = React26.useCallback(() => {
2626
- if (intervalRef.current) {
2627
- clearInterval(intervalRef.current);
2628
- intervalRef.current = null;
2629
- }
2630
- setIsPolling(true);
2631
- toolHook.call(args).catch(() => {
2632
- });
2633
- intervalRef.current = setInterval(() => {
2634
- toolHook.call(args).catch(() => {
2635
- });
2636
- }, interval);
2637
- }, [
2638
- toolHook.call,
2639
- args,
2640
- interval
2641
- ]);
2642
- const refresh = React26.useCallback(async () => {
2643
- return toolHook.call(args);
2644
- }, [
2645
- toolHook.call,
2646
- args
2647
- ]);
2648
- React26.useEffect(() => {
2649
- if (enabled) {
2650
- start();
2651
- }
2652
- return () => stop();
2653
- }, [
2654
- enabled,
2655
- start,
2656
- stop
2657
- ]);
2658
- return {
2659
- result: toolHook.result,
2660
- loading: toolHook.loading,
2661
- error: toolHook.error,
2662
- start,
2663
- stop,
2664
- isPolling,
2665
- refresh
2666
- };
2667
- }
2668
- chunk2HRO6CFU_js.__name(useToolSubscription, "useToolSubscription");
2669
- function useAuth() {
2670
- const { callTool, isConnected } = useGptApp();
2671
- const [isAuthenticated, setIsAuthenticated] = React26.useState(false);
2672
- const [user, setUser] = React26.useState(null);
2673
- const [loading, setLoading] = React26.useState(false);
2674
- const [error, setError] = React26.useState(null);
2675
- const checkAuthStatus = React26.useCallback(async () => {
2676
- if (!isConnected) return;
2677
- try {
2678
- const result = await callTool("getAuthStatus", {});
2679
- if (result && result.user) {
2680
- setIsAuthenticated(true);
2681
- setUser(result.user);
2682
- } else {
2683
- setIsAuthenticated(false);
2684
- setUser(null);
2685
- }
2686
- } catch (err) {
2687
- setIsAuthenticated(false);
2688
- setUser(null);
2689
- }
2690
- }, [
2691
- callTool,
2692
- isConnected
2693
- ]);
2694
- const triggerAuth = React26.useCallback(async () => {
2695
- if (!isConnected) {
2696
- setError(new Error("Not connected to ChatGPT"));
2697
- return;
2698
- }
2699
- setLoading(true);
2700
- setError(null);
2701
- try {
2702
- const result = await callTool("checkAuth", {});
2703
- if (result && result.user) {
2704
- setIsAuthenticated(true);
2705
- setUser(result.user);
2706
- } else if (result && result.success) {
2707
- setIsAuthenticated(true);
2708
- await checkAuthStatus();
2709
- }
2710
- } catch (err) {
2711
- setError(err);
2712
- } finally {
2713
- setLoading(false);
2714
- }
2715
- }, [
2716
- callTool,
2717
- isConnected,
2718
- checkAuthStatus
2719
- ]);
2720
- const clearAuth = React26.useCallback(() => {
2721
- setIsAuthenticated(false);
2722
- setUser(null);
2723
- setError(null);
2724
- }, []);
2725
- React26.useEffect(() => {
2726
- if (isConnected) {
2727
- checkAuthStatus().catch(() => {
2728
- });
2729
- }
2730
- }, [
2731
- isConnected,
2732
- checkAuthStatus
2733
- ]);
2734
- return {
2735
- isAuthenticated,
2736
- user,
2737
- loading,
2738
- error,
2739
- triggerAuth,
2740
- clearAuth
2741
- };
2742
- }
2743
- chunk2HRO6CFU_js.__name(useAuth, "useAuth");
2744
- var SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
2745
- function useOpenAiGlobal(key) {
2746
- return React26.useSyncExternalStore((onChange) => {
2747
- const handleSetGlobal = /* @__PURE__ */ chunk2HRO6CFU_js.__name((event) => {
2748
- const customEvent = event;
2749
- const value = customEvent.detail?.globals?.[key];
2750
- if (value !== void 0) {
2751
- onChange();
2752
- }
2753
- }, "handleSetGlobal");
2754
- window.addEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal, {
2755
- passive: true
2756
- });
2757
- return () => {
2758
- window.removeEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal);
2759
- };
2760
- }, () => window.openai?.[key]);
2761
- }
2762
- chunk2HRO6CFU_js.__name(useOpenAiGlobal, "useOpenAiGlobal");
2763
-
2764
- // src/mcp/useToolData.ts
2765
- function useToolOutput() {
2766
- return useOpenAiGlobal("toolOutput");
2767
- }
2768
- chunk2HRO6CFU_js.__name(useToolOutput, "useToolOutput");
2769
- function useToolResponseMetadata() {
2770
- return useOpenAiGlobal("toolResponseMetadata");
2771
- }
2772
- chunk2HRO6CFU_js.__name(useToolResponseMetadata, "useToolResponseMetadata");
2773
- function useToolInput2() {
2774
- return useOpenAiGlobal("toolInput");
2775
- }
2776
- chunk2HRO6CFU_js.__name(useToolInput2, "useToolInput");
2777
- function useWidgetState(initialState) {
2778
- const rawState = useOpenAiGlobal("widgetState");
2779
- const resolvedInitial = rawState ?? (typeof initialState === "function" ? initialState() : initialState);
2780
- const setWidgetState = React26.useCallback((newStateOrUpdater) => {
2781
- if (!window.openai?.setWidgetState) {
2782
- console.warn("window.openai.setWidgetState is not available");
2783
- return;
2784
- }
2785
- const current = window.openai.widgetState ?? resolvedInitial;
2786
- const next = typeof newStateOrUpdater === "function" ? newStateOrUpdater(current) : newStateOrUpdater;
2787
- window.openai.setWidgetState(next);
2788
- }, [
2789
- resolvedInitial
2790
- ]);
2791
- return [
2792
- resolvedInitial,
2793
- setWidgetState
2794
- ];
2795
- }
2796
- chunk2HRO6CFU_js.__name(useWidgetState, "useWidgetState");
2797
-
2798
- // src/types/mcp-types.ts
2799
- function normalizeToolBinding(tool) {
2800
- if (typeof tool === "string") {
2801
- return {
2802
- name: tool
2803
- };
2804
- }
2805
- return tool;
2806
- }
2807
- chunk2HRO6CFU_js.__name(normalizeToolBinding, "normalizeToolBinding");
2808
- var DEFAULT_RESULT_CONFIG = {
2809
- display: "none",
2810
- autoDismiss: 5e3
2811
- };
2812
- var INITIAL_TOOL_STATE = {
2813
- state: "idle",
2814
- loading: false,
2815
- result: null,
2816
- error: null,
2817
- hasResult: false
2818
- };
2819
- function CardTitle({ className, ...props }) {
2820
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2821
- "data-slot": "card-title",
2822
- className: cn("leading-none font-semibold", className),
2823
- ...props
2824
- });
2825
- }
2826
- chunk2HRO6CFU_js.__name(CardTitle, "CardTitle");
2827
- function CardDescription({ className, ...props }) {
2828
- return /* @__PURE__ */ React26__namespace.createElement("div", {
2829
- "data-slot": "card-description",
2830
- className: cn("text-muted-foreground text-sm", className),
2831
- ...props
2832
- });
2833
- }
2834
- chunk2HRO6CFU_js.__name(CardDescription, "CardDescription");
2835
- var Form = reactHookForm.FormProvider;
2836
- var FormFieldContext = /* @__PURE__ */ React26__namespace.createContext({});
2837
- var FormField = /* @__PURE__ */ chunk2HRO6CFU_js.__name(({ ...props }) => {
2838
- return /* @__PURE__ */ React26__namespace.createElement(FormFieldContext.Provider, {
2839
- value: {
2840
- name: props.name
2841
- }
2842
- }, /* @__PURE__ */ React26__namespace.createElement(reactHookForm.Controller, props));
2843
- }, "FormField");
2844
- var useFormField = /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => {
2845
- const fieldContext = React26__namespace.useContext(FormFieldContext);
2846
- const itemContext = React26__namespace.useContext(FormItemContext);
2847
- const { getFieldState } = reactHookForm.useFormContext();
2848
- const formState = reactHookForm.useFormState({
2849
- name: fieldContext.name
2850
- });
2851
- const fieldState = getFieldState(fieldContext.name, formState);
2852
- if (!fieldContext) {
2853
- throw new Error("useFormField should be used within <FormField>");
2854
- }
2855
- const { id } = itemContext;
2856
- return {
2857
- id,
2858
- name: fieldContext.name,
2859
- formItemId: `${id}-form-item`,
2860
- formDescriptionId: `${id}-form-item-description`,
2861
- formMessageId: `${id}-form-item-message`,
2862
- ...fieldState
2863
- };
2864
- }, "useFormField");
2865
- var FormItemContext = /* @__PURE__ */ React26__namespace.createContext({});
2866
- function FormItem({ className, ...props }) {
2867
- const id = React26__namespace.useId();
2868
- return /* @__PURE__ */ React26__namespace.createElement(FormItemContext.Provider, {
2869
- value: {
2870
- id
2871
- }
2872
- }, /* @__PURE__ */ React26__namespace.createElement("div", {
2873
- "data-slot": "form-item",
2874
- className: cn("grid gap-2", className),
2875
- ...props
2876
- }));
2877
- }
2878
- chunk2HRO6CFU_js.__name(FormItem, "FormItem");
2879
- function FormLabel({ className, ...props }) {
2880
- const { error, formItemId } = useFormField();
2881
- return /* @__PURE__ */ React26__namespace.createElement(Label2, {
2882
- "data-slot": "form-label",
2883
- "data-error": !!error,
2884
- className: cn("data-[error=true]:text-destructive", className),
2885
- htmlFor: formItemId,
2886
- ...props
2887
- });
2888
- }
2889
- chunk2HRO6CFU_js.__name(FormLabel, "FormLabel");
2890
- function FormControl({ ...props }) {
2891
- const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
2892
- return /* @__PURE__ */ React26__namespace.createElement(reactSlot.Slot, {
2893
- "data-slot": "form-control",
2894
- id: formItemId,
2895
- "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
2896
- "aria-invalid": !!error,
2897
- ...props
2898
- });
2899
- }
2900
- chunk2HRO6CFU_js.__name(FormControl, "FormControl");
2901
- function FormDescription({ className, ...props }) {
2902
- const { formDescriptionId } = useFormField();
2903
- return /* @__PURE__ */ React26__namespace.createElement("p", {
2904
- "data-slot": "form-description",
2905
- id: formDescriptionId,
2906
- className: cn("text-muted-foreground text-sm", className),
2907
- ...props
2908
- });
2909
- }
2910
- chunk2HRO6CFU_js.__name(FormDescription, "FormDescription");
2911
- function FormMessage({ className, ...props }) {
2912
- const { error, formMessageId } = useFormField();
2913
- const body = error ? String(error?.message ?? "") : props.children;
2914
- if (!body) {
2915
- return null;
2916
- }
2917
- return /* @__PURE__ */ React26__namespace.createElement("p", {
2918
- "data-slot": "form-message",
2919
- id: formMessageId,
2920
- className: cn("text-destructive text-sm", className),
2921
- ...props
2922
- }, body);
2923
- }
2924
- chunk2HRO6CFU_js.__name(FormMessage, "FormMessage");
2925
- var badgeVariants = classVarianceAuthority.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>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-[color,box-shadow] overflow-hidden", {
2926
- variants: {
2927
- variant: {
2928
- default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
2929
- secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
2930
- destructive: "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
2931
- outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"
2932
- }
2933
- },
2934
- defaultVariants: {
2935
- variant: "default"
2936
- }
2937
- });
2938
- function Badge({ className, variant, asChild = false, ...props }) {
2939
- const Comp = asChild ? reactSlot.Slot : "span";
2940
- return /* @__PURE__ */ React26__namespace.createElement(Comp, {
2941
- "data-slot": "badge",
2942
- className: cn(badgeVariants({
2943
- variant
2944
- }), className),
2945
- ...props
2946
- });
2947
- }
2948
- chunk2HRO6CFU_js.__name(Badge, "Badge");
2949
- function TabsList({ className, ...props }) {
2950
- return /* @__PURE__ */ React26__namespace.createElement(TabsPrimitive2__namespace.List, {
2951
- "data-slot": "tabs-list",
2952
- className: cn("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]", className),
2953
- ...props
2954
- });
2955
- }
2956
- chunk2HRO6CFU_js.__name(TabsList, "TabsList");
2957
- function TabsTrigger({ className, ...props }) {
2958
- return /* @__PURE__ */ React26__namespace.createElement(TabsPrimitive2__namespace.Trigger, {
2959
- "data-slot": "tabs-trigger",
2960
- className: cn("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
2961
- ...props
2962
- });
2963
- }
2964
- chunk2HRO6CFU_js.__name(TabsTrigger, "TabsTrigger");
2965
- function TabsContent({ className, ...props }) {
2966
- return /* @__PURE__ */ React26__namespace.createElement(TabsPrimitive2__namespace.Content, {
2967
- "data-slot": "tabs-content",
2968
- className: cn("flex-1 outline-none", className),
2969
- ...props
2970
- });
2971
- }
2972
- chunk2HRO6CFU_js.__name(TabsContent, "TabsContent");
2973
- function Separator2({ className, orientation = "horizontal", decorative = true, ...props }) {
2974
- return /* @__PURE__ */ React26__namespace.createElement(SeparatorPrimitive__namespace.Root, {
2975
- "data-slot": "separator",
2976
- decorative,
2977
- orientation,
2978
- className: cn("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px", className),
2979
- ...props
2980
- });
2981
- }
2982
- chunk2HRO6CFU_js.__name(Separator2, "Separator");
2983
- function ScrollArea({ className, children, ...props }) {
2984
- return /* @__PURE__ */ React26__namespace.createElement(ScrollAreaPrimitive__namespace.Root, {
2985
- "data-slot": "scroll-area",
2986
- className: cn("relative", className),
2987
- ...props
2988
- }, /* @__PURE__ */ React26__namespace.createElement(ScrollAreaPrimitive__namespace.Viewport, {
2989
- "data-slot": "scroll-area-viewport",
2990
- className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"
2991
- }, children), /* @__PURE__ */ React26__namespace.createElement(ScrollBar, null), /* @__PURE__ */ React26__namespace.createElement(ScrollAreaPrimitive__namespace.Corner, null));
2992
- }
2993
- chunk2HRO6CFU_js.__name(ScrollArea, "ScrollArea");
2994
- function ScrollBar({ className, orientation = "vertical", ...props }) {
2995
- return /* @__PURE__ */ React26__namespace.createElement(ScrollAreaPrimitive__namespace.ScrollAreaScrollbar, {
2996
- "data-slot": "scroll-area-scrollbar",
2997
- orientation,
2998
- className: cn("flex touch-none p-px transition-colors select-none", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent", orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent", className),
2999
- ...props
3000
- }, /* @__PURE__ */ React26__namespace.createElement(ScrollAreaPrimitive__namespace.ScrollAreaThumb, {
3001
- "data-slot": "scroll-area-thumb",
3002
- className: "bg-border relative flex-1 rounded-full"
3003
- }));
3004
- }
3005
- chunk2HRO6CFU_js.__name(ScrollBar, "ScrollBar");
3006
- function DropdownMenu({ ...props }) {
3007
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Root, {
3008
- "data-slot": "dropdown-menu",
3009
- ...props
3010
- });
3011
- }
3012
- chunk2HRO6CFU_js.__name(DropdownMenu, "DropdownMenu");
3013
- function DropdownMenuPortal({ ...props }) {
3014
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Portal, {
3015
- "data-slot": "dropdown-menu-portal",
3016
- ...props
3017
- });
3018
- }
3019
- chunk2HRO6CFU_js.__name(DropdownMenuPortal, "DropdownMenuPortal");
3020
- function DropdownMenuTrigger({ ...props }) {
3021
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Trigger, {
3022
- "data-slot": "dropdown-menu-trigger",
3023
- ...props
3024
- });
3025
- }
3026
- chunk2HRO6CFU_js.__name(DropdownMenuTrigger, "DropdownMenuTrigger");
3027
- function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
3028
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Portal, null, /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Content, {
3029
- "data-slot": "dropdown-menu-content",
3030
- sideOffset,
3031
- className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md", className),
3032
- ...props
3033
- }));
3034
- }
3035
- chunk2HRO6CFU_js.__name(DropdownMenuContent, "DropdownMenuContent");
3036
- function DropdownMenuGroup({ ...props }) {
3037
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Group, {
3038
- "data-slot": "dropdown-menu-group",
3039
- ...props
3040
- });
3041
- }
3042
- chunk2HRO6CFU_js.__name(DropdownMenuGroup, "DropdownMenuGroup");
3043
- function DropdownMenuItem({ className, inset, variant = "default", ...props }) {
3044
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Item, {
3045
- "data-slot": "dropdown-menu-item",
3046
- "data-inset": inset,
3047
- "data-variant": variant,
3048
- className: cn("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 [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
3049
- ...props
3050
- });
3051
- }
3052
- chunk2HRO6CFU_js.__name(DropdownMenuItem, "DropdownMenuItem");
3053
- function DropdownMenuCheckboxItem({ className, children, checked, ...props }) {
3054
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.CheckboxItem, {
3055
- "data-slot": "dropdown-menu-checkbox-item",
3056
- className: cn("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
3057
- checked,
3058
- ...props
3059
- }, /* @__PURE__ */ React26__namespace.createElement("span", {
3060
- className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center"
3061
- }, /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React26__namespace.createElement(lucideReact.CheckIcon, {
3062
- className: "size-4"
3063
- }))), children);
3064
- }
3065
- chunk2HRO6CFU_js.__name(DropdownMenuCheckboxItem, "DropdownMenuCheckboxItem");
3066
- function DropdownMenuRadioGroup({ ...props }) {
3067
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.RadioGroup, {
3068
- "data-slot": "dropdown-menu-radio-group",
3069
- ...props
3070
- });
3071
- }
3072
- chunk2HRO6CFU_js.__name(DropdownMenuRadioGroup, "DropdownMenuRadioGroup");
3073
- function DropdownMenuRadioItem({ className, children, ...props }) {
3074
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.RadioItem, {
3075
- "data-slot": "dropdown-menu-radio-item",
3076
- className: cn("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
3077
- ...props
3078
- }, /* @__PURE__ */ React26__namespace.createElement("span", {
3079
- className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center"
3080
- }, /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React26__namespace.createElement(lucideReact.CircleIcon, {
3081
- className: "size-2 fill-current"
3082
- }))), children);
3083
- }
3084
- chunk2HRO6CFU_js.__name(DropdownMenuRadioItem, "DropdownMenuRadioItem");
3085
- function DropdownMenuLabel({ className, inset, ...props }) {
3086
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Label, {
3087
- "data-slot": "dropdown-menu-label",
3088
- "data-inset": inset,
3089
- className: cn("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8", className),
3090
- ...props
3091
- });
3092
- }
3093
- chunk2HRO6CFU_js.__name(DropdownMenuLabel, "DropdownMenuLabel");
3094
- function DropdownMenuSeparator({ className, ...props }) {
3095
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Separator, {
3096
- "data-slot": "dropdown-menu-separator",
3097
- className: cn("bg-border -mx-1 my-1 h-px", className),
3098
- ...props
3099
- });
3100
- }
3101
- chunk2HRO6CFU_js.__name(DropdownMenuSeparator, "DropdownMenuSeparator");
3102
- function DropdownMenuShortcut({ className, ...props }) {
3103
- return /* @__PURE__ */ React26__namespace.createElement("span", {
3104
- "data-slot": "dropdown-menu-shortcut",
3105
- className: cn("text-muted-foreground ml-auto text-xs tracking-widest", className),
3106
- ...props
3107
- });
3108
- }
3109
- chunk2HRO6CFU_js.__name(DropdownMenuShortcut, "DropdownMenuShortcut");
3110
- function DropdownMenuSub({ ...props }) {
3111
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.Sub, {
3112
- "data-slot": "dropdown-menu-sub",
3113
- ...props
3114
- });
3115
- }
3116
- chunk2HRO6CFU_js.__name(DropdownMenuSub, "DropdownMenuSub");
3117
- function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
3118
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.SubTrigger, {
3119
- "data-slot": "dropdown-menu-sub-trigger",
3120
- "data-inset": inset,
3121
- className: cn("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
3122
- ...props
3123
- }, children, /* @__PURE__ */ React26__namespace.createElement(lucideReact.ChevronRightIcon, {
3124
- className: "ml-auto size-4"
3125
- }));
3126
- }
3127
- chunk2HRO6CFU_js.__name(DropdownMenuSubTrigger, "DropdownMenuSubTrigger");
3128
- function DropdownMenuSubContent({ className, ...props }) {
3129
- return /* @__PURE__ */ React26__namespace.createElement(DropdownMenuPrimitive__namespace.SubContent, {
3130
- "data-slot": "dropdown-menu-sub-content",
3131
- className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=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 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg", className),
3132
- ...props
3133
- });
3134
- }
3135
- chunk2HRO6CFU_js.__name(DropdownMenuSubContent, "DropdownMenuSubContent");
3136
- function TooltipProvider({ delayDuration = 0, ...props }) {
3137
- return /* @__PURE__ */ React26__namespace.createElement(TooltipPrimitive__namespace.Provider, {
3138
- "data-slot": "tooltip-provider",
3139
- delayDuration,
3140
- ...props
3141
- });
3142
- }
3143
- chunk2HRO6CFU_js.__name(TooltipProvider, "TooltipProvider");
3144
- function Tooltip({ ...props }) {
3145
- return /* @__PURE__ */ React26__namespace.createElement(TooltipProvider, null, /* @__PURE__ */ React26__namespace.createElement(TooltipPrimitive__namespace.Root, {
3146
- "data-slot": "tooltip",
3147
- ...props
3148
- }));
3149
- }
3150
- chunk2HRO6CFU_js.__name(Tooltip, "Tooltip");
3151
- function TooltipTrigger({ ...props }) {
3152
- return /* @__PURE__ */ React26__namespace.createElement(TooltipPrimitive__namespace.Trigger, {
3153
- "data-slot": "tooltip-trigger",
3154
- ...props
3155
- });
3156
- }
3157
- chunk2HRO6CFU_js.__name(TooltipTrigger, "TooltipTrigger");
3158
- function TooltipContent({ className, sideOffset = 0, children, ...props }) {
3159
- return /* @__PURE__ */ React26__namespace.createElement(TooltipPrimitive__namespace.Portal, null, /* @__PURE__ */ React26__namespace.createElement(TooltipPrimitive__namespace.Content, {
3160
- "data-slot": "tooltip-content",
3161
- sideOffset,
3162
- className: cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance", className),
3163
- ...props
3164
- }, children, /* @__PURE__ */ React26__namespace.createElement(TooltipPrimitive__namespace.Arrow, {
3165
- className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"
3166
- })));
3167
- }
3168
- chunk2HRO6CFU_js.__name(TooltipContent, "TooltipContent");
3169
- function DataGrid({ data, columns, searchable = false, searchPlaceholder = "Search...", onRowClick, loading = false, emptyMessage = "No data", className }) {
3170
- const [sorting, setSorting] = React26.useState([]);
3171
- const [globalFilter, setGlobalFilter] = React26.useState("");
3172
- const tableColumns = React26.useMemo(() => columns.map((col) => ({
3173
- id: String(col.key),
3174
- accessorKey: col.key,
3175
- header: col.header,
3176
- cell: col.cell ? ({ getValue, row }) => col.cell(getValue(), row.original) : ({ getValue }) => String(getValue() ?? ""),
3177
- enableSorting: col.sortable ?? true,
3178
- size: typeof col.width === "number" ? col.width : void 0
3179
- })), [
3180
- columns
3181
- ]);
3182
- const table = reactTable.useReactTable({
3183
- data,
3184
- columns: tableColumns,
3185
- state: {
3186
- sorting,
3187
- globalFilter
3188
- },
3189
- onSortingChange: setSorting,
3190
- onGlobalFilterChange: setGlobalFilter,
3191
- getCoreRowModel: reactTable.getCoreRowModel(),
3192
- getSortedRowModel: reactTable.getSortedRowModel(),
3193
- getFilteredRowModel: reactTable.getFilteredRowModel()
3194
- });
3195
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
3196
- className: clsx.clsx("lui-datagrid", className)
3197
- }, searchable && /* @__PURE__ */ React26__namespace.default.createElement("div", {
3198
- className: "lui-datagrid-search"
3199
- }, /* @__PURE__ */ React26__namespace.default.createElement("input", {
3200
- type: "text",
3201
- value: globalFilter,
3202
- onChange: /* @__PURE__ */ chunk2HRO6CFU_js.__name((e) => setGlobalFilter(e.target.value), "onChange"),
3203
- placeholder: searchPlaceholder,
3204
- className: "lui-datagrid-search-input"
3205
- })), /* @__PURE__ */ React26__namespace.default.createElement("div", {
3206
- className: "lui-datagrid-container"
3207
- }, /* @__PURE__ */ React26__namespace.default.createElement("table", {
3208
- className: "lui-datagrid-table"
3209
- }, /* @__PURE__ */ React26__namespace.default.createElement("thead", null, table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ React26__namespace.default.createElement("tr", {
3210
- key: headerGroup.id
3211
- }, headerGroup.headers.map((header) => /* @__PURE__ */ React26__namespace.default.createElement("th", {
3212
- key: header.id,
3213
- className: clsx.clsx("lui-datagrid-th", header.column.getCanSort() && "lui-datagrid-th--sortable"),
3214
- onClick: header.column.getToggleSortingHandler(),
3215
- style: {
3216
- width: header.column.getSize()
3217
- }
3218
- }, /* @__PURE__ */ React26__namespace.default.createElement("div", {
3219
- className: "lui-datagrid-th-content"
3220
- }, reactTable.flexRender(header.column.columnDef.header, header.getContext()), header.column.getIsSorted() && /* @__PURE__ */ React26__namespace.default.createElement("span", {
3221
- className: "lui-datagrid-sort-icon"
3222
- }, header.column.getIsSorted() === "asc" ? "\u2191" : "\u2193"))))))), /* @__PURE__ */ React26__namespace.default.createElement("tbody", null, loading ? /* @__PURE__ */ React26__namespace.default.createElement("tr", null, /* @__PURE__ */ React26__namespace.default.createElement("td", {
3223
- colSpan: columns.length,
3224
- className: "lui-datagrid-loading"
3225
- }, "Loading...")) : table.getRowModel().rows.length === 0 ? /* @__PURE__ */ React26__namespace.default.createElement("tr", null, /* @__PURE__ */ React26__namespace.default.createElement("td", {
3226
- colSpan: columns.length,
3227
- className: "lui-datagrid-empty"
3228
- }, emptyMessage)) : table.getRowModel().rows.map((row) => /* @__PURE__ */ React26__namespace.default.createElement("tr", {
3229
- key: row.id,
3230
- className: clsx.clsx("lui-datagrid-row", onRowClick && "lui-datagrid-row--clickable"),
3231
- onClick: /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => onRowClick?.(row.original), "onClick")
3232
- }, row.getVisibleCells().map((cell) => /* @__PURE__ */ React26__namespace.default.createElement("td", {
3233
- key: cell.id,
3234
- className: "lui-datagrid-td"
3235
- }, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())))))))));
3236
- }
3237
- chunk2HRO6CFU_js.__name(DataGrid, "DataGrid");
3238
- chart_js.Chart.register(chart_js.CategoryScale, chart_js.LinearScale, chart_js.PointElement, chart_js.LineElement, chart_js.BarElement, chart_js.ArcElement, chart_js.Title, chart_js.Tooltip, chart_js.Legend);
3239
- function Chart({ type, data, options, height = 300, width = "100%", className }) {
3240
- const defaultOptions = {
3241
- responsive: true,
3242
- maintainAspectRatio: false,
3243
- plugins: {
3244
- legend: {
3245
- display: true,
3246
- position: "top",
3247
- labels: {
3248
- usePointStyle: true,
3249
- padding: 16
3250
- }
3251
- },
3252
- tooltip: {
3253
- mode: "index",
3254
- intersect: false,
3255
- backgroundColor: "rgba(15, 23, 42, 0.9)",
3256
- titleColor: "#f1f5f9",
3257
- bodyColor: "#cbd5e1",
3258
- borderColor: "#334155",
3259
- borderWidth: 1,
3260
- cornerRadius: 8,
3261
- padding: 12
3262
- }
3263
- },
3264
- scales: type !== "pie" && type !== "doughnut" ? {
3265
- x: {
3266
- grid: {
3267
- color: "rgba(226, 232, 240, 0.5)"
3268
- },
3269
- ticks: {
3270
- color: "#64748b"
3271
- }
3272
- },
3273
- y: {
3274
- grid: {
3275
- color: "rgba(226, 232, 240, 0.5)"
3276
- },
3277
- ticks: {
3278
- color: "#64748b"
3279
- }
3280
- }
3281
- } : void 0
3282
- };
3283
- const mergedOptions = {
3284
- ...defaultOptions,
3285
- ...options,
3286
- plugins: {
3287
- ...defaultOptions.plugins,
3288
- ...options?.plugins
3289
- }
3290
- };
3291
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
3292
- className: clsx.clsx("lui-chart", className),
3293
- style: {
3294
- height,
3295
- width
3296
- }
3297
- }, /* @__PURE__ */ React26__namespace.default.createElement(reactChartjs2.Chart, {
3298
- type,
3299
- data,
3300
- options: mergedOptions
3301
- }));
3302
- }
3303
- chunk2HRO6CFU_js.__name(Chart, "Chart");
3304
- function AppShell({ header, sidebar, footer, sidebarPosition = "left", sidebarWidth = 240, autoResize = true, padding = "md", className, children, ...props }) {
3305
- const containerRef = React26.useRef(null);
3306
- const { app } = useMcpApp();
3307
- React26.useEffect(() => {
3308
- if (!autoResize || !containerRef.current) return;
3309
- if (!app) return;
3310
- let lastWidth = 0;
3311
- let lastHeight = 0;
3312
- let scheduled = false;
3313
- const sendSizeChanged = /* @__PURE__ */ chunk2HRO6CFU_js.__name(() => {
3314
- if (scheduled) return;
3315
- scheduled = true;
3316
- requestAnimationFrame(() => {
3317
- scheduled = false;
3318
- if (!containerRef.current) return;
3319
- const rect = containerRef.current.getBoundingClientRect();
3320
- const width = Math.ceil(rect.width);
3321
- const height = Math.ceil(rect.height);
3322
- if (width !== lastWidth || height !== lastHeight) {
3323
- lastWidth = width;
3324
- lastHeight = height;
3325
- app.sendSizeChanged({
3326
- width,
3327
- height
3328
- });
3329
- }
3330
- });
3331
- }, "sendSizeChanged");
3332
- const resizeObserver = new ResizeObserver(sendSizeChanged);
3333
- resizeObserver.observe(containerRef.current);
3334
- sendSizeChanged();
3335
- return () => {
3336
- resizeObserver.disconnect();
3337
- };
3338
- }, [
3339
- autoResize,
3340
- app
3341
- ]);
3342
- const sidebarStyle = {
3343
- width: typeof sidebarWidth === "number" ? `${sidebarWidth}px` : sidebarWidth,
3344
- flexShrink: 0
3345
- };
3346
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
3347
- ref: containerRef,
3348
- className: clsx.clsx("lui-app-shell", `lui-app-shell--padding-${padding}`, className),
3349
- ...props
3350
- }, header && /* @__PURE__ */ React26__namespace.default.createElement("header", {
3351
- className: "lui-app-shell-header"
3352
- }, header), /* @__PURE__ */ React26__namespace.default.createElement("div", {
3353
- className: "lui-app-shell-body"
3354
- }, sidebar && sidebarPosition === "left" && /* @__PURE__ */ React26__namespace.default.createElement("aside", {
3355
- className: "lui-app-shell-sidebar",
3356
- style: sidebarStyle
3357
- }, sidebar), /* @__PURE__ */ React26__namespace.default.createElement("main", {
3358
- className: "lui-app-shell-main"
3359
- }, children), sidebar && sidebarPosition === "right" && /* @__PURE__ */ React26__namespace.default.createElement("aside", {
3360
- className: "lui-app-shell-sidebar",
3361
- style: sidebarStyle
3362
- }, sidebar)), footer && /* @__PURE__ */ React26__namespace.default.createElement("footer", {
3363
- className: "lui-app-shell-footer"
3364
- }, footer));
3365
- }
3366
- chunk2HRO6CFU_js.__name(AppShell, "AppShell");
3367
- function Tabs2({ tabs, defaultValue, value, onValueChange, children, className }) {
3368
- const defaultTab = defaultValue || tabs[0]?.value;
3369
- return /* @__PURE__ */ React26__namespace.default.createElement(TabsPrimitive2__namespace.Root, {
3370
- className: clsx.clsx("lui-tabs", className),
3371
- defaultValue: defaultTab,
3372
- value,
3373
- onValueChange
3374
- }, /* @__PURE__ */ React26__namespace.default.createElement(TabsPrimitive2__namespace.List, {
3375
- className: "lui-tabs-list"
3376
- }, tabs.map((tab) => /* @__PURE__ */ React26__namespace.default.createElement(TabsPrimitive2__namespace.Trigger, {
3377
- key: tab.value,
3378
- value: tab.value,
3379
- disabled: tab.disabled,
3380
- className: "lui-tabs-trigger"
3381
- }, tab.label))), children);
3382
- }
3383
- chunk2HRO6CFU_js.__name(Tabs2, "Tabs");
3384
- function TabContent({ value, children, className }) {
3385
- return /* @__PURE__ */ React26__namespace.default.createElement(TabsPrimitive2__namespace.Content, {
3386
- value,
3387
- className: clsx.clsx("lui-tabs-content", className)
3388
- }, children);
3389
- }
3390
- chunk2HRO6CFU_js.__name(TabContent, "TabContent");
3391
- function Modal({ open, defaultOpen, onOpenChange, title, description, children, className, trigger }) {
3392
- return /* @__PURE__ */ React26__namespace.default.createElement(DialogPrimitive__namespace.Root, {
3393
- open,
3394
- defaultOpen,
3395
- onOpenChange
3396
- }, trigger && /* @__PURE__ */ React26__namespace.default.createElement(DialogPrimitive__namespace.Trigger, {
3397
- asChild: true
3398
- }, trigger), /* @__PURE__ */ React26__namespace.default.createElement(DialogPrimitive__namespace.Portal, null, /* @__PURE__ */ React26__namespace.default.createElement(DialogPrimitive__namespace.Overlay, {
3399
- className: "lui-modal-overlay"
3400
- }), /* @__PURE__ */ React26__namespace.default.createElement(DialogPrimitive__namespace.Content, {
3401
- className: clsx.clsx("lui-modal-content", className)
3402
- }, title && /* @__PURE__ */ React26__namespace.default.createElement(DialogPrimitive__namespace.Title, {
3403
- className: "lui-modal-title"
3404
- }, title), description && /* @__PURE__ */ React26__namespace.default.createElement(DialogPrimitive__namespace.Description, {
3405
- className: "lui-modal-description"
3406
- }, description), children, /* @__PURE__ */ React26__namespace.default.createElement(DialogPrimitive__namespace.Close, {
3407
- className: "lui-modal-close",
3408
- "aria-label": "Close"
3409
- }, /* @__PURE__ */ React26__namespace.default.createElement(CloseIcon, null)))));
3410
- }
3411
- chunk2HRO6CFU_js.__name(Modal, "Modal");
3412
- function CloseIcon() {
3413
- return /* @__PURE__ */ React26__namespace.default.createElement("svg", {
3414
- width: "14",
3415
- height: "14",
3416
- viewBox: "0 0 14 14",
3417
- fill: "none"
3418
- }, /* @__PURE__ */ React26__namespace.default.createElement("path", {
3419
- d: "M3.5 3.5L10.5 10.5M10.5 3.5L3.5 10.5",
3420
- stroke: "currentColor",
3421
- strokeWidth: "1.5",
3422
- strokeLinecap: "round"
3423
- }));
3424
- }
3425
- chunk2HRO6CFU_js.__name(CloseIcon, "CloseIcon");
3426
- function CodeBlock({ code, language = "text", showLineNumbers = false, copyable = true, className }) {
3427
- const [copied, setCopied] = React26__namespace.default.useState(false);
3428
- const handleCopy = /* @__PURE__ */ chunk2HRO6CFU_js.__name(async () => {
3429
- await navigator.clipboard.writeText(code);
3430
- setCopied(true);
3431
- setTimeout(() => setCopied(false), 2e3);
3432
- }, "handleCopy");
3433
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
3434
- className: clsx.clsx("lui-code-block", className)
3435
- }, copyable && /* @__PURE__ */ React26__namespace.default.createElement("button", {
3436
- type: "button",
3437
- className: "lui-code-block-copy",
3438
- onClick: handleCopy,
3439
- "aria-label": copied ? "Copied!" : "Copy code"
3440
- }, copied ? /* @__PURE__ */ React26__namespace.default.createElement("svg", {
3441
- viewBox: "0 0 24 24",
3442
- fill: "none",
3443
- stroke: "currentColor",
3444
- strokeWidth: "2"
3445
- }, /* @__PURE__ */ React26__namespace.default.createElement("polyline", {
3446
- points: "20,6 9,17 4,12"
3447
- })) : /* @__PURE__ */ React26__namespace.default.createElement("svg", {
3448
- viewBox: "0 0 24 24",
3449
- fill: "none",
3450
- stroke: "currentColor",
3451
- strokeWidth: "2"
3452
- }, /* @__PURE__ */ React26__namespace.default.createElement("rect", {
3453
- x: "9",
3454
- y: "9",
3455
- width: "13",
3456
- height: "13",
3457
- rx: "2",
3458
- ry: "2"
3459
- }), /* @__PURE__ */ React26__namespace.default.createElement("path", {
3460
- d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"
3461
- }))), /* @__PURE__ */ React26__namespace.default.createElement(prismReactRenderer.Highlight, {
3462
- theme: prismReactRenderer.themes.nightOwl,
3463
- code: code.trim(),
3464
- language
3465
- }, ({ className: hlClassName, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ React26__namespace.default.createElement("pre", {
3466
- className: clsx.clsx("lui-code-block-pre", hlClassName),
3467
- style
3468
- }, tokens.map((line, i) => /* @__PURE__ */ React26__namespace.default.createElement("div", {
3469
- key: i,
3470
- ...getLineProps({
3471
- line
3472
- })
3473
- }, showLineNumbers && /* @__PURE__ */ React26__namespace.default.createElement("span", {
3474
- className: "lui-code-block-line-number"
3475
- }, i + 1), line.map((token, key) => /* @__PURE__ */ React26__namespace.default.createElement("span", {
3476
- key,
3477
- ...getTokenProps({
3478
- token
3479
- })
3480
- })))))));
3481
- }
3482
- chunk2HRO6CFU_js.__name(CodeBlock, "CodeBlock");
3483
- var Card2 = /* @__PURE__ */ React26.forwardRef(({ className, variant = "default", padding = "md", interactive = false, children, ...props }, ref) => {
3484
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
3485
- ref,
3486
- className: clsx.clsx("lui-card", `lui-card--${variant}`, `lui-card--padding-${padding}`, interactive && "lui-card--interactive", className),
3487
- ...props
3488
- }, children);
3489
- });
3490
- Card2.displayName = "Card";
3491
- var CardHeader2 = /* @__PURE__ */ React26.forwardRef(({ className, title, description, action, children, ...props }, ref) => {
3492
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
3493
- ref,
3494
- className: clsx.clsx("lui-card-header", className),
3495
- ...props
3496
- }, (title || description) && /* @__PURE__ */ React26__namespace.default.createElement("div", {
3497
- className: "lui-card-header__text"
3498
- }, title && /* @__PURE__ */ React26__namespace.default.createElement("h3", {
3499
- className: "lui-card-header__title"
3500
- }, title), description && /* @__PURE__ */ React26__namespace.default.createElement("p", {
3501
- className: "lui-card-header__description"
3502
- }, description)), action && /* @__PURE__ */ React26__namespace.default.createElement("div", {
3503
- className: "lui-card-header__action"
3504
- }, action), children);
3505
- });
3506
- CardHeader2.displayName = "CardHeader";
3507
- var CardContent2 = /* @__PURE__ */ React26.forwardRef(({ className, children, ...props }, ref) => {
3508
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
3509
- ref,
3510
- className: clsx.clsx("lui-card-content", className),
3511
- ...props
3512
- }, children);
3513
- });
3514
- CardContent2.displayName = "CardContent";
3515
- var CardFooter2 = /* @__PURE__ */ React26.forwardRef(({ className, children, ...props }, ref) => {
3516
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
3517
- ref,
3518
- className: clsx.clsx("lui-card-footer", className),
3519
- ...props
3520
- }, children);
3521
- });
3522
- CardFooter2.displayName = "CardFooter";
3523
- var Input2 = /* @__PURE__ */ React26.forwardRef(({ className, label, helperText, error, size = "md", leftElement, rightElement, fullWidth = false, id, ...props }, ref) => {
3524
- const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
3525
- const hasError = Boolean(error);
3526
- return /* @__PURE__ */ React26__namespace.default.createElement("div", {
3527
- className: clsx.clsx("lui-input-wrapper", fullWidth && "lui-input-wrapper--full-width", className)
3528
- }, label && /* @__PURE__ */ React26__namespace.default.createElement("label", {
3529
- htmlFor: inputId,
3530
- className: "lui-input-label"
3531
- }, label), /* @__PURE__ */ React26__namespace.default.createElement("div", {
3532
- className: clsx.clsx("lui-input-container", `lui-input-container--${size}`, hasError && "lui-input-container--error", leftElement && "lui-input-container--has-left", rightElement && "lui-input-container--has-right")
3533
- }, leftElement && /* @__PURE__ */ React26__namespace.default.createElement("span", {
3534
- className: "lui-input-element lui-input-element--left"
3535
- }, leftElement), /* @__PURE__ */ React26__namespace.default.createElement("input", {
3536
- ref,
3537
- id: inputId,
3538
- className: "lui-input",
3539
- "aria-invalid": hasError,
3540
- "aria-describedby": error ? `${inputId}-error` : helperText ? `${inputId}-helper` : void 0,
3541
- ...props
3542
- }), rightElement && /* @__PURE__ */ React26__namespace.default.createElement("span", {
3543
- className: "lui-input-element lui-input-element--right"
3544
- }, rightElement)), (error || helperText) && /* @__PURE__ */ React26__namespace.default.createElement("p", {
3545
- id: error ? `${inputId}-error` : `${inputId}-helper`,
3546
- className: clsx.clsx("lui-input-message", error && "lui-input-message--error")
3547
- }, error || helperText));
3548
- });
3549
- Input2.displayName = "Input";
3550
-
3551
- Object.defineProperty(exports, "GPTApp", {
3552
- enumerable: true,
3553
- get: function () { return chunk2HRO6CFU_js.GPTApp; }
3554
- });
3555
- Object.defineProperty(exports, "UIApp", {
3556
- enumerable: true,
3557
- get: function () { return chunk2HRO6CFU_js.UIApp; }
3558
- });
3559
- Object.defineProperty(exports, "getGPTAppMetadata", {
3560
- enumerable: true,
3561
- get: function () { return chunk2HRO6CFU_js.getGPTAppMetadata; }
3562
- });
3563
- Object.defineProperty(exports, "getGPTAppUri", {
3564
- enumerable: true,
3565
- get: function () { return chunk2HRO6CFU_js.getGPTAppUri; }
3566
- });
3567
- Object.defineProperty(exports, "getUIAppMetadata", {
3568
- enumerable: true,
3569
- get: function () { return chunk2HRO6CFU_js.getUIAppMetadata; }
3570
- });
3571
- Object.defineProperty(exports, "getUIAppUri", {
3572
- enumerable: true,
3573
- get: function () { return chunk2HRO6CFU_js.getUIAppUri; }
3574
- });
3575
- Object.defineProperty(exports, "App", {
3576
- enumerable: true,
3577
- get: function () { return extApps.App; }
3578
- });
3579
- Object.defineProperty(exports, "PostMessageTransport", {
3580
- enumerable: true,
3581
- get: function () { return extApps.PostMessageTransport; }
3582
- });
3583
- Object.defineProperty(exports, "RESOURCE_MIME_TYPE", {
3584
- enumerable: true,
3585
- get: function () { return extApps.RESOURCE_MIME_TYPE; }
3586
- });
3587
- Object.defineProperty(exports, "RESOURCE_URI_META_KEY", {
3588
- enumerable: true,
3589
- get: function () { return extApps.RESOURCE_URI_META_KEY; }
3590
- });
3591
- Object.defineProperty(exports, "applyDocumentTheme", {
3592
- enumerable: true,
3593
- get: function () { return extApps.applyDocumentTheme; }
3594
- });
3595
- Object.defineProperty(exports, "applyHostFonts", {
3596
- enumerable: true,
3597
- get: function () { return extApps.applyHostFonts; }
3598
- });
3599
- Object.defineProperty(exports, "applyHostStyleVariables", {
3600
- enumerable: true,
3601
- get: function () { return extApps.applyHostStyleVariables; }
3602
- });
3603
- Object.defineProperty(exports, "getDocumentTheme", {
3604
- enumerable: true,
3605
- get: function () { return extApps.getDocumentTheme; }
3606
- });
3607
- Object.defineProperty(exports, "AppBridge", {
3608
- enumerable: true,
3609
- get: function () { return appBridge.AppBridge; }
3610
- });
3611
- exports.ActionButton = ActionButton;
3612
- exports.Alert = Alert;
3613
- exports.AlertDescription = AlertDescription;
3614
- exports.AlertTitle = AlertTitle;
3615
- exports.AppProvider = AppProvider;
3616
- exports.AppShell = AppShell;
3617
- exports.Badge = Badge;
3618
- exports.Button = Button2;
3619
- exports.Card = Card2;
3620
- exports.CardContent = CardContent2;
3621
- exports.CardDescription = CardDescription;
3622
- exports.CardFooter = CardFooter2;
3623
- exports.CardHeader = CardHeader2;
3624
- exports.CardTitle = CardTitle;
3625
- exports.Chart = Chart;
3626
- exports.Checkbox = Checkbox;
3627
- exports.CodeBlock = CodeBlock;
3628
- exports.Command = Command;
3629
- exports.CommandDialog = CommandDialog;
3630
- exports.CommandEmpty = CommandEmpty;
3631
- exports.CommandGroup = CommandGroup;
3632
- exports.CommandInput = CommandInput;
3633
- exports.CommandItem = CommandItem;
3634
- exports.CommandList = CommandList;
3635
- exports.CommandSeparator = CommandSeparator;
3636
- exports.CommandShortcut = CommandShortcut;
3637
- exports.DEFAULT_RESULT_CONFIG = DEFAULT_RESULT_CONFIG;
3638
- exports.DataGrid = DataGrid;
3639
- exports.Dialog = Dialog;
3640
- exports.DialogClose = DialogClose;
3641
- exports.DialogContent = DialogContent;
3642
- exports.DialogDescription = DialogDescription;
3643
- exports.DialogFooter = DialogFooter;
3644
- exports.DialogHeader = DialogHeader;
3645
- exports.DialogOverlay = DialogOverlay;
3646
- exports.DialogPortal = DialogPortal;
3647
- exports.DialogTitle = DialogTitle;
3648
- exports.DialogTrigger = DialogTrigger;
3649
- exports.DropdownMenu = DropdownMenu;
3650
- exports.DropdownMenuCheckboxItem = DropdownMenuCheckboxItem;
3651
- exports.DropdownMenuContent = DropdownMenuContent;
3652
- exports.DropdownMenuGroup = DropdownMenuGroup;
3653
- exports.DropdownMenuItem = DropdownMenuItem;
3654
- exports.DropdownMenuLabel = DropdownMenuLabel;
3655
- exports.DropdownMenuPortal = DropdownMenuPortal;
3656
- exports.DropdownMenuRadioGroup = DropdownMenuRadioGroup;
3657
- exports.DropdownMenuRadioItem = DropdownMenuRadioItem;
3658
- exports.DropdownMenuSeparator = DropdownMenuSeparator;
3659
- exports.DropdownMenuShortcut = DropdownMenuShortcut;
3660
- exports.DropdownMenuSub = DropdownMenuSub;
3661
- exports.DropdownMenuSubContent = DropdownMenuSubContent;
3662
- exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
3663
- exports.DropdownMenuTrigger = DropdownMenuTrigger;
3664
- exports.Form = Form;
3665
- exports.FormControl = FormControl;
3666
- exports.FormDescription = FormDescription;
3667
- exports.FormField = FormField;
3668
- exports.FormItem = FormItem;
3669
- exports.FormLabel = FormLabel;
3670
- exports.FormMessage = FormMessage;
3671
- exports.GPTAppProvider = GPTAppProvider;
3672
- exports.INITIAL_TOOL_STATE = INITIAL_TOOL_STATE;
3673
- exports.Input = Input2;
3674
- exports.Label = Label2;
3675
- exports.Modal = Modal;
3676
- exports.Popover = Popover;
3677
- exports.PopoverAnchor = PopoverAnchor;
3678
- exports.PopoverContent = PopoverContent;
3679
- exports.PopoverTrigger = PopoverTrigger;
3680
- exports.Progress = Progress;
3681
- exports.RequireConnection = RequireConnection;
3682
- exports.ResourceView = ResourceView;
3683
- exports.ScrollArea = ScrollArea;
3684
- exports.ScrollBar = ScrollBar;
3685
- exports.Select = Select;
3686
- exports.SelectContent = SelectContent;
3687
- exports.SelectGroup = SelectGroup;
3688
- exports.SelectItem = SelectItem;
3689
- exports.SelectLabel = SelectLabel;
3690
- exports.SelectScrollDownButton = SelectScrollDownButton;
3691
- exports.SelectScrollUpButton = SelectScrollUpButton;
3692
- exports.SelectSeparator = SelectSeparator;
3693
- exports.SelectTrigger = SelectTrigger;
3694
- exports.SelectValue = SelectValue;
3695
- exports.Separator = Separator2;
3696
- exports.Skeleton = Skeleton;
3697
- exports.Slider = Slider;
3698
- exports.StreamingContent = StreamingContent;
3699
- exports.Switch = Switch;
3700
- exports.TabContent = TabContent;
3701
- exports.Table = Table;
3702
- exports.TableBody = TableBody;
3703
- exports.TableCaption = TableCaption;
3704
- exports.TableCell = TableCell;
3705
- exports.TableFooter = TableFooter;
3706
- exports.TableHead = TableHead;
3707
- exports.TableHeader = TableHeader;
3708
- exports.TableRow = TableRow;
3709
- exports.Tabs = Tabs2;
3710
- exports.TabsContent = TabsContent;
3711
- exports.TabsList = TabsList;
3712
- exports.TabsTrigger = TabsTrigger;
3713
- exports.Textarea = Textarea;
3714
- exports.Toaster = Toaster;
3715
- exports.ToolButton = ToolButton;
3716
- exports.ToolDataGrid = ToolDataGrid;
3717
- exports.ToolErrorBoundary = ToolErrorBoundary;
3718
- exports.ToolForm = ToolForm;
3719
- exports.ToolInput = ToolInput;
3720
- exports.ToolProvider = ToolProvider;
3721
- exports.ToolSelect = ToolSelect;
3722
- exports.Tooltip = Tooltip;
3723
- exports.TooltipContent = TooltipContent;
3724
- exports.TooltipProvider = TooltipProvider;
3725
- exports.TooltipTrigger = TooltipTrigger;
3726
- exports.badgeVariants = badgeVariants;
3727
- exports.buttonVariants = buttonVariants;
3728
- exports.cn = cn;
3729
- exports.normalizeToolBinding = normalizeToolBinding;
3730
- exports.useAuth = useAuth;
3731
- exports.useFormField = useFormField;
3732
- exports.useGptApp = useGptApp;
3733
- exports.useGptTool = useGptTool;
3734
- exports.useHostContext = useHostContext;
3735
- exports.useMcpApp = useMcpApp;
3736
- exports.useMessage = useMessage;
3737
- exports.useOpenAiGlobal = useOpenAiGlobal;
3738
- exports.useResource = useResource;
3739
- exports.useTool = useTool;
3740
- exports.useToolContext = useToolContext;
3741
- exports.useToolInput = useToolInput;
3742
- exports.useToolInputPartial = useToolInputPartial;
3743
- exports.useToolInputSpec = useToolInput2;
3744
- exports.useToolOutput = useToolOutput;
3745
- exports.useToolResponseMetadata = useToolResponseMetadata;
3746
- exports.useToolResult = useToolResult;
3747
- exports.useToolStream = useToolStream;
3748
- exports.useToolSubscription = useToolSubscription;
3749
- exports.useWidgetState = useWidgetState;
3750
- //# sourceMappingURL=index.js.map
3751
- //# sourceMappingURL=index.js.map