@duskmoon-dev/components 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,30 +1,14 @@
1
1
  "use client";
2
2
 
3
- // src/components/chat/Chat.tsx
4
- import {
5
- forwardRef as forwardRef5,
6
- useId as useId3,
7
- useLayoutEffect as useLayoutEffect4,
8
- useRef as useRef5,
9
- useState as useState3
10
- } from "react";
11
-
12
- // src/components/chat/ChatComposer.tsx
3
+ // src/components/chat/ChatRequest.tsx
13
4
  import {
14
- forwardRef as forwardRef3,
5
+ forwardRef,
15
6
  useId,
16
- useLayoutEffect as useLayoutEffect3,
17
- useRef as useRef4,
18
- useState as useState2
7
+ useImperativeHandle,
8
+ useLayoutEffect,
9
+ useRef
19
10
  } from "react";
20
11
 
21
- // src/components/chat/composer/ComposerShell.tsx
22
- import { forwardRef, useEffect, useRef as useRef2, useState } from "react";
23
-
24
- // src/components/button/Button.tsx
25
- import React from "react";
26
- import { createPortal } from "react-dom";
27
-
28
12
  // ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
29
13
  function r(e) {
30
14
  var t, f, n = "";
@@ -50,6 +34,185 @@ function clsx() {
50
34
  function cn(...inputs) {
51
35
  return clsx(inputs);
52
36
  }
37
+ // src/components/chat/ChatRequest.tsx
38
+ import { jsx, jsxs } from "react/jsx-runtime";
39
+ var stateLabels = {
40
+ pending: "Awaiting approval",
41
+ approved: "Approved",
42
+ "approved-for-session": "Approved for this session",
43
+ declined: "Declined",
44
+ expired: "Expired",
45
+ "answer-elsewhere": "Answer elsewhere"
46
+ };
47
+ var ChatRequest = forwardRef(({
48
+ title,
49
+ state = "pending",
50
+ pending = false,
51
+ statusLabel,
52
+ actions = [],
53
+ explanation,
54
+ children,
55
+ className,
56
+ onFocusCapture,
57
+ onBlurCapture,
58
+ ...props
59
+ }, ref) => {
60
+ const id = useId();
61
+ const root = useRef(null);
62
+ const focusedAction = useRef(null);
63
+ useImperativeHandle(ref, () => root.current, []);
64
+ useLayoutEffect(() => {
65
+ const element = root.current;
66
+ const action = focusedAction.current;
67
+ if (element && action && !element.contains(action) && document.activeElement === document.body) {
68
+ element.focus({ preventScroll: true });
69
+ focusedAction.current = null;
70
+ }
71
+ });
72
+ return /* @__PURE__ */ jsxs("div", {
73
+ ...props,
74
+ ref: root,
75
+ className: cn("chat-approval", className),
76
+ "data-state": state,
77
+ role: props.role ?? "group",
78
+ tabIndex: props.tabIndex ?? -1,
79
+ "aria-labelledby": props["aria-labelledby"] ?? `${id}-title`,
80
+ "aria-busy": pending,
81
+ onFocusCapture: (event) => {
82
+ const target = event.target;
83
+ focusedAction.current = target.closest("[data-chat-request-action]");
84
+ onFocusCapture?.(event);
85
+ },
86
+ onBlurCapture: (event) => {
87
+ if (event.relatedTarget)
88
+ focusedAction.current = null;
89
+ onBlurCapture?.(event);
90
+ },
91
+ children: [
92
+ /* @__PURE__ */ jsxs("div", {
93
+ className: "chat-approval-header",
94
+ children: [
95
+ /* @__PURE__ */ jsx("div", {
96
+ id: `${id}-title`,
97
+ className: "chat-approval-title",
98
+ children: title
99
+ }),
100
+ /* @__PURE__ */ jsx("span", {
101
+ className: "chat-approval-status",
102
+ role: "status",
103
+ "aria-live": "polite",
104
+ "aria-atomic": "true",
105
+ children: statusLabel ?? (state === "pending" && pending ? "Decision pending" : stateLabels[state])
106
+ })
107
+ ]
108
+ }),
109
+ children != null || explanation != null ? /* @__PURE__ */ jsxs("div", {
110
+ className: "chat-approval-details",
111
+ children: [
112
+ children,
113
+ explanation
114
+ ]
115
+ }) : null,
116
+ state === "pending" && actions.length > 0 ? /* @__PURE__ */ jsx("div", {
117
+ className: "chat-approval-actions",
118
+ children: actions.map((action) => /* @__PURE__ */ jsx("button", {
119
+ type: "button",
120
+ "data-chat-request-action": "",
121
+ className: cn("btn btn-sm", action.tone === "primary" && "btn-primary", action.tone === "danger" && "btn-error", action.tone === undefined && "btn-outline"),
122
+ "aria-label": action.ariaLabel,
123
+ disabled: pending || action.disabled,
124
+ onClick: action.onSelect,
125
+ children: action.label
126
+ }, action.id))
127
+ }) : null
128
+ ]
129
+ });
130
+ });
131
+ ChatRequest.displayName = "Chat.Request";
132
+
133
+ // src/components/chat/ChatComposerContext.tsx
134
+ import { forwardRef as forwardRef2 } from "react";
135
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
136
+ var ChatComposerContext = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx2("div", {
137
+ role: "group",
138
+ "aria-label": "Composer context",
139
+ ...props,
140
+ ref,
141
+ className: cn("chat-composer-context", className)
142
+ }));
143
+ ChatComposerContext.displayName = "Chat.ComposerContext";
144
+ var ChatComposerContextItem = forwardRef2(({ icon, action, children, className, ...props }, ref) => /* @__PURE__ */ jsxs2("span", {
145
+ ...props,
146
+ ref,
147
+ className: cn("chat-composer-context-item", className),
148
+ children: [
149
+ icon ? /* @__PURE__ */ jsx2("span", {
150
+ className: "chat-composer-context-icon",
151
+ "aria-hidden": "true",
152
+ children: icon
153
+ }) : null,
154
+ /* @__PURE__ */ jsx2("span", {
155
+ className: "chat-composer-context-label",
156
+ children
157
+ }),
158
+ action ? /* @__PURE__ */ jsx2("button", {
159
+ type: "button",
160
+ className: "btn btn-ghost btn-xs",
161
+ "aria-label": action.label,
162
+ title: action.label,
163
+ disabled: action.disabled,
164
+ onClick: action.onClick,
165
+ children: action.children ?? action.label
166
+ }) : null
167
+ ]
168
+ }));
169
+ ChatComposerContextItem.displayName = "Chat.ComposerContextItem";
170
+ var ChatComposerContextEnd = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx2("span", {
171
+ ...props,
172
+ ref,
173
+ className: cn("chat-composer-context-end", className)
174
+ }));
175
+ ChatComposerContextEnd.displayName = "Chat.ComposerContextEnd";
176
+ var connectionLabels = {
177
+ connected: "Connected",
178
+ connecting: "Connecting",
179
+ disconnected: "Disconnected"
180
+ };
181
+ var ChatComposerConnection = forwardRef2(({ state, label, className, ...props }, ref) => /* @__PURE__ */ jsx2("span", {
182
+ role: "status",
183
+ ...props,
184
+ ref,
185
+ "data-state": state,
186
+ className: cn("chat-composer-connection", className),
187
+ children: label ?? connectionLabels[state]
188
+ }));
189
+ ChatComposerConnection.displayName = "Chat.ComposerConnection";
190
+
191
+ // src/components/chat/Chat.tsx
192
+ import {
193
+ forwardRef as forwardRef7,
194
+ useId as useId4,
195
+ useLayoutEffect as useLayoutEffect5,
196
+ useRef as useRef6,
197
+ useState as useState3
198
+ } from "react";
199
+
200
+ // src/components/chat/ChatComposer.tsx
201
+ import {
202
+ forwardRef as forwardRef5,
203
+ useId as useId2,
204
+ useLayoutEffect as useLayoutEffect4,
205
+ useRef as useRef5,
206
+ useState as useState2
207
+ } from "react";
208
+
209
+ // src/components/chat/composer/ComposerShell.tsx
210
+ import { forwardRef as forwardRef3, useEffect, useRef as useRef3, useState } from "react";
211
+
212
+ // src/components/button/Button.tsx
213
+ import React3 from "react";
214
+ import { createPortal } from "react-dom";
215
+
53
216
  // src/classes/button.ts
54
217
  var buttonBaseClass = "btn";
