@epam/ai-dial-conversation-input 1.2.0-dev.28 → 1.2.0-dev.284

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.
Files changed (44) hide show
  1. package/components/AddAttachmentButton/AddAttachmentButton.d.ts +6 -0
  2. package/components/AddAttachmentButton/AddAttachmentButton.d.ts.map +1 -1
  3. package/components/BottomSheetShell/BottomSheetShell.d.ts +2 -2
  4. package/components/BottomSheetShell/BottomSheetShell.d.ts.map +1 -1
  5. package/components/ChatSettingsModal/ChatSettingsModal.d.ts.map +1 -1
  6. package/components/ConversationInput/ConversationInput.d.ts.map +1 -1
  7. package/components/EditMessageInput/EditMessageInput.d.ts.map +1 -1
  8. package/components/Input/Input.d.ts +2 -3
  9. package/components/Input/Input.d.ts.map +1 -1
  10. package/components/Input/ModelSelectorControl.d.ts +3 -1
  11. package/components/Input/ModelSelectorControl.d.ts.map +1 -1
  12. package/components/ModelSelectorBottomSheet/ModelSelectorBottomSheet.d.ts +3 -0
  13. package/components/ModelSelectorBottomSheet/ModelSelectorBottomSheet.d.ts.map +1 -1
  14. package/components/ToolsChips/ToolsChips.d.ts +11 -0
  15. package/components/ToolsChips/ToolsChips.d.ts.map +1 -1
  16. package/components/VoiceBar/VoiceBar.d.ts +1 -3
  17. package/components/VoiceBar/VoiceBar.d.ts.map +1 -1
  18. package/constants/public-class-names.d.ts +41 -0
  19. package/constants/public-class-names.d.ts.map +1 -0
  20. package/hooks/useAttachments.d.ts.map +1 -1
  21. package/hooks/useCommandMenu/useCommandMenu.d.ts +35 -5
  22. package/hooks/useCommandMenu/useCommandMenu.d.ts.map +1 -1
  23. package/hooks/useComposerSeed.d.ts +32 -0
  24. package/hooks/useComposerSeed.d.ts.map +1 -0
  25. package/hooks/useMentionSelectionMirror.d.ts +22 -0
  26. package/hooks/useMentionSelectionMirror.d.ts.map +1 -0
  27. package/hooks/useModelSelector.d.ts +7 -13
  28. package/hooks/useModelSelector.d.ts.map +1 -1
  29. package/hooks/useTextInsertion.d.ts +24 -2
  30. package/hooks/useTextInsertion.d.ts.map +1 -1
  31. package/hooks/useVoiceRecorder.d.ts.map +1 -1
  32. package/index.css +2 -2
  33. package/index.d.ts +5 -2
  34. package/index.d.ts.map +1 -1
  35. package/index.js +1549 -1257
  36. package/models/ConversationInput.d.ts +99 -16
  37. package/models/ConversationInput.d.ts.map +1 -1
  38. package/models/Input.d.ts +207 -32
  39. package/models/Input.d.ts.map +1 -1
  40. package/package.json +4 -5
  41. package/utils/highlight-mirror.d.ts +17 -0
  42. package/utils/highlight-mirror.d.ts.map +1 -0
  43. package/hooks/useBottomSheet.d.ts +0 -9
  44. package/hooks/useBottomSheet.d.ts.map +0 -1
