@krak-stack/registry 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/components/ui/alert.d.ts +10 -0
- package/dist/components/ui/bubble.d.ts +16 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/empty.d.ts +11 -0
- package/dist/components/ui/marker.d.ts +10 -0
- package/dist/components/ui/message-scroller.d.ts +10 -0
- package/dist/components/ui/message.d.ts +10 -0
- package/dist/lib/docs-ai.d.ts +136 -0
- package/dist/lib/docs-ai.js +310 -0
- package/dist/lib/docs-core.d.ts +681 -0
- package/dist/lib/docs-core.js +2571 -0
- package/dist/lib/httpapi-ai.d.ts +54 -0
- package/dist/lib/httpapi-ai.js +361 -0
- package/dist/lib/httpapi-cli.d.ts +22 -0
- package/dist/lib/httpapi-cli.js +412 -0
- package/dist/lib/httpapi-client.d.ts +20 -0
- package/dist/lib/httpapi-client.js +50 -0
- package/dist/lib/httpapi-helpers.d.ts +105 -0
- package/dist/lib/httpapi-helpers.js +237 -0
- package/dist/lib/httpapi-mcp.d.ts +20 -0
- package/dist/lib/httpapi-mcp.js +366 -0
- package/dist/lib/query.js +128 -0
- package/dist/services/agent/client/atom.d.ts +56 -0
- package/dist/services/agent/client/index.d.ts +2 -0
- package/dist/services/agent/client/index.js +2239 -0
- package/dist/services/agent/client/widget.d.ts +52 -0
- package/dist/services/agent/index.d.ts +111 -0
- package/dist/services/agent/index.js +190 -0
- package/dist/services/agent/schema.d.ts +161 -0
- package/dist/services/agent/schema.js +135 -0
- package/package.json +58 -2
|
@@ -0,0 +1,2239 @@
|
|
|
1
|
+
// ../../src/services/agent/client/atom.ts
|
|
2
|
+
import { Effect, Layer, Stream } from "effect";
|
|
3
|
+
import { Atom } from "effect/unstable/reactivity";
|
|
4
|
+
var initialAgentState = {
|
|
5
|
+
context: undefined,
|
|
6
|
+
contextLocked: false,
|
|
7
|
+
messages: [],
|
|
8
|
+
pending: false
|
|
9
|
+
};
|
|
10
|
+
var updateTool = (messages, toolCallId, update) => messages.map((message) => ({
|
|
11
|
+
...message,
|
|
12
|
+
tools: message.tools.map((tool) => tool.toolCallId === toolCallId ? update(tool) : tool)
|
|
13
|
+
}));
|
|
14
|
+
var failAgentState = (state, error) => {
|
|
15
|
+
const lastMessage = state.messages.at(-1);
|
|
16
|
+
const messages = lastMessage?.role === "assistant" && !lastMessage.text && lastMessage.tools.length === 0 ? state.messages.slice(0, -1) : state.messages;
|
|
17
|
+
return { ...state, messages, error };
|
|
18
|
+
};
|
|
19
|
+
var reduceAgentEvent = (state, event) => {
|
|
20
|
+
switch (event.type) {
|
|
21
|
+
case "message-start":
|
|
22
|
+
return {
|
|
23
|
+
...state,
|
|
24
|
+
messages: [
|
|
25
|
+
...state.messages,
|
|
26
|
+
{ id: event.messageId, role: "assistant", text: "", tools: [] }
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
case "tool-call":
|
|
30
|
+
return {
|
|
31
|
+
...state,
|
|
32
|
+
messages: state.messages.map((message) => message.id === event.messageId ? {
|
|
33
|
+
...message,
|
|
34
|
+
tools: [...message.tools, { ...event, status: "running" }]
|
|
35
|
+
} : message)
|
|
36
|
+
};
|
|
37
|
+
case "tool-result":
|
|
38
|
+
return {
|
|
39
|
+
...state,
|
|
40
|
+
messages: updateTool(state.messages, event.toolCallId, (tool) => ({
|
|
41
|
+
...tool,
|
|
42
|
+
status: event.isFailure ? "failed" : "completed"
|
|
43
|
+
}))
|
|
44
|
+
};
|
|
45
|
+
case "approval-required":
|
|
46
|
+
return {
|
|
47
|
+
...state,
|
|
48
|
+
messages: updateTool(state.messages, event.toolCallId, (tool) => ({
|
|
49
|
+
...tool,
|
|
50
|
+
approvalId: event.approvalId,
|
|
51
|
+
status: "approval-required"
|
|
52
|
+
}))
|
|
53
|
+
};
|
|
54
|
+
case "text-delta":
|
|
55
|
+
return {
|
|
56
|
+
...state,
|
|
57
|
+
messages: state.messages.map((message) => message.id === event.messageId ? { ...message, text: message.text + event.delta } : message)
|
|
58
|
+
};
|
|
59
|
+
case "history":
|
|
60
|
+
return { ...state, history: event.value };
|
|
61
|
+
case "error":
|
|
62
|
+
return failAgentState(state, event.code);
|
|
63
|
+
case "finish":
|
|
64
|
+
return state;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var defaultErrorCode = (error) => {
|
|
68
|
+
if (error && typeof error === "object") {
|
|
69
|
+
const code = Reflect.get(error, "code");
|
|
70
|
+
if (code === "stream-failed" || code === "unavailable")
|
|
71
|
+
return code;
|
|
72
|
+
}
|
|
73
|
+
return "unavailable";
|
|
74
|
+
};
|
|
75
|
+
var makeAgentAtoms = ({
|
|
76
|
+
errorCode = defaultErrorCode,
|
|
77
|
+
reactivityKeys,
|
|
78
|
+
runtime = Atom.runtime(Layer.empty),
|
|
79
|
+
stream
|
|
80
|
+
}) => {
|
|
81
|
+
const state = Atom.family((_scope) => Atom.make(initialAgentState));
|
|
82
|
+
const submit = runtime.fn()((input, get) => {
|
|
83
|
+
const submitAction = input.action;
|
|
84
|
+
const stateAtom = state(input.scope);
|
|
85
|
+
const current = get(stateAtom);
|
|
86
|
+
const context = current.contextLocked ? current.context : input.context;
|
|
87
|
+
const approvalStatus = submitAction.type === "approval" ? submitAction.approved ? "approved" : "denied" : undefined;
|
|
88
|
+
const messages = submitAction.type === "message" ? [
|
|
89
|
+
...current.messages,
|
|
90
|
+
{
|
|
91
|
+
id: crypto.randomUUID(),
|
|
92
|
+
role: "user",
|
|
93
|
+
text: submitAction.text,
|
|
94
|
+
tools: []
|
|
95
|
+
}
|
|
96
|
+
] : current.messages.map((message) => ({
|
|
97
|
+
...message,
|
|
98
|
+
tools: message.tools.map((tool) => tool.toolCallId === submitAction.toolCallId ? { ...tool, status: approvalStatus ?? tool.status } : tool)
|
|
99
|
+
}));
|
|
100
|
+
get.set(stateAtom, {
|
|
101
|
+
...current,
|
|
102
|
+
context,
|
|
103
|
+
contextLocked: true,
|
|
104
|
+
messages,
|
|
105
|
+
pending: true,
|
|
106
|
+
error: undefined
|
|
107
|
+
});
|
|
108
|
+
const action = submitAction.type === "message" ? submitAction : {
|
|
109
|
+
type: submitAction.type,
|
|
110
|
+
approvalId: submitAction.approvalId,
|
|
111
|
+
approved: submitAction.approved
|
|
112
|
+
};
|
|
113
|
+
return stream(get, {
|
|
114
|
+
action,
|
|
115
|
+
context: context ? { label: context.label, resource: context.resource } : undefined,
|
|
116
|
+
history: current.history
|
|
117
|
+
}).pipe(Effect.flatMap(Stream.runForEach((event) => Effect.sync(() => get.set(stateAtom, reduceAgentEvent(get(stateAtom), event))))), Effect.catch((error) => Effect.sync(() => get.set(stateAtom, failAgentState(get(stateAtom), errorCode(error))))), Effect.ensuring(Effect.sync(() => get.set(stateAtom, { ...get(stateAtom), pending: false }))));
|
|
118
|
+
}, { reactivityKeys });
|
|
119
|
+
const reset = Atom.fnSync()((scope, get) => {
|
|
120
|
+
get.set(state(scope), initialAgentState);
|
|
121
|
+
});
|
|
122
|
+
const removeContext = Atom.fnSync()((scope, get) => {
|
|
123
|
+
const stateAtom = state(scope);
|
|
124
|
+
get.set(stateAtom, {
|
|
125
|
+
...get(stateAtom),
|
|
126
|
+
context: undefined,
|
|
127
|
+
contextLocked: true
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
return { removeContext, reset, state, submit };
|
|
131
|
+
};
|
|
132
|
+
// ../../src/services/agent/client/widget.tsx
|
|
133
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
134
|
+
import { Dialog as DialogPrimitive2 } from "@base-ui/react/dialog";
|
|
135
|
+
import { code } from "@streamdown/code";
|
|
136
|
+
import {
|
|
137
|
+
ArrowDownIcon as ArrowDownIcon2,
|
|
138
|
+
BotIcon,
|
|
139
|
+
ChevronDownIcon,
|
|
140
|
+
Maximize2Icon,
|
|
141
|
+
MessageCircleDashedIcon,
|
|
142
|
+
Minimize2Icon,
|
|
143
|
+
MinusIcon,
|
|
144
|
+
SendIcon,
|
|
145
|
+
SquareIcon,
|
|
146
|
+
XIcon as XIcon2
|
|
147
|
+
} from "lucide-react";
|
|
148
|
+
import { Streamdown } from "streamdown";
|
|
149
|
+
|
|
150
|
+
// ../../src/components/ui/alert.tsx
|
|
151
|
+
import { cva } from "class-variance-authority";
|
|
152
|
+
|
|
153
|
+
// ../../src/lib/utils.ts
|
|
154
|
+
import { clsx } from "clsx";
|
|
155
|
+
import { twMerge } from "tailwind-merge";
|
|
156
|
+
function cn(...inputs) {
|
|
157
|
+
return twMerge(clsx(inputs));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ../../src/components/ui/alert.tsx
|
|
161
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
162
|
+
var alertVariants = cva("group/alert relative grid w-full gap-0.5 rounded-lg border px-4 py-3 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4", {
|
|
163
|
+
variants: {
|
|
164
|
+
variant: {
|
|
165
|
+
default: "bg-card text-card-foreground",
|
|
166
|
+
destructive: "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
defaultVariants: {
|
|
170
|
+
variant: "default"
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
function Alert({
|
|
174
|
+
className,
|
|
175
|
+
variant,
|
|
176
|
+
...props
|
|
177
|
+
}) {
|
|
178
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
179
|
+
"data-slot": "alert",
|
|
180
|
+
role: "alert",
|
|
181
|
+
className: cn(alertVariants({ variant }), className),
|
|
182
|
+
...props
|
|
183
|
+
}, undefined, false, undefined, this);
|
|
184
|
+
}
|
|
185
|
+
function AlertTitle({ className, ...props }) {
|
|
186
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
187
|
+
"data-slot": "alert-title",
|
|
188
|
+
className: cn("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground", className),
|
|
189
|
+
...props
|
|
190
|
+
}, undefined, false, undefined, this);
|
|
191
|
+
}
|
|
192
|
+
function AlertDescription({
|
|
193
|
+
className,
|
|
194
|
+
...props
|
|
195
|
+
}) {
|
|
196
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
197
|
+
"data-slot": "alert-description",
|
|
198
|
+
className: cn("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4", className),
|
|
199
|
+
...props
|
|
200
|
+
}, undefined, false, undefined, this);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ../../src/components/ui/badge.tsx
|
|
204
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
205
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
206
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
207
|
+
var badgeVariants = cva2("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
|
|
208
|
+
variants: {
|
|
209
|
+
variant: {
|
|
210
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
211
|
+
secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
|
212
|
+
destructive: "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
|
213
|
+
outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
|
214
|
+
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
|
215
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
defaultVariants: {
|
|
219
|
+
variant: "default"
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
function Badge({
|
|
223
|
+
className,
|
|
224
|
+
variant = "default",
|
|
225
|
+
render,
|
|
226
|
+
...props
|
|
227
|
+
}) {
|
|
228
|
+
return useRender({
|
|
229
|
+
defaultTagName: "span",
|
|
230
|
+
props: mergeProps({
|
|
231
|
+
className: cn(badgeVariants({ variant }), className)
|
|
232
|
+
}, props),
|
|
233
|
+
render,
|
|
234
|
+
state: {
|
|
235
|
+
slot: "badge",
|
|
236
|
+
variant
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ../../src/components/ui/bubble.tsx
|
|
242
|
+
import { mergeProps as mergeProps2 } from "@base-ui/react/merge-props";
|
|
243
|
+
import { useRender as useRender2 } from "@base-ui/react/use-render";
|
|
244
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
245
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
246
|
+
var bubbleVariants = cva3("group/bubble relative flex w-fit max-w-[80%] min-w-0 flex-col gap-1 group-data-[align=end]/message:self-end data-[align=end]:self-end data-[variant=ghost]:max-w-full", {
|
|
247
|
+
variants: {
|
|
248
|
+
variant: {
|
|
249
|
+
default: "*:data-[slot=bubble-content]:bg-primary *:data-[slot=bubble-content]:text-primary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-primary/80",
|
|
250
|
+
secondary: "*:data-[slot=bubble-content]:bg-secondary *:data-[slot=bubble-content]:text-secondary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]",
|
|
251
|
+
muted: "*:data-[slot=bubble-content]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--muted),var(--foreground)_5%)]",
|
|
252
|
+
tinted: "*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.93_calc(c*0.4)_h)] *:data-[slot=bubble-content]:text-foreground dark:*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.3_calc(c*0.4)_h)] [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.88_calc(c*0.5)_h)] dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.35_calc(c*0.5)_h)]",
|
|
253
|
+
outline: "*:data-[slot=bubble-content]:border-border *:data-[slot=bubble-content]:bg-background [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-input/30",
|
|
254
|
+
ghost: "border-none *:data-[slot=bubble-content]:rounded-none *:data-[slot=bubble-content]:bg-transparent *:data-[slot=bubble-content]:p-0 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted/50",
|
|
255
|
+
destructive: "*:data-[slot=bubble-content]:bg-destructive/10 *:data-[slot=bubble-content]:text-destructive dark:*:data-[slot=bubble-content]:bg-destructive/20 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/20 dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/30"
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
defaultVariants: {
|
|
259
|
+
variant: "default"
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
function Bubble({
|
|
263
|
+
variant = "default",
|
|
264
|
+
align = "start",
|
|
265
|
+
className,
|
|
266
|
+
...props
|
|
267
|
+
}) {
|
|
268
|
+
return /* @__PURE__ */ jsxDEV2("div", {
|
|
269
|
+
"data-slot": "bubble",
|
|
270
|
+
"data-variant": variant,
|
|
271
|
+
"data-align": align,
|
|
272
|
+
className: cn(bubbleVariants({ variant }), className),
|
|
273
|
+
...props
|
|
274
|
+
}, undefined, false, undefined, this);
|
|
275
|
+
}
|
|
276
|
+
function BubbleContent({
|
|
277
|
+
className,
|
|
278
|
+
render,
|
|
279
|
+
...props
|
|
280
|
+
}) {
|
|
281
|
+
return useRender2({
|
|
282
|
+
defaultTagName: "div",
|
|
283
|
+
props: mergeProps2({
|
|
284
|
+
className: cn("w-fit max-w-full min-w-0 overflow-hidden rounded-xl border border-transparent px-3 py-2 text-sm leading-relaxed wrap-break-word group-data-[align=end]/bubble:self-end [button]:text-left [button,a]:transition-colors [button,a]:outline-none [button,a]:focus-visible:border-ring [button,a]:focus-visible:ring-3 [button,a]:focus-visible:ring-ring/50", className)
|
|
285
|
+
}, props),
|
|
286
|
+
render,
|
|
287
|
+
state: {
|
|
288
|
+
slot: "bubble-content"
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
var bubbleReactionsVariants = cva3("absolute z-10 flex w-fit shrink-0 items-center justify-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-sm ring-3 ring-card has-[button]:p-0", {
|
|
293
|
+
variants: {
|
|
294
|
+
side: {
|
|
295
|
+
top: "top-0 -translate-y-3/4",
|
|
296
|
+
bottom: "bottom-0 translate-y-3/4"
|
|
297
|
+
},
|
|
298
|
+
align: {
|
|
299
|
+
start: "left-3",
|
|
300
|
+
end: "right-3"
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
defaultVariants: {
|
|
304
|
+
side: "bottom",
|
|
305
|
+
align: "end"
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// ../../src/components/ui/button.tsx
|
|
310
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
311
|
+
import { cva as cva4 } from "class-variance-authority";
|
|
312
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
313
|
+
var buttonVariants = cva4("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
314
|
+
variants: {
|
|
315
|
+
variant: {
|
|
316
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
317
|
+
outline: "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
318
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
319
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
320
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
321
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
322
|
+
},
|
|
323
|
+
size: {
|
|
324
|
+
default: "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
325
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
326
|
+
sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
|
|
327
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
328
|
+
icon: "size-9",
|
|
329
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
330
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
331
|
+
"icon-lg": "size-10"
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
defaultVariants: {
|
|
335
|
+
variant: "default",
|
|
336
|
+
size: "default"
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
function Button({
|
|
340
|
+
className,
|
|
341
|
+
variant = "default",
|
|
342
|
+
size = "default",
|
|
343
|
+
...props
|
|
344
|
+
}) {
|
|
345
|
+
return /* @__PURE__ */ jsxDEV3(ButtonPrimitive, {
|
|
346
|
+
"data-slot": "button",
|
|
347
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
348
|
+
...props
|
|
349
|
+
}, undefined, false, undefined, this);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// ../../src/components/ui/card.tsx
|
|
353
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
354
|
+
function Card({
|
|
355
|
+
className,
|
|
356
|
+
size = "default",
|
|
357
|
+
...props
|
|
358
|
+
}) {
|
|
359
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
360
|
+
"data-slot": "card",
|
|
361
|
+
"data-size": size,
|
|
362
|
+
className: cn("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 [--card-spacing:--spacing(6)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl", className),
|
|
363
|
+
...props
|
|
364
|
+
}, undefined, false, undefined, this);
|
|
365
|
+
}
|
|
366
|
+
function CardHeader({ className, ...props }) {
|
|
367
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
368
|
+
"data-slot": "card-header",
|
|
369
|
+
className: cn("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)", className),
|
|
370
|
+
...props
|
|
371
|
+
}, undefined, false, undefined, this);
|
|
372
|
+
}
|
|
373
|
+
function CardTitle({ className, ...props }) {
|
|
374
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
375
|
+
"data-slot": "card-title",
|
|
376
|
+
className: cn("text-base leading-normal font-medium group-data-[size=sm]/card:text-sm", className),
|
|
377
|
+
...props
|
|
378
|
+
}, undefined, false, undefined, this);
|
|
379
|
+
}
|
|
380
|
+
function CardDescription({ className, ...props }) {
|
|
381
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
382
|
+
"data-slot": "card-description",
|
|
383
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
384
|
+
...props
|
|
385
|
+
}, undefined, false, undefined, this);
|
|
386
|
+
}
|
|
387
|
+
function CardContent({ className, ...props }) {
|
|
388
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
389
|
+
"data-slot": "card-content",
|
|
390
|
+
className: cn("px-(--card-spacing)", className),
|
|
391
|
+
...props
|
|
392
|
+
}, undefined, false, undefined, this);
|
|
393
|
+
}
|
|
394
|
+
function CardFooter({ className, ...props }) {
|
|
395
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
396
|
+
"data-slot": "card-footer",
|
|
397
|
+
className: cn("flex items-center rounded-b-xl px-(--card-spacing) [.border-t]:pt-(--card-spacing)", className),
|
|
398
|
+
...props
|
|
399
|
+
}, undefined, false, undefined, this);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// ../../src/components/ui/collapsible.tsx
|
|
403
|
+
import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
|
|
404
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
405
|
+
function Collapsible({ ...props }) {
|
|
406
|
+
return /* @__PURE__ */ jsxDEV5(CollapsiblePrimitive.Root, {
|
|
407
|
+
"data-slot": "collapsible",
|
|
408
|
+
...props
|
|
409
|
+
}, undefined, false, undefined, this);
|
|
410
|
+
}
|
|
411
|
+
function CollapsibleTrigger({ ...props }) {
|
|
412
|
+
return /* @__PURE__ */ jsxDEV5(CollapsiblePrimitive.Trigger, {
|
|
413
|
+
"data-slot": "collapsible-trigger",
|
|
414
|
+
...props
|
|
415
|
+
}, undefined, false, undefined, this);
|
|
416
|
+
}
|
|
417
|
+
function CollapsibleContent({ ...props }) {
|
|
418
|
+
return /* @__PURE__ */ jsxDEV5(CollapsiblePrimitive.Panel, {
|
|
419
|
+
"data-slot": "collapsible-content",
|
|
420
|
+
...props
|
|
421
|
+
}, undefined, false, undefined, this);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// ../../src/components/ui/command.tsx
|
|
425
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
426
|
+
import { SearchIcon } from "lucide-react";
|
|
427
|
+
|
|
428
|
+
// ../../src/components/ui/dialog.tsx
|
|
429
|
+
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
430
|
+
import { XIcon } from "lucide-react";
|
|
431
|
+
import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
|
|
432
|
+
function Dialog({ ...props }) {
|
|
433
|
+
return /* @__PURE__ */ jsxDEV6(DialogPrimitive.Root, {
|
|
434
|
+
"data-slot": "dialog",
|
|
435
|
+
...props
|
|
436
|
+
}, undefined, false, undefined, this);
|
|
437
|
+
}
|
|
438
|
+
function DialogTrigger({ ...props }) {
|
|
439
|
+
return /* @__PURE__ */ jsxDEV6(DialogPrimitive.Trigger, {
|
|
440
|
+
"data-slot": "dialog-trigger",
|
|
441
|
+
...props
|
|
442
|
+
}, undefined, false, undefined, this);
|
|
443
|
+
}
|
|
444
|
+
function DialogPortal({ ...props }) {
|
|
445
|
+
return /* @__PURE__ */ jsxDEV6(DialogPrimitive.Portal, {
|
|
446
|
+
"data-slot": "dialog-portal",
|
|
447
|
+
...props
|
|
448
|
+
}, undefined, false, undefined, this);
|
|
449
|
+
}
|
|
450
|
+
function DialogClose({ ...props }) {
|
|
451
|
+
return /* @__PURE__ */ jsxDEV6(DialogPrimitive.Close, {
|
|
452
|
+
"data-slot": "dialog-close",
|
|
453
|
+
...props
|
|
454
|
+
}, undefined, false, undefined, this);
|
|
455
|
+
}
|
|
456
|
+
function DialogHeader({ className, ...props }) {
|
|
457
|
+
return /* @__PURE__ */ jsxDEV6("div", {
|
|
458
|
+
"data-slot": "dialog-header",
|
|
459
|
+
className: cn("grid gap-1.5", className),
|
|
460
|
+
...props
|
|
461
|
+
}, undefined, false, undefined, this);
|
|
462
|
+
}
|
|
463
|
+
function DialogTitle({
|
|
464
|
+
className,
|
|
465
|
+
...props
|
|
466
|
+
}) {
|
|
467
|
+
return /* @__PURE__ */ jsxDEV6(DialogPrimitive.Title, {
|
|
468
|
+
"data-slot": "dialog-title",
|
|
469
|
+
className: cn("text-lg font-medium", className),
|
|
470
|
+
...props
|
|
471
|
+
}, undefined, false, undefined, this);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// ../../src/components/ui/command.tsx
|
|
475
|
+
import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
|
|
476
|
+
function Command({
|
|
477
|
+
className,
|
|
478
|
+
...props
|
|
479
|
+
}) {
|
|
480
|
+
return /* @__PURE__ */ jsxDEV7(CommandPrimitive, {
|
|
481
|
+
"data-slot": "command",
|
|
482
|
+
className: cn("flex size-full flex-col overflow-hidden rounded-xl bg-popover p-1 text-popover-foreground", className),
|
|
483
|
+
...props
|
|
484
|
+
}, undefined, false, undefined, this);
|
|
485
|
+
}
|
|
486
|
+
function CommandList({
|
|
487
|
+
className,
|
|
488
|
+
...props
|
|
489
|
+
}) {
|
|
490
|
+
return /* @__PURE__ */ jsxDEV7(CommandPrimitive.List, {
|
|
491
|
+
"data-slot": "command-list",
|
|
492
|
+
className: cn("max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none", className),
|
|
493
|
+
...props
|
|
494
|
+
}, undefined, false, undefined, this);
|
|
495
|
+
}
|
|
496
|
+
function CommandEmpty({
|
|
497
|
+
className,
|
|
498
|
+
...props
|
|
499
|
+
}) {
|
|
500
|
+
return /* @__PURE__ */ jsxDEV7(CommandPrimitive.Empty, {
|
|
501
|
+
"data-slot": "command-empty",
|
|
502
|
+
className: cn("py-6 text-center text-sm", className),
|
|
503
|
+
...props
|
|
504
|
+
}, undefined, false, undefined, this);
|
|
505
|
+
}
|
|
506
|
+
function CommandGroup({
|
|
507
|
+
className,
|
|
508
|
+
...props
|
|
509
|
+
}) {
|
|
510
|
+
return /* @__PURE__ */ jsxDEV7(CommandPrimitive.Group, {
|
|
511
|
+
"data-slot": "command-group",
|
|
512
|
+
className: cn("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground", className),
|
|
513
|
+
...props
|
|
514
|
+
}, undefined, false, undefined, this);
|
|
515
|
+
}
|
|
516
|
+
function CommandItem({
|
|
517
|
+
className,
|
|
518
|
+
...props
|
|
519
|
+
}) {
|
|
520
|
+
return /* @__PURE__ */ jsxDEV7(CommandPrimitive.Item, {
|
|
521
|
+
"data-slot": "command-item",
|
|
522
|
+
className: cn("group/command-item relative flex cursor-default items-center gap-2 rounded-lg px-2 py-1.5 text-sm outline-none select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
523
|
+
...props
|
|
524
|
+
}, undefined, false, undefined, this);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// ../../src/components/ui/empty.tsx
|
|
528
|
+
import { cva as cva5 } from "class-variance-authority";
|
|
529
|
+
import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
|
|
530
|
+
function Empty({ className, ...props }) {
|
|
531
|
+
return /* @__PURE__ */ jsxDEV8("div", {
|
|
532
|
+
"data-slot": "empty",
|
|
533
|
+
className: cn("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-lg border-dashed p-12 text-center text-balance", className),
|
|
534
|
+
...props
|
|
535
|
+
}, undefined, false, undefined, this);
|
|
536
|
+
}
|
|
537
|
+
function EmptyHeader({ className, ...props }) {
|
|
538
|
+
return /* @__PURE__ */ jsxDEV8("div", {
|
|
539
|
+
"data-slot": "empty-header",
|
|
540
|
+
className: cn("flex max-w-sm flex-col items-center gap-2", className),
|
|
541
|
+
...props
|
|
542
|
+
}, undefined, false, undefined, this);
|
|
543
|
+
}
|
|
544
|
+
var emptyMediaVariants = cva5("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0", {
|
|
545
|
+
variants: {
|
|
546
|
+
variant: {
|
|
547
|
+
default: "bg-transparent",
|
|
548
|
+
icon: "flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-6"
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
defaultVariants: {
|
|
552
|
+
variant: "default"
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
function EmptyMedia({
|
|
556
|
+
className,
|
|
557
|
+
variant = "default",
|
|
558
|
+
...props
|
|
559
|
+
}) {
|
|
560
|
+
return /* @__PURE__ */ jsxDEV8("div", {
|
|
561
|
+
"data-slot": "empty-icon",
|
|
562
|
+
"data-variant": variant,
|
|
563
|
+
className: cn(emptyMediaVariants({ variant, className })),
|
|
564
|
+
...props
|
|
565
|
+
}, undefined, false, undefined, this);
|
|
566
|
+
}
|
|
567
|
+
function EmptyTitle({ className, ...props }) {
|
|
568
|
+
return /* @__PURE__ */ jsxDEV8("div", {
|
|
569
|
+
"data-slot": "empty-title",
|
|
570
|
+
className: cn("text-lg font-medium tracking-tight", className),
|
|
571
|
+
...props
|
|
572
|
+
}, undefined, false, undefined, this);
|
|
573
|
+
}
|
|
574
|
+
function EmptyDescription({ className, ...props }) {
|
|
575
|
+
return /* @__PURE__ */ jsxDEV8("div", {
|
|
576
|
+
"data-slot": "empty-description",
|
|
577
|
+
className: cn("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", className),
|
|
578
|
+
...props
|
|
579
|
+
}, undefined, false, undefined, this);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// ../../src/components/ui/input-group.tsx
|
|
583
|
+
import { cva as cva6 } from "class-variance-authority";
|
|
584
|
+
|
|
585
|
+
// ../../src/components/ui/input.tsx
|
|
586
|
+
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
587
|
+
import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
|
|
588
|
+
|
|
589
|
+
// ../../src/components/ui/textarea.tsx
|
|
590
|
+
import { jsxDEV as jsxDEV10 } from "react/jsx-dev-runtime";
|
|
591
|
+
function Textarea({ className, ...props }) {
|
|
592
|
+
return /* @__PURE__ */ jsxDEV10("textarea", {
|
|
593
|
+
"data-slot": "textarea",
|
|
594
|
+
className: cn("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
|
|
595
|
+
...props
|
|
596
|
+
}, undefined, false, undefined, this);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// ../../src/components/ui/input-group.tsx
|
|
600
|
+
import { jsxDEV as jsxDEV11 } from "react/jsx-dev-runtime";
|
|
601
|
+
function InputGroup({ className, ...props }) {
|
|
602
|
+
return /* @__PURE__ */ jsxDEV11("div", {
|
|
603
|
+
"data-slot": "input-group",
|
|
604
|
+
role: "group",
|
|
605
|
+
className: cn("group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5", className),
|
|
606
|
+
...props
|
|
607
|
+
}, undefined, false, undefined, this);
|
|
608
|
+
}
|
|
609
|
+
var inputGroupAddonVariants = cva6("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
|
|
610
|
+
variants: {
|
|
611
|
+
align: {
|
|
612
|
+
"inline-start": "order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]",
|
|
613
|
+
"inline-end": "order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]",
|
|
614
|
+
"block-start": "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
|
|
615
|
+
"block-end": "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
defaultVariants: { align: "inline-start" }
|
|
619
|
+
});
|
|
620
|
+
function InputGroupAddon({
|
|
621
|
+
className,
|
|
622
|
+
align = "inline-start",
|
|
623
|
+
...props
|
|
624
|
+
}) {
|
|
625
|
+
return /* @__PURE__ */ jsxDEV11("div", {
|
|
626
|
+
role: "group",
|
|
627
|
+
"data-slot": "input-group-addon",
|
|
628
|
+
"data-align": align,
|
|
629
|
+
className: cn(inputGroupAddonVariants({ align }), className),
|
|
630
|
+
onClick: (event) => {
|
|
631
|
+
if (event.target.closest("button"))
|
|
632
|
+
return;
|
|
633
|
+
event.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
634
|
+
},
|
|
635
|
+
...props
|
|
636
|
+
}, undefined, false, undefined, this);
|
|
637
|
+
}
|
|
638
|
+
var inputGroupButtonVariants = cva6("flex items-center gap-2 text-sm shadow-none", {
|
|
639
|
+
variants: {
|
|
640
|
+
size: {
|
|
641
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
|
642
|
+
sm: "",
|
|
643
|
+
"icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
644
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0"
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
defaultVariants: { size: "xs" }
|
|
648
|
+
});
|
|
649
|
+
function InputGroupButton({
|
|
650
|
+
className,
|
|
651
|
+
type = "button",
|
|
652
|
+
variant = "ghost",
|
|
653
|
+
size = "xs",
|
|
654
|
+
...props
|
|
655
|
+
}) {
|
|
656
|
+
return /* @__PURE__ */ jsxDEV11(Button, {
|
|
657
|
+
type,
|
|
658
|
+
"data-size": size,
|
|
659
|
+
variant,
|
|
660
|
+
className: cn(inputGroupButtonVariants({ size }), className),
|
|
661
|
+
...props
|
|
662
|
+
}, undefined, false, undefined, this);
|
|
663
|
+
}
|
|
664
|
+
function InputGroupTextarea({
|
|
665
|
+
className,
|
|
666
|
+
...props
|
|
667
|
+
}) {
|
|
668
|
+
return /* @__PURE__ */ jsxDEV11(Textarea, {
|
|
669
|
+
"data-slot": "input-group-control",
|
|
670
|
+
className: cn("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent", className),
|
|
671
|
+
...props
|
|
672
|
+
}, undefined, false, undefined, this);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// ../../src/components/ui/marker.tsx
|
|
676
|
+
import { mergeProps as mergeProps3 } from "@base-ui/react/merge-props";
|
|
677
|
+
import { useRender as useRender3 } from "@base-ui/react/use-render";
|
|
678
|
+
import { cva as cva7 } from "class-variance-authority";
|
|
679
|
+
import { jsxDEV as jsxDEV12 } from "react/jsx-dev-runtime";
|
|
680
|
+
var markerVariants = cva7("group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground", {
|
|
681
|
+
variants: {
|
|
682
|
+
variant: {
|
|
683
|
+
default: "",
|
|
684
|
+
separator: "before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border",
|
|
685
|
+
border: "border-b border-border pb-2"
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
function Marker({
|
|
690
|
+
className,
|
|
691
|
+
variant = "default",
|
|
692
|
+
render,
|
|
693
|
+
...props
|
|
694
|
+
}) {
|
|
695
|
+
return useRender3({
|
|
696
|
+
defaultTagName: "div",
|
|
697
|
+
props: mergeProps3({
|
|
698
|
+
className: cn(markerVariants({ variant, className }))
|
|
699
|
+
}, props),
|
|
700
|
+
render,
|
|
701
|
+
state: {
|
|
702
|
+
slot: "marker",
|
|
703
|
+
variant
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
function MarkerContent({ className, ...props }) {
|
|
708
|
+
return /* @__PURE__ */ jsxDEV12("span", {
|
|
709
|
+
"data-slot": "marker-content",
|
|
710
|
+
className: cn("min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", className),
|
|
711
|
+
...props
|
|
712
|
+
}, undefined, false, undefined, this);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// ../../src/components/ui/message.tsx
|
|
716
|
+
import { jsxDEV as jsxDEV13 } from "react/jsx-dev-runtime";
|
|
717
|
+
function Message({
|
|
718
|
+
className,
|
|
719
|
+
align = "start",
|
|
720
|
+
...props
|
|
721
|
+
}) {
|
|
722
|
+
return /* @__PURE__ */ jsxDEV13("div", {
|
|
723
|
+
"data-slot": "message",
|
|
724
|
+
"data-align": align,
|
|
725
|
+
className: cn("group/message relative flex w-full min-w-0 gap-2 text-sm data-[align=end]:flex-row-reverse", className),
|
|
726
|
+
...props
|
|
727
|
+
}, undefined, false, undefined, this);
|
|
728
|
+
}
|
|
729
|
+
function MessageContent({ className, ...props }) {
|
|
730
|
+
return /* @__PURE__ */ jsxDEV13("div", {
|
|
731
|
+
"data-slot": "message-content",
|
|
732
|
+
className: cn("flex w-full min-w-0 flex-col gap-2.5 wrap-break-word group-data-[align=end]/message:*:data-slot:self-end", className),
|
|
733
|
+
...props
|
|
734
|
+
}, undefined, false, undefined, this);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// ../../src/components/ui/message-scroller.tsx
|
|
738
|
+
import {
|
|
739
|
+
MessageScroller as MessageScrollerPrimitive,
|
|
740
|
+
useMessageScroller,
|
|
741
|
+
useMessageScrollerScrollable,
|
|
742
|
+
useMessageScrollerVisibility
|
|
743
|
+
} from "@shadcn/react/message-scroller";
|
|
744
|
+
import { ArrowDownIcon } from "lucide-react";
|
|
745
|
+
import { jsxDEV as jsxDEV14, Fragment } from "react/jsx-dev-runtime";
|
|
746
|
+
function MessageScrollerProvider(props) {
|
|
747
|
+
return /* @__PURE__ */ jsxDEV14(MessageScrollerPrimitive.Provider, {
|
|
748
|
+
...props
|
|
749
|
+
}, undefined, false, undefined, this);
|
|
750
|
+
}
|
|
751
|
+
function MessageScroller({
|
|
752
|
+
className,
|
|
753
|
+
...props
|
|
754
|
+
}) {
|
|
755
|
+
return /* @__PURE__ */ jsxDEV14(MessageScrollerPrimitive.Root, {
|
|
756
|
+
"data-slot": "message-scroller",
|
|
757
|
+
className: cn("group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden", className),
|
|
758
|
+
...props
|
|
759
|
+
}, undefined, false, undefined, this);
|
|
760
|
+
}
|
|
761
|
+
function MessageScrollerViewport({
|
|
762
|
+
className,
|
|
763
|
+
...props
|
|
764
|
+
}) {
|
|
765
|
+
return /* @__PURE__ */ jsxDEV14(MessageScrollerPrimitive.Viewport, {
|
|
766
|
+
"data-slot": "message-scroller-viewport",
|
|
767
|
+
className: cn("size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content data-autoscrolling:scrollbar-thumb-transparent data-autoscrolling:scrollbar-track-transparent", className),
|
|
768
|
+
...props
|
|
769
|
+
}, undefined, false, undefined, this);
|
|
770
|
+
}
|
|
771
|
+
function MessageScrollerContent({
|
|
772
|
+
className,
|
|
773
|
+
...props
|
|
774
|
+
}) {
|
|
775
|
+
return /* @__PURE__ */ jsxDEV14(MessageScrollerPrimitive.Content, {
|
|
776
|
+
"data-slot": "message-scroller-content",
|
|
777
|
+
className: cn("flex h-max min-h-full flex-col gap-8", className),
|
|
778
|
+
...props
|
|
779
|
+
}, undefined, false, undefined, this);
|
|
780
|
+
}
|
|
781
|
+
function MessageScrollerItem({
|
|
782
|
+
className,
|
|
783
|
+
scrollAnchor = false,
|
|
784
|
+
...props
|
|
785
|
+
}) {
|
|
786
|
+
return /* @__PURE__ */ jsxDEV14(MessageScrollerPrimitive.Item, {
|
|
787
|
+
"data-slot": "message-scroller-item",
|
|
788
|
+
scrollAnchor,
|
|
789
|
+
className: cn("min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]", className),
|
|
790
|
+
...props
|
|
791
|
+
}, undefined, false, undefined, this);
|
|
792
|
+
}
|
|
793
|
+
function MessageScrollerButton({
|
|
794
|
+
direction = "end",
|
|
795
|
+
className,
|
|
796
|
+
children,
|
|
797
|
+
render,
|
|
798
|
+
variant = "secondary",
|
|
799
|
+
size = "icon-sm",
|
|
800
|
+
...props
|
|
801
|
+
}) {
|
|
802
|
+
return /* @__PURE__ */ jsxDEV14(MessageScrollerPrimitive.Button, {
|
|
803
|
+
"data-slot": "message-scroller-button",
|
|
804
|
+
"data-direction": direction,
|
|
805
|
+
"data-variant": variant,
|
|
806
|
+
"data-size": size,
|
|
807
|
+
direction,
|
|
808
|
+
className: cn("absolute inset-s-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180", className),
|
|
809
|
+
render: render ?? /* @__PURE__ */ jsxDEV14(Button, {
|
|
810
|
+
variant,
|
|
811
|
+
size
|
|
812
|
+
}, undefined, false, undefined, this),
|
|
813
|
+
...props,
|
|
814
|
+
children: children ?? /* @__PURE__ */ jsxDEV14(Fragment, {
|
|
815
|
+
children: [
|
|
816
|
+
/* @__PURE__ */ jsxDEV14(ArrowDownIcon, {}, undefined, false, undefined, this),
|
|
817
|
+
/* @__PURE__ */ jsxDEV14("span", {
|
|
818
|
+
className: "sr-only",
|
|
819
|
+
children: direction === "end" ? "Scroll to end" : "Scroll to start"
|
|
820
|
+
}, undefined, false, undefined, this)
|
|
821
|
+
]
|
|
822
|
+
}, undefined, true, undefined, this)
|
|
823
|
+
}, undefined, false, undefined, this);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// ../../src/components/ui/popover.tsx
|
|
827
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
828
|
+
import { jsxDEV as jsxDEV15 } from "react/jsx-dev-runtime";
|
|
829
|
+
function Popover({ ...props }) {
|
|
830
|
+
return /* @__PURE__ */ jsxDEV15(PopoverPrimitive.Root, {
|
|
831
|
+
"data-slot": "popover",
|
|
832
|
+
...props
|
|
833
|
+
}, undefined, false, undefined, this);
|
|
834
|
+
}
|
|
835
|
+
function PopoverTrigger({ ...props }) {
|
|
836
|
+
return /* @__PURE__ */ jsxDEV15(PopoverPrimitive.Trigger, {
|
|
837
|
+
"data-slot": "popover-trigger",
|
|
838
|
+
...props
|
|
839
|
+
}, undefined, false, undefined, this);
|
|
840
|
+
}
|
|
841
|
+
function PopoverContent({
|
|
842
|
+
className,
|
|
843
|
+
align = "center",
|
|
844
|
+
alignOffset = 0,
|
|
845
|
+
side = "bottom",
|
|
846
|
+
sideOffset = 4,
|
|
847
|
+
...props
|
|
848
|
+
}) {
|
|
849
|
+
return /* @__PURE__ */ jsxDEV15(PopoverPrimitive.Portal, {
|
|
850
|
+
children: /* @__PURE__ */ jsxDEV15(PopoverPrimitive.Positioner, {
|
|
851
|
+
align,
|
|
852
|
+
alignOffset,
|
|
853
|
+
side,
|
|
854
|
+
sideOffset,
|
|
855
|
+
className: "isolate z-50",
|
|
856
|
+
children: /* @__PURE__ */ jsxDEV15(PopoverPrimitive.Popup, {
|
|
857
|
+
"data-slot": "popover-content",
|
|
858
|
+
className: cn("z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
|
|
859
|
+
...props
|
|
860
|
+
}, undefined, false, undefined, this)
|
|
861
|
+
}, undefined, false, undefined, this)
|
|
862
|
+
}, undefined, false, undefined, this);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// ../../src/components/ui/tooltip.tsx
|
|
866
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
867
|
+
import { jsxDEV as jsxDEV16 } from "react/jsx-dev-runtime";
|
|
868
|
+
"use client";
|
|
869
|
+
function Tooltip({ ...props }) {
|
|
870
|
+
return /* @__PURE__ */ jsxDEV16(TooltipPrimitive.Root, {
|
|
871
|
+
"data-slot": "tooltip",
|
|
872
|
+
...props
|
|
873
|
+
}, undefined, false, undefined, this);
|
|
874
|
+
}
|
|
875
|
+
function TooltipTrigger({ ...props }) {
|
|
876
|
+
return /* @__PURE__ */ jsxDEV16(TooltipPrimitive.Trigger, {
|
|
877
|
+
"data-slot": "tooltip-trigger",
|
|
878
|
+
...props
|
|
879
|
+
}, undefined, false, undefined, this);
|
|
880
|
+
}
|
|
881
|
+
function TooltipContent({
|
|
882
|
+
className,
|
|
883
|
+
side = "top",
|
|
884
|
+
sideOffset = 4,
|
|
885
|
+
align = "center",
|
|
886
|
+
alignOffset = 0,
|
|
887
|
+
children,
|
|
888
|
+
...props
|
|
889
|
+
}) {
|
|
890
|
+
return /* @__PURE__ */ jsxDEV16(TooltipPrimitive.Portal, {
|
|
891
|
+
children: /* @__PURE__ */ jsxDEV16(TooltipPrimitive.Positioner, {
|
|
892
|
+
align,
|
|
893
|
+
alignOffset,
|
|
894
|
+
side,
|
|
895
|
+
sideOffset,
|
|
896
|
+
className: "isolate z-50",
|
|
897
|
+
children: /* @__PURE__ */ jsxDEV16(TooltipPrimitive.Popup, {
|
|
898
|
+
"data-slot": "tooltip-content",
|
|
899
|
+
className: cn("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
|
|
900
|
+
...props,
|
|
901
|
+
children: [
|
|
902
|
+
children,
|
|
903
|
+
/* @__PURE__ */ jsxDEV16(TooltipPrimitive.Arrow, {
|
|
904
|
+
className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"
|
|
905
|
+
}, undefined, false, undefined, this)
|
|
906
|
+
]
|
|
907
|
+
}, undefined, true, undefined, this)
|
|
908
|
+
}, undefined, false, undefined, this)
|
|
909
|
+
}, undefined, false, undefined, this);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// ../../src/paraglide/runtime.js
|
|
913
|
+
import"@inlang/paraglide-js/urlpattern-polyfill";
|
|
914
|
+
var baseLocale = "en";
|
|
915
|
+
var locales = ["en", "fr"];
|
|
916
|
+
var cookieName = "locale";
|
|
917
|
+
var cookieMaxAge = 34560000;
|
|
918
|
+
var cookieDomain = "";
|
|
919
|
+
var localStorageKey = "PARAGLIDE_LOCALE";
|
|
920
|
+
var strategy = [
|
|
921
|
+
"url",
|
|
922
|
+
"cookie",
|
|
923
|
+
"preferredLanguage",
|
|
924
|
+
"baseLocale"
|
|
925
|
+
];
|
|
926
|
+
var routeStrategies = [
|
|
927
|
+
{
|
|
928
|
+
match: "/api/:path(.*)?",
|
|
929
|
+
exclude: true
|
|
930
|
+
}
|
|
931
|
+
];
|
|
932
|
+
var urlPatterns = [
|
|
933
|
+
{
|
|
934
|
+
pattern: "/:path(.*)?",
|
|
935
|
+
localized: [
|
|
936
|
+
[
|
|
937
|
+
"en",
|
|
938
|
+
"/en/:path(.*)?"
|
|
939
|
+
],
|
|
940
|
+
[
|
|
941
|
+
"fr",
|
|
942
|
+
"/fr/:path(.*)?"
|
|
943
|
+
]
|
|
944
|
+
]
|
|
945
|
+
}
|
|
946
|
+
];
|
|
947
|
+
var cachedRouteStrategyUrl;
|
|
948
|
+
var cachedRouteStrategy;
|
|
949
|
+
function findMatchingRouteStrategy(url) {
|
|
950
|
+
if (routeStrategies.length === 0) {
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
const urlString = typeof url === "string" ? url : url.href;
|
|
954
|
+
if (cachedRouteStrategyUrl === urlString) {
|
|
955
|
+
return cachedRouteStrategy;
|
|
956
|
+
}
|
|
957
|
+
const urlObject = new URL(urlString, "http://dummy.com");
|
|
958
|
+
let match;
|
|
959
|
+
for (const routeStrategy of routeStrategies) {
|
|
960
|
+
const pattern = new URLPattern(routeStrategy.match, urlObject.href);
|
|
961
|
+
if (pattern.exec(urlObject.href)) {
|
|
962
|
+
match = routeStrategy;
|
|
963
|
+
break;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
cachedRouteStrategyUrl = urlString;
|
|
967
|
+
cachedRouteStrategy = match;
|
|
968
|
+
return match;
|
|
969
|
+
}
|
|
970
|
+
function getStrategyForUrl(url) {
|
|
971
|
+
const routeStrategy = findMatchingRouteStrategy(url);
|
|
972
|
+
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
973
|
+
return routeStrategy.strategy;
|
|
974
|
+
}
|
|
975
|
+
return strategy;
|
|
976
|
+
}
|
|
977
|
+
var serverAsyncLocalStorage = undefined;
|
|
978
|
+
var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
|
|
979
|
+
var experimentalStaticLocale = undefined;
|
|
980
|
+
var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
|
|
981
|
+
var TREE_SHAKE_URL_STRATEGY_USED = true;
|
|
982
|
+
var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
|
|
983
|
+
var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
|
|
984
|
+
var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
|
|
985
|
+
var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
|
|
986
|
+
globalThis.__paraglide = globalThis.__paraglide ?? {};
|
|
987
|
+
globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
|
|
988
|
+
var _locale;
|
|
989
|
+
var localeInitiallySet = false;
|
|
990
|
+
var getLocale = () => {
|
|
991
|
+
if (experimentalStaticLocale !== undefined) {
|
|
992
|
+
return experimentalStaticLocale;
|
|
993
|
+
}
|
|
994
|
+
if (serverAsyncLocalStorage) {
|
|
995
|
+
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
996
|
+
if (locale) {
|
|
997
|
+
return locale;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
let strategyToUse = strategy;
|
|
1001
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
1002
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
1003
|
+
}
|
|
1004
|
+
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
1005
|
+
if (resolved) {
|
|
1006
|
+
if (!localeInitiallySet) {
|
|
1007
|
+
_locale = resolved;
|
|
1008
|
+
localeInitiallySet = true;
|
|
1009
|
+
setLocale(resolved, { reload: false });
|
|
1010
|
+
}
|
|
1011
|
+
return resolved;
|
|
1012
|
+
}
|
|
1013
|
+
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
1014
|
+
};
|
|
1015
|
+
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
1016
|
+
let locale;
|
|
1017
|
+
for (const strat of strategyToUse) {
|
|
1018
|
+
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
1019
|
+
locale = extractLocaleFromCookie();
|
|
1020
|
+
} else if (strat === "baseLocale") {
|
|
1021
|
+
locale = baseLocale;
|
|
1022
|
+
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
|
|
1023
|
+
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
1024
|
+
} else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
|
|
1025
|
+
locale = _locale;
|
|
1026
|
+
} else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
|
|
1027
|
+
locale = extractLocaleFromNavigator();
|
|
1028
|
+
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
|
|
1029
|
+
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
1030
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
1031
|
+
const handler = customClientStrategies.get(strat);
|
|
1032
|
+
if (handler) {
|
|
1033
|
+
const result = handler.getLocale();
|
|
1034
|
+
if (result instanceof Promise) {
|
|
1035
|
+
continue;
|
|
1036
|
+
}
|
|
1037
|
+
if (result !== undefined) {
|
|
1038
|
+
return assertIsLocale(result);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
const matchedLocale = toLocale(locale);
|
|
1043
|
+
if (matchedLocale) {
|
|
1044
|
+
return matchedLocale;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
var rtlLanguages = new Set([
|
|
1050
|
+
"ar",
|
|
1051
|
+
"dv",
|
|
1052
|
+
"fa",
|
|
1053
|
+
"he",
|
|
1054
|
+
"ks",
|
|
1055
|
+
"ku",
|
|
1056
|
+
"ps",
|
|
1057
|
+
"sd",
|
|
1058
|
+
"ug",
|
|
1059
|
+
"ur",
|
|
1060
|
+
"yi"
|
|
1061
|
+
]);
|
|
1062
|
+
var navigateOrReload = (newLocation) => {
|
|
1063
|
+
if (newLocation) {
|
|
1064
|
+
window.location.href = newLocation;
|
|
1065
|
+
} else {
|
|
1066
|
+
window.location.reload();
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
var setLocale = (newLocale, options) => {
|
|
1070
|
+
const optionsWithDefaults = {
|
|
1071
|
+
reload: true,
|
|
1072
|
+
...options
|
|
1073
|
+
};
|
|
1074
|
+
let currentLocale;
|
|
1075
|
+
try {
|
|
1076
|
+
currentLocale = getLocale();
|
|
1077
|
+
} catch {}
|
|
1078
|
+
const customSetLocalePromises = [];
|
|
1079
|
+
let newLocation = undefined;
|
|
1080
|
+
let strategyToUse = strategy;
|
|
1081
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
1082
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
1083
|
+
}
|
|
1084
|
+
for (const strat of strategyToUse) {
|
|
1085
|
+
if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
|
|
1086
|
+
_locale = newLocale;
|
|
1087
|
+
} else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
1088
|
+
if (isServer || typeof document === "undefined" || typeof window === "undefined") {
|
|
1089
|
+
continue;
|
|
1090
|
+
}
|
|
1091
|
+
const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
|
|
1092
|
+
document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
|
|
1093
|
+
} else if (strat === "baseLocale") {
|
|
1094
|
+
continue;
|
|
1095
|
+
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
|
|
1096
|
+
newLocation = localizeUrl(window.location.href, {
|
|
1097
|
+
locale: newLocale
|
|
1098
|
+
}).href;
|
|
1099
|
+
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
|
|
1100
|
+
localStorage.setItem(localStorageKey, newLocale);
|
|
1101
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
1102
|
+
const handler = customClientStrategies.get(strat);
|
|
1103
|
+
if (handler) {
|
|
1104
|
+
let result = handler.setLocale(newLocale);
|
|
1105
|
+
if (result instanceof Promise) {
|
|
1106
|
+
result = result.catch((error) => {
|
|
1107
|
+
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
1108
|
+
cause: error
|
|
1109
|
+
});
|
|
1110
|
+
});
|
|
1111
|
+
customSetLocalePromises.push(result);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
const runReload = () => {
|
|
1117
|
+
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
1118
|
+
navigateOrReload(newLocation);
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
if (customSetLocalePromises.length) {
|
|
1122
|
+
return Promise.all(customSetLocalePromises).then(() => {
|
|
1123
|
+
runReload();
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
runReload();
|
|
1127
|
+
return;
|
|
1128
|
+
};
|
|
1129
|
+
var getUrlOrigin = () => {
|
|
1130
|
+
if (serverAsyncLocalStorage) {
|
|
1131
|
+
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
1132
|
+
} else if (typeof window !== "undefined") {
|
|
1133
|
+
return window.location.origin;
|
|
1134
|
+
}
|
|
1135
|
+
return "http://fallback.com";
|
|
1136
|
+
};
|
|
1137
|
+
function toLocale(value) {
|
|
1138
|
+
if (typeof value !== "string") {
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
const lowerValue = value.toLowerCase();
|
|
1142
|
+
for (const locale of locales) {
|
|
1143
|
+
if (locale.toLowerCase() === lowerValue) {
|
|
1144
|
+
return locale;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
function assertIsLocale(input) {
|
|
1150
|
+
const locale = toLocale(input);
|
|
1151
|
+
if (locale)
|
|
1152
|
+
return locale;
|
|
1153
|
+
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
1154
|
+
}
|
|
1155
|
+
function extractLocaleFromCookie() {
|
|
1156
|
+
if (typeof document === "undefined" || !document.cookie) {
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
1160
|
+
const locale = match?.[2];
|
|
1161
|
+
return toLocale(locale);
|
|
1162
|
+
}
|
|
1163
|
+
function extractLocaleFromNavigator() {
|
|
1164
|
+
if (!navigator?.languages?.length) {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
const languages = navigator.languages.map((lang) => ({
|
|
1168
|
+
fullTag: lang,
|
|
1169
|
+
baseTag: lang.split("-")[0]
|
|
1170
|
+
}));
|
|
1171
|
+
for (const lang of languages) {
|
|
1172
|
+
const fullLocale = toLocale(lang.fullTag);
|
|
1173
|
+
if (fullLocale) {
|
|
1174
|
+
return fullLocale;
|
|
1175
|
+
}
|
|
1176
|
+
const baseLocale2 = toLocale(lang.baseTag);
|
|
1177
|
+
if (baseLocale2) {
|
|
1178
|
+
return baseLocale2;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
var cachedUrl;
|
|
1184
|
+
var cachedLocale;
|
|
1185
|
+
function extractLocaleFromUrl(url) {
|
|
1186
|
+
const urlString = typeof url === "string" ? url : url.href;
|
|
1187
|
+
if (cachedUrl === urlString) {
|
|
1188
|
+
return cachedLocale;
|
|
1189
|
+
}
|
|
1190
|
+
let result;
|
|
1191
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
1192
|
+
result = defaultUrlPatternExtractLocale(url);
|
|
1193
|
+
} else {
|
|
1194
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
1195
|
+
for (const element of urlPatterns) {
|
|
1196
|
+
for (const [locale, localizedPattern] of element.localized) {
|
|
1197
|
+
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
1198
|
+
if (match) {
|
|
1199
|
+
result = locale;
|
|
1200
|
+
break;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
if (result)
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
cachedUrl = urlString;
|
|
1208
|
+
cachedLocale = result;
|
|
1209
|
+
return result;
|
|
1210
|
+
}
|
|
1211
|
+
function defaultUrlPatternExtractLocale(url) {
|
|
1212
|
+
const urlObj = new URL(url, "http://dummy.com");
|
|
1213
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
1214
|
+
return toLocale(pathSegments[0]) || baseLocale;
|
|
1215
|
+
}
|
|
1216
|
+
function localizeUrl(url, options) {
|
|
1217
|
+
const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
|
|
1218
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
1219
|
+
return localizeUrlDefaultPattern(url, targetLocale);
|
|
1220
|
+
}
|
|
1221
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
1222
|
+
for (const element of urlPatterns) {
|
|
1223
|
+
for (const [, localizedPattern] of element.localized) {
|
|
1224
|
+
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
1225
|
+
if (!match) {
|
|
1226
|
+
continue;
|
|
1227
|
+
}
|
|
1228
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
1229
|
+
if (!targetPattern) {
|
|
1230
|
+
continue;
|
|
1231
|
+
}
|
|
1232
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
1233
|
+
return fillMissingUrlParts(localizedUrl, match);
|
|
1234
|
+
}
|
|
1235
|
+
const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
|
|
1236
|
+
if (unlocalizedMatch) {
|
|
1237
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
1238
|
+
if (targetPattern) {
|
|
1239
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
1240
|
+
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return urlObj;
|
|
1245
|
+
}
|
|
1246
|
+
function localizeUrlDefaultPattern(url, locale) {
|
|
1247
|
+
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
1248
|
+
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
1249
|
+
if (currentLocale === locale) {
|
|
1250
|
+
return urlObj;
|
|
1251
|
+
}
|
|
1252
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
1253
|
+
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
1254
|
+
pathSegments.shift();
|
|
1255
|
+
}
|
|
1256
|
+
if (locale === baseLocale) {
|
|
1257
|
+
urlObj.pathname = "/" + pathSegments.join("/");
|
|
1258
|
+
} else {
|
|
1259
|
+
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
1260
|
+
}
|
|
1261
|
+
return urlObj;
|
|
1262
|
+
}
|
|
1263
|
+
function fillMissingUrlParts(url, match) {
|
|
1264
|
+
if (match.protocol.groups["0"]) {
|
|
1265
|
+
url.protocol = match.protocol.groups["0"] ?? "";
|
|
1266
|
+
}
|
|
1267
|
+
if (match.hostname.groups["0"]) {
|
|
1268
|
+
url.hostname = match.hostname.groups["0"] ?? "";
|
|
1269
|
+
}
|
|
1270
|
+
if (match.username.groups["0"]) {
|
|
1271
|
+
url.username = match.username.groups["0"] ?? "";
|
|
1272
|
+
}
|
|
1273
|
+
if (match.password.groups["0"]) {
|
|
1274
|
+
url.password = match.password.groups["0"] ?? "";
|
|
1275
|
+
}
|
|
1276
|
+
if (match.port.groups["0"]) {
|
|
1277
|
+
url.port = match.port.groups["0"] ?? "";
|
|
1278
|
+
}
|
|
1279
|
+
if (match.pathname.groups["0"]) {
|
|
1280
|
+
url.pathname = match.pathname.groups["0"] ?? "";
|
|
1281
|
+
}
|
|
1282
|
+
if (match.search.groups["0"]) {
|
|
1283
|
+
url.search = match.search.groups["0"] ?? "";
|
|
1284
|
+
}
|
|
1285
|
+
if (match.hash.groups["0"]) {
|
|
1286
|
+
url.hash = match.hash.groups["0"] ?? "";
|
|
1287
|
+
}
|
|
1288
|
+
return url;
|
|
1289
|
+
}
|
|
1290
|
+
function fillPattern(pattern, values, origin) {
|
|
1291
|
+
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
1292
|
+
return `${protocol}#PORT-${port}#${slash}`;
|
|
1293
|
+
});
|
|
1294
|
+
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
1295
|
+
if (modifier === "?") {
|
|
1296
|
+
return content;
|
|
1297
|
+
}
|
|
1298
|
+
return content;
|
|
1299
|
+
});
|
|
1300
|
+
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
1301
|
+
const value = values[name];
|
|
1302
|
+
if (value === null) {
|
|
1303
|
+
return "";
|
|
1304
|
+
}
|
|
1305
|
+
if (modifier === "?") {
|
|
1306
|
+
return value !== undefined ? `${slash}${value}` : "";
|
|
1307
|
+
}
|
|
1308
|
+
if (modifier === "+" || modifier === "*") {
|
|
1309
|
+
if (value === undefined && modifier === "+") {
|
|
1310
|
+
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
1311
|
+
}
|
|
1312
|
+
return value ? `${slash}${value}` : "";
|
|
1313
|
+
}
|
|
1314
|
+
if (value === undefined) {
|
|
1315
|
+
throw new Error(`Missing value for "${name}"`);
|
|
1316
|
+
}
|
|
1317
|
+
return `${slash}${value}`;
|
|
1318
|
+
});
|
|
1319
|
+
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
1320
|
+
return new URL(filled, origin);
|
|
1321
|
+
}
|
|
1322
|
+
function aggregateGroups(match) {
|
|
1323
|
+
return {
|
|
1324
|
+
...match.hash.groups,
|
|
1325
|
+
...match.hostname.groups,
|
|
1326
|
+
...match.password.groups,
|
|
1327
|
+
...match.pathname.groups,
|
|
1328
|
+
...match.port.groups,
|
|
1329
|
+
...match.protocol.groups,
|
|
1330
|
+
...match.search.groups,
|
|
1331
|
+
...match.username.groups
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
var customServerStrategies = new Map;
|
|
1335
|
+
var customClientStrategies = new Map;
|
|
1336
|
+
function isCustomStrategy(strategy2) {
|
|
1337
|
+
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
// ../../src/services/agent/schema.ts
|
|
1341
|
+
import { Schema } from "effect";
|
|
1342
|
+
import {
|
|
1343
|
+
HttpApiEndpoint,
|
|
1344
|
+
HttpApiError,
|
|
1345
|
+
HttpApiGroup,
|
|
1346
|
+
HttpApiSchema,
|
|
1347
|
+
OpenApi
|
|
1348
|
+
} from "effect/unstable/httpapi";
|
|
1349
|
+
var AgentMessageText = Schema.String.check(Schema.isLengthBetween(1, 4000)).annotate({
|
|
1350
|
+
identifier: "AgentMessageText",
|
|
1351
|
+
title: "Agent message",
|
|
1352
|
+
description: "A user message sent to the agent."
|
|
1353
|
+
});
|
|
1354
|
+
var AgentReferenceLabel = Schema.String.check(Schema.isLengthBetween(1, 500));
|
|
1355
|
+
var AGENT_REFERENCE_LIMIT = 20;
|
|
1356
|
+
var AgentToolMetadata = Schema.Struct({
|
|
1357
|
+
title: Schema.optional(Schema.String),
|
|
1358
|
+
description: Schema.optional(Schema.String),
|
|
1359
|
+
destructive: Schema.Boolean
|
|
1360
|
+
}).annotate({ identifier: "AgentToolMetadata" });
|
|
1361
|
+
var AgentEvent = Schema.Union([
|
|
1362
|
+
Schema.Struct({
|
|
1363
|
+
type: Schema.Literal("message-start"),
|
|
1364
|
+
messageId: Schema.String
|
|
1365
|
+
}),
|
|
1366
|
+
Schema.Struct({
|
|
1367
|
+
type: Schema.Literal("text-delta"),
|
|
1368
|
+
messageId: Schema.String,
|
|
1369
|
+
delta: Schema.String
|
|
1370
|
+
}),
|
|
1371
|
+
Schema.Struct({
|
|
1372
|
+
type: Schema.Literal("tool-call"),
|
|
1373
|
+
messageId: Schema.String,
|
|
1374
|
+
toolCallId: Schema.String,
|
|
1375
|
+
name: Schema.String,
|
|
1376
|
+
input: Schema.Unknown,
|
|
1377
|
+
metadata: AgentToolMetadata
|
|
1378
|
+
}),
|
|
1379
|
+
Schema.Struct({
|
|
1380
|
+
type: Schema.Literal("tool-result"),
|
|
1381
|
+
toolCallId: Schema.String,
|
|
1382
|
+
name: Schema.String,
|
|
1383
|
+
isFailure: Schema.Boolean
|
|
1384
|
+
}),
|
|
1385
|
+
Schema.Struct({
|
|
1386
|
+
type: Schema.Literal("approval-required"),
|
|
1387
|
+
approvalId: Schema.String,
|
|
1388
|
+
toolCallId: Schema.String
|
|
1389
|
+
}),
|
|
1390
|
+
Schema.Struct({
|
|
1391
|
+
type: Schema.Literal("history"),
|
|
1392
|
+
value: Schema.String
|
|
1393
|
+
}),
|
|
1394
|
+
Schema.Struct({ type: Schema.Literal("finish") }),
|
|
1395
|
+
Schema.Struct({
|
|
1396
|
+
type: Schema.Literal("error"),
|
|
1397
|
+
code: Schema.Literals([
|
|
1398
|
+
"unavailable",
|
|
1399
|
+
"invalid-request",
|
|
1400
|
+
"round-limit",
|
|
1401
|
+
"stream-failed"
|
|
1402
|
+
])
|
|
1403
|
+
})
|
|
1404
|
+
]).annotate({
|
|
1405
|
+
identifier: "AgentEvent",
|
|
1406
|
+
title: "Agent stream event",
|
|
1407
|
+
description: "An event emitted by the agent endpoint."
|
|
1408
|
+
});
|
|
1409
|
+
var AgentStreamError = Schema.Struct({
|
|
1410
|
+
code: Schema.Literals(["unavailable", "stream-failed"])
|
|
1411
|
+
}).annotate({
|
|
1412
|
+
identifier: "AgentStreamError",
|
|
1413
|
+
title: "Agent stream error",
|
|
1414
|
+
description: "A recoverable agent stream failure."
|
|
1415
|
+
});
|
|
1416
|
+
|
|
1417
|
+
// ../../src/services/agent/client/widget.tsx
|
|
1418
|
+
import { jsxDEV as jsxDEV17 } from "react/jsx-dev-runtime";
|
|
1419
|
+
var messages = {
|
|
1420
|
+
en: {
|
|
1421
|
+
approve: "Approve",
|
|
1422
|
+
approvalDestructive: "This may permanently remove data. Check the action before continuing.",
|
|
1423
|
+
approvalDestructiveLabel: "Destructive",
|
|
1424
|
+
approvalRequired: "The assistant needs your confirmation before making this change.",
|
|
1425
|
+
cancel: "Cancel",
|
|
1426
|
+
close: "Close",
|
|
1427
|
+
copied: "Copied",
|
|
1428
|
+
copy: "Copy",
|
|
1429
|
+
description: "Ask questions and use available tools to get things done.",
|
|
1430
|
+
errorInvalidRequest: "The request could not be processed. Start a new conversation and try again.",
|
|
1431
|
+
errorRoundLimit: "The assistant stopped after too many API steps. Try a more specific request.",
|
|
1432
|
+
errorStreamFailed: "The response was interrupted. Please try again.",
|
|
1433
|
+
errorUnavailable: "The assistant is currently unavailable.",
|
|
1434
|
+
maximize: "Maximize assistant",
|
|
1435
|
+
minimize: "Minimize assistant",
|
|
1436
|
+
noReferences: "No references found.",
|
|
1437
|
+
open: "Open AI Assistant",
|
|
1438
|
+
placeholder: "Ask a question...",
|
|
1439
|
+
removeContext: "Remove context",
|
|
1440
|
+
references: "References",
|
|
1441
|
+
restore: "Restore assistant window",
|
|
1442
|
+
scrollLatest: "Scroll to latest message",
|
|
1443
|
+
send: "Send message",
|
|
1444
|
+
stop: "Stop response",
|
|
1445
|
+
title: "AI Assistant",
|
|
1446
|
+
toolDenied: "Cancelled",
|
|
1447
|
+
toolFailed: "Failed",
|
|
1448
|
+
toolRunning: "Checking the API",
|
|
1449
|
+
toolWorked: (seconds) => `Worked for ${seconds} ${seconds === 1 ? "second" : "seconds"}`,
|
|
1450
|
+
viewLess: "View less",
|
|
1451
|
+
viewMore: "View more",
|
|
1452
|
+
welcome: "How can I help?"
|
|
1453
|
+
},
|
|
1454
|
+
fr: {
|
|
1455
|
+
approve: "Approuver",
|
|
1456
|
+
approvalDestructive: "Cette action peut supprimer définitivement des données. Vérifiez-la avant de continuer.",
|
|
1457
|
+
approvalDestructiveLabel: "Destructif",
|
|
1458
|
+
approvalRequired: "L'assistant a besoin de votre confirmation avant d'effectuer cette modification.",
|
|
1459
|
+
cancel: "Annuler",
|
|
1460
|
+
close: "Fermer",
|
|
1461
|
+
copied: "Copié",
|
|
1462
|
+
copy: "Copier",
|
|
1463
|
+
description: "Posez des questions et utilisez les outils disponibles pour accomplir vos tâches.",
|
|
1464
|
+
errorInvalidRequest: "La demande n'a pas pu être traitée. Commencez une nouvelle conversation et réessayez.",
|
|
1465
|
+
errorRoundLimit: "L'assistant s'est arrêté après trop d'étapes d'API. Essayez une demande plus précise.",
|
|
1466
|
+
errorStreamFailed: "La réponse a été interrompue. Veuillez réessayer.",
|
|
1467
|
+
errorUnavailable: "L'assistant est actuellement indisponible.",
|
|
1468
|
+
maximize: "Agrandir l'assistant",
|
|
1469
|
+
minimize: "Réduire l'assistant",
|
|
1470
|
+
noReferences: "Aucune référence trouvée.",
|
|
1471
|
+
open: "Ouvrir l'assistant IA",
|
|
1472
|
+
placeholder: "Posez une question...",
|
|
1473
|
+
removeContext: "Supprimer le contexte",
|
|
1474
|
+
references: "Références",
|
|
1475
|
+
restore: "Restaurer la fenêtre de l'assistant",
|
|
1476
|
+
scrollLatest: "Défiler jusqu'au dernier message",
|
|
1477
|
+
send: "Envoyer le message",
|
|
1478
|
+
stop: "Arrêter la réponse",
|
|
1479
|
+
title: "Assistant IA",
|
|
1480
|
+
toolDenied: "Annulé",
|
|
1481
|
+
toolFailed: "Échec",
|
|
1482
|
+
toolRunning: "Consultation de l'API",
|
|
1483
|
+
toolWorked: (seconds) => `A travaillé pendant ${seconds} ${seconds === 1 ? "seconde" : "secondes"}`,
|
|
1484
|
+
viewLess: "Voir moins",
|
|
1485
|
+
viewMore: "Voir plus",
|
|
1486
|
+
welcome: "Comment puis-je vous aider?"
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
var agentWidgetMessages = (locale = getLocale(), overrides) => ({
|
|
1490
|
+
...locale.startsWith("fr") ? messages.fr : messages.en,
|
|
1491
|
+
...overrides
|
|
1492
|
+
});
|
|
1493
|
+
var errorMessage = (code2, labels) => {
|
|
1494
|
+
switch (code2) {
|
|
1495
|
+
case "invalid-request":
|
|
1496
|
+
return labels.errorInvalidRequest;
|
|
1497
|
+
case "round-limit":
|
|
1498
|
+
return labels.errorRoundLimit;
|
|
1499
|
+
case "stream-failed":
|
|
1500
|
+
return labels.errorStreamFailed;
|
|
1501
|
+
case "unavailable":
|
|
1502
|
+
return labels.errorUnavailable;
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
var inputCodeBlock = (input) => {
|
|
1506
|
+
const value = JSON.stringify(input, null, 2) ?? String(input);
|
|
1507
|
+
const longestFence = Math.max(0, ...value.match(/`+/g)?.map((fence2) => fence2.length) ?? []);
|
|
1508
|
+
const fence = "`".repeat(Math.max(3, longestFence + 1));
|
|
1509
|
+
return `${fence}json
|
|
1510
|
+
${value}
|
|
1511
|
+
${fence}`;
|
|
1512
|
+
};
|
|
1513
|
+
var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1514
|
+
var referenceMentionPattern = (label) => new RegExp(`@${escapeRegExp(label)}(?![\\p{L}\\p{N}_-])`, "u");
|
|
1515
|
+
var hasReferenceMention = (input, label) => referenceMentionPattern(label).test(input);
|
|
1516
|
+
var highlightedInput = (input, references) => {
|
|
1517
|
+
const mentions = references.map(({ label }) => `@${label}`).sort((left, right) => right.length - left.length);
|
|
1518
|
+
if (mentions.length === 0)
|
|
1519
|
+
return input;
|
|
1520
|
+
const mentionPattern = new RegExp(`(${mentions.map(escapeRegExp).join("|")})(?![\\p{L}\\p{N}_-])`, "gu");
|
|
1521
|
+
const mentionSet = new Set(mentions);
|
|
1522
|
+
return input.split(mentionPattern).map((part, index) => mentionSet.has(part) ? /* @__PURE__ */ jsxDEV17("span", {
|
|
1523
|
+
className: "text-primary",
|
|
1524
|
+
children: part
|
|
1525
|
+
}, `${part}:${index}`, false, undefined, this) : part);
|
|
1526
|
+
};
|
|
1527
|
+
var referenceSearchQuery = (input) => input.match(/(?:^|\s)@([^@\n]*)$/)?.[1].trimEnd();
|
|
1528
|
+
var ToolLabel = ({
|
|
1529
|
+
description,
|
|
1530
|
+
label
|
|
1531
|
+
}) => {
|
|
1532
|
+
if (!description)
|
|
1533
|
+
return label;
|
|
1534
|
+
return /* @__PURE__ */ jsxDEV17(Tooltip, {
|
|
1535
|
+
children: [
|
|
1536
|
+
/* @__PURE__ */ jsxDEV17(TooltipTrigger, {
|
|
1537
|
+
render: /* @__PURE__ */ jsxDEV17("span", {
|
|
1538
|
+
className: "cursor-help",
|
|
1539
|
+
tabIndex: 0
|
|
1540
|
+
}, undefined, false, undefined, this),
|
|
1541
|
+
children: label
|
|
1542
|
+
}, undefined, false, undefined, this),
|
|
1543
|
+
/* @__PURE__ */ jsxDEV17(TooltipContent, {
|
|
1544
|
+
className: "max-w-sm",
|
|
1545
|
+
children: description
|
|
1546
|
+
}, undefined, false, undefined, this)
|
|
1547
|
+
]
|
|
1548
|
+
}, undefined, true, undefined, this);
|
|
1549
|
+
};
|
|
1550
|
+
function ToolActivityCard({
|
|
1551
|
+
disabled,
|
|
1552
|
+
labels,
|
|
1553
|
+
onApproval,
|
|
1554
|
+
tool
|
|
1555
|
+
}) {
|
|
1556
|
+
const [detailsOpen, setDetailsOpen] = useState(false);
|
|
1557
|
+
const requiresApproval = tool.status === "approval-required";
|
|
1558
|
+
const label = tool.metadata.title ?? tool.name;
|
|
1559
|
+
if (!requiresApproval) {
|
|
1560
|
+
return /* @__PURE__ */ jsxDEV17(Marker, {
|
|
1561
|
+
children: [
|
|
1562
|
+
/* @__PURE__ */ jsxDEV17(MarkerContent, {
|
|
1563
|
+
children: /* @__PURE__ */ jsxDEV17("span", {
|
|
1564
|
+
className: cn("block w-fit max-w-full", tool.status === "running" && "shimmer"),
|
|
1565
|
+
children: /* @__PURE__ */ jsxDEV17(ToolLabel, {
|
|
1566
|
+
description: tool.metadata.description,
|
|
1567
|
+
label
|
|
1568
|
+
}, undefined, false, undefined, this)
|
|
1569
|
+
}, undefined, false, undefined, this)
|
|
1570
|
+
}, undefined, false, undefined, this),
|
|
1571
|
+
tool.status === "failed" || tool.status === "denied" ? /* @__PURE__ */ jsxDEV17(Badge, {
|
|
1572
|
+
variant: "destructive",
|
|
1573
|
+
children: tool.status === "failed" ? labels.toolFailed : labels.toolDenied
|
|
1574
|
+
}, undefined, false, undefined, this) : null
|
|
1575
|
+
]
|
|
1576
|
+
}, undefined, true, undefined, this);
|
|
1577
|
+
}
|
|
1578
|
+
return /* @__PURE__ */ jsxDEV17(Collapsible, {
|
|
1579
|
+
className: "mx-1",
|
|
1580
|
+
open: detailsOpen,
|
|
1581
|
+
onOpenChange: setDetailsOpen,
|
|
1582
|
+
children: /* @__PURE__ */ jsxDEV17(Card, {
|
|
1583
|
+
size: "sm",
|
|
1584
|
+
className: "w-full border shadow-none ring-0",
|
|
1585
|
+
children: [
|
|
1586
|
+
/* @__PURE__ */ jsxDEV17(CardHeader, {
|
|
1587
|
+
children: [
|
|
1588
|
+
/* @__PURE__ */ jsxDEV17(CardTitle, {
|
|
1589
|
+
className: "flex items-center gap-2",
|
|
1590
|
+
children: [
|
|
1591
|
+
/* @__PURE__ */ jsxDEV17(ToolLabel, {
|
|
1592
|
+
description: tool.metadata.description,
|
|
1593
|
+
label
|
|
1594
|
+
}, undefined, false, undefined, this),
|
|
1595
|
+
tool.metadata.destructive ? /* @__PURE__ */ jsxDEV17(Badge, {
|
|
1596
|
+
variant: "destructive",
|
|
1597
|
+
children: labels.approvalDestructiveLabel
|
|
1598
|
+
}, undefined, false, undefined, this) : null
|
|
1599
|
+
]
|
|
1600
|
+
}, undefined, true, undefined, this),
|
|
1601
|
+
/* @__PURE__ */ jsxDEV17(CardDescription, {
|
|
1602
|
+
children: tool.metadata.destructive ? labels.approvalDestructive : labels.approvalRequired
|
|
1603
|
+
}, undefined, false, undefined, this)
|
|
1604
|
+
]
|
|
1605
|
+
}, undefined, true, undefined, this),
|
|
1606
|
+
/* @__PURE__ */ jsxDEV17(CollapsibleContent, {
|
|
1607
|
+
children: /* @__PURE__ */ jsxDEV17(CardContent, {
|
|
1608
|
+
className: "min-w-0 overflow-hidden border-y py-3",
|
|
1609
|
+
children: /* @__PURE__ */ jsxDEV17(Streamdown, {
|
|
1610
|
+
className: "min-w-0 text-xs",
|
|
1611
|
+
controls: {
|
|
1612
|
+
code: { copy: true, download: false },
|
|
1613
|
+
mermaid: false,
|
|
1614
|
+
table: false
|
|
1615
|
+
},
|
|
1616
|
+
linkSafety: { enabled: false },
|
|
1617
|
+
plugins: { code },
|
|
1618
|
+
translations: {
|
|
1619
|
+
copied: labels.copied,
|
|
1620
|
+
copyCode: labels.copy
|
|
1621
|
+
},
|
|
1622
|
+
children: inputCodeBlock(tool.input)
|
|
1623
|
+
}, undefined, false, undefined, this)
|
|
1624
|
+
}, undefined, false, undefined, this)
|
|
1625
|
+
}, undefined, false, undefined, this),
|
|
1626
|
+
/* @__PURE__ */ jsxDEV17(CardFooter, {
|
|
1627
|
+
className: "flex flex-wrap gap-2",
|
|
1628
|
+
children: [
|
|
1629
|
+
/* @__PURE__ */ jsxDEV17(Button, {
|
|
1630
|
+
size: "sm",
|
|
1631
|
+
variant: tool.metadata.destructive ? "destructive" : "default",
|
|
1632
|
+
disabled,
|
|
1633
|
+
onClick: () => onApproval(tool, true),
|
|
1634
|
+
children: labels.approve
|
|
1635
|
+
}, undefined, false, undefined, this),
|
|
1636
|
+
/* @__PURE__ */ jsxDEV17(Button, {
|
|
1637
|
+
size: "sm",
|
|
1638
|
+
variant: "outline",
|
|
1639
|
+
disabled,
|
|
1640
|
+
onClick: () => onApproval(tool, false),
|
|
1641
|
+
children: labels.cancel
|
|
1642
|
+
}, undefined, false, undefined, this),
|
|
1643
|
+
/* @__PURE__ */ jsxDEV17(CollapsibleTrigger, {
|
|
1644
|
+
render: /* @__PURE__ */ jsxDEV17(Button, {
|
|
1645
|
+
variant: "ghost",
|
|
1646
|
+
size: "sm",
|
|
1647
|
+
className: "ml-auto",
|
|
1648
|
+
children: [
|
|
1649
|
+
detailsOpen ? labels.viewLess : labels.viewMore,
|
|
1650
|
+
/* @__PURE__ */ jsxDEV17(ChevronDownIcon, {
|
|
1651
|
+
"data-icon": "inline-end",
|
|
1652
|
+
className: cn("transition-transform", detailsOpen && "rotate-180")
|
|
1653
|
+
}, undefined, false, undefined, this)
|
|
1654
|
+
]
|
|
1655
|
+
}, undefined, true, undefined, this)
|
|
1656
|
+
}, undefined, false, undefined, this)
|
|
1657
|
+
]
|
|
1658
|
+
}, undefined, true, undefined, this)
|
|
1659
|
+
]
|
|
1660
|
+
}, undefined, true, undefined, this)
|
|
1661
|
+
}, undefined, false, undefined, this);
|
|
1662
|
+
}
|
|
1663
|
+
function ToolActivityLog({
|
|
1664
|
+
disabled,
|
|
1665
|
+
labels,
|
|
1666
|
+
onApproval,
|
|
1667
|
+
pending,
|
|
1668
|
+
tools,
|
|
1669
|
+
workedSeconds
|
|
1670
|
+
}) {
|
|
1671
|
+
const [logOpen, setLogOpen] = useState(false);
|
|
1672
|
+
const currentTool = tools.at(-1);
|
|
1673
|
+
if (!currentTool) {
|
|
1674
|
+
return /* @__PURE__ */ jsxDEV17(Marker, {
|
|
1675
|
+
children: /* @__PURE__ */ jsxDEV17(MarkerContent, {
|
|
1676
|
+
children: /* @__PURE__ */ jsxDEV17("span", {
|
|
1677
|
+
className: "shimmer block w-fit max-w-full",
|
|
1678
|
+
children: labels.toolRunning
|
|
1679
|
+
}, undefined, false, undefined, this)
|
|
1680
|
+
}, undefined, false, undefined, this)
|
|
1681
|
+
}, undefined, false, undefined, this);
|
|
1682
|
+
}
|
|
1683
|
+
const label = currentTool.metadata.title ?? currentTool.name;
|
|
1684
|
+
const showWorkedSummary = workedSeconds !== undefined && currentTool.status !== "approval-required";
|
|
1685
|
+
const isWorking = pending && workedSeconds === undefined && currentTool.status !== "approval-required";
|
|
1686
|
+
const loggedTools = showWorkedSummary ? tools : tools.slice(0, -1);
|
|
1687
|
+
if (currentTool.status === "approval-required") {
|
|
1688
|
+
return /* @__PURE__ */ jsxDEV17("div", {
|
|
1689
|
+
className: "flex flex-col gap-2",
|
|
1690
|
+
children: [
|
|
1691
|
+
loggedTools.length > 0 ? /* @__PURE__ */ jsxDEV17(Collapsible, {
|
|
1692
|
+
open: logOpen,
|
|
1693
|
+
onOpenChange: setLogOpen,
|
|
1694
|
+
children: [
|
|
1695
|
+
/* @__PURE__ */ jsxDEV17(CollapsibleTrigger, {
|
|
1696
|
+
render: /* @__PURE__ */ jsxDEV17(Button, {
|
|
1697
|
+
variant: "ghost",
|
|
1698
|
+
size: "sm",
|
|
1699
|
+
className: "ml-auto"
|
|
1700
|
+
}, undefined, false, undefined, this),
|
|
1701
|
+
children: [
|
|
1702
|
+
logOpen ? labels.viewLess : labels.viewMore,
|
|
1703
|
+
/* @__PURE__ */ jsxDEV17(ChevronDownIcon, {
|
|
1704
|
+
"data-icon": "inline-end",
|
|
1705
|
+
className: cn("transition-transform", logOpen && "rotate-180")
|
|
1706
|
+
}, undefined, false, undefined, this)
|
|
1707
|
+
]
|
|
1708
|
+
}, undefined, true, undefined, this),
|
|
1709
|
+
/* @__PURE__ */ jsxDEV17(CollapsibleContent, {
|
|
1710
|
+
className: "mt-2 ml-2 flex flex-col gap-2 border-l pl-3",
|
|
1711
|
+
children: loggedTools.map((tool) => /* @__PURE__ */ jsxDEV17(ToolActivityCard, {
|
|
1712
|
+
disabled,
|
|
1713
|
+
labels,
|
|
1714
|
+
onApproval,
|
|
1715
|
+
tool
|
|
1716
|
+
}, tool.toolCallId, false, undefined, this))
|
|
1717
|
+
}, undefined, false, undefined, this)
|
|
1718
|
+
]
|
|
1719
|
+
}, undefined, true, undefined, this) : null,
|
|
1720
|
+
/* @__PURE__ */ jsxDEV17(ToolActivityCard, {
|
|
1721
|
+
disabled,
|
|
1722
|
+
labels,
|
|
1723
|
+
onApproval,
|
|
1724
|
+
tool: currentTool
|
|
1725
|
+
}, undefined, false, undefined, this)
|
|
1726
|
+
]
|
|
1727
|
+
}, undefined, true, undefined, this);
|
|
1728
|
+
}
|
|
1729
|
+
return /* @__PURE__ */ jsxDEV17(Collapsible, {
|
|
1730
|
+
open: logOpen,
|
|
1731
|
+
onOpenChange: setLogOpen,
|
|
1732
|
+
children: [
|
|
1733
|
+
/* @__PURE__ */ jsxDEV17(CollapsibleTrigger, {
|
|
1734
|
+
render: /* @__PURE__ */ jsxDEV17(Marker, {
|
|
1735
|
+
className: "focus-visible:ring-ring/50 cursor-pointer rounded-sm outline-none focus-visible:ring-3",
|
|
1736
|
+
render: /* @__PURE__ */ jsxDEV17("button", {
|
|
1737
|
+
type: "button"
|
|
1738
|
+
}, undefined, false, undefined, this)
|
|
1739
|
+
}, undefined, false, undefined, this),
|
|
1740
|
+
children: [
|
|
1741
|
+
/* @__PURE__ */ jsxDEV17(MarkerContent, {
|
|
1742
|
+
className: "flex-1",
|
|
1743
|
+
children: /* @__PURE__ */ jsxDEV17("span", {
|
|
1744
|
+
className: cn("block w-fit max-w-full", isWorking && "shimmer"),
|
|
1745
|
+
children: showWorkedSummary ? labels.toolWorked(workedSeconds) : label
|
|
1746
|
+
}, undefined, false, undefined, this)
|
|
1747
|
+
}, undefined, false, undefined, this),
|
|
1748
|
+
currentTool.status === "failed" || currentTool.status === "denied" ? /* @__PURE__ */ jsxDEV17(Badge, {
|
|
1749
|
+
variant: "destructive",
|
|
1750
|
+
children: currentTool.status === "failed" ? labels.toolFailed : labels.toolDenied
|
|
1751
|
+
}, undefined, false, undefined, this) : null,
|
|
1752
|
+
/* @__PURE__ */ jsxDEV17(ChevronDownIcon, {
|
|
1753
|
+
className: cn("transition-transform", logOpen && "rotate-180")
|
|
1754
|
+
}, undefined, false, undefined, this),
|
|
1755
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
1756
|
+
className: "sr-only",
|
|
1757
|
+
children: logOpen ? labels.viewLess : labels.viewMore
|
|
1758
|
+
}, undefined, false, undefined, this)
|
|
1759
|
+
]
|
|
1760
|
+
}, undefined, true, undefined, this),
|
|
1761
|
+
/* @__PURE__ */ jsxDEV17(CollapsibleContent, {
|
|
1762
|
+
className: "mt-2 ml-2 flex flex-col gap-2 border-l pl-3",
|
|
1763
|
+
children: [
|
|
1764
|
+
/* @__PURE__ */ jsxDEV17(Marker, {
|
|
1765
|
+
children: /* @__PURE__ */ jsxDEV17(MarkerContent, {
|
|
1766
|
+
children: labels.toolRunning
|
|
1767
|
+
}, undefined, false, undefined, this)
|
|
1768
|
+
}, undefined, false, undefined, this),
|
|
1769
|
+
loggedTools.map((tool) => /* @__PURE__ */ jsxDEV17(ToolActivityCard, {
|
|
1770
|
+
disabled,
|
|
1771
|
+
labels,
|
|
1772
|
+
onApproval,
|
|
1773
|
+
tool
|
|
1774
|
+
}, tool.toolCallId, false, undefined, this))
|
|
1775
|
+
]
|
|
1776
|
+
}, undefined, true, undefined, this)
|
|
1777
|
+
]
|
|
1778
|
+
}, undefined, true, undefined, this);
|
|
1779
|
+
}
|
|
1780
|
+
function AgentMessageRow({
|
|
1781
|
+
disabled,
|
|
1782
|
+
labels,
|
|
1783
|
+
message,
|
|
1784
|
+
onApproval,
|
|
1785
|
+
pending
|
|
1786
|
+
}) {
|
|
1787
|
+
const isUser = message.role === "user";
|
|
1788
|
+
const activeStartedAt = useRef(undefined);
|
|
1789
|
+
const activeMilliseconds = useRef(0);
|
|
1790
|
+
const wasPending = useRef(pending);
|
|
1791
|
+
const [workedSeconds, setWorkedSeconds] = useState();
|
|
1792
|
+
const hasPendingApproval = message.tools.some((tool) => tool.status === "approval-required");
|
|
1793
|
+
useEffect(() => {
|
|
1794
|
+
const isWorking = pending && !hasPendingApproval;
|
|
1795
|
+
if (isWorking) {
|
|
1796
|
+
wasPending.current = true;
|
|
1797
|
+
activeStartedAt.current ??= Date.now();
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
if (activeStartedAt.current !== undefined) {
|
|
1801
|
+
activeMilliseconds.current += Date.now() - activeStartedAt.current;
|
|
1802
|
+
activeStartedAt.current = undefined;
|
|
1803
|
+
}
|
|
1804
|
+
const completed = !isUser && message.tools.length > 0 && !hasPendingApproval && (message.text.length > 0 || !pending);
|
|
1805
|
+
if (!completed || !wasPending.current || workedSeconds !== undefined) {
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
setWorkedSeconds(Math.max(1, Math.round(activeMilliseconds.current / 1000)));
|
|
1809
|
+
}, [
|
|
1810
|
+
hasPendingApproval,
|
|
1811
|
+
isUser,
|
|
1812
|
+
message.text,
|
|
1813
|
+
message.tools.length,
|
|
1814
|
+
pending,
|
|
1815
|
+
workedSeconds
|
|
1816
|
+
]);
|
|
1817
|
+
return /* @__PURE__ */ jsxDEV17(Message, {
|
|
1818
|
+
align: isUser ? "end" : "start",
|
|
1819
|
+
children: /* @__PURE__ */ jsxDEV17(MessageContent, {
|
|
1820
|
+
children: [
|
|
1821
|
+
!isUser && (message.tools.length > 0 || pending && !message.text) ? /* @__PURE__ */ jsxDEV17(ToolActivityLog, {
|
|
1822
|
+
disabled,
|
|
1823
|
+
labels,
|
|
1824
|
+
onApproval,
|
|
1825
|
+
pending,
|
|
1826
|
+
tools: message.tools,
|
|
1827
|
+
workedSeconds
|
|
1828
|
+
}, undefined, false, undefined, this) : null,
|
|
1829
|
+
message.text ? isUser ? /* @__PURE__ */ jsxDEV17(Bubble, {
|
|
1830
|
+
align: "end",
|
|
1831
|
+
children: /* @__PURE__ */ jsxDEV17(BubbleContent, {
|
|
1832
|
+
className: "whitespace-pre-wrap",
|
|
1833
|
+
children: message.text
|
|
1834
|
+
}, undefined, false, undefined, this)
|
|
1835
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV17(Streamdown, {
|
|
1836
|
+
animated: true,
|
|
1837
|
+
className: "w-full",
|
|
1838
|
+
controls: {
|
|
1839
|
+
code: { copy: true, download: false },
|
|
1840
|
+
mermaid: false,
|
|
1841
|
+
table: false
|
|
1842
|
+
},
|
|
1843
|
+
isAnimating: pending,
|
|
1844
|
+
linkSafety: { enabled: false },
|
|
1845
|
+
plugins: { code },
|
|
1846
|
+
translations: {
|
|
1847
|
+
copied: labels.copied,
|
|
1848
|
+
copyCode: labels.copy
|
|
1849
|
+
},
|
|
1850
|
+
children: message.text
|
|
1851
|
+
}, undefined, false, undefined, this) : null
|
|
1852
|
+
]
|
|
1853
|
+
}, undefined, true, undefined, this)
|
|
1854
|
+
}, undefined, false, undefined, this);
|
|
1855
|
+
}
|
|
1856
|
+
function AgentWidget({
|
|
1857
|
+
availableReferences = [],
|
|
1858
|
+
context,
|
|
1859
|
+
messages: messageOverrides,
|
|
1860
|
+
onInterrupt,
|
|
1861
|
+
onRemoveContext,
|
|
1862
|
+
onReset,
|
|
1863
|
+
onSubmit,
|
|
1864
|
+
state
|
|
1865
|
+
}) {
|
|
1866
|
+
const labels = agentWidgetMessages(getLocale(), messageOverrides);
|
|
1867
|
+
const referenceInputId = useId();
|
|
1868
|
+
const referenceListId = `${referenceInputId}-list`;
|
|
1869
|
+
const [open, setOpen] = useState(false);
|
|
1870
|
+
const [maximized, setMaximized] = useState(false);
|
|
1871
|
+
const [referencePickerOpen, setReferencePickerOpen] = useState(false);
|
|
1872
|
+
const [activeReferenceKey, setActiveReferenceKey] = useState("");
|
|
1873
|
+
const [input, setInput] = useState("");
|
|
1874
|
+
const [references, setReferences] = useState([]);
|
|
1875
|
+
const activeContext = state.contextLocked ? state.context ? {
|
|
1876
|
+
...state.context,
|
|
1877
|
+
icon: availableReferences.find(({ key }) => key === state.context?.key)?.icon
|
|
1878
|
+
} : undefined : context;
|
|
1879
|
+
const referenceQuery = referenceSearchQuery(input);
|
|
1880
|
+
const selectedKeys = new Set(references.map(({ key }) => key));
|
|
1881
|
+
const selectedLabels = new Set(references.map(({ label }) => label));
|
|
1882
|
+
const selectableReferences = availableReferences.filter((reference) => references.length < AGENT_REFERENCE_LIMIT && reference.key !== activeContext?.key && !selectedKeys.has(reference.key) && !selectedLabels.has(reference.label));
|
|
1883
|
+
const matchingReferences = selectableReferences.filter((reference) => referenceQuery === undefined ? false : `${reference.label} ${reference.key}`.toLocaleLowerCase().includes(referenceQuery.toLocaleLowerCase()));
|
|
1884
|
+
const activeReferenceIndex = Math.max(0, matchingReferences.findIndex((reference) => reference.key === activeReferenceKey));
|
|
1885
|
+
const activeReference = matchingReferences[activeReferenceIndex];
|
|
1886
|
+
const hasPendingApproval = state.messages.some((message) => message.tools.some((tool) => tool.status === "approval-required"));
|
|
1887
|
+
const sendMessage = () => {
|
|
1888
|
+
const text = input.trim();
|
|
1889
|
+
if (!text || state.pending || hasPendingApproval)
|
|
1890
|
+
return;
|
|
1891
|
+
setInput("");
|
|
1892
|
+
setReferences([]);
|
|
1893
|
+
setReferencePickerOpen(false);
|
|
1894
|
+
onSubmit({
|
|
1895
|
+
type: "message",
|
|
1896
|
+
text,
|
|
1897
|
+
...references.length > 0 ? {
|
|
1898
|
+
references: references.map(({ label, resource }) => ({
|
|
1899
|
+
label,
|
|
1900
|
+
resource
|
|
1901
|
+
}))
|
|
1902
|
+
} : {}
|
|
1903
|
+
});
|
|
1904
|
+
};
|
|
1905
|
+
const respondToApproval = (tool, approved) => {
|
|
1906
|
+
if (!tool.approvalId || state.pending)
|
|
1907
|
+
return;
|
|
1908
|
+
onSubmit({
|
|
1909
|
+
type: "approval",
|
|
1910
|
+
approvalId: tool.approvalId,
|
|
1911
|
+
toolCallId: tool.toolCallId,
|
|
1912
|
+
approved
|
|
1913
|
+
});
|
|
1914
|
+
};
|
|
1915
|
+
const selectReference = (reference) => {
|
|
1916
|
+
setReferences((current) => [...current, reference]);
|
|
1917
|
+
setInput((current) => current.replace(/@[^@\n]*$/, `@${reference.label}`));
|
|
1918
|
+
setReferencePickerOpen(false);
|
|
1919
|
+
};
|
|
1920
|
+
const clearConversation = () => {
|
|
1921
|
+
onInterrupt();
|
|
1922
|
+
onReset();
|
|
1923
|
+
setInput("");
|
|
1924
|
+
setReferences([]);
|
|
1925
|
+
setReferencePickerOpen(false);
|
|
1926
|
+
};
|
|
1927
|
+
const handleOpenChange = (nextOpen) => {
|
|
1928
|
+
if (!nextOpen) {
|
|
1929
|
+
clearConversation();
|
|
1930
|
+
setMaximized(false);
|
|
1931
|
+
}
|
|
1932
|
+
setOpen(nextOpen);
|
|
1933
|
+
};
|
|
1934
|
+
return /* @__PURE__ */ jsxDEV17(Dialog, {
|
|
1935
|
+
open,
|
|
1936
|
+
onOpenChange: handleOpenChange,
|
|
1937
|
+
modal: false,
|
|
1938
|
+
disablePointerDismissal: true,
|
|
1939
|
+
children: [
|
|
1940
|
+
/* @__PURE__ */ jsxDEV17(DialogTrigger, {
|
|
1941
|
+
render: /* @__PURE__ */ jsxDEV17(Button, {
|
|
1942
|
+
size: "icon-lg",
|
|
1943
|
+
className: "fixed right-4 bottom-4 z-9999 rounded-full shadow-lg md:right-6 md:bottom-6"
|
|
1944
|
+
}, undefined, false, undefined, this),
|
|
1945
|
+
children: [
|
|
1946
|
+
/* @__PURE__ */ jsxDEV17(BotIcon, {}, undefined, false, undefined, this),
|
|
1947
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
1948
|
+
className: "sr-only",
|
|
1949
|
+
children: labels.open
|
|
1950
|
+
}, undefined, false, undefined, this)
|
|
1951
|
+
]
|
|
1952
|
+
}, undefined, true, undefined, this),
|
|
1953
|
+
/* @__PURE__ */ jsxDEV17(DialogPortal, {
|
|
1954
|
+
children: /* @__PURE__ */ jsxDEV17(DialogPrimitive2.Popup, {
|
|
1955
|
+
"data-slot": "dialog-content",
|
|
1956
|
+
className: cn("bg-popover text-popover-foreground ring-foreground/10 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 fixed z-50 flex flex-col gap-0 overflow-hidden rounded-xl text-sm shadow-lg ring-1 duration-100 outline-none", maximized ? "inset-4 max-h-none max-w-none md:inset-6" : "right-4 bottom-20 h-[min(42rem,calc(100svh-6rem))] w-[calc(100%-2rem)] max-w-md md:right-6"),
|
|
1957
|
+
children: [
|
|
1958
|
+
/* @__PURE__ */ jsxDEV17(DialogHeader, {
|
|
1959
|
+
className: "shrink-0 border-b p-4",
|
|
1960
|
+
children: /* @__PURE__ */ jsxDEV17("div", {
|
|
1961
|
+
className: "flex items-center gap-1",
|
|
1962
|
+
children: [
|
|
1963
|
+
/* @__PURE__ */ jsxDEV17(DialogTitle, {
|
|
1964
|
+
className: "min-w-0 flex-1 truncate",
|
|
1965
|
+
children: labels.title
|
|
1966
|
+
}, undefined, false, undefined, this),
|
|
1967
|
+
/* @__PURE__ */ jsxDEV17(Button, {
|
|
1968
|
+
variant: "ghost",
|
|
1969
|
+
size: "icon-sm",
|
|
1970
|
+
onClick: () => setOpen(false),
|
|
1971
|
+
children: [
|
|
1972
|
+
/* @__PURE__ */ jsxDEV17(MinusIcon, {}, undefined, false, undefined, this),
|
|
1973
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
1974
|
+
className: "sr-only",
|
|
1975
|
+
children: labels.minimize
|
|
1976
|
+
}, undefined, false, undefined, this)
|
|
1977
|
+
]
|
|
1978
|
+
}, undefined, true, undefined, this),
|
|
1979
|
+
/* @__PURE__ */ jsxDEV17(Button, {
|
|
1980
|
+
variant: "ghost",
|
|
1981
|
+
size: "icon-sm",
|
|
1982
|
+
onClick: () => setMaximized((current) => !current),
|
|
1983
|
+
children: [
|
|
1984
|
+
maximized ? /* @__PURE__ */ jsxDEV17(Minimize2Icon, {}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV17(Maximize2Icon, {}, undefined, false, undefined, this),
|
|
1985
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
1986
|
+
className: "sr-only",
|
|
1987
|
+
children: maximized ? labels.restore : labels.maximize
|
|
1988
|
+
}, undefined, false, undefined, this)
|
|
1989
|
+
]
|
|
1990
|
+
}, undefined, true, undefined, this),
|
|
1991
|
+
/* @__PURE__ */ jsxDEV17(DialogClose, {
|
|
1992
|
+
render: /* @__PURE__ */ jsxDEV17(Button, {
|
|
1993
|
+
variant: "ghost",
|
|
1994
|
+
size: "icon-sm"
|
|
1995
|
+
}, undefined, false, undefined, this),
|
|
1996
|
+
children: [
|
|
1997
|
+
/* @__PURE__ */ jsxDEV17(XIcon2, {}, undefined, false, undefined, this),
|
|
1998
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
1999
|
+
className: "sr-only",
|
|
2000
|
+
children: labels.close
|
|
2001
|
+
}, undefined, false, undefined, this)
|
|
2002
|
+
]
|
|
2003
|
+
}, undefined, true, undefined, this)
|
|
2004
|
+
]
|
|
2005
|
+
}, undefined, true, undefined, this)
|
|
2006
|
+
}, undefined, false, undefined, this),
|
|
2007
|
+
/* @__PURE__ */ jsxDEV17("div", {
|
|
2008
|
+
className: "min-h-0 flex-1",
|
|
2009
|
+
children: state.messages.length === 0 && !state.error ? /* @__PURE__ */ jsxDEV17(Empty, {
|
|
2010
|
+
className: "h-full",
|
|
2011
|
+
children: /* @__PURE__ */ jsxDEV17(EmptyHeader, {
|
|
2012
|
+
children: [
|
|
2013
|
+
/* @__PURE__ */ jsxDEV17(EmptyMedia, {
|
|
2014
|
+
variant: "icon",
|
|
2015
|
+
children: /* @__PURE__ */ jsxDEV17(MessageCircleDashedIcon, {}, undefined, false, undefined, this)
|
|
2016
|
+
}, undefined, false, undefined, this),
|
|
2017
|
+
/* @__PURE__ */ jsxDEV17(EmptyTitle, {
|
|
2018
|
+
children: labels.welcome
|
|
2019
|
+
}, undefined, false, undefined, this),
|
|
2020
|
+
/* @__PURE__ */ jsxDEV17(EmptyDescription, {
|
|
2021
|
+
children: labels.description
|
|
2022
|
+
}, undefined, false, undefined, this)
|
|
2023
|
+
]
|
|
2024
|
+
}, undefined, true, undefined, this)
|
|
2025
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV17(MessageScrollerProvider, {
|
|
2026
|
+
autoScroll: true,
|
|
2027
|
+
children: /* @__PURE__ */ jsxDEV17(MessageScroller, {
|
|
2028
|
+
children: [
|
|
2029
|
+
/* @__PURE__ */ jsxDEV17(MessageScrollerViewport, {
|
|
2030
|
+
"aria-label": labels.title,
|
|
2031
|
+
children: /* @__PURE__ */ jsxDEV17(MessageScrollerContent, {
|
|
2032
|
+
"aria-busy": state.pending,
|
|
2033
|
+
className: "p-4",
|
|
2034
|
+
children: [
|
|
2035
|
+
state.messages.map((message, index) => /* @__PURE__ */ jsxDEV17(MessageScrollerItem, {
|
|
2036
|
+
messageId: message.id,
|
|
2037
|
+
scrollAnchor: message.role === "user",
|
|
2038
|
+
children: /* @__PURE__ */ jsxDEV17(AgentMessageRow, {
|
|
2039
|
+
disabled: state.pending,
|
|
2040
|
+
labels,
|
|
2041
|
+
message,
|
|
2042
|
+
onApproval: respondToApproval,
|
|
2043
|
+
pending: state.pending && index === state.messages.length - 1
|
|
2044
|
+
}, undefined, false, undefined, this)
|
|
2045
|
+
}, message.id, false, undefined, this)),
|
|
2046
|
+
state.error ? /* @__PURE__ */ jsxDEV17(MessageScrollerItem, {
|
|
2047
|
+
messageId: "error",
|
|
2048
|
+
children: /* @__PURE__ */ jsxDEV17(Alert, {
|
|
2049
|
+
variant: "destructive",
|
|
2050
|
+
children: [
|
|
2051
|
+
/* @__PURE__ */ jsxDEV17(AlertTitle, {
|
|
2052
|
+
children: labels.title
|
|
2053
|
+
}, undefined, false, undefined, this),
|
|
2054
|
+
/* @__PURE__ */ jsxDEV17(AlertDescription, {
|
|
2055
|
+
children: errorMessage(state.error, labels)
|
|
2056
|
+
}, undefined, false, undefined, this)
|
|
2057
|
+
]
|
|
2058
|
+
}, undefined, true, undefined, this)
|
|
2059
|
+
}, undefined, false, undefined, this) : null
|
|
2060
|
+
]
|
|
2061
|
+
}, undefined, true, undefined, this)
|
|
2062
|
+
}, undefined, false, undefined, this),
|
|
2063
|
+
/* @__PURE__ */ jsxDEV17(MessageScrollerButton, {
|
|
2064
|
+
children: [
|
|
2065
|
+
/* @__PURE__ */ jsxDEV17(ArrowDownIcon2, {}, undefined, false, undefined, this),
|
|
2066
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
2067
|
+
className: "sr-only",
|
|
2068
|
+
children: labels.scrollLatest
|
|
2069
|
+
}, undefined, false, undefined, this)
|
|
2070
|
+
]
|
|
2071
|
+
}, undefined, true, undefined, this)
|
|
2072
|
+
]
|
|
2073
|
+
}, undefined, true, undefined, this)
|
|
2074
|
+
}, undefined, false, undefined, this)
|
|
2075
|
+
}, undefined, false, undefined, this),
|
|
2076
|
+
/* @__PURE__ */ jsxDEV17("form", {
|
|
2077
|
+
className: "shrink-0 border-t p-3",
|
|
2078
|
+
onSubmit: (event) => {
|
|
2079
|
+
event.preventDefault();
|
|
2080
|
+
sendMessage();
|
|
2081
|
+
},
|
|
2082
|
+
children: /* @__PURE__ */ jsxDEV17(InputGroup, {
|
|
2083
|
+
children: [
|
|
2084
|
+
activeContext ? /* @__PURE__ */ jsxDEV17(InputGroupAddon, {
|
|
2085
|
+
align: "block-start",
|
|
2086
|
+
className: "bg-background rounded-t-[calc(var(--radius-md)-1px)] border-b",
|
|
2087
|
+
children: [
|
|
2088
|
+
activeContext.icon,
|
|
2089
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
2090
|
+
className: "min-w-0 flex-1 truncate text-left",
|
|
2091
|
+
children: activeContext.label
|
|
2092
|
+
}, undefined, false, undefined, this),
|
|
2093
|
+
onRemoveContext ? /* @__PURE__ */ jsxDEV17(InputGroupButton, {
|
|
2094
|
+
size: "icon-xs",
|
|
2095
|
+
"aria-label": `${labels.removeContext}: ${activeContext.label}`,
|
|
2096
|
+
onClick: onRemoveContext,
|
|
2097
|
+
children: /* @__PURE__ */ jsxDEV17(XIcon2, {}, undefined, false, undefined, this)
|
|
2098
|
+
}, undefined, false, undefined, this) : null
|
|
2099
|
+
]
|
|
2100
|
+
}, undefined, true, undefined, this) : null,
|
|
2101
|
+
/* @__PURE__ */ jsxDEV17("div", {
|
|
2102
|
+
className: "relative w-full min-w-0 self-stretch text-left",
|
|
2103
|
+
children: [
|
|
2104
|
+
/* @__PURE__ */ jsxDEV17("div", {
|
|
2105
|
+
"aria-hidden": "true",
|
|
2106
|
+
className: "text-foreground pointer-events-none absolute inset-0 overflow-hidden px-2.5 py-2 text-left font-[inherit] text-base break-words whitespace-pre-wrap md:text-sm",
|
|
2107
|
+
children: highlightedInput(input, references)
|
|
2108
|
+
}, undefined, false, undefined, this),
|
|
2109
|
+
/* @__PURE__ */ jsxDEV17(Popover, {
|
|
2110
|
+
open: referencePickerOpen,
|
|
2111
|
+
triggerId: referenceInputId,
|
|
2112
|
+
children: [
|
|
2113
|
+
/* @__PURE__ */ jsxDEV17(PopoverTrigger, {
|
|
2114
|
+
id: referenceInputId,
|
|
2115
|
+
render: /* @__PURE__ */ jsxDEV17(InputGroupTextarea, {
|
|
2116
|
+
className: "caret-foreground selection:bg-primary selection:text-primary-foreground relative w-full text-left text-transparent",
|
|
2117
|
+
value: input,
|
|
2118
|
+
placeholder: labels.placeholder,
|
|
2119
|
+
"aria-label": labels.placeholder,
|
|
2120
|
+
"aria-activedescendant": referencePickerOpen && activeReference ? `${referenceInputId}-reference-${activeReferenceIndex}` : undefined,
|
|
2121
|
+
"aria-autocomplete": "list",
|
|
2122
|
+
"aria-controls": referenceListId,
|
|
2123
|
+
"aria-expanded": referencePickerOpen,
|
|
2124
|
+
disabled: state.pending || hasPendingApproval,
|
|
2125
|
+
role: "combobox",
|
|
2126
|
+
rows: 2,
|
|
2127
|
+
onChange: (event) => {
|
|
2128
|
+
const value = event.target.value;
|
|
2129
|
+
setInput(value);
|
|
2130
|
+
setReferences((current) => current.filter(({ label }) => hasReferenceMention(value, label)));
|
|
2131
|
+
const query = referenceSearchQuery(value);
|
|
2132
|
+
const startsReferenceQuery = query !== undefined && value.lastIndexOf("@") > input.lastIndexOf("@");
|
|
2133
|
+
setReferencePickerOpen((current) => current || startsReferenceQuery && selectableReferences.length > 0);
|
|
2134
|
+
},
|
|
2135
|
+
onKeyDown: (event) => {
|
|
2136
|
+
if (event.key === "Escape" && referencePickerOpen) {
|
|
2137
|
+
event.preventDefault();
|
|
2138
|
+
setReferencePickerOpen(false);
|
|
2139
|
+
return;
|
|
2140
|
+
}
|
|
2141
|
+
if (referencePickerOpen && (event.key === "ArrowDown" || event.key === "ArrowUp") && matchingReferences.length > 0) {
|
|
2142
|
+
event.preventDefault();
|
|
2143
|
+
const offset = event.key === "ArrowDown" ? 1 : -1;
|
|
2144
|
+
const nextIndex = Math.min(matchingReferences.length - 1, Math.max(0, activeReferenceIndex + offset));
|
|
2145
|
+
setActiveReferenceKey(matchingReferences[nextIndex].key);
|
|
2146
|
+
return;
|
|
2147
|
+
}
|
|
2148
|
+
if (event.key === "Enter" && !event.shiftKey && referencePickerOpen && activeReference) {
|
|
2149
|
+
event.preventDefault();
|
|
2150
|
+
selectReference(activeReference);
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2153
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
2154
|
+
event.preventDefault();
|
|
2155
|
+
event.currentTarget.form?.requestSubmit();
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
}, undefined, false, undefined, this)
|
|
2159
|
+
}, undefined, false, undefined, this),
|
|
2160
|
+
/* @__PURE__ */ jsxDEV17(PopoverContent, {
|
|
2161
|
+
align: "start",
|
|
2162
|
+
initialFocus: false,
|
|
2163
|
+
side: "top",
|
|
2164
|
+
className: "w-[min(24rem,calc(100vw-2rem))] p-0",
|
|
2165
|
+
children: /* @__PURE__ */ jsxDEV17(Command, {
|
|
2166
|
+
shouldFilter: false,
|
|
2167
|
+
value: activeReference?.key ?? "",
|
|
2168
|
+
onValueChange: setActiveReferenceKey,
|
|
2169
|
+
children: /* @__PURE__ */ jsxDEV17(CommandList, {
|
|
2170
|
+
id: referenceListId,
|
|
2171
|
+
children: [
|
|
2172
|
+
/* @__PURE__ */ jsxDEV17(CommandEmpty, {
|
|
2173
|
+
children: labels.noReferences
|
|
2174
|
+
}, undefined, false, undefined, this),
|
|
2175
|
+
/* @__PURE__ */ jsxDEV17(CommandGroup, {
|
|
2176
|
+
heading: labels.references,
|
|
2177
|
+
children: matchingReferences.map((reference, index) => /* @__PURE__ */ jsxDEV17(CommandItem, {
|
|
2178
|
+
id: `${referenceInputId}-reference-${index}`,
|
|
2179
|
+
value: reference.key,
|
|
2180
|
+
onSelect: () => selectReference(reference),
|
|
2181
|
+
children: [
|
|
2182
|
+
reference.icon,
|
|
2183
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
2184
|
+
className: "truncate",
|
|
2185
|
+
children: reference.label
|
|
2186
|
+
}, undefined, false, undefined, this)
|
|
2187
|
+
]
|
|
2188
|
+
}, reference.key, true, undefined, this))
|
|
2189
|
+
}, undefined, false, undefined, this)
|
|
2190
|
+
]
|
|
2191
|
+
}, undefined, true, undefined, this)
|
|
2192
|
+
}, undefined, false, undefined, this)
|
|
2193
|
+
}, undefined, false, undefined, this)
|
|
2194
|
+
]
|
|
2195
|
+
}, undefined, true, undefined, this)
|
|
2196
|
+
]
|
|
2197
|
+
}, undefined, true, undefined, this),
|
|
2198
|
+
/* @__PURE__ */ jsxDEV17(InputGroupAddon, {
|
|
2199
|
+
align: "block-end",
|
|
2200
|
+
className: "justify-end",
|
|
2201
|
+
children: state.pending ? /* @__PURE__ */ jsxDEV17(InputGroupButton, {
|
|
2202
|
+
size: "icon-xs",
|
|
2203
|
+
onClick: onInterrupt,
|
|
2204
|
+
children: [
|
|
2205
|
+
/* @__PURE__ */ jsxDEV17(SquareIcon, {}, undefined, false, undefined, this),
|
|
2206
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
2207
|
+
className: "sr-only",
|
|
2208
|
+
children: labels.stop
|
|
2209
|
+
}, undefined, false, undefined, this)
|
|
2210
|
+
]
|
|
2211
|
+
}, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV17(InputGroupButton, {
|
|
2212
|
+
type: "submit",
|
|
2213
|
+
size: "icon-xs",
|
|
2214
|
+
disabled: !input.trim() || hasPendingApproval,
|
|
2215
|
+
children: [
|
|
2216
|
+
/* @__PURE__ */ jsxDEV17(SendIcon, {}, undefined, false, undefined, this),
|
|
2217
|
+
/* @__PURE__ */ jsxDEV17("span", {
|
|
2218
|
+
className: "sr-only",
|
|
2219
|
+
children: labels.send
|
|
2220
|
+
}, undefined, false, undefined, this)
|
|
2221
|
+
]
|
|
2222
|
+
}, undefined, true, undefined, this)
|
|
2223
|
+
}, undefined, false, undefined, this)
|
|
2224
|
+
]
|
|
2225
|
+
}, undefined, true, undefined, this)
|
|
2226
|
+
}, undefined, false, undefined, this)
|
|
2227
|
+
]
|
|
2228
|
+
}, undefined, true, undefined, this)
|
|
2229
|
+
}, undefined, false, undefined, this)
|
|
2230
|
+
]
|
|
2231
|
+
}, undefined, true, undefined, this);
|
|
2232
|
+
}
|
|
2233
|
+
export {
|
|
2234
|
+
reduceAgentEvent,
|
|
2235
|
+
makeAgentAtoms,
|
|
2236
|
+
initialAgentState,
|
|
2237
|
+
agentWidgetMessages,
|
|
2238
|
+
AgentWidget
|
|
2239
|
+
};
|