55
218
  var buttonColorClasses = {
@@ -97,7 +260,7 @@ function getButtonClasses({
97
260
  }
98
261
 
99
262
  // src/components/button/Button.tsx
100
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
263
+ import { jsx as jsx3, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
101
264
  function isPromiseLike(value) {
102
265
  return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
103
266
  }
@@ -118,18 +281,18 @@ function Button({
118
281
  onClick,
119
282
  ...props
120
283
  }) {
121
- const buttonRef = React.useRef(null);
122
- const popoverRef = React.useRef(null);
123
- const cancelRef = React.useRef(null);
124
- const approvalRef = React.useRef("idle");
125
- const pendingRef = React.useRef(false);
126
- const actionRef = React.useRef(0);
127
- const operationRef = React.useRef(0);
128
- const mountedRef = React.useRef(false);
129
- const [portalTarget, setPortalTarget] = React.useState(null);
130
- const [confirmLoading, setConfirmLoading] = React.useState(false);
131
- const [confirmError, setConfirmError] = React.useState(false);
132
- const generatedId = React.useId().replace(/:/g, "");
284
+ const buttonRef = React3.useRef(null);
285
+ const popoverRef = React3.useRef(null);
286
+ const cancelRef = React3.useRef(null);
287
+ const approvalRef = React3.useRef("idle");
288
+ const pendingRef = React3.useRef(false);
289
+ const actionRef = React3.useRef(0);
290
+ const operationRef = React3.useRef(0);
291
+ const mountedRef = React3.useRef(false);
292
+ const [portalTarget, setPortalTarget] = React3.useState(null);
293
+ const [confirmLoading, setConfirmLoading] = React3.useState(false);
294
+ const [confirmError, setConfirmError] = React3.useState(false);
295
+ const generatedId = React3.useId().replace(/:/g, "");
133
296
  const popoverId = `button-confirm-${generatedId}`;
134
297
  const titleId = `${popoverId}-title`;
135
298
  const descriptionId = `${popoverId}-description`;
@@ -140,7 +303,7 @@ function Button({
140
303
  const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
141
304
  const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
142
305
  const hasContent = content !== undefined && content !== null && content !== false && content !== "";
143
- const mergedRef = React.useCallback((node) => {
306
+ const mergedRef = React3.useCallback((node) => {
144
307
  buttonRef.current = node;
145
308
  if (!node) {
146
309
  if (typeof ref === "function")
@@ -162,14 +325,14 @@ function Button({
162
325
  ref.current = null;
163
326
  };
164
327
  }, [ref]);
165
- React.useEffect(() => {
328
+ React3.useEffect(() => {
166
329
  mountedRef.current = true;
167
330
  return () => {
168
331
  mountedRef.current = false;
169
332
  operationRef.current += 1;
170
333
  };
171
334
  }, []);
172
- React.useEffect(() => {
335
+ React3.useEffect(() => {
173
336
  operationRef.current += 1;
174
337
  approvalRef.current = "idle";
175
338
  setConfirmError(false);
@@ -277,9 +440,9 @@ function Button({
277
440
  size: "sm",
278
441
  isLoading: confirmLoading
279
442
  });
280
- return /* @__PURE__ */ jsxs(Fragment, {
443
+ return /* @__PURE__ */ jsxs3(Fragment, {
281
444
  children: [
282
- /* @__PURE__ */ jsxs("button", {
445
+ /* @__PURE__ */ jsxs3("button", {
283
446
  ref: confirm ? mergedRef : ref,
284
447
  className: classes,
285
448
  disabled: disabled || isLoading,
@@ -291,24 +454,24 @@ function Button({
291
454
  "aria-controls": confirm ? popoverId : props["aria-controls"],
292
455
  onClick: confirm ? handleClick : onClick,
293
456
  children: [
294
- isLoading && /* @__PURE__ */ jsx("span", {
457
+ isLoading && /* @__PURE__ */ jsx3("span", {
295
458
  className: "btn-spinner"
296
459
  }),
297
- !isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
460
+ !isLoading && leftIcon && /* @__PURE__ */ jsx3("span", {
298
461
  className: "btn-icon-left",
299
462
  children: leftIcon
300
463
  }),
301
- /* @__PURE__ */ jsx("span", {
464
+ /* @__PURE__ */ jsx3("span", {
302
465
  className: "btn-content",
303
466
  children
304
467
  }),
305
- !isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
468
+ !isLoading && rightIcon && /* @__PURE__ */ jsx3("span", {
306
469
  className: "btn-icon-right",
307
470
  children: rightIcon
308
471
  })
309
472
  ]
310
473
  }),
311
- confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs("form", {
474
+ confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs3("form", {
312
475
  id: popoverId,
313
476
  ref: popoverRef,
314
477
  popover: "auto",
@@ -329,28 +492,28 @@ function Button({
329
492
  }
330
493
  },
331
494
  children: [
332
- hasTitle && /* @__PURE__ */ jsx("div", {
495
+ hasTitle && /* @__PURE__ */ jsx3("div", {
333
496
  className: "popover-header",
334
- children: /* @__PURE__ */ jsx("h3", {
497
+ children: /* @__PURE__ */ jsx3("h3", {
335
498
  id: titleId,
336
499
  className: "popover-title",
337
500
  children: title
338
501
  })
339
502
  }),
340
- hasContent && /* @__PURE__ */ jsx("div", {
503
+ hasContent && /* @__PURE__ */ jsx3("div", {
341
504
  id: descriptionId,
342
505
  className: "popover-body",
343
506
  children: content
344
507
  }),
345
- confirmError && /* @__PURE__ */ jsx("div", {
508
+ confirmError && /* @__PURE__ */ jsx3("div", {
346
509
  role: "alert",
347
510
  className: "popover-body",
348
511
  children: "The action failed. Please try again."
349
512
  }),
350
- /* @__PURE__ */ jsxs("div", {
513
+ /* @__PURE__ */ jsxs3("div", {
351
514
  className: "popover-footer",
352
515
  children: [
353
- /* @__PURE__ */ jsx("button", {
516
+ /* @__PURE__ */ jsx3("button", {
354
517
  ref: cancelRef,
355
518
  type: "button",
356
519
  className: "btn btn-text btn-sm",
@@ -359,7 +522,7 @@ function Button({
359
522
  disabled: confirmLoading,
360
523
  children: confirmation?.cancelText ?? "Cancel"
361
524
  }),
362
- /* @__PURE__ */ jsx("button", {
525
+ /* @__PURE__ */ jsx3("button", {
363
526
  type: "submit",
364
527
  className: confirmClasses,
365
528
  disabled: disabled || isLoading || confirmLoading,
@@ -374,8 +537,8 @@ function Button({
374
537
  });
375
538
  }
376
539
  // src/components/chat/composer/CompletionList.tsx
377
- import React2, { useLayoutEffect, useRef } from "react";
378
- import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
540
+ import React4, { useLayoutEffect as useLayoutEffect2, useRef as useRef2 } from "react";
541
+ import { jsx as jsx4, jsxs as jsxs4, Fragment as Fragment2 } from "react/jsx-runtime";
379
542
  function completionOptionId(composerId, candidateId) {
380
543
  return `${composerId}-option-${encodeURIComponent(candidateId)}`;
381
544
  }
@@ -391,12 +554,12 @@ function CompletionList({
391
554
  status,
392
555
  onDismiss
393
556
  }) {
394
- const surface = useRef(null);
395
- useLayoutEffect(() => {
557
+ const surface = useRef2(null);
558
+ useLayoutEffect2(() => {
396
559
  if (compact)
397
560
  surface.current?.showPopover?.();
398
561
  }, [compact]);
399
- useLayoutEffect(() => {
562
+ useLayoutEffect2(() => {
400
563
  const tray = surface.current;
401
564
  const option = tray?.querySelector('[aria-selected="true"]');
402
565
  if (!compact || !tray || !option)
@@ -410,20 +573,20 @@ function CompletionList({
410
573
  else if (selected.bottom > bottom)
411
574
  tray.scrollTop += selected.bottom - bottom;
412
575
  }, [compact, activeId, candidates]);
413
- const list = candidates.length ? /* @__PURE__ */ jsx2("ul", {
576
+ const list = candidates.length ? /* @__PURE__ */ jsx4("ul", {
414
577
  id: `${composerId}-completions`,
415
578
  role: "listbox",
416
579
  "aria-label": label,
417
580
  className: compact ? "chat-composer-completion-list" : "chat-composer-completions",
418
- children: candidates.map((item, index) => /* @__PURE__ */ jsxs2(React2.Fragment, {
581
+ children: candidates.map((item, index) => /* @__PURE__ */ jsxs4(React4.Fragment, {
419
582
  children: [
420
- item.group && candidates[index - 1]?.group !== item.group ? /* @__PURE__ */ jsx2("li", {
583
+ item.group && candidates[index - 1]?.group !== item.group ? /* @__PURE__ */ jsx4("li", {
421
584
  role: "presentation",
422
585
  className: "chat-composer-group",
423
586
  "aria-hidden": "true",
424
587
  children: item.group
425
588
  }) : null,
426
- /* @__PURE__ */ jsxs2("li", {
589
+ /* @__PURE__ */ jsxs4("li", {
427
590
  id: completionOptionId(composerId, item.id),
428
591
  className: compact ? "chat-composer-option chat-composer-option-compact" : "chat-composer-option",
429
592
  role: "option",
@@ -442,22 +605,22 @@ function CompletionList({
442
605
  }
443
606
  },
444
607
  children: [
445
- compact && item.icon ? /* @__PURE__ */ jsx2("span", {
608
+ compact && item.icon ? /* @__PURE__ */ jsx4("span", {
446
609
  className: "chat-composer-option-icon",
447
610
  "aria-hidden": "true",
448
611
  children: item.icon
449
612
  }) : null,
450
- /* @__PURE__ */ jsx2("span", {
613
+ /* @__PURE__ */ jsx4("span", {
451
614
  className: compact ? "chat-composer-label" : undefined,
452
615
  title: item.label,
453
616
  children: item.label
454
617
  }),
455
- item.description ? /* @__PURE__ */ jsx2("span", {
618
+ item.description ? /* @__PURE__ */ jsx4("span", {
456
619
  className: compact ? "chat-composer-description chat-composer-option-description" : "chat-composer-description",
457
620
  title: typeof item.description === "string" ? item.description : undefined,
458
621
  children: item.description
459
622
  }) : null,
460
- compact && item.sourceLabel ? /* @__PURE__ */ jsx2("span", {
623
+ compact && item.sourceLabel ? /* @__PURE__ */ jsx4("span", {
461
624
  className: "chat-composer-description chat-composer-option-source",
462
625
  children: item.sourceLabel
463
626
  }) : null
@@ -466,7 +629,7 @@ function CompletionList({
466
629
  ]
467
630
  }, item.id))
468
631
  }) : null;
469
- return compact ? /* @__PURE__ */ jsxs2("div", {
632
+ return compact ? /* @__PURE__ */ jsxs4("div", {
470
633
  ref: surface,
471
634
  popover: "auto",
472
635
  className: "chat-composer-completions chat-composer-completions-compact",
@@ -480,7 +643,7 @@ function CompletionList({
480
643
  list,
481
644
  status
482
645
  ]
483
- }) : /* @__PURE__ */ jsxs2(Fragment2, {
646
+ }) : /* @__PURE__ */ jsxs4(Fragment2, {
484
647
  children: [
485
648
  header,
486
649
  status,
@@ -490,9 +653,9 @@ function CompletionList({
490
653
  }
491
654
 
492
655
  // src/components/chat/composer/ComposerShell.tsx
493
- import { jsx as jsx3, jsxs as jsxs3, Fragment as Fragment3 } from "react/jsx-runtime";
656
+ import { jsx as jsx5, jsxs as jsxs5, Fragment as Fragment3 } from "react/jsx-runtime";
494
657
  function AttachmentPreview({ file }) {
495
- const imageRef = useRef2(null);
658
+ const imageRef = useRef3(null);
496
659
  useEffect(() => {
497
660
  const image = imageRef.current;
498
661
  if (!image || !file.type.startsWith("image/") || !URL.createObjectURL)
@@ -506,7 +669,7 @@ function AttachmentPreview({ file }) {
506
669
  URL.revokeObjectURL(objectUrl);
507
670
  };
508
671
  }, [file]);
509
- return file.type.startsWith("image/") ? /* @__PURE__ */ jsx3("img", {
672
+ return file.type.startsWith("image/") ? /* @__PURE__ */ jsx5("img", {
510
673
  ref: imageRef,
511
674
  className: "chat-composer-preview",
512
675
  alt: file.name,
@@ -516,7 +679,7 @@ function AttachmentPreview({ file }) {
516
679
  function ComposerIcon({
517
680
  action
518
681
  }) {
519
- return /* @__PURE__ */ jsx3("svg", {
682
+ return /* @__PURE__ */ jsx5("svg", {
520
683
  width: "18",
521
684
  height: "18",
522
685
  viewBox: "0 0 24 24",
@@ -527,11 +690,11 @@ function ComposerIcon({
527
690
  strokeLinejoin: "round",
528
691
  "aria-hidden": "true",
529
692
  focusable: "false",
530
- children: action === "attach" ? /* @__PURE__ */ jsx3("path", {
693
+ children: action === "attach" ? /* @__PURE__ */ jsx5("path", {
531
694
  d: "M12 5v14M5 12h14"
532
- }) : action === "send" ? /* @__PURE__ */ jsx3("path", {
695
+ }) : action === "send" ? /* @__PURE__ */ jsx5("path", {
533
696
  d: "m5 12 7-7 7 7M12 5v14"
534
- }) : action === "stop" ? /* @__PURE__ */ jsx3("rect", {
697
+ }) : action === "stop" ? /* @__PURE__ */ jsx5("rect", {
535
698
  x: "6",
536
699
  y: "6",
537
700
  width: "12",
@@ -539,9 +702,9 @@ function ComposerIcon({
539
702
  rx: "1",
540
703
  fill: "currentColor",
541
704
  stroke: "none"
542
- }) : action === "retry" ? /* @__PURE__ */ jsx3("path", {
705
+ }) : action === "retry" ? /* @__PURE__ */ jsx5("path", {
543
706
  d: "M3 11a9 9 0 1 1 2.6 7.4M3 4v7h7"
544
- }) : /* @__PURE__ */ jsx3("path", {
707
+ }) : /* @__PURE__ */ jsx5("path", {
545
708
  d: "m6 6 12 12M6 18 18 6"
546
709
  })
547
710
  });
@@ -559,11 +722,12 @@ function ExtraActions({
559
722
  }) {
560
723
  return typeof children === "function" ? children(context) : children;
561
724
  }
562
- var ComposerShell = forwardRef(({
725
+ var ComposerShell = forwardRef3(({
563
726
  editor,
564
727
  composerId,
565
728
  compact = false,
566
729
  addMenu,
730
+ context,
567
731
  entries,
568
732
  renderAttachment,
569
733
  removeAttachment,
@@ -605,9 +769,9 @@ var ComposerShell = forwardRef(({
605
769
  const addAnchor = `--composer-add-${composerId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
606
770
  const completionAnchor = `--composer-completions-${composerId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
607
771
  const thumbnails = compact && entries.length > 0 && !renderAttachment && entries.every(({ file, previewUrl, state, status, progress, retry, cancel }) => (previewUrl || file?.type.startsWith("image/") && typeof URL.createObjectURL === "function") && (!state || state === "ready") && !status && progress === undefined && !retry && !cancel);
608
- const attachmentAction = onAttachmentsChange ? /* @__PURE__ */ jsxs3(Fragment3, {
772
+ const attachmentAction = onAttachmentsChange ? /* @__PURE__ */ jsxs5(Fragment3, {
609
773
  children: [
610
- /* @__PURE__ */ jsx3("input", {
774
+ /* @__PURE__ */ jsx5("input", {
611
775
  ref: pickerRef,
612
776
  type: "file",
613
777
  accept,
@@ -622,7 +786,7 @@ var ComposerShell = forwardRef(({
622
786
  addAttachments(files, "picker");
623
787
  }
624
788
  }),
625
- /* @__PURE__ */ jsx3(Button, {
789
+ /* @__PURE__ */ jsx5(Button, {
626
790
  type: "button",
627
791
  color: "base",
628
792
  appearance: "ghost",
@@ -632,15 +796,15 @@ var ComposerShell = forwardRef(({
632
796
  title: attachLabel,
633
797
  disabled,
634
798
  onClick: openAttachments,
635
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
799
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
636
800
  action: "attach"
637
801
  })
638
802
  })
639
803
  ]
640
804
  }) : null;
641
- const actionContent = /* @__PURE__ */ jsxs3(Fragment3, {
805
+ const actionContent = /* @__PURE__ */ jsxs5(Fragment3, {
642
806
  children: [
643
- /* @__PURE__ */ jsx3(ExtraActions, {
807
+ /* @__PURE__ */ jsx5(ExtraActions, {
644
808
  context: {
645
809
  submit: () => {
646
810
  submit();
@@ -653,7 +817,7 @@ var ComposerShell = forwardRef(({
653
817
  },
654
818
  children
655
819
  }),
656
- generating && onStop && (!compact || !eligible) ? /* @__PURE__ */ jsx3(Button, {
820
+ generating && onStop && (!compact || !eligible) ? /* @__PURE__ */ jsx5(Button, {
657
821
  type: "button",
658
822
  color: compact ? "primary" : undefined,
659
823
  size: "sm",
@@ -662,11 +826,11 @@ var ComposerShell = forwardRef(({
662
826
  title: stopLabel,
663
827
  disabled,
664
828
  onClick: onStop,
665
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
829
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
666
830
  action: "stop"
667
831
  })
668
832
  }) : null,
669
- !compact || !generating || !onStop || eligible ? /* @__PURE__ */ jsx3(Button, {
833
+ !compact || !generating || !onStop || eligible ? /* @__PURE__ */ jsx5(Button, {
670
834
  type: "button",
671
835
  color: "primary",
672
836
  size: "sm",
@@ -678,19 +842,19 @@ var ComposerShell = forwardRef(({
678
842
  onClick: () => {
679
843
  submit();
680
844
  },
681
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
845
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
682
846
  action: "send"
683
847
  })
684
848
  }) : null
685
849
  ]
686
850
  });
687
851
  function renderToolbar(menuContent) {
688
- return compact ? /* @__PURE__ */ jsxs3("div", {
852
+ return compact ? /* @__PURE__ */ jsxs5("div", {
689
853
  className: "chat-composer-toolbar chat-composer-toolbar-compact",
690
854
  children: [
691
- onAttachmentsChange || addMenu || menuContent ? /* @__PURE__ */ jsxs3(Fragment3, {
855
+ onAttachmentsChange || addMenu || menuContent ? /* @__PURE__ */ jsxs5(Fragment3, {
692
856
  children: [
693
- /* @__PURE__ */ jsx3(Button, {
857
+ /* @__PURE__ */ jsx5(Button, {
694
858
  type: "button",
695
859
  color: "base",
696
860
  appearance: "ghost",
@@ -703,11 +867,11 @@ var ComposerShell = forwardRef(({
703
867
  "aria-controls": addId,
704
868
  "aria-expanded": addOpen,
705
869
  style: { anchorName: addAnchor },
706
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
870
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
707
871
  action: "attach"
708
872
  })
709
873
  }),
710
- /* @__PURE__ */ jsxs3("div", {
874
+ /* @__PURE__ */ jsxs5("div", {
711
875
  id: addId,
712
876
  popover: "auto",
713
877
  role: "group",
@@ -716,13 +880,13 @@ var ComposerShell = forwardRef(({
716
880
  style: { positionAnchor: addAnchor },
717
881
  onToggle: (event) => setAddOpen(event.currentTarget.matches(":popover-open")),
718
882
  children: [
719
- /* @__PURE__ */ jsx3("div", {
883
+ /* @__PURE__ */ jsx5("div", {
720
884
  className: "chat-composer-group",
721
885
  children: "Add"
722
886
  }),
723
- onAttachmentsChange ? /* @__PURE__ */ jsxs3(Fragment3, {
887
+ onAttachmentsChange ? /* @__PURE__ */ jsxs5(Fragment3, {
724
888
  children: [
725
- /* @__PURE__ */ jsx3("input", {
889
+ /* @__PURE__ */ jsx5("input", {
726
890
  ref: pickerRef,
727
891
  type: "file",
728
892
  accept,
@@ -737,7 +901,7 @@ var ComposerShell = forwardRef(({
737
901
  addAttachments(files, "picker");
738
902
  }
739
903
  }),
740
- /* @__PURE__ */ jsxs3("button", {
904
+ /* @__PURE__ */ jsxs5("button", {
741
905
  type: "button",
742
906
  className: "popover-menu-item",
743
907
  disabled,
@@ -746,10 +910,10 @@ var ComposerShell = forwardRef(({
746
910
  openAttachments();
747
911
  },
748
912
  children: [
749
- /* @__PURE__ */ jsx3(ComposerIcon, {
913
+ /* @__PURE__ */ jsx5(ComposerIcon, {
750
914
  action: "attach"
751
915
  }),
752
- /* @__PURE__ */ jsx3("span", {
916
+ /* @__PURE__ */ jsx5("span", {
753
917
  children: "Files"
754
918
  })
755
919
  ]
@@ -762,12 +926,12 @@ var ComposerShell = forwardRef(({
762
926
  })
763
927
  ]
764
928
  }) : null,
765
- /* @__PURE__ */ jsx3("div", {
929
+ /* @__PURE__ */ jsx5("div", {
766
930
  className: "chat-composer-actions",
767
931
  children: actionContent
768
932
  })
769
933
  ]
770
- }) : /* @__PURE__ */ jsxs3("div", {
934
+ }) : /* @__PURE__ */ jsxs5("div", {
771
935
  className: "chat-composer-actions",
772
936
  children: [
773
937
  attachmentAction,
@@ -775,10 +939,10 @@ var ComposerShell = forwardRef(({
775
939
  ]
776
940
  });
777
941
  }
778
- return /* @__PURE__ */ jsxs3("div", {
942
+ return /* @__PURE__ */ jsxs5("div", {
779
943
  ...props,
780
944
  ref,
781
- className: cn("chat-composer", className),
945
+ className: cn("chat-composer", compact && "chat-composer-compact", className),
782
946
  style: compact ? {
783
947
  ...props.style,
784
948
  anchorName: props.style?.anchorName && props.style.anchorName !== "none" ? `${props.style.anchorName}, ${completionAnchor}` : completionAnchor
@@ -807,7 +971,8 @@ var ComposerShell = forwardRef(({
807
971
  }
808
972
  },
809
973
  children: [
810
- entries.length > 0 ? /* @__PURE__ */ jsx3("ul", {
974
+ context,
975
+ entries.length > 0 ? /* @__PURE__ */ jsx5("ul", {
811
976
  role: "list",
812
977
  className: cn("chat-composer-attachments", thumbnails && "chat-composer-thumbnails"),
813
978
  "aria-label": "Attachments",
@@ -823,38 +988,38 @@ var ComposerShell = forwardRef(({
823
988
  cancel
824
989
  }) => {
825
990
  const name = file?.name ?? entryName ?? "Attachment";
826
- return /* @__PURE__ */ jsx3("li", {
991
+ return /* @__PURE__ */ jsx5("li", {
827
992
  className: cn("chat-composer-attachment", thumbnails && "chat-composer-attachment-tile"),
828
993
  "data-state": state,
829
- children: renderAttachment && file ? /* @__PURE__ */ jsx3(AttachmentContent, {
994
+ children: renderAttachment && file ? /* @__PURE__ */ jsx5(AttachmentContent, {
830
995
  file,
831
996
  renderAttachment,
832
997
  context: {
833
998
  remove: () => removeAttachment(id),
834
999
  disabled: disabled || !onAttachmentsChange
835
1000
  }
836
- }) : /* @__PURE__ */ jsxs3(Fragment3, {
1001
+ }) : /* @__PURE__ */ jsxs5(Fragment3, {
837
1002
  children: [
838
- previewUrl ? /* @__PURE__ */ jsx3("img", {
1003
+ previewUrl ? /* @__PURE__ */ jsx5("img", {
839
1004
  className: "chat-composer-preview",
840
1005
  src: previewUrl,
841
1006
  alt: name
842
- }) : file ? /* @__PURE__ */ jsx3(AttachmentPreview, {
1007
+ }) : file ? /* @__PURE__ */ jsx5(AttachmentPreview, {
843
1008
  file
844
1009
  }) : null,
845
- !thumbnails ? /* @__PURE__ */ jsxs3("div", {
1010
+ !thumbnails ? /* @__PURE__ */ jsxs5("div", {
846
1011
  className: "chat-composer-attachment-info",
847
1012
  children: [
848
- /* @__PURE__ */ jsx3("span", {
1013
+ /* @__PURE__ */ jsx5("span", {
849
1014
  className: "chat-composer-filename",
850
1015
  title: name,
851
1016
  children: name
852
1017
  }),
853
- status ? /* @__PURE__ */ jsx3("span", {
1018
+ status ? /* @__PURE__ */ jsx5("span", {
854
1019
  className: "chat-composer-description",
855
1020
  children: status
856
1021
  }) : null,
857
- progress !== undefined ? /* @__PURE__ */ jsx3("progress", {
1022
+ progress !== undefined ? /* @__PURE__ */ jsx5("progress", {
858
1023
  className: "progress",
859
1024
  value: progress,
860
1025
  max: 1,
@@ -862,7 +1027,7 @@ var ComposerShell = forwardRef(({
862
1027
  }) : null
863
1028
  ]
864
1029
  }) : null,
865
- retry ? /* @__PURE__ */ jsx3(Button, {
1030
+ retry ? /* @__PURE__ */ jsx5(Button, {
866
1031
  type: "button",
867
1032
  size: "sm",
868
1033
  shape: "circle",
@@ -870,11 +1035,11 @@ var ComposerShell = forwardRef(({
870
1035
  onClick: retry,
871
1036
  "aria-label": `Retry ${name}`,
872
1037
  title: `Retry ${name}`,
873
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
1038
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
874
1039
  action: "retry"
875
1040
  })
876
1041
  }) : null,
877
- cancel ? /* @__PURE__ */ jsx3(Button, {
1042
+ cancel ? /* @__PURE__ */ jsx5(Button, {
878
1043
  type: "button",
879
1044
  size: "sm",
880
1045
  shape: "circle",
@@ -882,11 +1047,11 @@ var ComposerShell = forwardRef(({
882
1047
  onClick: cancel,
883
1048
  "aria-label": `Cancel ${name}`,
884
1049
  title: `Cancel ${name}`,
885
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
1050
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
886
1051
  action: "remove"
887
1052
  })
888
1053
  }) : null,
889
- onAttachmentsChange ? /* @__PURE__ */ jsx3(Button, {
1054
+ onAttachmentsChange ? /* @__PURE__ */ jsx5(Button, {
890
1055
  type: "button",
891
1056
  size: thumbnails ? "xs" : "sm",
892
1057
  shape: "circle",
@@ -897,7 +1062,7 @@ var ComposerShell = forwardRef(({
897
1062
  "aria-label": `Remove ${name}`,
898
1063
  title: `Remove ${name}`,
899
1064
  onClick: () => removeAttachment(id),
900
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
1065
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
901
1066
  action: "remove"
902
1067
  })
903
1068
  }) : null
@@ -907,7 +1072,7 @@ var ComposerShell = forwardRef(({
907
1072
  })
908
1073
  }) : null,
909
1074
  editor,
910
- showCompletion || completionHeader || completionStatus ? /* @__PURE__ */ jsx3(CompletionList, {
1075
+ showCompletion || completionHeader || completionStatus ? /* @__PURE__ */ jsx5(CompletionList, {
911
1076
  composerId,
912
1077
  label: completion?.label ?? "Suggestions",
913
1078
  candidates: showCompletion ? candidates : [],
@@ -920,7 +1085,7 @@ var ComposerShell = forwardRef(({
920
1085
  onDismiss: dismissCompletion
921
1086
  }) : null,
922
1087
  statusContent,
923
- hasError ? /* @__PURE__ */ jsx3("div", {
1088
+ hasError ? /* @__PURE__ */ jsx5("div", {
924
1089
  id: `${composerId}-error`,
925
1090
  role: "alert",
926
1091
  className: "chat-composer-error chat-composer-status",
@@ -935,10 +1100,10 @@ ComposerShell.displayName = "ComposerShell";
935
1100
 
936
1101
  // src/components/chat/composer/PlainEditor.tsx
937
1102
  import {
938
- forwardRef as forwardRef2,
939
- useImperativeHandle,
940
- useLayoutEffect as useLayoutEffect2,
941
- useRef as useRef3
1103
+ forwardRef as forwardRef4,
1104
+ useImperativeHandle as useImperativeHandle2,
1105
+ useLayoutEffect as useLayoutEffect3,
1106
+ useRef as useRef4
942
1107
  } from "react";
943
1108
 
944
1109
  // src/classes/input.ts
@@ -1027,8 +1192,8 @@ function getTextAreaCountClasses({ exceeded }) {
1027
1192
  }
1028
1193
 
1029
1194
  // src/components/chat/composer/PlainEditor.tsx
1030
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1031
- var PlainEditor = forwardRef2(({
1195
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1196
+ var PlainEditor = forwardRef4(({
1032
1197
  value,
1033
1198
  disabled,
1034
1199
  minRows,
@@ -1044,8 +1209,8 @@ var PlainEditor = forwardRef2(({
1044
1209
  onChange,
1045
1210
  onKeyDown
1046
1211
  }, ref) => {
1047
- const editorRef = useRef3(null);
1048
- const composingRef = useRef3(false);
1212
+ const editorRef = useRef4(null);
1213
+ const composingRef = useRef4(false);
1049
1214
  const minimumRows = Math.max(1, Math.floor(minRows));
1050
1215
  const maximumRows = Math.max(minimumRows, Math.floor(maxRows));
1051
1216
  const { showCount, ...nativeProps } = textareaProps ?? {};
@@ -1053,7 +1218,7 @@ var PlainEditor = forwardRef2(({
1053
1218
  delete nativeProps.status;
1054
1219
  delete nativeProps.variant;
1055
1220
  delete nativeProps.resize;
1056
- useImperativeHandle(ref, () => ({
1221
+ useImperativeHandle2(ref, () => ({
1057
1222
  focus: () => editorRef.current?.focus(),
1058
1223
  select: (start, end) => editorRef.current?.setSelectionRange(start, end),
1059
1224
  selection: (currentValue) => ({
@@ -1062,10 +1227,10 @@ var PlainEditor = forwardRef2(({
1062
1227
  selectionEnd: editorRef.current?.selectionEnd ?? currentValue.length
1063
1228
  })
1064
1229
  }), []);
1065
- useLayoutEffect2(() => {
1230
+ useLayoutEffect3(() => {
1066
1231
  composingRef.current = false;
1067
1232
  }, [generation]);
1068
- useLayoutEffect2(() => {
1233
+ useLayoutEffect3(() => {
1069
1234
  const editor = editorRef.current;
1070
1235
  if (!editor)
1071
1236
  return;
@@ -1093,7 +1258,7 @@ var PlainEditor = forwardRef2(({
1093
1258
  window.removeEventListener("resize", measure);
1094
1259
  };
1095
1260
  }, [value, minimumRows, maximumRows, textareaProps?.style]);
1096
- const control = /* @__PURE__ */ jsx4("textarea", {
1261
+ const control = /* @__PURE__ */ jsx6("textarea", {
1097
1262
  ...nativeProps,
1098
1263
  ref: editorRef,
1099
1264
  className: cn("chat-composer-editor", textareaProps?.className),
@@ -1123,11 +1288,11 @@ var PlainEditor = forwardRef2(({
1123
1288
  onKeyDown(event);
1124
1289
  }
1125
1290
  });
1126
- return showCount ? /* @__PURE__ */ jsxs4("span", {
1291
+ return showCount ? /* @__PURE__ */ jsxs6("span", {
1127
1292
  className: textAreaWrapperClass,
1128
1293
  children: [
1129
1294
  control,
1130
- /* @__PURE__ */ jsxs4("span", {
1295
+ /* @__PURE__ */ jsxs6("span", {
1131
1296
  className: getTextAreaCountClasses({
1132
1297
  exceeded: textareaProps?.maxLength !== undefined && value.length > textareaProps.maxLength
1133
1298
  }),
@@ -1777,8 +1942,8 @@ function createComposerAttachmentController(options) {
1777
1942
  }
1778
1943
 
1779
1944
  // src/components/chat/ChatComposer.tsx
1780
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1781
- var ChatComposer = forwardRef3(({
1945
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1946
+ var ChatComposer = forwardRef5(({
1782
1947
  value,
1783
1948
  onValueChange,
1784
1949
  onSubmit,
@@ -1792,6 +1957,7 @@ var ChatComposer = forwardRef3(({
1792
1957
  allowAttachmentOnly = false,
1793
1958
  compact = false,
1794
1959
  addMenu,
1960
+ context,
1795
1961
  disabled = false,
1796
1962
  busy = false,
1797
1963
  generating = false,
@@ -1812,26 +1978,26 @@ var ChatComposer = forwardRef3(({
1812
1978
  className,
1813
1979
  ...props
1814
1980
  }, ref) => {
1815
- const id = useId();
1816
- const editorRef = useRef4(null);
1817
- const pickerRef = useRef4(null);
1818
- const mountedRef = useRef4(false);
1819
- const submittingRef = useRef4(false);
1820
- const revisionRef = useRef4(0);
1821
- const observedValueRef = useRef4(value);
1822
- const entriesRef = useRef4([]);
1823
- const nextEntryRef = useRef4(0);
1824
- const scopeRef = useRef4({
1981
+ const id = useId2();
1982
+ const editorRef = useRef5(null);
1983
+ const pickerRef = useRef5(null);
1984
+ const mountedRef = useRef5(false);
1985
+ const submittingRef = useRef5(false);
1986
+ const revisionRef = useRef5(0);
1987
+ const observedValueRef = useRef5(value);
1988
+ const entriesRef = useRef5([]);
1989
+ const nextEntryRef = useRef5(0);
1990
+ const scopeRef = useRef5({
1825
1991
  contextKey: scope?.contextKey,
1826
1992
  conversationId: scope?.conversationId
1827
1993
  });
1828
- const generationRef = useRef4(0);
1994
+ const generationRef = useRef5(0);
1829
1995
  const [submitting, setSubmitting] = useState2(false);
1830
1996
  const [submitError, setSubmitError] = useState2();
1831
1997
  const [attachmentRejections, setAttachmentRejections] = useState2([]);
1832
1998
  const [activeId, setActiveId] = useState2();
1833
1999
  const [dismissed, setDismissed] = useState2(false);
1834
- const latestRef = useRef4({
2000
+ const latestRef = useRef5({
1835
2001
  value,
1836
2002
  onValueChange,
1837
2003
  attachments,
@@ -1842,13 +2008,13 @@ var ChatComposer = forwardRef3(({
1842
2008
  const scopeChanged = scopeRef.current.contextKey !== scope?.contextKey || scopeRef.current.conversationId !== scope?.conversationId;
1843
2009
  const generation = generationRef.current + (scopeChanged ? 1 : 0);
1844
2010
  const occurrences = reconcileAttachments(scopeChanged ? [] : entriesRef.current, attachments, nextEntryRef.current);
1845
- useLayoutEffect3(() => {
2011
+ useLayoutEffect4(() => {
1846
2012
  mountedRef.current = true;
1847
2013
  return () => {
1848
2014
  mountedRef.current = false;
1849
2015
  };
1850
2016
  }, []);
1851
- useLayoutEffect3(() => {
2017
+ useLayoutEffect4(() => {
1852
2018
  if (scopeChanged) {
1853
2019
  scopeRef.current = {
1854
2020
  contextKey: scope?.contextKey,
@@ -1864,7 +2030,7 @@ var ChatComposer = forwardRef3(({
1864
2030
  revisionRef.current++;
1865
2031
  }
1866
2032
  }, [scopeChanged, scope?.contextKey, scope?.conversationId, generation]);
1867
- useLayoutEffect3(() => {
2033
+ useLayoutEffect4(() => {
1868
2034
  if (observedValueRef.current !== value) {
1869
2035
  revisionRef.current++;
1870
2036
  observedValueRef.current = value;
@@ -1892,8 +2058,8 @@ var ChatComposer = forwardRef3(({
1892
2058
  const candidates = completion?.items ?? [];
1893
2059
  const { enabled, active } = legacyCompletion(candidates, activeId);
1894
2060
  const showCompletion = !disabled && !dismissed && candidates.length > 0;
1895
- const visibleError = error ?? submitError ?? (attachmentRejections.length ? /* @__PURE__ */ jsx5("ul", {
1896
- children: attachmentRejections.map((item, index) => /* @__PURE__ */ jsxs5("li", {
2061
+ const visibleError = error ?? submitError ?? (attachmentRejections.length ? /* @__PURE__ */ jsx7("ul", {
2062
+ children: attachmentRejections.map((item, index) => /* @__PURE__ */ jsxs7("li", {
1897
2063
  children: [
1898
2064
  item.metadata.name,
1899
2065
  ": ",
@@ -1983,13 +2149,14 @@ var ChatComposer = forwardRef3(({
1983
2149
  }
1984
2150
  }
1985
2151
  }
1986
- return /* @__PURE__ */ jsx5(ComposerShell, {
2152
+ return /* @__PURE__ */ jsx7(ComposerShell, {
1987
2153
  ...props,
1988
2154
  ref,
1989
2155
  className,
1990
2156
  composerId: id,
1991
2157
  compact,
1992
2158
  addMenu,
2159
+ context,
1993
2160
  entries: occurrences.entries,
1994
2161
  renderAttachment,
1995
2162
  removeAttachment: (entryId) => {
@@ -2020,7 +2187,7 @@ var ChatComposer = forwardRef3(({
2020
2187
  openAttachments,
2021
2188
  submit,
2022
2189
  onStop,
2023
- editor: /* @__PURE__ */ jsx5(PlainEditor, {
2190
+ editor: /* @__PURE__ */ jsx7(PlainEditor, {
2024
2191
  ref: editorRef,
2025
2192
  value,
2026
2193
  disabled,
@@ -2072,7 +2239,7 @@ var ChatComposer = forwardRef3(({
2072
2239
  ChatComposer.displayName = "Chat.Composer";
2073
2240
 
2074
2241
  // src/components/chat/ChatPrimitives.tsx
2075
- import { forwardRef as forwardRef4, useId as useId2 } from "react";
2242
+ import { forwardRef as forwardRef6, useId as useId3 } from "react";
2076
2243
 
2077
2244
  // src/classes/chat.ts
2078
2245
  var chatBaseClass = "chat";
@@ -2149,69 +2316,69 @@ function getChatToolClasses({
2149
2316
  }
2150
2317
 
2151
2318
  // src/components/chat/ChatPrimitives.tsx
2152
- import { jsx as jsx6, jsxs as jsxs6, Fragment as Fragment4 } from "react/jsx-runtime";
2153
- var ChatAgent = forwardRef4(({ timeline, className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2319
+ import { jsx as jsx8, jsxs as jsxs8, Fragment as Fragment4 } from "react/jsx-runtime";
2320
+ var ChatAgent = forwardRef6(({ timeline, className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2154
2321
  ...props,
2155
2322
  ref,
2156
2323
  "data-chat-tl": timeline ?? props["data-chat-tl"],
2157
2324
  className: getChatClasses({ className: cn("chat-agent", className) })
2158
2325
  }));
2159
2326
  ChatAgent.displayName = "Chat.Agent";
2160
- var ChatContent = forwardRef4(({ streaming, className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2327
+ var ChatContent = forwardRef6(({ streaming, className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2161
2328
  ...props,
2162
2329
  ref,
2163
2330
  className: cn("chat-content", streaming && "chat-streaming", className)
2164
2331
  }));
2165
2332
  ChatContent.displayName = "Chat.Content";
2166
- var ChatWork = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("details", {
2333
+ var ChatWork = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("details", {
2167
2334
  ...props,
2168
2335
  ref,
2169
2336
  className: cn("chat-work", className)
2170
2337
  }));
2171
2338
  ChatWork.displayName = "Chat.Work";
2172
- var ChatWorkSummary = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("summary", {
2339
+ var ChatWorkSummary = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("summary", {
2173
2340
  ...props,
2174
2341
  ref,
2175
2342
  className: cn("chat-work-summary", className)
2176
2343
  }));
2177
2344
  ChatWorkSummary.displayName = "Chat.WorkSummary";
2178
- var ChatWorkBody = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2345
+ var ChatWorkBody = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2179
2346
  ...props,
2180
2347
  ref,
2181
2348
  className: cn("chat-work-body", className)
2182
2349
  }));
2183
2350
  ChatWorkBody.displayName = "Chat.WorkBody";
2184
- var ChatInputArea = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2351
+ var ChatInputArea = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2185
2352
  ...props,
2186
2353
  ref,
2187
2354
  className: cn("chat-input-area", className)
2188
2355
  }));
2189
2356
  ChatInputArea.displayName = "Chat.InputArea";
2190
- var ChatComposerForm = forwardRef4(({ color, ghost, className, ...props }, ref) => /* @__PURE__ */ jsx6("form", {
2357
+ var ChatComposerForm = forwardRef6(({ color, ghost, className, ...props }, ref) => /* @__PURE__ */ jsx8("form", {
2191
2358
  ...props,
2192
2359
  ref,
2193
2360
  className: cn("chat-composer", color && `chat-composer-${color}`, ghost && "chat-composer-ghost", className)
2194
2361
  }));
2195
2362
  ChatComposerForm.displayName = "Chat.ComposerForm";
2196
- var ChatComposerInput = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("textarea", {
2363
+ var ChatComposerInput = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("textarea", {
2197
2364
  ...props,
2198
2365
  ref,
2199
2366
  className: cn("chat-composer-input", className)
2200
2367
  }));
2201
2368
  ChatComposerInput.displayName = "Chat.ComposerInput";
2202
- var ChatComposerActions = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2369
+ var ChatComposerActions = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2203
2370
  ...props,
2204
2371
  ref,
2205
2372
  className: cn("chat-composer-actions", className)
2206
2373
  }));
2207
2374
  ChatComposerActions.displayName = "Chat.ComposerActions";
2208
- var ChatComposerHint = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("kbd", {
2375
+ var ChatComposerHint = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("kbd", {
2209
2376
  ...props,
2210
2377
  ref,
2211
2378
  className: cn("chat-composer-hint", className)
2212
2379
  }));
2213
2380
  ChatComposerHint.displayName = "Chat.ComposerHint";
2214
- var ChatQueue = forwardRef4(({
2381
+ var ChatQueue = forwardRef6(({
2215
2382
  items,
2216
2383
  activeId = items[0]?.id,
2217
2384
  pendingIds = [],
@@ -2225,23 +2392,23 @@ var ChatQueue = forwardRef4(({
2225
2392
  className,
2226
2393
  ...props
2227
2394
  }, ref) => {
2228
- const titleId = `${useId2()}-queue-title`;
2229
- return /* @__PURE__ */ jsxs6("section", {
2395
+ const titleId = `${useId3()}-queue-title`;
2396
+ return /* @__PURE__ */ jsxs8("section", {
2230
2397
  ...props,
2231
2398
  ref,
2232
2399
  hidden: hidden || items.length === 0,
2233
2400
  "aria-labelledby": props["aria-labelledby"] ?? (props["aria-label"] ? undefined : titleId),
2234
2401
  className: cn("chat-queue", className),
2235
2402
  children: [
2236
- /* @__PURE__ */ jsxs6("div", {
2403
+ /* @__PURE__ */ jsxs8("div", {
2237
2404
  className: "chat-queue-header sr-only",
2238
2405
  children: [
2239
- /* @__PURE__ */ jsx6("h3", {
2406
+ /* @__PURE__ */ jsx8("h3", {
2240
2407
  className: "chat-queue-title",
2241
2408
  id: titleId,
2242
2409
  children: label
2243
2410
  }),
2244
- /* @__PURE__ */ jsxs6("span", {
2411
+ /* @__PURE__ */ jsxs8("span", {
2245
2412
  className: "chat-queue-count",
2246
2413
  children: [
2247
2414
  items.length,
@@ -2250,57 +2417,57 @@ var ChatQueue = forwardRef4(({
2250
2417
  })
2251
2418
  ]
2252
2419
  }),
2253
- /* @__PURE__ */ jsx6("ol", {
2420
+ /* @__PURE__ */ jsx8("ol", {
2254
2421
  className: "chat-queue-list",
2255
2422
  role: "list",
2256
2423
  tabIndex: 0,
2257
2424
  "aria-label": label,
2258
2425
  children: items.map((item, index) => {
2259
2426
  const pending = pendingIds.includes(item.id);
2260
- return /* @__PURE__ */ jsxs6("li", {
2427
+ return /* @__PURE__ */ jsxs8("li", {
2261
2428
  className: cn("chat-queue-item", item.id === activeId && "chat-queue-item-active"),
2262
2429
  "aria-busy": pending || undefined,
2263
2430
  children: [
2264
- /* @__PURE__ */ jsx6("svg", {
2431
+ /* @__PURE__ */ jsx8("svg", {
2265
2432
  className: "chat-queue-icon",
2266
2433
  viewBox: "0 0 24 24",
2267
2434
  fill: "none",
2268
2435
  stroke: "currentColor",
2269
2436
  "aria-hidden": "true",
2270
2437
  focusable: "false",
2271
- children: /* @__PURE__ */ jsx6("path", {
2438
+ children: /* @__PURE__ */ jsx8("path", {
2272
2439
  d: "m8 6 4 4-4 4M12 10H5m10-4h4m-4 6h4m-4 6h4"
2273
2440
  })
2274
2441
  }),
2275
- /* @__PURE__ */ jsxs6("span", {
2442
+ /* @__PURE__ */ jsxs8("span", {
2276
2443
  className: "chat-queue-number sr-only",
2277
2444
  children: [
2278
2445
  "#",
2279
2446
  index + 1
2280
2447
  ]
2281
2448
  }),
2282
- item.attachment ? /* @__PURE__ */ jsx6("img", {
2449
+ item.attachment ? /* @__PURE__ */ jsx8("img", {
2283
2450
  className: "chat-queue-attachment",
2284
2451
  src: item.attachment.src,
2285
2452
  alt: item.attachment.alt
2286
2453
  }) : null,
2287
- /* @__PURE__ */ jsx6("div", {
2454
+ /* @__PURE__ */ jsx8("div", {
2288
2455
  className: "chat-queue-content",
2289
2456
  title: item.text,
2290
2457
  children: renderItemContent ? renderItemContent(item, index) : item.text
2291
2458
  }),
2292
- /* @__PURE__ */ jsx6("div", {
2459
+ /* @__PURE__ */ jsx8("div", {
2293
2460
  className: "chat-actions chat-queue-actions",
2294
- children: renderItemActions ? renderItemActions(item, index, pending) : /* @__PURE__ */ jsxs6(Fragment4, {
2461
+ children: renderItemActions ? renderItemActions(item, index, pending) : /* @__PURE__ */ jsxs8(Fragment4, {
2295
2462
  children: [
2296
- /* @__PURE__ */ jsx6("button", {
2463
+ /* @__PURE__ */ jsx8("button", {
2297
2464
  className: "btn btn-ghost btn-sm btn-circle btn-icon btn-icon-sm chat-queue-steer",
2298
2465
  type: "button",
2299
2466
  disabled: pending || steerDisabled,
2300
2467
  "aria-label": `Steer waiting message ${index + 1}`,
2301
2468
  title: `Steer waiting message ${index + 1}`,
2302
2469
  onClick: () => onSteer(item.id),
2303
- children: /* @__PURE__ */ jsx6("svg", {
2470
+ children: /* @__PURE__ */ jsx8("svg", {
2304
2471
  width: "16",
2305
2472
  height: "16",
2306
2473
  style: { flexShrink: 0 },
@@ -2309,19 +2476,19 @@ var ChatQueue = forwardRef4(({
2309
2476
  stroke: "currentColor",
2310
2477
  "aria-hidden": "true",
2311
2478
  focusable: "false",
2312
- children: /* @__PURE__ */ jsx6("path", {
2479
+ children: /* @__PURE__ */ jsx8("path", {
2313
2480
  d: "m15 4 5 5-5 5M20 9h-9a6 6 0 0 0-6 6v4"
2314
2481
  })
2315
2482
  })
2316
2483
  }),
2317
- /* @__PURE__ */ jsx6("button", {
2484
+ /* @__PURE__ */ jsx8("button", {
2318
2485
  className: "btn btn-ghost btn-sm btn-circle btn-icon btn-icon-sm chat-queue-remove",
2319
2486
  type: "button",
2320
2487
  disabled: pending,
2321
2488
  "aria-label": `Remove waiting message ${index + 1}`,
2322
2489
  title: `Remove waiting message ${index + 1}`,
2323
2490
  onClick: () => onRemove(item.id),
2324
- children: /* @__PURE__ */ jsx6("svg", {
2491
+ children: /* @__PURE__ */ jsx8("svg", {
2325
2492
  width: "16",
2326
2493
  height: "16",
2327
2494
  style: { flexShrink: 0 },
@@ -2330,7 +2497,7 @@ var ChatQueue = forwardRef4(({
2330
2497
  stroke: "currentColor",
2331
2498
  "aria-hidden": "true",
2332
2499
  focusable: "false",
2333
- children: /* @__PURE__ */ jsx6("path", {
2500
+ children: /* @__PURE__ */ jsx8("path", {
2334
2501
  d: "M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7m4-7v7"
2335
2502
  })
2336
2503
  })
@@ -2348,20 +2515,20 @@ var ChatQueue = forwardRef4(({
2348
2515
  ChatQueue.displayName = "Chat.Queue";
2349
2516
 
2350
2517
  // src/components/chat/Chat.tsx
2351
- import { jsx as jsx7, jsxs as jsxs7, Fragment as Fragment5 } from "react/jsx-runtime";
2352
- var ChatAvatar = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2518
+ import { jsx as jsx9, jsxs as jsxs9, Fragment as Fragment5 } from "react/jsx-runtime";
2519
+ var ChatAvatar = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2353
2520
  ...props,
2354
2521
  ref,
2355
2522
  className: cn(chatAvatarClass, className)
2356
2523
  }));
2357
2524
  ChatAvatar.displayName = "Chat.Avatar";
2358
- var ChatHeader = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2525
+ var ChatHeader = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2359
2526
  ...props,
2360
2527
  ref,
2361
2528
  className: cn(chatHeaderClass, className)
2362
2529
  }));
2363
2530
  ChatHeader.displayName = "Chat.Header";
2364
- var ChatBubble = forwardRef5(({
2531
+ var ChatBubble = forwardRef7(({
2365
2532
  color,
2366
2533
  size = "md",
2367
2534
  filled,
@@ -2374,15 +2541,15 @@ var ChatBubble = forwardRef5(({
2374
2541
  children,
2375
2542
  ...props
2376
2543
  }, ref) => {
2377
- const contentId = `${useId3()}-content`;
2378
- const contentRef = useRef5(null);
2379
- const toggleRef = useRef5(null);
2380
- const collapseRequestedRef = useRef5(false);
2544
+ const contentId = `${useId4()}-content`;
2545
+ const contentRef = useRef6(null);
2546
+ const toggleRef = useRef6(null);
2547
+ const collapseRequestedRef = useRef6(false);
2381
2548
  const [overflows, setOverflows] = useState3(false);
2382
2549
  const [internalExpanded, setInternalExpanded] = useState3(defaultExpanded);
2383
2550
  const requestedExpanded = expanded ?? internalExpanded;
2384
2551
  const isExpanded = overflows && requestedExpanded;
2385
- useLayoutEffect4(() => {
2552
+ useLayoutEffect5(() => {
2386
2553
  const content = contentRef.current;
2387
2554
  if (!collapsible || !content) {
2388
2555
  collapseRequestedRef.current = false;
@@ -2424,16 +2591,16 @@ var ChatBubble = forwardRef5(({
2424
2591
  mutation?.disconnect();
2425
2592
  };
2426
2593
  }, [collapsible, children, requestedExpanded, expanded, onExpandedChange]);
2427
- const body = /* @__PURE__ */ jsxs7(Fragment5, {
2594
+ const body = /* @__PURE__ */ jsxs9(Fragment5, {
2428
2595
  children: [
2429
2596
  children,
2430
- streaming ? /* @__PURE__ */ jsx7("span", {
2597
+ streaming ? /* @__PURE__ */ jsx9("span", {
2431
2598
  className: "chat-bubble-content chat-bubble-streaming",
2432
2599
  "aria-hidden": "true"
2433
2600
  }) : null
2434
2601
  ]
2435
2602
  });
2436
- return /* @__PURE__ */ jsx7("div", {
2603
+ return /* @__PURE__ */ jsx9("div", {
2437
2604
  ...props,
2438
2605
  ref,
2439
2606
  className: getChatBubbleClasses({
@@ -2443,16 +2610,16 @@ var ChatBubble = forwardRef5(({
2443
2610
  streaming,
2444
2611
  className: cn(collapsible && "chat-bubble-collapsible", className)
2445
2612
  }),
2446
- children: collapsible ? /* @__PURE__ */ jsxs7(Fragment5, {
2613
+ children: collapsible ? /* @__PURE__ */ jsxs9(Fragment5, {
2447
2614
  children: [
2448
- /* @__PURE__ */ jsx7("div", {
2615
+ /* @__PURE__ */ jsx9("div", {
2449
2616
  ref: contentRef,
2450
2617
  className: "chat-bubble-content",
2451
2618
  id: contentId,
2452
2619
  tabIndex: -1,
2453
2620
  children: body
2454
2621
  }),
2455
- /* @__PURE__ */ jsx7("button", {
2622
+ /* @__PURE__ */ jsx9("button", {
2456
2623
  ref: toggleRef,
2457
2624
  type: "button",
2458
2625
  className: "btn btn-ghost btn-xs chat-bubble-toggle",
@@ -2471,55 +2638,55 @@ var ChatBubble = forwardRef5(({
2471
2638
  });
2472
2639
  });
2473
2640
  ChatBubble.displayName = "Chat.Bubble";
2474
- var ChatFooter = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2641
+ var ChatFooter = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2475
2642
  ...props,
2476
2643
  ref,
2477
2644
  className: cn(chatFooterClass, className)
2478
2645
  }));
2479
2646
  ChatFooter.displayName = "Chat.Footer";
2480
- var ChatStatus = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2647
+ var ChatStatus = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2481
2648
  ...props,
2482
2649
  ref,
2483
2650
  className: cn(chatStatusClass, className)
2484
2651
  }));
2485
2652
  ChatStatus.displayName = "Chat.Status";
2486
- var ChatStatusItem = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("span", {
2653
+ var ChatStatusItem = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("span", {
2487
2654
  ...props,
2488
2655
  ref,
2489
2656
  className: cn(chatStatusItemClass, className)
2490
2657
  }));
2491
2658
  ChatStatusItem.displayName = "Chat.StatusItem";
2492
- var ChatStatusValue = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("span", {
2659
+ var ChatStatusValue = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("span", {
2493
2660
  ...props,
2494
2661
  ref,
2495
2662
  className: cn(chatStatusValueClass, className)
2496
2663
  }));
2497
2664
  ChatStatusValue.displayName = "Chat.StatusValue";
2498
- var ChatActions = forwardRef5(({ hover, className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2665
+ var ChatActions = forwardRef7(({ hover, className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2499
2666
  ...props,
2500
2667
  ref,
2501
2668
  className: cn(chatActionsClass, hover && chatActionsHoverClass, className)
2502
2669
  }));
2503
2670
  ChatActions.displayName = "Chat.Actions";
2504
- var ChatScroll = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2671
+ var ChatScroll = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2505
2672
  ...props,
2506
2673
  ref,
2507
2674
  className: cn(chatScrollClass, className)
2508
2675
  }));
2509
2676
  ChatScroll.displayName = "Chat.Scroll";
2510
- var ChatScrollBody = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2677
+ var ChatScrollBody = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2511
2678
  ...props,
2512
2679
  ref,
2513
2680
  className: cn(chatScrollBodyClass, className)
2514
2681
  }));
2515
2682
  ChatScrollBody.displayName = "Chat.ScrollBody";
2516
- var ChatScrollTrack = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2683
+ var ChatScrollTrack = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2517
2684
  ...props,
2518
2685
  ref,
2519
2686
  className: cn(chatScrollTrackClass, className)
2520
2687
  }));
2521
2688
  ChatScrollTrack.displayName = "Chat.ScrollTrack";
2522
- var ChatScrollIndicator = forwardRef5(({ targetId, timeline, type = "button", className, onClick, ...props }, ref) => /* @__PURE__ */ jsx7("button", {
2689
+ var ChatScrollIndicator = forwardRef7(({ targetId, timeline, type = "button", className, onClick, ...props }, ref) => /* @__PURE__ */ jsx9("button", {
2523
2690
  ...props,
2524
2691
  ref,
2525
2692
  type,
@@ -2541,59 +2708,59 @@ var ChatScrollIndicator = forwardRef5(({ targetId, timeline, type = "button", cl
2541
2708
  }
2542
2709
  }));
2543
2710
  ChatScrollIndicator.displayName = "Chat.ScrollIndicator";
2544
- var ChatReasoning = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("details", {
2711
+ var ChatReasoning = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("details", {
2545
2712
  ...props,
2546
2713
  ref,
2547
2714
  className: cn(chatReasoningClass, className)
2548
2715
  }));
2549
2716
  ChatReasoning.displayName = "Chat.Reasoning";
2550
- var ChatTool = forwardRef5(({ status, className, ...props }, ref) => /* @__PURE__ */ jsx7("details", {
2717
+ var ChatTool = forwardRef7(({ status, className, ...props }, ref) => /* @__PURE__ */ jsx9("details", {
2551
2718
  ...props,
2552
2719
  ref,
2553
2720
  className: getChatToolClasses({ status, className })
2554
2721
  }));
2555
2722
  ChatTool.displayName = "Chat.Tool";
2556
- var ChatToolHeader = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("summary", {
2723
+ var ChatToolHeader = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("summary", {
2557
2724
  ...props,
2558
2725
  ref,
2559
2726
  className: cn(chatToolHeaderClass, className)
2560
2727
  }));
2561
2728
  ChatToolHeader.displayName = "Chat.ToolHeader";
2562
- var ChatToolStatus = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("span", {
2729
+ var ChatToolStatus = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("span", {
2563
2730
  ...props,
2564
2731
  ref,
2565
2732
  className: cn(chatToolStatusClass, className)
2566
2733
  }));
2567
2734
  ChatToolStatus.displayName = "Chat.ToolStatus";
2568
- var ChatToolCall = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2735
+ var ChatToolCall = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2569
2736
  ...props,
2570
2737
  ref,
2571
2738
  className: cn(chatToolCallClass, className)
2572
2739
  }));
2573
2740
  ChatToolCall.displayName = "Chat.ToolCall";
2574
- var ChatToolResult = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2741
+ var ChatToolResult = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2575
2742
  ...props,
2576
2743
  ref,
2577
2744
  className: cn(chatToolResultClass, className)
2578
2745
  }));
2579
2746
  ChatToolResult.displayName = "Chat.ToolResult";
2580
- var ChatTyping = forwardRef5(({
2747
+ var ChatTyping = forwardRef7(({
2581
2748
  className,
2582
2749
  role = "status",
2583
2750
  "aria-label": ariaLabel = "Assistant is typing",
2584
2751
  ...props
2585
- }, ref) => /* @__PURE__ */ jsx7("span", {
2752
+ }, ref) => /* @__PURE__ */ jsx9("span", {
2586
2753
  ...props,
2587
2754
  ref,
2588
2755
  role,
2589
2756
  "aria-label": ariaLabel,
2590
2757
  className: cn(chatTypingClass, className),
2591
- children: /* @__PURE__ */ jsx7("span", {
2758
+ children: /* @__PURE__ */ jsx9("span", {
2592
2759
  "aria-hidden": "true"
2593
2760
  })
2594
2761
  }));
2595
2762
  ChatTyping.displayName = "Chat.Typing";
2596
- var ChatRoot = forwardRef5(({ placement = "start", timeline, className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2763
+ var ChatRoot = forwardRef7(({ placement = "start", timeline, className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2597
2764
  ...props,
2598
2765
  ref,
2599
2766
  "data-chat-tl": timeline ?? props["data-chat-tl"],
@@ -2602,6 +2769,11 @@ var ChatRoot = forwardRef5(({ placement = "start", timeline, className, ...props
2602
2769
  ChatRoot.displayName = "Chat";
2603
2770
  var Chat = Object.assign(ChatRoot, {
2604
2771
  Composer: ChatComposer,
2772
+ ComposerContext: ChatComposerContext,
2773
+ ComposerContextItem: ChatComposerContextItem,
2774
+ ComposerContextEnd: ChatComposerContextEnd,
2775
+ ComposerConnection: ChatComposerConnection,
2776
+ Request: ChatRequest,
2605
2777
  Agent: ChatAgent,
2606
2778
  Content: ChatContent,
2607
2779
  Work: ChatWork,
@@ -2634,16 +2806,16 @@ var Chat = Object.assign(ChatRoot, {
2634
2806
  Typing: ChatTyping
2635
2807
  });
2636
2808
  // src/components/chat/ChatSessionComposer.tsx
2637
- import { forwardRef as forwardRef8 } from "react";
2809
+ import { forwardRef as forwardRef10 } from "react";
2638
2810
 
2639
2811
  // src/components/chat/composer/SemanticComposer.tsx
2640
2812
  import {
2641
- forwardRef as forwardRef7,
2642
- useId as useId7,
2813
+ forwardRef as forwardRef9,
2814
+ useId as useId8,
2643
2815
  useCallback as useCallback2,
2644
- useImperativeHandle as useImperativeHandle3,
2645
- useLayoutEffect as useLayoutEffect10,
2646
- useRef as useRef7,
2816
+ useImperativeHandle as useImperativeHandle4,
2817
+ useLayoutEffect as useLayoutEffect11,
2818
+ useRef as useRef8,
2647
2819
  useState as useState8,
2648
2820
  useSyncExternalStore as useSyncExternalStore5
2649
2821
  } from "react";
@@ -2651,14 +2823,14 @@ import {
2651
2823
  // src/components/chat/composer/useComposerAttachments.ts
2652
2824
  import {
2653
2825
  useEffect as useEffect2,
2654
- useLayoutEffect as useLayoutEffect5,
2826
+ useLayoutEffect as useLayoutEffect6,
2655
2827
  useState as useState4,
2656
2828
  useSyncExternalStore
2657
2829
  } from "react";
2658
2830
  function useComposerAttachments(options) {
2659
2831
  const [controller] = useState4(() => createComposerAttachmentController(options));
2660
2832
  const snapshot = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
2661
- useLayoutEffect5(() => {
2833
+ useLayoutEffect6(() => {
2662
2834
  controller.configure(options);
2663
2835
  });
2664
2836
  useEffect2(() => () => {
@@ -2668,7 +2840,7 @@ function useComposerAttachments(options) {
2668
2840
  }
2669
2841
 
2670
2842
  // src/components/chat/composer/useComposerProviders.ts
2671
- import { useLayoutEffect as useLayoutEffect6, useState as useState5, useSyncExternalStore as useSyncExternalStore2 } from "react";
2843
+ import { useLayoutEffect as useLayoutEffect7, useState as useState5, useSyncExternalStore as useSyncExternalStore2 } from "react";
2672
2844
 
2673
2845
  // src/components/chat/composer/providers.ts
2674
2846
  var nextController = 0;
@@ -3042,18 +3214,18 @@ class ComposerProviderController {
3042
3214
  function useComposerProviders(context) {
3043
3215
  const [controller] = useState5(() => new ComposerProviderController);
3044
3216
  const snapshot = useSyncExternalStore2(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
3045
- useLayoutEffect6(() => {
3217
+ useLayoutEffect7(() => {
3046
3218
  controller.activate();
3047
3219
  return () => controller.dispose();
3048
3220
  }, [controller]);
3049
- useLayoutEffect6(() => {
3221
+ useLayoutEffect7(() => {
3050
3222
  controller.update(context);
3051
3223
  });
3052
3224
  return { controller, snapshot };
3053
3225
  }
3054
3226
 
3055
3227
  // src/components/chat/composer/useComposerSession.ts
3056
- import { useId as useId4, useLayoutEffect as useLayoutEffect7, useState as useState6, useSyncExternalStore as useSyncExternalStore3 } from "react";
3228
+ import { useId as useId5, useLayoutEffect as useLayoutEffect8, useState as useState6, useSyncExternalStore as useSyncExternalStore3 } from "react";
3057
3229
 
3058
3230
  // src/components/chat/composer/session.ts
3059
3231
  function sameComposerScope(a, b) {
@@ -3469,14 +3641,14 @@ function createComposerSessionController(initial, identity) {
3469
3641
 
3470
3642
  // src/components/chat/composer/useComposerSession.ts
3471
3643
  function useComposerSession(context) {
3472
- const instanceId = useId4();
3644
+ const instanceId = useId5();
3473
3645
  const [controller] = useState6(() => createComposerSessionController(context, { instanceId }));
3474
3646
  const snapshot = useSyncExternalStore3(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
3475
- useLayoutEffect7(() => {
3647
+ useLayoutEffect8(() => {
3476
3648
  controller.activate();
3477
3649
  return () => controller.dispose();
3478
3650
  }, [controller]);
3479
- useLayoutEffect7(() => {
3651
+ useLayoutEffect8(() => {
3480
3652
  controller.update(context);
3481
3653
  });
3482
3654
  return { controller, snapshot };
@@ -3484,25 +3656,25 @@ function useComposerSession(context) {
3484
3656
 
3485
3657
  // src/components/chat/composer/PlainSemanticEditor.tsx
3486
3658
  import {
3487
- forwardRef as forwardRef6,
3488
- useId as useId5,
3489
- useImperativeHandle as useImperativeHandle2,
3659
+ forwardRef as forwardRef8,
3660
+ useId as useId6,
3661
+ useImperativeHandle as useImperativeHandle3,
3490
3662
  useCallback,
3491
- useLayoutEffect as useLayoutEffect8,
3492
- useRef as useRef6
3663
+ useLayoutEffect as useLayoutEffect9,
3664
+ useRef as useRef7
3493
3665
  } from "react";
3494
- import { jsx as jsx8 } from "react/jsx-runtime";
3666
+ import { jsx as jsx10 } from "react/jsx-runtime";
3495
3667
  function isPlainComposerDocument(document2) {
3496
3668
  return !document2.command && document2.content.every((node) => node.type === "text");
3497
3669
  }
3498
- var PlainSemanticEditor = forwardRef6((props, ref) => {
3499
- const editor = useRef6(null);
3500
- const originId = useId5();
3501
- const latest = useRef6(props);
3502
- const revision = useRef6(props.value.revision);
3503
- const pendingCaret = useRef6(undefined);
3670
+ var PlainSemanticEditor = forwardRef8((props, ref) => {
3671
+ const editor = useRef7(null);
3672
+ const originId = useId6();
3673
+ const latest = useRef7(props);
3674
+ const revision = useRef7(props.value.revision);
3675
+ const pendingCaret = useRef7(undefined);
3504
3676
  const text = props.value.document.content.map((node) => node.type === "text" ? node.text : "").join("");
3505
- useLayoutEffect8(() => {
3677
+ useLayoutEffect9(() => {
3506
3678
  latest.current = props;
3507
3679
  revision.current = Math.max(revision.current, props.value.revision);
3508
3680
  const caret = pendingCaret.current;
@@ -3513,7 +3685,7 @@ var PlainSemanticEditor = forwardRef6((props, ref) => {
3513
3685
  pendingCaret.current = undefined;
3514
3686
  }
3515
3687
  });
3516
- useLayoutEffect8(() => {
3688
+ useLayoutEffect9(() => {
3517
3689
  latest.current.onReady?.(true);
3518
3690
  return () => latest.current.onReady?.(false);
3519
3691
  }, []);
@@ -3553,7 +3725,7 @@ var PlainSemanticEditor = forwardRef6((props, ref) => {
3553
3725
  }
3554
3726
  return latest.current.value.document.content.length ? null : { nodeIndex: 0, start: 0, end: 0 };
3555
3727
  }
3556
- useImperativeHandle2(ref, () => ({
3728
+ useImperativeHandle3(ref, () => ({
3557
3729
  focus: () => editor.current?.focus(),
3558
3730
  selection,
3559
3731
  insertText: (value) => {
@@ -3593,7 +3765,7 @@ var PlainSemanticEditor = forwardRef6((props, ref) => {
3593
3765
  return true;
3594
3766
  }
3595
3767
  }), [change]);
3596
- return /* @__PURE__ */ jsx8(PlainEditor, {
3768
+ return /* @__PURE__ */ jsx10(PlainEditor, {
3597
3769
  ref: editor,
3598
3770
  value: text,
3599
3771
  disabled: !!props.disabled,
@@ -3631,7 +3803,7 @@ var PlainSemanticEditor = forwardRef6((props, ref) => {
3631
3803
  PlainSemanticEditor.displayName = "PlainSemanticEditor";
3632
3804
 
3633
3805
  // src/components/chat/composer/PreservedDraft.tsx
3634
- import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
3806
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
3635
3807
  function PreservedDraft({
3636
3808
  input,
3637
3809
  reason,
@@ -3645,27 +3817,27 @@ function PreservedDraft({
3645
3817
  } catch (cause) {
3646
3818
  exportError = cause instanceof Error ? cause.message : "Unsupported data";
3647
3819
  }
3648
- return /* @__PURE__ */ jsxs8("section", {
3820
+ return /* @__PURE__ */ jsxs10("section", {
3649
3821
  className: "chat-composer-status",
3650
3822
  "data-state": state,
3651
3823
  "aria-label": "Preserved draft",
3652
3824
  children: [
3653
- /* @__PURE__ */ jsxs8("p", {
3825
+ /* @__PURE__ */ jsxs10("p", {
3654
3826
  role: state === "error" ? "alert" : "status",
3655
3827
  children: [
3656
3828
  reason,
3657
3829
  " Your draft is preserved."
3658
3830
  ]
3659
3831
  }),
3660
- /* @__PURE__ */ jsx9("pre", {
3832
+ /* @__PURE__ */ jsx11("pre", {
3661
3833
  children: document2.status === "compatible" ? exportComposerText(document2.value) : json ?? "The application retains the original incompatible input."
3662
3834
  }),
3663
- json ? /* @__PURE__ */ jsx9("a", {
3835
+ json ? /* @__PURE__ */ jsx11("a", {
3664
3836
  download: "composer-draft.json",
3665
3837
  href: `data:application/json;charset=utf-8,${encodeURIComponent(json)}`,
3666
3838
  children: "Export preserved draft"
3667
3839
  }) : null,
3668
- exportError ? /* @__PURE__ */ jsxs8("p", {
3840
+ exportError ? /* @__PURE__ */ jsxs10("p", {
3669
3841
  children: [
3670
3842
  "JSON export unavailable: ",
3671
3843
  exportError,
@@ -3677,10 +3849,10 @@ function PreservedDraft({
3677
3849
  }
3678
3850
 
3679
3851
  // src/components/chat/composer/DraftLifecycle.tsx
3680
- import { useId as useId6 } from "react";
3852
+ import { useId as useId7 } from "react";
3681
3853
 
3682
3854
  // src/components/chat/composer/useComposerDraft.ts
3683
- import { useLayoutEffect as useLayoutEffect9, useState as useState7, useSyncExternalStore as useSyncExternalStore4 } from "react";
3855
+ import { useLayoutEffect as useLayoutEffect10, useState as useState7, useSyncExternalStore as useSyncExternalStore4 } from "react";
3684
3856
 
3685
3857
  // src/components/chat/composer/drafts.ts
3686
3858
  function error2(cause, code) {
@@ -4046,18 +4218,18 @@ function createComposerDraftController(context) {
4046
4218
  function useComposerDraft(context) {
4047
4219
  const [controller] = useState7(() => createComposerDraftController(context));
4048
4220
  const snapshot = useSyncExternalStore4(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
4049
- useLayoutEffect9(() => {
4221
+ useLayoutEffect10(() => {
4050
4222
  controller.activate();
4051
4223
  return () => controller.dispose();
4052
4224
  }, [controller]);
4053
- useLayoutEffect9(() => {
4225
+ useLayoutEffect10(() => {
4054
4226
  controller.update(context);
4055
4227
  });
4056
4228
  return { controller, snapshot };
4057
4229
  }
4058
4230
 
4059
4231
  // src/components/chat/composer/DraftLifecycle.tsx
4060
- import { jsx as jsx10, jsxs as jsxs9, Fragment as Fragment6 } from "react/jsx-runtime";
4232
+ import { jsx as jsx12, jsxs as jsxs11, Fragment as Fragment6 } from "react/jsx-runtime";
4061
4233
  function DraftLifecycle({
4062
4234
  adapter,
4063
4235
  scope,
@@ -4070,7 +4242,7 @@ function DraftLifecycle({
4070
4242
  compact = false,
4071
4243
  children
4072
4244
  }) {
4073
- const originId = `${useId6()}-draft`;
4245
+ const originId = `${useId7()}-draft`;
4074
4246
  function restore(draft) {
4075
4247
  attachments.restore(draft.attachments);
4076
4248
  onDocumentChange({
@@ -4093,24 +4265,24 @@ function DraftLifecycle({
4093
4265
  });
4094
4266
  const blocked = disabled || snapshot.saving || snapshot.status === "idle" || snapshot.status === "loading" || snapshot.restorePending || snapshot.status === "incompatible" && !snapshot.overwriteAllowed || snapshot.status === "error" && snapshot.errorOperation !== "save";
4095
4267
  const status = snapshot.status === "loading" ? "Loading stored draft…" : snapshot.saving ? "Saving draft…" : snapshot.lastSavedRevision === value.revision ? "Draft saved by host storage." : snapshot.loaded?.applied ? "Stored draft restored." : "Draft storage is provided by the host.";
4096
- const feedback = /* @__PURE__ */ jsxs9(Fragment6, {
4268
+ const feedback = /* @__PURE__ */ jsxs11(Fragment6, {
4097
4269
  children: [
4098
- /* @__PURE__ */ jsx10("div", {
4270
+ /* @__PURE__ */ jsx12("div", {
4099
4271
  role: "status",
4100
4272
  className: compact ? "sr-only" : undefined,
4101
4273
  children: status
4102
4274
  }),
4103
- snapshot.error ? /* @__PURE__ */ jsx10("p", {
4275
+ snapshot.error ? /* @__PURE__ */ jsx12("p", {
4104
4276
  role: "alert",
4105
4277
  children: snapshot.error.message
4106
4278
  }) : null,
4107
- snapshot.incompatible ? /* @__PURE__ */ jsxs9(Fragment6, {
4279
+ snapshot.incompatible ? /* @__PURE__ */ jsxs11(Fragment6, {
4108
4280
  children: [
4109
- /* @__PURE__ */ jsx10(PreservedDraft, {
4281
+ /* @__PURE__ */ jsx12(PreservedDraft, {
4110
4282
  input: snapshot.incompatible.input,
4111
4283
  reason: snapshot.incompatible.reason
4112
4284
  }),
4113
- !snapshot.overwriteAllowed ? /* @__PURE__ */ jsx10("button", {
4285
+ !snapshot.overwriteAllowed ? /* @__PURE__ */ jsx12("button", {
4114
4286
  type: "button",
4115
4287
  disabled,
4116
4288
  onClick: () => {
@@ -4121,14 +4293,14 @@ function DraftLifecycle({
4121
4293
  }) : null
4122
4294
  ]
4123
4295
  }) : null,
4124
- snapshot.loaded && !snapshot.loaded.applied ? /* @__PURE__ */ jsxs9(Fragment6, {
4296
+ snapshot.loaded && !snapshot.loaded.applied ? /* @__PURE__ */ jsxs11(Fragment6, {
4125
4297
  children: [
4126
- /* @__PURE__ */ jsx10(PreservedDraft, {
4298
+ /* @__PURE__ */ jsx12(PreservedDraft, {
4127
4299
  input: snapshot.loaded.draft,
4128
4300
  reason: "A stored draft arrived after editing. Your current draft is preserved.",
4129
4301
  state: "pending"
4130
4302
  }),
4131
- /* @__PURE__ */ jsx10("button", {
4303
+ /* @__PURE__ */ jsx12("button", {
4132
4304
  type: "button",
4133
4305
  disabled,
4134
4306
  onClick: () => {
@@ -4141,9 +4313,9 @@ function DraftLifecycle({
4141
4313
  }) : null
4142
4314
  ]
4143
4315
  });
4144
- const actions = compact ? /* @__PURE__ */ jsxs9(Fragment6, {
4316
+ const actions = compact ? /* @__PURE__ */ jsxs11(Fragment6, {
4145
4317
  children: [
4146
- /* @__PURE__ */ jsxs9("button", {
4318
+ /* @__PURE__ */ jsxs11("button", {
4147
4319
  type: "button",
4148
4320
  className: "popover-menu-item",
4149
4321
  title: status,
@@ -4153,7 +4325,7 @@ function DraftLifecycle({
4153
4325
  event.currentTarget.closest("[popover]")?.hidePopover?.();
4154
4326
  },
4155
4327
  children: [
4156
- /* @__PURE__ */ jsx10("svg", {
4328
+ /* @__PURE__ */ jsx12("svg", {
4157
4329
  width: "18",
4158
4330
  height: "18",
4159
4331
  viewBox: "0 0 24 24",
@@ -4164,16 +4336,16 @@ function DraftLifecycle({
4164
4336
  strokeLinejoin: "round",
4165
4337
  "aria-hidden": "true",
4166
4338
  focusable: "false",
4167
- children: /* @__PURE__ */ jsx10("path", {
4339
+ children: /* @__PURE__ */ jsx12("path", {
4168
4340
  d: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12l4 4v12a2 2 0 0 1-2 2ZM7 3v6h10V3M7 21v-8h10v8"
4169
4341
  })
4170
4342
  }),
4171
- /* @__PURE__ */ jsx10("span", {
4343
+ /* @__PURE__ */ jsx12("span", {
4172
4344
  children: "Save draft"
4173
4345
  })
4174
4346
  ]
4175
4347
  }),
4176
- /* @__PURE__ */ jsxs9("button", {
4348
+ /* @__PURE__ */ jsxs11("button", {
4177
4349
  type: "button",
4178
4350
  className: "popover-menu-item",
4179
4351
  title: "Reload stored draft",
@@ -4183,7 +4355,7 @@ function DraftLifecycle({
4183
4355
  event.currentTarget.closest("[popover]")?.hidePopover?.();
4184
4356
  },
4185
4357
  children: [
4186
- /* @__PURE__ */ jsx10("svg", {
4358
+ /* @__PURE__ */ jsx12("svg", {
4187
4359
  width: "18",
4188
4360
  height: "18",
4189
4361
  viewBox: "0 0 24 24",
@@ -4194,25 +4366,25 @@ function DraftLifecycle({
4194
4366
  strokeLinejoin: "round",
4195
4367
  "aria-hidden": "true",
4196
4368
  focusable: "false",
4197
- children: /* @__PURE__ */ jsx10("path", {
4369
+ children: /* @__PURE__ */ jsx12("path", {
4198
4370
  d: "M3 11a9 9 0 1 1 2.6 7.4M3 4v7h7"
4199
4371
  })
4200
4372
  }),
4201
- /* @__PURE__ */ jsx10("span", {
4373
+ /* @__PURE__ */ jsx12("span", {
4202
4374
  children: "Reload stored draft"
4203
4375
  })
4204
4376
  ]
4205
4377
  })
4206
4378
  ]
4207
- }) : /* @__PURE__ */ jsxs9(Fragment6, {
4379
+ }) : /* @__PURE__ */ jsxs11(Fragment6, {
4208
4380
  children: [
4209
- /* @__PURE__ */ jsx10("button", {
4381
+ /* @__PURE__ */ jsx12("button", {
4210
4382
  type: "button",
4211
4383
  disabled: blocked,
4212
4384
  onClick: () => void controller.save(),
4213
4385
  children: "Save draft"
4214
4386
  }),
4215
- /* @__PURE__ */ jsx10("button", {
4387
+ /* @__PURE__ */ jsx12("button", {
4216
4388
  type: "button",
4217
4389
  disabled: disabled || snapshot.status === "loading" || snapshot.saving,
4218
4390
  onClick: () => void controller.reload(),
@@ -4220,7 +4392,7 @@ function DraftLifecycle({
4220
4392
  })
4221
4393
  ]
4222
4394
  });
4223
- return compact ? children(feedback, actions) : children(/* @__PURE__ */ jsxs9("div", {
4395
+ return compact ? children(feedback, actions) : children(/* @__PURE__ */ jsxs11("div", {
4224
4396
  className: "chat-composer-status",
4225
4397
  "aria-label": "Draft storage",
4226
4398
  children: [
@@ -4231,8 +4403,8 @@ function DraftLifecycle({
4231
4403
  }
4232
4404
 
4233
4405
  // src/components/chat/composer/SemanticComposer.tsx
4234
- import { jsx as jsx11, jsxs as jsxs10, Fragment as Fragment7 } from "react/jsx-runtime";
4235
- var SemanticComposer = forwardRef7(({
4406
+ import { jsx as jsx13, jsxs as jsxs12, Fragment as Fragment7 } from "react/jsx-runtime";
4407
+ var SemanticComposer = forwardRef9(({
4236
4408
  Editor,
4237
4409
  structured,
4238
4410
  value,
@@ -4253,6 +4425,7 @@ var SemanticComposer = forwardRef7(({
4253
4425
  allowAttachmentOnly = false,
4254
4426
  compact = false,
4255
4427
  addMenu,
4428
+ context: composerContext,
4256
4429
  onStop,
4257
4430
  label = "Message",
4258
4431
  attachLabel = "Attach files",
@@ -4270,24 +4443,24 @@ var SemanticComposer = forwardRef7(({
4270
4443
  onKeyDownCapture,
4271
4444
  ...rootProps
4272
4445
  }, forwardedRef) => {
4273
- const id = useId7();
4274
- const editor = useRef7(null);
4275
- const picker = useRef7(null);
4446
+ const id = useId8();
4447
+ const editor = useRef8(null);
4448
+ const picker = useRef8(null);
4276
4449
  const [readiness, setReadiness] = useState8({ generation: 0, ready: false });
4277
4450
  const [editorFailure, setEditorFailure] = useState8();
4278
4451
  const [localFailure, setLocalFailure] = useState8();
4279
4452
  const [selection, setSelection] = useState8(null);
4280
- const observed = useRef7({ scope: { ...scope }, draftKey, generation: 0 });
4453
+ const observed = useRef8({ scope: { ...scope }, draftKey, generation: 0 });
4281
4454
  const changedScope = !sameComposerScope(observed.current.scope, scope) || observed.current.draftKey !== draftKey;
4282
4455
  const generation = observed.current.generation + (changedScope ? 1 : 0);
4283
- const alive = useRef7(false);
4284
- useLayoutEffect10(() => {
4456
+ const alive = useRef8(false);
4457
+ useLayoutEffect11(() => {
4285
4458
  alive.current = true;
4286
4459
  return () => {
4287
4460
  alive.current = false;
4288
4461
  };
4289
4462
  }, []);
4290
- useLayoutEffect10(() => {
4463
+ useLayoutEffect11(() => {
4291
4464
  if (changedScope)
4292
4465
  observed.current = { scope: { ...scope }, draftKey, generation };
4293
4466
  }, [
@@ -4388,7 +4561,7 @@ var SemanticComposer = forwardRef7(({
4388
4561
  const showCompletion = popup && candidates.length > 0;
4389
4562
  const visibleError = error ?? localError ?? session.snapshot.error?.message;
4390
4563
  const hasError = visibleError !== undefined && visibleError !== null && visibleError !== false;
4391
- useImperativeHandle3(forwardedRef, () => ({
4564
+ useImperativeHandle4(forwardedRef, () => ({
4392
4565
  focus: () => editor.current?.focus(),
4393
4566
  selection: () => editor.current?.selection() ?? null,
4394
4567
  insertReference: (node) => {
@@ -4445,12 +4618,13 @@ var SemanticComposer = forwardRef7(({
4445
4618
  editor.current?.focus();
4446
4619
  }
4447
4620
  const compactImages = compact && attachmentsCurrent && attachments.entries.length > 0 && attachments.entries.every((entry) => entry.state.status === "ready" && entry.metadata.mediaType.startsWith("image/") && !!attachments.controller.previewUrl(entry.entryId));
4448
- return /* @__PURE__ */ jsx11(ComposerShell, {
4621
+ return /* @__PURE__ */ jsx13(ComposerShell, {
4449
4622
  ...rootProps,
4450
4623
  className,
4451
4624
  composerId: id,
4452
4625
  compact,
4453
4626
  addMenu,
4627
+ context: composerContext,
4454
4628
  entries: (attachmentsCurrent ? attachments.entries : []).map((entry) => ({
4455
4629
  id: entry.entryId,
4456
4630
  name: entry.metadata.name,
@@ -4507,34 +4681,34 @@ var SemanticComposer = forwardRef7(({
4507
4681
  showCompletion,
4508
4682
  selectCompletion: selectCandidate,
4509
4683
  dismissCompletion: () => completion.controller.dismiss(),
4510
- completionHeader: completion.snapshot.breadcrumbs.length ? /* @__PURE__ */ jsxs10("nav", {
4684
+ completionHeader: completion.snapshot.breadcrumbs.length ? /* @__PURE__ */ jsxs12("nav", {
4511
4685
  "aria-label": "Suggestion folders",
4512
4686
  className: "chat-composer-breadcrumb",
4513
4687
  children: [
4514
- /* @__PURE__ */ jsx11("button", {
4688
+ /* @__PURE__ */ jsx13("button", {
4515
4689
  type: "button",
4516
4690
  onMouseDown: (event) => event.preventDefault(),
4517
4691
  onClick: () => completion.controller.back(0),
4518
4692
  children: "All results"
4519
4693
  }),
4520
- completion.snapshot.breadcrumbs.map((crumb, index) => /* @__PURE__ */ jsx11("button", {
4694
+ completion.snapshot.breadcrumbs.map((crumb, index) => /* @__PURE__ */ jsx13("button", {
4521
4695
  type: "button",
4522
4696
  onMouseDown: (event) => event.preventDefault(),
4523
4697
  onClick: () => completion.controller.back(index + 1),
4524
4698
  children: crumb.label
4525
4699
  }, crumb.refId)),
4526
- /* @__PURE__ */ jsx11("span", {
4700
+ /* @__PURE__ */ jsx13("span", {
4527
4701
  className: "chat-composer-hint",
4528
4702
  children: "Alt+Left returns to the parent folder."
4529
4703
  })
4530
4704
  ]
4531
4705
  }) : null,
4532
- completionStatus: popup && completion.snapshot.status !== "ready" ? /* @__PURE__ */ jsxs10("div", {
4706
+ completionStatus: popup && completion.snapshot.status !== "ready" ? /* @__PURE__ */ jsxs12("div", {
4533
4707
  role: "status",
4534
4708
  className: "chat-composer-status",
4535
4709
  children: [
4536
4710
  completion.snapshot.status === "loading" ? "Loading suggestions…" : completion.snapshot.status === "empty" ? "No suggestions" : completion.snapshot.error?.message ?? "Some suggestions could not be loaded",
4537
- completion.snapshot.status === "error" ? /* @__PURE__ */ jsx11("button", {
4711
+ completion.snapshot.status === "error" ? /* @__PURE__ */ jsx13("button", {
4538
4712
  type: "button",
4539
4713
  onClick: () => completion.controller.retry(),
4540
4714
  children: "Retry suggestions"
@@ -4543,78 +4717,78 @@ var SemanticComposer = forwardRef7(({
4543
4717
  }) : null,
4544
4718
  visibleError,
4545
4719
  hasError,
4546
- statusContent: /* @__PURE__ */ jsxs10(Fragment7, {
4720
+ statusContent: /* @__PURE__ */ jsxs12(Fragment7, {
4547
4721
  children: [
4548
- attachmentsCurrent && attachments.rejections.length ? /* @__PURE__ */ jsxs10("div", {
4722
+ attachmentsCurrent && attachments.rejections.length ? /* @__PURE__ */ jsxs12("div", {
4549
4723
  role: "alert",
4550
4724
  className: "chat-composer-status",
4551
4725
  "data-state": "error",
4552
4726
  children: [
4553
- attachments.rejections.map((item, index) => /* @__PURE__ */ jsxs10("p", {
4727
+ attachments.rejections.map((item, index) => /* @__PURE__ */ jsxs12("p", {
4554
4728
  children: [
4555
4729
  item.metadata.name,
4556
4730
  ": ",
4557
4731
  item.error.message
4558
4732
  ]
4559
4733
  }, `${index}-${item.metadata.name}`)),
4560
- /* @__PURE__ */ jsx11("button", {
4734
+ /* @__PURE__ */ jsx13("button", {
4561
4735
  type: "button",
4562
4736
  onClick: () => attachments.controller.clearRejections(),
4563
4737
  children: "Dismiss attachment errors"
4564
4738
  })
4565
4739
  ]
4566
4740
  }) : null,
4567
- recovery.filter((attempt) => sameComposerScope(attempt.snapshot.scope, scope) && (attempt.status === "unknown" || attempt.status === "pending")).map((attempt) => compact && attempt.status === "pending" ? /* @__PURE__ */ jsx11("p", {
4741
+ recovery.filter((attempt) => sameComposerScope(attempt.snapshot.scope, scope) && (attempt.status === "unknown" || attempt.status === "pending")).map((attempt) => compact && attempt.status === "pending" ? /* @__PURE__ */ jsx13("p", {
4568
4742
  role: "status",
4569
4743
  className: "sr-only",
4570
4744
  "data-state": "pending",
4571
4745
  children: "Awaiting admission"
4572
- }, attempt.snapshot.clientSubmissionId) : /* @__PURE__ */ jsxs10("details", {
4746
+ }, attempt.snapshot.clientSubmissionId) : /* @__PURE__ */ jsxs12("details", {
4573
4747
  className: "chat-composer-status",
4574
4748
  "data-state": attempt.status,
4575
4749
  children: [
4576
- /* @__PURE__ */ jsx11("summary", {
4750
+ /* @__PURE__ */ jsx13("summary", {
4577
4751
  children: attempt.status === "unknown" ? "Submission outcome unknown — draft retained" : "Awaiting admission"
4578
4752
  }),
4579
- /* @__PURE__ */ jsx11("p", {
4753
+ /* @__PURE__ */ jsx13("p", {
4580
4754
  children: attempt.snapshot.clientSubmissionId
4581
4755
  }),
4582
- attempt.receipt?.outcome === "unknown" ? /* @__PURE__ */ jsx11("p", {
4756
+ attempt.receipt?.outcome === "unknown" ? /* @__PURE__ */ jsx13("p", {
4583
4757
  children: attempt.receipt.error.message
4584
4758
  }) : null,
4585
- host.reconcile ? /* @__PURE__ */ jsx11("button", {
4759
+ host.reconcile ? /* @__PURE__ */ jsx13("button", {
4586
4760
  type: "button",
4587
4761
  onClick: () => {
4588
4762
  session.controller.reconcile(attempt.snapshot.clientSubmissionId).catch((cause) => setLocalError(String(cause), generation));
4589
4763
  },
4590
4764
  children: "Check submission status"
4591
4765
  }) : null,
4592
- attempt.status === "unknown" && host.authorizeRetry ? /* @__PURE__ */ jsx11("button", {
4766
+ attempt.status === "unknown" && host.authorizeRetry ? /* @__PURE__ */ jsx13("button", {
4593
4767
  type: "button",
4594
4768
  onClick: () => {
4595
4769
  session.controller.retry(attempt.snapshot.clientSubmissionId).catch((cause) => setLocalError(String(cause), generation));
4596
4770
  },
4597
4771
  children: "Request authorized retry"
4598
4772
  }) : null,
4599
- /* @__PURE__ */ jsx11(PreservedDraft, {
4773
+ /* @__PURE__ */ jsx13(PreservedDraft, {
4600
4774
  input: attempt.snapshot.document,
4601
4775
  reason: "Submitted snapshot",
4602
4776
  state: attempt.status === "unknown" ? "unknown" : "pending"
4603
4777
  })
4604
4778
  ]
4605
4779
  }, attempt.snapshot.clientSubmissionId)),
4606
- session.snapshot.recoveryFailures?.map((attempt) => /* @__PURE__ */ jsx11(PreservedDraft, {
4780
+ session.snapshot.recoveryFailures?.map((attempt) => /* @__PURE__ */ jsx13(PreservedDraft, {
4607
4781
  input: attempt,
4608
4782
  reason: "The host could not retain this submission. Export its recovery record before leaving."
4609
4783
  }, attempt.snapshot.clientSubmissionId)),
4610
- session.snapshot.lastReceipt?.outcome === "accepted" ? /* @__PURE__ */ jsx11("div", {
4784
+ session.snapshot.lastReceipt?.outcome === "accepted" ? /* @__PURE__ */ jsx13("div", {
4611
4785
  role: "status",
4612
4786
  className: compact ? "sr-only" : "chat-composer-status",
4613
4787
  children: session.snapshot.lastReceipt.operation === "command" ? "Command completed" : `Admitted: ${session.snapshot.lastReceipt.delivery} (${session.snapshot.lastReceipt.persistence})`
4614
4788
  }) : null
4615
4789
  ]
4616
4790
  }),
4617
- renderFooter: (renderToolbar) => draftAdapter && attachmentsCurrent && read.status === "compatible" ? /* @__PURE__ */ jsx11(DraftLifecycle, {
4791
+ renderFooter: (renderToolbar) => draftAdapter && attachmentsCurrent && read.status === "compatible" ? /* @__PURE__ */ jsx13(DraftLifecycle, {
4618
4792
  compact,
4619
4793
  adapter: draftAdapter,
4620
4794
  scope,
@@ -4624,7 +4798,7 @@ var SemanticComposer = forwardRef7(({
4624
4798
  attachments: attachments.controller,
4625
4799
  onDocumentChange,
4626
4800
  disabled: disabled || runtime.status === "read_only",
4627
- children: (feedback, actions) => /* @__PURE__ */ jsxs10(Fragment7, {
4801
+ children: (feedback, actions) => /* @__PURE__ */ jsxs12(Fragment7, {
4628
4802
  children: [
4629
4803
  feedback,
4630
4804
  renderToolbar(actions)
@@ -4640,7 +4814,7 @@ var SemanticComposer = forwardRef7(({
4640
4814
  },
4641
4815
  submit,
4642
4816
  onStop,
4643
- editor: editAvailable ? /* @__PURE__ */ jsx11(Editor, {
4817
+ editor: editAvailable ? /* @__PURE__ */ jsx13(Editor, {
4644
4818
  ref: editor,
4645
4819
  value,
4646
4820
  instanceGeneration: generation,
@@ -4693,7 +4867,7 @@ var SemanticComposer = forwardRef7(({
4693
4867
  submit();
4694
4868
  }
4695
4869
  }
4696
- }, generation) : /* @__PURE__ */ jsx11(PreservedDraft, {
4870
+ }, generation) : /* @__PURE__ */ jsx13(PreservedDraft, {
4697
4871
  input: value.document,
4698
4872
  reason: editorError?.message ?? (read.status === "incompatible" ? read.reason : "This draft requires the optional rich editor.")
4699
4873
  }),
@@ -4703,8 +4877,8 @@ var SemanticComposer = forwardRef7(({
4703
4877
  SemanticComposer.displayName = "SemanticComposer";
4704
4878
 
4705
4879
  // src/components/chat/ChatSessionComposer.tsx
4706
- import { jsx as jsx12 } from "react/jsx-runtime";
4707
- var ChatSessionComposer = forwardRef8((props, ref) => /* @__PURE__ */ jsx12(SemanticComposer, {
4880
+ import { jsx as jsx14 } from "react/jsx-runtime";
4881
+ var ChatSessionComposer = forwardRef10((props, ref) => /* @__PURE__ */ jsx14(SemanticComposer, {
4708
4882
  ...props,
4709
4883
  ref,
4710
4884
  Editor: PlainSemanticEditor,
@@ -4712,8 +4886,8 @@ var ChatSessionComposer = forwardRef8((props, ref) => /* @__PURE__ */ jsx12(Sema
4712
4886
  }));
4713
4887
  ChatSessionComposer.displayName = "ChatSessionComposer";
4714
4888
  // src/components/chat/ChatAuthoritativeQueue.tsx
4715
- import { useId as useId8, useLayoutEffect as useLayoutEffect11, useRef as useRef8, useState as useState9 } from "react";
4716
- import { jsx as jsx13, jsxs as jsxs11, Fragment as Fragment8 } from "react/jsx-runtime";
4889
+ import { useId as useId9, useLayoutEffect as useLayoutEffect12, useRef as useRef9, useState as useState9 } from "react";
4890
+ import { jsx as jsx15, jsxs as jsxs13, Fragment as Fragment8 } from "react/jsx-runtime";
4717
4891
  function scopeKey(projection) {
4718
4892
  return JSON.stringify([
4719
4893
  projection.scope.contextKey,
@@ -4730,7 +4904,7 @@ function QueueActionIcon({
4730
4904
  save: "m5 12 4 4L19 6",
4731
4905
  cancel: "m6 6 12 12M6 18 18 6"
4732
4906
  };
4733
- return /* @__PURE__ */ jsx13("svg", {
4907
+ return /* @__PURE__ */ jsx15("svg", {
4734
4908
  width: "16",
4735
4909
  height: "16",
4736
4910
  viewBox: "0 0 24 24",
@@ -4741,7 +4915,7 @@ function QueueActionIcon({
4741
4915
  strokeLinejoin: "round",
4742
4916
  "aria-hidden": "true",
4743
4917
  focusable: "false",
4744
- children: /* @__PURE__ */ jsx13("path", {
4918
+ children: /* @__PURE__ */ jsx15("path", {
4745
4919
  d: paths[action]
4746
4920
  })
4747
4921
  });
@@ -4756,29 +4930,29 @@ function DocumentEditorSlot({
4756
4930
  renderEditor,
4757
4931
  ...editor
4758
4932
  }) {
4759
- return /* @__PURE__ */ jsx13(Fragment8, {
4933
+ return /* @__PURE__ */ jsx15(Fragment8, {
4760
4934
  children: renderEditor(editor)
4761
4935
  });
4762
4936
  }
4763
4937
  function ChatAuthoritativeQueue(props) {
4764
- return /* @__PURE__ */ jsx13(QueueSession, {
4938
+ return /* @__PURE__ */ jsx15(QueueSession, {
4765
4939
  ...props
4766
4940
  }, scopeKey(props.projection));
4767
4941
  }
4768
4942
  function QueueSession(props) {
4769
- const latest = useRef8(props);
4770
- const watermark = useRef8(props.projection.revision);
4771
- useLayoutEffect11(() => {
4943
+ const latest = useRef9(props);
4944
+ const watermark = useRef9(props.projection.revision);
4945
+ useLayoutEffect12(() => {
4772
4946
  latest.current = props;
4773
4947
  watermark.current = Math.max(watermark.current, props.projection.revision);
4774
4948
  });
4775
- const requests = useRef8(new Map);
4776
- const counter = useRef8(0);
4777
- const instanceId = useId8();
4949
+ const requests = useRef9(new Map);
4950
+ const counter = useRef9(0);
4951
+ const instanceId = useId9();
4778
4952
  const [pending, setPending] = useState9([]);
4779
4953
  const [message, setMessage] = useState9();
4780
4954
  const [edit, setEdit] = useState9();
4781
- useLayoutEffect11(() => {
4955
+ useLayoutEffect12(() => {
4782
4956
  const active = requests.current;
4783
4957
  return () => {
4784
4958
  for (const controller of active.values())
@@ -4847,10 +5021,10 @@ function QueueSession(props) {
4847
5021
  }
4848
5022
  const noop = () => {};
4849
5023
  const editAllowed = Boolean(edit && props.projection.items.some((item) => item.id === edit.item.id && canEdit(item, props) && (!edit.text || safeText(item))));
4850
- return /* @__PURE__ */ jsxs11("div", {
5024
+ return /* @__PURE__ */ jsxs13("div", {
4851
5025
  className: props.className,
4852
5026
  children: [
4853
- /* @__PURE__ */ jsx13(ChatQueue, {
5027
+ /* @__PURE__ */ jsx15(ChatQueue, {
4854
5028
  label: props.label,
4855
5029
  items: props.projection.items.map((item) => ({
4856
5030
  id: item.id,
@@ -4862,9 +5036,9 @@ function QueueSession(props) {
4862
5036
  renderItemActions: (row, index, busy) => {
4863
5037
  const item = props.projection.items[index];
4864
5038
  const editable = canEdit(item, props);
4865
- return /* @__PURE__ */ jsxs11(Fragment8, {
5039
+ return /* @__PURE__ */ jsxs13(Fragment8, {
4866
5040
  children: [
4867
- editable ? /* @__PURE__ */ jsx13("button", {
5041
+ editable ? /* @__PURE__ */ jsx15("button", {
4868
5042
  type: "button",
4869
5043
  className: "btn btn-ghost btn-sm btn-square",
4870
5044
  disabled: busy,
@@ -4876,11 +5050,11 @@ function QueueSession(props) {
4876
5050
  document: snapshotComposerDocument(item.document),
4877
5051
  text: safeText(item)
4878
5052
  }),
4879
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5053
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4880
5054
  action: "edit"
4881
5055
  })
4882
5056
  }) : null,
4883
- props.capabilities.promote && item.capabilities.promote ? /* @__PURE__ */ jsx13("button", {
5057
+ props.capabilities.promote && item.capabilities.promote ? /* @__PURE__ */ jsx15("button", {
4884
5058
  type: "button",
4885
5059
  className: "btn btn-ghost btn-sm btn-square chat-queue-steer",
4886
5060
  disabled: busy || !props.targetTurnId,
@@ -4893,18 +5067,18 @@ function QueueSession(props) {
4893
5067
  targetTurnId: props.targetTurnId
4894
5068
  }, row.id);
4895
5069
  },
4896
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5070
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4897
5071
  action: "steer"
4898
5072
  })
4899
5073
  }) : null,
4900
- props.capabilities.remove && item.capabilities.remove ? /* @__PURE__ */ jsx13("button", {
5074
+ props.capabilities.remove && item.capabilities.remove ? /* @__PURE__ */ jsx15("button", {
4901
5075
  type: "button",
4902
5076
  className: "btn btn-ghost btn-sm btn-square chat-queue-remove",
4903
5077
  disabled: busy,
4904
5078
  "aria-label": `Remove waiting message ${index + 1}`,
4905
5079
  title: `Remove waiting message ${index + 1}`,
4906
5080
  onClick: () => void mutate({ operation: "remove" }, row.id),
4907
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5081
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4908
5082
  action: "remove"
4909
5083
  })
4910
5084
  }) : null
@@ -4912,13 +5086,13 @@ function QueueSession(props) {
4912
5086
  });
4913
5087
  }
4914
5088
  }),
4915
- edit ? /* @__PURE__ */ jsx13("div", {
5089
+ edit ? /* @__PURE__ */ jsx15("div", {
4916
5090
  className: "chat-composer",
4917
5091
  role: "group",
4918
5092
  "aria-label": "Edit queued message",
4919
- children: edit.text ? /* @__PURE__ */ jsxs11(Fragment8, {
5093
+ children: edit.text ? /* @__PURE__ */ jsxs13(Fragment8, {
4920
5094
  children: [
4921
- /* @__PURE__ */ jsx13("textarea", {
5095
+ /* @__PURE__ */ jsx15("textarea", {
4922
5096
  className: "chat-composer-input",
4923
5097
  "aria-label": "Queued message",
4924
5098
  value: exportComposerText(edit.document),
@@ -4933,35 +5107,35 @@ function QueueSession(props) {
4933
5107
  }
4934
5108
  })
4935
5109
  }),
4936
- /* @__PURE__ */ jsxs11("div", {
5110
+ /* @__PURE__ */ jsxs13("div", {
4937
5111
  className: "chat-composer-actions",
4938
5112
  children: [
4939
- /* @__PURE__ */ jsx13("button", {
5113
+ /* @__PURE__ */ jsx15("button", {
4940
5114
  className: "btn btn-sm btn-square",
4941
5115
  type: "button",
4942
5116
  "aria-label": "Save queued message",
4943
5117
  title: "Save queued message",
4944
5118
  disabled: pending.includes(edit.item.id) || !editAllowed,
4945
5119
  onClick: () => void mutate({ operation: "edit", document: edit.document }, edit.item.id, edit.revision),
4946
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5120
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4947
5121
  action: "save"
4948
5122
  })
4949
5123
  }),
4950
- /* @__PURE__ */ jsx13("button", {
5124
+ /* @__PURE__ */ jsx15("button", {
4951
5125
  className: "btn btn-ghost btn-sm btn-square",
4952
5126
  type: "button",
4953
5127
  "aria-label": "Cancel",
4954
5128
  title: "Cancel",
4955
5129
  disabled: pending.includes(edit.item.id),
4956
5130
  onClick: () => setEdit(undefined),
4957
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5131
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4958
5132
  action: "cancel"
4959
5133
  })
4960
5134
  })
4961
5135
  ]
4962
5136
  })
4963
5137
  ]
4964
- }) : props.renderDocumentEditor && editAllowed ? /* @__PURE__ */ jsx13(DocumentEditorSlot, {
5138
+ }) : props.renderDocumentEditor && editAllowed ? /* @__PURE__ */ jsx15(DocumentEditorSlot, {
4965
5139
  renderEditor: props.renderDocumentEditor,
4966
5140
  item: edit.item,
4967
5141
  value: edit.document,
@@ -4972,14 +5146,14 @@ function QueueSession(props) {
4972
5146
  onSave: () => void mutate({ operation: "edit", document: edit.document }, edit.item.id, edit.revision),
4973
5147
  onCancel: () => setEdit(undefined),
4974
5148
  pending: pending.includes(edit.item.id)
4975
- }) : /* @__PURE__ */ jsxs11(Fragment8, {
5149
+ }) : /* @__PURE__ */ jsxs13(Fragment8, {
4976
5150
  children: [
4977
- /* @__PURE__ */ jsx13(PreservedDraft, {
5151
+ /* @__PURE__ */ jsx15(PreservedDraft, {
4978
5152
  input: edit.document,
4979
5153
  reason: "This queued message is no longer editable. Your replacement draft is preserved.",
4980
5154
  state: "pending"
4981
5155
  }),
4982
- /* @__PURE__ */ jsx13("button", {
5156
+ /* @__PURE__ */ jsx15("button", {
4983
5157
  type: "button",
4984
5158
  onClick: () => setEdit(undefined),
4985
5159
  children: "Discard queued edit"
@@ -4987,7 +5161,7 @@ function QueueSession(props) {
4987
5161
  ]
4988
5162
  })
4989
5163
  }) : null,
4990
- message ? /* @__PURE__ */ jsx13("p", {
5164
+ message ? /* @__PURE__ */ jsx15("p", {
4991
5165
  className: message.error ? "chat-composer-error" : "chat-composer-status",
4992
5166
  role: message.error ? "alert" : "status",
4993
5167
  children: message.text
@@ -4996,17 +5170,297 @@ function QueueSession(props) {
4996
5170
  });
4997
5171
  }
4998
5172
  // src/components/chat/ComposerSettings.tsx
4999
- import { useId as useId10, useLayoutEffect as useLayoutEffect12, useRef as useRef10, useState as useState11 } from "react";
5173
+ import { useId as useId12, useLayoutEffect as useLayoutEffect13, useRef as useRef12, useState as useState12 } from "react";
5174
+
5175
+ // src/components/chat/ComposerSettingsMenus.tsx
5176
+ import React15, { useId as useId10, useRef as useRef10, useState as useState10 } from "react";
5177
+ import { jsx as jsx16, jsxs as jsxs14, Fragment as Fragment9 } from "react/jsx-runtime";
5178
+ function ComposerSettingsMenus(props) {
5179
+ const groups = props.groups ?? props.settings.map((setting) => ({
5180
+ id: setting.id,
5181
+ label: setting.label,
5182
+ settingIds: [setting.id]
5183
+ }));
5184
+ return /* @__PURE__ */ jsxs14(Fragment9, {
5185
+ children: [
5186
+ groups.map((group) => /* @__PURE__ */ jsx16(SettingsMenu, {
5187
+ ...props,
5188
+ group
5189
+ }, group.id)),
5190
+ /* @__PURE__ */ jsx16("span", {
5191
+ className: "sr-only",
5192
+ role: "status",
5193
+ children: props.busy ? "Change pending" : Object.values(props.feedback).filter(Boolean).join(". ")
5194
+ })
5195
+ ]
5196
+ });
5197
+ }
5198
+ function OrderedSetting({
5199
+ setting,
5200
+ disabled,
5201
+ choose
5202
+ }) {
5203
+ const current = Math.max(0, setting.choices.findIndex((choice) => choice.value === setting.value));
5204
+ const [draft, setDraft] = useState10();
5205
+ const value = draft ?? current;
5206
+ const commit = () => {
5207
+ if (draft !== undefined)
5208
+ choose(setting.choices[draft].value);
5209
+ setDraft(undefined);
5210
+ };
5211
+ return /* @__PURE__ */ jsxs14(Fragment9, {
5212
+ children: [
5213
+ /* @__PURE__ */ jsxs14("div", {
5214
+ className: "chat-composer-menu-row",
5215
+ children: [
5216
+ /* @__PURE__ */ jsx16("strong", {
5217
+ children: setting.choices[value]?.label
5218
+ }),
5219
+ setting.defaultValue !== undefined ? /* @__PURE__ */ jsx16("button", {
5220
+ type: "button",
5221
+ className: "btn btn-ghost btn-xs",
5222
+ "aria-label": `Reset ${setting.label.toLowerCase()}`,
5223
+ disabled: disabled || setting.value === setting.defaultValue || !setting.choices.some((choice) => choice.value === setting.defaultValue && !choice.unavailableReason),
5224
+ onClick: () => choose(setting.defaultValue),
5225
+ children: "Reset"
5226
+ }) : null
5227
+ ]
5228
+ }),
5229
+ /* @__PURE__ */ jsxs14("label", {
5230
+ className: "chat-composer-menu-field",
5231
+ children: [
5232
+ /* @__PURE__ */ jsx16("span", {
5233
+ className: "sr-only",
5234
+ children: setting.label
5235
+ }),
5236
+ /* @__PURE__ */ jsx16("input", {
5237
+ type: "range",
5238
+ className: "range range-sm",
5239
+ min: 0,
5240
+ max: Math.max(0, setting.choices.length - 1),
5241
+ step: 1,
5242
+ value,
5243
+ "aria-valuetext": setting.choices[value]?.label,
5244
+ disabled: disabled || !setting.choices.length,
5245
+ onChange: (event) => setDraft(Number(event.currentTarget.value)),
5246
+ onPointerUp: commit,
5247
+ onKeyUp: (event) => {
5248
+ if ([
5249
+ "ArrowLeft",
5250
+ "ArrowRight",
5251
+ "ArrowUp",
5252
+ "ArrowDown",
5253
+ "Home",
5254
+ "End",
5255
+ "PageUp",
5256
+ "PageDown"
5257
+ ].includes(event.key))
5258
+ commit();
5259
+ },
5260
+ onBlur: commit,
5261
+ onPointerCancel: () => setDraft(undefined)
5262
+ })
5263
+ ]
5264
+ }),
5265
+ /* @__PURE__ */ jsxs14("div", {
5266
+ className: "chat-composer-menu-row chat-composer-description",
5267
+ children: [
5268
+ /* @__PURE__ */ jsx16("span", {
5269
+ children: setting.choices[0]?.label
5270
+ }),
5271
+ /* @__PURE__ */ jsx16("span", {
5272
+ children: setting.choices.at(-1)?.label
5273
+ })
5274
+ ]
5275
+ })
5276
+ ]
5277
+ });
5278
+ }
5279
+ function SettingsMenu({
5280
+ group,
5281
+ ...props
5282
+ }) {
5283
+ const id = useId10();
5284
+ const anchor = `--settings-${id.replace(/[^a-zA-Z0-9_-]/g, "")}`;
5285
+ const panel = useRef10(null);
5286
+ const trigger = useRef10(null);
5287
+ const [open, setOpen] = useState10(false);
5288
+ const settings = group.settingIds.flatMap((key) => props.settings.filter((setting) => setting.id === key));
5289
+ const warning = settings.some((setting) => setting.choices.find((choice) => choice.value === setting.value)?.tone === "warning");
5290
+ function choose(setting, value) {
5291
+ if (props.busy || setting.unavailableReason || setting.choices.find((choice) => choice.value === value)?.unavailableReason)
5292
+ return;
5293
+ props.request(setting.id, value);
5294
+ panel.current?.querySelectorAll("[popover]").forEach((element) => element.hidePopover?.());
5295
+ panel.current?.hidePopover?.();
5296
+ trigger.current?.focus({ preventScroll: true });
5297
+ }
5298
+ function choices(setting) {
5299
+ return setting.choices.map((choice) => /* @__PURE__ */ jsxs14("button", {
5300
+ type: "button",
5301
+ className: cn("popover-menu-item chat-composer-menu-option", choice.tone === "warning" && "chat-composer-menu-option-warning"),
5302
+ "aria-pressed": setting.value === choice.value,
5303
+ disabled: props.busy || !!setting.unavailableReason || !!choice.unavailableReason,
5304
+ onClick: () => choose(setting, choice.value),
5305
+ children: [
5306
+ choice.icon,
5307
+ /* @__PURE__ */ jsxs14("span", {
5308
+ className: "chat-composer-label",
5309
+ children: [
5310
+ choice.label,
5311
+ choice.description ? /* @__PURE__ */ jsx16("span", {
5312
+ className: "chat-composer-description",
5313
+ children: choice.description
5314
+ }) : null,
5315
+ choice.unavailableReason ? /* @__PURE__ */ jsx16("span", {
5316
+ className: "chat-composer-description",
5317
+ children: choice.unavailableReason
5318
+ }) : null
5319
+ ]
5320
+ }),
5321
+ setting.value === choice.value ? /* @__PURE__ */ jsx16("span", {
5322
+ "aria-hidden": "true",
5323
+ children: "✓"
5324
+ }) : null
5325
+ ]
5326
+ }, choice.value));
5327
+ }
5328
+ return /* @__PURE__ */ jsxs14(Fragment9, {
5329
+ children: [
5330
+ /* @__PURE__ */ jsxs14("button", {
5331
+ ref: trigger,
5332
+ type: "button",
5333
+ className: cn("btn btn-ghost btn-sm chat-composer-config", group.appearance && `chat-composer-${group.appearance}`, props.className),
5334
+ "data-active": group.appearance === "access" ? warning : undefined,
5335
+ "aria-label": `${group.label}: ${settings.map((setting) => setting.choices.find((choice) => choice.value === setting.value)?.label ?? setting.value).join(", ")}`,
5336
+ title: group.label,
5337
+ popoverTarget: id,
5338
+ "aria-controls": id,
5339
+ "aria-expanded": open,
5340
+ disabled: settings.every((setting) => !!setting.unavailableReason),
5341
+ "aria-busy": props.busy || undefined,
5342
+ style: { anchorName: anchor },
5343
+ children: [
5344
+ group.icon,
5345
+ /* @__PURE__ */ jsx16("span", {
5346
+ className: "chat-composer-label",
5347
+ children: settings.map((setting, index) => /* @__PURE__ */ jsxs14(React15.Fragment, {
5348
+ children: [
5349
+ index ? " " : null,
5350
+ /* @__PURE__ */ jsx16("span", {
5351
+ className: setting.ordered ? "chat-composer-effort" : undefined,
5352
+ children: setting.choices.find((choice) => choice.value === setting.value)?.label ?? setting.value
5353
+ })
5354
+ ]
5355
+ }, setting.id))
5356
+ }),
5357
+ /* @__PURE__ */ jsx16("span", {
5358
+ "aria-hidden": "true",
5359
+ children: "⌄"
5360
+ })
5361
+ ]
5362
+ }),
5363
+ /* @__PURE__ */ jsx16("div", {
5364
+ id,
5365
+ ref: panel,
5366
+ popover: "auto",
5367
+ role: "group",
5368
+ "aria-label": group.appearance === "model" ? `Composer ${group.label.toLowerCase()}` : group.label,
5369
+ className: cn("popover popover-menu chat-composer-menu", group.appearance === "model" && "chat-composer-menu-end"),
5370
+ style: { positionAnchor: anchor },
5371
+ onToggle: (event) => setOpen(event.newState === "open"),
5372
+ children: settings.map((setting) => /* @__PURE__ */ jsxs14(React15.Fragment, {
5373
+ children: [
5374
+ setting.ordered ? /* @__PURE__ */ jsx16(OrderedSetting, {
5375
+ setting,
5376
+ disabled: props.busy || !!setting.unavailableReason,
5377
+ choose: (value) => choose(setting, value)
5378
+ }, `${setting.id}-${setting.value}-${props.revision}`) : group.nestedSettingIds?.includes(setting.id) ? /* @__PURE__ */ jsx16(NestedSetting, {
5379
+ id: `${id}-${setting.id}`,
5380
+ setting,
5381
+ disabled: props.busy || !!setting.unavailableReason,
5382
+ anchor,
5383
+ children: choices(setting)
5384
+ }) : /* @__PURE__ */ jsxs14(Fragment9, {
5385
+ children: [
5386
+ /* @__PURE__ */ jsx16("div", {
5387
+ className: "chat-composer-group",
5388
+ children: setting.label
5389
+ }),
5390
+ choices(setting)
5391
+ ]
5392
+ }),
5393
+ setting.unavailableReason ? /* @__PURE__ */ jsx16("p", {
5394
+ className: "chat-composer-description",
5395
+ children: setting.unavailableReason
5396
+ }) : null
5397
+ ]
5398
+ }, setting.id))
5399
+ })
5400
+ ]
5401
+ });
5402
+ }
5403
+ function NestedSetting({
5404
+ id,
5405
+ setting,
5406
+ disabled,
5407
+ anchor,
5408
+ children
5409
+ }) {
5410
+ const [open, setOpen] = useState10(false);
5411
+ return /* @__PURE__ */ jsxs14(Fragment9, {
5412
+ children: [
5413
+ /* @__PURE__ */ jsxs14("button", {
5414
+ type: "button",
5415
+ className: "popover-menu-item",
5416
+ "aria-label": `Choose a ${setting.label.toLowerCase()}: ${setting.choices.find((choice) => choice.value === setting.value)?.label ?? setting.value}`,
5417
+ disabled,
5418
+ popoverTarget: id,
5419
+ "aria-controls": id,
5420
+ "aria-expanded": open,
5421
+ children: [
5422
+ /* @__PURE__ */ jsx16("span", {
5423
+ className: "chat-composer-label",
5424
+ children: setting.choices.find((choice) => choice.value === setting.value)?.label ?? setting.value
5425
+ }),
5426
+ /* @__PURE__ */ jsx16("span", {
5427
+ "aria-hidden": "true",
5428
+ children: "›"
5429
+ })
5430
+ ]
5431
+ }),
5432
+ /* @__PURE__ */ jsxs14("div", {
5433
+ id,
5434
+ popover: "auto",
5435
+ role: "group",
5436
+ "aria-label": `Choose a ${setting.label.toLowerCase()}`,
5437
+ className: "popover popover-menu chat-composer-menu chat-composer-menu-end",
5438
+ style: { positionAnchor: anchor },
5439
+ onToggle: (event) => setOpen(event.newState === "open"),
5440
+ children: [
5441
+ /* @__PURE__ */ jsxs14("div", {
5442
+ className: "chat-composer-group",
5443
+ children: [
5444
+ "Select ",
5445
+ setting.label.toLowerCase()
5446
+ ]
5447
+ }),
5448
+ children
5449
+ ]
5450
+ })
5451
+ ]
5452
+ });
5453
+ }
5000
5454
 
5001
5455
  // src/components/select/Select.tsx
5002
- import React13, {
5003
- forwardRef as forwardRef9,
5456
+ import React16, {
5457
+ forwardRef as forwardRef11,
5004
5458
  useCallback as useCallback3,
5005
5459
  useEffect as useEffect3,
5006
- useId as useId9,
5460
+ useId as useId11,
5007
5461
  useMemo,
5008
- useRef as useRef9,
5009
- useState as useState10
5462
+ useRef as useRef11,
5463
+ useState as useState11
5010
5464
  } from "react";
5011
5465
 
5012
5466
  // src/classes/select.ts
@@ -5063,7 +5517,7 @@ function getSelectOptionClasses({
5063
5517
  }
5064
5518
 
5065
5519
  // src/components/select/Select.tsx
5066
- import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
5520
+ import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
5067
5521
  function isGroup(option) {
5068
5522
  return "options" in option;
5069
5523
  }
@@ -5088,8 +5542,8 @@ function normalizeMultiValue(value) {
5088
5542
  }
5089
5543
  function optionsFromChildren(children) {
5090
5544
  const result = [];
5091
- React13.Children.forEach(children, (child) => {
5092
- if (!React13.isValidElement(child)) {
5545
+ React16.Children.forEach(children, (child) => {
5546
+ if (!React16.isValidElement(child)) {
5093
5547
  return;
5094
5548
  }
5095
5549
  if (child.type === Option) {
@@ -5139,19 +5593,19 @@ function filterOptions(options, searchValue, filterOption) {
5139
5593
  function renderValue(option) {
5140
5594
  return option ? optionLabel(option) : null;
5141
5595
  }
5142
- var Option = forwardRef9(({ children, ...props }, ref) => /* @__PURE__ */ jsx14("div", {
5596
+ var Option = forwardRef11(({ children, ...props }, ref) => /* @__PURE__ */ jsx17("div", {
5143
5597
  ...props,
5144
5598
  ref,
5145
5599
  children
5146
5600
  }));
5147
5601
  Option.displayName = "Select.Option";
5148
- var OptGroup = forwardRef9(({ children, ...props }, ref) => /* @__PURE__ */ jsx14("div", {
5602
+ var OptGroup = forwardRef11(({ children, ...props }, ref) => /* @__PURE__ */ jsx17("div", {
5149
5603
  ...props,
5150
5604
  ref,
5151
5605
  children
5152
5606
  }));
5153
5607
  OptGroup.displayName = "Select.OptGroup";
5154
- var SelectRoot = forwardRef9(({
5608
+ var SelectRoot = forwardRef11(({
5155
5609
  allowClear,
5156
5610
  "aria-describedby": ariaDescribedBy,
5157
5611
  "aria-errormessage": ariaErrorMessage,
@@ -5180,16 +5634,16 @@ var SelectRoot = forwardRef9(({
5180
5634
  value,
5181
5635
  ...props
5182
5636
  }, ref) => {
5183
- const generatedId = useId9();
5637
+ const generatedId = useId11();
5184
5638
  const cleanId = generatedId.replace(/[^a-zA-Z0-9_-]/g, "");
5185
5639
  const triggerId = id || `select-${cleanId}`;
5186
5640
  const dropdownId = `select-dropdown-${cleanId}`;
5187
5641
  const anchorName = `--dm-select-${cleanId}`;
5188
- const [internalOpen, setInternalOpen] = useState10(Boolean(defaultOpen));
5642
+ const [internalOpen, setInternalOpen] = useState11(Boolean(defaultOpen));
5189
5643
  const isControlled = openProp !== undefined;
5190
5644
  const isOpen = isControlled ? Boolean(openProp) : internalOpen;
5191
- const containerRef = useRef9(null);
5192
- const dropdownRef = useRef9(null);
5645
+ const containerRef = useRef11(null);
5646
+ const dropdownRef = useRef11(null);
5193
5647
  const setOpenState = useCallback3((nextOpen) => {
5194
5648
  if (!isControlled) {
5195
5649
  setInternalOpen(nextOpen);
@@ -5234,8 +5688,8 @@ var SelectRoot = forwardRef9(({
5234
5688
  const multiple = mode === "multiple" || mode === "tags";
5235
5689
  const sourceOptions = useMemo(() => options ?? optionsFromChildren(children), [children, options]);
5236
5690
  const flatOptions = useMemo(() => flattenOptions(sourceOptions), [sourceOptions]);
5237
- const [searchValue, setSearchValue] = useState10("");
5238
- const [internalValue, setInternalValue] = useState10(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
5691
+ const [searchValue, setSearchValue] = useState11("");
5692
+ const [internalValue, setInternalValue] = useState11(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
5239
5693
  const controlled = value !== undefined;
5240
5694
  const currentValue = controlled ? value : internalValue;
5241
5695
  const selectedValues = multiple ? normalizeMultiValue(currentValue) : normalizeSingleValue(currentValue) === undefined ? [] : [normalizeSingleValue(currentValue)];
@@ -5292,7 +5746,7 @@ var SelectRoot = forwardRef9(({
5292
5746
  }
5293
5747
  function renderOption(option) {
5294
5748
  const selected = selectedKeys.has(valueKey(option.value));
5295
- return /* @__PURE__ */ jsx14("button", {
5749
+ return /* @__PURE__ */ jsx17("button", {
5296
5750
  type: "button",
5297
5751
  role: "option",
5298
5752
  "aria-selected": selected,
@@ -5311,11 +5765,11 @@ var SelectRoot = forwardRef9(({
5311
5765
  if (!isGroup(option)) {
5312
5766
  return renderOption(option);
5313
5767
  }
5314
- return /* @__PURE__ */ jsxs12("div", {
5768
+ return /* @__PURE__ */ jsxs15("div", {
5315
5769
  className: cn(selectGroupClass, option.className),
5316
5770
  role: "group",
5317
5771
  children: [
5318
- /* @__PURE__ */ jsx14("div", {
5772
+ /* @__PURE__ */ jsx17("div", {
5319
5773
  className: selectGroupLabelClass,
5320
5774
  children: option.label
5321
5775
  }),
@@ -5332,11 +5786,11 @@ var SelectRoot = forwardRef9(({
5332
5786
  ref.current = node;
5333
5787
  }
5334
5788
  };
5335
- const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx14("span", {
5789
+ const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx17("span", {
5336
5790
  className: selectTagClass,
5337
5791
  children: renderValue(option)
5338
5792
  }, valueKey(option.value))) : renderValue(selectedOptions[0]);
5339
- return /* @__PURE__ */ jsxs12("div", {
5793
+ return /* @__PURE__ */ jsxs15("div", {
5340
5794
  ...props,
5341
5795
  ref: setRefs,
5342
5796
  className: getSelectContainerClasses({
@@ -5347,7 +5801,7 @@ var SelectRoot = forwardRef9(({
5347
5801
  className
5348
5802
  }),
5349
5803
  children: [
5350
- /* @__PURE__ */ jsxs12("button", {
5804
+ /* @__PURE__ */ jsxs15("button", {
5351
5805
  type: "button",
5352
5806
  id: triggerId,
5353
5807
  className: getSelectClasses({ size, status, disabled }),
@@ -5368,17 +5822,17 @@ var SelectRoot = forwardRef9(({
5368
5822
  setOpenState(!isOpen);
5369
5823
  },
5370
5824
  children: [
5371
- /* @__PURE__ */ jsx14("span", {
5825
+ /* @__PURE__ */ jsx17("span", {
5372
5826
  className: selectSelectionClass,
5373
- children: hasValue ? selection : /* @__PURE__ */ jsx14("span", {
5827
+ children: hasValue ? selection : /* @__PURE__ */ jsx17("span", {
5374
5828
  className: selectPlaceholderClass,
5375
5829
  children: placeholder
5376
5830
  })
5377
5831
  }),
5378
- /* @__PURE__ */ jsx14("span", {
5832
+ /* @__PURE__ */ jsx17("span", {
5379
5833
  className: selectIconClass,
5380
5834
  "aria-hidden": "true",
5381
- children: /* @__PURE__ */ jsx14("svg", {
5835
+ children: /* @__PURE__ */ jsx17("svg", {
5382
5836
  width: "16",
5383
5837
  height: "16",
5384
5838
  viewBox: "0 0 24 24",
@@ -5388,19 +5842,19 @@ var SelectRoot = forwardRef9(({
5388
5842
  strokeLinecap: "round",
5389
5843
  strokeLinejoin: "round",
5390
5844
  "aria-hidden": "true",
5391
- children: /* @__PURE__ */ jsx14("path", {
5845
+ children: /* @__PURE__ */ jsx17("path", {
5392
5846
  d: "m6 9 6 6 6-6"
5393
5847
  })
5394
5848
  })
5395
5849
  })
5396
5850
  ]
5397
5851
  }),
5398
- allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx14("button", {
5852
+ allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx17("button", {
5399
5853
  type: "button",
5400
5854
  className: selectClearClass,
5401
5855
  "aria-label": "Clear selection",
5402
5856
  onClick: clearValue,
5403
- children: /* @__PURE__ */ jsx14("svg", {
5857
+ children: /* @__PURE__ */ jsx17("svg", {
5404
5858
  width: "14",
5405
5859
  height: "14",
5406
5860
  viewBox: "0 0 24 24",
@@ -5409,12 +5863,12 @@ var SelectRoot = forwardRef9(({
5409
5863
  strokeWidth: "2",
5410
5864
  strokeLinecap: "round",
5411
5865
  "aria-hidden": "true",
5412
- children: /* @__PURE__ */ jsx14("path", {
5866
+ children: /* @__PURE__ */ jsx17("path", {
5413
5867
  d: "m6 6 12 12M6 18 18 6"
5414
5868
  })
5415
5869
  })
5416
5870
  }) : null,
5417
- isOpen ? /* @__PURE__ */ jsxs12("div", {
5871
+ isOpen ? /* @__PURE__ */ jsxs15("div", {
5418
5872
  id: dropdownId,
5419
5873
  ref: dropdownRef,
5420
5874
  popover: "auto",
@@ -5431,7 +5885,7 @@ var SelectRoot = forwardRef9(({
5431
5885
  }
5432
5886
  },
5433
5887
  children: [
5434
- searchable ? /* @__PURE__ */ jsx14("input", {
5888
+ searchable ? /* @__PURE__ */ jsx17("input", {
5435
5889
  className: selectSearchClass,
5436
5890
  value: searchValue,
5437
5891
  placeholder: typeof placeholder === "string" ? placeholder : undefined,
@@ -5443,7 +5897,7 @@ var SelectRoot = forwardRef9(({
5443
5897
  }
5444
5898
  }
5445
5899
  }) : null,
5446
- visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx14("div", {
5900
+ visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx17("div", {
5447
5901
  className: selectEmptyClass,
5448
5902
  children: "No data"
5449
5903
  })
@@ -5458,25 +5912,25 @@ Select.Option = Option;
5458
5912
  Select.OptGroup = OptGroup;
5459
5913
 
5460
5914
  // src/components/chat/ComposerSettings.tsx
5461
- import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
5915
+ import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
5462
5916
  function ComposerSettings(props) {
5463
- return /* @__PURE__ */ jsx15(SettingsSession, {
5917
+ return /* @__PURE__ */ jsx18(SettingsSession, {
5464
5918
  ...props
5465
5919
  }, props.scopeKey);
5466
5920
  }
5467
5921
  function SettingsSession(props) {
5468
- const latest = useRef10(props);
5469
- const watermark = useRef10(props.revision);
5470
- useLayoutEffect12(() => {
5922
+ const latest = useRef12(props);
5923
+ const watermark = useRef12(props.revision);
5924
+ useLayoutEffect13(() => {
5471
5925
  latest.current = props;
5472
5926
  watermark.current = Math.max(watermark.current, props.revision);
5473
5927
  });
5474
- const requests = useRef10(new Map);
5475
- const nextId = useRef10(0);
5476
- const instanceId = useId10();
5477
- const [pending, setPending] = useState11([]);
5478
- const [feedback, setFeedback] = useState11({});
5479
- useLayoutEffect12(() => {
5928
+ const requests = useRef12(new Map);
5929
+ const nextId = useRef12(0);
5930
+ const instanceId = useId12();
5931
+ const [pending, setPending] = useState12([]);
5932
+ const [feedback, setFeedback] = useState12({});
5933
+ useLayoutEffect13(() => {
5480
5934
  const active = requests.current;
5481
5935
  return () => {
5482
5936
  for (const controller of active.values())
@@ -5536,7 +5990,14 @@ function SettingsSession(props) {
5536
5990
  }
5537
5991
  }
5538
5992
  }
5539
- return /* @__PURE__ */ jsx15("div", {
5993
+ if (props.variant === "menu")
5994
+ return /* @__PURE__ */ jsx18(ComposerSettingsMenus, {
5995
+ ...props,
5996
+ busy: pending.length > 0,
5997
+ feedback,
5998
+ request
5999
+ });
6000
+ return /* @__PURE__ */ jsx18("div", {
5540
6001
  className: cn("chat-composer-toolbar", props.className),
5541
6002
  role: "group",
5542
6003
  "aria-label": props.label ?? "Composer settings",
@@ -5544,9 +6005,9 @@ function SettingsSession(props) {
5544
6005
  const busy = pending.length > 0;
5545
6006
  const descriptionId = `${instanceId}-${setting.id}-description`;
5546
6007
  const description = busy ? "Change pending" : feedback[setting.id] || setting.unavailableReason;
5547
- return /* @__PURE__ */ jsxs13("div", {
6008
+ return /* @__PURE__ */ jsxs16("div", {
5548
6009
  children: [
5549
- /* @__PURE__ */ jsx15(Select, {
6010
+ /* @__PURE__ */ jsx18(Select, {
5550
6011
  "aria-label": setting.label,
5551
6012
  "aria-describedby": description ? descriptionId : undefined,
5552
6013
  value: setting.value,
@@ -5562,7 +6023,7 @@ function SettingsSession(props) {
5562
6023
  request(setting.id, value);
5563
6024
  }
5564
6025
  }),
5565
- description ? /* @__PURE__ */ jsx15("p", {
6026
+ description ? /* @__PURE__ */ jsx18("p", {
5566
6027
  id: descriptionId,
5567
6028
  className: "chat-composer-status",
5568
6029
  role: "status",
@@ -5582,6 +6043,10 @@ export {
5582
6043
  ChatBubble,
5583
6044
  ChatComposer,
5584
6045
  ChatComposerActions,
6046
+ ChatComposerConnection,
6047
+ ChatComposerContext,
6048
+ ChatComposerContextEnd,
6049
+ ChatComposerContextItem,
5585
6050
  ChatComposerForm,
5586
6051
  ChatComposerHint,
5587
6052
  ChatComposerInput,
@@ -5591,6 +6056,7 @@ export {
5591
6056
  ChatInputArea,
5592
6057
  ChatQueue,
5593
6058
  ChatReasoning,
6059
+ ChatRequest,
5594
6060
  ChatScroll,
5595
6061
  ChatScrollBody,
5596
6062
  ChatScrollIndicator,