package/index.js CHANGED
@@ -1,159 +1,110 @@
1
- import { AttachmentErrorReason as e, AttachmentType as t, DeploymentIcon as n, RESIZABLE_TEXTAREA_CLASS_NAME as r, RequestStatus as i, ResponseFormat as a, SELECT_LIST_MAX_HEIGHT_PX as o, buildCssVars as s, mergeClasses as c, useIsMobile as l } from "@epam/ai-dial-chat-shared";
2
- import { BASE_ICON_SIZE as u, Button as d, CloseButton as f, DIAL_ICON_SIZE as p, DIAL_KIT_ICON_STROKE as m, Dropdown as h, ElementSize as g, ErrorText as _, GhostIconButton as v, Highlight as y, MenuItemMark as b, NeutralButton as x, Popup as S, PopupSize as C, PrimaryButton as w, PrimaryIconButton as T, RadioGroup as E, RadioGroupOrientation as D, Search as O, Skeleton as k, SkeletonVariant as ee, Slider as A, Spinner as te, StaticIconButton as j, Textarea as ne, TextareaResize as M, Tooltip as N } from "@epam/ai-dial-ui-kit";
3
- import { IconArrowLeft as re, IconArrowNarrowRight as ie, IconCheck as P, IconChevronDown as F, IconChevronRight as ae, IconFile as oe, IconMicrophone as se, IconPaperclip as ce, IconPlayerStopFilled as I, IconPlaystationSquare as le, IconPlus as ue, IconSettings as de, IconTool as fe, IconX as pe } from "@tabler/icons-react";
4
- import { createElement as me, memo as he, useCallback as L, useEffect as R, useImperativeHandle as ge, useLayoutEffect as _e, useMemo as z, useRef as B, useState as V } from "react";
5
- import { createPortal as H } from "react-dom";
6
- import { Fragment as U, jsx as W, jsxs as G } from "react/jsx-runtime";
7
- import { AttachmentTray as ve, MAX_UPLOADS_PER_MINUTE as ye, generateAttachmentId as be, useClipboardPaste as xe } from "@epam/ai-dial-attachment-input";
8
- //#region src/hooks/useBottomSheet.ts
9
- var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])", Ce = (e, t, n) => {
10
- R(() => {
11
- if (!e) return;
12
- let n = (e) => {
13
- e.key === "Escape" && t();
14
- };
15
- return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
16
- }, [e, t]), R(() => {
17
- if (e) return document.body.style.overflow = "hidden", () => {
18
- document.body.style.overflow = "";
19
- };
20
- }, [e]), R(() => {
21
- if (!e || n?.current == null) return;
22
- let t = n.current, r = document.activeElement instanceof HTMLElement ? document.activeElement : null;
23
- (t.querySelector(Se) ?? t).focus();
24
- let i = (e) => {
25
- if (e.key !== "Tab") return;
26
- let n = Array.from(t.querySelectorAll(Se));
27
- if (n.length === 0) {
28
- e.preventDefault(), t.focus();
29
- return;
30
- }
31
- let r = n[0], i = n[n.length - 1], a = document.activeElement, o = a === t || a === null || !t.contains(a);
32
- e.shiftKey ? (a === r || o) && (e.preventDefault(), i.focus()) : (a === i || o) && (e.preventDefault(), r.focus());
33
- };
34
- return document.addEventListener("keydown", i), () => {
35
- document.removeEventListener("keydown", i), r?.focus();
36
- };
37
- }, [e, n]);
38
- }, we = {
39
- backdrop: "_backdrop_1d50f_9",
40
- sheet: "_sheet_1d50f_13",
41
- "slide-up": "_slide-up_1d50f_1",
42
- title: "_title_1d50f_18",
43
- divider: "_divider_1d50f_22"
44
- }, Te = ({ isOpen: e, title: t, closeLabel: n, onClose: r, onBack: i, backLabel: a, "aria-label": o, style: l, titleClassName: u = "dial-body-semi-text", className: d, colors: h, children: _ }) => {
45
- let y = B(null);
46
- if (Ce(e, r, y), !e || typeof document > "u") return null;
47
- let b = s({
48
- "--ci-backdrop": h?.backdrop,
49
- "--ci-sheet-bg": h?.sheetBg,
50
- "--ci-sheet-text": h?.sheetText,
51
- "--ci-sheet-divider": h?.divider
1
+ import { AttachmentErrorReason as e, AttachmentType as t, DeploymentIcon as n, MIME_TYPE_EXT_MAP as r, RESIZABLE_TEXTAREA_CLASS_NAME as i, RequestStatus as a, ResponseFormat as o, SELECT_LIST_MAX_HEIGHT_PX as s, buildCssVars as c, mergeClasses as l, normalizeMimeType as u, useIsMobile as d } from "@epam/ai-dial-chat-shared";
2
+ import { BASE_ICON_SIZE as f, BottomSheet as p, Button as m, ButtonVariant as h, DIAL_ICON_SIZE as g, DIAL_KIT_ICON_STROKE as _, Dropdown as v, ElementSize as y, ErrorText as b, GhostIconButton as x, Highlight as S, MenuItemMark as C, NeutralButton as w, NeutralIconButton as T, Popup as E, PopupSize as D, PrimaryButton as ee, PrimaryIconButton as O, RadioGroup as k, RadioGroupOrientation as te, Search as A, Skeleton as ne, SkeletonVariant as j, Slider as re, Spinner as ie, Textarea as M, TextareaResize as N, Tooltip as ae } from "@epam/ai-dial-ui-kit";
3
+ import { Fragment as oe, jsx as P, jsxs as F } from "react/jsx-runtime";
4
+ import { AttachmentTray as se, MAX_UPLOADS_PER_MINUTE as I, generateAttachmentId as ce, useClipboardPaste as le } from "@epam/ai-dial-attachment-input";
5
+ import { IconArrowNarrowRight as ue, IconCheck as L, IconChevronDown as de, IconChevronRight as fe, IconFile as pe, IconMicrophone as me, IconPaperclip as he, IconPlayerStop as ge, IconPlus as _e, IconSettings as ve, IconTool as ye, IconX as be } from "@tabler/icons-react";
6
+ import { createElement as xe, forwardRef as Se, memo as Ce, useCallback as R, useEffect as z, useId as we, useImperativeHandle as Te, useLayoutEffect as Ee, useMemo as B, useRef as V, useState as H } from "react";
7
+ //#region src/constants/public-class-names.ts
8
+ var U = {
9
+ wrapper: "dial-ci-wrapper",
10
+ actionRow: "dial-ci-action-row",
11
+ textareaWrap: "dial-ci-textarea-wrap",
12
+ addCluster: "dial-ci-add-cluster",
13
+ toolsChips: "dial-ci-tools-chips",
14
+ footerActions: "dial-ci-footer-actions",
15
+ modelSelectorButton: "dial-ci-model-selector-button",
16
+ modelSelectorIcon: "dial-ci-model-selector-icon",
17
+ modelSelectorCaret: "dial-ci-model-selector-caret",
18
+ modelMenu: "dial-ci-model-menu",
19
+ modelMenuSearch: "dial-ci-model-menu-search",
20
+ modelMenuItem: "dial-ci-model-menu-item",
21
+ modelMenuItemSelected: "dial-ci-model-menu-item-selected"
22
+ }, De = {
23
+ backdrop: "_backdrop_1ym62_8",
24
+ sheet: "_sheet_1ym62_12",
25
+ title: "_title_1ym62_16",
26
+ divider: "_divider_1ym62_20"
27
+ }, W = ({ isOpen: e, title: t, closeLabel: n, onClose: r, onBack: i, backLabel: a, "aria-label": o, style: s, titleClassName: u = "dial-body-semi-text", className: d, colors: f, children: m }) => {
28
+ let h = c({
29
+ "--ci-backdrop": f?.backdrop,
30
+ "--ci-sheet-bg": f?.sheetBg,
31
+ "--ci-sheet-text": f?.sheetText,
32
+ "--ci-sheet-divider": f?.divider
52
33
  });
53
- return H(/* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("div", {
54
- className: c(we.backdrop, "fixed inset-0 z-[55]"),
55
- style: b,
56
- onPointerDown: r,
57
- "aria-hidden": !0
58
- }), /* @__PURE__ */ G("div", {
59
- ref: y,
60
- role: "dialog",
61
- "aria-modal": !0,
62
- "aria-label": t ?? o,
63
- tabIndex: -1,
34
+ return /* @__PURE__ */ P(p, {
35
+ open: e,
36
+ onClose: r,
37
+ title: t,
38
+ ariaLabel: o,
39
+ onBack: i,
40
+ backAriaLabel: a,
41
+ closeAriaLabel: n,
64
42
  style: {
65
- ...b,
66
- ...l
43
+ ...h,
44
+ ...s
67
45
  },
68
- className: c(we.sheet, "fixed inset-x-0 bottom-0 z-[60] flex max-h-[85dvh] flex-col rounded-t-lg", d),
69
- children: [t != null && /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ G("div", {
70
- className: "relative flex h-[60px] flex-shrink-0 items-center justify-center px-4",
71
- children: [
72
- i && /* @__PURE__ */ W("div", {
73
- className: "absolute start-4",
74
- children: /* @__PURE__ */ W(v, {
75
- icon: /* @__PURE__ */ W(re, {
76
- size: p.LG,
77
- stroke: m,
78
- className: "rtl:scale-x-[-1]"
79
- }),
80
- "aria-label": a,
81
- onClick: i
82
- })
83
- }),
84
- /* @__PURE__ */ W("span", {
85
- className: c(we.title, u),
86
- children: t
87
- }),
88
- /* @__PURE__ */ W("div", {
89
- className: "absolute end-4 m-2",
90
- children: /* @__PURE__ */ W(f, {
91
- ariaLabel: n,
92
- onClose: r,
93
- size: g.Standard
94
- })
95
- })
96
- ]
97
- }), /* @__PURE__ */ W("div", { className: c(we.divider, "h-px flex-shrink-0") })] }), /* @__PURE__ */ W("div", {
98
- className: "overflow-y-auto",
99
- children: _
100
- })]
101
- })] }), document.body);
102
- }, Ee = async (e, t, n) => {
46
+ overlayStyle: h,
47
+ className: l(De.sheet, d),
48
+ overlayClassName: De.backdrop,
49
+ headerClassName: De.divider,
50
+ titleClassName: l(De.title, u),
51
+ children: m
52
+ });
53
+ }, Oe = async (e, t, n) => {
103
54
  let r = 6e4 / t, i = [];
104
55
  for (let t = 0; t < e.length; t++) t > 0 && await new Promise((e) => setTimeout(e, r)), i.push(n(e[t]));
105
56
  await Promise.allSettled(i);
106
- }, De = ({ initialAttachments: n, onUploadAttachment: r, onAttachmentsChange: a, validateAttachment: o, pendingDropFiles: s, onDropFilesConsumed: c, pendingAttachments: l, onPendingAttachmentsConsumed: u, onExpandPastedText: d, maximumAttachmentsAmount: f, baseAttachmentsAmount: p = 0, onAttachmentsLimitExceeded: m }) => {
107
- let [h, g] = V(n), _ = B(h);
108
- R(() => {
57
+ }, ke = ({ initialAttachments: n, onUploadAttachment: r, onAttachmentsChange: i, validateAttachment: o, pendingDropFiles: s, onDropFilesConsumed: c, pendingAttachments: l, onPendingAttachmentsConsumed: u, onExpandPastedText: d, maximumAttachmentsAmount: f, baseAttachmentsAmount: p = 0, onAttachmentsLimitExceeded: m }) => {
58
+ let [h, g] = H(n), _ = V(h);
59
+ z(() => {
109
60
  _.current = h;
110
- }, [h]), R(() => () => {
61
+ }, [h]), z(() => () => {
111
62
  _.current.forEach((e) => {
112
63
  e.previewUrl && URL.revokeObjectURL(e.previewUrl), e.playUrl && URL.revokeObjectURL(e.playUrl);
113
64
  });
114
65
  }, []);
115
- let v = L((e) => e.map((e) => {
116
- let n = e.type.startsWith("image/"), r = e.type.startsWith("audio/"), a = n ? URL.createObjectURL(e) : void 0, o = r ? URL.createObjectURL(e) : void 0;
66
+ let v = R((e) => e.map((e) => {
67
+ let n = e.type.startsWith("image/"), r = e.type.startsWith("audio/"), i = n ? URL.createObjectURL(e) : void 0, o = r ? URL.createObjectURL(e) : void 0;
117
68
  return {
118
- id: be(),
69
+ id: ce(),
119
70
  name: e.name,
120
71
  contentType: e.type,
121
72
  file: e,
122
73
  type: n ? t.Image : r ? t.Audio : t.File,
123
- status: i.Idle,
124
- previewUrl: a,
74
+ status: a.Idle,
75
+ previewUrl: i,
125
76
  playUrl: o
126
77
  };
127
- }), []), y = B(a);
128
- R(() => {
129
- y.current = a;
130
- }, [a]);
131
- let b = B(!0), x = L((e) => {
78
+ }), []), y = V(i);
79
+ z(() => {
80
+ y.current = i;
81
+ }, [i]);
82
+ let b = V(!0), x = R((e) => {
132
83
  g((t) => {
133
84
  let n = e(t);
134
85
  return n === t ? t : n;
135
86
  });
136
87
  }, []);
137
- R(() => {
88
+ z(() => {
138
89
  if (b.current) {
139
90
  b.current = !1;
140
91
  return;
141
92
  }
142
93
  y.current?.(h);
143
94
  }, [h]);
144
- let S = L((e) => {
95
+ let S = R((e) => {
145
96
  g(e);
146
- }, []), C = L(async (t) => {
97
+ }, []), C = R(async (t) => {
147
98
  if (r) {
148
99
  x((e) => e.map((e) => e.id === t.id ? {
149
100
  ...e,
150
- status: i.Loading
101
+ status: a.Loading
151
102
  } : e));
152
103
  try {
153
104
  let { url: e, name: n } = await r(t);
154
105
  x((r) => r.map((r) => r.id === t.id ? {
155
106
  ...r,
156
- status: i.Idle,
107
+ status: a.Idle,
157
108
  url: e,
158
109
  name: n
159
110
  } : r));
@@ -161,12 +112,12 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
161
112
  let r = typeof n == "object" && n && "errorReason" in n && Object.values(e).includes(n.errorReason) ? n.errorReason : void 0;
162
113
  x((e) => e.map((e) => e.id === t.id ? {
163
114
  ...e,
164
- status: i.Error,
115
+ status: a.Error,
165
116
  ...r != null && { errorReason: r }
166
117
  } : e));
167
118
  }
168
119
  }
169
- }, [r, x]), w = L((e, t = !0) => {
120
+ }, [r, x]), w = R((e, t = !0) => {
170
121
  let n = new Set(_.current.map((e) => e.id)), r = e.filter((e) => !n.has(e.id));
171
122
  if (r.length !== 0) {
172
123
  if (f != null && f > 0 && Number.isFinite(f)) {
@@ -184,10 +135,10 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
184
135
  let n = o?.(t);
185
136
  n == null ? e.push(t) : x((e) => e.map((e) => e.id === t.id ? {
186
137
  ...e,
187
- status: i.Error,
138
+ status: a.Error,
188
139
  errorReason: n
189
140
  } : e));
190
- }), Ee(e, ye, C);
141
+ }), Oe(e, I, C);
191
142
  }
192
143
  }
193
144
  }, [
@@ -197,35 +148,40 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
197
148
  x,
198
149
  C,
199
150
  o
200
- ]);
201
- R(() => {
202
- s.length !== 0 && (w(v(s)), c?.());
151
+ ]), T = V(/* @__PURE__ */ new WeakSet());
152
+ z(() => {
153
+ if (s.length === 0) {
154
+ T.current = /* @__PURE__ */ new WeakSet();
155
+ return;
156
+ }
157
+ let e = s.filter((e) => !T.current.has(e));
158
+ e.length !== 0 && (e.forEach((e) => T.current.add(e)), w(v(e)), c?.());
203
159
  }, [
204
160
  w,
205
161
  v,
206
162
  c,
207
163
  s
208
- ]), R(() => {
164
+ ]), z(() => {
209
165
  l.length !== 0 && (w(l, !1), u?.());
210
166
  }, [
211
167
  w,
212
168
  u,
213
169
  l
214
- ]), R(() => {
170
+ ]), z(() => {
215
171
  if (!o) return;
216
172
  let t = !1, n = [], r = _.current.map((r) => {
217
- if (r.status === i.Loading) return r;
218
- let a = o(r);
219
- if (a != null) return r.status === i.Error && r.errorReason === a ? r : (t = !0, {
173
+ if (r.status === a.Loading) return r;
174
+ let i = o(r);
175
+ if (i != null) return r.status === a.Error && r.errorReason === i ? r : (t = !0, {
220
176
  ...r,
221
- status: i.Error,
222
- errorReason: a
177
+ status: a.Error,
178
+ errorReason: i
223
179
  });
224
- if (r.errorReason === e.UnsupportedType) {
180
+ if (r.errorReason === e.UnsupportedType || r.errorReason === e.FileTooLarge) {
225
181
  t = !0;
226
182
  let e = {
227
183
  ...r,
228
- status: i.Idle,
184
+ status: a.Idle,
229
185
  errorReason: void 0
230
186
  };
231
187
  return e.url ?? n.push(e), e;
@@ -238,7 +194,7 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
238
194
  x,
239
195
  C
240
196
  ]);
241
- let T = L((e) => {
197
+ let E = R((e) => {
242
198
  x((t) => {
243
199
  let n = t.find((t) => t.id === e);
244
200
  return n?.previewUrl && URL.revokeObjectURL(n.previewUrl), n?.playUrl && URL.revokeObjectURL(n.playUrl), t.filter((t) => t.id !== e);
@@ -249,63 +205,120 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
249
205
  buildAttachments: v,
250
206
  addAttachments: w,
251
207
  resetAttachments: S,
252
- handleRemove: T,
253
- handleRetry: L((e) => {
208
+ handleRemove: E,
209
+ handleRetry: R((e) => {
254
210
  let t = h.find((t) => t.id === e);
255
211
  t && C(t);
256
212
  }, [h, C]),
257
- handleExpand: L(async (e) => {
213
+ handleExpand: R(async (e) => {
258
214
  let n = h.find((t) => t.id === e);
259
215
  if (!n || n.type !== t.Pasted) return;
260
216
  let r = await n.file.text();
261
- d?.(r), T(e);
217
+ d?.(r), E(e);
262
218
  }, [
263
219
  h,
264
- T,
220
+ E,
265
221
  d
266
222
  ]),
267
- hasBlockedAttachments: h.some((e) => e.status === i.Loading || e.status === i.Error)
223
+ hasBlockedAttachments: h.some((e) => e.status === a.Loading || e.status === a.Error)
224
+ };
225
+ }, G = (e, t) => {
226
+ let n = t;
227
+ for (; n < e.length && !/\s/.test(e[n]);) n++;
228
+ return n;
229
+ }, Ae = (e, t) => {
230
+ let n = t;
231
+ for (; n > 0 && !/\s/.test(e[n - 1]);) n--;
232
+ return {
233
+ start: n,
234
+ end: G(e, n)
268
235
  };
269
- }, Oe = (e, t) => {
270
- if (!e.startsWith(t)) return !1;
271
- let n = e.slice(t.length);
272
- return !/\s/.test(n) && !n.includes(t);
273
- }, ke = ({ config: e, message: t }) => {
274
- let [n, r] = V(!1), [i, a] = V(!1), o = e != null && Oe(t, e.triggerPrefix) ? t.slice(e.triggerPrefix.length) : "", s = L((n, a, o) => {
275
- if (e == null || a || t !== "" || i) return;
276
- let s = n === e.triggerPrefix, c = o === "insertFromPaste" && Oe(n, e.triggerPrefix);
277
- (s || c) && r(!0);
236
+ }, je = (e, t) => e.startsWith(t) && !e.slice(t.length).includes(t), Me = "[role=\"option\"]:not([aria-disabled=\"true\"])", Ne = /* @__PURE__ */ function(e) {
237
+ return e.Next = "next", e.Previous = "previous", e;
238
+ }({}), Pe = ({ config: e, message: t }) => {
239
+ let [n, r] = H(!1), [i, a] = H(null), [o, s] = H(null), c = V(null);
240
+ c.current = i;
241
+ let l = e != null && i != null && i <= t.length ? (() => {
242
+ let n = t.slice(i, G(t, i));
243
+ return je(n, e.triggerPrefix) ? n.slice(e.triggerPrefix.length) : "";
244
+ })() : "", u = R((t, n, i) => {
245
+ if (e == null || i) return;
246
+ let { start: c, end: l } = Ae(t, n), u = t.slice(c, l);
247
+ if (!je(u, e.triggerPrefix)) {
248
+ r(!1), s(null), a(null);
249
+ return;
250
+ }
251
+ if (a(c), u === e.triggerPrefix || o !== c) {
252
+ r(!0), s(null);
253
+ return;
254
+ }
255
+ r(!1);
256
+ }, [e, o]);
257
+ z(() => {
258
+ if (e == null) {
259
+ r(!1), s(null), a(null);
260
+ return;
261
+ }
262
+ let n = c.current;
263
+ if (n == null) return;
264
+ let i = Math.min(n, t.length);
265
+ je(t.slice(i, G(t, i)), e.triggerPrefix) || (r(!1), s(null), a(null));
266
+ }, [e, t]);
267
+ let d = R(() => {
268
+ r(!1), s(i);
269
+ }, [i]), f = R(() => {
270
+ r(!1);
271
+ }, []), p = R((n) => {
272
+ if (e == null) return;
273
+ let { start: i, end: s } = Ae(t, n);
274
+ if (!je(t.slice(i, s), e.triggerPrefix)) {
275
+ a(null), r(!1);
276
+ return;
277
+ }
278
+ a(i), r(o !== i);
278
279
  }, [
279
280
  e,
280
281
  t,
281
- i
282
- ]);
283
- return R(() => {
284
- if (e == null) {
285
- r(!1), a(!1);
282
+ o
283
+ ]), m = we(), h = V(null), [g, _] = H(null);
284
+ z(() => {
285
+ _(null);
286
+ }, [n, l]);
287
+ let v = R(() => Array.from(h.current?.querySelectorAll(Me) ?? []), []), y = R((e) => {
288
+ let t = v();
289
+ if (t.length === 0) {
290
+ _(null);
286
291
  return;
287
292
  }
288
- Oe(t, e.triggerPrefix) || (r(!1), a(!1));
289
- }, [e, t]), {
293
+ let n = t.findIndex((e) => e.id === g), r = t[e === "next" ? (n + 1) % t.length : (n <= 0 ? t.length : n) - 1];
294
+ _(r.id), r.scrollIntoView?.({ block: "nearest" });
295
+ }, [v, g]), b = R(() => v().find((e) => e.id === g) ?? null, [v, g]);
296
+ return {
290
297
  isMenuOpen: n,
291
- query: o,
292
- dismiss: L(() => {
293
- r(!1), a(!0);
294
- }, []),
295
- handleValueChange: s
298
+ query: l,
299
+ activeWordStart: i,
300
+ dismiss: d,
301
+ closeOnOutsidePress: f,
302
+ handleCaretMove: p,
303
+ handleValueChange: u,
304
+ listboxId: m,
305
+ overlayRef: h,
306
+ activeOptionId: n ? g : null,
307
+ moveActiveOption: y,
308
+ getActiveOption: b
296
309
  };
297
- }, Ae = (e, t) => !e.slice(0, t).includes("\n"), je = (e, t) => !e.slice(t).includes("\n"), Me = (e) => {
298
- let t = B(e);
310
+ }, Fe = (e, t) => !e.slice(0, t).includes("\n"), Ie = (e, t) => !e.slice(t).includes("\n"), Le = (e) => {
311
+ let t = V(e);
299
312
  t.current = e;
300
- let n = B(-1), r = B(""), i = L((e, i, a) => {
313
+ let n = V(-1), r = V(""), i = R((e, i, a) => {
301
314
  let o = t.current;
302
- return !o || o.length === 0 ? null : e === "up" ? !Ae(i, a) || n.current === 0 ? null : (n.current === -1 ? (r.current = i, n.current = o.length - 1) : --n.current, o[n.current]) : n.current === -1 || !je(i, a) ? null : n.current < o.length - 1 ? (n.current += 1, o[n.current]) : (n.current = -1, r.current);
303
- }, []), a = L(() => {
315
+ return !o || o.length === 0 ? null : e === "up" ? !Fe(i, a) || n.current === 0 ? null : (n.current === -1 ? (r.current = i, n.current = o.length - 1) : --n.current, o[n.current]) : n.current === -1 || !Ie(i, a) ? null : n.current < o.length - 1 ? (n.current += 1, o[n.current]) : (n.current = -1, r.current);
316
+ }, []), a = R(() => {
304
317
  n.current = -1, r.current = "";
305
- }, []), o = L(() => {
318
+ }, []), o = R(() => {
306
319
  n.current = -1, r.current = "";
307
320
  }, []);
308
- return z(() => ({
321
+ return B(() => ({
309
322
  navigate: i,
310
323
  notifyChange: a,
311
324
  reset: o
@@ -314,185 +327,274 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
314
327
  a,
315
328
  o
316
329
  ]);
317
- }, Ne = ({ messageProp: e, messageRevision: t }) => {
318
- let [n, r] = V(e), i = B(null);
319
- return R(() => {
330
+ }, Re = (e, t, n, r, i) => {
331
+ let a = [...t].sort((e, t) => e.start - t.start), o = [...n].sort((e, t) => e.offset - t.offset), s = [], c = 0, l = 0, u = (t, n) => {
332
+ if (n <= t) return;
333
+ let r = t;
334
+ o.filter((e) => e.offset >= t && e.offset <= n).forEach((t) => {
335
+ t.offset > r && s.push(/* @__PURE__ */ P("span", {
336
+ "aria-hidden": !0,
337
+ children: e.slice(r, t.offset)
338
+ }, `text-${l++}`)), s.push(t.node), r = t.offset;
339
+ }), r < n && s.push(/* @__PURE__ */ P("span", {
340
+ "aria-hidden": !0,
341
+ children: e.slice(r, n)
342
+ }, `text-${l++}`));
343
+ };
344
+ return a.forEach((t, n) => {
345
+ if (u(c, t.start), t.start + t.length <= c) return;
346
+ let a = e.slice(t.start, t.start + t.length);
347
+ s.push(t.render ? /* @__PURE__ */ P("span", {
348
+ className: "pointer-events-auto",
349
+ children: t.render()
350
+ }, `range-${n}`) : /* @__PURE__ */ P("span", {
351
+ "aria-hidden": !0,
352
+ className: t.isUnsupported ? i : r,
353
+ children: a
354
+ }, `range-${n}`)), c = Math.max(c, t.start + t.length);
355
+ }), u(c, e.length), s;
356
+ }, ze = (e, t) => {
357
+ let n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, { acceptNode: (e) => e.parentElement?.closest("[data-mirror-synthetic]") == null ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT }), r = 0;
358
+ for (let e = n.nextNode(); e != null; e = n.nextNode()) {
359
+ let n = e.textContent?.length ?? 0;
360
+ if (t <= r + n) return {
361
+ node: e,
362
+ offset: t - r
363
+ };
364
+ r += n;
365
+ }
366
+ return null;
367
+ }, Be = (e, t, n) => {
368
+ let r = ze(e, t), i = ze(e, n);
369
+ if (r == null || i == null) return null;
370
+ let a = document.createRange();
371
+ return a.setStart(r.node, r.offset), a.setEnd(i.node, i.offset), a;
372
+ }, Ve = ({ textareaRef: e, message: t, isMirrorActive: n }) => {
373
+ let r = V(null), [i, a] = H([]), o = R(() => {
374
+ let t = e.current, i = r.current, o = t?.selectionStart, s = t?.selectionEnd;
375
+ if (!n || t == null || i == null || o == null || s == null || o === s) {
376
+ a((e) => e.length === 0 ? e : []);
377
+ return;
378
+ }
379
+ let c = Be(i, o, s);
380
+ if (c == null) {
381
+ a((e) => e.length === 0 ? e : []);
382
+ return;
383
+ }
384
+ let l = i.getBoundingClientRect();
385
+ a(Array.from(c.getClientRects()).map((e) => new DOMRect(e.left - l.left, e.top - l.top, e.width, e.height)));
386
+ }, [n, e]);
387
+ return Ee(() => {
388
+ o();
389
+ }, [o, t]), z(() => {
390
+ if (!n) return;
391
+ let t = e.current;
392
+ if (t == null || typeof ResizeObserver > "u") return;
393
+ let r = new ResizeObserver(o);
394
+ return r.observe(t), () => r.disconnect();
395
+ }, [
396
+ n,
397
+ e,
398
+ o
399
+ ]), {
400
+ mirrorRef: r,
401
+ selectionRects: i,
402
+ updateSelectionRects: o
403
+ };
404
+ }, He = ({ messageProp: e, messageRevision: t }) => {
405
+ let [n, r] = H(e), i = V(null);
406
+ return z(() => {
320
407
  r(e);
321
408
  }, [e, t]), {
322
409
  message: n,
323
410
  setMessage: r,
324
411
  textareaRef: i
325
412
  };
326
- }, Pe = (e, t, n) => {
327
- let r = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")?.set;
328
- r ? r.call(e, t) : e.value = t, e.setSelectionRange(n, n), e.dispatchEvent(new Event("input", { bubbles: !0 }));
329
- }, Fe = ({ insertion: e, textareaRef: t }) => {
330
- let n = e?.revision, r = B(e?.text);
413
+ }, Ue = (e, t, n, r = n) => {
414
+ let i = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")?.set;
415
+ i ? i.call(e, t) : e.value = t, e.setSelectionRange(n, r), e.dispatchEvent(new Event("input", { bubbles: !0 }));
416
+ }, We = (e) => e.key.toLowerCase() === "z" && (e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey, Ge = ({ insertion: e, textareaRef: t }) => {
417
+ let n = e?.revision, r = V(e?.text);
331
418
  r.current = e?.text;
332
- let i = B(n);
333
- R(() => {
419
+ let i = V(n), a = V(null);
420
+ return z(() => {
334
421
  if (n === i.current) return;
335
422
  i.current = n;
336
- let e = t.current, a = r.current;
337
- if (!e || !a) return;
338
- let { value: o, selectionStart: s, selectionEnd: c } = e, l = s ?? o.length, u = c ?? l;
339
- e.focus(), !(typeof document.execCommand == "function" && document.execCommand("insertText", !1, a)) && Pe(e, `${o.slice(0, l)}${a}${o.slice(u)}`, l + a.length);
340
- }, [n, t]);
341
- }, Ie = /* @__PURE__ */ function(e) {
423
+ let e = r.current;
424
+ !t.current || !e || queueMicrotask(() => {
425
+ let n = t.current;
426
+ if (!n) return;
427
+ let { value: r, selectionStart: i, selectionEnd: o } = n, s = i ?? r.length, c = o ?? s;
428
+ if (n.focus(), a.current = null, typeof document.execCommand == "function" && document.execCommand("insertText", !1, e)) return;
429
+ let l = `${r.slice(0, s)}${e}${r.slice(c)}`;
430
+ Ue(n, l, s + e.length), a.current = {
431
+ insertedValue: l,
432
+ previousValue: r,
433
+ previousSelectionStart: s,
434
+ previousSelectionEnd: c
435
+ };
436
+ });
437
+ }, [n, t]), { handleUndoKeyDown: (e) => {
438
+ let n = a.current, r = t.current;
439
+ return n == null || r == null || !We(e) || (a.current = null, r.value !== n.insertedValue) ? !1 : (e.preventDefault(), Ue(r, n.previousValue, n.previousSelectionStart, n.previousSelectionEnd), !0);
440
+ } };
441
+ }, Ke = /* @__PURE__ */ function(e) {
342
442
  return e.Idle = "idle", e.Recording = "recording", e.Processing = "processing", e.Error = "error", e;
343
- }({}), Le = /* @__PURE__ */ function(e) {
443
+ }({}), qe = /* @__PURE__ */ function(e) {
344
444
  return e.Dictation = "dictation", e.Attachment = "attachment", e;
345
- }({}), Re = [
445
+ }({}), Je = [
346
446
  "audio/webm;codecs=opus",
347
447
  "audio/ogg;codecs=opus",
348
448
  "audio/webm"
349
- ], ze = 100, Be = 100, Ve = .01, He = ({ onAttachAudio: e, onTranscribeAudio: t, onTranscript: n, errorLabel: r = "Voice input failed" }) => {
350
- let [i, a] = V("idle"), [o, s] = V(null), c = B(null), l = B(null), u = B({
449
+ ], Ye = 100, Xe = 100, Ze = .01, Qe = ({ onAttachAudio: e, onTranscribeAudio: t, onTranscript: n, errorLabel: i = "Voice input failed" }) => {
450
+ let [a, o] = H("idle"), [s, c] = H(null), l = V(null), d = V(null), f = V({
351
451
  onAttachAudio: e,
352
452
  onTranscribeAudio: t,
353
453
  onTranscript: n,
354
- errorLabel: r
454
+ errorLabel: i
355
455
  });
356
- u.current = {
456
+ f.current = {
357
457
  onAttachAudio: e,
358
458
  onTranscribeAudio: t,
359
459
  onTranscript: n,
360
- errorLabel: r
460
+ errorLabel: i
361
461
  };
362
- let d = L((e = "dictation") => {
363
- if (l.current) return;
462
+ let p = R((e = "dictation") => {
463
+ if (d.current) return;
364
464
  let t = { controller: new AbortController() };
365
- l.current = t, s(null), a("recording");
366
- let { signal: n } = t.controller, r = e === "dictation" ? u.current.onTranscribeAudio : void 0, i, o, d, f, p = !1, m = !1, h = [], g = () => {
367
- clearInterval(f), f = void 0;
368
- }, _ = () => {
369
- g(), d &&= (d.ondataavailable = null, d.onstop = null, d.onerror = null, d.state !== "inactive" && d.stop(), void 0), i?.getTracks().forEach((e) => e.stop()), i = void 0, o &&= (o.close(), void 0), l.current === t && (c.current = null);
465
+ d.current = t, c(null), o("recording");
466
+ let { signal: n } = t.controller, i = e === "dictation" ? f.current.onTranscribeAudio : void 0, a, s, p, m, h = !1, g = !1, _ = [], v = () => {
467
+ clearInterval(m), m = void 0;
468
+ }, y = () => {
469
+ v(), p &&= (p.ondataavailable = null, p.onstop = null, p.onerror = null, p.state !== "inactive" && p.stop(), void 0), a?.getTracks().forEach((e) => e.stop()), a = void 0, s &&= (s.close(), void 0), d.current === t && (l.current = null);
370
470
  };
371
471
  n.addEventListener("abort", () => {
372
- h.length = 0, _();
472
+ _.length = 0, y();
373
473
  }, { once: !0 });
374
- let v = () => {
375
- n.aborted || (_(), l.current = null, s(null), a("idle"));
376
- }, y = (e) => {
377
- n.aborted || (t.controller.abort(), l.current = null, s(e instanceof Error ? e.message : u.current.errorLabel), a("error"));
378
- }, b = () => {
379
- if (!i || n.aborted) return;
380
- let e = Re.find((e) => MediaRecorder.isTypeSupported(e)), t = new MediaRecorder(i, e ? { mimeType: e } : void 0);
381
- d = t;
382
- let o = Date.now(), s = !1, l = !1, b = new Uint8Array(c.current?.fftSize ?? 256), x = async () => {
383
- if (!(m || n.aborted)) {
384
- m = !0, p = !0;
474
+ let b = () => {
475
+ n.aborted || (y(), d.current = null, c(null), o("idle"));
476
+ }, x = (e) => {
477
+ n.aborted || (t.controller.abort(), d.current = null, c(e instanceof Error ? e.message : f.current.errorLabel), o("error"));
478
+ }, S = () => {
479
+ if (!a || n.aborted) return;
480
+ let e = Je.find((e) => MediaRecorder.isTypeSupported(e)), t = new MediaRecorder(a, e ? { mimeType: e } : void 0);
481
+ p = t;
482
+ let s = Date.now(), c = !1, d = !1, S = new Uint8Array(l.current?.fftSize ?? 256), C = async () => {
483
+ if (!(g || n.aborted)) {
484
+ g = !0, h = !0;
385
485
  try {
386
- let i = t.mimeType || e || "audio/webm", c = new Blob(h, { type: i });
387
- h.length = 0, _();
388
- let d = Date.now() - o >= Be;
389
- if (c.size && (!r || d && (!s || l))) {
390
- let e = i.split(";")[0].split("/")[1] ?? "webm", t = new File([c], "voice-" + crypto.randomUUID() + "." + e, { type: i });
391
- if (r) {
392
- a("processing");
393
- let e = await r(t, n);
486
+ let a = t.mimeType || e || "audio/webm", l = new Blob(_, { type: a });
487
+ _.length = 0, y();
488
+ let p = Date.now() - s >= Xe;
489
+ if (l.size && (!i || p && (!c || d))) {
490
+ let e = u(a), t = r[e] ?? e.split("/")[1] ?? "webm", s = new File([l], "voice-" + crypto.randomUUID() + "." + t, { type: a });
491
+ if (i) {
492
+ o("processing");
493
+ let e = await i(s, n);
394
494
  if (n.aborted) return;
395
- u.current.onTranscript?.(e);
396
- } else u.current.onAttachAudio(t);
397
- } else r && u.current.onTranscript?.("");
398
- v();
495
+ f.current.onTranscript?.(e);
496
+ } else f.current.onAttachAudio(s);
497
+ } else i && f.current.onTranscript?.("");
498
+ b();
399
499
  } catch (e) {
400
- y(e);
500
+ x(e);
401
501
  }
402
502
  }
403
503
  };
404
504
  t.ondataavailable = (e) => {
405
- e.data.size && h.push(e.data);
406
- }, t.onerror = () => y(Error(u.current.errorLabel)), t.onstop = () => {
407
- x();
408
- }, t.start(), r && (f = setInterval(() => {
409
- let e = c.current;
505
+ e.data.size && _.push(e.data);
506
+ }, t.onerror = () => x(Error(f.current.errorLabel)), t.onstop = () => {
507
+ C();
508
+ }, t.start(), i && (m = setInterval(() => {
509
+ let e = l.current;
410
510
  if (!e) return;
411
- e.getByteTimeDomainData(b), s = !0;
511
+ e.getByteTimeDomainData(S), c = !0;
412
512
  let t = 0;
413
- for (let e of b) t += ((e - 128) / 128) ** 2;
414
- Math.sqrt(t / b.length) >= Ve && (l = !0, g());
415
- }, ze));
513
+ for (let e of S) t += ((e - 128) / 128) ** 2;
514
+ Math.sqrt(t / S.length) >= Ze && (d = !0, v());
515
+ }, Ye));
416
516
  };
417
517
  t.stop = () => {
418
- p || n.aborted || (p = !0, g(), a("processing"), d?.state === "recording" && d.stop());
518
+ h || n.aborted || (h = !0, v(), o("processing"), p?.state === "recording" && p.stop());
419
519
  }, (async () => {
420
520
  try {
421
521
  let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
422
- if (n.aborted || p) {
423
- e.getTracks().forEach((e) => e.stop()), v();
522
+ if (n.aborted || h) {
523
+ e.getTracks().forEach((e) => e.stop()), b();
424
524
  return;
425
525
  }
426
- i = e, o = new AudioContext();
427
- let t = o.createAnalyser();
428
- t.fftSize = 256, c.current = t, o.createMediaStreamSource(i).connect(t), b(), a("recording");
526
+ a = e, s = new AudioContext();
527
+ let t = s.createAnalyser();
528
+ t.fftSize = 256, l.current = t, s.createMediaStreamSource(a).connect(t), S(), o("recording");
429
529
  } catch (e) {
430
- y(e);
530
+ x(e);
431
531
  }
432
532
  })();
433
- }, []), f = L(() => l.current?.stop?.(), []), p = L(() => {
434
- l.current?.controller.abort(), l.current = null, s(null), a("idle");
533
+ }, []), m = R(() => d.current?.stop?.(), []), h = R(() => {
534
+ d.current?.controller.abort(), d.current = null, c(null), o("idle");
435
535
  }, []);
436
- return R(() => () => {
437
- l.current?.controller.abort(), l.current = null;
536
+ return z(() => () => {
537
+ d.current?.controller.abort(), d.current = null;
438
538
  }, []), {
439
- state: i,
440
- analyserNodeRef: c,
441
- errorMessage: o,
442
- startRecording: d,
443
- stopRecording: f,
444
- discardRecording: p
539
+ state: a,
540
+ analyserNodeRef: l,
541
+ errorMessage: s,
542
+ startRecording: p,
543
+ stopRecording: m,
544
+ discardRecording: h
445
545
  };
446
- }, Ue = /* @__PURE__ */ function(e) {
546
+ }, $e = /* @__PURE__ */ function(e) {
447
547
  return e.Enter = "enter", e.MetaEnter = "meta-enter", e;
448
- }({}), We = {
548
+ }({}), et = /* @__PURE__ */ function(e) {
549
+ return e.Stacked = "stacked", e.Inline = "inline", e;
550
+ }({}), tt = {
449
551
  item: "_item_1sr2n_1",
450
552
  itemIcon: "_itemIcon_1sr2n_11"
451
- }, Ge = ({ isOpen: e, title: t, closeLabel: n, onClose: r, style: i, items: a, className: o, titleClassName: l = "dial-body-semi-text", itemLabelClassName: u = "dial-small-text", btnTextClassName: f = "", colors: p }) => {
452
- let m = (e) => {
553
+ }, nt = ({ isOpen: e, title: t, closeLabel: n, onClose: r, style: i, items: a, className: o, titleClassName: s = "dial-body-semi-text", itemLabelClassName: u = "dial-small-text", btnTextClassName: d = "", colors: f }) => {
554
+ let p = (e) => {
453
555
  e(), r();
454
- }, h = s({
455
- "--ci-sheet-text": p?.itemText,
456
- "--ci-sheet-item-hover": p?.itemHoverBg,
457
- "--ci-sheet-item-active": p?.itemActiveBg,
458
- "--ci-sheet-icon": p?.itemIcon
556
+ }, h = c({
557
+ "--ci-sheet-text": f?.itemText,
558
+ "--ci-sheet-item-hover": f?.itemHoverBg,
559
+ "--ci-sheet-item-active": f?.itemActiveBg,
560
+ "--ci-sheet-icon": f?.itemIcon
459
561
  });
460
- return /* @__PURE__ */ W(Te, {
562
+ return /* @__PURE__ */ P(W, {
461
563
  isOpen: e,
462
564
  title: t,
463
565
  closeLabel: n,
464
566
  onClose: r,
465
567
  style: i,
466
568
  className: o,
467
- titleClassName: l,
468
- colors: p?.shell,
469
- children: /* @__PURE__ */ W("ul", {
569
+ titleClassName: s,
570
+ colors: f?.shell,
571
+ children: /* @__PURE__ */ P("ul", {
470
572
  role: "list",
471
573
  className: "flex flex-col",
472
574
  style: h,
473
- children: a.map(({ key: e, label: t, icon: n, iconAfter: r, onClick: i }) => /* @__PURE__ */ W("li", { children: /* @__PURE__ */ W(d, {
575
+ children: a.map(({ key: e, label: t, icon: n, iconAfter: r, onClick: i }) => /* @__PURE__ */ P("li", { children: /* @__PURE__ */ P(m, {
474
576
  type: "button",
475
- className: c(We.item, "w-full gap-3 px-4 py-[10px] text-start"),
476
- iconBefore: /* @__PURE__ */ W("span", {
477
- className: We.itemIcon,
577
+ className: l(tt.item, "w-full gap-3 px-4 py-[10px] text-start"),
578
+ iconBefore: /* @__PURE__ */ P("span", {
579
+ className: tt.itemIcon,
478
580
  children: n
479
581
  }),
480
- iconAfter: r ? /* @__PURE__ */ W("span", {
582
+ iconAfter: r ? /* @__PURE__ */ P("span", {
481
583
  className: "ms-auto",
482
584
  children: r
483
585
  }) : null,
484
- textClassName: f,
485
- label: /* @__PURE__ */ W("span", {
586
+ textClassName: d,
587
+ label: /* @__PURE__ */ P("span", {
486
588
  className: u,
487
589
  children: t
488
590
  }),
489
- onClick: () => m(i)
591
+ onClick: () => p(i)
490
592
  }) }, e))
491
593
  })
492
594
  });
493
- }, Ke = ({ features: e, initialResponseFormat: t, initialSystemPrompt: n, initialTemperature: r, onSave: i, onClose: a, isOpen: o }) => {
494
- let [s, c] = V(t), [l, u] = V(n), [d, f] = V(r), p = B(o);
495
- R(() => {
595
+ }, rt = ({ features: e, initialResponseFormat: t, initialSystemPrompt: n, initialTemperature: r, onSave: i, onClose: a, isOpen: o }) => {
596
+ let [s, c] = H(t), [l, u] = H(n), [d, f] = H(r), p = V(o);
597
+ z(() => {
496
598
  o && !p.current && (c(t), u(n), f(r)), p.current = o;
497
599
  }, [
498
600
  o,
@@ -509,7 +611,7 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
509
611
  setResponseFormat: c,
510
612
  setSystemPrompt: u,
511
613
  setTemperature: f,
512
- handleSubmit: L(() => {
614
+ handleSubmit: R(() => {
513
615
  if (!m) return;
514
616
  let t = {};
515
617
  e.responseFormat && s != null && (t.responseFormat = s), e.systemPrompt && (t.systemPrompt = l), e.temperature && (t.temperature = d), i(t), a();
@@ -523,17 +625,17 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
523
625
  a
524
626
  ])
525
627
  };
526
- }, qe = { label: "_label_14i7c_1" }, Je = ({ features: e, responseFormat: t, systemPrompt: n, temperature: i, onResponseFormatChange: o, onSystemPromptChange: l, onTemperatureChange: u, responseFormatLabel: d = "Response format", responseFormatHint: f = "Applies to new and existing messages", responseFormatMarkdownLabel: p = "Markdown", responseFormatPlainTextLabel: m = "Plain text", systemPromptLabel: h = "System prompt", systemPromptTooltip: g = "Enter a prompt", temperatureLabel: _ = "Temperature", temperatureLabels: v = [
628
+ }, it = { label: "_label_14i7c_1" }, at = ({ features: e, responseFormat: t, systemPrompt: n, temperature: r, onResponseFormatChange: a, onSystemPromptChange: s, onTemperatureChange: u, responseFormatLabel: d = "Response format", responseFormatHint: f = "Applies to new and existing messages", responseFormatMarkdownLabel: p = "Markdown", responseFormatPlainTextLabel: m = "Plain text", systemPromptLabel: h = "System prompt", systemPromptTooltip: g = "Enter a prompt", temperatureLabel: _ = "Temperature", temperatureLabels: v = [
527
629
  "Precise",
528
630
  "Neutral",
529
631
  "Creative"
530
632
  ], temperatureHint: y, labelClassName: b = "!dial-small-semi-text", colors: x }) => {
531
- let S = s({ "--csf-label-text": x?.labelText }), C = c(b, qe.label, "gap-1");
532
- return /* @__PURE__ */ G("div", {
633
+ let S = c({ "--csf-label-text": x?.labelText }), C = l(b, it.label, "gap-1");
634
+ return /* @__PURE__ */ F("div", {
533
635
  className: "flex flex-col gap-4 px-6 pb-3",
534
636
  style: S,
535
637
  children: [
536
- e.responseFormat && /* @__PURE__ */ W(E, {
638
+ e.responseFormat && /* @__PURE__ */ P(k, {
537
639
  id: "response-format",
538
640
  labelProps: {
539
641
  label: d,
@@ -541,35 +643,35 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
541
643
  caption: f
542
644
  },
543
645
  optionsClassName: "mb-2",
544
- orientation: D.Column,
545
- value: t ?? a.Markdown,
646
+ orientation: te.Column,
647
+ value: t ?? o.Markdown,
546
648
  items: [{
547
- value: a.Markdown,
649
+ value: o.Markdown,
548
650
  label: p
549
651
  }, {
550
- value: a.PlainText,
652
+ value: o.PlainText,
551
653
  label: m
552
654
  }],
553
- onChange: (e) => o(e)
655
+ onChange: (e) => a(e)
554
656
  }),
555
- e.systemPrompt && /* @__PURE__ */ W(ne, {
657
+ e.systemPrompt && /* @__PURE__ */ P(M, {
556
658
  value: n,
557
659
  placeholder: g,
558
- className: r,
559
- resize: M.Vertical,
660
+ className: i,
661
+ resize: N.Vertical,
560
662
  labelProps: {
561
663
  className: C,
562
664
  label: h
563
665
  },
564
- onChange: (e) => l(e ?? "")
666
+ onChange: (e) => s(e ?? "")
565
667
  }),
566
- e.temperature && /* @__PURE__ */ W(A, {
668
+ e.temperature && /* @__PURE__ */ P(re, {
567
669
  labelProps: {
568
670
  label: _,
569
671
  className: C,
570
672
  caption: y
571
673
  },
572
- value: i,
674
+ value: r,
573
675
  min: 0,
574
676
  max: 1,
575
677
  step: .1,
@@ -579,17 +681,17 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
579
681
  })
580
682
  ]
581
683
  });
582
- }, K = ({ isOpen: e, onBack: t, backLabel: n, onClose: r, closeLabel: i, style: a, features: o, initialResponseFormat: s, initialSystemPrompt: l, initialTemperature: u, onSave: d, title: f = "Chat settings", responseFormatLabel: p, responseFormatHint: m, responseFormatMarkdownLabel: h, responseFormatPlainTextLabel: g, systemPromptLabel: _, systemPromptTooltip: v, temperatureLabel: y, temperatureLabels: b, temperatureHint: x, saveLabel: S = "Apply changes", saveDisabledTooltip: C }) => {
583
- let { responseFormat: T, systemPrompt: E, temperature: D, canSubmit: O, setResponseFormat: k, setSystemPrompt: ee, setTemperature: A, handleSubmit: te } = Ke({
684
+ }, ot = ({ isOpen: e, onBack: t, backLabel: n, onClose: r, closeLabel: i, style: a, features: o, initialResponseFormat: s, initialSystemPrompt: c, initialTemperature: u, onSave: d, title: f = "Chat settings", responseFormatLabel: p, responseFormatHint: m, responseFormatMarkdownLabel: h, responseFormatPlainTextLabel: g, systemPromptLabel: _, systemPromptTooltip: v, temperatureLabel: y, temperatureLabels: b, temperatureHint: x, saveLabel: S = "Apply changes", saveDisabledTooltip: C }) => {
685
+ let { responseFormat: w, systemPrompt: T, temperature: E, canSubmit: D, setResponseFormat: O, setSystemPrompt: k, setTemperature: te, handleSubmit: A } = rt({
584
686
  isOpen: e,
585
687
  features: o,
586
688
  initialResponseFormat: s,
587
- initialSystemPrompt: l,
689
+ initialSystemPrompt: c,
588
690
  initialTemperature: u,
589
691
  onSave: d,
590
692
  onClose: r
591
693
  });
592
- return /* @__PURE__ */ G(Te, {
694
+ return /* @__PURE__ */ F(W, {
593
695
  isOpen: e,
594
696
  title: f,
595
697
  closeLabel: i,
@@ -597,14 +699,14 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
597
699
  onBack: t,
598
700
  backLabel: n,
599
701
  style: a,
600
- children: [/* @__PURE__ */ W(Je, {
702
+ children: [/* @__PURE__ */ P(at, {
601
703
  features: o,
602
- responseFormat: T,
603
- systemPrompt: E,
604
- temperature: D,
605
- onResponseFormatChange: k,
606
- onSystemPromptChange: ee,
607
- onTemperatureChange: A,
704
+ responseFormat: w,
705
+ systemPrompt: T,
706
+ temperature: E,
707
+ onResponseFormatChange: O,
708
+ onSystemPromptChange: k,
709
+ onTemperatureChange: te,
608
710
  responseFormatLabel: p,
609
711
  responseFormatHint: m,
610
712
  responseFormatMarkdownLabel: h,
@@ -614,23 +716,23 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
614
716
  temperatureLabel: y,
615
717
  temperatureLabels: b,
616
718
  temperatureHint: x
617
- }), /* @__PURE__ */ W("div", {
618
- className: c("px-6 py-4 mobile:pb-8"),
619
- children: /* @__PURE__ */ W(N, {
719
+ }), /* @__PURE__ */ P("div", {
720
+ className: l("px-6 py-4 mobile:pb-8"),
721
+ children: /* @__PURE__ */ P(ae, {
620
722
  tooltip: C,
621
- hideTooltip: O || !C,
723
+ hideTooltip: D || !C,
622
724
  triggerClassName: "w-full",
623
- children: /* @__PURE__ */ W(w, {
725
+ children: /* @__PURE__ */ P(ee, {
624
726
  label: S,
625
- onClick: te,
626
- disabled: !O,
727
+ onClick: A,
728
+ disabled: !D,
627
729
  className: "w-full"
628
730
  })
629
731
  })
630
732
  })]
631
733
  });
632
- }, Ye = { modal: "_modal_kl0h0_1" }, Xe = ({ features: e, initialResponseFormat: t, initialSystemPrompt: n, initialTemperature: r, onSave: i, onClose: a, title: o = "Chat settings", titleClassName: s = "dial-h1-text", responseFormatLabel: c, responseFormatHint: l, responseFormatMarkdownLabel: u, responseFormatPlainTextLabel: d, systemPromptLabel: f, systemPromptTooltip: p, temperatureLabel: m, temperatureLabels: h, temperatureHint: g, saveLabel: _ = "Apply changes", saveDisabledTooltip: v, backgroundClassName: y = Ye.modal }) => {
633
- let { responseFormat: b, systemPrompt: x, temperature: T, canSubmit: E, setResponseFormat: D, setSystemPrompt: O, setTemperature: k, handleSubmit: ee } = Ke({
734
+ }, st = { modal: "_modal_kl0h0_1" }, ct = ({ features: e, initialResponseFormat: t, initialSystemPrompt: n, initialTemperature: r, onSave: i, onClose: a, title: o = "Chat settings", titleClassName: s = "dial-h1-text", responseFormatLabel: c, responseFormatHint: l, responseFormatMarkdownLabel: u, responseFormatPlainTextLabel: d, systemPromptLabel: f, systemPromptTooltip: p, temperatureLabel: m, temperatureLabels: g, temperatureHint: _, saveLabel: v = "Apply changes", saveDisabledTooltip: y, backgroundClassName: b = st.modal }) => {
735
+ let { responseFormat: x, systemPrompt: S, temperature: C, canSubmit: w, setResponseFormat: T, setSystemPrompt: ee, setTemperature: O, handleSubmit: k } = rt({
634
736
  features: e,
635
737
  initialResponseFormat: t,
636
738
  initialSystemPrompt: n,
@@ -638,33 +740,31 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
638
740
  onSave: i,
639
741
  onClose: a
640
742
  });
641
- return /* @__PURE__ */ W(S, {
743
+ return /* @__PURE__ */ P(E, {
642
744
  open: !0,
643
745
  header: o,
644
746
  titleClassName: s,
645
- size: C.Sm,
747
+ size: D.Sm,
646
748
  onClose: a,
647
- className: y,
648
- footer: /* @__PURE__ */ W("div", {
649
- className: "flex justify-end px-6 py-4",
650
- children: /* @__PURE__ */ W(N, {
651
- tooltip: v,
652
- hideTooltip: E || !v,
653
- children: /* @__PURE__ */ W(w, {
654
- label: _,
655
- onClick: ee,
656
- disabled: !E
657
- })
658
- })
659
- }),
660
- children: /* @__PURE__ */ W(Je, {
749
+ className: b,
750
+ mainButtons: [{
751
+ label: v,
752
+ variant: h.Primary,
753
+ onClick: k,
754
+ disabled: !w,
755
+ tooltipProps: y ? {
756
+ tooltip: y,
757
+ hideTooltip: w
758
+ } : void 0
759
+ }],
760
+ children: /* @__PURE__ */ P(at, {
661
761
  features: e,
662
- responseFormat: b,
663
- systemPrompt: x,
664
- temperature: T,
665
- onResponseFormatChange: D,
666
- onSystemPromptChange: O,
667
- onTemperatureChange: k,
762
+ responseFormat: x,
763
+ systemPrompt: S,
764
+ temperature: C,
765
+ onResponseFormatChange: T,
766
+ onSystemPromptChange: ee,
767
+ onTemperatureChange: O,
668
768
  responseFormatLabel: c,
669
769
  responseFormatHint: l,
670
770
  responseFormatMarkdownLabel: u,
@@ -672,14 +772,14 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
672
772
  systemPromptLabel: f,
673
773
  systemPromptTooltip: p,
674
774
  temperatureLabel: m,
675
- temperatureLabels: h,
676
- temperatureHint: g
775
+ temperatureLabels: g,
776
+ temperatureHint: _
677
777
  })
678
778
  });
679
- }, Ze = {
779
+ }, lt = {
680
780
  icon: "_icon_1fv6z_1",
681
781
  selectedIcon: "_selectedIcon_1fv6z_5"
682
- }, Qe = ({ isOpen: e, onBack: t, backLabel: n = "Back", onClose: r, closeLabel: i = "Close", style: a, title: o = "Tools", items: l, onToolToggle: f, itemLabelClassName: p = "dial-small-text", colors: h }) => /* @__PURE__ */ W(Te, {
782
+ }, K = ({ isOpen: e, onBack: t, backLabel: n = "Back", onClose: r, closeLabel: i = "Close", style: a, title: o = "Tools", items: s, onToolToggle: u, itemLabelClassName: d = "dial-small-text", colors: p }) => /* @__PURE__ */ P(W, {
683
783
  isOpen: e,
684
784
  title: o,
685
785
  closeLabel: i,
@@ -687,140 +787,140 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
687
787
  onBack: t,
688
788
  backLabel: n,
689
789
  style: a,
690
- children: /* @__PURE__ */ W("ul", {
790
+ children: /* @__PURE__ */ P("ul", {
691
791
  role: "menu",
692
792
  className: "flex flex-col pb-4",
693
- style: s({
694
- "--tbs-icon-text": h?.iconText,
695
- "--tbs-selected-icon-text": h?.selectedIconText
793
+ style: c({
794
+ "--tbs-icon-text": p?.iconText,
795
+ "--tbs-selected-icon-text": p?.selectedIconText
696
796
  }),
697
- children: l.map((e) => /* @__PURE__ */ W("li", {
797
+ children: s.map((e) => /* @__PURE__ */ P("li", {
698
798
  role: "none",
699
- children: /* @__PURE__ */ W(d, {
799
+ children: /* @__PURE__ */ P(m, {
700
800
  type: "button",
701
801
  role: "menuitemcheckbox",
702
802
  "aria-checked": e.isSelected,
703
803
  className: "w-full gap-3 px-4 py-[10px] text-start",
704
- iconBefore: /* @__PURE__ */ W("span", {
705
- className: c("flex items-center", Ze.icon),
804
+ iconBefore: /* @__PURE__ */ P("span", {
805
+ className: l("flex items-center", lt.icon),
706
806
  children: e.icon
707
807
  }),
708
- iconAfter: e.isSelected ? /* @__PURE__ */ W("span", {
709
- className: c("ms-auto", Ze.selectedIcon),
710
- children: /* @__PURE__ */ W(P, {
711
- size: u,
808
+ iconAfter: e.isSelected ? /* @__PURE__ */ P("span", {
809
+ className: l("ms-auto", lt.selectedIcon),
810
+ children: /* @__PURE__ */ P(L, {
811
+ size: f,
712
812
  "aria-hidden": !0,
713
- stroke: m
813
+ stroke: _
714
814
  })
715
815
  }) : null,
716
- label: /* @__PURE__ */ W("span", {
717
- className: p,
816
+ label: /* @__PURE__ */ P("span", {
817
+ className: d,
718
818
  children: e.label
719
819
  }),
720
- onClick: () => f(e.id)
820
+ onClick: () => u(e.id)
721
821
  })
722
822
  }, e.id))
723
823
  })
724
- }), $e = {
824
+ }), ut = {
725
825
  toolIcon: "_toolIcon_ma5s5_1",
726
826
  chevronIcon: "_chevronIcon_ma5s5_5"
727
- }, et = ({ onAttachClick: e, onRecordVoice: t, recordVoiceLabel: n = "Record voice", attachLabel: r, addMenuTitle: i, menuTitle: o, menuCloseLabel: d, style: f, listClassName: _ = "w-[240px]", isDisabled: y = !1, chatSettings: x, extraMenuItems: S, toolsMenuItems: C = [], onToolToggle: w, toolsMenuTitle: T = "Tools", toolsBackLabel: E = "Back", menuOverlays: D, colors: O }) => {
728
- let k = l(), [ee, A] = V(!1), [te, j] = V(!1), [ne, M] = V(!1), [N, re] = V(null), [ie, P] = V(!1), F = z(() => s({
827
+ }, dt = ({ onAttachClick: e, onRecordVoice: t, recordVoiceLabel: n = "Record voice", attachLabel: r, addMenuTitle: i, menuTitle: a, menuCloseLabel: s, style: u, listClassName: p = "w-[240px]", isDisabled: m = !1, chatSettings: h, extraMenuItems: b, toolsMenuItems: S = [], onToolToggle: w, toolsMenuTitle: T = "Tools", toolsBackLabel: E = "Back", menuOverlays: D, getCaretPosition: ee, colors: O }) => {
828
+ let k = d(), [te, A] = H(!1), [ne, j] = H(!1), [re, ie] = H(!1), [M, N] = H(null), [ae, se] = H(!1), I = B(() => c({
729
829
  "--aab-tool-icon": O?.toolIcon,
730
830
  "--aab-chevron-icon": O?.chevronIcon
731
- }), [O?.toolIcon, O?.chevronIcon]), oe = C.length > 0 && w != null, I = D != null && D.length > 0, le = z(() => C.map((e) => ({
831
+ }), [O?.toolIcon, O?.chevronIcon]), ce = S.length > 0 && w != null, le = D != null && D.length > 0, ue = B(() => S.map((e) => ({
732
832
  key: e.id,
733
833
  label: e.label,
734
- icon: /* @__PURE__ */ W("span", {
735
- style: F,
736
- className: c("flex items-center", $e.toolIcon),
834
+ icon: /* @__PURE__ */ P("span", {
835
+ style: I,
836
+ className: l("flex items-center", ut.toolIcon),
737
837
  children: e.icon
738
838
  }),
739
839
  selectable: !0,
740
- mark: b.Check,
840
+ mark: C.Check,
741
841
  checked: e.isSelected,
742
842
  onClick: () => w?.(e.id)
743
843
  })), [
744
- C,
844
+ S,
745
845
  w,
746
- F
747
- ]), pe = z(() => [
846
+ I
847
+ ]), L = B(() => [
748
848
  ...e == null ? [] : [{
749
849
  key: "attach",
750
850
  label: r,
751
- icon: /* @__PURE__ */ W(ce, {
752
- size: u,
851
+ icon: /* @__PURE__ */ P(he, {
852
+ size: f,
753
853
  "aria-hidden": !0,
754
- stroke: m
854
+ stroke: _
755
855
  }),
756
856
  onClick: e
757
857
  }],
758
- ...S ?? [],
759
- ...oe ? [{
858
+ ...b ?? [],
859
+ ...ce ? [{
760
860
  key: "tools",
761
861
  label: T,
762
- icon: /* @__PURE__ */ W(fe, {
763
- size: u,
862
+ icon: /* @__PURE__ */ P(ye, {
863
+ size: f,
764
864
  "aria-hidden": !0,
765
- stroke: m
865
+ stroke: _
766
866
  }),
767
867
  onClick: k ? () => {
768
- M(!0), A(!1);
868
+ ie(!0), A(!1);
769
869
  } : () => void 0,
770
- ...k ? { iconAfter: /* @__PURE__ */ W(ae, {
771
- size: u,
772
- stroke: m,
773
- style: F,
774
- className: c("rtl:scale-x-[-1]", $e.chevronIcon),
870
+ ...k ? { iconAfter: /* @__PURE__ */ P(fe, {
871
+ size: f,
872
+ stroke: _,
873
+ style: I,
874
+ className: l("rtl:scale-x-[-1]", ut.chevronIcon),
775
875
  "aria-hidden": !0
776
- }) } : { children: le }
876
+ }) } : { children: ue }
777
877
  }] : [],
778
878
  ...(D ?? []).map((e) => ({
779
879
  key: e.key,
780
880
  label: e.title,
781
881
  icon: e.icon,
782
882
  onClick: k ? () => {
783
- re(e.key), A(!1);
883
+ N(e.key), A(!1);
784
884
  } : () => void 0,
785
- ...k ? { iconAfter: /* @__PURE__ */ W(ae, {
786
- size: u,
787
- stroke: m,
788
- style: F,
789
- className: c("rtl:scale-x-[-1]", $e.chevronIcon),
885
+ ...k ? { iconAfter: /* @__PURE__ */ P(fe, {
886
+ size: f,
887
+ stroke: _,
888
+ style: I,
889
+ className: l("rtl:scale-x-[-1]", ut.chevronIcon),
790
890
  "aria-hidden": !0
791
891
  }) } : {
792
892
  children: [{
793
893
  key: `${e.key}-panel`,
794
894
  label: ""
795
895
  }],
796
- renderSubMenu: () => e.renderOverlay(() => P(!1))
896
+ renderSubMenu: () => e.renderOverlay(() => se(!1), ee?.() ?? 0)
797
897
  }
798
898
  })),
799
899
  ...t == null ? [] : [{
800
900
  key: "record-voice",
801
901
  label: n,
802
- icon: /* @__PURE__ */ W(se, {
803
- size: u,
902
+ icon: /* @__PURE__ */ P(me, {
903
+ size: f,
804
904
  "aria-hidden": !0,
805
- stroke: m
905
+ stroke: _
806
906
  }),
807
907
  onClick: () => {
808
- A(!1), P(!1), t();
908
+ A(!1), se(!1), t();
809
909
  }
810
910
  }],
811
- ...x == null ? [] : [{
911
+ ...h == null ? [] : [{
812
912
  key: "chat-settings",
813
- label: x.menuItemLabel ?? "Chat settings",
814
- icon: /* @__PURE__ */ W(de, {
815
- size: u,
913
+ label: h.menuItemLabel ?? "Chat settings",
914
+ icon: /* @__PURE__ */ P(ve, {
915
+ size: f,
816
916
  "aria-hidden": !0,
817
- stroke: m
917
+ stroke: _
818
918
  }),
819
- iconAfter: k ? /* @__PURE__ */ W(ae, {
820
- size: u,
821
- stroke: m,
822
- style: F,
823
- className: c("rtl:scale-x-[-1]", $e.chevronIcon),
919
+ iconAfter: k ? /* @__PURE__ */ P(fe, {
920
+ size: f,
921
+ stroke: _,
922
+ style: I,
923
+ className: l("rtl:scale-x-[-1]", ut.chevronIcon),
824
924
  "aria-hidden": !0
825
925
  }) : null,
826
926
  onClick: () => j(!0)
@@ -830,216 +930,240 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
830
930
  e,
831
931
  t,
832
932
  n,
833
- x,
834
- S,
933
+ h,
934
+ b,
835
935
  k,
836
- oe,
936
+ ce,
837
937
  T,
838
- le,
938
+ ue,
839
939
  D,
840
- F
940
+ ee,
941
+ I
841
942
  ]);
842
- if (pe.length === 0) return null;
843
- let me = /* @__PURE__ */ W(h, {
943
+ if (L.length === 0) return null;
944
+ let de = /* @__PURE__ */ P(v, {
844
945
  matchReferenceWidth: !1,
845
946
  placement: "bottom-start",
846
- listClassName: _,
847
- items: pe,
848
- open: I ? ie : void 0,
849
- onOpenChange: I ? P : void 0,
850
- children: /* @__PURE__ */ W(v, {
851
- icon: /* @__PURE__ */ W(ue, {
852
- size: p.LG,
947
+ listClassName: p,
948
+ overlayContentClassName: "flex flex-col gap-1",
949
+ items: L,
950
+ open: le ? ae : void 0,
951
+ onOpenChange: le ? se : void 0,
952
+ children: /* @__PURE__ */ P(x, {
953
+ icon: /* @__PURE__ */ P(_e, {
954
+ size: g.LG,
853
955
  "aria-hidden": !0,
854
- stroke: m
956
+ stroke: _
855
957
  }),
856
958
  "aria-label": i,
857
959
  tooltipProps: { tooltip: i },
858
- disabled: y
960
+ disabled: m
859
961
  })
860
962
  });
861
- return /* @__PURE__ */ W(U, { children: k ? /* @__PURE__ */ G(U, { children: [
862
- /* @__PURE__ */ W(v, {
863
- icon: /* @__PURE__ */ W(ue, {
864
- size: p.LG,
963
+ return /* @__PURE__ */ P(oe, { children: k ? /* @__PURE__ */ F(oe, { children: [
964
+ /* @__PURE__ */ P(x, {
965
+ icon: /* @__PURE__ */ P(_e, {
966
+ size: g.LG,
865
967
  "aria-hidden": !0,
866
- stroke: m
968
+ stroke: _
867
969
  }),
868
970
  "aria-label": i,
869
- size: g.Large,
971
+ size: y.Large,
870
972
  tooltipProps: { tooltip: i },
871
- disabled: y,
973
+ disabled: m,
872
974
  onClick: () => A(!0)
873
975
  }),
874
- /* @__PURE__ */ W(Ge, {
875
- isOpen: ee,
876
- title: o,
877
- closeLabel: d,
976
+ /* @__PURE__ */ P(nt, {
977
+ isOpen: te,
978
+ title: a,
979
+ closeLabel: s,
878
980
  onClose: () => A(!1),
879
- style: f,
880
- items: pe,
981
+ style: u,
982
+ items: L,
881
983
  className: "pb-4",
882
984
  btnTextClassName: "flex-1"
883
985
  }),
884
- oe && /* @__PURE__ */ W(Qe, {
885
- isOpen: ne,
986
+ ce && /* @__PURE__ */ P(K, {
987
+ isOpen: re,
886
988
  onBack: () => {
887
- M(!1), A(!0);
989
+ ie(!1), A(!0);
888
990
  },
889
991
  backLabel: E,
890
- onClose: () => M(!1),
891
- closeLabel: d,
892
- style: f,
992
+ onClose: () => ie(!1),
993
+ closeLabel: s,
994
+ style: u,
893
995
  title: T,
894
- items: C,
996
+ items: S,
895
997
  onToolToggle: w
896
998
  }),
897
- D?.map((e) => /* @__PURE__ */ W(Te, {
898
- isOpen: N === e.key,
999
+ D?.map((e) => /* @__PURE__ */ P(W, {
1000
+ isOpen: M === e.key,
899
1001
  title: e.title,
900
- closeLabel: d,
1002
+ closeLabel: s,
901
1003
  onBack: () => {
902
- re(null), A(!0);
1004
+ N(null), A(!0);
903
1005
  },
904
1006
  backLabel: e.backLabel ?? "Back",
905
- onClose: () => re(null),
906
- style: f,
907
- children: e.renderOverlay(() => re(null))
1007
+ onClose: () => N(null),
1008
+ style: u,
1009
+ children: /* @__PURE__ */ P("div", {
1010
+ role: "menu",
1011
+ "aria-label": e.title,
1012
+ children: e.renderOverlay(() => N(null), ee?.() ?? 0)
1013
+ })
908
1014
  }, e.key)),
909
- x != null && /* @__PURE__ */ W(K, {
910
- isOpen: te,
1015
+ h != null && /* @__PURE__ */ P(ot, {
1016
+ isOpen: ne,
911
1017
  onBack: () => {
912
1018
  j(!1), A(!0);
913
1019
  },
914
- backLabel: x.backLabel ?? "Back",
1020
+ backLabel: h.backLabel ?? "Back",
915
1021
  onClose: () => j(!1),
916
- closeLabel: d,
917
- style: f,
918
- features: x.features,
919
- initialResponseFormat: x.responseFormat ?? a.Markdown,
920
- initialSystemPrompt: x.systemPrompt,
921
- initialTemperature: x.temperature,
922
- onSave: x.onSave,
923
- title: x.title,
924
- responseFormatLabel: x.responseFormatLabel,
925
- responseFormatHint: x.responseFormatHint,
926
- responseFormatMarkdownLabel: x.responseFormatMarkdownLabel,
927
- responseFormatPlainTextLabel: x.responseFormatPlainTextLabel,
928
- systemPromptLabel: x.systemPromptLabel,
929
- systemPromptTooltip: x.systemPromptTooltip,
930
- temperatureLabel: x.temperatureLabel,
931
- temperatureLabels: x.temperatureLabels,
932
- temperatureHint: x.temperatureHint,
933
- saveLabel: x.saveLabel,
934
- saveDisabledTooltip: x.saveDisabledTooltip
1022
+ closeLabel: s,
1023
+ style: u,
1024
+ features: h.features,
1025
+ initialResponseFormat: h.responseFormat ?? o.Markdown,
1026
+ initialSystemPrompt: h.systemPrompt,
1027
+ initialTemperature: h.temperature,
1028
+ onSave: h.onSave,
1029
+ title: h.title,
1030
+ responseFormatLabel: h.responseFormatLabel,
1031
+ responseFormatHint: h.responseFormatHint,
1032
+ responseFormatMarkdownLabel: h.responseFormatMarkdownLabel,
1033
+ responseFormatPlainTextLabel: h.responseFormatPlainTextLabel,
1034
+ systemPromptLabel: h.systemPromptLabel,
1035
+ systemPromptTooltip: h.systemPromptTooltip,
1036
+ temperatureLabel: h.temperatureLabel,
1037
+ temperatureLabels: h.temperatureLabels,
1038
+ temperatureHint: h.temperatureHint,
1039
+ saveLabel: h.saveLabel,
1040
+ saveDisabledTooltip: h.saveDisabledTooltip
935
1041
  })
936
- ] }) : /* @__PURE__ */ G(U, { children: [me, x != null && te && /* @__PURE__ */ W(Xe, {
937
- features: x.features,
938
- initialResponseFormat: x.responseFormat ?? a.Markdown,
939
- initialSystemPrompt: x.systemPrompt,
940
- initialTemperature: x.temperature,
941
- onSave: x.onSave,
1042
+ ] }) : /* @__PURE__ */ F(oe, { children: [de, h != null && ne && /* @__PURE__ */ P(ct, {
1043
+ features: h.features,
1044
+ initialResponseFormat: h.responseFormat ?? o.Markdown,
1045
+ initialSystemPrompt: h.systemPrompt,
1046
+ initialTemperature: h.temperature,
1047
+ onSave: h.onSave,
942
1048
  onClose: () => j(!1),
943
- title: x.title,
944
- responseFormatLabel: x.responseFormatLabel,
945
- responseFormatHint: x.responseFormatHint,
946
- responseFormatMarkdownLabel: x.responseFormatMarkdownLabel,
947
- responseFormatPlainTextLabel: x.responseFormatPlainTextLabel,
948
- systemPromptLabel: x.systemPromptLabel,
949
- systemPromptTooltip: x.systemPromptTooltip,
950
- temperatureLabel: x.temperatureLabel,
951
- temperatureLabels: x.temperatureLabels,
952
- temperatureHint: x.temperatureHint,
953
- saveLabel: x.saveLabel,
954
- saveDisabledTooltip: x.saveDisabledTooltip
1049
+ title: h.title,
1050
+ responseFormatLabel: h.responseFormatLabel,
1051
+ responseFormatHint: h.responseFormatHint,
1052
+ responseFormatMarkdownLabel: h.responseFormatMarkdownLabel,
1053
+ responseFormatPlainTextLabel: h.responseFormatPlainTextLabel,
1054
+ systemPromptLabel: h.systemPromptLabel,
1055
+ systemPromptTooltip: h.systemPromptTooltip,
1056
+ temperatureLabel: h.temperatureLabel,
1057
+ temperatureLabels: h.temperatureLabels,
1058
+ temperatureHint: h.temperatureHint,
1059
+ saveLabel: h.saveLabel,
1060
+ saveDisabledTooltip: h.saveDisabledTooltip
955
1061
  })] }) });
956
- }, tt = {
957
- chip: "_chip_ydmd8_1",
958
- chipSelected: "_chipSelected_ydmd8_9",
959
- chipIcon: "_chipIcon_ydmd8_16",
960
- chipText: "_chipText_ydmd8_19",
961
- chipClose: "_chipClose_ydmd8_22"
962
- }, nt = (e) => `Remove ${e}`, rt = ({ items: e, onToolToggle: t, onToolDismiss: n, canRemove: r = !0, removeLabel: i = nt, typography: a, colors: o }) => e.length === 0 ? null : /* @__PURE__ */ W("div", {
963
- className: "flex flex-wrap items-center gap-2",
964
- style: s({
965
- "--ci-chip-bg": o?.chipBg,
966
- "--ci-chip-border": o?.chipBorder,
967
- "--ci-chip-icon": o?.chipIcon,
968
- "--ci-chip-text": o?.chipText,
969
- "--ci-chip-hover-bg": o?.chipHoverBg,
970
- "--ci-chip-selected-bg": o?.chipSelectedBg,
971
- "--ci-chip-selected-border": o?.chipSelectedBorder,
972
- "--ci-chip-selected-icon": o?.chipSelectedIcon,
973
- "--ci-chip-selected-text": o?.chipSelectedText,
974
- "--ci-chip-close": o?.chipClose,
975
- "--ci-chip-close-hover": o?.chipCloseHover
976
- }),
977
- children: e.map((e) => /* @__PURE__ */ G("div", {
978
- className: c(tt.chip, e.isSelected && tt.chipSelected, "flex min-w-0 items-center gap-1.5 rounded-full border py-1 transition-colors", r ? "pe-1 ps-2" : "px-2"),
979
- children: [/* @__PURE__ */ G("button", {
980
- type: "button",
981
- onClick: () => t(e.id),
982
- "aria-pressed": e.isSelected,
983
- className: "flex min-w-0 items-center gap-1.5",
984
- children: [/* @__PURE__ */ W("span", {
985
- className: c(tt.chipIcon, "shrink-0"),
986
- "aria-hidden": !0,
987
- children: e.icon
988
- }), /* @__PURE__ */ W("span", {
989
- className: c(tt.chipText, a?.fontClassName || "dial-small-paragraph-text", "truncate"),
990
- children: e.label
1062
+ }, ft = {
1063
+ chip: "_chip_1lvv5_1",
1064
+ chipSelected: "_chipSelected_1lvv5_9",
1065
+ chipIcon: "_chipIcon_1lvv5_16",
1066
+ chipText: "_chipText_1lvv5_19",
1067
+ chipState: "_chipState_1lvv5_22",
1068
+ chipClose: "_chipClose_1lvv5_25"
1069
+ }, pt = (e) => `Remove ${e}`, mt = ({ items: e, onToolToggle: t, onToolDismiss: n, canRemove: r = !0, removeLabel: i = pt, stateOnLabel: a, stateOffLabel: o, typography: s, colors: u }) => {
1070
+ if (e.length === 0) return null;
1071
+ let d = !!(a && o);
1072
+ return /* @__PURE__ */ P("div", {
1073
+ className: "flex flex-wrap items-center gap-2",
1074
+ style: c({
1075
+ "--ci-chip-bg": u?.chipBg,
1076
+ "--ci-chip-border": u?.chipBorder,
1077
+ "--ci-chip-icon": u?.chipIcon,
1078
+ "--ci-chip-text": u?.chipText,
1079
+ "--ci-chip-hover-bg": u?.chipHoverBg,
1080
+ "--ci-chip-selected-bg": u?.chipSelectedBg,
1081
+ "--ci-chip-selected-border": u?.chipSelectedBorder,
1082
+ "--ci-chip-selected-icon": u?.chipSelectedIcon,
1083
+ "--ci-chip-selected-text": u?.chipSelectedText,
1084
+ "--ci-chip-state-text": u?.chipStateText,
1085
+ "--ci-chip-close": u?.chipClose,
1086
+ "--ci-chip-close-hover": u?.chipCloseHover
1087
+ }),
1088
+ children: e.map((e) => /* @__PURE__ */ F("div", {
1089
+ className: l(ft.chip, e.isSelected && ft.chipSelected, "flex min-w-0 items-center gap-1.5 rounded-full border py-1 transition-colors", r ? "pe-1 ps-2" : "px-2"),
1090
+ children: [/* @__PURE__ */ F("button", {
1091
+ type: "button",
1092
+ onClick: () => t(e.id),
1093
+ "aria-pressed": e.isSelected,
1094
+ className: "flex min-w-0 items-center gap-1.5",
1095
+ children: [
1096
+ /* @__PURE__ */ P("span", {
1097
+ className: l(ft.chipIcon, "shrink-0"),
1098
+ "aria-hidden": !0,
1099
+ children: e.icon
1100
+ }),
1101
+ /* @__PURE__ */ F("span", {
1102
+ className: l(ft.chipText, s?.fontClassName || "dial-small-paragraph-text", "truncate"),
1103
+ children: [e.label, d && /* @__PURE__ */ P("span", {
1104
+ "aria-hidden": !0,
1105
+ children: ":"
1106
+ })]
1107
+ }),
1108
+ d && /* @__PURE__ */ P("span", {
1109
+ className: l(ft.chipState, s?.fontClassName || "dial-small-paragraph-text", "ms-1 shrink-0 uppercase tracking-wider"),
1110
+ "aria-hidden": !0,
1111
+ children: e.isSelected ? a : o
1112
+ })
1113
+ ]
1114
+ }), r && /* @__PURE__ */ P("button", {
1115
+ type: "button",
1116
+ onClick: () => n(e.id),
1117
+ "aria-label": i(e.label),
1118
+ className: l(ft.chipClose, "flex shrink-0 items-center rounded p-0.5 transition-colors"),
1119
+ children: /* @__PURE__ */ P(be, {
1120
+ size: 12,
1121
+ "aria-hidden": !0,
1122
+ stroke: _
1123
+ })
991
1124
  })]
992
- }), r && /* @__PURE__ */ W("button", {
993
- type: "button",
994
- onClick: () => n(e.id),
995
- "aria-label": i(e.label),
996
- className: c(tt.chipClose, "flex shrink-0 items-center rounded p-0.5 transition-colors"),
997
- children: /* @__PURE__ */ W(pe, {
998
- size: 12,
999
- "aria-hidden": !0,
1000
- stroke: m
1001
- })
1002
- })]
1003
- }, e.id))
1004
- }), q = {
1005
- wrapper: "_wrapper_q1jcl_2",
1006
- wrapperDisabled: "_wrapperDisabled_q1jcl_9",
1007
- textarea: "_textarea_q1jcl_13",
1008
- textareaIndented: "_textareaIndented_q1jcl_19",
1009
- commandHint: "_commandHint_q1jcl_43",
1010
- modelSelectorButton: "_modelSelectorButton_q1jcl_47",
1011
- modelSelectorCaret: "_modelSelectorCaret_q1jcl_47",
1012
- modelSelectorName: "_modelSelectorName_q1jcl_50",
1013
- modelSelectorVersion: "_modelSelectorVersion_q1jcl_53",
1014
- modelSelectorButtonDisabled: "_modelSelectorButtonDisabled_q1jcl_62"
1015
- }, it = {
1016
- wrapperError: "_wrapperError_129ri_1",
1017
- waveformCanvas: "_waveformCanvas_129ri_5",
1018
- recordingDot: "_recordingDot_129ri_19",
1019
- "recording-pulse": "_recording-pulse_129ri_1"
1020
- }, at = 3, ot = 4, st = 200, ct = ({ state: e, analyserNodeRef: t, errorMessage: n, onStop: r, onDiscard: i, attachButton: a, stopLabel: o = "Stop recording", discardLabel: s = "Discard recording", processingLabel: l = "Transcribing audio…", style: u, className: d, embedded: f = !1 }) => {
1021
- let h = B(null), g = B(new Float32Array(st)), y = B(0), b = B(0), x = e === Ie.Recording, S = e === Ie.Error, C = e === Ie.Processing, w = L((e) => {
1125
+ }, e.id))
1126
+ });
1127
+ }, q = {
1128
+ wrapper: "_wrapper_19a9k_2",
1129
+ wrapperDisabled: "_wrapperDisabled_19a9k_9",
1130
+ textarea: "_textarea_19a9k_13",
1131
+ textareaMentionMode: "_textareaMentionMode_19a9k_19",
1132
+ commandHint: "_commandHint_19a9k_53",
1133
+ mentionHighlight: "_mentionHighlight_19a9k_57",
1134
+ mentionHighlightUnsupported: "_mentionHighlightUnsupported_19a9k_63",
1135
+ modelSelectorButton: "_modelSelectorButton_19a9k_69",
1136
+ modelSelectorCaret: "_modelSelectorCaret_19a9k_69",
1137
+ modelSelectorName: "_modelSelectorName_19a9k_72",
1138
+ modelSelectorVersion: "_modelSelectorVersion_19a9k_75",
1139
+ modelSelectorButtonDisabled: "_modelSelectorButtonDisabled_19a9k_84"
1140
+ }, ht = {
1141
+ waveformCanvas: "_waveformCanvas_18zb5_1",
1142
+ recordingDot: "_recordingDot_18zb5_15",
1143
+ "recording-pulse": "_recording-pulse_18zb5_1"
1144
+ }, gt = 3, _t = 4, vt = 200, yt = ({ state: e, analyserNodeRef: t, onStop: n, onDiscard: r, attachButton: i, stopLabel: a = "Stop recording", discardLabel: o = "Discard recording", processingLabel: s = "Transcribing audio…", style: c, className: u, embedded: d = !1 }) => {
1145
+ let f = V(null), p = V(new Float32Array(vt)), m = V(0), h = V(0), v = e === Ke.Recording, y = e === Ke.Processing, b = R((e) => {
1022
1146
  let t = e.getContext("2d");
1023
1147
  if (!t) return;
1024
1148
  e.width = e.clientWidth || 200, e.height = e.clientHeight || 32;
1025
1149
  let { width: n, height: r } = e;
1026
1150
  t.clearRect(0, 0, n, r), t.fillStyle = getComputedStyle(e).color;
1027
- let i = Math.min(Math.max(1, Math.floor(n / ot)), st - 1), a = y.current, o = b.current;
1151
+ let i = Math.min(Math.max(1, Math.floor(n / _t)), vt - 1), a = m.current, o = h.current;
1028
1152
  t.save(), t.beginPath(), t.rect(0, 0, n, r), t.clip(), t.translate(-o, 0);
1029
1153
  for (let e = 0; e <= i; e++) {
1030
- let n = ((a - i + e) % st + st) % st, o = g.current[n] ?? 0, s = Math.min(1, o * 6), c = Math.max(3, s * r);
1031
- t.fillRect(e * ot, (r - c) / 2, at, c);
1154
+ let n = ((a - i + e) % vt + vt) % vt, o = p.current[n] ?? 0, s = Math.min(1, o * 6), c = Math.max(3, s * r);
1155
+ t.fillRect(e * _t, (r - c) / 2, gt, c);
1032
1156
  }
1033
1157
  t.restore();
1034
1158
  }, []);
1035
- R(() => {
1036
- if (!x) return;
1037
- let e = h.current;
1159
+ z(() => {
1160
+ if (!v) return;
1161
+ let e = f.current;
1038
1162
  if (!e) return;
1039
- g.current.fill(0), y.current = 0, b.current = 0;
1163
+ p.current.fill(0), m.current = 0, h.current = 0;
1040
1164
  let n, r = () => {
1041
- if (b.current += 1, b.current >= ot) {
1042
- b.current -= ot;
1165
+ if (h.current += 1, h.current >= _t) {
1166
+ h.current -= _t;
1043
1167
  let e = t.current;
1044
1168
  if (e) {
1045
1169
  let t = new Uint8Array(e.frequencyBinCount);
@@ -1049,206 +1173,223 @@ var Se = "a[href], button:not([disabled]), input:not([disabled]), select:not([di
1049
1173
  let r = (t[e] - 128) / 128;
1050
1174
  n += r * r;
1051
1175
  }
1052
- g.current[y.current % st] = Math.sqrt(n / t.length), y.current++;
1176
+ p.current[m.current % vt] = Math.sqrt(n / t.length), m.current++;
1053
1177
  }
1054
1178
  }
1055
- w(e), n = requestAnimationFrame(r);
1179
+ b(e), n = requestAnimationFrame(r);
1056
1180
  };
1057
1181
  return n = requestAnimationFrame(r), () => {
1058
1182
  cancelAnimationFrame(n);
1059
1183
  };
1060
1184
  }, [
1061
- x,
1185
+ v,
1062
1186
  t,
1063
- w
1064
- ]), R(() => {
1065
- let e = h.current;
1187
+ b
1188
+ ]), z(() => {
1189
+ let e = f.current;
1066
1190
  if (!e) return;
1067
1191
  let t = new ResizeObserver(() => {
1068
- w(e);
1192
+ b(e);
1069
1193
  });
1070
1194
  return t.observe(e), () => t.disconnect();
1071
- }, [w]);
1072
- let E = /* @__PURE__ */ G("div", {
1195
+ }, [b]);
1196
+ let x = /* @__PURE__ */ F("div", {
1073
1197
  className: "flex flex-shrink-0 items-center justify-end gap-1",
1074
1198
  children: [
1075
- /* @__PURE__ */ W(v, {
1076
- icon: /* @__PURE__ */ W(pe, {
1077
- size: p.LG,
1199
+ /* @__PURE__ */ P(T, {
1200
+ icon: /* @__PURE__ */ P(be, {
1201
+ size: g.LG,
1078
1202
  "aria-hidden": !0,
1079
- stroke: m
1203
+ stroke: _
1080
1204
  }),
1081
- "aria-label": s,
1205
+ "aria-label": o,
1082
1206
  className: "mobile:min-h-11 mobile:min-w-11",
1083
- onClick: i
1207
+ onClick: r
1084
1208
  }),
1085
- x && /* @__PURE__ */ W(T, {
1086
- icon: /* @__PURE__ */ W(I, {
1087
- size: p.LG,
1088
- "aria-hidden": !0
1209
+ v && /* @__PURE__ */ P(O, {
1210
+ icon: /* @__PURE__ */ P(L, {
1211
+ size: g.LG,
1212
+ "aria-hidden": !0,
1213
+ stroke: _
1089
1214
  }),
1090
- onClick: () => r?.(),
1215
+ onClick: () => n?.(),
1091
1216
  autoFocus: !0,
1092
- "aria-label": o,
1217
+ "aria-label": a,
1093
1218
  className: "mobile:min-h-11 mobile:min-w-11"
1094
1219
  }),
1095
- C && /* @__PURE__ */ W("span", {
1220
+ y && /* @__PURE__ */ P("span", {
1096
1221
  className: "flex size-[40px] flex-shrink-0 items-center justify-center mobile:min-h-11 mobile:min-w-11",
1097
- children: /* @__PURE__ */ W(te, {
1222
+ children: /* @__PURE__ */ P(ie, {
1098
1223
  size: 20,
1099
- ariaLabel: l
1224
+ ariaLabel: s
1100
1225
  })
1101
1226
  })
1102
1227
  ]
1103
1228
  });
1104
- return /* @__PURE__ */ G("div", {
1105
- className: d,
1106
- children: [/* @__PURE__ */ G("div", {
1107
- style: u,
1108
- className: c("flex w-full min-w-0 flex-col justify-center gap-2", !f && q.wrapper, !f && "min-h-[64px] max-w-[748px] rounded-xl border px-3 shadow-md", S && it.wrapperError),
1109
- children: [/* @__PURE__ */ G("div", {
1229
+ return /* @__PURE__ */ P("div", {
1230
+ className: u,
1231
+ children: /* @__PURE__ */ F("div", {
1232
+ style: c,
1233
+ className: l("flex w-full min-w-0 flex-col justify-center gap-2", !d && q.wrapper, !d && "min-h-[64px] max-w-[748px] rounded-xl border px-3 shadow-md"),
1234
+ children: [/* @__PURE__ */ F("div", {
1110
1235
  className: "flex min-w-0 flex-1 items-center gap-3",
1111
- children: [x && /* @__PURE__ */ W("span", {
1112
- className: c(it.recordingDot, "pointer-events-none block size-[8px] rounded-3xl"),
1236
+ children: [v && /* @__PURE__ */ P("span", {
1237
+ className: l(ht.recordingDot, "pointer-events-none block size-[8px] rounded-3xl"),
1113
1238
  "aria-hidden": !0
1114
- }), /* @__PURE__ */ W("canvas", {
1115
- ref: h,
1239
+ }), /* @__PURE__ */ P("canvas", {
1240
+ ref: f,
1116
1241
  height: 26,
1117
1242
  "aria-hidden": !0,
1118
- className: c(it.waveformCanvas, "h-[26px] min-w-0 flex-1")
1243
+ className: l(ht.waveformCanvas, "h-[26px] min-w-0 flex-1")
1119
1244
  })]
1120
- }), /* @__PURE__ */ G("div", {
1245
+ }), /* @__PURE__ */ F("div", {
1121
1246
  className: "flex items-center justify-between gap-2",
1122
- children: [a ?? /* @__PURE__ */ W("span", { "aria-hidden": !0 }), E]
1247
+ children: [i ?? /* @__PURE__ */ P("span", { "aria-hidden": !0 }), x]
1123
1248
  })]
1124
- }), S && n && /* @__PURE__ */ W("div", {
1125
- role: "alert",
1126
- children: /* @__PURE__ */ W(_, {
1127
- text: n,
1128
- className: "mt-1 px-1"
1129
- })
1130
- })]
1249
+ })
1131
1250
  });
1132
- }, lt = ({ onSend: e, isDisabled: t = !1, ariaLabel: n = "Send message", sendTooltip: r }) => /* @__PURE__ */ W(T, {
1251
+ }, bt = ({ onSend: e, isDisabled: t = !1, ariaLabel: n = "Send message", sendTooltip: r }) => /* @__PURE__ */ P(O, {
1133
1252
  "aria-label": n,
1134
1253
  onClick: () => e?.(),
1135
1254
  disabled: t,
1136
1255
  tooltipProps: r ? { tooltip: r } : void 0,
1137
- icon: /* @__PURE__ */ W(ie, {
1138
- size: p.LG,
1256
+ icon: /* @__PURE__ */ P(ue, {
1257
+ size: g.LG,
1139
1258
  className: "rtl:scale-x-[-1]",
1140
- stroke: m
1259
+ stroke: _
1141
1260
  })
1142
- }), ut = ({ onStop: e, ariaLabel: t = "Stop streaming" }) => /* @__PURE__ */ W(j, {
1143
- icon: /* @__PURE__ */ W(le, {
1144
- size: p.LG,
1145
- stroke: m
1261
+ }), xt = ({ onStop: e, ariaLabel: t = "Stop streaming" }) => /* @__PURE__ */ P(T, {
1262
+ icon: /* @__PURE__ */ P(ge, {
1263
+ size: g.LG,
1264
+ stroke: _
1146
1265
  }),
1147
1266
  onClick: () => e?.(),
1148
1267
  "aria-label": t
1149
- }), dt = ({ size: e = 20 }) => /* @__PURE__ */ W(k, {
1150
- variant: ee.Circular,
1268
+ }), St = ({ size: e = 20 }) => /* @__PURE__ */ P(ne, {
1269
+ variant: j.Circular,
1151
1270
  width: e,
1152
1271
  height: e,
1153
1272
  active: !0
1154
- }), ft = ({ loadingLabel: e }) => /* @__PURE__ */ G("span", {
1273
+ }), Ct = ({ loadingLabel: e }) => /* @__PURE__ */ F("span", {
1155
1274
  className: "flex min-w-0 flex-1 items-center",
1156
- children: [/* @__PURE__ */ W(k, {
1157
- variant: ee.Text,
1275
+ children: [/* @__PURE__ */ P(ne, {
1276
+ variant: j.Text,
1158
1277
  width: "100%",
1159
1278
  height: 16,
1160
1279
  active: !0
1161
- }), e && /* @__PURE__ */ W("span", {
1280
+ }), e && /* @__PURE__ */ P("span", {
1162
1281
  className: "sr-only",
1163
1282
  children: e
1164
1283
  })]
1165
- }), pt = ({ loadingLabel: e }) => /* @__PURE__ */ W("div", {
1284
+ }), wt = ({ loadingLabel: e }) => /* @__PURE__ */ P("div", {
1166
1285
  role: "status",
1167
1286
  "aria-label": e,
1168
- children: Array.from({ length: 7 }).map((e, t) => /* @__PURE__ */ G("div", {
1287
+ children: Array.from({ length: 7 }).map((e, t) => /* @__PURE__ */ F("div", {
1169
1288
  className: "flex h-11 items-center gap-3 px-4",
1170
1289
  "aria-hidden": "true",
1171
- children: [/* @__PURE__ */ W(dt, {}), /* @__PURE__ */ W(ft, {})]
1290
+ children: [/* @__PURE__ */ P(St, {}), /* @__PURE__ */ P(Ct, {})]
1172
1291
  }, t))
1173
- }), mt = (e) => e.displayName ?? e.id, ht = (e, t) => {
1292
+ }), Tt = (e) => e.displayName ?? e.id, Et = (e, t) => {
1174
1293
  let n = t.trim().toLowerCase();
1175
- return n ? e.filter((e) => mt(e).toLowerCase().includes(n)) : e;
1176
- }, J = (e, t, r, i = 18, a) => /* @__PURE__ */ W(n, {
1294
+ return n ? e.filter((e) => Tt(e).toLowerCase().includes(n)) : e;
1295
+ }, Dt = (e, t, r, i = 18, a) => /* @__PURE__ */ P(n, {
1177
1296
  src: e,
1178
1297
  size: i,
1179
1298
  labels: { tooltip: a },
1180
1299
  initialsName: r
1181
- }), Y = { searchHeader: "_searchHeader_1728o_1" }, gt = ({ deployments: e, selectedDeploymentId: t, onDeploymentChange: n, modelSelectorLabels: r, searchHeaderClassName: i = Y.searchHeader, colors: a }) => {
1182
- let [o, l] = V(""), u = z(() => e?.find((e) => e.id === t), [e, t]), d = r?.loading !== void 0, f = !d && !u && !!t, m = z(() => d ? /* @__PURE__ */ W(dt, { size: p.LG }) : J(u?.iconUrl, u?.type, u?.displayName ?? u?.id ?? "", p.LG, f ? r?.unavailableTooltip ?? "This deployment is no longer available" : void 0), [
1183
- d,
1300
+ }), Ot = {
1301
+ searchHeader: "_searchHeader_1u7db_1",
1302
+ itemText: "_itemText_1u7db_13",
1303
+ itemHover: "_itemHover_1u7db_17",
1304
+ selectedItemBackground: "_selectedItemBackground_1u7db_22",
1305
+ selectedItemText: "_selectedItemText_1u7db_26",
1306
+ checkIcon: "_checkIcon_1u7db_30"
1307
+ }, kt = ({ deployments: e, selectedDeploymentId: t, onDeploymentChange: n, modelSelectorLabels: r, styles: i }) => {
1308
+ let [a, o] = H(""), s = B(() => e?.find((e) => e.id === t), [e, t]), u = r?.loading !== void 0, d = !u && !s && !!t, f = B(() => u ? /* @__PURE__ */ P(St, { size: g.LG }) : Dt(s?.iconUrl, s?.type, s?.displayName ?? s?.id ?? "", g.LG, d ? r?.unavailableTooltip ?? "This deployment is no longer available" : void 0), [
1184
1309
  u,
1185
- f,
1310
+ s,
1311
+ d,
1186
1312
  r?.unavailableTooltip
1187
- ]), h = u?.displayName ?? u?.id, _ = u?.displayVersion;
1188
- return {
1189
- selectorIcon: m,
1190
- selectorAriaLabel: h ? `${r?.ariaLabel ?? "Select model"}: ${h}` : r?.ariaLabel ?? "Select model",
1191
- selectedLabel: h,
1192
- selectedVersion: _,
1193
- menuItems: z(() => {
1194
- if (d) return Array.from({ length: 7 }, (e, t) => ({
1195
- key: `__loading-${t}`,
1196
- icon: /* @__PURE__ */ W(dt, {}),
1197
- label: /* @__PURE__ */ W(ft, { loadingLabel: t === 0 ? r?.loading : void 0 }),
1313
+ ]), p = s?.displayName ?? s?.id, m = s?.displayVersion, h = p ? `${r?.ariaLabel ?? "Select model"}: ${p}` : r?.ariaLabel ?? "Select model", _ = B(() => {
1314
+ if (u) return Array.from({ length: 7 }, (e, t) => ({
1315
+ key: `__loading-${t}`,
1316
+ icon: /* @__PURE__ */ P(St, {}),
1317
+ label: /* @__PURE__ */ P(Ct, { loadingLabel: t === 0 ? r?.loading : void 0 }),
1318
+ disabled: !0
1319
+ }));
1320
+ if (!e || e.length === 0) {
1321
+ let e = r?.error ?? r?.empty;
1322
+ return e ? [{
1323
+ key: "__state",
1324
+ label: e,
1198
1325
  disabled: !0
1199
- }));
1200
- if (!e || e.length === 0) {
1201
- let e = r?.error ?? r?.empty;
1202
- return e ? [{
1203
- key: "__state",
1204
- label: e,
1205
- disabled: !0
1206
- }] : [];
1207
- }
1208
- return ht(e, o).map((e) => ({
1326
+ }] : [];
1327
+ }
1328
+ let o = i?.colors;
1329
+ return Et(e, a).map((e) => {
1330
+ let r = e.id === t;
1331
+ return {
1209
1332
  key: e.id,
1210
- label: /* @__PURE__ */ W(y, {
1211
- text: mt(e),
1212
- query: o,
1333
+ label: /* @__PURE__ */ P(S, {
1334
+ text: Tt(e),
1335
+ query: a,
1213
1336
  maxLines: 1
1214
1337
  }),
1215
- icon: J(e.iconUrl, e.type, e.displayName ?? e.id),
1216
- mark: b.Check,
1217
- checked: e.id === t,
1338
+ icon: Dt(e.iconUrl, e.type, e.displayName ?? e.id),
1339
+ mark: C.Check,
1340
+ checked: r,
1341
+ className: l(o?.itemText && Ot.itemText, o?.itemHoverBackground && Ot.itemHover, r && o?.selectedItemBackground && Ot.selectedItemBackground, r && o?.selectedItemText && Ot.selectedItemText, r && o?.checkIcon && Ot.checkIcon, i?.itemClassName, r && i?.selectedItemClassName, U.modelMenuItem, r && U.modelMenuItemSelected),
1218
1342
  onClick: () => n?.(e.id)
1219
- }));
1220
- }, [
1221
- e,
1222
- d,
1223
- o,
1224
- t,
1225
- r,
1226
- n
1227
- ]),
1228
- menuHeader: z(() => !d && e && e.length > 0 ? /* @__PURE__ */ W("div", {
1229
- style: s({ "--ms-search-header-bg": a?.searchHeaderBackground }),
1230
- className: c("sticky top-0 z-10 pb-1 pe-2 pt-2", i),
1231
- children: /* @__PURE__ */ W(O, {
1232
- value: o,
1343
+ };
1344
+ });
1345
+ }, [
1346
+ e,
1347
+ u,
1348
+ a,
1349
+ t,
1350
+ r,
1351
+ n,
1352
+ i?.itemClassName,
1353
+ i?.selectedItemClassName,
1354
+ i?.colors
1355
+ ]), v = B(() => c({
1356
+ "--ms-item-text": i?.colors?.itemText,
1357
+ "--ms-item-hover-bg": i?.colors?.itemHoverBackground,
1358
+ "--ms-selected-item-bg": i?.colors?.selectedItemBackground,
1359
+ "--ms-selected-item-text": i?.colors?.selectedItemText,
1360
+ "--ms-check-icon": i?.colors?.checkIcon
1361
+ }), [i?.colors]);
1362
+ return {
1363
+ selectorIcon: f,
1364
+ selectorAriaLabel: h,
1365
+ selectedLabel: p,
1366
+ selectedVersion: m,
1367
+ menuItems: _,
1368
+ menuHeader: B(() => !u && e && e.length > 0 ? /* @__PURE__ */ P("div", {
1369
+ style: c({ "--ms-search-header-bg": i?.colors?.searchHeaderBackground }),
1370
+ className: l("sticky top-0 z-10 pb-1 pe-2 pt-2", Ot.searchHeader, i?.searchHeaderClassName, U.modelMenuSearch),
1371
+ children: /* @__PURE__ */ P(A, {
1372
+ value: a,
1233
1373
  placeholder: r?.searchPlaceholder ?? "Search",
1234
- size: g.Small,
1374
+ size: y.Small,
1235
1375
  wrapperClassName: "border-0",
1236
- onChange: (e) => l(e ?? "")
1376
+ onChange: (e) => o(e ?? "")
1237
1377
  })
1238
1378
  }) : void 0, [
1239
1379
  e,
1240
- d,
1241
- o,
1380
+ u,
1381
+ a,
1242
1382
  r,
1243
- i,
1244
- a?.searchHeaderBackground
1383
+ i?.searchHeaderClassName,
1384
+ i?.colors?.searchHeaderBackground
1245
1385
  ]),
1386
+ menuStyle: v,
1246
1387
  onOpenChange: (e) => {
1247
- e || l("");
1388
+ e || o("");
1248
1389
  }
1249
1390
  };
1250
- }, _t = typeof window < "u" ? _e : R;
1251
- function vt(e) {
1391
+ }, At = typeof window < "u" ? Ee : z;
1392
+ function jt(e) {
1252
1393
  if (e !== void 0) switch (typeof e) {
1253
1394
  case "number": return e;
1254
1395
  case "string":
@@ -1256,15 +1397,15 @@ function vt(e) {
1256
1397
  break;
1257
1398
  }
1258
1399
  }
1259
- function yt({ box: e, defaultHeight: t, defaultWidth: n, disabled: r, element: i, mode: a, style: o }) {
1260
- let { styleHeight: s, styleWidth: c } = z(() => ({
1261
- styleHeight: vt(o?.height),
1262
- styleWidth: vt(o?.width)
1263
- }), [o?.height, o?.width]), [l, u] = V({
1400
+ function Mt({ box: e, defaultHeight: t, defaultWidth: n, disabled: r, element: i, mode: a, style: o }) {
1401
+ let { styleHeight: s, styleWidth: c } = B(() => ({
1402
+ styleHeight: jt(o?.height),
1403
+ styleWidth: jt(o?.width)
1404
+ }), [o?.height, o?.width]), [l, u] = H({
1264
1405
  height: t,
1265
1406
  width: n
1266
1407
  }), d = r || a === "only-height" && s !== void 0 || a === "only-width" && c !== void 0 || s !== void 0 && c !== void 0;
1267
- return _t(() => {
1408
+ return At(() => {
1268
1409
  if (i === null || d) return;
1269
1410
  let t = new ResizeObserver((e) => {
1270
1411
  for (let t of e) {
@@ -1284,7 +1425,7 @@ function yt({ box: e, defaultHeight: t, defaultWidth: n, disabled: r, element: i
1284
1425
  i,
1285
1426
  s,
1286
1427
  c
1287
- ]), z(() => ({
1428
+ ]), B(() => ({
1288
1429
  height: s ?? l.height,
1289
1430
  width: c ?? l.width
1290
1431
  }), [
@@ -1293,26 +1434,26 @@ function yt({ box: e, defaultHeight: t, defaultWidth: n, disabled: r, element: i
1293
1434
  c
1294
1435
  ]);
1295
1436
  }
1296
- function bt(e) {
1297
- let t = B(() => {
1437
+ function Nt(e) {
1438
+ let t = V(() => {
1298
1439
  throw Error("Cannot call during render.");
1299
1440
  });
1300
- return _t(() => {
1441
+ return At(() => {
1301
1442
  t.current = e;
1302
- }, [e]), L((e) => t.current?.(e), [t]);
1443
+ }, [e]), R((e) => t.current?.(e), [t]);
1303
1444
  }
1304
- var xt = null;
1305
- function X(e = !1) {
1306
- if (xt === null || e) {
1445
+ var Pt = null;
1446
+ function Ft(e = !1) {
1447
+ if (Pt === null || e) {
1307
1448
  let e = document.createElement("div"), t = e.style;
1308
1449
  t.width = "50px", t.height = "50px", t.overflow = "scroll", t.direction = "rtl";
1309
1450
  let n = document.createElement("div"), r = n.style;
1310
- return r.width = "100px", r.height = "100px", e.appendChild(n), document.body.appendChild(e), e.scrollLeft > 0 ? xt = "positive-descending" : (e.scrollLeft = 1, xt = e.scrollLeft === 0 ? "negative" : "positive-ascending"), document.body.removeChild(e), xt;
1451
+ return r.width = "100px", r.height = "100px", e.appendChild(n), document.body.appendChild(e), e.scrollLeft > 0 ? Pt = "positive-descending" : (e.scrollLeft = 1, Pt = e.scrollLeft === 0 ? "negative" : "positive-ascending"), document.body.removeChild(e), Pt;
1311
1452
  }
1312
- return xt;
1453
+ return Pt;
1313
1454
  }
1314
- function Z({ containerElement: e, direction: t, isRtl: n, scrollOffset: r }) {
1315
- if (t === "horizontal" && n) switch (X()) {
1455
+ function It({ containerElement: e, direction: t, isRtl: n, scrollOffset: r }) {
1456
+ if (t === "horizontal" && n) switch (Ft()) {
1316
1457
  case "negative": return -r;
1317
1458
  case "positive-descending":
1318
1459
  if (e) {
@@ -1323,26 +1464,26 @@ function Z({ containerElement: e, direction: t, isRtl: n, scrollOffset: r }) {
1323
1464
  }
1324
1465
  return r;
1325
1466
  }
1326
- function Q(e, t = "Assertion error") {
1467
+ function J(e, t = "Assertion error") {
1327
1468
  if (!e) throw console.error(t), Error(t);
1328
1469
  }
1329
- function St(e, t) {
1470
+ function Y(e, t) {
1330
1471
  if (e === t) return !0;
1331
- if (!!e != !!t || (Q(e !== void 0), Q(t !== void 0), Object.keys(e).length !== Object.keys(t).length)) return !1;
1472
+ if (!!e != !!t || (J(e !== void 0), J(t !== void 0), Object.keys(e).length !== Object.keys(t).length)) return !1;
1332
1473
  for (let n in e) if (!Object.is(t[n], e[n])) return !1;
1333
1474
  return !0;
1334
1475
  }
1335
- function Ct({ cachedBounds: e, itemCount: t, itemSize: n }) {
1476
+ function X({ cachedBounds: e, itemCount: t, itemSize: n }) {
1336
1477
  if (t === 0) return 0;
1337
1478
  if (typeof n == "number") return t * n;
1338
1479
  {
1339
1480
  let n = e.get(e.size === 0 ? 0 : e.size - 1);
1340
- return Q(n !== void 0, "Unexpected bounds cache miss"), t * ((n.scrollOffset + n.size) / e.size);
1481
+ return J(n !== void 0, "Unexpected bounds cache miss"), t * ((n.scrollOffset + n.size) / e.size);
1341
1482
  }
1342
1483
  }
1343
- function wt({ align: e, cachedBounds: t, index: n, itemCount: r, itemSize: i, containerScrollOffset: a, containerSize: o }) {
1484
+ function Lt({ align: e, cachedBounds: t, index: n, itemCount: r, itemSize: i, containerScrollOffset: a, containerSize: o }) {
1344
1485
  if (n < 0 || n >= r) throw RangeError(`Invalid index specified: ${n}`, { cause: `Index ${n} is not within the range of 0 - ${r - 1}` });
1345
- let s = Ct({
1486
+ let s = X({
1346
1487
  cachedBounds: t,
1347
1488
  itemCount: r,
1348
1489
  itemSize: i
@@ -1354,7 +1495,7 @@ function wt({ align: e, cachedBounds: t, index: n, itemCount: r, itemSize: i, co
1354
1495
  default: return a >= u && a <= l ? a : a < u ? u : l;
1355
1496
  }
1356
1497
  }
1357
- function Tt({ cachedBounds: e, containerScrollOffset: t, containerSize: n, itemCount: r, overscanCount: i }) {
1498
+ function Rt({ cachedBounds: e, containerScrollOffset: t, containerSize: n, itemCount: r, overscanCount: i }) {
1358
1499
  let a = r - 1, o = 0, s = -1, c = 0, l = -1, u = 0;
1359
1500
  for (; u < a;) {
1360
1501
  let n = e.get(u);
@@ -1373,11 +1514,11 @@ function Tt({ cachedBounds: e, containerScrollOffset: t, containerSize: n, itemC
1373
1514
  stopIndexOverscan: l
1374
1515
  };
1375
1516
  }
1376
- function Et({ itemCount: e, itemProps: t, itemSize: n }) {
1517
+ function zt({ itemCount: e, itemProps: t, itemSize: n }) {
1377
1518
  let r = /* @__PURE__ */ new Map();
1378
1519
  return {
1379
1520
  get(i) {
1380
- for (Q(i < e, `Invalid index ${i}`); r.size - 1 < i;) {
1521
+ for (J(i < e, `Invalid index ${i}`); r.size - 1 < i;) {
1381
1522
  let e = r.size, a;
1382
1523
  switch (typeof n) {
1383
1524
  case "function":
@@ -1393,14 +1534,14 @@ function Et({ itemCount: e, itemProps: t, itemSize: n }) {
1393
1534
  });
1394
1535
  else {
1395
1536
  let t = r.get(e - 1);
1396
- Q(t !== void 0, `Unexpected bounds cache miss for index ${i}`), r.set(e, {
1537
+ J(t !== void 0, `Unexpected bounds cache miss for index ${i}`), r.set(e, {
1397
1538
  scrollOffset: t.scrollOffset + t.size,
1398
1539
  size: a
1399
1540
  });
1400
1541
  }
1401
1542
  }
1402
1543
  let a = r.get(i);
1403
- return Q(a !== void 0, `Unexpected bounds cache miss for index ${i}`), a;
1544
+ return J(a !== void 0, `Unexpected bounds cache miss for index ${i}`), a;
1404
1545
  },
1405
1546
  set(e, t) {
1406
1547
  r.set(e, t);
@@ -1410,8 +1551,8 @@ function Et({ itemCount: e, itemProps: t, itemSize: n }) {
1410
1551
  }
1411
1552
  };
1412
1553
  }
1413
- function Dt({ itemCount: e, itemProps: t, itemSize: n }) {
1414
- return z(() => Et({
1554
+ function Z({ itemCount: e, itemProps: t, itemSize: n }) {
1555
+ return B(() => zt({
1415
1556
  itemCount: e,
1416
1557
  itemProps: t,
1417
1558
  itemSize: n
@@ -1421,11 +1562,11 @@ function Dt({ itemCount: e, itemProps: t, itemSize: n }) {
1421
1562
  n
1422
1563
  ]);
1423
1564
  }
1424
- function Ot({ containerSize: e, itemSize: t }) {
1565
+ function Bt({ containerSize: e, itemSize: t }) {
1425
1566
  let n;
1426
1567
  switch (typeof t) {
1427
1568
  case "string":
1428
- Q(t.endsWith("%"), `Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`), Q(e !== void 0, "Container size must be defined if a percentage item size is specified"), n = e * parseInt(t) / 100;
1569
+ J(t.endsWith("%"), `Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`), J(e !== void 0, "Container size must be defined if a percentage item size is specified"), n = e * parseInt(t) / 100;
1429
1570
  break;
1430
1571
  default:
1431
1572
  n = t;
@@ -1433,21 +1574,21 @@ function Ot({ containerSize: e, itemSize: t }) {
1433
1574
  }
1434
1575
  return n;
1435
1576
  }
1436
- function kt({ containerElement: e, containerStyle: t, defaultContainerSize: n = 0, direction: r, isRtl: i = !1, itemCount: a, itemProps: o, itemSize: s, onResize: c, overscanCount: l }) {
1437
- let { height: u = n, width: d = n } = yt({
1577
+ function Vt({ containerElement: e, containerStyle: t, defaultContainerSize: n = 0, direction: r, isRtl: i = !1, itemCount: a, itemProps: o, itemSize: s, onResize: c, overscanCount: l }) {
1578
+ let { height: u = n, width: d = n } = Mt({
1438
1579
  defaultHeight: r === "vertical" ? n : void 0,
1439
1580
  defaultWidth: r === "horizontal" ? n : void 0,
1440
1581
  element: e,
1441
1582
  mode: r === "vertical" ? "only-height" : "only-width",
1442
1583
  style: t
1443
- }), f = B({
1584
+ }), f = V({
1444
1585
  height: 0,
1445
1586
  width: 0
1446
- }), p = r === "vertical" ? u : d, m = Ot({
1587
+ }), p = r === "vertical" ? u : d, m = Bt({
1447
1588
  containerSize: p,
1448
1589
  itemSize: s
1449
1590
  });
1450
- _e(() => {
1591
+ Ee(() => {
1451
1592
  if (typeof c == "function") {
1452
1593
  let e = f.current;
1453
1594
  (e.height !== u || e.width !== d) && (c({
@@ -1460,11 +1601,11 @@ function kt({ containerElement: e, containerStyle: t, defaultContainerSize: n =
1460
1601
  c,
1461
1602
  d
1462
1603
  ]);
1463
- let h = Dt({
1604
+ let h = Z({
1464
1605
  itemCount: a,
1465
1606
  itemProps: o,
1466
1607
  itemSize: m
1467
- }), g = L((e) => h.get(e), [h]), [_, v] = V(() => Tt({
1608
+ }), g = R((e) => h.get(e), [h]), [_, v] = H(() => Rt({
1468
1609
  cachedBounds: h,
1469
1610
  containerScrollOffset: 0,
1470
1611
  containerSize: p,
@@ -1475,7 +1616,7 @@ function kt({ containerElement: e, containerStyle: t, defaultContainerSize: n =
1475
1616
  startIndexOverscan: Math.min(a - 1, _.startIndexOverscan),
1476
1617
  stopIndexVisible: Math.min(a - 1, _.stopIndexVisible),
1477
1618
  stopIndexOverscan: Math.min(a - 1, _.stopIndexOverscan)
1478
- }, C = L(() => Ct({
1619
+ }, C = R(() => X({
1479
1620
  cachedBounds: h,
1480
1621
  itemCount: a,
1481
1622
  itemSize: m
@@ -1483,9 +1624,9 @@ function kt({ containerElement: e, containerStyle: t, defaultContainerSize: n =
1483
1624
  h,
1484
1625
  a,
1485
1626
  m
1486
- ]), w = L((t) => Tt({
1627
+ ]), w = R((t) => Rt({
1487
1628
  cachedBounds: h,
1488
- containerScrollOffset: Z({
1629
+ containerScrollOffset: It({
1489
1630
  containerElement: e,
1490
1631
  direction: r,
1491
1632
  isRtl: i,
@@ -1503,19 +1644,19 @@ function kt({ containerElement: e, containerStyle: t, defaultContainerSize: n =
1503
1644
  a,
1504
1645
  l
1505
1646
  ]);
1506
- return _t(() => {
1647
+ return At(() => {
1507
1648
  v(w((r === "vertical" ? e?.scrollTop : e?.scrollLeft) ?? 0));
1508
1649
  }, [
1509
1650
  e,
1510
1651
  r,
1511
1652
  w
1512
- ]), _t(() => {
1653
+ ]), At(() => {
1513
1654
  if (!e) return;
1514
1655
  let t = () => {
1515
1656
  v((t) => {
1516
- let { scrollLeft: n, scrollTop: o } = e, s = Tt({
1657
+ let { scrollLeft: n, scrollTop: o } = e, s = Rt({
1517
1658
  cachedBounds: h,
1518
- containerScrollOffset: Z({
1659
+ containerScrollOffset: It({
1519
1660
  containerElement: e,
1520
1661
  direction: r,
1521
1662
  isRtl: i,
@@ -1525,7 +1666,7 @@ function kt({ containerElement: e, containerStyle: t, defaultContainerSize: n =
1525
1666
  itemCount: a,
1526
1667
  overscanCount: l
1527
1668
  });
1528
- return St(s, t) ? t : s;
1669
+ return Y(s, t) ? t : s;
1529
1670
  });
1530
1671
  };
1531
1672
  return e.addEventListener("scroll", t), () => {
@@ -1541,8 +1682,8 @@ function kt({ containerElement: e, containerStyle: t, defaultContainerSize: n =
1541
1682
  ]), {
1542
1683
  getCellBounds: g,
1543
1684
  getEstimatedSize: C,
1544
- scrollToIndex: bt(({ align: t = "auto", containerScrollOffset: n, index: o }) => {
1545
- let s = wt({
1685
+ scrollToIndex: Nt(({ align: t = "auto", containerScrollOffset: n, index: o }) => {
1686
+ let s = Lt({
1546
1687
  align: t,
1547
1688
  cachedBounds: h,
1548
1689
  containerScrollOffset: n,
@@ -1552,14 +1693,14 @@ function kt({ containerElement: e, containerStyle: t, defaultContainerSize: n =
1552
1693
  itemSize: m
1553
1694
  });
1554
1695
  if (e) {
1555
- if (s = Z({
1696
+ if (s = It({
1556
1697
  containerElement: e,
1557
1698
  direction: r,
1558
1699
  isRtl: i,
1559
1700
  scrollOffset: s
1560
1701
  }), typeof e.scrollTo != "function") {
1561
1702
  let e = w(s);
1562
- St(_, e) || v(e);
1703
+ Y(_, e) || v(e);
1563
1704
  }
1564
1705
  return s;
1565
1706
  }
@@ -1570,30 +1711,30 @@ function kt({ containerElement: e, containerStyle: t, defaultContainerSize: n =
1570
1711
  stopIndexVisible: x
1571
1712
  };
1572
1713
  }
1573
- function At(e) {
1574
- return z(() => e, Object.values(e));
1714
+ function Ht(e) {
1715
+ return B(() => e, Object.values(e));
1575
1716
  }
1576
- function jt(e, t) {
1717
+ function Ut(e, t) {
1577
1718
  let { ariaAttributes: n, style: r, ...i } = e, { ariaAttributes: a, style: o, ...s } = t;
1578
- return St(n, a) && St(r, o) && St(i, s);
1719
+ return Y(n, a) && Y(r, o) && Y(i, s);
1579
1720
  }
1580
- function Mt(e) {
1721
+ function Wt(e) {
1581
1722
  return typeof e == "object" && !!e && "getAverageRowHeight" in e && typeof e.getAverageRowHeight == "function";
1582
1723
  }
1583
- var Nt = "data-react-window-index";
1584
- function Pt({ children: e, className: t, defaultHeight: n = 0, listRef: r, onResize: i, onRowsRendered: a, overscanCount: o = 3, rowComponent: s, rowCount: c, rowHeight: l, rowProps: u, tagName: d = "div", style: f, ...p }) {
1585
- let m = At(u), h = z(() => he(s, jt), [s]), [g, _] = V(null), v = Mt(l), { getCellBounds: y, getEstimatedSize: b, scrollToIndex: x, startIndexOverscan: S, startIndexVisible: C, stopIndexOverscan: w, stopIndexVisible: T } = kt({
1724
+ var Gt = "data-react-window-index";
1725
+ function Kt({ children: e, className: t, defaultHeight: n = 0, listRef: r, onResize: i, onRowsRendered: a, overscanCount: o = 3, rowComponent: s, rowCount: c, rowHeight: l, rowProps: u, tagName: d = "div", style: f, ...p }) {
1726
+ let m = Ht(u), h = B(() => Ce(s, Ut), [s]), [g, _] = H(null), v = Wt(l), { getCellBounds: y, getEstimatedSize: b, scrollToIndex: x, startIndexOverscan: S, startIndexVisible: C, stopIndexOverscan: w, stopIndexVisible: T } = Vt({
1586
1727
  containerElement: g,
1587
1728
  containerStyle: f,
1588
1729
  defaultContainerSize: n,
1589
1730
  direction: "vertical",
1590
1731
  itemCount: c,
1591
1732
  itemProps: m,
1592
- itemSize: z(() => v ? (e) => l.getRowHeight(e) ?? l.getAverageRowHeight() : l, [v, l]),
1733
+ itemSize: B(() => v ? (e) => l.getRowHeight(e) ?? l.getAverageRowHeight() : l, [v, l]),
1593
1734
  onResize: i,
1594
1735
  overscanCount: o
1595
1736
  });
1596
- ge(r, () => ({
1737
+ Te(r, () => ({
1597
1738
  get element() {
1598
1739
  return g;
1599
1740
  },
@@ -1608,12 +1749,12 @@ function Pt({ children: e, className: t, defaultHeight: n = 0, listRef: r, onRes
1608
1749
  top: r
1609
1750
  });
1610
1751
  }
1611
- }), [g, x]), _t(() => {
1752
+ }), [g, x]), At(() => {
1612
1753
  if (!g) return;
1613
1754
  let e = Array.from(g.children).filter((e, t) => {
1614
1755
  if (e.hasAttribute("aria-hidden")) return !1;
1615
1756
  let n = `${S + t}`;
1616
- return e.setAttribute(Nt, n), !0;
1757
+ return e.setAttribute(Gt, n), !0;
1617
1758
  });
1618
1759
  if (v) return l.observeRowElements(e);
1619
1760
  }, [
@@ -1622,7 +1763,7 @@ function Pt({ children: e, className: t, defaultHeight: n = 0, listRef: r, onRes
1622
1763
  l,
1623
1764
  S,
1624
1765
  w
1625
- ]), R(() => {
1766
+ ]), z(() => {
1626
1767
  S >= 0 && w >= 0 && a && a({
1627
1768
  startIndex: C,
1628
1769
  stopIndex: T
@@ -1637,11 +1778,11 @@ function Pt({ children: e, className: t, defaultHeight: n = 0, listRef: r, onRes
1637
1778
  w,
1638
1779
  T
1639
1780
  ]);
1640
- let E = z(() => {
1781
+ let E = B(() => {
1641
1782
  let e = [];
1642
1783
  if (c > 0) for (let t = S; t <= w; t++) {
1643
1784
  let n = y(t);
1644
- e.push(/* @__PURE__ */ me(h, {
1785
+ e.push(/* @__PURE__ */ xe(h, {
1645
1786
  ...m,
1646
1787
  ariaAttributes: {
1647
1788
  "aria-posinset": t + 1,
@@ -1668,7 +1809,7 @@ function Pt({ children: e, className: t, defaultHeight: n = 0, listRef: r, onRes
1668
1809
  m,
1669
1810
  S,
1670
1811
  w
1671
- ]), D = /* @__PURE__ */ W("div", {
1812
+ ]), D = /* @__PURE__ */ P("div", {
1672
1813
  "aria-hidden": !0,
1673
1814
  style: {
1674
1815
  height: b(),
@@ -1676,7 +1817,7 @@ function Pt({ children: e, className: t, defaultHeight: n = 0, listRef: r, onRes
1676
1817
  zIndex: -1
1677
1818
  }
1678
1819
  });
1679
- return me(d, {
1820
+ return xe(d, {
1680
1821
  role: "list",
1681
1822
  ...p,
1682
1823
  className: t,
@@ -1690,206 +1831,220 @@ function Pt({ children: e, className: t, defaultHeight: n = 0, listRef: r, onRes
1690
1831
  }
1691
1832
  }, E, e, D);
1692
1833
  }
1693
- var Ft = {
1694
- divider: "_divider_1tiyp_1",
1695
- item: "_item_1tiyp_5",
1696
- itemIcon: "_itemIcon_1tiyp_15",
1697
- checkIcon: "_checkIcon_1tiyp_19",
1698
- stateLabel: "_stateLabel_1tiyp_23"
1699
- }, It = 44, Lt = 8, Rt = ({ index: e, style: t, ariaAttributes: n, items: r, selectedDeploymentId: i, labelClassName: a, query: o, onSelect: s }) => {
1700
- let l = r[e], u = J(l.iconUrl, l.type, l.displayName ?? l.id, p.SM), f = l.id === i;
1701
- return /* @__PURE__ */ W("div", {
1834
+ var Q = {
1835
+ search: "_search_5skzl_1",
1836
+ divider: "_divider_5skzl_5",
1837
+ item: "_item_5skzl_9",
1838
+ itemIcon: "_itemIcon_5skzl_19",
1839
+ checkIcon: "_checkIcon_5skzl_23",
1840
+ stateLabel: "_stateLabel_5skzl_27",
1841
+ itemSelectedBackground: "_itemSelectedBackground_5skzl_37",
1842
+ itemSelectedText: "_itemSelectedText_5skzl_41"
1843
+ }, qt = 44, Jt = 8, Yt = ({ index: e, style: t, ariaAttributes: n, items: r, selectedDeploymentId: i, labelClassName: a, query: o, itemClassName: s, selectedItemClassName: c, hasSelectedBackground: u, hasSelectedText: d, onSelect: f }) => {
1844
+ let p = r[e], h = Dt(p.iconUrl, p.type, p.displayName ?? p.id, g.SM), v = p.id === i;
1845
+ return /* @__PURE__ */ P("div", {
1702
1846
  style: t,
1703
1847
  ...n,
1704
- children: /* @__PURE__ */ W(d, {
1848
+ children: /* @__PURE__ */ P(m, {
1705
1849
  type: "button",
1706
- "aria-current": f ? "true" : void 0,
1707
- className: c(Ft.item, "h-full w-full gap-3 px-4"),
1708
- iconBefore: /* @__PURE__ */ W("span", {
1709
- className: Ft.itemIcon,
1710
- children: u
1850
+ "aria-current": v ? "true" : void 0,
1851
+ className: l(Q.item, "h-full w-full gap-3 px-4", v && u && Q.itemSelectedBackground, v && d && Q.itemSelectedText, s, v && c, U.modelMenuItem, v && U.modelMenuItemSelected),
1852
+ iconBefore: /* @__PURE__ */ P("span", {
1853
+ className: Q.itemIcon,
1854
+ children: h
1711
1855
  }),
1712
- label: /* @__PURE__ */ G("span", {
1856
+ label: /* @__PURE__ */ F("span", {
1713
1857
  className: "flex flex-1 items-center justify-between gap-2",
1714
- children: [/* @__PURE__ */ W(y, {
1715
- text: l.displayName ?? l.id,
1858
+ children: [/* @__PURE__ */ P(S, {
1859
+ text: p.displayName ?? p.id,
1716
1860
  query: o,
1717
1861
  maxLines: 1,
1718
- className: c(a, "min-w-0 flex-1 text-start")
1719
- }), f && /* @__PURE__ */ W(P, {
1720
- size: p.SM,
1721
- className: Ft.checkIcon,
1862
+ className: l(a, "min-w-0 flex-1 text-start")
1863
+ }), v && /* @__PURE__ */ P(L, {
1864
+ size: g.SM,
1865
+ className: Q.checkIcon,
1722
1866
  "aria-hidden": !0,
1723
- stroke: m
1867
+ stroke: _
1724
1868
  })]
1725
1869
  }),
1726
- onClick: () => s(l.id)
1870
+ onClick: () => f(p.id)
1727
1871
  })
1728
1872
  });
1729
- }, zt = ({ isOpen: e, title: t, closeLabel: n, searchPlaceholder: r = "Search", onClose: i, deployments: a, selectedDeploymentId: o, onSelect: l, loadingLabel: u, errorLabel: d, emptyLabel: f, style: p, titleClassName: m = "dial-body-semi-text", labelClassName: h = "dial-small-text", colors: _ }) => {
1730
- let [v, y] = V("");
1731
- R(() => {
1732
- e || y("");
1873
+ }, Xt = ({ isOpen: e, title: t, closeLabel: n, searchPlaceholder: r = "Search", onClose: i, deployments: a, selectedDeploymentId: o, onSelect: s, loadingLabel: u, errorLabel: d, emptyLabel: f, style: p, titleClassName: m = "dial-body-semi-text", labelClassName: h = "dial-small-text", colors: g, menuStyles: _ }) => {
1874
+ let [v, b] = H("");
1875
+ z(() => {
1876
+ e || b("");
1733
1877
  }, [e]);
1734
- let b = a && a.length > 0, x = u !== void 0, S = !b && !x ? d ?? f : void 0, C = b ? ht(a, v) : [], w = (e) => {
1735
- l(e), i();
1736
- }, T = s({
1737
- "--ci-sheet-divider": _?.divider,
1738
- "--ci-sheet-text": _?.itemText,
1739
- "--ci-sheet-item-hover": _?.itemHoverBg,
1740
- "--ci-sheet-item-active": _?.itemActiveBg,
1741
- "--ci-sheet-icon": _?.itemIcon,
1742
- "--ci-check-icon": _?.checkIcon
1878
+ let x = a && a.length > 0, S = u !== void 0, C = !x && !S ? d ?? f : void 0, w = x ? Et(a, v) : [], T = (e) => {
1879
+ s(e), i();
1880
+ }, E = _?.colors, D = c({
1881
+ "--ci-sheet-divider": g?.divider,
1882
+ "--ci-sheet-text": E?.itemText ?? g?.itemText,
1883
+ "--ci-sheet-item-hover": E?.itemHoverBackground ?? g?.itemHoverBg,
1884
+ "--ci-sheet-item-active": g?.itemActiveBg,
1885
+ "--ci-sheet-icon": E?.itemText ?? g?.itemIcon,
1886
+ "--ci-check-icon": E?.checkIcon ?? g?.checkIcon,
1887
+ "--ci-sheet-selected-bg": E?.selectedItemBackground,
1888
+ "--ci-sheet-selected-text": E?.selectedItemText
1743
1889
  });
1744
- return /* @__PURE__ */ W(Te, {
1890
+ return /* @__PURE__ */ P(W, {
1745
1891
  isOpen: e,
1746
1892
  title: t,
1747
1893
  closeLabel: n,
1748
1894
  onClose: i,
1749
1895
  style: p,
1750
1896
  titleClassName: m,
1751
- className: "max-h-[80dvh]",
1752
- colors: _?.shell,
1753
- children: /* @__PURE__ */ G("div", {
1897
+ className: l("max-h-[80dvh]", _?.className, U.modelMenu),
1898
+ colors: g?.shell,
1899
+ children: /* @__PURE__ */ F("div", {
1754
1900
  className: "contents",
1755
- style: T,
1756
- children: [b && !x && /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("div", {
1757
- className: "flex-shrink-0 px-4 py-[10px]",
1758
- children: /* @__PURE__ */ W(O, {
1901
+ style: D,
1902
+ children: [x && !S && /* @__PURE__ */ F(oe, { children: [/* @__PURE__ */ P("div", {
1903
+ style: c({ "--ci-sheet-search-bg": _?.colors?.searchHeaderBackground }),
1904
+ className: l("flex-shrink-0 px-4 py-[10px]", Q.search, _?.searchHeaderClassName, U.modelMenuSearch),
1905
+ children: /* @__PURE__ */ P(A, {
1759
1906
  value: v,
1760
1907
  placeholder: r,
1761
- size: g.Standard,
1762
- onChange: (e) => y(e ?? "")
1908
+ size: y.Standard,
1909
+ onChange: (e) => b(e ?? "")
1763
1910
  })
1764
- }), /* @__PURE__ */ W("div", { className: c(Ft.divider, "h-px flex-shrink-0") })] }), x ? /* @__PURE__ */ W(pt, { loadingLabel: u }) : S ? /* @__PURE__ */ W("div", {
1911
+ }), /* @__PURE__ */ P("div", { className: l(Q.divider, "h-px flex-shrink-0") })] }), S ? /* @__PURE__ */ P(wt, { loadingLabel: u }) : C ? /* @__PURE__ */ P("div", {
1765
1912
  role: "list",
1766
- className: c(Ft.stateLabel, h, "px-4 py-4"),
1767
- children: S
1768
- }) : /* @__PURE__ */ W(Pt, {
1913
+ className: l(Q.stateLabel, h, "px-4 py-4"),
1914
+ children: C
1915
+ }) : /* @__PURE__ */ P(Kt, {
1769
1916
  role: "list",
1770
1917
  className: "overflow-y-auto",
1771
- style: { height: Math.min(C.length, Lt) * It },
1772
- rowComponent: Rt,
1773
- rowCount: C.length,
1774
- rowHeight: It,
1918
+ style: { height: Math.min(w.length, Jt) * qt },
1919
+ rowComponent: Yt,
1920
+ rowCount: w.length,
1921
+ rowHeight: qt,
1775
1922
  rowProps: {
1776
- items: C,
1923
+ items: w,
1777
1924
  selectedDeploymentId: o,
1778
1925
  labelClassName: h,
1779
1926
  query: v,
1780
- onSelect: w
1927
+ itemClassName: _?.itemClassName,
1928
+ selectedItemClassName: _?.selectedItemClassName,
1929
+ hasSelectedBackground: !!E?.selectedItemBackground,
1930
+ hasSelectedText: !!E?.selectedItemText,
1931
+ onSelect: T
1781
1932
  }
1782
1933
  })]
1783
1934
  })
1784
1935
  });
1785
- }, Bt = ({ deployments: e, selectedDeploymentId: t, onDeploymentChange: n, modelSelectorLabels: r, isStreaming: i, isMobile: a, isDisabled: s = !1, style: l, modelPickerOverlay: u, isPickerOpen: d, onPickerToggle: f, onPickerOpenChange: g }) => {
1786
- let [_, y] = V(!1), { selectorIcon: b, selectorAriaLabel: x, selectedLabel: S, selectedVersion: C, menuItems: w, menuHeader: T, onOpenChange: E } = gt({
1936
+ }, Zt = ({ deployments: e, selectedDeploymentId: t, onDeploymentChange: n, modelSelectorLabels: r, menuStyles: i, isStreaming: a, isMobile: o, isDisabled: c = !1, style: u, modelPickerOverlay: d, isPickerOpen: f, onPickerToggle: p, onPickerOpenChange: h }) => {
1937
+ let [y, b] = H(!1), { selectorIcon: S, selectorAriaLabel: C, selectedLabel: w, selectedVersion: T, menuItems: E, menuHeader: D, menuStyle: ee, onOpenChange: O } = kt({
1787
1938
  deployments: e,
1788
1939
  selectedDeploymentId: t,
1789
1940
  onDeploymentChange: n,
1790
- modelSelectorLabels: r
1941
+ modelSelectorLabels: r,
1942
+ styles: i
1791
1943
  });
1792
1944
  if (!e) return null;
1793
- let D = i || s ? "pointer-events-none opacity-50 cursor-not-allowed" : void 0, O = /* @__PURE__ */ W(F, {
1794
- size: p.SM,
1795
- className: q.modelSelectorCaret,
1945
+ let k = a || c ? "pointer-events-none opacity-50 cursor-not-allowed" : void 0, te = /* @__PURE__ */ P(de, {
1946
+ size: g.SM,
1947
+ className: l(q.modelSelectorCaret, U.modelSelectorCaret),
1796
1948
  "aria-hidden": !0,
1797
- stroke: m
1949
+ stroke: _
1950
+ }), A = /* @__PURE__ */ P("span", {
1951
+ className: l("flex shrink-0 items-center", U.modelSelectorIcon),
1952
+ children: S
1798
1953
  });
1799
- return a ? /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(N, {
1800
- tooltip: S,
1801
- children: /* @__PURE__ */ W(v, {
1802
- icon: /* @__PURE__ */ G("div", {
1803
- className: "flex items-center gap-1",
1804
- children: [b, O]
1805
- }),
1806
- "aria-label": x,
1807
- onClick: () => {
1808
- s || y(!0);
1809
- },
1810
- className: c("w-[50px]", q.modelSelectorButton, D)
1811
- })
1812
- }), u ? /* @__PURE__ */ W(Te, {
1813
- isOpen: _,
1954
+ if (o) return /* @__PURE__ */ F(oe, { children: [/* @__PURE__ */ P(x, {
1955
+ tooltipProps: { tooltip: w },
1956
+ icon: /* @__PURE__ */ F("div", {
1957
+ className: "flex items-center gap-1",
1958
+ children: [A, te]
1959
+ }),
1960
+ "aria-label": C,
1961
+ onClick: () => {
1962
+ c || b(!0);
1963
+ },
1964
+ className: l("w-[50px]", q.modelSelectorButton, k, U.modelSelectorButton)
1965
+ }), d ? /* @__PURE__ */ P(W, {
1966
+ isOpen: y,
1814
1967
  title: r?.ariaLabel ?? "Select model",
1815
1968
  closeLabel: r?.closeLabel ?? "Close",
1816
- onClose: () => y(!1),
1817
- style: l,
1818
- children: u(() => y(!1))
1819
- }) : /* @__PURE__ */ W(zt, {
1820
- isOpen: _,
1969
+ onClose: () => b(!1),
1970
+ style: u,
1971
+ className: l(i?.className, U.modelMenu),
1972
+ children: d(() => b(!1))
1973
+ }) : /* @__PURE__ */ P(Xt, {
1974
+ isOpen: y,
1821
1975
  title: r?.ariaLabel ?? "Select model",
1822
1976
  closeLabel: r?.closeLabel ?? "Close",
1823
1977
  searchPlaceholder: r?.searchPlaceholder ?? "Search",
1824
- onClose: () => y(!1),
1978
+ onClose: () => b(!1),
1825
1979
  deployments: e,
1826
1980
  selectedDeploymentId: t,
1827
1981
  onSelect: (e) => n?.(e),
1828
1982
  loadingLabel: r?.loading,
1829
1983
  errorLabel: r?.error,
1830
1984
  emptyLabel: r?.empty,
1831
- style: l
1832
- })] }) : u ? /* @__PURE__ */ W(h, {
1833
- placement: "top-end",
1834
- matchReferenceWidth: !1,
1835
- open: d,
1836
- onOpenChange: g,
1837
- trigger: [],
1838
- outsideClosable: !0,
1839
- renderOverlay: () => u(() => g?.(!1)),
1840
- listClassName: "!w-[368px] !bg-layer-raised",
1841
- children: /* @__PURE__ */ W(N, {
1842
- tooltip: C ? `${S} · ${C}` : S,
1843
- children: /* @__PURE__ */ G("button", {
1844
- type: "button",
1845
- "aria-label": x,
1846
- "aria-disabled": s || void 0,
1847
- className: c("flex min-w-0 items-center gap-1.5 rounded-full py-1.5 pe-2 ps-1.5", q.modelSelectorButton, D, s && q.modelSelectorButtonDisabled),
1985
+ style: u,
1986
+ menuStyles: i
1987
+ })] });
1988
+ if (d) {
1989
+ let e = T ? `${w} · ${T}` : w;
1990
+ return /* @__PURE__ */ P(v, {
1991
+ placement: "top-end",
1992
+ matchReferenceWidth: !1,
1993
+ open: f,
1994
+ onOpenChange: h,
1995
+ trigger: [],
1996
+ outsideClosable: !0,
1997
+ renderOverlay: () => d(() => h?.(!1)),
1998
+ listClassName: l("!w-[368px] !bg-layer-raised", i?.className, U.modelMenu),
1999
+ children: /* @__PURE__ */ P(m, {
2000
+ "aria-label": C,
2001
+ "aria-disabled": c || void 0,
2002
+ tooltipProps: { tooltip: e },
2003
+ className: l("h-auto min-w-0 gap-1.5 !rounded-full !border-0 px-0 py-1.5 pe-2 ps-1.5", q.modelSelectorButton, k, c && q.modelSelectorButtonDisabled, U.modelSelectorButton),
1848
2004
  onClick: () => {
1849
- !i && !s && f?.();
2005
+ !a && !c && p?.();
1850
2006
  },
1851
- children: [
1852
- b,
1853
- /* @__PURE__ */ G("span", {
1854
- className: "flex min-w-0 max-w-[180px] items-baseline gap-1",
1855
- children: [/* @__PURE__ */ W("span", {
1856
- className: c("dial-small-text max-w-[180px] shrink-0 truncate", q.modelSelectorName),
1857
- children: S
1858
- }), C && /* @__PURE__ */ W("span", {
1859
- className: c("dial-tiny-text min-w-0 truncate", q.modelSelectorVersion),
1860
- children: C
1861
- })]
1862
- }),
1863
- O
1864
- ]
2007
+ iconBefore: A,
2008
+ iconAfter: te,
2009
+ textClassName: "min-w-0",
2010
+ label: /* @__PURE__ */ F("span", {
2011
+ className: "flex min-w-0 max-w-[180px] items-baseline gap-1",
2012
+ children: [/* @__PURE__ */ P("span", {
2013
+ className: l("dial-small-text max-w-[180px] shrink-0 truncate", q.modelSelectorName),
2014
+ children: w
2015
+ }), T && /* @__PURE__ */ P("span", {
2016
+ className: l("dial-tiny-text min-w-0 truncate", q.modelSelectorVersion),
2017
+ children: T
2018
+ })]
2019
+ })
1865
2020
  })
1866
- })
1867
- }) : /* @__PURE__ */ W("div", {
1868
- className: c(s && D),
1869
- "aria-disabled": s || void 0,
1870
- children: /* @__PURE__ */ W(h, {
1871
- items: w,
1872
- menuHeader: T,
2021
+ });
2022
+ }
2023
+ return /* @__PURE__ */ P("div", {
2024
+ className: l(c && k),
2025
+ "aria-disabled": c || void 0,
2026
+ children: /* @__PURE__ */ P(v, {
2027
+ items: E,
2028
+ menuHeader: D,
1873
2029
  placement: "bottom-end",
1874
2030
  matchReferenceWidth: !1,
1875
- maxDropdownHeight: o,
1876
- listClassName: "!w-[240px]",
1877
- disabled: s,
1878
- onOpenChange: s ? void 0 : E,
1879
- children: /* @__PURE__ */ W(N, {
1880
- tooltip: S,
1881
- children: /* @__PURE__ */ G("button", {
1882
- type: "button",
1883
- "aria-label": x,
1884
- "aria-disabled": s || void 0,
1885
- className: c("flex items-center gap-1 rounded-full p-1.5", q.modelSelectorButton, s && q.modelSelectorButtonDisabled),
1886
- children: [b, O]
1887
- })
2031
+ maxDropdownHeight: s,
2032
+ listClassName: l("!w-[240px]", i?.className, U.modelMenu),
2033
+ listStyle: ee,
2034
+ disabled: c,
2035
+ onOpenChange: c ? void 0 : O,
2036
+ children: /* @__PURE__ */ P(m, {
2037
+ "aria-label": C,
2038
+ "aria-disabled": c || void 0,
2039
+ tooltipProps: { tooltip: w },
2040
+ iconBefore: A,
2041
+ iconAfter: te,
2042
+ className: l("h-auto gap-1 !rounded-full !border-0 p-1.5", q.modelSelectorButton, c && q.modelSelectorButtonDisabled, U.modelSelectorButton)
1888
2043
  })
1889
2044
  })
1890
2045
  });
1891
- }, Vt = ({ message: e = "", messageRevision: t, textInsertion: n, onSend: r, onUploadAttachment: i, onStop: a, isStreaming: o = !1, onChange: d, onAttachmentsChange: f, placeholder: g = "Type a message...", ariaLabel: y, attachLabel: b = "Attach file", fileAccept: x, addMenuTitle: S = "Add", menuTitle: C = "Menu", menuCloseLabel: w = "Close", removeLabel: T, retryLabel: E, uploadingLabel: D, sendLabel: O, sendTooltip: k, stopLabel: ee, micLabel: A = "Dictate", recordVoiceLabel: te = "Record voice", stopRecordingLabel: j, discardRecordingLabel: ne, colors: M, typography: N, className: re, pendingDropFiles: ie = [], onDropFilesConsumed: P, pendingAttachments: F = [], onPendingAttachmentsConsumed: ae, pasteTextThreshold: ce = 4e3, maxMessageLength: I = 5e4, deployments: le, selectedDeploymentId: ue, onDeploymentChange: de, modelSelectorLabels: fe, initialAttachments: pe = [], hideAddButton: me = !1, hideAttachFile: he = !1, hideActionBar: ge = !1, renderFooterActions: _e, isInputDisabled: H = !1, isModelSelectorDisabled: ye = !1, isSendDisabled: be = !1, isAudioMessageSupported: Se = !1, isVoiceRecordingSupported: Ce = Se, onTranscribeAudio: we, transcribingLabel: Te, voiceErrorLabel: Ee, sendOnEnter: Oe = Ue.Enter, prefixAttachments: Ae = [], onRemovePrefixAttachment: je, chatSettings: Pe, toolsMenuItems: Re, onToolToggle: ze, canRemoveTools: Be = !0, toolsMenuTitle: Ve, toolsBackLabel: We, toolsChipLabels: Ge, menuOverlays: Ke, inlineStartSlot: qe, onInlineStartRemove: Je, commandMenu: K, autoFocus: Ye = !1, messageHistory: Xe, onDialFileSystemClick: Ze, dialFileSystemLabel: Qe, validateAttachment: $e, onAttachmentClick: tt, modelPickerOverlay: nt, maximumAttachmentsAmount: it, onAttachmentsLimitExceeded: at, isAttachmentsEnabled: ot = !0, isTextAttachmentsAllowed: st = !0, usageLimitsSlot: dt, onMessageTooLong: ft }) => {
1892
- let pt = l(), [mt, ht] = V(!1), J = Me(Xe), Y = qe != null, [gt, _t] = V(null), [vt, yt] = V(0), bt = z(() => s({
2046
+ }, Qt = Se(({ message: e = "", messageRevision: t, focusRequestId: n, textInsertion: r, onSend: i, onUploadAttachment: a, onStop: o, isStreaming: s = !1, onChange: u, onAttachmentsChange: p, placeholder: m = "Type a message...", ariaLabel: h, attachLabel: y = "Attach file", fileAccept: S, addMenuTitle: C = "Add", menuTitle: w = "Menu", menuCloseLabel: T = "Close", removeLabel: E, retryLabel: D, uploadingLabel: ee, sendLabel: O, sendTooltip: k, emptyMessageTooltip: te, stopLabel: A, micLabel: ne = "Dictate", recordVoiceLabel: j = "Record voice", stopRecordingLabel: re, discardRecordingLabel: ie, colors: M, typography: N, attachmentTray: ae, modelMenu: I, className: ce, pendingDropFiles: ue = [], onDropFilesConsumed: L, pendingAttachments: de = [], onPendingAttachmentsConsumed: fe, pasteTextThreshold: he = 4e3, maxMessageLength: ge = 5e4, deployments: _e, selectedDeploymentId: ve, onDeploymentChange: ye, modelSelectorLabels: be, initialAttachments: xe = [], hideAddButton: Se = !1, hideAttachFile: Ce = !1, hideActionBar: we = !1, actionRowLayout: De = et.Stacked, isInlineActionRowAllowedBelowDesktop: W = !1, renderFooterActions: Oe, isInputDisabled: G = !1, isModelSelectorDisabled: Ae = !1, isSendDisabled: je = !1, isAudioMessageSupported: Me = !1, isVoiceRecordingSupported: Fe = Me, onTranscribeAudio: Ie, transcribingLabel: ze, voiceErrorLabel: Be, sendOnEnter: We = $e.Enter, prefixAttachments: Je = [], onRemovePrefixAttachment: Ye, chatSettings: Xe, toolsMenuItems: Ze, onToolToggle: tt, canRemoveTools: nt = !0, toolsMenuTitle: rt, toolsBackLabel: it, toolsChipLabels: at, menuOverlays: ot, activeMentions: st, onBackspaceAtCaret: ct, caretPositionOverride: lt, commandMenu: K, autoFocus: ut = !1, messageHistory: ft, onDialFileSystemClick: pt, dialFileSystemLabel: ht, validateAttachment: gt, onAttachmentClick: _t, modelPickerOverlay: vt, maximumAttachmentsAmount: St, onAttachmentsLimitExceeded: Ct, isAttachmentsEnabled: wt = !0, isTextAttachmentsAllowed: Tt = !0, usageLimitsSlot: Et, onMessageTooLong: Dt }, Ot) => {
2047
+ let kt = d(), [At, jt] = H(!1), Mt = Le(ft), Nt = st ?? [], Pt = Nt.length > 0, Ft = B(() => c({
1893
2048
  "--ci-bg": M?.background,
1894
2049
  "--ci-text": M?.text,
1895
2050
  "--ci-border": M?.border,
@@ -1901,494 +2056,631 @@ var Ft = {
1901
2056
  "--ci-model-selector-disabled-color": M?.modelSelectorDisabled,
1902
2057
  "--ci-model-selector-name-color": M?.modelSelectorName,
1903
2058
  "--ci-model-selector-version-color": M?.modelSelectorVersion,
1904
- "--ci-voice-error": M?.voiceError,
1905
2059
  "--ci-voice-waveform": M?.voiceWaveform,
1906
2060
  "--ci-voice-accent": M?.voiceAccent,
1907
- "--ci-first-line-indent": Y ? `calc(${vt}px + 4px)` : void 0
1908
- }), [
1909
- M,
1910
- Y,
1911
- vt
1912
- ]), xt = z(() => Ze ? [{
2061
+ "--ci-mention-highlight-bg": M?.mentionHighlightBg,
2062
+ "--ci-mention-highlight-text": M?.mentionHighlightText,
2063
+ "--ci-mention-highlight-unsupported-bg": M?.mentionHighlightUnsupportedBg,
2064
+ "--ci-mention-highlight-unsupported-text": M?.mentionHighlightUnsupportedText
2065
+ }), [M]), It = B(() => pt ? [{
1913
2066
  key: "dial-fs",
1914
- label: Qe ?? "DIAL file system",
1915
- icon: /* @__PURE__ */ W(oe, {
1916
- size: u,
2067
+ label: ht ?? "DIAL file system",
2068
+ icon: /* @__PURE__ */ P(pe, {
2069
+ size: f,
1917
2070
  "aria-hidden": !0,
1918
- stroke: m
2071
+ stroke: _
1919
2072
  }),
1920
- onClick: Ze
1921
- }] : [], [Ze, Qe]), { message: X, setMessage: Z, textareaRef: Q } = Ne({
2073
+ onClick: pt
2074
+ }] : [], [pt, ht]), { message: J, setMessage: Y, textareaRef: X } = He({
1922
2075
  messageProp: e,
1923
2076
  messageRevision: t
1924
2077
  });
1925
- Fe({
1926
- insertion: n,
1927
- textareaRef: Q
1928
- });
1929
- let { isMenuOpen: St, query: Ct, dismiss: wt, handleValueChange: Tt } = ke({
2078
+ z(() => {
2079
+ n !== void 0 && X.current?.focus();
2080
+ }, [n, X]), Te(Ot, () => ({ getCaretPosition: () => X.current?.selectionStart ?? J.length }), [J, X]);
2081
+ let { handleUndoKeyDown: Lt } = Ge({
2082
+ insertion: r,
2083
+ textareaRef: X
2084
+ }), { isMenuOpen: Rt, query: zt, activeWordStart: Z, dismiss: Bt, closeOnOutsidePress: Vt, handleCaretMove: Ht, handleValueChange: Ut, listboxId: Wt, overlayRef: Gt, activeOptionId: Kt, moveActiveOption: Q, getActiveOption: qt } = Pe({
1930
2085
  config: K,
1931
- message: X
1932
- }), Et = K?.emptyQueryHint != null, Dt = Et && St && Ct === "", Ot = L((e) => {
1933
- if (K == null || (wt(), !e?.consumeQuery)) return;
1934
- Q.current?.focus();
1935
- let t = `${K.triggerPrefix}${Ct}`;
1936
- if (!X.startsWith(t)) return;
1937
- let n = X.slice(t.length);
1938
- Z(n), J.notifyChange(), d?.(n);
2086
+ message: J
2087
+ }), Jt = () => {
2088
+ Ht(X.current?.selectionStart ?? J.length);
2089
+ }, Yt = () => {
2090
+ requestAnimationFrame(() => {
2091
+ Ht(X.current?.selectionStart ?? J.length);
2092
+ });
2093
+ }, Xt = (e) => {
2094
+ e.key !== "ArrowLeft" && e.key !== "ArrowRight" && e.key !== "Home" && e.key !== "End" && e.key !== "PageUp" && e.key !== "PageDown" || Ht(e.currentTarget.selectionStart ?? J.length);
2095
+ }, Qt = K?.emptyQueryHint != null, $t = K != null && Z != null ? Z + K.triggerPrefix.length : null, en = $t != null && J.slice($t).split("\n", 1)[0] !== "", tn = Qt && Rt && zt === "" && $t != null && !en, nn = K != null && Rt ? Z ?? 0 : null, rn = V(null), an = V(null), [on, sn] = H(null), cn = R(() => {
2096
+ let e = rn.current, t = an.current;
2097
+ if (e == null || t == null) {
2098
+ sn(null);
2099
+ return;
2100
+ }
2101
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
2102
+ sn({
2103
+ left: n.left - r.left,
2104
+ top: n.top - r.top
2105
+ });
2106
+ }, []);
2107
+ Ee(() => {
2108
+ cn();
1939
2109
  }, [
1940
- K,
1941
- wt,
1942
- Ct,
2110
+ cn,
2111
+ nn,
2112
+ J
2113
+ ]), z(() => {
2114
+ if (nn == null) return;
2115
+ let e = X.current;
2116
+ if (e == null || typeof ResizeObserver > "u") return;
2117
+ let t = new ResizeObserver(cn);
2118
+ return t.observe(e), () => t.disconnect();
2119
+ }, [
2120
+ nn,
1943
2121
  X,
1944
- Z,
1945
- J,
1946
- d,
1947
- Q
2122
+ cn
1948
2123
  ]);
1949
- R(() => {
1950
- if (gt == null) return;
1951
- let e = new ResizeObserver((e) => {
1952
- let t = e[0];
1953
- t != null && yt(t.contentRect.width);
1954
- });
1955
- return e.observe(gt), () => e.disconnect();
1956
- }, [gt]);
1957
- let { attachments: kt, buildAttachments: At, addAttachments: jt, resetAttachments: Mt, handleRemove: Nt, handleRetry: Pt, handleExpand: Ft, hasBlockedAttachments: It } = De({
1958
- initialAttachments: pe,
1959
- onUploadAttachment: i,
1960
- onAttachmentsChange: f,
1961
- validateAttachment: $e,
1962
- pendingDropFiles: ie,
1963
- onDropFilesConsumed: P,
1964
- pendingAttachments: F,
1965
- onPendingAttachmentsConsumed: ae,
1966
- onExpandPastedText: L((e) => {
1967
- Z((t) => t ? `${t}\n${e}` : e);
1968
- }, [Z]),
1969
- maximumAttachmentsAmount: it,
1970
- baseAttachmentsAmount: Ae.length,
1971
- onAttachmentsLimitExceeded: at
1972
- }), Lt = L((e) => {
1973
- jt(At([e]));
1974
- }, [jt, At]), Rt = B(!1), zt = B(X);
1975
- zt.current = X;
1976
- let [Vt, Ht] = V({
2124
+ let ln = R((e) => {
2125
+ if (K == null || (Bt(), !e?.consumeQuery) || (e.returnFocus !== !1 && X.current?.focus(), Z == null)) return;
2126
+ let t = `${K.triggerPrefix}${zt}`, n = Z + t.length;
2127
+ if (J.slice(Z, n) !== t) return;
2128
+ let r = J.slice(0, Z) + J.slice(n);
2129
+ Y(r), Mt.notifyChange(), u?.(r);
2130
+ }, [
2131
+ K,
2132
+ Bt,
2133
+ zt,
2134
+ J,
2135
+ Z,
2136
+ Y,
2137
+ Mt,
2138
+ u,
2139
+ X
2140
+ ]), un = V(void 0);
2141
+ z(() => {
2142
+ lt == null || un.current === t || (un.current = t, X.current?.setSelectionRange(lt, lt), Ht(lt));
2143
+ }, [J]);
2144
+ let { attachments: dn, buildAttachments: fn, addAttachments: pn, resetAttachments: mn, handleRemove: hn, handleRetry: gn, handleExpand: _n, hasBlockedAttachments: vn } = ke({
2145
+ initialAttachments: xe,
2146
+ onUploadAttachment: a,
2147
+ onAttachmentsChange: p,
2148
+ validateAttachment: gt,
2149
+ pendingDropFiles: ue,
2150
+ onDropFilesConsumed: L,
2151
+ pendingAttachments: de,
2152
+ onPendingAttachmentsConsumed: fe,
2153
+ onExpandPastedText: R((e) => {
2154
+ Y((t) => t ? `${t}\n${e}` : e);
2155
+ }, [Y]),
2156
+ maximumAttachmentsAmount: St,
2157
+ baseAttachmentsAmount: Je.length,
2158
+ onAttachmentsLimitExceeded: Ct
2159
+ }), yn = R((e) => {
2160
+ pn(fn([e]));
2161
+ }, [pn, fn]), bn = V(!1), xn = V(J);
2162
+ xn.current = J;
2163
+ let [Sn, Cn] = H({
1977
2164
  text: "",
1978
2165
  revision: 0
1979
- }), { state: Ut, analyserNodeRef: Wt, errorMessage: Gt, startRecording: Kt, stopRecording: qt, discardRecording: Jt } = He({
1980
- onAttachAudio: Lt,
1981
- onTranscribeAudio: we,
1982
- onTranscript: L((e) => {
2166
+ }), { state: wn, analyserNodeRef: Tn, errorMessage: En, startRecording: Dn, stopRecording: On, discardRecording: kn } = Qe({
2167
+ onAttachAudio: yn,
2168
+ onTranscribeAudio: Ie,
2169
+ onTranscript: R((e) => {
1983
2170
  let t = e.trim();
1984
2171
  if (t) {
1985
- let e = zt.current, n = `${e}${e && !/\s$/.test(e) ? " " : ""}${t}`;
1986
- zt.current = n, Z(n), Ht((e) => ({
2172
+ let e = xn.current, n = `${e}${e && !/\s$/.test(e) ? " " : ""}${t}`;
2173
+ xn.current = n, Y(n), Cn((e) => ({
1987
2174
  text: t,
1988
2175
  revision: e.revision + 1
1989
- })), J.notifyChange(), d?.(n);
2176
+ })), Mt.notifyChange(), u?.(n);
1990
2177
  }
1991
- Rt.current = !0;
2178
+ bn.current = !0;
1992
2179
  }, [
1993
- Z,
1994
- J,
1995
- d
2180
+ Y,
2181
+ Mt,
2182
+ u
1996
2183
  ]),
1997
- errorLabel: Ee
1998
- }), $ = Ut === Ie.Recording || Ut === Ie.Processing;
1999
- R(() => {
2000
- (Ut === Ie.Error || Ut === Ie.Idle && Rt.current) && (Rt.current = !1, Q.current?.focus());
2001
- }, [Ut, Q]);
2002
- let Yt = B(null), Xt = B(null), Zt = ot && st, { handlePaste: Qt } = xe(jt, Zt ? ce : Infinity), $t = L((e) => {
2003
- if (!Zt) {
2184
+ errorLabel: Be
2185
+ }), $ = wn === Ke.Recording || wn === Ke.Processing;
2186
+ z(() => {
2187
+ (wn === Ke.Error || wn === Ke.Idle && bn.current) && (bn.current = !1, X.current?.focus());
2188
+ }, [wn, X]);
2189
+ let An = V(null), jn = V(null), Mn = wt && Tt, { handlePaste: Nn } = le(pn, Mn ? he : Infinity), Pn = R((e) => {
2190
+ if (!Mn) {
2004
2191
  let t = e.clipboardData.getData("text/plain");
2005
- t.length >= I && ft?.(t.length, I);
2192
+ t.length >= ge && Dt?.(t.length, ge);
2006
2193
  }
2007
- Qt(e);
2194
+ Nn(e);
2008
2195
  }, [
2009
- Zt,
2010
- I,
2011
- ft,
2012
- Qt
2013
- ]), en = (X.trim().length > 0 || kt.length > 0 || Y) && !It && !be && !$, [tn, nn] = V([]);
2014
- R(() => {
2015
- nn([]);
2016
- }, [(Re ?? []).map((e) => e.id).join("|")]);
2017
- let rn = z(() => {
2018
- let e = Re ?? [];
2019
- return Be ? e.filter((e) => e.isSelected || !tn.includes(e.id)) : e;
2196
+ Mn,
2197
+ ge,
2198
+ Dt,
2199
+ Nn
2200
+ ]), Fn = J.trim().length > 0 || dn.length > 0, In = Fn && !vn && !je && !$, [Ln, Rn] = H([]);
2201
+ z(() => {
2202
+ Rn([]);
2203
+ }, [(Ze ?? []).map((e) => e.id).join("|")]);
2204
+ let zn = B(() => {
2205
+ let e = Ze ?? [];
2206
+ return nt ? e.filter((e) => e.isSelected || !Ln.includes(e.id)) : e;
2020
2207
  }, [
2021
- Re,
2022
- tn,
2023
- Be
2024
- ]), an = L((e) => {
2025
- nn((t) => t.includes(e) ? t : [...t, e]), Re?.find((t) => t.id === e)?.isSelected && ze?.(e);
2026
- }, [Re, ze]), on = le === void 0 || ue != null, sn = Se && !o, cn = async () => {
2027
- if (be || $) return;
2028
- if (X.length >= I) {
2029
- ft?.(X.length, I);
2208
+ Ze,
2209
+ Ln,
2210
+ nt
2211
+ ]), Bn = R((e) => {
2212
+ Rn((t) => t.includes(e) ? t : [...t, e]), Ze?.find((t) => t.id === e)?.isSelected && tt?.(e);
2213
+ }, [Ze, tt]), Vn = _e === void 0 || ve != null, Hn = Me && !s, Un = async () => {
2214
+ if (je || $) return;
2215
+ if (J.length >= ge) {
2216
+ Dt?.(J.length, ge);
2030
2217
  return;
2031
2218
  }
2032
- let e = X, t = kt;
2033
- Z(""), J.reset();
2219
+ let e = J, t = dn;
2220
+ Y(""), Mt.reset();
2034
2221
  try {
2035
- await r?.(e, t), t.forEach((e) => {
2222
+ await i?.(e, t), t.forEach((e) => {
2036
2223
  e.previewUrl && URL.revokeObjectURL(e.previewUrl), e.playUrl && URL.revokeObjectURL(e.playUrl);
2037
- }), Mt([]);
2224
+ }), mn([]);
2038
2225
  } catch {
2039
- Z(e), Mt(t);
2226
+ Y(e), mn(t);
2040
2227
  }
2041
- }, ln = (e) => {
2042
- if (!$) {
2043
- if (!e.nativeEvent.isComposing && !H && !o) {
2228
+ }, Wn = (e) => We === $e.MetaEnter ? (e.metaKey || e.ctrlKey) && !e.shiftKey : !e.shiftKey && !e.metaKey && !e.ctrlKey, Gn = (e) => {
2229
+ if (!Rt || e.nativeEvent.isComposing) return !1;
2230
+ if (e.key === "Escape") return e.preventDefault(), e.stopPropagation(), Bt(), !0;
2231
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") return e.preventDefault(), Q(e.key === "ArrowDown" ? Ne.Next : Ne.Previous), !0;
2232
+ if (e.key !== "Enter" || e.shiftKey) return !1;
2233
+ let t = qt();
2234
+ return t == null ? Wn(e) ? (e.preventDefault(), !0) : !1 : (e.preventDefault(), t.click(), !0);
2235
+ }, Kn = (e) => {
2236
+ if (!$ && !Lt(e) && !Gn(e)) {
2237
+ if (!e.nativeEvent.isComposing && !G && !s) {
2044
2238
  if (e.key === "ArrowUp" || e.key === "ArrowDown") {
2045
- let t = e.currentTarget.selectionStart ?? 0, n = J.navigate(e.key === "ArrowUp" ? "up" : "down", X, t);
2239
+ let t = e.currentTarget.selectionStart ?? 0, n = Mt.navigate(e.key === "ArrowUp" ? "up" : "down", J, t);
2046
2240
  if (n !== null) {
2047
- e.preventDefault(), Z(n);
2241
+ e.preventDefault(), Y(n);
2048
2242
  return;
2049
2243
  }
2050
2244
  }
2051
- if (e.key === "Backspace" && Y && Je != null && e.currentTarget.selectionStart === 0 && e.currentTarget.selectionEnd === 0) {
2052
- e.preventDefault(), Je();
2053
- return;
2245
+ if (e.key === "Backspace" && ct != null && e.currentTarget.selectionStart === e.currentTarget.selectionEnd && e.currentTarget.selectionStart != null) {
2246
+ let t = ct(e.currentTarget.selectionStart);
2247
+ if (t != null) {
2248
+ e.preventDefault();
2249
+ let n = e.currentTarget;
2250
+ n.setSelectionRange(t.start, t.start + t.length), typeof document.execCommand == "function" && document.execCommand("delete", !1) || Ue(n, J.slice(0, t.start) + J.slice(t.start + t.length), t.start);
2251
+ return;
2252
+ }
2054
2253
  }
2055
2254
  }
2056
- e.key === "Enter" && (Oe === Ue.MetaEnter ? (e.metaKey || e.ctrlKey) && !e.shiftKey : !e.shiftKey && !e.metaKey && !e.ctrlKey) && (e.preventDefault(), !o && en && on && !H && cn());
2255
+ e.key === "Enter" && Wn(e) && (e.preventDefault(), !s && In && Vn && !G && Un());
2057
2256
  }
2058
- }, un = (e) => {
2257
+ }, qn = (e) => {
2059
2258
  let t = Array.from(e.target.files ?? []);
2060
2259
  if (t.length === 0) return;
2061
- let n = At(t);
2062
- e.target.value = "", jt(n);
2063
- }, dn = /* @__PURE__ */ W("textarea", {
2064
- className: c(q.textarea, Y && q.textareaIndented, N?.fontClassName || "dial-body-paragraph-text", "max-h-[272px] w-full resize-none overflow-y-auto border-0 bg-transparent outline-none [field-sizing:content]", "disabled:cursor-not-allowed"),
2065
- ref: Q,
2066
- autoFocus: Ye,
2067
- value: X,
2260
+ let n = fn(t);
2261
+ e.target.value = "", pn(n);
2262
+ }, Jn = B(() => {
2263
+ let e = [];
2264
+ return nn != null && e.push({
2265
+ offset: nn,
2266
+ node: /* @__PURE__ */ P("span", {
2267
+ ref: rn,
2268
+ "aria-hidden": !0,
2269
+ className: "inline-block h-[1lh] w-0 align-text-top"
2270
+ }, "caret-marker")
2271
+ }), tn && K != null && $t != null && e.push({
2272
+ offset: $t,
2273
+ node: /* @__PURE__ */ P("span", {
2274
+ className: q.commandHint,
2275
+ "aria-hidden": !0,
2276
+ "data-mirror-synthetic": !0,
2277
+ children: K.emptyQueryHint
2278
+ }, "command-hint")
2279
+ }), e;
2280
+ }, [
2281
+ nn,
2282
+ tn,
2283
+ K,
2284
+ $t
2285
+ ]), Yn = Pt || Jn.length > 0, { mirrorRef: Xn, selectionRects: Zn, updateSelectionRects: Qn } = Ve({
2286
+ textareaRef: X,
2287
+ message: J,
2288
+ isMirrorActive: Yn
2289
+ }), $n = /* @__PURE__ */ P("textarea", {
2290
+ className: l(q.textarea, Yn && q.textareaMentionMode, N?.fontClassName || "dial-body-paragraph-text", "relative z-0 max-h-[272px] w-full resize-none overflow-y-auto border-0 bg-transparent pe-1 ps-1 outline-none [field-sizing:content]", "disabled:cursor-not-allowed"),
2291
+ ref: X,
2292
+ autoFocus: ut,
2293
+ value: J,
2068
2294
  onChange: (e) => {
2069
- Z(e.target.value), J.notifyChange();
2295
+ Y(e.target.value), Mt.notifyChange();
2070
2296
  let t = e.nativeEvent instanceof InputEvent ? e.nativeEvent : void 0;
2071
- Tt(e.target.value, t?.isComposing ?? !1, t?.inputType), d?.(e.target.value);
2297
+ Ut(e.target.value, e.target.selectionStart ?? e.target.value.length, t?.isComposing ?? !1), u?.(e.target.value);
2072
2298
  },
2073
- onKeyDown: ln,
2074
- onPaste: $t,
2075
- placeholder: Y ? void 0 : g,
2076
- "aria-label": y,
2077
- disabled: H,
2299
+ onSelect: Qn,
2300
+ onFocus: Yt,
2301
+ onClick: Jt,
2302
+ onKeyDown: Kn,
2303
+ onKeyUp: Xt,
2304
+ onPaste: Pn,
2305
+ placeholder: m,
2306
+ "aria-label": h,
2307
+ "aria-autocomplete": K == null ? void 0 : "list",
2308
+ "aria-controls": Rt ? Wt : void 0,
2309
+ "aria-activedescendant": Kt ?? void 0,
2310
+ "aria-hidden": Pt ? !0 : void 0,
2311
+ disabled: G,
2078
2312
  readOnly: $,
2079
2313
  rows: 1
2080
- }), fn = K == null ? dn : /* @__PURE__ */ W(h, {
2081
- className: "w-full",
2082
- open: St,
2083
- onOpenChange: (e) => {
2084
- e || wt();
2314
+ }), er = K == null ? $n : /* @__PURE__ */ F(oe, { children: [$n, /* @__PURE__ */ P("div", {
2315
+ "aria-hidden": !0,
2316
+ className: l("pointer-events-none absolute", N?.fontClassName || "dial-body-paragraph-text"),
2317
+ style: {
2318
+ left: on?.left ?? 0,
2319
+ top: on?.top ?? 0
2085
2320
  },
2086
- placement: "top-start",
2087
- trigger: [],
2088
- initialFocus: -1,
2089
- matchReferenceWidth: !1,
2090
- outsidePressIgnoreRef: Q,
2091
- renderOverlay: () => {
2092
- let e = K.renderMenu({
2093
- query: Ct,
2094
- close: Ot
2095
- });
2096
- return K.menuLabel == null ? e : /* @__PURE__ */ W("div", {
2097
- role: "group",
2321
+ children: /* @__PURE__ */ P(v, {
2322
+ open: Rt,
2323
+ onOpenChange: (e) => {
2324
+ e || Vt();
2325
+ },
2326
+ placement: "top-start",
2327
+ trigger: [],
2328
+ initialFocus: -1,
2329
+ matchReferenceWidth: !1,
2330
+ outsidePressIgnoreRef: X,
2331
+ renderOverlay: () => /* @__PURE__ */ P("div", {
2332
+ ref: Gt,
2333
+ role: K.menuLabel == null ? void 0 : "group",
2098
2334
  "aria-label": K.menuLabel,
2099
- children: e
2100
- });
2101
- },
2102
- children: dn
2103
- }), pn = Y || Et ? /* @__PURE__ */ G("div", {
2104
- className: "relative w-full",
2105
- children: [
2106
- Y && /* @__PURE__ */ W("div", {
2107
- ref: _t,
2108
- className: "absolute start-0 top-0",
2109
- children: qe
2335
+ children: K.renderMenu({
2336
+ query: zt,
2337
+ caretPosition: Z ?? 0,
2338
+ close: ln,
2339
+ listboxId: Wt,
2340
+ activeOptionId: Kt
2341
+ })
2110
2342
  }),
2111
- Dt && K != null && /* @__PURE__ */ G("span", {
2112
- className: c(q.commandHint, "pointer-events-none absolute start-[var(--ci-first-line-indent,0px)] top-0", N?.fontClassName || "dial-body-paragraph-text"),
2343
+ children: /* @__PURE__ */ P("span", {
2113
2344
  "aria-hidden": !0,
2114
- children: [/* @__PURE__ */ W("span", {
2115
- className: "invisible",
2116
- children: K.triggerPrefix
2117
- }), K.emptyQueryHint]
2118
- }),
2119
- fn
2120
- ]
2121
- }) : fn, mn = me ? void 0 : /* @__PURE__ */ W(et, {
2122
- onAttachClick: he ? void 0 : () => Yt.current?.click(),
2123
- attachLabel: b,
2124
- addMenuTitle: S,
2125
- menuTitle: C,
2126
- menuCloseLabel: w,
2127
- style: bt,
2128
- isDisabled: H || $,
2129
- chatSettings: Pe,
2130
- extraMenuItems: xt,
2131
- onRecordVoice: Ce && ot && !o && !$ ? () => Kt(Le.Attachment) : void 0,
2132
- recordVoiceLabel: te,
2133
- toolsMenuItems: Be ? Re : void 0,
2134
- onToolToggle: ze,
2135
- toolsMenuTitle: Ve,
2136
- toolsBackLabel: We,
2137
- menuOverlays: Ke
2345
+ className: "inline-block h-[1lh] w-0"
2346
+ })
2347
+ })
2348
+ })] }), tr = /* @__PURE__ */ F("div", {
2349
+ ref: an,
2350
+ className: "relative -me-1 -ms-1 w-[calc(100%+8px)]",
2351
+ children: [Yn && /* @__PURE__ */ F("div", {
2352
+ ref: Xn,
2353
+ className: l(q.textarea, N?.fontClassName || "dial-body-paragraph-text", "pointer-events-none absolute inset-0 z-10 max-h-[272px] w-full overflow-hidden whitespace-pre-wrap pe-1 ps-1 [overflow-wrap:anywhere]"),
2354
+ children: [Re(J, Nt, Jn, q.mentionHighlight, q.mentionHighlightUnsupported), Zn.map((e, t) => /* @__PURE__ */ P("div", {
2355
+ "aria-hidden": !0,
2356
+ className: "pointer-events-none absolute rounded-sm bg-control-accent-alpha-active",
2357
+ style: {
2358
+ left: e.left,
2359
+ top: e.top,
2360
+ width: e.width,
2361
+ height: e.height
2362
+ }
2363
+ }, `selection-${t}`))]
2364
+ }), er]
2365
+ }), nr = Se ? void 0 : /* @__PURE__ */ P(dt, {
2366
+ onAttachClick: Ce ? void 0 : () => An.current?.click(),
2367
+ attachLabel: y,
2368
+ addMenuTitle: C,
2369
+ menuTitle: w,
2370
+ menuCloseLabel: T,
2371
+ style: Ft,
2372
+ isDisabled: G || $,
2373
+ chatSettings: Xe,
2374
+ extraMenuItems: It,
2375
+ onRecordVoice: Fe && wt && !s && !$ ? () => Dn(qe.Attachment) : void 0,
2376
+ recordVoiceLabel: j,
2377
+ toolsMenuItems: nt ? Ze : void 0,
2378
+ onToolToggle: tt,
2379
+ toolsMenuTitle: rt,
2380
+ toolsBackLabel: it,
2381
+ menuOverlays: ot,
2382
+ getCaretPosition: () => X.current?.selectionStart ?? J.length
2383
+ }), rr = De === et.Inline && (!kt || W), ir = nr && /* @__PURE__ */ P("div", {
2384
+ className: l("flex", U.addCluster),
2385
+ children: nr
2386
+ }), ar = zn.length > 0 && tt != null && /* @__PURE__ */ P("div", {
2387
+ className: l("min-w-0 flex-1", U.toolsChips),
2388
+ children: /* @__PURE__ */ P(mt, {
2389
+ items: zn,
2390
+ onToolToggle: tt,
2391
+ onToolDismiss: Bn,
2392
+ canRemove: nt,
2393
+ removeLabel: at?.removeLabel,
2394
+ stateOnLabel: at?.stateOnLabel,
2395
+ stateOffLabel: at?.stateOffLabel
2396
+ })
2138
2397
  });
2139
- return /* @__PURE__ */ G("div", {
2140
- ref: Xt,
2141
- style: bt,
2142
- className: c(q.wrapper, H && q.wrapperDisabled, H && "cursor-not-allowed", "flex w-full max-w-[748px] flex-col justify-center gap-3 rounded-xl border", "focus-within:outline focus-within:-outline-offset-1 active:outline active:-outline-offset-1", kt.length > 6 ? "py-4 ps-4" : "p-4", re),
2398
+ return /* @__PURE__ */ F("div", {
2399
+ ref: jn,
2400
+ style: Ft,
2401
+ className: l(q.wrapper, G && q.wrapperDisabled, G && "cursor-not-allowed", "flex w-full max-w-[748px] flex-col justify-center gap-3 rounded-xl border", "focus-within:outline focus-within:-outline-offset-1 active:outline active:-outline-offset-1", dn.length > 6 ? "py-4 ps-4" : "p-4", ce, U.wrapper),
2143
2402
  children: [
2144
- (Ae.length > 0 || kt.length > 0) && /* @__PURE__ */ W(ve, {
2145
- attachments: [...Ae, ...kt],
2403
+ (Je.length > 0 || dn.length > 0) && /* @__PURE__ */ P(se, {
2404
+ attachments: [...Je, ...dn],
2146
2405
  onRemove: (e) => {
2147
- Ae.some((t) => t.id === e) ? je?.(e) : Nt(e);
2406
+ Je.some((t) => t.id === e) ? Ye?.(e) : hn(e);
2148
2407
  },
2149
- onRetry: Pt,
2150
- onExpand: Ft,
2408
+ onRetry: gn,
2409
+ onExpand: _n,
2151
2410
  labels: {
2152
- removeLabel: T,
2153
- retryLabel: E,
2154
- uploadingLabel: D
2411
+ removeLabel: E,
2412
+ retryLabel: D,
2413
+ uploadingLabel: ee
2155
2414
  },
2156
- onAttachmentClick: tt == null ? void 0 : (e) => {
2157
- let t = [...Ae, ...kt].find((t) => t.id === e);
2158
- t != null && tt(t);
2415
+ styles: ae,
2416
+ onAttachmentClick: _t == null ? void 0 : (e) => {
2417
+ let t = [...Je, ...dn].find((t) => t.id === e);
2418
+ t != null && _t(t);
2159
2419
  }
2160
2420
  }),
2161
- !me && /* @__PURE__ */ W("input", {
2162
- ref: Yt,
2421
+ !Se && /* @__PURE__ */ P("input", {
2422
+ ref: An,
2163
2423
  type: "file",
2164
2424
  multiple: !0,
2165
- accept: x,
2425
+ accept: S,
2166
2426
  className: "sr-only",
2167
2427
  "aria-hidden": !0,
2168
2428
  tabIndex: -1,
2169
- onChange: un
2429
+ onChange: qn
2170
2430
  }),
2171
- Gt && /* @__PURE__ */ W(_, {
2172
- text: Gt,
2431
+ En && /* @__PURE__ */ P(b, {
2432
+ text: En,
2173
2433
  className: "min-w-0 break-words px-1"
2174
2434
  }),
2175
- $ && /* @__PURE__ */ W(ct, {
2435
+ $ && /* @__PURE__ */ P(yt, {
2176
2436
  embedded: !0,
2177
- state: Ut,
2178
- analyserNodeRef: Wt,
2179
- errorMessage: Gt,
2180
- onStop: qt,
2181
- onDiscard: Jt,
2182
- attachButton: mn,
2183
- stopLabel: j,
2184
- discardLabel: ne,
2185
- processingLabel: Te
2437
+ state: wn,
2438
+ analyserNodeRef: Tn,
2439
+ onStop: On,
2440
+ onDiscard: kn,
2441
+ attachButton: nr,
2442
+ stopLabel: re,
2443
+ discardLabel: ie,
2444
+ processingLabel: ze
2445
+ }),
2446
+ !$ && we && tr,
2447
+ !$ && !we && rr && ar && /* @__PURE__ */ P("div", {
2448
+ className: "flex",
2449
+ children: ar
2186
2450
  }),
2187
- !$ && ge && pn,
2188
- !$ && !ge && /* @__PURE__ */ G("div", {
2189
- className: "flex flex-wrap items-center gap-2",
2451
+ !$ && !we && /* @__PURE__ */ F("div", {
2452
+ className: l("flex items-center gap-2", rr ? "flex-nowrap" : "flex-wrap", U.actionRow),
2190
2453
  children: [
2191
- /* @__PURE__ */ W("div", {
2192
- className: "flex w-full min-w-0 items-center self-stretch",
2193
- children: pn
2194
- }),
2195
- mn && /* @__PURE__ */ W("div", {
2196
- className: "flex",
2197
- children: mn
2454
+ rr && ir,
2455
+ /* @__PURE__ */ P("div", {
2456
+ className: l("flex min-w-0 items-center self-stretch", rr ? "flex-1" : "w-full", U.textareaWrap),
2457
+ children: tr
2198
2458
  }),
2199
- rn.length > 0 && ze != null && /* @__PURE__ */ W("div", {
2200
- className: "min-w-0 flex-1",
2201
- children: /* @__PURE__ */ W(rt, {
2202
- items: rn,
2203
- onToolToggle: ze,
2204
- onToolDismiss: an,
2205
- canRemove: Be,
2206
- removeLabel: Ge?.removeLabel
2207
- })
2208
- }),
2209
- /* @__PURE__ */ W("div", {
2210
- className: "ms-auto flex flex-shrink-0 items-center gap-2",
2211
- children: _e ? _e({
2212
- canSend: en,
2213
- onSend: cn
2214
- }) : /* @__PURE__ */ G(U, { children: [
2215
- dt,
2216
- /* @__PURE__ */ W(Bt, {
2217
- deployments: le,
2218
- selectedDeploymentId: ue,
2219
- onDeploymentChange: de,
2220
- modelSelectorLabels: fe,
2221
- isStreaming: o,
2222
- isMobile: pt,
2223
- isDisabled: ye,
2224
- style: bt,
2225
- modelPickerOverlay: nt,
2226
- isPickerOpen: mt,
2227
- onPickerToggle: () => ht((e) => !e),
2228
- onPickerOpenChange: ht
2459
+ !rr && ir,
2460
+ !rr && ar,
2461
+ /* @__PURE__ */ P("div", {
2462
+ className: l("ms-auto flex flex-shrink-0 items-center gap-2", U.footerActions),
2463
+ children: Oe ? Oe({
2464
+ canSend: In,
2465
+ onSend: Un
2466
+ }) : /* @__PURE__ */ F(oe, { children: [
2467
+ Et,
2468
+ /* @__PURE__ */ P(Zt, {
2469
+ deployments: _e,
2470
+ selectedDeploymentId: ve,
2471
+ onDeploymentChange: ye,
2472
+ modelSelectorLabels: be,
2473
+ menuStyles: I,
2474
+ isStreaming: s,
2475
+ isMobile: kt,
2476
+ isDisabled: Ae,
2477
+ style: Ft,
2478
+ modelPickerOverlay: vt,
2479
+ isPickerOpen: At,
2480
+ onPickerToggle: () => jt((e) => !e),
2481
+ onPickerOpenChange: jt
2229
2482
  }),
2230
- sn && /* @__PURE__ */ W(v, {
2231
- icon: /* @__PURE__ */ W(se, {
2232
- size: p.LG,
2233
- stroke: m,
2483
+ Hn && /* @__PURE__ */ P(x, {
2484
+ icon: /* @__PURE__ */ P(me, {
2485
+ size: g.LG,
2486
+ stroke: _,
2234
2487
  "aria-hidden": !0
2235
2488
  }),
2236
- "aria-label": A,
2237
- tooltipProps: { tooltip: A },
2489
+ "aria-label": ne,
2490
+ tooltipProps: { tooltip: ne },
2238
2491
  className: "size-[40px] flex-shrink-0 mobile:min-h-11 mobile:min-w-11",
2239
- onClick: () => Kt(Le.Dictation),
2240
- disabled: H || o
2492
+ onClick: () => Dn(qe.Dictation),
2493
+ disabled: G || s
2241
2494
  }),
2242
- o && a ? /* @__PURE__ */ W(ut, {
2243
- onStop: a,
2244
- ariaLabel: ee
2245
- }) : !o && /* @__PURE__ */ W(lt, {
2246
- onSend: cn,
2247
- isDisabled: !on || !en,
2495
+ s && o ? /* @__PURE__ */ P(xt, {
2496
+ onStop: o,
2497
+ ariaLabel: A
2498
+ }) : !s && /* @__PURE__ */ P(bt, {
2499
+ onSend: Un,
2500
+ isDisabled: !Vn || !In,
2248
2501
  ariaLabel: O,
2249
- sendTooltip: k
2502
+ sendTooltip: Fn ? k : te ?? k
2250
2503
  })
2251
2504
  ] })
2252
2505
  })
2253
2506
  ]
2254
2507
  }),
2255
- /* @__PURE__ */ W("span", {
2508
+ /* @__PURE__ */ P("span", {
2256
2509
  className: "sr-only",
2257
2510
  role: "status",
2258
2511
  "aria-live": "polite",
2259
2512
  "aria-atomic": "true",
2260
- children: /* @__PURE__ */ W("span", { children: Vt.text }, Vt.revision)
2513
+ children: /* @__PURE__ */ P("span", { children: Sn.text }, Sn.revision)
2261
2514
  })
2262
2515
  ]
2263
2516
  });
2264
- }, Ht = {
2517
+ });
2518
+ Qt.displayName = "Input";
2519
+ var $t = {
2265
2520
  welcome: "_welcome_1icyo_1",
2266
2521
  description: "_description_1icyo_5"
2267
- }, Ut = ({ isStreaming: e = !1, placeholder: t = "Type a prompt or use \"/\" to select one", welcomeText: n, descriptionText: r, styles: i, className: a, inputClassName: o, isInputDisabled: l = !1, ...u }) => {
2268
- let { colors: d, typography: f } = i ?? {};
2269
- return /* @__PURE__ */ G("div", {
2270
- style: s({
2271
- "--ci-welcome-color": d?.welcomeText,
2272
- "--ci-description-color": d?.descriptionText
2522
+ }, en = ({ isStreaming: e = !1, placeholder: t = "Type a prompt or use \"/\" to select one", welcomeText: n, descriptionText: r, belowWelcomeSlot: i, styles: a, className: o, inputClassName: s, isInputDisabled: u = !1, ...d }) => {
2523
+ let { colors: f, typography: p, attachmentTray: m, modelMenu: h } = a ?? {};
2524
+ return /* @__PURE__ */ F("div", {
2525
+ style: c({
2526
+ "--ci-welcome-color": f?.welcomeText,
2527
+ "--ci-description-color": f?.descriptionText
2273
2528
  }),
2274
- className: c("relative flex w-full flex-col items-center gap-9 px-4 py-5 desktop:p-5", a),
2275
- children: [n && /* @__PURE__ */ G("div", {
2276
- className: "flex flex-col items-center gap-4 text-center",
2277
- children: [/* @__PURE__ */ W("h1", {
2278
- className: c(Ht.welcome, "m-0", f?.welcomeClassName || "dial-display2-text"),
2279
- children: n
2280
- }), r && /* @__PURE__ */ W("p", {
2281
- className: c(Ht.description, "m-0 max-w-[540px]", f?.descriptionClassName || "dial-body-paragraph-text"),
2282
- children: r
2283
- })]
2284
- }), /* @__PURE__ */ W("div", {
2285
- className: c("relative w-full", n ? "max-w-[700px]" : "max-w-[748px]"),
2286
- children: /* @__PURE__ */ W(Vt, {
2287
- placeholder: t,
2288
- isStreaming: e,
2289
- isInputDisabled: l,
2290
- ...u,
2291
- className: o,
2292
- colors: d?.input,
2293
- typography: f?.input
2529
+ className: l("relative flex w-full flex-col items-center gap-9 px-4 py-5 desktop:p-5", o),
2530
+ children: [
2531
+ n && /* @__PURE__ */ F("div", {
2532
+ className: "flex flex-col items-center gap-4 text-center",
2533
+ children: [/* @__PURE__ */ P("h1", {
2534
+ className: l($t.welcome, "m-0", p?.welcomeClassName || "dial-display2-text"),
2535
+ children: n
2536
+ }), r && /* @__PURE__ */ P("p", {
2537
+ className: l($t.description, "m-0 max-w-[540px]", p?.descriptionClassName || "dial-body-paragraph-text"),
2538
+ children: r
2539
+ })]
2540
+ }),
2541
+ i != null && /* @__PURE__ */ P("div", {
2542
+ className: "flex w-full max-w-[700px] flex-col items-center empty:hidden",
2543
+ children: i
2544
+ }),
2545
+ /* @__PURE__ */ P("div", {
2546
+ className: l("relative w-full", n ? "max-w-[700px]" : "max-w-[748px]"),
2547
+ children: /* @__PURE__ */ P(Qt, {
2548
+ placeholder: t,
2549
+ isStreaming: e,
2550
+ isInputDisabled: u,
2551
+ ...d,
2552
+ className: s,
2553
+ colors: f?.input,
2554
+ typography: p?.input,
2555
+ attachmentTray: m,
2556
+ modelMenu: h
2557
+ })
2294
2558
  })
2295
- })]
2559
+ ]
2296
2560
  });
2297
- }, Wt = ({ message: e, inlineStartSlot: t, onInlineStartRemove: n, initialAttachments: r = [], onCancel: a, onSave: o, onUploadAttachment: s, cancelLabel: l = "Cancel", saveLabel: d = "Save & Submit", ariaLabel: f, removeLabel: p, retryLabel: h, uploadingLabel: g, addMenuTitle: _ = "Add", attachLabel: v = "Attach file", menuTitle: y = "Menu", menuCloseLabel: b = "Close", className: S, pendingDropFiles: C, onDropFilesConsumed: T, validateAttachment: E, isAttachmentsEnabled: D, isTextAttachmentsAllowed: O, hideAttachFile: k = !1, fileAccept: ee, maximumAttachmentsAmount: A, onAttachmentsLimitExceeded: te, onDialFileSystemClick: j, dialFileSystemLabel: ne, pendingAttachments: M, onPendingAttachmentsConsumed: N, onAttachmentClick: re, pasteTextThreshold: ie, maxMessageLength: P = 5e4, onMessageTooLong: F }) => {
2298
- let ae = B(null), [se, ce] = V([]);
2299
- R(() => {
2300
- C?.length && (ce(C), T?.());
2301
- }, [C, T]);
2302
- let [I, le] = V(e ?? ""), [ue, de] = V([]), [fe, pe] = V(r), me = ue.some((e) => e.status === i.Loading || e.status === i.Error), he = (I.trim().length > 0 || ue.length > 0 || fe.length > 0) && !me, ge = (e) => {
2303
- pe((t) => t.filter((t) => t.id !== e));
2304
- }, _e = L((e, t) => {
2305
- o(e, fe, t);
2306
- }, [fe, o]), H = () => {
2307
- if (he) {
2308
- if (I.length >= P) {
2309
- F?.(I.length, P);
2561
+ }, tn = ({ message: e, messageRevision: t, onChange: n, activeMentions: r, onBackspaceAtCaret: i, caretPositionOverride: o, commandMenu: s, menuOverlays: c, initialAttachments: u = [], onCancel: d, onSave: p, onUploadAttachment: m, cancelLabel: h = "Cancel", saveLabel: g = "Save & Submit", ariaLabel: v, removeLabel: y, retryLabel: b, uploadingLabel: x, addMenuTitle: S = "Add", attachLabel: C = "Attach file", menuTitle: T = "Menu", menuCloseLabel: E = "Close", className: D, pendingDropFiles: O, onDropFilesConsumed: k, validateAttachment: te, isAttachmentsEnabled: A, isTextAttachmentsAllowed: ne, hideAttachFile: j = !1, fileAccept: re, maximumAttachmentsAmount: ie, onAttachmentsLimitExceeded: M, onDialFileSystemClick: N, dialFileSystemLabel: ae, pendingAttachments: oe, onPendingAttachmentsConsumed: se, onAttachmentClick: I, pasteTextThreshold: ce, maxMessageLength: le = 5e4, onMessageTooLong: ue }) => {
2562
+ let L = V(null), de = V(null), [fe, me] = H([]);
2563
+ z(() => {
2564
+ O?.length && (me(O), k?.());
2565
+ }, [O, k]);
2566
+ let [he, ge] = H(e ?? ""), [_e, ve] = H([]), [ye, be] = H(u), xe = _e.some((e) => e.status === a.Loading || e.status === a.Error), Se = (he.trim().length > 0 || _e.length > 0 || ye.length > 0) && !xe, Ce = (e) => {
2567
+ be((t) => t.filter((t) => t.id !== e));
2568
+ }, we = R((e, t) => {
2569
+ p(e, ye, t);
2570
+ }, [ye, p]), Te = () => {
2571
+ if (Se) {
2572
+ if (he.length >= le) {
2573
+ ue?.(he.length, le);
2310
2574
  return;
2311
2575
  }
2312
- _e(I, ue);
2576
+ we(he, _e);
2313
2577
  }
2314
- }, ve = L(() => ce([]), []), ye = L((e) => {
2578
+ }, Ee = R(() => me([]), []), U = R((e) => {
2579
+ ge(e), n?.(e);
2580
+ }, [n]), De = R((e) => {
2315
2581
  let t = Array.from(e.target.files ?? []);
2316
- t.length !== 0 && (e.target.value = "", ce(t));
2317
- }, []), be = z(() => j ? [{
2582
+ t.length !== 0 && (e.target.value = "", me(t));
2583
+ }, []), W = B(() => N ? [{
2318
2584
  key: "dial-fs",
2319
- label: ne ?? "DIAL file system",
2320
- icon: /* @__PURE__ */ W(oe, {
2321
- size: u,
2585
+ label: ae ?? "DIAL file system",
2586
+ icon: /* @__PURE__ */ P(pe, {
2587
+ size: f,
2322
2588
  "aria-hidden": !0,
2323
- stroke: m
2589
+ stroke: _
2324
2590
  }),
2325
- onClick: j
2326
- }] : [], [j, ne]);
2327
- return /* @__PURE__ */ G("div", {
2328
- className: c("flex w-full flex-col gap-2", S),
2329
- children: [/* @__PURE__ */ W(Vt, {
2591
+ onClick: N
2592
+ }] : [], [N, ae]);
2593
+ return /* @__PURE__ */ F("div", {
2594
+ className: l("flex w-full flex-col gap-2", D),
2595
+ children: [/* @__PURE__ */ P(Qt, {
2596
+ ref: de,
2330
2597
  message: e,
2331
- inlineStartSlot: t,
2332
- onInlineStartRemove: n,
2333
- ariaLabel: f,
2598
+ messageRevision: t,
2599
+ activeMentions: r,
2600
+ onBackspaceAtCaret: i,
2601
+ caretPositionOverride: o,
2602
+ commandMenu: s,
2603
+ ariaLabel: v,
2334
2604
  hideActionBar: !0,
2335
- pendingDropFiles: se,
2336
- onDropFilesConsumed: ve,
2337
- onSend: _e,
2338
- onUploadAttachment: s,
2339
- onChange: le,
2340
- onAttachmentsChange: de,
2341
- removeLabel: p,
2342
- retryLabel: h,
2343
- uploadingLabel: g,
2605
+ pendingDropFiles: fe,
2606
+ onDropFilesConsumed: Ee,
2607
+ onSend: we,
2608
+ onUploadAttachment: m,
2609
+ onChange: U,
2610
+ onAttachmentsChange: ve,
2611
+ removeLabel: y,
2612
+ retryLabel: b,
2613
+ uploadingLabel: x,
2344
2614
  className: "max-w-full",
2345
- prefixAttachments: fe,
2346
- onRemovePrefixAttachment: ge,
2347
- validateAttachment: E,
2348
- isAttachmentsEnabled: D,
2349
- isTextAttachmentsAllowed: O,
2350
- maximumAttachmentsAmount: A,
2351
- onAttachmentsLimitExceeded: te,
2352
- pendingAttachments: M,
2353
- onPendingAttachmentsConsumed: N,
2354
- onAttachmentClick: re,
2355
- pasteTextThreshold: ie,
2356
- maxMessageLength: P,
2357
- onMessageTooLong: F
2358
- }), /* @__PURE__ */ G("div", {
2615
+ prefixAttachments: ye,
2616
+ onRemovePrefixAttachment: Ce,
2617
+ validateAttachment: te,
2618
+ isAttachmentsEnabled: A,
2619
+ isTextAttachmentsAllowed: ne,
2620
+ maximumAttachmentsAmount: ie,
2621
+ onAttachmentsLimitExceeded: M,
2622
+ pendingAttachments: oe,
2623
+ onPendingAttachmentsConsumed: se,
2624
+ onAttachmentClick: I,
2625
+ pasteTextThreshold: ce,
2626
+ maxMessageLength: le,
2627
+ onMessageTooLong: ue
2628
+ }), /* @__PURE__ */ F("div", {
2359
2629
  className: "flex items-center justify-between",
2360
- children: [/* @__PURE__ */ W("div", {
2630
+ children: [/* @__PURE__ */ F("div", {
2361
2631
  className: "flex",
2362
- children: !k && /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("input", {
2363
- ref: ae,
2632
+ children: [!j && /* @__PURE__ */ P("input", {
2633
+ ref: L,
2364
2634
  type: "file",
2365
2635
  multiple: !0,
2366
- accept: ee,
2636
+ accept: re,
2367
2637
  className: "sr-only",
2368
2638
  "aria-hidden": !0,
2369
2639
  tabIndex: -1,
2370
- onChange: ye
2371
- }), /* @__PURE__ */ W(et, {
2372
- onAttachClick: () => ae.current?.click(),
2373
- attachLabel: v,
2374
- addMenuTitle: _,
2375
- menuTitle: y,
2376
- menuCloseLabel: b,
2377
- extraMenuItems: be
2378
- })] })
2379
- }), /* @__PURE__ */ G("div", {
2640
+ onChange: De
2641
+ }), (!j || (c?.length ?? 0) > 0) && /* @__PURE__ */ P(dt, {
2642
+ onAttachClick: j ? void 0 : () => L.current?.click(),
2643
+ attachLabel: C,
2644
+ addMenuTitle: S,
2645
+ menuTitle: T,
2646
+ menuCloseLabel: E,
2647
+ extraMenuItems: W,
2648
+ menuOverlays: c,
2649
+ getCaretPosition: () => de.current?.getCaretPosition() ?? 0
2650
+ })]
2651
+ }), /* @__PURE__ */ F("div", {
2380
2652
  className: "flex gap-2",
2381
- children: [/* @__PURE__ */ W(x, {
2382
- label: l,
2383
- onClick: a
2384
- }), /* @__PURE__ */ W(w, {
2385
- label: d,
2386
- onClick: H,
2387
- disabled: !he
2653
+ children: [/* @__PURE__ */ P(w, {
2654
+ label: h,
2655
+ onClick: d
2656
+ }), /* @__PURE__ */ P(ee, {
2657
+ label: g,
2658
+ onClick: Te,
2659
+ disabled: !Se
2388
2660
  })]
2389
2661
  })]
2390
2662
  })]
2391
2663
  });
2664
+ }, nn = (e) => {
2665
+ let [t, n] = H({
2666
+ text: e?.text,
2667
+ revision: e?.revision ?? 0
2668
+ }), r = R((e) => {
2669
+ n((t) => ({
2670
+ text: e,
2671
+ revision: t.revision + 1
2672
+ }));
2673
+ }, []);
2674
+ return {
2675
+ message: t.text,
2676
+ messageRevision: t.revision,
2677
+ seedMessage: r
2678
+ };
2679
+ }, rn = (e, t) => {
2680
+ let n = V(e), r = V(t);
2681
+ r.current = t, z(() => {
2682
+ e !== n.current && (n.current = e, r.current());
2683
+ }, [e]);
2392
2684
  };
2393
2685
  //#endregion
2394
- export { Te as BottomSheetShell, Xe as ChatSettingsModal, Ut as ConversationInput, Wt as EditMessageInput, Vt as Input, Ue as SendOnEnter };
2686
+ export { et as ActionRowLayout, W as BottomSheetShell, U as CONVERSATION_INPUT_CLASS, ct as ChatSettingsModal, en as ConversationInput, tn as EditMessageInput, Qt as Input, $e as SendOnEnter, nn as useComposerSeed, rn as useComposerSeedSource };