@assistant-ui/react 0.5.21 → 0.5.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/{AssistantTypes-D93BmqD5.d.mts → AssistantTypes-BNB-knVq.d.mts} +1 -1
  2. package/dist/{AssistantTypes-D93BmqD5.d.ts → AssistantTypes-BNB-knVq.d.ts} +1 -1
  3. package/dist/chunk-DCHYNTHI.js +11 -0
  4. package/dist/chunk-DCHYNTHI.js.map +1 -0
  5. package/dist/chunk-NSPHKRLF.js +819 -0
  6. package/dist/chunk-NSPHKRLF.js.map +1 -0
  7. package/dist/{chunk-2RKUKZSZ.mjs → chunk-ZWRFAYHH.mjs} +61 -3
  8. package/dist/chunk-ZWRFAYHH.mjs.map +1 -0
  9. package/dist/edge.d.mts +90 -5
  10. package/dist/edge.d.ts +90 -5
  11. package/dist/edge.js +0 -1
  12. package/dist/edge.js.map +1 -1
  13. package/dist/edge.mjs +799 -49
  14. package/dist/edge.mjs.map +1 -1
  15. package/dist/index.d.mts +153 -7
  16. package/dist/index.d.ts +153 -7
  17. package/dist/index.js +724 -1596
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +807 -252
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/tailwindcss/index.js +24 -53
  22. package/dist/tailwindcss/index.js.map +1 -1
  23. package/package.json +1 -12
  24. package/dist/Thread-BbLf1cc4.d.mts +0 -156
  25. package/dist/Thread-jfAlPLli.d.ts +0 -156
  26. package/dist/chunk-2RKUKZSZ.mjs.map +0 -1
  27. package/dist/chunk-QBS6JLLN.mjs +0 -63
  28. package/dist/chunk-QBS6JLLN.mjs.map +0 -1
  29. package/dist/chunk-V66MVXBH.mjs +0 -608
  30. package/dist/chunk-V66MVXBH.mjs.map +0 -1
  31. package/dist/internal.d.mts +0 -9
  32. package/dist/internal.d.ts +0 -9
  33. package/dist/internal.js +0 -620
  34. package/dist/internal.js.map +0 -1
  35. package/dist/internal.mjs +0 -24
  36. package/dist/internal.mjs.map +0 -1
  37. package/internal/README.md +0 -1
  38. package/internal/package.json +0 -5
package/dist/index.js CHANGED
@@ -1,119 +1,31 @@
1
- "use client";
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // src/index.ts
32
- var src_exports = {};
33
- __export(src_exports, {
34
- ActionBarPrimitive: () => actionBar_exports,
35
- AssistantActionBar: () => assistant_action_bar_default,
36
- AssistantMessage: () => assistant_message_default,
37
- AssistantModal: () => assistant_modal_default,
38
- AssistantModalPrimitive: () => assistantModal_exports,
39
- AssistantRuntimeProvider: () => AssistantRuntimeProvider,
40
- BranchPicker: () => branch_picker_default,
41
- BranchPickerPrimitive: () => branchPicker_exports,
42
- Composer: () => composer_default,
43
- ComposerPrimitive: () => composer_exports,
44
- ContentPart: () => content_part_default,
45
- ContentPartPrimitive: () => contentPart_exports,
46
- EdgeChatAdapter: () => EdgeChatAdapter,
47
- EditComposer: () => edit_composer_default,
48
- ExternalStoreRuntime: () => ExternalStoreRuntime,
49
- INTERNAL: () => internal_exports,
50
- MessagePrimitive: () => message_exports,
51
- Thread: () => thread_default,
52
- ThreadConfigProvider: () => ThreadConfigProvider,
53
- ThreadPrimitive: () => thread_exports,
54
- ThreadWelcome: () => thread_welcome_default,
55
- UserActionBar: () => user_action_bar_default,
56
- UserMessage: () => user_message_default,
57
- fromCoreMessage: () => fromCoreMessage,
58
- fromCoreMessages: () => fromCoreMessages,
59
- fromLanguageModelMessages: () => fromLanguageModelMessages,
60
- fromLanguageModelTools: () => fromLanguageModelTools,
61
- getExternalStoreMessage: () => getExternalStoreMessage,
62
- makeAssistantTool: () => makeAssistantTool,
63
- makeAssistantToolUI: () => makeAssistantToolUI,
64
- toCoreMessage: () => toCoreMessage,
65
- toCoreMessages: () => toCoreMessages,
66
- toLanguageModelMessages: () => toLanguageModelMessages,
67
- toLanguageModelTools: () => toLanguageModelTools,
68
- useActionBarCopy: () => useActionBarCopy,
69
- useActionBarEdit: () => useActionBarEdit,
70
- useActionBarReload: () => useActionBarReload,
71
- useAppendMessage: () => useAppendMessage,
72
- useAssistantContext: () => useAssistantContext,
73
- useAssistantInstructions: () => useAssistantInstructions,
74
- useAssistantTool: () => useAssistantTool,
75
- useAssistantToolUI: () => useAssistantToolUI,
76
- useBranchPickerCount: () => useBranchPickerCount,
77
- useBranchPickerNext: () => useBranchPickerNext,
78
- useBranchPickerNumber: () => useBranchPickerNumber,
79
- useBranchPickerPrevious: () => useBranchPickerPrevious,
80
- useComposerCancel: () => useComposerCancel,
81
- useComposerContext: () => useComposerContext,
82
- useComposerIf: () => useComposerIf,
83
- useComposerSend: () => useComposerSend,
84
- useContentPartContext: () => useContentPartContext,
85
- useContentPartDisplay: () => useContentPartDisplay,
86
- useContentPartImage: () => useContentPartImage,
87
- useContentPartText: () => useContentPartText,
88
- useEdgeRuntime: () => useEdgeRuntime,
89
- useExternalStoreRuntime: () => useExternalStoreRuntime,
90
- useLocalRuntime: () => useLocalRuntime,
91
- useMessageContext: () => useMessageContext,
92
- useMessageIf: () => useMessageIf,
93
- useSwitchToNewThread: () => useSwitchToNewThread,
94
- useThreadConfig: () => useThreadConfig,
95
- useThreadContext: () => useThreadContext,
96
- useThreadEmpty: () => useThreadEmpty,
97
- useThreadIf: () => useThreadIf,
98
- useThreadScrollToBottom: () => useThreadScrollToBottom,
99
- useThreadSuggestion: () => useThreadSuggestion
100
- });
101
- module.exports = __toCommonJS(src_exports);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8;"use client";
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ var _chunkNSPHKRLFjs = require('./chunk-NSPHKRLF.js');
11
+
12
+
13
+ var _chunkDCHYNTHIjs = require('./chunk-DCHYNTHI.js');
102
14
 
103
15
  // src/context/providers/AssistantRuntimeProvider.tsx
104
- var import_react6 = require("react");
16
+ var _react = require('react');
105
17
 
106
18
  // src/context/providers/AssistantProvider.tsx
107
- var import_react5 = require("react");
19
+
108
20
 
109
21
  // src/context/react/AssistantContext.ts
110
- var import_react = require("react");
111
- var AssistantContext = (0, import_react.createContext)(
22
+
23
+ var AssistantContext = _react.createContext.call(void 0,
112
24
  null
113
25
  );
114
26
  function useAssistantContext(options) {
115
- const context = (0, import_react.useContext)(AssistantContext);
116
- if (!options?.optional && !context)
27
+ const context = _react.useContext.call(void 0, AssistantContext);
28
+ if (!_optionalChain([options, 'optionalAccess', _2 => _2.optional]) && !context)
117
29
  throw new Error(
118
30
  "This component must be used within an AssistantRuntimeProvider."
119
31
  );
@@ -121,68 +33,13 @@ function useAssistantContext(options) {
121
33
  }
122
34
 
123
35
  // src/context/stores/AssistantModelConfig.ts
124
- var import_zustand = require("zustand");
125
-
126
- // src/types/ModelConfigTypes.ts
127
- var import_zod = require("zod");
128
- var LanguageModelV1CallSettingsSchema = import_zod.z.object({
129
- maxTokens: import_zod.z.number().int().positive().optional(),
130
- temperature: import_zod.z.number().optional(),
131
- topP: import_zod.z.number().optional(),
132
- presencePenalty: import_zod.z.number().optional(),
133
- frequencyPenalty: import_zod.z.number().optional(),
134
- seed: import_zod.z.number().int().optional(),
135
- headers: import_zod.z.record(import_zod.z.string().optional()).optional()
136
- });
137
- var LanguageModelConfigSchema = import_zod.z.object({
138
- apiKey: import_zod.z.string().optional(),
139
- baseUrl: import_zod.z.string().optional(),
140
- modelName: import_zod.z.string().optional()
141
- });
142
- var mergeModelConfigs = (configSet) => {
143
- const configs = Array.from(configSet).map((c) => c.getModelConfig()).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
144
- return configs.reduce((acc, config) => {
145
- if (config.system) {
146
- if (acc.system) {
147
- acc.system += `
148
-
149
- ${config.system}`;
150
- } else {
151
- acc.system = config.system;
152
- }
153
- }
154
- if (config.tools) {
155
- for (const [name, tool] of Object.entries(config.tools)) {
156
- if (acc.tools?.[name]) {
157
- throw new Error(
158
- `You tried to define a tool with the name ${name}, but it already exists.`
159
- );
160
- }
161
- if (!acc.tools) acc.tools = {};
162
- acc.tools[name] = tool;
163
- }
164
- }
165
- if (config.config) {
166
- acc.config = {
167
- ...acc.config,
168
- ...config.config
169
- };
170
- }
171
- if (config.callSettings) {
172
- acc.callSettings = {
173
- ...acc.callSettings,
174
- ...config.callSettings
175
- };
176
- }
177
- return acc;
178
- }, {});
179
- };
36
+ var _zustand = require('zustand');
180
37
 
181
38
  // src/utils/ProxyConfigProvider.ts
182
- var ProxyConfigProvider = class {
183
- _providers = /* @__PURE__ */ new Set();
39
+ var ProxyConfigProvider = (_class = class {constructor() { _class.prototype.__init.call(this); }
40
+ __init() {this._providers = /* @__PURE__ */ new Set()}
184
41
  getModelConfig() {
185
- return mergeModelConfigs(this._providers);
42
+ return _chunkNSPHKRLFjs.mergeModelConfigs.call(void 0, this._providers);
186
43
  }
187
44
  registerModelConfigProvider(provider) {
188
45
  this._providers.add(provider);
@@ -190,10 +47,10 @@ var ProxyConfigProvider = class {
190
47
  this._providers.delete(provider);
191
48
  };
192
49
  }
193
- };
50
+ }, _class);
194
51
 
195
52
  // src/context/stores/AssistantModelConfig.ts
196
- var makeAssistantModelConfigStore = () => (0, import_zustand.create)(() => {
53
+ var makeAssistantModelConfigStore = () => _zustand.create.call(void 0, () => {
197
54
  const proxy = new ProxyConfigProvider();
198
55
  return Object.freeze({
199
56
  getModelConfig: () => {
@@ -206,13 +63,13 @@ var makeAssistantModelConfigStore = () => (0, import_zustand.create)(() => {
206
63
  });
207
64
 
208
65
  // src/context/stores/AssistantToolUIs.ts
209
- var import_zustand2 = require("zustand");
210
- var makeAssistantToolUIsStore = () => (0, import_zustand2.create)((set) => {
66
+
67
+ var makeAssistantToolUIsStore = () => _zustand.create.call(void 0, (set) => {
211
68
  const renderers = /* @__PURE__ */ new Map();
212
69
  return Object.freeze({
213
70
  getToolUI: (name) => {
214
71
  const arr = renderers.get(name);
215
- const last = arr?.at(-1);
72
+ const last = _optionalChain([arr, 'optionalAccess', _3 => _3.at, 'call', _4 => _4(-1)]);
216
73
  if (last) return last;
217
74
  return null;
218
75
  },
@@ -238,14 +95,14 @@ var makeAssistantToolUIsStore = () => (0, import_zustand2.create)((set) => {
238
95
  });
239
96
 
240
97
  // src/context/providers/ThreadProvider.tsx
241
- var import_react4 = require("react");
98
+
242
99
 
243
100
  // src/context/react/ThreadContext.ts
244
- var import_react2 = require("react");
245
- var ThreadContext = (0, import_react2.createContext)(null);
101
+
102
+ var ThreadContext = _react.createContext.call(void 0, null);
246
103
  function useThreadContext(options) {
247
- const context = (0, import_react2.useContext)(ThreadContext);
248
- if (!options?.optional && !context)
104
+ const context = _react.useContext.call(void 0, ThreadContext);
105
+ if (!_optionalChain([options, 'optionalAccess', _5 => _5.optional]) && !context)
249
106
  throw new Error(
250
107
  "This component must be used within an AssistantRuntimeProvider."
251
108
  );
@@ -253,7 +110,7 @@ function useThreadContext(options) {
253
110
  }
254
111
 
255
112
  // src/context/stores/Composer.ts
256
- var import_zustand3 = require("zustand");
113
+
257
114
 
258
115
  // src/context/stores/BaseComposer.ts
259
116
  var makeBaseComposer = (set) => ({
@@ -266,7 +123,7 @@ var makeBaseComposer = (set) => ({
266
123
  // src/context/stores/Composer.ts
267
124
  var makeComposerStore = (useThreadMessages, useThreadActions) => {
268
125
  const focusListeners = /* @__PURE__ */ new Set();
269
- return (0, import_zustand3.create)()((set, get, store) => {
126
+ return _zustand.create.call(void 0, )((set, get, store) => {
270
127
  return {
271
128
  ...makeBaseComposer(set, get, store),
272
129
  get canCancel() {
@@ -277,7 +134,7 @@ var makeComposerStore = (useThreadMessages, useThreadActions) => {
277
134
  const { setValue, value } = get();
278
135
  setValue("");
279
136
  useThreadActions.getState().append({
280
- parentId: useThreadMessages.getState().at(-1)?.id ?? null,
137
+ parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _6 => _6.getState, 'call', _7 => _7(), 'access', _8 => _8.at, 'call', _9 => _9(-1), 'optionalAccess', _10 => _10.id]), () => ( null)),
281
138
  role: "user",
282
139
  content: [{ type: "text", text: value }]
283
140
  });
@@ -301,19 +158,19 @@ var makeComposerStore = (useThreadMessages, useThreadActions) => {
301
158
  };
302
159
 
303
160
  // src/context/stores/Thread.ts
304
- var import_zustand4 = require("zustand");
161
+
305
162
  var makeThreadStore = (runtimeRef) => {
306
- return (0, import_zustand4.create)(() => ({
163
+ return _zustand.create.call(void 0, () => ({
307
164
  isDisabled: runtimeRef.getState().isDisabled,
308
165
  isRunning: runtimeRef.getState().isRunning
309
166
  }));
310
167
  };
311
168
 
312
169
  // src/context/stores/ThreadViewport.tsx
313
- var import_zustand5 = require("zustand");
170
+
314
171
  var makeThreadViewportStore = () => {
315
172
  const scrollToBottomListeners = /* @__PURE__ */ new Set();
316
- return (0, import_zustand5.create)(() => ({
173
+ return _zustand.create.call(void 0, () => ({
317
174
  isAtBottom: true,
318
175
  scrollToBottom: () => {
319
176
  for (const listener of scrollToBottomListeners) {
@@ -330,9 +187,9 @@ var makeThreadViewportStore = () => {
330
187
  };
331
188
 
332
189
  // src/context/stores/ThreadActions.ts
333
- var import_zustand6 = require("zustand");
190
+
334
191
  var makeThreadActionStore = (runtimeStore) => {
335
- return (0, import_zustand6.create)(
192
+ return _zustand.create.call(void 0,
336
193
  () => Object.freeze({
337
194
  get capabilities() {
338
195
  return runtimeStore.getState().capabilities;
@@ -348,22 +205,22 @@ var makeThreadActionStore = (runtimeStore) => {
348
205
  };
349
206
 
350
207
  // src/context/stores/ThreadMessages.ts
351
- var import_zustand7 = require("zustand");
208
+
352
209
  var makeThreadMessagesStore = (runtimeRef) => {
353
- return (0, import_zustand7.create)(() => runtimeRef.getState().messages);
210
+ return _zustand.create.call(void 0, () => runtimeRef.getState().messages);
354
211
  };
355
212
 
356
213
  // src/context/stores/ThreadRuntime.tsx
357
- var import_zustand8 = require("zustand");
214
+
358
215
  var makeThreadRuntimeStore = (runtime) => {
359
- return (0, import_zustand8.create)(() => runtime);
216
+ return _zustand.create.call(void 0, () => runtime);
360
217
  };
361
218
 
362
219
  // src/utils/hooks/useManagedRef.ts
363
- var import_react3 = require("react");
220
+
364
221
  var useManagedRef = (callback) => {
365
- const cleanupRef = (0, import_react3.useRef)();
366
- const ref = (0, import_react3.useCallback)(
222
+ const cleanupRef = _react.useRef.call(void 0, );
223
+ const ref = _react.useCallback.call(void 0,
367
224
  (el) => {
368
225
  if (cleanupRef.current) {
369
226
  cleanupRef.current();
@@ -378,12 +235,12 @@ var useManagedRef = (callback) => {
378
235
  };
379
236
 
380
237
  // src/context/providers/ThreadProvider.tsx
381
- var import_jsx_runtime = require("react/jsx-runtime");
238
+ var _jsxruntime = require('react/jsx-runtime');
382
239
  var ThreadProvider = ({
383
240
  children,
384
241
  provider
385
242
  }) => {
386
- const [context] = (0, import_react4.useState)(() => {
243
+ const [context] = _react.useState.call(void 0, () => {
387
244
  const useThreadRuntime = makeThreadRuntimeStore(provider.thread);
388
245
  const useThread = makeThreadStore(useThreadRuntime);
389
246
  const useThreadMessages = makeThreadMessagesStore(useThreadRuntime);
@@ -400,7 +257,7 @@ var ThreadProvider = ({
400
257
  };
401
258
  });
402
259
  const threadRef = useManagedRef(
403
- (0, import_react4.useCallback)(
260
+ _react.useCallback.call(void 0,
404
261
  (thread) => {
405
262
  const onThreadUpdate = () => {
406
263
  const threadState = context.useThread.getState();
@@ -423,7 +280,7 @@ var ThreadProvider = ({
423
280
  [context]
424
281
  )
425
282
  );
426
- (0, import_react4.useInsertionEffect)(() => {
283
+ _react.useInsertionEffect.call(void 0, () => {
427
284
  const unsubscribe = provider.subscribe(() => {
428
285
  context.useThreadRuntime.setState(provider.thread, true);
429
286
  threadRef(provider.thread);
@@ -437,15 +294,15 @@ var ThreadProvider = ({
437
294
  const Synchronizer = context.useThreadRuntime(
438
295
  (t) => t.unstable_synchronizer
439
296
  );
440
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ThreadContext.Provider, { value: context, children: [
441
- Synchronizer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Synchronizer, {}),
297
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadContext.Provider, { value: context, children: [
298
+ Synchronizer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Synchronizer, {}),
442
299
  children
443
300
  ] });
444
301
  };
445
302
 
446
303
  // src/context/stores/AssistantActions.tsx
447
- var import_zustand9 = require("zustand");
448
- var makeAssistantActionsStore = (runtimeRef) => (0, import_zustand9.create)(
304
+
305
+ var makeAssistantActionsStore = (runtimeRef) => _zustand.create.call(void 0,
449
306
  () => Object.freeze({
450
307
  switchToThread: () => runtimeRef.current.switchToThread(null),
451
308
  getRuntime: () => runtimeRef.current
@@ -453,41 +310,41 @@ var makeAssistantActionsStore = (runtimeRef) => (0, import_zustand9.create)(
453
310
  );
454
311
 
455
312
  // src/context/providers/AssistantProvider.tsx
456
- var import_jsx_runtime2 = require("react/jsx-runtime");
313
+
457
314
  var AssistantProvider = ({ children, runtime }) => {
458
- const runtimeRef = (0, import_react5.useRef)(runtime);
459
- (0, import_react5.useInsertionEffect)(() => {
315
+ const runtimeRef = _react.useRef.call(void 0, runtime);
316
+ _react.useInsertionEffect.call(void 0, () => {
460
317
  runtimeRef.current = runtime;
461
318
  });
462
- const [context] = (0, import_react5.useState)(() => {
319
+ const [context] = _react.useState.call(void 0, () => {
463
320
  const useModelConfig = makeAssistantModelConfigStore();
464
321
  const useToolUIs = makeAssistantToolUIsStore();
465
322
  const useAssistantActions = makeAssistantActionsStore(runtimeRef);
466
323
  return { useModelConfig, useToolUIs, useAssistantActions };
467
324
  });
468
325
  const getModelConfig = context.useModelConfig();
469
- (0, import_react5.useEffect)(() => {
326
+ _react.useEffect.call(void 0, () => {
470
327
  return runtime.registerModelConfigProvider(getModelConfig);
471
328
  }, [runtime, getModelConfig]);
472
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AssistantContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ThreadProvider, { provider: runtime, children }) });
329
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantContext.Provider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadProvider, { provider: runtime, children }) });
473
330
  };
474
331
 
475
332
  // src/context/providers/AssistantRuntimeProvider.tsx
476
- var import_jsx_runtime3 = require("react/jsx-runtime");
333
+
477
334
  var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
478
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AssistantProvider, { runtime, children });
335
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantProvider, { runtime, children });
479
336
  };
480
- var AssistantRuntimeProvider = (0, import_react6.memo)(AssistantRuntimeProviderImpl);
337
+ var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProviderImpl);
481
338
 
482
339
  // src/context/react/ComposerContext.ts
483
- var import_react8 = require("react");
340
+
484
341
 
485
342
  // src/context/react/MessageContext.ts
486
- var import_react7 = require("react");
487
- var MessageContext = (0, import_react7.createContext)(null);
343
+
344
+ var MessageContext = _react.createContext.call(void 0, null);
488
345
  function useMessageContext(options) {
489
- const context = (0, import_react7.useContext)(MessageContext);
490
- if (!options?.optional && !context)
346
+ const context = _react.useContext.call(void 0, MessageContext);
347
+ if (!_optionalChain([options, 'optionalAccess', _11 => _11.optional]) && !context)
491
348
  throw new Error(
492
349
  "This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
493
350
  );
@@ -497,10 +354,10 @@ function useMessageContext(options) {
497
354
  // src/context/react/ComposerContext.ts
498
355
  var useComposerContext = () => {
499
356
  const { useComposer } = useThreadContext();
500
- const { useEditComposer } = useMessageContext({ optional: true }) ?? {};
501
- return (0, import_react8.useMemo)(
357
+ const { useEditComposer } = _nullishCoalesce(useMessageContext({ optional: true }), () => ( {}));
358
+ return _react.useMemo.call(void 0,
502
359
  () => ({
503
- useComposer: useEditComposer ?? useComposer,
360
+ useComposer: _nullishCoalesce(useEditComposer, () => ( useComposer)),
504
361
  type: useEditComposer ? "edit" : "new"
505
362
  }),
506
363
  [useEditComposer, useComposer]
@@ -508,13 +365,13 @@ var useComposerContext = () => {
508
365
  };
509
366
 
510
367
  // src/context/react/ContentPartContext.ts
511
- var import_react9 = require("react");
512
- var ContentPartContext = (0, import_react9.createContext)(
368
+
369
+ var ContentPartContext = _react.createContext.call(void 0,
513
370
  null
514
371
  );
515
372
  function useContentPartContext(options) {
516
- const context = (0, import_react9.useContext)(ContentPartContext);
517
- if (!options?.optional && !context)
373
+ const context = _react.useContext.call(void 0, ContentPartContext);
374
+ if (!_optionalChain([options, 'optionalAccess', _12 => _12.optional]) && !context)
518
375
  throw new Error(
519
376
  "This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
520
377
  );
@@ -522,24 +379,24 @@ function useContentPartContext(options) {
522
379
  }
523
380
 
524
381
  // src/hooks/useAppendMessage.tsx
525
- var import_react10 = require("react");
382
+
526
383
  var toAppendMessage = (useThreadMessages, message) => {
527
384
  if (typeof message === "string") {
528
385
  return {
529
- parentId: useThreadMessages.getState().at(-1)?.id ?? null,
386
+ parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _13 => _13.getState, 'call', _14 => _14(), 'access', _15 => _15.at, 'call', _16 => _16(-1), 'optionalAccess', _17 => _17.id]), () => ( null)),
530
387
  role: "user",
531
388
  content: [{ type: "text", text: message }]
532
389
  };
533
390
  }
534
391
  return {
535
- parentId: message.parentId ?? useThreadMessages.getState().at(-1)?.id ?? null,
536
- role: message.role ?? "user",
392
+ parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _18 => _18.getState, 'call', _19 => _19(), 'access', _20 => _20.at, 'call', _21 => _21(-1), 'optionalAccess', _22 => _22.id]))), () => ( null)),
393
+ role: _nullishCoalesce(message.role, () => ( "user")),
537
394
  content: message.content
538
395
  };
539
396
  };
540
397
  var useAppendMessage = () => {
541
398
  const { useThreadMessages, useThreadActions, useViewport, useComposer } = useThreadContext();
542
- const append = (0, import_react10.useCallback)(
399
+ const append = _react.useCallback.call(void 0,
543
400
  (message) => {
544
401
  const appendMessage = toAppendMessage(useThreadMessages, message);
545
402
  useThreadActions.getState().append(appendMessage);
@@ -552,11 +409,11 @@ var useAppendMessage = () => {
552
409
  };
553
410
 
554
411
  // src/hooks/useSwitchToNewThread.tsx
555
- var import_react11 = require("react");
412
+
556
413
  var useSwitchToNewThread = () => {
557
414
  const { useAssistantActions } = useAssistantContext();
558
415
  const { useComposer } = useThreadContext();
559
- const switchToNewThread = (0, import_react11.useCallback)(() => {
416
+ const switchToNewThread = _react.useCallback.call(void 0, () => {
560
417
  useAssistantActions.getState().switchToThread(null);
561
418
  useComposer.getState().focus();
562
419
  }, [useAssistantActions, useComposer]);
@@ -564,14 +421,14 @@ var useSwitchToNewThread = () => {
564
421
  };
565
422
 
566
423
  // src/model-config/useAssistantTool.tsx
567
- var import_react12 = require("react");
424
+
568
425
  var useAssistantTool = (tool) => {
569
426
  const { useModelConfig, useToolUIs } = useAssistantContext();
570
427
  const registerModelConfigProvider = useModelConfig(
571
428
  (s) => s.registerModelConfigProvider
572
429
  );
573
430
  const setToolUI = useToolUIs((s) => s.setToolUI);
574
- (0, import_react12.useEffect)(() => {
431
+ _react.useEffect.call(void 0, () => {
575
432
  const { toolName, render, ...rest } = tool;
576
433
  const config = {
577
434
  tools: {
@@ -584,7 +441,7 @@ var useAssistantTool = (tool) => {
584
441
  const unsub2 = render ? setToolUI(toolName, render) : void 0;
585
442
  return () => {
586
443
  unsub1();
587
- unsub2?.();
444
+ _optionalChain([unsub2, 'optionalCall', _23 => _23()]);
588
445
  };
589
446
  }, [registerModelConfigProvider, setToolUI, tool]);
590
447
  };
@@ -599,11 +456,11 @@ var makeAssistantTool = (tool) => {
599
456
  };
600
457
 
601
458
  // src/model-config/useAssistantToolUI.tsx
602
- var import_react13 = require("react");
459
+
603
460
  var useAssistantToolUI = (tool) => {
604
461
  const { useToolUIs } = useAssistantContext();
605
462
  const setToolUI = useToolUIs((s) => s.setToolUI);
606
- (0, import_react13.useEffect)(() => {
463
+ _react.useEffect.call(void 0, () => {
607
464
  if (!tool) return;
608
465
  const { toolName, render } = tool;
609
466
  return setToolUI(toolName, render);
@@ -620,13 +477,13 @@ var makeAssistantToolUI = (tool) => {
620
477
  };
621
478
 
622
479
  // src/model-config/useAssistantInstructions.tsx
623
- var import_react14 = require("react");
480
+
624
481
  var useAssistantInstructions = (instruction) => {
625
482
  const { useModelConfig } = useAssistantContext();
626
483
  const registerModelConfigProvider = useModelConfig(
627
484
  (s) => s.registerModelConfigProvider
628
485
  );
629
- (0, import_react14.useEffect)(() => {
486
+ _react.useEffect.call(void 0, () => {
630
487
  const config = {
631
488
  system: instruction
632
489
  };
@@ -635,13 +492,13 @@ var useAssistantInstructions = (instruction) => {
635
492
  };
636
493
 
637
494
  // src/primitive-hooks/actionBar/useActionBarCopy.tsx
638
- var import_react17 = require("react");
495
+
639
496
 
640
497
  // src/utils/combined/useCombinedStore.ts
641
- var import_react16 = require("react");
498
+
642
499
 
643
500
  // src/utils/combined/createCombinedStore.ts
644
- var import_react15 = require("react");
501
+
645
502
  var createCombinedStore = (stores) => {
646
503
  const subscribe = (callback) => {
647
504
  const unsubscribes = stores.map((store) => store.subscribe(callback));
@@ -653,13 +510,13 @@ var createCombinedStore = (stores) => {
653
510
  };
654
511
  return (selector) => {
655
512
  const getSnapshot = () => selector(...stores.map((store) => store.getState()));
656
- return (0, import_react15.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
513
+ return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getSnapshot);
657
514
  };
658
515
  };
659
516
 
660
517
  // src/utils/combined/useCombinedStore.ts
661
518
  var useCombinedStore = (stores, selector) => {
662
- const useCombined = (0, import_react16.useMemo)(() => createCombinedStore(stores), stores);
519
+ const useCombined = _react.useMemo.call(void 0, () => createCombinedStore(stores), stores);
663
520
  return useCombined(selector);
664
521
  };
665
522
 
@@ -682,7 +539,7 @@ var useActionBarCopy = ({
682
539
  return !c.isEditing && m.message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
683
540
  }
684
541
  );
685
- const callback = (0, import_react17.useCallback)(() => {
542
+ const callback = _react.useCallback.call(void 0, () => {
686
543
  const { message } = useMessage.getState();
687
544
  const { setIsCopied } = useMessageUtils.getState();
688
545
  const { isEditing, value: composerValue } = useEditComposer.getState();
@@ -697,14 +554,14 @@ var useActionBarCopy = ({
697
554
  };
698
555
 
699
556
  // src/primitive-hooks/actionBar/useActionBarEdit.tsx
700
- var import_react18 = require("react");
557
+
701
558
  var useActionBarEdit = () => {
702
559
  const { useMessage, useEditComposer } = useMessageContext();
703
560
  const disabled = useCombinedStore(
704
561
  [useMessage, useEditComposer],
705
562
  (m, c) => m.message.role !== "user" || c.isEditing
706
563
  );
707
- const callback = (0, import_react18.useCallback)(() => {
564
+ const callback = _react.useCallback.call(void 0, () => {
708
565
  const { edit } = useEditComposer.getState();
709
566
  edit();
710
567
  }, [useEditComposer]);
@@ -713,7 +570,7 @@ var useActionBarEdit = () => {
713
570
  };
714
571
 
715
572
  // src/primitive-hooks/actionBar/useActionBarReload.tsx
716
- var import_react19 = require("react");
573
+
717
574
  var useActionBarReload = () => {
718
575
  const { useThread, useThreadActions, useComposer, useViewport } = useThreadContext();
719
576
  const { useMessage } = useMessageContext();
@@ -721,7 +578,7 @@ var useActionBarReload = () => {
721
578
  [useThread, useMessage],
722
579
  (t, m) => t.isRunning || t.isDisabled || m.message.role !== "assistant"
723
580
  );
724
- const callback = (0, import_react19.useCallback)(() => {
581
+ const callback = _react.useCallback.call(void 0, () => {
725
582
  const { parentId } = useMessage.getState();
726
583
  useThreadActions.getState().startRun(parentId);
727
584
  useViewport.getState().scrollToBottom();
@@ -739,7 +596,7 @@ var useBranchPickerCount = () => {
739
596
  };
740
597
 
741
598
  // src/primitive-hooks/branchPicker/useBranchPickerNext.tsx
742
- var import_react20 = require("react");
599
+
743
600
  var useBranchPickerNext = () => {
744
601
  const { useThreadActions } = useThreadContext();
745
602
  const { useMessage, useEditComposer } = useMessageContext();
@@ -747,7 +604,7 @@ var useBranchPickerNext = () => {
747
604
  [useMessage, useEditComposer],
748
605
  (m, c) => c.isEditing || m.branches.indexOf(m.message.id) + 1 >= m.branches.length
749
606
  );
750
- const callback = (0, import_react20.useCallback)(() => {
607
+ const callback = _react.useCallback.call(void 0, () => {
751
608
  const { message, branches } = useMessage.getState();
752
609
  useThreadActions.getState().switchToBranch(branches[branches.indexOf(message.id) + 1]);
753
610
  }, [useThreadActions, useMessage]);
@@ -763,7 +620,7 @@ var useBranchPickerNumber = () => {
763
620
  };
764
621
 
765
622
  // src/primitive-hooks/branchPicker/useBranchPickerPrevious.tsx
766
- var import_react21 = require("react");
623
+
767
624
  var useBranchPickerPrevious = () => {
768
625
  const { useThreadActions } = useThreadContext();
769
626
  const { useMessage, useEditComposer } = useMessageContext();
@@ -771,7 +628,7 @@ var useBranchPickerPrevious = () => {
771
628
  [useMessage, useEditComposer],
772
629
  (m, c) => c.isEditing || m.branches.indexOf(m.message.id) <= 0
773
630
  );
774
- const callback = (0, import_react21.useCallback)(() => {
631
+ const callback = _react.useCallback.call(void 0, () => {
775
632
  const { message, branches } = useMessage.getState();
776
633
  useThreadActions.getState().switchToBranch(branches[branches.indexOf(message.id) - 1]);
777
634
  }, [useThreadActions, useMessage]);
@@ -780,11 +637,11 @@ var useBranchPickerPrevious = () => {
780
637
  };
781
638
 
782
639
  // src/primitive-hooks/composer/useComposerCancel.tsx
783
- var import_react22 = require("react");
640
+
784
641
  var useComposerCancel = () => {
785
642
  const { useComposer } = useComposerContext();
786
643
  const disabled = useComposer((c) => !c.canCancel);
787
- const callback = (0, import_react22.useCallback)(() => {
644
+ const callback = _react.useCallback.call(void 0, () => {
788
645
  const { cancel } = useComposer.getState();
789
646
  cancel();
790
647
  }, [useComposer]);
@@ -803,7 +660,7 @@ var useComposerIf = (props) => {
803
660
  };
804
661
 
805
662
  // src/primitive-hooks/composer/useComposerSend.tsx
806
- var import_react23 = require("react");
663
+
807
664
  var useComposerSend = () => {
808
665
  const {
809
666
  useThread,
@@ -815,7 +672,7 @@ var useComposerSend = () => {
815
672
  [useThread, useComposer],
816
673
  (t, c) => t.isDisabled || t.isRunning || !c.isEditing || c.value.length === 0
817
674
  );
818
- const callback = (0, import_react23.useCallback)(() => {
675
+ const callback = _react.useCallback.call(void 0, () => {
819
676
  const composerState = useComposer.getState();
820
677
  if (!composerState.isEditing) return;
821
678
  composerState.send();
@@ -906,11 +763,11 @@ var useThreadEmpty = () => {
906
763
  };
907
764
 
908
765
  // src/primitive-hooks/thread/useThreadScrollToBottom.tsx
909
- var import_react24 = require("react");
766
+
910
767
  var useThreadScrollToBottom = () => {
911
768
  const { useComposer, useViewport } = useThreadContext();
912
769
  const isAtBottom = useViewport((s) => s.isAtBottom);
913
- const handleScrollToBottom = (0, import_react24.useCallback)(() => {
770
+ const handleScrollToBottom = _react.useCallback.call(void 0, () => {
914
771
  useViewport.getState().scrollToBottom();
915
772
  useComposer.getState().focus();
916
773
  }, [useViewport, useComposer]);
@@ -919,7 +776,7 @@ var useThreadScrollToBottom = () => {
919
776
  };
920
777
 
921
778
  // src/primitive-hooks/thread/useThreadSuggestion.tsx
922
- var import_react25 = require("react");
779
+
923
780
  var useThreadSuggestion = ({
924
781
  prompt,
925
782
  autoSend
@@ -927,7 +784,7 @@ var useThreadSuggestion = ({
927
784
  const { useThread, useComposer } = useThreadContext();
928
785
  const append = useAppendMessage();
929
786
  const disabled = useThread((t) => t.isDisabled);
930
- const callback = (0, import_react25.useCallback)(() => {
787
+ const callback = _react.useCallback.call(void 0, () => {
931
788
  const thread = useThread.getState();
932
789
  const composer = useComposer.getState();
933
790
  if (autoSend && !thread.isRunning) {
@@ -943,7 +800,7 @@ var useThreadSuggestion = ({
943
800
 
944
801
  // src/primitives/actionBar/index.ts
945
802
  var actionBar_exports = {};
946
- __export(actionBar_exports, {
803
+ _chunkDCHYNTHIjs.__export.call(void 0, actionBar_exports, {
947
804
  Copy: () => ActionBarPrimitiveCopy,
948
805
  Edit: () => ActionBarPrimitiveEdit,
949
806
  Reload: () => ActionBarPrimitiveReload,
@@ -951,8 +808,8 @@ __export(actionBar_exports, {
951
808
  });
952
809
 
953
810
  // src/primitives/actionBar/ActionBarRoot.tsx
954
- var import_react_primitive = require("@radix-ui/react-primitive");
955
- var import_react26 = require("react");
811
+ var _reactprimitive = require('@radix-ui/react-primitive');
812
+
956
813
 
957
814
  // src/primitives/actionBar/useActionBarFloatStatus.tsx
958
815
  var useActionBarFloatStatus = ({
@@ -977,16 +834,16 @@ var useActionBarFloatStatus = ({
977
834
  };
978
835
 
979
836
  // src/primitives/actionBar/ActionBarRoot.tsx
980
- var import_jsx_runtime4 = require("react/jsx-runtime");
981
- var ActionBarPrimitiveRoot = (0, import_react26.forwardRef)(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {
837
+
838
+ var ActionBarPrimitiveRoot = _react.forwardRef.call(void 0, ({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {
982
839
  const hideAndfloatStatus = useActionBarFloatStatus({
983
840
  hideWhenRunning,
984
841
  autohide,
985
842
  autohideFloat
986
843
  });
987
844
  if (hideAndfloatStatus === "hidden" /* Hidden */) return null;
988
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
989
- import_react_primitive.Primitive.div,
845
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
846
+ _reactprimitive.Primitive.div,
990
847
  {
991
848
  ...hideAndfloatStatus === "floating" /* Floating */ ? { "data-floating": "true" } : null,
992
849
  ...rest,
@@ -997,12 +854,12 @@ var ActionBarPrimitiveRoot = (0, import_react26.forwardRef)(({ hideWhenRunning,
997
854
  ActionBarPrimitiveRoot.displayName = "ActionBarPrimitive.Root";
998
855
 
999
856
  // src/utils/createActionButton.tsx
1000
- var import_react27 = require("react");
1001
- var import_react_primitive2 = require("@radix-ui/react-primitive");
1002
- var import_primitive = require("@radix-ui/primitive");
1003
- var import_jsx_runtime5 = require("react/jsx-runtime");
857
+
858
+
859
+ var _primitive = require('@radix-ui/primitive');
860
+
1004
861
  var createActionButton = (displayName, useActionButton, forwardProps = []) => {
1005
- const ActionButton = (0, import_react27.forwardRef)((props, forwardedRef) => {
862
+ const ActionButton = _react.forwardRef.call(void 0, (props, forwardedRef) => {
1006
863
  const forwardedProps = {};
1007
864
  const primitiveProps = {};
1008
865
  Object.keys(props).forEach((key) => {
@@ -1013,15 +870,15 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
1013
870
  }
1014
871
  });
1015
872
  const callback = useActionButton(forwardedProps);
1016
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1017
- import_react_primitive2.Primitive.button,
873
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
874
+ _reactprimitive.Primitive.button,
1018
875
  {
1019
876
  type: "button",
1020
877
  disabled: !callback,
1021
878
  ...primitiveProps,
1022
879
  ref: forwardedRef,
1023
- onClick: (0, import_primitive.composeEventHandlers)(primitiveProps.onClick, () => {
1024
- callback?.();
880
+ onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
881
+ _optionalChain([callback, 'optionalCall', _24 => _24()]);
1025
882
  })
1026
883
  }
1027
884
  );
@@ -1051,7 +908,7 @@ var ActionBarPrimitiveEdit = createActionButton(
1051
908
 
1052
909
  // src/primitives/assistantModal/index.ts
1053
910
  var assistantModal_exports = {};
1054
- __export(assistantModal_exports, {
911
+ _chunkDCHYNTHIjs.__export.call(void 0, assistantModal_exports, {
1055
912
  Anchor: () => AssistantModalPrimitiveAnchor,
1056
913
  Content: () => AssistantModalPrimitiveContent,
1057
914
  Root: () => AssistantModalPrimitiveRoot,
@@ -1059,17 +916,17 @@ __export(assistantModal_exports, {
1059
916
  });
1060
917
 
1061
918
  // src/primitives/assistantModal/AssistantModalRoot.tsx
1062
- var import_react29 = require("react");
1063
- var PopoverPrimitive2 = __toESM(require("@radix-ui/react-popover"));
1064
- var import_primitive2 = require("@radix-ui/primitive");
919
+
920
+ var _reactpopover = require('@radix-ui/react-popover'); var PopoverPrimitive2 = _interopRequireWildcard(_reactpopover); var PopoverPrimitive = _interopRequireWildcard(_reactpopover); var PopoverPrimitive3 = _interopRequireWildcard(_reactpopover); var PopoverPrimitive4 = _interopRequireWildcard(_reactpopover); var PopoverPrimitive5 = _interopRequireWildcard(_reactpopover);
921
+
1065
922
 
1066
923
  // src/utils/hooks/useOnComposerFocus.tsx
1067
- var import_react_use_callback_ref = require("@radix-ui/react-use-callback-ref");
1068
- var import_react28 = require("react");
924
+ var _reactusecallbackref = require('@radix-ui/react-use-callback-ref');
925
+
1069
926
  var useOnComposerFocus = (callback) => {
1070
- const callbackRef = (0, import_react_use_callback_ref.useCallbackRef)(callback);
927
+ const callbackRef = _reactusecallbackref.useCallbackRef.call(void 0, callback);
1071
928
  const { useComposer } = useThreadContext();
1072
- (0, import_react28.useEffect)(() => {
929
+ _react.useEffect.call(void 0, () => {
1073
930
  return useComposer.getState().onFocus(() => {
1074
931
  callbackRef();
1075
932
  });
@@ -1077,13 +934,13 @@ var useOnComposerFocus = (callback) => {
1077
934
  };
1078
935
 
1079
936
  // src/primitives/assistantModal/scope.tsx
1080
- var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"));
937
+
1081
938
  var usePopoverScope = PopoverPrimitive.createPopoverScope();
1082
939
 
1083
940
  // src/primitives/assistantModal/AssistantModalRoot.tsx
1084
- var import_jsx_runtime6 = require("react/jsx-runtime");
941
+
1085
942
  var useAssistantModalOpenState = (defaultOpen = false) => {
1086
- const state = (0, import_react29.useState)(defaultOpen);
943
+ const state = _react.useState.call(void 0, defaultOpen);
1087
944
  const [, setOpen] = state;
1088
945
  useOnComposerFocus(() => {
1089
946
  setOpen(true);
@@ -1099,12 +956,12 @@ var AssistantModalPrimitiveRoot = ({
1099
956
  }) => {
1100
957
  const scope = usePopoverScope(__scopeAssistantModal);
1101
958
  const [modalOpen, setOpen] = useAssistantModalOpenState(defaultOpen);
1102
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
959
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1103
960
  PopoverPrimitive2.Root,
1104
961
  {
1105
962
  ...scope,
1106
963
  open: open === void 0 ? modalOpen : open,
1107
- onOpenChange: (0, import_primitive2.composeEventHandlers)(onOpenChange, setOpen),
964
+ onOpenChange: _primitive.composeEventHandlers.call(void 0, onOpenChange, setOpen),
1108
965
  ...rest
1109
966
  }
1110
967
  );
@@ -1112,26 +969,26 @@ var AssistantModalPrimitiveRoot = ({
1112
969
  AssistantModalPrimitiveRoot.displayName = "AssistantModalPrimitive.Root";
1113
970
 
1114
971
  // src/primitives/assistantModal/AssistantModalTrigger.tsx
1115
- var import_react30 = require("react");
1116
- var PopoverPrimitive3 = __toESM(require("@radix-ui/react-popover"));
1117
- var import_jsx_runtime7 = require("react/jsx-runtime");
1118
- var AssistantModalPrimitiveTrigger = (0, import_react30.forwardRef)(
972
+
973
+
974
+
975
+ var AssistantModalPrimitiveTrigger = _react.forwardRef.call(void 0,
1119
976
  ({
1120
977
  __scopeAssistantModal,
1121
978
  ...rest
1122
979
  }, ref) => {
1123
980
  const scope = usePopoverScope(__scopeAssistantModal);
1124
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PopoverPrimitive3.Trigger, { ...scope, ...rest, ref });
981
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverPrimitive3.Trigger, { ...scope, ...rest, ref });
1125
982
  }
1126
983
  );
1127
984
  AssistantModalPrimitiveTrigger.displayName = "AssistantModalPrimitive.Trigger";
1128
985
 
1129
986
  // src/primitives/assistantModal/AssistantModalContent.tsx
1130
- var import_react31 = require("react");
1131
- var PopoverPrimitive4 = __toESM(require("@radix-ui/react-popover"));
1132
- var import_primitive3 = require("@radix-ui/primitive");
1133
- var import_jsx_runtime8 = require("react/jsx-runtime");
1134
- var AssistantModalPrimitiveContent = (0, import_react31.forwardRef)(
987
+
988
+
989
+
990
+
991
+ var AssistantModalPrimitiveContent = _react.forwardRef.call(void 0,
1135
992
  ({
1136
993
  __scopeAssistantModal,
1137
994
  side,
@@ -1141,15 +998,15 @@ var AssistantModalPrimitiveContent = (0, import_react31.forwardRef)(
1141
998
  ...props
1142
999
  }, forwardedRef) => {
1143
1000
  const scope = usePopoverScope(__scopeAssistantModal);
1144
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PopoverPrimitive4.Portal, { ...scope, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1001
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverPrimitive4.Portal, { ...scope, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1145
1002
  PopoverPrimitive4.Content,
1146
1003
  {
1147
1004
  ...scope,
1148
1005
  ...props,
1149
1006
  ref: forwardedRef,
1150
- side: side ?? "top",
1151
- align: align ?? "end",
1152
- onInteractOutside: (0, import_primitive3.composeEventHandlers)(
1007
+ side: _nullishCoalesce(side, () => ( "top")),
1008
+ align: _nullishCoalesce(align, () => ( "end")),
1009
+ onInteractOutside: _primitive.composeEventHandlers.call(void 0,
1153
1010
  onInteractOutside,
1154
1011
  dissmissOnInteractOutside ? void 0 : (e) => e.preventDefault()
1155
1012
  )
@@ -1160,23 +1017,23 @@ var AssistantModalPrimitiveContent = (0, import_react31.forwardRef)(
1160
1017
  AssistantModalPrimitiveContent.displayName = "AssistantModalPrimitive.Content";
1161
1018
 
1162
1019
  // src/primitives/assistantModal/AssistantModalAnchor.tsx
1163
- var import_react32 = require("react");
1164
- var PopoverPrimitive5 = __toESM(require("@radix-ui/react-popover"));
1165
- var import_jsx_runtime9 = require("react/jsx-runtime");
1166
- var AssistantModalPrimitiveAnchor = (0, import_react32.forwardRef)(
1020
+
1021
+
1022
+
1023
+ var AssistantModalPrimitiveAnchor = _react.forwardRef.call(void 0,
1167
1024
  ({
1168
1025
  __scopeAssistantModal,
1169
1026
  ...rest
1170
1027
  }, ref) => {
1171
1028
  const scope = usePopoverScope(__scopeAssistantModal);
1172
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverPrimitive5.Anchor, { ...scope, ...rest, ref });
1029
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverPrimitive5.Anchor, { ...scope, ...rest, ref });
1173
1030
  }
1174
1031
  );
1175
1032
  AssistantModalPrimitiveAnchor.displayName = "AssistantModalPrimitive.Anchor";
1176
1033
 
1177
1034
  // src/primitives/branchPicker/index.ts
1178
1035
  var branchPicker_exports = {};
1179
- __export(branchPicker_exports, {
1036
+ _chunkDCHYNTHIjs.__export.call(void 0, branchPicker_exports, {
1180
1037
  Count: () => BranchPickerPrimitiveCount,
1181
1038
  Next: () => BranchPickerPrimitiveNext,
1182
1039
  Number: () => BranchPickerPrimitiveNumber,
@@ -1197,28 +1054,28 @@ var BranchPickerPrevious = createActionButton(
1197
1054
  );
1198
1055
 
1199
1056
  // src/primitives/branchPicker/BranchPickerCount.tsx
1200
- var import_jsx_runtime10 = require("react/jsx-runtime");
1057
+
1201
1058
  var BranchPickerPrimitiveCount = () => {
1202
1059
  const branchCount = useBranchPickerCount();
1203
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: branchCount });
1060
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: branchCount });
1204
1061
  };
1205
1062
  BranchPickerPrimitiveCount.displayName = "BranchPickerPrimitive.Count";
1206
1063
 
1207
1064
  // src/primitives/branchPicker/BranchPickerNumber.tsx
1208
- var import_jsx_runtime11 = require("react/jsx-runtime");
1065
+
1209
1066
  var BranchPickerPrimitiveNumber = () => {
1210
1067
  const branchNumber = useBranchPickerNumber();
1211
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: branchNumber });
1068
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: branchNumber });
1212
1069
  };
1213
1070
  BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
1214
1071
 
1215
1072
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1216
- var import_react_primitive5 = require("@radix-ui/react-primitive");
1217
- var import_react40 = require("react");
1073
+
1074
+
1218
1075
 
1219
1076
  // src/primitives/message/index.ts
1220
1077
  var message_exports = {};
1221
- __export(message_exports, {
1078
+ _chunkDCHYNTHIjs.__export.call(void 0, message_exports, {
1222
1079
  Content: () => MessagePrimitiveContent,
1223
1080
  If: () => MessagePrimitiveIf,
1224
1081
  InProgress: () => MessagePrimitiveInProgress,
@@ -1226,13 +1083,16 @@ __export(message_exports, {
1226
1083
  });
1227
1084
 
1228
1085
  // src/primitives/message/MessageRoot.tsx
1229
- var import_react_primitive3 = require("@radix-ui/react-primitive");
1230
- var import_react33 = require("react");
1231
- var import_react_compose_refs = require("@radix-ui/react-compose-refs");
1232
- var import_jsx_runtime12 = require("react/jsx-runtime");
1086
+
1087
+
1088
+
1089
+
1090
+
1091
+ var _reactcomposerefs = require('@radix-ui/react-compose-refs');
1092
+
1233
1093
  var useIsHoveringRef = () => {
1234
1094
  const { useMessageUtils } = useMessageContext();
1235
- const callbackRef = (0, import_react33.useCallback)(
1095
+ const callbackRef = _react.useCallback.call(void 0,
1236
1096
  (el) => {
1237
1097
  const setIsHovering = useMessageUtils.getState().setIsHovering;
1238
1098
  const handleMouseEnter = () => {
@@ -1253,10 +1113,10 @@ var useIsHoveringRef = () => {
1253
1113
  );
1254
1114
  return useManagedRef(callbackRef);
1255
1115
  };
1256
- var MessagePrimitiveRoot = (0, import_react33.forwardRef)(({ onMouseEnter, onMouseLeave, ...rest }, forwardRef29) => {
1116
+ var MessagePrimitiveRoot = _react.forwardRef.call(void 0, ({ onMouseEnter, onMouseLeave, ...rest }, forwardRef29) => {
1257
1117
  const isHoveringRef = useIsHoveringRef();
1258
- const ref = (0, import_react_compose_refs.useComposedRefs)(forwardRef29, isHoveringRef);
1259
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_primitive3.Primitive.div, { ...rest, ref });
1118
+ const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardRef29, isHoveringRef);
1119
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...rest, ref });
1260
1120
  });
1261
1121
  MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
1262
1122
 
@@ -1271,12 +1131,12 @@ var MessagePrimitiveIf = ({
1271
1131
  MessagePrimitiveIf.displayName = "MessagePrimitive.If";
1272
1132
 
1273
1133
  // src/primitives/message/MessageContent.tsx
1274
- var import_react39 = require("react");
1134
+
1275
1135
 
1276
1136
  // src/context/providers/ContentPartProvider.tsx
1277
- var import_react34 = require("react");
1278
- var import_zustand10 = require("zustand");
1279
- var import_jsx_runtime13 = require("react/jsx-runtime");
1137
+
1138
+
1139
+
1280
1140
  var COMPLETE_STATUS = {
1281
1141
  type: "complete"
1282
1142
  };
@@ -1306,20 +1166,20 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
1306
1166
  }
1307
1167
  }
1308
1168
  const status = toContentPartStatus(message, partIndex, part);
1309
- const currentState = useContentPart?.getState();
1169
+ const currentState = _optionalChain([useContentPart, 'optionalAccess', _25 => _25.getState, 'call', _26 => _26()]);
1310
1170
  if (currentState && currentState.part === part && currentState.status === status)
1311
1171
  return null;
1312
1172
  return Object.freeze({ part, status });
1313
1173
  };
1314
1174
  var useContentPartContext2 = (partIndex) => {
1315
1175
  const { useMessage } = useMessageContext();
1316
- const [context] = (0, import_react34.useState)(() => {
1317
- const useContentPart = (0, import_zustand10.create)(
1176
+ const [context] = _react.useState.call(void 0, () => {
1177
+ const useContentPart = _zustand.create.call(void 0,
1318
1178
  () => getContentPartState(useMessage.getState(), void 0, partIndex)
1319
1179
  );
1320
1180
  return { useContentPart };
1321
1181
  });
1322
- (0, import_react34.useEffect)(() => {
1182
+ _react.useEffect.call(void 0, () => {
1323
1183
  const syncContentPart = (message) => {
1324
1184
  const newState = getContentPartState(
1325
1185
  message,
@@ -1339,43 +1199,50 @@ var ContentPartProvider = ({
1339
1199
  children
1340
1200
  }) => {
1341
1201
  const context = useContentPartContext2(partIndex);
1342
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ContentPartContext.Provider, { value: context, children });
1202
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartContext.Provider, { value: context, children });
1343
1203
  };
1344
1204
 
1345
1205
  // src/primitives/contentPart/ContentPartText.tsx
1346
- var import_react37 = require("react");
1206
+
1207
+
1208
+
1347
1209
 
1348
1210
  // src/utils/smooth/useSmooth.tsx
1349
- var import_react36 = require("react");
1211
+
1350
1212
 
1351
1213
  // src/utils/smooth/SmoothContext.tsx
1352
- var import_react35 = require("react");
1353
- var import_zustand11 = require("zustand");
1354
- var import_jsx_runtime14 = require("react/jsx-runtime");
1355
- var SmoothContext = (0, import_react35.createContext)(null);
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+ var SmoothContext = _react.createContext.call(void 0, null);
1356
1223
  var makeSmoothContext = (initialState) => {
1357
- const useSmoothStatus2 = (0, import_zustand11.create)(() => initialState);
1224
+ const useSmoothStatus2 = _zustand.create.call(void 0, () => initialState);
1358
1225
  return { useSmoothStatus: useSmoothStatus2 };
1359
1226
  };
1360
1227
  var SmoothContextProvider = ({ children }) => {
1361
1228
  const outer = useSmoothContext({ optional: true });
1362
1229
  const { useContentPart } = useContentPartContext();
1363
- const [context] = (0, import_react35.useState)(
1230
+ const [context] = _react.useState.call(void 0,
1364
1231
  () => makeSmoothContext(useContentPart.getState().status)
1365
1232
  );
1366
1233
  if (outer) return children;
1367
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SmoothContext.Provider, { value: context, children });
1234
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmoothContext.Provider, { value: context, children });
1368
1235
  };
1369
1236
  var withSmoothContextProvider = (Component) => {
1370
- const Wrapped = (0, import_react35.forwardRef)((props, ref) => {
1371
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SmoothContextProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Component, { ...props, ref }) });
1237
+ const Wrapped = _react.forwardRef.call(void 0, (props, ref) => {
1238
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmoothContextProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { ...props, ref }) });
1372
1239
  });
1373
1240
  Wrapped.displayName = Component.displayName;
1374
1241
  return Wrapped;
1375
1242
  };
1376
1243
  function useSmoothContext(options) {
1377
- const context = (0, import_react35.useContext)(SmoothContext);
1378
- if (!options?.optional && !context)
1244
+ const context = _react.useContext.call(void 0, SmoothContext);
1245
+ if (!_optionalChain([options, 'optionalAccess', _27 => _27.optional]) && !context)
1379
1246
  throw new Error(
1380
1247
  "This component must be used within a SmoothContextProvider."
1381
1248
  );
@@ -1387,15 +1254,15 @@ var useSmoothStatus = () => {
1387
1254
  };
1388
1255
 
1389
1256
  // src/utils/smooth/useSmooth.tsx
1390
- var import_react_use_callback_ref2 = require("@radix-ui/react-use-callback-ref");
1391
- var TextStreamAnimator = class {
1392
- constructor(currentText, setText) {
1257
+
1258
+ var TextStreamAnimator = (_class2 = class {
1259
+ constructor(currentText, setText) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);
1393
1260
  this.currentText = currentText;
1394
1261
  this.setText = setText;
1395
1262
  }
1396
- animationFrameId = null;
1397
- lastUpdateTime = Date.now();
1398
- targetText = "";
1263
+ __init2() {this.animationFrameId = null}
1264
+ __init3() {this.lastUpdateTime = Date.now()}
1265
+ __init4() {this.targetText = ""}
1399
1266
  start() {
1400
1267
  if (this.animationFrameId !== null) return;
1401
1268
  this.lastUpdateTime = Date.now();
@@ -1407,7 +1274,7 @@ var TextStreamAnimator = class {
1407
1274
  this.animationFrameId = null;
1408
1275
  }
1409
1276
  }
1410
- animate = () => {
1277
+ __init5() {this.animate = () => {
1411
1278
  const currentTime = Date.now();
1412
1279
  const deltaTime = currentTime - this.lastUpdateTime;
1413
1280
  let timeToConsume = deltaTime;
@@ -1430,28 +1297,28 @@ var TextStreamAnimator = class {
1430
1297
  );
1431
1298
  this.lastUpdateTime = currentTime - timeToConsume;
1432
1299
  this.setText(this.currentText);
1433
- };
1434
- };
1300
+ }}
1301
+ }, _class2);
1435
1302
  var SMOOTH_STATUS = Object.freeze({
1436
1303
  type: "running"
1437
1304
  });
1438
1305
  var useSmooth = (state, smooth = false) => {
1439
- const { useSmoothStatus: useSmoothStatus2 } = useSmoothContext({ optional: true }) ?? {};
1306
+ const { useSmoothStatus: useSmoothStatus2 } = _nullishCoalesce(useSmoothContext({ optional: true }), () => ( {}));
1440
1307
  const {
1441
1308
  part: { text }
1442
1309
  } = state;
1443
1310
  const { useMessage } = useMessageContext();
1444
1311
  const id = useMessage((m) => m.message.id);
1445
- const idRef = (0, import_react36.useRef)(id);
1446
- const [displayedText, setDisplayedText] = (0, import_react36.useState)(text);
1447
- const setText = (0, import_react_use_callback_ref2.useCallbackRef)((text2) => {
1312
+ const idRef = _react.useRef.call(void 0, id);
1313
+ const [displayedText, setDisplayedText] = _react.useState.call(void 0, text);
1314
+ const setText = _reactusecallbackref.useCallbackRef.call(void 0, (text2) => {
1448
1315
  setDisplayedText(text2);
1449
- useSmoothStatus2?.setState(text2 !== state.part.text ? SMOOTH_STATUS : state.status);
1316
+ _optionalChain([useSmoothStatus2, 'optionalAccess', _28 => _28.setState, 'call', _29 => _29(text2 !== state.part.text ? SMOOTH_STATUS : state.status)]);
1450
1317
  });
1451
- const [animatorRef] = (0, import_react36.useState)(
1318
+ const [animatorRef] = _react.useState.call(void 0,
1452
1319
  new TextStreamAnimator(text, setText)
1453
1320
  );
1454
- (0, import_react36.useEffect)(() => {
1321
+ _react.useEffect.call(void 0, () => {
1455
1322
  if (!smooth) {
1456
1323
  animatorRef.stop();
1457
1324
  return;
@@ -1467,12 +1334,12 @@ var useSmooth = (state, smooth = false) => {
1467
1334
  animatorRef.targetText = text;
1468
1335
  animatorRef.start();
1469
1336
  }, [setText, animatorRef, id, smooth, text]);
1470
- (0, import_react36.useEffect)(() => {
1337
+ _react.useEffect.call(void 0, () => {
1471
1338
  return () => {
1472
1339
  animatorRef.stop();
1473
1340
  };
1474
1341
  }, [animatorRef]);
1475
- return (0, import_react36.useMemo)(
1342
+ return _react.useMemo.call(void 0,
1476
1343
  () => smooth ? {
1477
1344
  part: { type: "text", text: displayedText },
1478
1345
  status: text === displayedText ? state.status : SMOOTH_STATUS
@@ -1482,25 +1349,25 @@ var useSmooth = (state, smooth = false) => {
1482
1349
  };
1483
1350
 
1484
1351
  // src/primitives/contentPart/ContentPartText.tsx
1485
- var import_jsx_runtime15 = require("react/jsx-runtime");
1486
- var ContentPartPrimitiveText = (0, import_react37.forwardRef)(({ smooth = true, component: Component = "span", ...rest }, forwardedRef) => {
1352
+
1353
+ var ContentPartPrimitiveText = _react.forwardRef.call(void 0, ({ smooth = true, component: Component = "span", ...rest }, forwardedRef) => {
1487
1354
  const {
1488
1355
  part: { text },
1489
1356
  status
1490
1357
  } = useSmooth(useContentPartText(), smooth);
1491
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Component, { "data-status": status.type, ...rest, ref: forwardedRef, children: text });
1358
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { "data-status": status.type, ...rest, ref: forwardedRef, children: text });
1492
1359
  });
1493
1360
  ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
1494
1361
 
1495
1362
  // src/primitives/contentPart/ContentPartImage.tsx
1496
- var import_react_primitive4 = require("@radix-ui/react-primitive");
1497
- var import_react38 = require("react");
1498
- var import_jsx_runtime16 = require("react/jsx-runtime");
1499
- var ContentPartPrimitiveImage = (0, import_react38.forwardRef)((props, forwardedRef) => {
1363
+
1364
+
1365
+
1366
+ var ContentPartPrimitiveImage = _react.forwardRef.call(void 0, (props, forwardedRef) => {
1500
1367
  const {
1501
1368
  part: { image }
1502
1369
  } = useContentPartImage();
1503
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_primitive4.Primitive.img, { src: image, ...props, ref: forwardedRef });
1370
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.img, { src: image, ...props, ref: forwardedRef });
1504
1371
  });
1505
1372
  ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
1506
1373
 
@@ -1509,7 +1376,7 @@ var ContentPartPrimitiveDisplay = () => {
1509
1376
  const {
1510
1377
  part: { display }
1511
1378
  } = useContentPartDisplay();
1512
- return display ?? null;
1379
+ return _nullishCoalesce(display, () => ( null));
1513
1380
  };
1514
1381
  ContentPartPrimitiveDisplay.displayName = "ContentPartPrimitive.Display";
1515
1382
 
@@ -1522,20 +1389,20 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
1522
1389
  ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
1523
1390
 
1524
1391
  // src/primitives/message/MessageContent.tsx
1525
- var import_jsx_runtime17 = require("react/jsx-runtime");
1392
+
1526
1393
  var defaultComponents = {
1527
- Text: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("p", { style: { whiteSpace: "pre-line" }, children: [
1528
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ContentPartPrimitiveText, {}),
1529
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
1394
+ Text: () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { style: { whiteSpace: "pre-line" }, children: [
1395
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveText, {}),
1396
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
1530
1397
  ] }),
1531
- Image: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ContentPartPrimitiveImage, {}),
1532
- UI: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ContentPartPrimitiveDisplay, {}),
1398
+ Image: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveImage, {}),
1399
+ UI: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveDisplay, {}),
1533
1400
  tools: {
1534
1401
  Fallback: (props) => {
1535
1402
  const { useToolUIs } = useAssistantContext();
1536
1403
  const Render = useToolUIs((s) => s.getToolUI(props.part.toolName));
1537
1404
  if (!Render) return null;
1538
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Render, { ...props });
1405
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Render, { ...props });
1539
1406
  }
1540
1407
  }
1541
1408
  };
@@ -1558,16 +1425,16 @@ var MessageContentPartComponent = ({
1558
1425
  case "text":
1559
1426
  if (status.type === "requires-action")
1560
1427
  throw new Error("Encountered unexpected requires-action status");
1561
- if (part === EMPTY_CONTENT) return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Empty, { part, status });
1562
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text2, { part, status });
1428
+ if (part === EMPTY_CONTENT) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Empty, { part, status });
1429
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text2, { part, status });
1563
1430
  case "image":
1564
1431
  if (status.type === "requires-action")
1565
1432
  throw new Error("Encountered unexpected requires-action status");
1566
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Image2, { part, status });
1433
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Image2, { part, status });
1567
1434
  case "ui":
1568
1435
  if (status.type === "requires-action")
1569
1436
  throw new Error("Encountered unexpected requires-action status");
1570
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(UI, { part, status });
1437
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UI, { part, status });
1571
1438
  case "tool-call": {
1572
1439
  const Tool = by_name[part.toolName] || Fallback2;
1573
1440
  const addResult = (result) => addToolResult({
@@ -1575,7 +1442,7 @@ var MessageContentPartComponent = ({
1575
1442
  toolCallId: part.toolCallId,
1576
1443
  result
1577
1444
  });
1578
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Tool, { part, status, addResult });
1445
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tool, { part, status, addResult });
1579
1446
  }
1580
1447
  default:
1581
1448
  const unhandledType = type;
@@ -1586,11 +1453,11 @@ var MessageContentPartImpl = ({
1586
1453
  partIndex,
1587
1454
  components
1588
1455
  }) => {
1589
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ContentPartProvider, { partIndex, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MessageContentPartComponent, { components }) });
1456
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartProvider, { partIndex, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContentPartComponent, { components }) });
1590
1457
  };
1591
- var MessageContentPart = (0, import_react39.memo)(
1458
+ var MessageContentPart = _react.memo.call(void 0,
1592
1459
  MessageContentPartImpl,
1593
- (prev, next) => prev.partIndex === next.partIndex && prev.components?.Text === next.components?.Text && prev.components?.Image === next.components?.Image && prev.components?.UI === next.components?.UI && prev.components?.tools === next.components?.tools
1460
+ (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _30 => _30.components, 'optionalAccess', _31 => _31.Text]) === _optionalChain([next, 'access', _32 => _32.components, 'optionalAccess', _33 => _33.Text]) && _optionalChain([prev, 'access', _34 => _34.components, 'optionalAccess', _35 => _35.Image]) === _optionalChain([next, 'access', _36 => _36.components, 'optionalAccess', _37 => _37.Image]) && _optionalChain([prev, 'access', _38 => _38.components, 'optionalAccess', _39 => _39.UI]) === _optionalChain([next, 'access', _40 => _40.components, 'optionalAccess', _41 => _41.UI]) && _optionalChain([prev, 'access', _42 => _42.components, 'optionalAccess', _43 => _43.tools]) === _optionalChain([next, 'access', _44 => _44.components, 'optionalAccess', _45 => _45.tools])
1594
1461
  );
1595
1462
  var MessagePrimitiveContent = ({
1596
1463
  components
@@ -1599,7 +1466,7 @@ var MessagePrimitiveContent = ({
1599
1466
  const contentLength = useMessage((s) => s.message.content.length) || 1;
1600
1467
  return new Array(contentLength).fill(null).map((_, idx) => {
1601
1468
  const partIndex = idx;
1602
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1469
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1603
1470
  MessageContentPart,
1604
1471
  {
1605
1472
  partIndex,
@@ -1618,15 +1485,15 @@ var MessagePrimitiveInProgress = () => {
1618
1485
  MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
1619
1486
 
1620
1487
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1621
- var import_jsx_runtime18 = require("react/jsx-runtime");
1622
- var BranchPickerPrimitiveRoot = (0, import_react40.forwardRef)(({ hideWhenSingleBranch, ...rest }, ref) => {
1623
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_primitive5.Primitive.div, { ...rest, ref }) });
1488
+
1489
+ var BranchPickerPrimitiveRoot = _react.forwardRef.call(void 0, ({ hideWhenSingleBranch, ...rest }, ref) => {
1490
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...rest, ref }) });
1624
1491
  });
1625
1492
  BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
1626
1493
 
1627
1494
  // src/primitives/composer/index.ts
1628
1495
  var composer_exports = {};
1629
- __export(composer_exports, {
1496
+ _chunkDCHYNTHIjs.__export.call(void 0, composer_exports, {
1630
1497
  Cancel: () => ComposerPrimitiveCancel,
1631
1498
  If: () => ComposerPrimitiveIf,
1632
1499
  Input: () => ComposerPrimitiveInput,
@@ -1635,37 +1502,44 @@ __export(composer_exports, {
1635
1502
  });
1636
1503
 
1637
1504
  // src/primitives/composer/ComposerRoot.tsx
1638
- var import_primitive4 = require("@radix-ui/primitive");
1639
- var import_react_primitive6 = require("@radix-ui/react-primitive");
1640
- var import_react41 = require("react");
1641
- var import_jsx_runtime19 = require("react/jsx-runtime");
1642
- var ComposerPrimitiveRoot = (0, import_react41.forwardRef)(({ onSubmit, ...rest }, forwardedRef) => {
1505
+
1506
+
1507
+
1508
+
1509
+
1510
+
1511
+ var ComposerPrimitiveRoot = _react.forwardRef.call(void 0, ({ onSubmit, ...rest }, forwardedRef) => {
1643
1512
  const send = useComposerSend();
1644
1513
  const handleSubmit = (e) => {
1645
1514
  e.preventDefault();
1646
1515
  if (!send) return;
1647
1516
  send();
1648
1517
  };
1649
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1650
- import_react_primitive6.Primitive.form,
1518
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1519
+ _reactprimitive.Primitive.form,
1651
1520
  {
1652
1521
  ...rest,
1653
1522
  ref: forwardedRef,
1654
- onSubmit: (0, import_primitive4.composeEventHandlers)(onSubmit, handleSubmit)
1523
+ onSubmit: _primitive.composeEventHandlers.call(void 0, onSubmit, handleSubmit)
1655
1524
  }
1656
1525
  );
1657
1526
  });
1658
1527
  ComposerPrimitiveRoot.displayName = "ComposerPrimitive.Root";
1659
1528
 
1660
1529
  // src/primitives/composer/ComposerInput.tsx
1661
- var import_primitive5 = require("@radix-ui/primitive");
1662
- var import_react_compose_refs2 = require("@radix-ui/react-compose-refs");
1663
- var import_react_slot = require("@radix-ui/react-slot");
1664
- var import_react42 = require("react");
1665
- var import_react_textarea_autosize = __toESM(require("react-textarea-autosize"));
1666
- var import_react_use_escape_keydown = require("@radix-ui/react-use-escape-keydown");
1667
- var import_jsx_runtime20 = require("react/jsx-runtime");
1668
- var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
1530
+
1531
+
1532
+ var _reactslot = require('@radix-ui/react-slot');
1533
+
1534
+
1535
+
1536
+
1537
+
1538
+
1539
+ var _reacttextareaautosize = require('react-textarea-autosize'); var _reacttextareaautosize2 = _interopRequireDefault(_reacttextareaautosize);
1540
+ var _reactuseescapekeydown = require('@radix-ui/react-use-escape-keydown');
1541
+
1542
+ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
1669
1543
  ({
1670
1544
  autoFocus = false,
1671
1545
  asChild,
@@ -1680,11 +1554,11 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
1680
1554
  if (!c.isEditing) return "";
1681
1555
  return c.value;
1682
1556
  });
1683
- const Component = asChild ? import_react_slot.Slot : import_react_textarea_autosize.default;
1684
- const isDisabled = useThread((t) => t.isDisabled) ?? disabledProp ?? false;
1685
- const textareaRef = (0, import_react42.useRef)(null);
1686
- const ref = (0, import_react_compose_refs2.useComposedRefs)(forwardedRef, textareaRef);
1687
- (0, import_react_use_escape_keydown.useEscapeKeydown)((e) => {
1557
+ const Component = asChild ? _reactslot.Slot : _reacttextareaautosize2.default;
1558
+ const isDisabled = _nullishCoalesce(_nullishCoalesce(useThread((t) => t.isDisabled), () => ( disabledProp)), () => ( false));
1559
+ const textareaRef = _react.useRef.call(void 0, null);
1560
+ const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardedRef, textareaRef);
1561
+ _reactuseescapekeydown.useEscapeKeydown.call(void 0, (e) => {
1688
1562
  const composer = useComposer.getState();
1689
1563
  if (composer.canCancel) {
1690
1564
  composer.cancel();
@@ -1697,12 +1571,12 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
1697
1571
  const isRunning = useThread.getState().isRunning;
1698
1572
  if (!isRunning) {
1699
1573
  e.preventDefault();
1700
- textareaRef.current?.closest("form")?.requestSubmit();
1574
+ _optionalChain([textareaRef, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.closest, 'call', _48 => _48("form"), 'optionalAccess', _49 => _49.requestSubmit, 'call', _50 => _50()]);
1701
1575
  }
1702
1576
  }
1703
1577
  };
1704
1578
  const autoFocusEnabled = autoFocus && !isDisabled;
1705
- const focus = (0, import_react42.useCallback)(() => {
1579
+ const focus = _react.useCallback.call(void 0, () => {
1706
1580
  const textarea = textareaRef.current;
1707
1581
  if (!textarea || !autoFocusEnabled) return;
1708
1582
  textarea.focus({ preventScroll: true });
@@ -1711,13 +1585,13 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
1711
1585
  textareaRef.current.value.length
1712
1586
  );
1713
1587
  }, [autoFocusEnabled]);
1714
- (0, import_react42.useEffect)(() => focus(), [focus]);
1588
+ _react.useEffect.call(void 0, () => focus(), [focus]);
1715
1589
  useOnComposerFocus(() => {
1716
1590
  if (type === "new") {
1717
1591
  focus();
1718
1592
  }
1719
1593
  });
1720
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1594
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1721
1595
  Component,
1722
1596
  {
1723
1597
  name: "input",
@@ -1725,12 +1599,12 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
1725
1599
  ...rest,
1726
1600
  ref,
1727
1601
  disabled: isDisabled,
1728
- onChange: (0, import_primitive5.composeEventHandlers)(onChange, (e) => {
1602
+ onChange: _primitive.composeEventHandlers.call(void 0, onChange, (e) => {
1729
1603
  const composerState = useComposer.getState();
1730
1604
  if (!composerState.isEditing) return;
1731
1605
  return composerState.setValue(e.target.value);
1732
1606
  }),
1733
- onKeyDown: (0, import_primitive5.composeEventHandlers)(onKeyDown, handleKeyPress)
1607
+ onKeyDown: _primitive.composeEventHandlers.call(void 0, onKeyDown, handleKeyPress)
1734
1608
  }
1735
1609
  );
1736
1610
  }
@@ -1738,14 +1612,14 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
1738
1612
  ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
1739
1613
 
1740
1614
  // src/primitives/composer/ComposerSend.tsx
1741
- var import_react43 = require("react");
1742
- var import_react_primitive7 = require("@radix-ui/react-primitive");
1743
- var import_jsx_runtime21 = require("react/jsx-runtime");
1744
- var ComposerPrimitiveSend = (0, import_react43.forwardRef)(({ disabled, ...rest }, ref) => {
1615
+
1616
+
1617
+
1618
+ var ComposerPrimitiveSend = _react.forwardRef.call(void 0, ({ disabled, ...rest }, ref) => {
1745
1619
  const { useComposer } = useComposerContext();
1746
1620
  const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
1747
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1748
- import_react_primitive7.Primitive.button,
1621
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1622
+ _reactprimitive.Primitive.button,
1749
1623
  {
1750
1624
  type: "submit",
1751
1625
  ...rest,
@@ -1774,7 +1648,7 @@ ComposerPrimitiveIf.displayName = "ComposerPrimitive.If";
1774
1648
 
1775
1649
  // src/primitives/contentPart/index.ts
1776
1650
  var contentPart_exports = {};
1777
- __export(contentPart_exports, {
1651
+ _chunkDCHYNTHIjs.__export.call(void 0, contentPart_exports, {
1778
1652
  Display: () => ContentPartPrimitiveDisplay,
1779
1653
  Image: () => ContentPartPrimitiveImage,
1780
1654
  InProgress: () => ContentPartPrimitiveInProgress,
@@ -1783,7 +1657,7 @@ __export(contentPart_exports, {
1783
1657
 
1784
1658
  // src/primitives/thread/index.ts
1785
1659
  var thread_exports = {};
1786
- __export(thread_exports, {
1660
+ _chunkDCHYNTHIjs.__export.call(void 0, thread_exports, {
1787
1661
  Empty: () => ThreadPrimitiveEmpty,
1788
1662
  If: () => ThreadPrimitiveIf,
1789
1663
  Messages: () => ThreadPrimitiveMessages,
@@ -1794,11 +1668,11 @@ __export(thread_exports, {
1794
1668
  });
1795
1669
 
1796
1670
  // src/primitives/thread/ThreadRoot.tsx
1797
- var import_react_primitive8 = require("@radix-ui/react-primitive");
1798
- var import_react44 = require("react");
1799
- var import_jsx_runtime22 = require("react/jsx-runtime");
1800
- var ThreadPrimitiveRoot = (0, import_react44.forwardRef)((props, ref) => {
1801
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_react_primitive8.Primitive.div, { ...props, ref });
1671
+
1672
+
1673
+
1674
+ var ThreadPrimitiveRoot = _react.forwardRef.call(void 0, (props, ref) => {
1675
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...props, ref });
1802
1676
  });
1803
1677
  ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
1804
1678
 
@@ -1822,20 +1696,20 @@ var ThreadPrimitiveIf = ({
1822
1696
  ThreadPrimitiveIf.displayName = "ThreadPrimitive.If";
1823
1697
 
1824
1698
  // src/primitives/thread/ThreadViewport.tsx
1825
- var import_react_compose_refs4 = require("@radix-ui/react-compose-refs");
1826
- var import_react_primitive9 = require("@radix-ui/react-primitive");
1827
- var import_react48 = require("react");
1699
+
1700
+
1701
+
1828
1702
 
1829
1703
  // src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
1830
- var import_react_compose_refs3 = require("@radix-ui/react-compose-refs");
1831
- var import_react47 = require("react");
1704
+
1705
+
1832
1706
 
1833
1707
  // src/utils/hooks/useOnResizeContent.tsx
1834
- var import_react_use_callback_ref3 = require("@radix-ui/react-use-callback-ref");
1835
- var import_react45 = require("react");
1708
+
1709
+
1836
1710
  var useOnResizeContent = (callback) => {
1837
- const callbackRef = (0, import_react_use_callback_ref3.useCallbackRef)(callback);
1838
- const refCallback = (0, import_react45.useCallback)(
1711
+ const callbackRef = _reactusecallbackref.useCallbackRef.call(void 0, callback);
1712
+ const refCallback = _react.useCallback.call(void 0,
1839
1713
  (el) => {
1840
1714
  const resizeObserver = new ResizeObserver(() => {
1841
1715
  callbackRef();
@@ -1871,12 +1745,12 @@ var useOnResizeContent = (callback) => {
1871
1745
  };
1872
1746
 
1873
1747
  // src/utils/hooks/useOnScrollToBottom.tsx
1874
- var import_react_use_callback_ref4 = require("@radix-ui/react-use-callback-ref");
1875
- var import_react46 = require("react");
1748
+
1749
+
1876
1750
  var useOnScrollToBottom = (callback) => {
1877
- const callbackRef = (0, import_react_use_callback_ref4.useCallbackRef)(callback);
1751
+ const callbackRef = _reactusecallbackref.useCallbackRef.call(void 0, callback);
1878
1752
  const { useViewport } = useThreadContext();
1879
- (0, import_react46.useEffect)(() => {
1753
+ _react.useEffect.call(void 0, () => {
1880
1754
  return useViewport.getState().onScrollToBottom(() => {
1881
1755
  callbackRef();
1882
1756
  });
@@ -1887,10 +1761,10 @@ var useOnScrollToBottom = (callback) => {
1887
1761
  var useThreadViewportAutoScroll = ({
1888
1762
  autoScroll = true
1889
1763
  }) => {
1890
- const divRef = (0, import_react47.useRef)(null);
1764
+ const divRef = _react.useRef.call(void 0, null);
1891
1765
  const { useViewport } = useThreadContext();
1892
- const lastScrollTop = (0, import_react47.useRef)(0);
1893
- const isScrollingToBottomRef = (0, import_react47.useRef)(false);
1766
+ const lastScrollTop = _react.useRef.call(void 0, 0);
1767
+ const isScrollingToBottomRef = _react.useRef.call(void 0, false);
1894
1768
  const scrollToBottom = (behavior) => {
1895
1769
  const div = divRef.current;
1896
1770
  if (!div || !autoScroll) return;
@@ -1927,7 +1801,7 @@ var useThreadViewportAutoScroll = ({
1927
1801
  el.removeEventListener("scroll", handleScroll);
1928
1802
  };
1929
1803
  });
1930
- const autoScrollRef = (0, import_react_compose_refs3.useComposedRefs)(resizeRef, scrollRef, divRef);
1804
+ const autoScrollRef = _reactcomposerefs.useComposedRefs.call(void 0, resizeRef, scrollRef, divRef);
1931
1805
  useOnScrollToBottom(() => {
1932
1806
  scrollToBottom("auto");
1933
1807
  });
@@ -1935,29 +1809,29 @@ var useThreadViewportAutoScroll = ({
1935
1809
  };
1936
1810
 
1937
1811
  // src/primitives/thread/ThreadViewport.tsx
1938
- var import_jsx_runtime23 = require("react/jsx-runtime");
1939
- var ThreadPrimitiveViewport = (0, import_react48.forwardRef)(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
1812
+
1813
+ var ThreadPrimitiveViewport = _react.forwardRef.call(void 0, ({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
1940
1814
  const autoScrollRef = useThreadViewportAutoScroll({
1941
1815
  autoScroll
1942
1816
  });
1943
- const ref = (0, import_react_compose_refs4.useComposedRefs)(forwardedRef, autoScrollRef);
1944
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_primitive9.Primitive.div, { ...rest, ref, children });
1817
+ const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardedRef, autoScrollRef);
1818
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...rest, ref, children });
1945
1819
  });
1946
1820
  ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
1947
1821
 
1948
1822
  // src/primitives/thread/ThreadMessages.tsx
1949
- var import_react50 = require("react");
1823
+
1950
1824
 
1951
1825
  // src/context/providers/MessageProvider.tsx
1952
- var import_react49 = require("react");
1953
- var import_zustand14 = require("zustand");
1826
+
1827
+
1954
1828
 
1955
1829
  // src/context/stores/EditComposer.ts
1956
- var import_zustand12 = require("zustand");
1830
+
1957
1831
  var makeEditComposerStore = ({
1958
1832
  onEdit,
1959
1833
  onSend
1960
- }) => (0, import_zustand12.create)()((set, get, store) => ({
1834
+ }) => _zustand.create.call(void 0, )((set, get, store) => ({
1961
1835
  ...makeBaseComposer(set, get, store),
1962
1836
  canCancel: false,
1963
1837
  isEditing: false,
@@ -1976,8 +1850,8 @@ var makeEditComposerStore = ({
1976
1850
  }));
1977
1851
 
1978
1852
  // src/context/stores/MessageUtils.ts
1979
- var import_zustand13 = require("zustand");
1980
- var makeMessageUtilsStore = () => (0, import_zustand13.create)((set) => ({
1853
+
1854
+ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => ({
1981
1855
  isCopied: false,
1982
1856
  setIsCopied: (value) => {
1983
1857
  set({ isCopied: value });
@@ -1989,17 +1863,17 @@ var makeMessageUtilsStore = () => (0, import_zustand13.create)((set) => ({
1989
1863
  }));
1990
1864
 
1991
1865
  // src/context/providers/MessageProvider.tsx
1992
- var import_jsx_runtime24 = require("react/jsx-runtime");
1866
+
1993
1867
  var getIsLast = (messages, message) => {
1994
- return messages[messages.length - 1]?.id === message.id;
1868
+ return _optionalChain([messages, 'access', _51 => _51[messages.length - 1], 'optionalAccess', _52 => _52.id]) === message.id;
1995
1869
  };
1996
1870
  var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
1997
- const parentId = messages[messageIndex - 1]?.id ?? null;
1871
+ const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _53 => _53[messageIndex - 1], 'optionalAccess', _54 => _54.id]), () => ( null));
1998
1872
  const message = messages[messageIndex];
1999
1873
  if (!message) return null;
2000
1874
  const isLast = getIsLast(messages, message);
2001
1875
  const branches = getBranches(message.id);
2002
- const currentState = useMessage?.getState();
1876
+ const currentState = _optionalChain([useMessage, 'optionalAccess', _55 => _55.getState, 'call', _56 => _56()]);
2003
1877
  if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
2004
1878
  return null;
2005
1879
  return Object.freeze({
@@ -2011,8 +1885,8 @@ var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
2011
1885
  };
2012
1886
  var useMessageContext2 = (messageIndex) => {
2013
1887
  const { useThreadMessages, useThreadActions } = useThreadContext();
2014
- const [context] = (0, import_react49.useState)(() => {
2015
- const useMessage = (0, import_zustand14.create)(
1888
+ const [context] = _react.useState.call(void 0, () => {
1889
+ const useMessage = _zustand.create.call(void 0,
2016
1890
  () => getMessageState(
2017
1891
  useThreadMessages.getState(),
2018
1892
  useThreadActions.getState().getBranches,
@@ -2049,7 +1923,7 @@ var useMessageContext2 = (messageIndex) => {
2049
1923
  });
2050
1924
  return { useMessage, useMessageUtils, useEditComposer };
2051
1925
  });
2052
- (0, import_react49.useEffect)(() => {
1926
+ _react.useEffect.call(void 0, () => {
2053
1927
  const syncMessage = (thread) => {
2054
1928
  const newState = getMessageState(
2055
1929
  thread,
@@ -2073,18 +1947,18 @@ var MessageProvider = ({
2073
1947
  children
2074
1948
  }) => {
2075
1949
  const context = useMessageContext2(messageIndex);
2076
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(MessageContext.Provider, { value: context, children });
1950
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContext.Provider, { value: context, children });
2077
1951
  };
2078
1952
 
2079
1953
  // src/primitives/thread/ThreadMessages.tsx
2080
- var import_jsx_runtime25 = require("react/jsx-runtime");
1954
+
2081
1955
  var DEFAULT_SYSTEM_MESSAGE = () => null;
2082
1956
  var getComponents = (components) => {
2083
1957
  return {
2084
- EditComposer: components.EditComposer ?? components.UserMessage ?? components.Message,
2085
- UserMessage: components.UserMessage ?? components.Message,
2086
- AssistantMessage: components.AssistantMessage ?? components.Message,
2087
- SystemMessage: components.SystemMessage ?? DEFAULT_SYSTEM_MESSAGE
1958
+ EditComposer: _nullishCoalesce(_nullishCoalesce(components.EditComposer, () => ( components.UserMessage)), () => ( components.Message)),
1959
+ UserMessage: _nullishCoalesce(components.UserMessage, () => ( components.Message)),
1960
+ AssistantMessage: _nullishCoalesce(components.AssistantMessage, () => ( components.Message)),
1961
+ SystemMessage: _nullishCoalesce(components.SystemMessage, () => ( DEFAULT_SYSTEM_MESSAGE))
2088
1962
  };
2089
1963
  };
2090
1964
  var ThreadMessageImpl = ({
@@ -2092,16 +1966,16 @@ var ThreadMessageImpl = ({
2092
1966
  components
2093
1967
  }) => {
2094
1968
  const { UserMessage: UserMessage2, EditComposer: EditComposer2, AssistantMessage: AssistantMessage2, SystemMessage: SystemMessage2 } = getComponents(components);
2095
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(MessageProvider, { messageIndex, children: [
2096
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(MessagePrimitiveIf, { user: true, children: [
2097
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UserMessage2, {}) }),
2098
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(EditComposer2, {}) })
1969
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, MessageProvider, { messageIndex, children: [
1970
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, MessagePrimitiveIf, { user: true, children: [
1971
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessage2, {}) }),
1972
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposer2, {}) })
2099
1973
  ] }),
2100
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(AssistantMessage2, {}) }),
2101
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(MessagePrimitiveIf, { system: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SystemMessage2, {}) })
1974
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessage2, {}) }),
1975
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { system: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SystemMessage2, {}) })
2102
1976
  ] });
2103
1977
  };
2104
- var ThreadMessage = (0, import_react50.memo)(
1978
+ var ThreadMessage = _react.memo.call(void 0,
2105
1979
  ThreadMessageImpl,
2106
1980
  (prev, next) => prev.messageIndex === next.messageIndex && prev.components.Message === next.components.Message && prev.components.UserMessage === next.components.UserMessage && prev.components.EditComposer === next.components.EditComposer && prev.components.AssistantMessage === next.components.AssistantMessage && prev.components.SystemMessage === next.components.SystemMessage
2107
1981
  );
@@ -2113,7 +1987,7 @@ var ThreadPrimitiveMessagesImpl = ({
2113
1987
  if (messagesLength === 0) return null;
2114
1988
  return new Array(messagesLength).fill(null).map((_, idx) => {
2115
1989
  const messageIndex = idx;
2116
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1990
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2117
1991
  ThreadMessage,
2118
1992
  {
2119
1993
  messageIndex,
@@ -2124,9 +1998,9 @@ var ThreadPrimitiveMessagesImpl = ({
2124
1998
  });
2125
1999
  };
2126
2000
  ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
2127
- var ThreadPrimitiveMessages = (0, import_react50.memo)(
2001
+ var ThreadPrimitiveMessages = _react.memo.call(void 0,
2128
2002
  ThreadPrimitiveMessagesImpl,
2129
- (prev, next) => prev.components?.Message === next.components?.Message && prev.components?.UserMessage === next.components?.UserMessage && prev.components?.EditComposer === next.components?.EditComposer && prev.components?.AssistantMessage === next.components?.AssistantMessage && prev.components?.SystemMessage === next.components?.SystemMessage
2003
+ (prev, next) => _optionalChain([prev, 'access', _57 => _57.components, 'optionalAccess', _58 => _58.Message]) === _optionalChain([next, 'access', _59 => _59.components, 'optionalAccess', _60 => _60.Message]) && _optionalChain([prev, 'access', _61 => _61.components, 'optionalAccess', _62 => _62.UserMessage]) === _optionalChain([next, 'access', _63 => _63.components, 'optionalAccess', _64 => _64.UserMessage]) && _optionalChain([prev, 'access', _65 => _65.components, 'optionalAccess', _66 => _66.EditComposer]) === _optionalChain([next, 'access', _67 => _67.components, 'optionalAccess', _68 => _68.EditComposer]) && _optionalChain([prev, 'access', _69 => _69.components, 'optionalAccess', _70 => _70.AssistantMessage]) === _optionalChain([next, 'access', _71 => _71.components, 'optionalAccess', _72 => _72.AssistantMessage]) && _optionalChain([prev, 'access', _73 => _73.components, 'optionalAccess', _74 => _74.SystemMessage]) === _optionalChain([next, 'access', _75 => _75.components, 'optionalAccess', _76 => _76.SystemMessage])
2130
2004
  );
2131
2005
 
2132
2006
  // src/primitives/thread/ThreadScrollToBottom.tsx
@@ -2143,11 +2017,11 @@ var ThreadPrimitiveSuggestion = createActionButton(
2143
2017
  );
2144
2018
 
2145
2019
  // src/runtimes/local/useLocalRuntime.tsx
2146
- var import_react55 = require("react");
2020
+
2147
2021
 
2148
2022
  // src/runtimes/core/BaseAssistantRuntime.tsx
2149
- var BaseAssistantRuntime = class {
2150
- constructor(_thread) {
2023
+ var BaseAssistantRuntime = (_class3 = class {
2024
+ constructor(_thread) {;_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);
2151
2025
  this._thread = _thread;
2152
2026
  this._thread = _thread;
2153
2027
  }
@@ -2158,19 +2032,19 @@ var BaseAssistantRuntime = class {
2158
2032
  this._thread = thread;
2159
2033
  this.subscriptionHandler();
2160
2034
  }
2161
- _subscriptions = /* @__PURE__ */ new Set();
2035
+ __init6() {this._subscriptions = /* @__PURE__ */ new Set()}
2162
2036
  subscribe(callback) {
2163
2037
  this._subscriptions.add(callback);
2164
2038
  return () => this._subscriptions.delete(callback);
2165
2039
  }
2166
- subscriptionHandler = () => {
2040
+ __init7() {this.subscriptionHandler = () => {
2167
2041
  for (const callback of this._subscriptions) callback();
2168
- };
2169
- };
2042
+ }}
2043
+ }, _class3);
2170
2044
 
2171
2045
  // src/internal.ts
2172
2046
  var internal_exports = {};
2173
- __export(internal_exports, {
2047
+ _chunkDCHYNTHIjs.__export.call(void 0, internal_exports, {
2174
2048
  BaseAssistantRuntime: () => BaseAssistantRuntime,
2175
2049
  MessageRepository: () => MessageRepository,
2176
2050
  ProxyConfigProvider: () => ProxyConfigProvider,
@@ -2182,8 +2056,8 @@ __export(internal_exports, {
2182
2056
  });
2183
2057
 
2184
2058
  // src/utils/idUtils.tsx
2185
- var import_non_secure = require("nanoid/non-secure");
2186
- var generateId = (0, import_non_secure.customAlphabet)(
2059
+ var _nonsecure = require('nanoid/non-secure');
2060
+ var generateId = _nonsecure.customAlphabet.call(void 0,
2187
2061
  "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
2188
2062
  7
2189
2063
  );
@@ -2243,22 +2117,22 @@ var findHead = (message) => {
2243
2117
  if (message.next) return findHead(message.next);
2244
2118
  return message;
2245
2119
  };
2246
- var MessageRepository = class {
2247
- messages = /* @__PURE__ */ new Map();
2120
+ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__init8.call(this);_class4.prototype.__init9.call(this);_class4.prototype.__init10.call(this); }
2121
+ __init8() {this.messages = /* @__PURE__ */ new Map()}
2248
2122
  // message_id -> item
2249
- head = null;
2250
- root = {
2123
+ __init9() {this.head = null}
2124
+ __init10() {this.root = {
2251
2125
  children: []
2252
- };
2126
+ }}
2253
2127
  performOp(newParent, child, operation) {
2254
- const parentOrRoot = child.prev ?? this.root;
2255
- const newParentOrRoot = newParent ?? this.root;
2128
+ const parentOrRoot = _nullishCoalesce(child.prev, () => ( this.root));
2129
+ const newParentOrRoot = _nullishCoalesce(newParent, () => ( this.root));
2256
2130
  if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
2257
2131
  if (operation !== "link") {
2258
2132
  parentOrRoot.children = parentOrRoot.children.filter(
2259
2133
  (m) => m !== child.current.id
2260
2134
  );
2261
- if (child.prev?.next === child) {
2135
+ if (_optionalChain([child, 'access', _77 => _77.prev, 'optionalAccess', _78 => _78.next]) === child) {
2262
2136
  const fallbackId = child.prev.children.at(-1);
2263
2137
  const fallback = fallbackId ? this.messages.get(fallbackId) : null;
2264
2138
  if (fallback === void 0) {
@@ -2281,7 +2155,7 @@ var MessageRepository = class {
2281
2155
  }
2282
2156
  }
2283
2157
  getMessages() {
2284
- const messages = new Array(this.head?.level ?? 0);
2158
+ const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access', _79 => _79.head, 'optionalAccess', _80 => _80.level]), () => ( 0)));
2285
2159
  for (let current = this.head; current; current = current.prev) {
2286
2160
  messages[current.level] = current.current;
2287
2161
  }
@@ -2319,7 +2193,7 @@ var MessageRepository = class {
2319
2193
  "MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
2320
2194
  );
2321
2195
  return {
2322
- parentId: message.prev?.current.id ?? null,
2196
+ parentId: _nullishCoalesce(_optionalChain([message, 'access', _81 => _81.prev, 'optionalAccess', _82 => _82.current, 'access', _83 => _83.id]), () => ( null)),
2323
2197
  message: message.current
2324
2198
  };
2325
2199
  }
@@ -2368,7 +2242,7 @@ var MessageRepository = class {
2368
2242
  throw new Error(
2369
2243
  "MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
2370
2244
  );
2371
- const { children } = message.prev ?? this.root;
2245
+ const { children } = _nullishCoalesce(message.prev, () => ( this.root));
2372
2246
  return children;
2373
2247
  }
2374
2248
  switchToBranch(messageId) {
@@ -2399,34 +2273,36 @@ var MessageRepository = class {
2399
2273
  }
2400
2274
  }
2401
2275
  }
2402
- };
2276
+ }, _class4);
2403
2277
 
2404
2278
  // src/ui/base/tooltip-icon-button.tsx
2405
- var import_react53 = require("react");
2279
+
2406
2280
 
2407
2281
  // src/ui/base/tooltip.tsx
2408
- var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
2282
+ var _reacttooltip = require('@radix-ui/react-tooltip'); var TooltipPrimitive = _interopRequireWildcard(_reacttooltip);
2409
2283
 
2410
2284
  // src/ui/utils/withDefaults.tsx
2411
- var import_react51 = require("react");
2412
- var import_classnames = __toESM(require("classnames"));
2413
- var import_jsx_runtime26 = require("react/jsx-runtime");
2285
+
2286
+
2287
+
2288
+ var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames);
2289
+
2414
2290
  var withDefaultProps = ({
2415
2291
  className,
2416
2292
  ...defaultProps
2417
2293
  }) => ({ className: classNameProp, ...props }) => {
2418
2294
  return {
2419
- className: (0, import_classnames.default)(className, classNameProp),
2295
+ className: _classnames2.default.call(void 0, className, classNameProp),
2420
2296
  ...defaultProps,
2421
2297
  ...props
2422
2298
  };
2423
2299
  };
2424
2300
  var withDefaults = (Component, defaultProps) => {
2425
2301
  const getProps = withDefaultProps(defaultProps);
2426
- const WithDefaults = (0, import_react51.forwardRef)(
2302
+ const WithDefaults = _react.forwardRef.call(void 0,
2427
2303
  (props, ref) => {
2428
2304
  const ComponentAsAny = Component;
2429
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ComponentAsAny, { ...getProps(props), ref });
2305
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComponentAsAny, { ...getProps(props), ref });
2430
2306
  }
2431
2307
  );
2432
2308
  WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
@@ -2434,9 +2310,9 @@ var withDefaults = (Component, defaultProps) => {
2434
2310
  };
2435
2311
 
2436
2312
  // src/ui/base/tooltip.tsx
2437
- var import_jsx_runtime27 = require("react/jsx-runtime");
2313
+
2438
2314
  var Tooltip = (props) => {
2439
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TooltipPrimitive.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TooltipPrimitive.Root, { ...props }) });
2315
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipPrimitive.Provider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipPrimitive.Root, { ...props }) });
2440
2316
  };
2441
2317
  Tooltip.displayName = "Tooltip";
2442
2318
  var TooltipTrigger = TooltipPrimitive.Trigger;
@@ -2447,11 +2323,11 @@ var TooltipContent = withDefaults(TooltipPrimitive.Content, {
2447
2323
  TooltipContent.displayName = "TooltipContent";
2448
2324
 
2449
2325
  // src/ui/base/button.tsx
2450
- var import_class_variance_authority = require("class-variance-authority");
2451
- var import_react_primitive10 = require("@radix-ui/react-primitive");
2452
- var import_react52 = require("react");
2453
- var import_jsx_runtime28 = require("react/jsx-runtime");
2454
- var buttonVariants = (0, import_class_variance_authority.cva)("aui-button", {
2326
+ var _classvarianceauthority = require('class-variance-authority');
2327
+
2328
+
2329
+
2330
+ var buttonVariants = _classvarianceauthority.cva.call(void 0, "aui-button", {
2455
2331
  variants: {
2456
2332
  variant: {
2457
2333
  default: "aui-button-primary",
@@ -2468,10 +2344,10 @@ var buttonVariants = (0, import_class_variance_authority.cva)("aui-button", {
2468
2344
  size: "default"
2469
2345
  }
2470
2346
  });
2471
- var Button = (0, import_react52.forwardRef)(
2347
+ var Button = _react.forwardRef.call(void 0,
2472
2348
  ({ className, variant, size, ...props }, ref) => {
2473
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2474
- import_react_primitive10.Primitive.button,
2349
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2350
+ _reactprimitive.Primitive.button,
2475
2351
  {
2476
2352
  className: buttonVariants({ variant, size, className }),
2477
2353
  ...props,
@@ -2483,134 +2359,18 @@ var Button = (0, import_react52.forwardRef)(
2483
2359
  Button.displayName = "Button";
2484
2360
 
2485
2361
  // src/ui/base/tooltip-icon-button.tsx
2486
- var import_jsx_runtime29 = require("react/jsx-runtime");
2487
- var TooltipIconButton = (0, import_react53.forwardRef)(({ children, tooltip, side = "bottom", ...rest }, ref) => {
2488
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Tooltip, { children: [
2489
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
2362
+
2363
+ var TooltipIconButton = _react.forwardRef.call(void 0, ({ children, tooltip, side = "bottom", ...rest }, ref) => {
2364
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Tooltip, { children: [
2365
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
2490
2366
  children,
2491
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "aui-sr-only", children: tooltip })
2367
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-sr-only", children: tooltip })
2492
2368
  ] }) }),
2493
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TooltipContent, { side, children: tooltip })
2369
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipContent, { side, children: tooltip })
2494
2370
  ] });
2495
2371
  });
2496
2372
  TooltipIconButton.displayName = "TooltipIconButton";
2497
2373
 
2498
- // src/runtimes/edge/converters/toLanguageModelMessages.ts
2499
- var assistantMessageSplitter = () => {
2500
- const stash = [];
2501
- let assistantMessage = {
2502
- role: "assistant",
2503
- content: []
2504
- };
2505
- let toolMessage = {
2506
- role: "tool",
2507
- content: []
2508
- };
2509
- return {
2510
- addTextContentPart: (part) => {
2511
- if (toolMessage.content.length > 0) {
2512
- stash.push(assistantMessage);
2513
- stash.push(toolMessage);
2514
- assistantMessage = {
2515
- role: "assistant",
2516
- content: []
2517
- };
2518
- toolMessage = {
2519
- role: "tool",
2520
- content: []
2521
- };
2522
- }
2523
- assistantMessage.content.push(part);
2524
- },
2525
- addToolCallPart: (part) => {
2526
- assistantMessage.content.push({
2527
- type: "tool-call",
2528
- toolCallId: part.toolCallId,
2529
- toolName: part.toolName,
2530
- args: part.args
2531
- });
2532
- if (part.result) {
2533
- toolMessage.content.push({
2534
- type: "tool-result",
2535
- toolCallId: part.toolCallId,
2536
- toolName: part.toolName,
2537
- result: part.result
2538
- // isError
2539
- });
2540
- }
2541
- },
2542
- getMessages: () => {
2543
- if (toolMessage.content.length > 0) {
2544
- return [...stash, assistantMessage, toolMessage];
2545
- }
2546
- return [...stash, assistantMessage];
2547
- }
2548
- };
2549
- };
2550
- function toLanguageModelMessages(message) {
2551
- return message.flatMap((message2) => {
2552
- const role = message2.role;
2553
- switch (role) {
2554
- case "system": {
2555
- return [{ role: "system", content: message2.content[0].text }];
2556
- }
2557
- case "user": {
2558
- const msg = {
2559
- role: "user",
2560
- content: message2.content.map(
2561
- (part) => {
2562
- const type = part.type;
2563
- switch (type) {
2564
- case "text": {
2565
- return part;
2566
- }
2567
- case "image": {
2568
- return {
2569
- type: "image",
2570
- image: new URL(part.image)
2571
- };
2572
- }
2573
- default: {
2574
- const unhandledType = type;
2575
- throw new Error(
2576
- `Unspported content part type: ${unhandledType}`
2577
- );
2578
- }
2579
- }
2580
- }
2581
- )
2582
- };
2583
- return [msg];
2584
- }
2585
- case "assistant": {
2586
- const splitter = assistantMessageSplitter();
2587
- for (const part of message2.content) {
2588
- const type = part.type;
2589
- switch (type) {
2590
- case "text": {
2591
- splitter.addTextContentPart(part);
2592
- break;
2593
- }
2594
- case "tool-call": {
2595
- splitter.addToolCallPart(part);
2596
- break;
2597
- }
2598
- default: {
2599
- const unhandledType = type;
2600
- throw new Error(`Unhandled content part type: ${unhandledType}`);
2601
- }
2602
- }
2603
- }
2604
- return splitter.getMessages();
2605
- }
2606
- default: {
2607
- const unhandledRole = role;
2608
- throw new Error(`Unknown message role: ${unhandledRole}`);
2609
- }
2610
- }
2611
- });
2612
- }
2613
-
2614
2374
  // src/runtimes/edge/converters/fromLanguageModelMessages.ts
2615
2375
  var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
2616
2376
  const messages = [];
@@ -2674,7 +2434,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
2674
2434
  });
2675
2435
  if (mergeRoundtrips) {
2676
2436
  const previousMessage = messages[messages.length - 1];
2677
- if (previousMessage?.role === "assistant") {
2437
+ if (_optionalChain([previousMessage, 'optionalAccess', _84 => _84.role]) === "assistant") {
2678
2438
  previousMessage.content.push(...newContent);
2679
2439
  break;
2680
2440
  }
@@ -2687,7 +2447,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
2687
2447
  }
2688
2448
  case "tool": {
2689
2449
  const previousMessage = messages[messages.length - 1];
2690
- if (previousMessage?.role !== "assistant")
2450
+ if (_optionalChain([previousMessage, 'optionalAccess', _85 => _85.role]) !== "assistant")
2691
2451
  throw new Error(
2692
2452
  "A tool message must be preceded by an assistant message."
2693
2453
  );
@@ -2715,45 +2475,6 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
2715
2475
  return messages;
2716
2476
  };
2717
2477
 
2718
- // src/runtimes/edge/converters/toCoreMessages.ts
2719
- var toCoreMessages = (message) => {
2720
- return message.map(toCoreMessage);
2721
- };
2722
- var toCoreMessage = (message) => {
2723
- const role = message.role;
2724
- switch (role) {
2725
- case "assistant":
2726
- return {
2727
- role,
2728
- content: message.content.map((part) => {
2729
- if (part.type === "ui") throw new Error("UI parts are not supported");
2730
- if (part.type === "tool-call") {
2731
- const { argsText, ...rest } = part;
2732
- return rest;
2733
- }
2734
- return part;
2735
- })
2736
- };
2737
- case "user":
2738
- return {
2739
- role,
2740
- content: message.content.map((part) => {
2741
- if (part.type === "ui") throw new Error("UI parts are not supported");
2742
- return part;
2743
- })
2744
- };
2745
- case "system":
2746
- return {
2747
- role,
2748
- content: message.content
2749
- };
2750
- default: {
2751
- const unsupportedRole = role;
2752
- throw new Error(`Unknown message role: ${unsupportedRole}`);
2753
- }
2754
- }
2755
- };
2756
-
2757
2478
  // src/runtimes/edge/converters/fromLanguageModelTools.ts
2758
2479
  var fromLanguageModelTools = (tools) => {
2759
2480
  return Object.fromEntries(
@@ -2767,20 +2488,8 @@ var fromLanguageModelTools = (tools) => {
2767
2488
  );
2768
2489
  };
2769
2490
 
2770
- // src/runtimes/edge/converters/toLanguageModelTools.ts
2771
- var import_zod2 = require("zod");
2772
- var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"));
2773
- var toLanguageModelTools = (tools) => {
2774
- return Object.entries(tools).map(([name, tool]) => ({
2775
- type: "function",
2776
- name,
2777
- ...tool.description ? { description: tool.description } : void 0,
2778
- parameters: tool.parameters instanceof import_zod2.z.ZodType ? (0, import_zod_to_json_schema.default)(tool.parameters) : tool.parameters
2779
- }));
2780
- };
2781
-
2782
2491
  // src/runtimes/edge/useEdgeRuntime.ts
2783
- var import_react54 = require("react");
2492
+
2784
2493
 
2785
2494
  // src/runtimes/edge/streams/assistantDecoderStream.ts
2786
2495
  function assistantDecoderStream() {
@@ -2886,589 +2595,6 @@ function chunkByLineStream() {
2886
2595
  });
2887
2596
  }
2888
2597
 
2889
- // src/runtimes/edge/partial-json/parse-partial-json.ts
2890
- var import_secure_json_parse = __toESM(require("secure-json-parse"));
2891
-
2892
- // src/runtimes/edge/partial-json/fix-json.ts
2893
- function fixJson(input) {
2894
- const stack = ["ROOT"];
2895
- let lastValidIndex = -1;
2896
- let literalStart = null;
2897
- function processValueStart(char, i, swapState) {
2898
- {
2899
- switch (char) {
2900
- case '"': {
2901
- lastValidIndex = i;
2902
- stack.pop();
2903
- stack.push(swapState);
2904
- stack.push("INSIDE_STRING");
2905
- break;
2906
- }
2907
- case "f":
2908
- case "t":
2909
- case "n": {
2910
- lastValidIndex = i;
2911
- literalStart = i;
2912
- stack.pop();
2913
- stack.push(swapState);
2914
- stack.push("INSIDE_LITERAL");
2915
- break;
2916
- }
2917
- case "-": {
2918
- stack.pop();
2919
- stack.push(swapState);
2920
- stack.push("INSIDE_NUMBER");
2921
- break;
2922
- }
2923
- case "0":
2924
- case "1":
2925
- case "2":
2926
- case "3":
2927
- case "4":
2928
- case "5":
2929
- case "6":
2930
- case "7":
2931
- case "8":
2932
- case "9": {
2933
- lastValidIndex = i;
2934
- stack.pop();
2935
- stack.push(swapState);
2936
- stack.push("INSIDE_NUMBER");
2937
- break;
2938
- }
2939
- case "{": {
2940
- lastValidIndex = i;
2941
- stack.pop();
2942
- stack.push(swapState);
2943
- stack.push("INSIDE_OBJECT_START");
2944
- break;
2945
- }
2946
- case "[": {
2947
- lastValidIndex = i;
2948
- stack.pop();
2949
- stack.push(swapState);
2950
- stack.push("INSIDE_ARRAY_START");
2951
- break;
2952
- }
2953
- }
2954
- }
2955
- }
2956
- function processAfterObjectValue(char, i) {
2957
- switch (char) {
2958
- case ",": {
2959
- stack.pop();
2960
- stack.push("INSIDE_OBJECT_AFTER_COMMA");
2961
- break;
2962
- }
2963
- case "}": {
2964
- lastValidIndex = i;
2965
- stack.pop();
2966
- break;
2967
- }
2968
- }
2969
- }
2970
- function processAfterArrayValue(char, i) {
2971
- switch (char) {
2972
- case ",": {
2973
- stack.pop();
2974
- stack.push("INSIDE_ARRAY_AFTER_COMMA");
2975
- break;
2976
- }
2977
- case "]": {
2978
- lastValidIndex = i;
2979
- stack.pop();
2980
- break;
2981
- }
2982
- }
2983
- }
2984
- for (let i = 0; i < input.length; i++) {
2985
- const char = input[i];
2986
- const currentState = stack[stack.length - 1];
2987
- switch (currentState) {
2988
- case "ROOT":
2989
- processValueStart(char, i, "FINISH");
2990
- break;
2991
- case "INSIDE_OBJECT_START": {
2992
- switch (char) {
2993
- case '"': {
2994
- stack.pop();
2995
- stack.push("INSIDE_OBJECT_KEY");
2996
- break;
2997
- }
2998
- case "}": {
2999
- lastValidIndex = i;
3000
- stack.pop();
3001
- break;
3002
- }
3003
- }
3004
- break;
3005
- }
3006
- case "INSIDE_OBJECT_AFTER_COMMA": {
3007
- switch (char) {
3008
- case '"': {
3009
- stack.pop();
3010
- stack.push("INSIDE_OBJECT_KEY");
3011
- break;
3012
- }
3013
- }
3014
- break;
3015
- }
3016
- case "INSIDE_OBJECT_KEY": {
3017
- switch (char) {
3018
- case '"': {
3019
- stack.pop();
3020
- stack.push("INSIDE_OBJECT_AFTER_KEY");
3021
- break;
3022
- }
3023
- }
3024
- break;
3025
- }
3026
- case "INSIDE_OBJECT_AFTER_KEY": {
3027
- switch (char) {
3028
- case ":": {
3029
- stack.pop();
3030
- stack.push("INSIDE_OBJECT_BEFORE_VALUE");
3031
- break;
3032
- }
3033
- }
3034
- break;
3035
- }
3036
- case "INSIDE_OBJECT_BEFORE_VALUE": {
3037
- processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
3038
- break;
3039
- }
3040
- case "INSIDE_OBJECT_AFTER_VALUE": {
3041
- processAfterObjectValue(char, i);
3042
- break;
3043
- }
3044
- case "INSIDE_STRING": {
3045
- switch (char) {
3046
- case '"': {
3047
- stack.pop();
3048
- lastValidIndex = i;
3049
- break;
3050
- }
3051
- case "\\": {
3052
- stack.push("INSIDE_STRING_ESCAPE");
3053
- break;
3054
- }
3055
- default: {
3056
- lastValidIndex = i;
3057
- }
3058
- }
3059
- break;
3060
- }
3061
- case "INSIDE_ARRAY_START": {
3062
- switch (char) {
3063
- case "]": {
3064
- lastValidIndex = i;
3065
- stack.pop();
3066
- break;
3067
- }
3068
- default: {
3069
- lastValidIndex = i;
3070
- processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
3071
- break;
3072
- }
3073
- }
3074
- break;
3075
- }
3076
- case "INSIDE_ARRAY_AFTER_VALUE": {
3077
- switch (char) {
3078
- case ",": {
3079
- stack.pop();
3080
- stack.push("INSIDE_ARRAY_AFTER_COMMA");
3081
- break;
3082
- }
3083
- case "]": {
3084
- lastValidIndex = i;
3085
- stack.pop();
3086
- break;
3087
- }
3088
- default: {
3089
- lastValidIndex = i;
3090
- break;
3091
- }
3092
- }
3093
- break;
3094
- }
3095
- case "INSIDE_ARRAY_AFTER_COMMA": {
3096
- processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
3097
- break;
3098
- }
3099
- case "INSIDE_STRING_ESCAPE": {
3100
- stack.pop();
3101
- lastValidIndex = i;
3102
- break;
3103
- }
3104
- case "INSIDE_NUMBER": {
3105
- switch (char) {
3106
- case "0":
3107
- case "1":
3108
- case "2":
3109
- case "3":
3110
- case "4":
3111
- case "5":
3112
- case "6":
3113
- case "7":
3114
- case "8":
3115
- case "9": {
3116
- lastValidIndex = i;
3117
- break;
3118
- }
3119
- case "e":
3120
- case "E":
3121
- case "-":
3122
- case ".": {
3123
- break;
3124
- }
3125
- case ",": {
3126
- stack.pop();
3127
- if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
3128
- processAfterArrayValue(char, i);
3129
- }
3130
- if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
3131
- processAfterObjectValue(char, i);
3132
- }
3133
- break;
3134
- }
3135
- case "}": {
3136
- stack.pop();
3137
- if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
3138
- processAfterObjectValue(char, i);
3139
- }
3140
- break;
3141
- }
3142
- case "]": {
3143
- stack.pop();
3144
- if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
3145
- processAfterArrayValue(char, i);
3146
- }
3147
- break;
3148
- }
3149
- default: {
3150
- stack.pop();
3151
- break;
3152
- }
3153
- }
3154
- break;
3155
- }
3156
- case "INSIDE_LITERAL": {
3157
- const partialLiteral = input.substring(literalStart, i + 1);
3158
- if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
3159
- stack.pop();
3160
- if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
3161
- processAfterObjectValue(char, i);
3162
- } else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
3163
- processAfterArrayValue(char, i);
3164
- }
3165
- } else {
3166
- lastValidIndex = i;
3167
- }
3168
- break;
3169
- }
3170
- }
3171
- }
3172
- let result = input.slice(0, lastValidIndex + 1);
3173
- for (let i = stack.length - 1; i >= 0; i--) {
3174
- const state = stack[i];
3175
- switch (state) {
3176
- case "INSIDE_STRING": {
3177
- result += '"';
3178
- break;
3179
- }
3180
- case "INSIDE_OBJECT_KEY":
3181
- case "INSIDE_OBJECT_AFTER_KEY":
3182
- case "INSIDE_OBJECT_AFTER_COMMA":
3183
- case "INSIDE_OBJECT_START":
3184
- case "INSIDE_OBJECT_BEFORE_VALUE":
3185
- case "INSIDE_OBJECT_AFTER_VALUE": {
3186
- result += "}";
3187
- break;
3188
- }
3189
- case "INSIDE_ARRAY_START":
3190
- case "INSIDE_ARRAY_AFTER_COMMA":
3191
- case "INSIDE_ARRAY_AFTER_VALUE": {
3192
- result += "]";
3193
- break;
3194
- }
3195
- case "INSIDE_LITERAL": {
3196
- const partialLiteral = input.substring(literalStart, input.length);
3197
- if ("true".startsWith(partialLiteral)) {
3198
- result += "true".slice(partialLiteral.length);
3199
- } else if ("false".startsWith(partialLiteral)) {
3200
- result += "false".slice(partialLiteral.length);
3201
- } else if ("null".startsWith(partialLiteral)) {
3202
- result += "null".slice(partialLiteral.length);
3203
- }
3204
- }
3205
- }
3206
- }
3207
- return result;
3208
- }
3209
-
3210
- // src/runtimes/edge/partial-json/parse-partial-json.ts
3211
- var parsePartialJson = (json) => {
3212
- try {
3213
- return import_secure_json_parse.default.parse(json);
3214
- } catch {
3215
- try {
3216
- return import_secure_json_parse.default.parse(fixJson(json));
3217
- } catch {
3218
- return void 0;
3219
- }
3220
- }
3221
- };
3222
-
3223
- // src/runtimes/edge/streams/runResultStream.ts
3224
- function runResultStream() {
3225
- let message = {
3226
- content: [],
3227
- status: { type: "running" }
3228
- };
3229
- const currentToolCall = { toolCallId: "", argsText: "" };
3230
- return new TransformStream({
3231
- transform(chunk, controller) {
3232
- const chunkType = chunk.type;
3233
- switch (chunkType) {
3234
- case "text-delta": {
3235
- message = appendOrUpdateText(message, chunk.textDelta);
3236
- controller.enqueue(message);
3237
- break;
3238
- }
3239
- case "tool-call-delta": {
3240
- const { toolCallId, toolName, argsTextDelta } = chunk;
3241
- if (currentToolCall.toolCallId !== toolCallId) {
3242
- currentToolCall.toolCallId = toolCallId;
3243
- currentToolCall.argsText = argsTextDelta;
3244
- } else {
3245
- currentToolCall.argsText += argsTextDelta;
3246
- }
3247
- message = appendOrUpdateToolCall(
3248
- message,
3249
- toolCallId,
3250
- toolName,
3251
- currentToolCall.argsText
3252
- );
3253
- controller.enqueue(message);
3254
- break;
3255
- }
3256
- case "tool-call": {
3257
- break;
3258
- }
3259
- case "tool-result": {
3260
- message = appendOrUpdateToolResult(
3261
- message,
3262
- chunk.toolCallId,
3263
- chunk.toolName,
3264
- chunk.result
3265
- );
3266
- controller.enqueue(message);
3267
- break;
3268
- }
3269
- case "finish": {
3270
- message = appendOrUpdateFinish(message, chunk);
3271
- controller.enqueue(message);
3272
- break;
3273
- }
3274
- case "error": {
3275
- if (chunk.error instanceof Error && chunk.error.name === "AbortError") {
3276
- message = appendOrUpdateCancel(message);
3277
- controller.enqueue(message);
3278
- break;
3279
- } else {
3280
- throw chunk.error;
3281
- }
3282
- }
3283
- default: {
3284
- const unhandledType = chunkType;
3285
- throw new Error(`Unhandled chunk type: ${unhandledType}`);
3286
- }
3287
- }
3288
- }
3289
- });
3290
- }
3291
- var appendOrUpdateText = (message, textDelta) => {
3292
- let contentParts = message.content;
3293
- let contentPart = message.content.at(-1);
3294
- if (contentPart?.type !== "text") {
3295
- contentPart = { type: "text", text: textDelta };
3296
- } else {
3297
- contentParts = contentParts.slice(0, -1);
3298
- contentPart = { type: "text", text: contentPart.text + textDelta };
3299
- }
3300
- return {
3301
- ...message,
3302
- content: contentParts.concat([contentPart])
3303
- };
3304
- };
3305
- var appendOrUpdateToolCall = (message, toolCallId, toolName, argsText) => {
3306
- let contentParts = message.content;
3307
- let contentPart = message.content.at(-1);
3308
- if (contentPart?.type !== "tool-call" || contentPart.toolCallId !== toolCallId) {
3309
- contentPart = {
3310
- type: "tool-call",
3311
- toolCallId,
3312
- toolName,
3313
- argsText,
3314
- args: parsePartialJson(argsText)
3315
- };
3316
- } else {
3317
- contentParts = contentParts.slice(0, -1);
3318
- contentPart = {
3319
- ...contentPart,
3320
- argsText,
3321
- args: parsePartialJson(argsText)
3322
- };
3323
- }
3324
- return {
3325
- ...message,
3326
- content: contentParts.concat([contentPart])
3327
- };
3328
- };
3329
- var appendOrUpdateToolResult = (message, toolCallId, toolName, result) => {
3330
- let found = false;
3331
- const newContentParts = message.content.map((part) => {
3332
- if (part.type !== "tool-call" || part.toolCallId !== toolCallId)
3333
- return part;
3334
- found = true;
3335
- if (part.toolName !== toolName)
3336
- throw new Error(
3337
- `Tool call ${toolCallId} found with tool name ${part.toolName}, but expected ${toolName}`
3338
- );
3339
- return {
3340
- ...part,
3341
- result
3342
- };
3343
- });
3344
- if (!found)
3345
- throw new Error(
3346
- `Received tool result for unknown tool call "${toolName}" / "${toolCallId}". This is likely an internal bug in assistant-ui.`
3347
- );
3348
- return {
3349
- ...message,
3350
- content: newContentParts
3351
- };
3352
- };
3353
- var appendOrUpdateFinish = (message, chunk) => {
3354
- const { type, ...rest } = chunk;
3355
- return {
3356
- ...message,
3357
- status: getStatus(chunk),
3358
- roundtrips: [
3359
- ...message.roundtrips ?? [],
3360
- {
3361
- logprobs: rest.logprobs,
3362
- usage: rest.usage
3363
- }
3364
- ]
3365
- };
3366
- };
3367
- var getStatus = (chunk) => {
3368
- if (chunk.finishReason === "tool-calls") {
3369
- return {
3370
- type: "requires-action",
3371
- reason: "tool-calls"
3372
- };
3373
- } else if (chunk.finishReason === "stop" || chunk.finishReason === "unknown") {
3374
- return {
3375
- type: "complete",
3376
- reason: chunk.finishReason
3377
- };
3378
- } else {
3379
- return {
3380
- type: "incomplete",
3381
- reason: chunk.finishReason
3382
- };
3383
- }
3384
- };
3385
- var appendOrUpdateCancel = (message) => {
3386
- return {
3387
- ...message,
3388
- status: {
3389
- type: "incomplete",
3390
- reason: "cancelled"
3391
- }
3392
- };
3393
- };
3394
-
3395
- // src/runtimes/edge/streams/toolResultStream.ts
3396
- var import_zod3 = require("zod");
3397
- var import_secure_json_parse2 = __toESM(require("secure-json-parse"));
3398
- function toolResultStream(tools) {
3399
- const toolCallExecutions = /* @__PURE__ */ new Map();
3400
- return new TransformStream({
3401
- transform(chunk, controller) {
3402
- controller.enqueue(chunk);
3403
- const chunkType = chunk.type;
3404
- switch (chunkType) {
3405
- case "tool-call": {
3406
- const { toolCallId, toolCallType, toolName, args: argsText } = chunk;
3407
- const tool = tools?.[toolName];
3408
- if (!tool || !tool.execute) return;
3409
- const args = import_secure_json_parse2.default.parse(argsText);
3410
- if (tool.parameters instanceof import_zod3.z.ZodType) {
3411
- const result = tool.parameters.safeParse(args);
3412
- if (!result.success) {
3413
- controller.enqueue({
3414
- type: "tool-result",
3415
- toolCallType,
3416
- toolCallId,
3417
- toolName,
3418
- result: "Function parameter validation failed. " + JSON.stringify(result.error.issues),
3419
- isError: true
3420
- });
3421
- return;
3422
- } else {
3423
- toolCallExecutions.set(
3424
- toolCallId,
3425
- (async () => {
3426
- try {
3427
- const result2 = await tool.execute(args);
3428
- controller.enqueue({
3429
- type: "tool-result",
3430
- toolCallType,
3431
- toolCallId,
3432
- toolName,
3433
- result: result2
3434
- });
3435
- } catch (error) {
3436
- console.error("Error: ", error);
3437
- controller.enqueue({
3438
- type: "tool-result",
3439
- toolCallType,
3440
- toolCallId,
3441
- toolName,
3442
- result: "Error: " + error,
3443
- isError: true
3444
- });
3445
- } finally {
3446
- toolCallExecutions.delete(toolCallId);
3447
- }
3448
- })()
3449
- );
3450
- }
3451
- }
3452
- break;
3453
- }
3454
- case "text-delta":
3455
- case "tool-call-delta":
3456
- case "tool-result":
3457
- case "finish":
3458
- case "error":
3459
- break;
3460
- default: {
3461
- const unhandledType = chunkType;
3462
- throw new Error(`Unhandled chunk type: ${unhandledType}`);
3463
- }
3464
- }
3465
- },
3466
- async flush() {
3467
- await Promise.all(toolCallExecutions.values());
3468
- }
3469
- });
3470
- }
3471
-
3472
2598
  // src/runtimes/edge/EdgeChatAdapter.ts
3473
2599
  function asAsyncIterable(source) {
3474
2600
  return {
@@ -3495,8 +2621,8 @@ var EdgeChatAdapter = class {
3495
2621
  },
3496
2622
  body: JSON.stringify({
3497
2623
  system: config.system,
3498
- messages: toCoreMessages(messages),
3499
- tools: config.tools ? toLanguageModelTools(config.tools) : [],
2624
+ messages: _chunkNSPHKRLFjs.toCoreMessages.call(void 0, messages),
2625
+ tools: config.tools ? _chunkNSPHKRLFjs.toLanguageModelTools.call(void 0, config.tools) : [],
3500
2626
  ...config.callSettings,
3501
2627
  ...config.config
3502
2628
  }),
@@ -3505,7 +2631,7 @@ var EdgeChatAdapter = class {
3505
2631
  if (result.status !== 200) {
3506
2632
  throw new Error(`Status ${result.status}: ${await result.text()}`);
3507
2633
  }
3508
- const stream = result.body.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(config.tools)).pipeThrough(runResultStream());
2634
+ const stream = result.body.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkNSPHKRLFjs.toolResultStream.call(void 0, config.tools)).pipeThrough(_chunkNSPHKRLFjs.runResultStream.call(void 0, ));
3509
2635
  let update;
3510
2636
  for await (update of asAsyncIterable(stream)) {
3511
2637
  yield update;
@@ -3520,12 +2646,12 @@ var useEdgeRuntime = ({
3520
2646
  initialMessages,
3521
2647
  ...options
3522
2648
  }) => {
3523
- const [adapter] = (0, import_react54.useState)(() => new EdgeChatAdapter(options));
2649
+ const [adapter] = _react.useState.call(void 0, () => new EdgeChatAdapter(options));
3524
2650
  return useLocalRuntime(adapter, { initialMessages });
3525
2651
  };
3526
2652
 
3527
2653
  // src/runtimes/local/shouldContinue.tsx
3528
- var shouldContinue = (result) => result.status?.type === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
2654
+ var shouldContinue = (result) => _optionalChain([result, 'access', _86 => _86.status, 'optionalAccess', _87 => _87.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
3529
2655
 
3530
2656
  // src/runtimes/local/LocalThreadRuntime.tsx
3531
2657
  var CAPABILITIES = Object.freeze({
@@ -3535,12 +2661,12 @@ var CAPABILITIES = Object.freeze({
3535
2661
  cancel: true,
3536
2662
  copy: true
3537
2663
  });
3538
- var LocalThreadRuntime = class {
3539
- constructor(configProvider, adapter, options) {
2664
+ var LocalThreadRuntime = (_class5 = class {
2665
+ constructor(configProvider, adapter, options) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);
3540
2666
  this.configProvider = configProvider;
3541
2667
  this.adapter = adapter;
3542
2668
  this.options = options;
3543
- if (options?.initialMessages) {
2669
+ if (_optionalChain([options, 'optionalAccess', _88 => _88.initialMessages])) {
3544
2670
  let parentId = null;
3545
2671
  const messages = fromCoreMessages(options.initialMessages);
3546
2672
  for (const message of messages) {
@@ -3549,11 +2675,11 @@ var LocalThreadRuntime = class {
3549
2675
  }
3550
2676
  }
3551
2677
  }
3552
- _subscriptions = /* @__PURE__ */ new Set();
3553
- abortController = null;
3554
- repository = new MessageRepository();
3555
- capabilities = CAPABILITIES;
3556
- isDisabled = false;
2678
+ __init11() {this._subscriptions = /* @__PURE__ */ new Set()}
2679
+ __init12() {this.abortController = null}
2680
+ __init13() {this.repository = new MessageRepository()}
2681
+ __init14() {this.capabilities = CAPABILITIES}
2682
+ __init15() {this.isDisabled = false}
3557
2683
  get messages() {
3558
2684
  return this.repository.getMessages();
3559
2685
  }
@@ -3598,22 +2724,22 @@ var LocalThreadRuntime = class {
3598
2724
  }
3599
2725
  async performRoundtrip(parentId, message) {
3600
2726
  const messages = this.repository.getMessages();
3601
- this.abortController?.abort();
2727
+ _optionalChain([this, 'access', _89 => _89.abortController, 'optionalAccess', _90 => _90.abort, 'call', _91 => _91()]);
3602
2728
  this.abortController = new AbortController();
3603
2729
  const initialContent = message.content;
3604
2730
  const initialRoundtrips = message.roundtrips;
3605
2731
  const updateMessage = (m) => {
3606
2732
  message = {
3607
2733
  ...message,
3608
- ...m.content ? { content: [...initialContent, ...m.content ?? []] } : void 0,
3609
- status: m.status ?? message.status,
3610
- ...m.roundtrips?.length ? { roundtrips: [...initialRoundtrips ?? [], ...m.roundtrips] } : void 0
2734
+ ...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
2735
+ status: _nullishCoalesce(m.status, () => ( message.status)),
2736
+ ..._optionalChain([m, 'access', _92 => _92.roundtrips, 'optionalAccess', _93 => _93.length]) ? { roundtrips: [..._nullishCoalesce(initialRoundtrips, () => ( [])), ...m.roundtrips] } : void 0
3611
2737
  };
3612
2738
  this.repository.addOrUpdateMessage(parentId, message);
3613
2739
  this.notifySubscribers();
3614
2740
  };
3615
- const maxToolRoundtrips = this.options?.maxToolRoundtrips ?? 1;
3616
- const toolRoundtrips = message.roundtrips?.length ?? 0;
2741
+ const maxToolRoundtrips = _nullishCoalesce(_optionalChain([this, 'access', _94 => _94.options, 'optionalAccess', _95 => _95.maxToolRoundtrips]), () => ( 1));
2742
+ const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _96 => _96.roundtrips, 'optionalAccess', _97 => _97.length]), () => ( 0));
3617
2743
  if (toolRoundtrips > maxToolRoundtrips) {
3618
2744
  updateMessage({
3619
2745
  status: {
@@ -3705,11 +2831,11 @@ var LocalThreadRuntime = class {
3705
2831
  this.performRoundtrip(parentId, message);
3706
2832
  }
3707
2833
  }
3708
- };
2834
+ }, _class5);
3709
2835
 
3710
2836
  // src/runtimes/local/LocalRuntime.tsx
3711
2837
  var LocalRuntime = class extends BaseAssistantRuntime {
3712
- _proxyConfigProvider;
2838
+
3713
2839
  constructor(adapter, options) {
3714
2840
  const proxyConfigProvider = new ProxyConfigProvider();
3715
2841
  super(new LocalThreadRuntime(proxyConfigProvider, adapter, options));
@@ -3734,15 +2860,15 @@ var LocalRuntime = class extends BaseAssistantRuntime {
3734
2860
 
3735
2861
  // src/runtimes/local/useLocalRuntime.tsx
3736
2862
  var useLocalRuntime = (adapter, options) => {
3737
- const [runtime] = (0, import_react55.useState)(() => new LocalRuntime(adapter, options));
3738
- (0, import_react55.useInsertionEffect)(() => {
2863
+ const [runtime] = _react.useState.call(void 0, () => new LocalRuntime(adapter, options));
2864
+ _react.useInsertionEffect.call(void 0, () => {
3739
2865
  runtime.adapter = adapter;
3740
2866
  });
3741
2867
  return runtime;
3742
2868
  };
3743
2869
 
3744
2870
  // src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
3745
- var import_zustand15 = require("zustand");
2871
+
3746
2872
 
3747
2873
  // src/runtimes/external-store/getExternalStoreMessage.tsx
3748
2874
  var symbolInnerMessage = Symbol("innerMessage");
@@ -3751,11 +2877,11 @@ var getExternalStoreMessage = (message) => {
3751
2877
  };
3752
2878
 
3753
2879
  // src/runtimes/external-store/useExternalStoreSync.tsx
3754
- var import_react56 = require("react");
2880
+
3755
2881
 
3756
2882
  // src/runtimes/external-store/ThreadMessageConverter.ts
3757
- var ThreadMessageConverter = class {
3758
- cache = /* @__PURE__ */ new WeakMap();
2883
+ var ThreadMessageConverter = (_class6 = class {constructor() { _class6.prototype.__init16.call(this); }
2884
+ __init16() {this.cache = /* @__PURE__ */ new WeakMap()}
3759
2885
  convertMessages(messages, converter, keyMapper = (key) => key) {
3760
2886
  return messages.map((m, idx) => {
3761
2887
  const key = keyMapper(m);
@@ -3765,7 +2891,7 @@ var ThreadMessageConverter = class {
3765
2891
  return newMessage;
3766
2892
  });
3767
2893
  }
3768
- };
2894
+ }, _class6);
3769
2895
 
3770
2896
  // src/runtimes/external-store/auto-status.tsx
3771
2897
  var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
@@ -3779,8 +2905,8 @@ var getAutoStatus = (isLast, isRunning) => isLast && isRunning ? AUTO_STATUS_RUN
3779
2905
  var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
3780
2906
  const { role, content, id, createdAt, status } = like;
3781
2907
  const common = {
3782
- id: id ?? fallbackId,
3783
- createdAt: createdAt ?? /* @__PURE__ */ new Date()
2908
+ id: _nullishCoalesce(id, () => ( fallbackId)),
2909
+ createdAt: _nullishCoalesce(createdAt, () => ( /* @__PURE__ */ new Date()))
3784
2910
  };
3785
2911
  switch (role) {
3786
2912
  case "assistant":
@@ -3806,7 +2932,7 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
3806
2932
  }
3807
2933
  }
3808
2934
  }),
3809
- status: status ?? fallbackStatus
2935
+ status: _nullishCoalesce(status, () => ( fallbackStatus))
3810
2936
  };
3811
2937
  case "user":
3812
2938
  return {
@@ -3845,16 +2971,16 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
3845
2971
 
3846
2972
  // src/runtimes/external-store/useExternalStoreSync.tsx
3847
2973
  var useExternalStoreSync = (adapter, updateData) => {
3848
- const adapterRef = (0, import_react56.useRef)(adapter);
3849
- (0, import_react56.useInsertionEffect)(() => {
2974
+ const adapterRef = _react.useRef.call(void 0, adapter);
2975
+ _react.useInsertionEffect.call(void 0, () => {
3850
2976
  adapterRef.current = adapter;
3851
2977
  });
3852
- const [converter, convertCallback] = (0, import_react56.useMemo)(() => {
3853
- const converter2 = adapter.convertMessage ?? ((m) => m);
2978
+ const [converter, convertCallback] = _react.useMemo.call(void 0, () => {
2979
+ const converter2 = _nullishCoalesce(adapter.convertMessage, () => ( ((m) => m)));
3854
2980
  const convertCallback2 = (cache, m, idx) => {
3855
2981
  const autoStatus = getAutoStatus(
3856
2982
  adapterRef.current.messages.at(-1) === m,
3857
- adapterRef.current.isRunning ?? false
2983
+ _nullishCoalesce(adapterRef.current.isRunning, () => ( false))
3858
2984
  );
3859
2985
  if (cache && (cache.role !== "assistant" || cache.status === autoStatus))
3860
2986
  return cache;
@@ -3868,10 +2994,10 @@ var useExternalStoreSync = (adapter, updateData) => {
3868
2994
  };
3869
2995
  return [new ThreadMessageConverter(), convertCallback2];
3870
2996
  }, [adapter.convertMessage]);
3871
- (0, import_react56.useEffect)(() => {
2997
+ _react.useEffect.call(void 0, () => {
3872
2998
  updateData(
3873
- adapter.isDisabled ?? false,
3874
- adapter.isRunning ?? false,
2999
+ _nullishCoalesce(adapter.isDisabled, () => ( false)),
3000
+ _nullishCoalesce(adapter.isRunning, () => ( false)),
3875
3001
  converter.convertMessages(adapter.messages, convertCallback)
3876
3002
  );
3877
3003
  }, [
@@ -3886,24 +3012,24 @@ var useExternalStoreSync = (adapter, updateData) => {
3886
3012
 
3887
3013
  // src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
3888
3014
  var hasUpcomingMessage = (isRunning, messages) => {
3889
- return isRunning && messages[messages.length - 1]?.role !== "assistant";
3015
+ return isRunning && _optionalChain([messages, 'access', _98 => _98[messages.length - 1], 'optionalAccess', _99 => _99.role]) !== "assistant";
3890
3016
  };
3891
- var ExternalStoreThreadRuntime = class {
3892
- constructor(store) {
3017
+ var ExternalStoreThreadRuntime = (_class7 = class {
3018
+ constructor(store) {;_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);_class7.prototype.__init22.call(this);_class7.prototype.__init23.call(this);_class7.prototype.__init24.call(this);_class7.prototype.__init25.call(this);
3893
3019
  this.store = store;
3894
3020
  this.updateData(
3895
- store.isDisabled ?? false,
3896
- store.isRunning ?? false,
3021
+ _nullishCoalesce(store.isDisabled, () => ( false)),
3022
+ _nullishCoalesce(store.isRunning, () => ( false)),
3897
3023
  store.messages
3898
3024
  );
3899
- this.useStore = (0, import_zustand15.create)(() => ({
3025
+ this.useStore = _zustand.create.call(void 0, () => ({
3900
3026
  store
3901
3027
  }));
3902
3028
  }
3903
- _subscriptions = /* @__PURE__ */ new Set();
3904
- repository = new MessageRepository();
3905
- assistantOptimisticId = null;
3906
- useStore;
3029
+ __init17() {this._subscriptions = /* @__PURE__ */ new Set()}
3030
+ __init18() {this.repository = new MessageRepository()}
3031
+ __init19() {this.assistantOptimisticId = null}
3032
+
3907
3033
  get capabilities() {
3908
3034
  return {
3909
3035
  switchToBranch: this.store.setMessages !== void 0,
@@ -3913,9 +3039,9 @@ var ExternalStoreThreadRuntime = class {
3913
3039
  copy: this.store.onCopy !== null
3914
3040
  };
3915
3041
  }
3916
- messages = [];
3917
- isDisabled = false;
3918
- isRunning = false;
3042
+ __init20() {this.messages = []}
3043
+ __init21() {this.isDisabled = false}
3044
+ __init22() {this.isRunning = false}
3919
3045
  getBranches(messageId) {
3920
3046
  return this.repository.getBranches(messageId);
3921
3047
  }
@@ -3926,7 +3052,7 @@ var ExternalStoreThreadRuntime = class {
3926
3052
  this.updateMessages(this.repository.getMessages());
3927
3053
  }
3928
3054
  async append(message) {
3929
- if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {
3055
+ if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _110 => _110.messages, 'access', _111 => _111.at, 'call', _112 => _112(-1), 'optionalAccess', _113 => _113.id]), () => ( null)))) {
3930
3056
  if (!this.store.onEdit)
3931
3057
  throw new Error("Runtime does not support editing messages.");
3932
3058
  await this.store.onEdit(message);
@@ -3956,21 +3082,21 @@ var ExternalStoreThreadRuntime = class {
3956
3082
  this._subscriptions.add(callback);
3957
3083
  return () => this._subscriptions.delete(callback);
3958
3084
  }
3959
- updateMessages = (messages) => {
3960
- this.store.setMessages?.(
3085
+ __init23() {this.updateMessages = (messages) => {
3086
+ _optionalChain([this, 'access', _114 => _114.store, 'access', _115 => _115.setMessages, 'optionalCall', _116 => _116(
3961
3087
  messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
3962
- );
3963
- };
3088
+ )]);
3089
+ }}
3964
3090
  onStoreUpdated() {
3965
3091
  if (this.useStore.getState().store !== this.store) {
3966
3092
  this.useStore.setState({ store: this.store });
3967
3093
  }
3968
3094
  }
3969
- updateData = (isDisabled, isRunning, vm) => {
3095
+ __init24() {this.updateData = (isDisabled, isRunning, vm) => {
3970
3096
  for (let i = 0; i < vm.length; i++) {
3971
3097
  const message = vm[i];
3972
3098
  const parent = vm[i - 1];
3973
- this.repository.addOrUpdateMessage(parent?.id ?? null, message);
3099
+ this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _117 => _117.id]), () => ( null)), message);
3974
3100
  }
3975
3101
  if (this.assistantOptimisticId) {
3976
3102
  this.repository.deleteMessage(this.assistantOptimisticId);
@@ -3978,7 +3104,7 @@ var ExternalStoreThreadRuntime = class {
3978
3104
  }
3979
3105
  if (hasUpcomingMessage(isRunning, vm)) {
3980
3106
  this.assistantOptimisticId = this.repository.appendOptimisticMessage(
3981
- vm.at(-1)?.id ?? null,
3107
+ _nullishCoalesce(_optionalChain([vm, 'access', _118 => _118.at, 'call', _119 => _119(-1), 'optionalAccess', _120 => _120.id]), () => ( null)),
3982
3108
  {
3983
3109
  role: "assistant",
3984
3110
  content: []
@@ -3986,30 +3112,30 @@ var ExternalStoreThreadRuntime = class {
3986
3112
  );
3987
3113
  }
3988
3114
  this.repository.resetHead(
3989
- this.assistantOptimisticId ?? vm.at(-1)?.id ?? null
3115
+ _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([vm, 'access', _121 => _121.at, 'call', _122 => _122(-1), 'optionalAccess', _123 => _123.id]))), () => ( null))
3990
3116
  );
3991
3117
  this.messages = this.repository.getMessages();
3992
3118
  this.isDisabled = isDisabled;
3993
3119
  this.isRunning = isRunning;
3994
3120
  for (const callback of this._subscriptions) callback();
3995
- };
3996
- unstable_synchronizer = () => {
3121
+ }}
3122
+ __init25() {this.unstable_synchronizer = () => {
3997
3123
  const { store } = this.useStore();
3998
3124
  useExternalStoreSync(store, this.updateData);
3999
3125
  return null;
4000
- };
3126
+ }}
4001
3127
  addToolResult(options) {
4002
3128
  if (!this.store.onAddToolResult)
4003
3129
  throw new Error("Runtime does not support tool results.");
4004
3130
  this.store.onAddToolResult(options);
4005
3131
  }
4006
- };
3132
+ }, _class7);
4007
3133
 
4008
3134
  // src/runtimes/external-store/ExternalStoreRuntime.tsx
4009
- var ExternalStoreRuntime = class extends BaseAssistantRuntime {
4010
- _proxyConfigProvider = new ProxyConfigProvider();
3135
+ var ExternalStoreRuntime = (_class8 = class extends BaseAssistantRuntime {
3136
+ __init26() {this._proxyConfigProvider = new ProxyConfigProvider()}
4011
3137
  constructor(store) {
4012
- super(new ExternalStoreThreadRuntime(store));
3138
+ super(new ExternalStoreThreadRuntime(store));_class8.prototype.__init26.call(this);;
4013
3139
  }
4014
3140
  set store(store) {
4015
3141
  this.thread.store = store;
@@ -4034,48 +3160,51 @@ var ExternalStoreRuntime = class extends BaseAssistantRuntime {
4034
3160
  return this.store.onNewThread();
4035
3161
  }
4036
3162
  }
4037
- };
3163
+ }, _class8);
4038
3164
 
4039
3165
  // src/runtimes/external-store/useExternalStoreRuntime.tsx
4040
- var import_react57 = require("react");
3166
+
4041
3167
  var useExternalStoreRuntime = (store) => {
4042
- const [runtime] = (0, import_react57.useState)(() => new ExternalStoreRuntime(store));
4043
- (0, import_react57.useInsertionEffect)(() => {
3168
+ const [runtime] = _react.useState.call(void 0, () => new ExternalStoreRuntime(store));
3169
+ _react.useInsertionEffect.call(void 0, () => {
4044
3170
  runtime.store = store;
4045
3171
  });
4046
- (0, import_react57.useEffect)(() => {
3172
+ _react.useEffect.call(void 0, () => {
4047
3173
  runtime.onStoreUpdated();
4048
3174
  });
4049
3175
  return runtime;
4050
3176
  };
4051
3177
 
4052
3178
  // src/ui/thread-config.tsx
4053
- var import_react58 = require("react");
4054
- var import_jsx_runtime30 = require("react/jsx-runtime");
4055
- var ThreadConfigContext = (0, import_react58.createContext)({});
3179
+
3180
+
3181
+
3182
+
3183
+
3184
+ var ThreadConfigContext = _react.createContext.call(void 0, {});
4056
3185
  var useThreadConfig = () => {
4057
- return (0, import_react58.useContext)(ThreadConfigContext);
3186
+ return _react.useContext.call(void 0, ThreadConfigContext);
4058
3187
  };
4059
3188
  var ThreadConfigProvider = ({
4060
3189
  children,
4061
3190
  config
4062
3191
  }) => {
4063
3192
  const assistant = useAssistantContext({ optional: true });
4064
- const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
4065
- if (!config?.runtime) return configProvider;
3193
+ const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
3194
+ if (!_optionalChain([config, 'optionalAccess', _124 => _124.runtime])) return configProvider;
4066
3195
  if (assistant) {
4067
3196
  throw new Error(
4068
3197
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
4069
3198
  );
4070
3199
  }
4071
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
3200
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
4072
3201
  };
4073
3202
  ThreadConfigProvider.displayName = "ThreadConfigProvider";
4074
3203
 
4075
3204
  // src/ui/assistant-action-bar.tsx
4076
- var import_react59 = require("react");
4077
- var import_lucide_react = require("lucide-react");
4078
- var import_jsx_runtime31 = require("react/jsx-runtime");
3205
+
3206
+ var _lucidereact = require('lucide-react');
3207
+
4079
3208
  var useAllowCopy = () => {
4080
3209
  const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
4081
3210
  const { useThreadActions } = useThreadContext();
@@ -4092,15 +3221,15 @@ var AssistantActionBar = () => {
4092
3221
  const allowCopy = useAllowCopy();
4093
3222
  const allowReload = useAllowReload();
4094
3223
  if (!allowCopy && !allowReload) return null;
4095
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3224
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
4096
3225
  AssistantActionBarRoot,
4097
3226
  {
4098
3227
  hideWhenRunning: true,
4099
3228
  autohide: "not-last",
4100
3229
  autohideFloat: "single-branch",
4101
3230
  children: [
4102
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(AssistantActionBarCopy, {}),
4103
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(AssistantActionBarReload, {})
3231
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantActionBarCopy, {}),
3232
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantActionBarReload, {})
4104
3233
  ]
4105
3234
  }
4106
3235
  );
@@ -4110,7 +3239,7 @@ var AssistantActionBarRoot = withDefaults(actionBar_exports.Root, {
4110
3239
  className: "aui-assistant-action-bar-root"
4111
3240
  });
4112
3241
  AssistantActionBarRoot.displayName = "AssistantActionBarRoot";
4113
- var AssistantActionBarCopy = (0, import_react59.forwardRef)((props, ref) => {
3242
+ var AssistantActionBarCopy = _react.forwardRef.call(void 0, (props, ref) => {
4114
3243
  const {
4115
3244
  strings: {
4116
3245
  assistantMessage: { reload: { tooltip = "Copy" } = {} } = {}
@@ -4118,13 +3247,13 @@ var AssistantActionBarCopy = (0, import_react59.forwardRef)((props, ref) => {
4118
3247
  } = useThreadConfig();
4119
3248
  const allowCopy = useAllowCopy();
4120
3249
  if (!allowCopy) return null;
4121
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
4122
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(message_exports.If, { copied: true, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react.CheckIcon, {}) }),
4123
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(message_exports.If, { copied: false, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react.CopyIcon, {}) })
4124
- ] }) }) });
3250
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3251
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { copied: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CheckIcon, {}) }),
3252
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { copied: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CopyIcon, {}) })
3253
+ ] }))) }) });
4125
3254
  });
4126
3255
  AssistantActionBarCopy.displayName = "AssistantActionBarCopy";
4127
- var AssistantActionBarReload = (0, import_react59.forwardRef)((props, ref) => {
3256
+ var AssistantActionBarReload = _react.forwardRef.call(void 0, (props, ref) => {
4128
3257
  const {
4129
3258
  strings: {
4130
3259
  assistantMessage: { reload: { tooltip = "Refresh" } = {} } = {}
@@ -4132,26 +3261,26 @@ var AssistantActionBarReload = (0, import_react59.forwardRef)((props, ref) => {
4132
3261
  } = useThreadConfig();
4133
3262
  const allowReload = useAllowReload();
4134
3263
  if (!allowReload) return null;
4135
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(actionBar_exports.Reload, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(TooltipIconButton, { tooltip, ...props, ref, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react.RefreshCwIcon, {}) }) });
3264
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Reload, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCwIcon, {}) }) });
4136
3265
  });
4137
3266
  AssistantActionBarReload.displayName = "AssistantActionBarReload";
4138
- var exports2 = {
3267
+ var exports = {
4139
3268
  Root: AssistantActionBarRoot,
4140
3269
  Reload: AssistantActionBarReload,
4141
3270
  Copy: AssistantActionBarCopy
4142
3271
  };
4143
3272
  var assistant_action_bar_default = Object.assign(
4144
3273
  AssistantActionBar,
4145
- exports2
3274
+ exports
4146
3275
  );
4147
3276
 
4148
3277
  // src/ui/assistant-message.tsx
4149
- var import_react61 = require("react");
3278
+
4150
3279
 
4151
3280
  // src/ui/branch-picker.tsx
4152
- var import_react60 = require("react");
4153
- var import_lucide_react2 = require("lucide-react");
4154
- var import_jsx_runtime32 = require("react/jsx-runtime");
3281
+
3282
+
3283
+
4155
3284
  var useAllowBranchPicker = () => {
4156
3285
  const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
4157
3286
  const { useThreadActions } = useThreadContext();
@@ -4161,10 +3290,10 @@ var useAllowBranchPicker = () => {
4161
3290
  var BranchPicker = () => {
4162
3291
  const allowBranchPicker = useAllowBranchPicker();
4163
3292
  if (!allowBranchPicker) return null;
4164
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
4165
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(BranchPickerPrevious2, {}),
4166
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(BranchPickerState, {}),
4167
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(BranchPickerNext, {})
3293
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, BranchPickerRoot, { hideWhenSingleBranch: true, children: [
3294
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerPrevious2, {}),
3295
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerState, {}),
3296
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerNext, {})
4168
3297
  ] });
4169
3298
  };
4170
3299
  BranchPicker.displayName = "BranchPicker";
@@ -4172,48 +3301,48 @@ var BranchPickerRoot = withDefaults(branchPicker_exports.Root, {
4172
3301
  className: "aui-branch-picker-root"
4173
3302
  });
4174
3303
  BranchPickerRoot.displayName = "BranchPickerRoot";
4175
- var BranchPickerPrevious2 = (0, import_react60.forwardRef)((props, ref) => {
3304
+ var BranchPickerPrevious2 = _react.forwardRef.call(void 0, (props, ref) => {
4176
3305
  const {
4177
3306
  strings: {
4178
3307
  branchPicker: { previous: { tooltip = "Previous" } = {} } = {}
4179
3308
  } = {}
4180
3309
  } = useThreadConfig();
4181
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(branchPicker_exports.Previous, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react2.ChevronLeftIcon, {}) }) });
3310
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Previous, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon, {}))) }) });
4182
3311
  });
4183
3312
  BranchPickerPrevious2.displayName = "BranchPickerPrevious";
4184
3313
  var BranchPickerStateWrapper = withDefaults("span", {
4185
3314
  className: "aui-branch-picker-state"
4186
3315
  });
4187
- var BranchPickerState = (0, import_react60.forwardRef)((props, ref) => {
4188
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(BranchPickerStateWrapper, { ...props, ref, children: [
4189
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(branchPicker_exports.Number, {}),
3316
+ var BranchPickerState = _react.forwardRef.call(void 0, (props, ref) => {
3317
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, BranchPickerStateWrapper, { ...props, ref, children: [
3318
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Number, {}),
4190
3319
  " / ",
4191
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(branchPicker_exports.Count, {})
3320
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Count, {})
4192
3321
  ] });
4193
3322
  });
4194
3323
  BranchPickerState.displayName = "BranchPickerState";
4195
- var BranchPickerNext = (0, import_react60.forwardRef)((props, ref) => {
3324
+ var BranchPickerNext = _react.forwardRef.call(void 0, (props, ref) => {
4196
3325
  const {
4197
3326
  strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {}
4198
3327
  } = useThreadConfig();
4199
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(branchPicker_exports.Next, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react2.ChevronRightIcon, {}) }) });
3328
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Next, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ChevronRightIcon, {}))) }) });
4200
3329
  });
4201
3330
  BranchPickerNext.displayName = "BranchPickerNext";
4202
- var exports3 = {
3331
+ var exports2 = {
4203
3332
  Root: BranchPickerRoot,
4204
3333
  Previous: BranchPickerPrevious2,
4205
3334
  Next: BranchPickerNext
4206
3335
  };
4207
- var branch_picker_default = Object.assign(BranchPicker, exports3);
3336
+ var branch_picker_default = Object.assign(BranchPicker, exports2);
4208
3337
 
4209
3338
  // src/ui/base/avatar.tsx
4210
- var AvatarPrimitive = __toESM(require("@radix-ui/react-avatar"));
4211
- var import_jsx_runtime33 = require("react/jsx-runtime");
3339
+ var _reactavatar = require('@radix-ui/react-avatar'); var AvatarPrimitive = _interopRequireWildcard(_reactavatar);
3340
+
4212
3341
  var Avatar = ({ src, alt, fallback }) => {
4213
3342
  if (src == null && fallback == null) return null;
4214
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(AvatarRoot, { children: [
4215
- src != null && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(AvatarImage, { src, alt }),
4216
- fallback != null && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(AvatarFallback, { children: fallback })
3343
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AvatarRoot, { children: [
3344
+ src != null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AvatarImage, { src, alt }),
3345
+ fallback != null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AvatarFallback, { children: fallback })
4217
3346
  ] });
4218
3347
  };
4219
3348
  Avatar.displayName = "Avatar";
@@ -4231,14 +3360,14 @@ var AvatarFallback = withDefaults(AvatarPrimitive.Fallback, {
4231
3360
  AvatarFallback.displayName = "AvatarFallback";
4232
3361
 
4233
3362
  // src/ui/content-part.tsx
4234
- var import_classnames2 = __toESM(require("classnames"));
4235
- var import_jsx_runtime34 = require("react/jsx-runtime");
3363
+
3364
+
4236
3365
  var Text = () => {
4237
3366
  const status = useSmoothStatus();
4238
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3367
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4239
3368
  contentPart_exports.Text,
4240
3369
  {
4241
- className: (0, import_classnames2.default)(
3370
+ className: _classnames2.default.call(void 0,
4242
3371
  "aui-text",
4243
3372
  status.type === "running" && "aui-text-running"
4244
3373
  ),
@@ -4246,23 +3375,23 @@ var Text = () => {
4246
3375
  }
4247
3376
  );
4248
3377
  };
4249
- var exports4 = { Text: withSmoothContextProvider(Text) };
4250
- var content_part_default = exports4;
3378
+ var exports3 = { Text: withSmoothContextProvider(Text) };
3379
+ var content_part_default = exports3;
4251
3380
 
4252
3381
  // src/ui/assistant-message.tsx
4253
- var import_jsx_runtime35 = require("react/jsx-runtime");
3382
+
4254
3383
  var AssistantMessage = () => {
4255
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(AssistantMessageRoot, { children: [
4256
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AssistantMessageAvatar, {}),
4257
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AssistantMessageContent, {}),
4258
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(branch_picker_default, {}),
4259
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(assistant_action_bar_default, {})
3384
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AssistantMessageRoot, { children: [
3385
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessageAvatar, {}),
3386
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessageContent, {}),
3387
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branch_picker_default, {}),
3388
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, assistant_action_bar_default, {})
4260
3389
  ] });
4261
3390
  };
4262
3391
  AssistantMessage.displayName = "AssistantMessage";
4263
3392
  var AssistantMessageAvatar = () => {
4264
3393
  const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
4265
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Avatar, { ...avatar });
3394
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Avatar, { ...avatar });
4266
3395
  };
4267
3396
  var AssistantMessageRoot = withDefaults(message_exports.Root, {
4268
3397
  className: "aui-assistant-message-root"
@@ -4271,62 +3400,62 @@ AssistantMessageRoot.displayName = "AssistantMessageRoot";
4271
3400
  var AssistantMessageContentWrapper = withDefaults("div", {
4272
3401
  className: "aui-assistant-message-content"
4273
3402
  });
4274
- var AssistantMessageContent = (0, import_react61.forwardRef)(({ components: componentsProp, ...rest }, ref) => {
3403
+ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: componentsProp, ...rest }, ref) => {
4275
3404
  const { assistantMessage: { components = {} } = {} } = useThreadConfig();
4276
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3405
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4277
3406
  message_exports.Content,
4278
3407
  {
4279
3408
  components: {
4280
3409
  ...componentsProp,
4281
- Text: componentsProp?.Text ?? components.Text ?? content_part_default.Text
3410
+ Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _125 => _125.Text]), () => ( components.Text)), () => ( content_part_default.Text))
4282
3411
  }
4283
3412
  }
4284
3413
  ) });
4285
3414
  });
4286
3415
  AssistantMessageContent.displayName = "AssistantMessageContent";
4287
- var exports5 = {
3416
+ var exports4 = {
4288
3417
  Root: AssistantMessageRoot,
4289
3418
  Avatar: AssistantMessageAvatar,
4290
3419
  Content: AssistantMessageContent
4291
3420
  };
4292
3421
  var assistant_message_default = Object.assign(
4293
3422
  AssistantMessage,
4294
- exports5
3423
+ exports4
4295
3424
  );
4296
3425
 
4297
3426
  // src/ui/assistant-modal.tsx
4298
- var import_react68 = require("react");
4299
- var import_lucide_react6 = require("lucide-react");
3427
+
3428
+
4300
3429
 
4301
3430
  // src/ui/thread.tsx
4302
- var import_react67 = require("react");
4303
- var import_lucide_react5 = require("lucide-react");
3431
+
3432
+
4304
3433
 
4305
3434
  // src/ui/composer.tsx
4306
- var import_react62 = require("react");
4307
- var import_lucide_react3 = require("lucide-react");
3435
+
3436
+
4308
3437
 
4309
3438
  // src/ui/base/CircleStopIcon.tsx
4310
- var import_jsx_runtime36 = require("react/jsx-runtime");
3439
+
4311
3440
  var CircleStopIcon = () => {
4312
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3441
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4313
3442
  "svg",
4314
3443
  {
4315
3444
  xmlns: "http://www.w3.org/2000/svg",
4316
3445
  viewBox: "0 0 16 16",
4317
3446
  fill: "currentColor",
4318
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
3447
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
4319
3448
  }
4320
3449
  );
4321
3450
  };
4322
3451
  CircleStopIcon.displayName = "CircleStopIcon";
4323
3452
 
4324
3453
  // src/ui/composer.tsx
4325
- var import_jsx_runtime37 = require("react/jsx-runtime");
3454
+
4326
3455
  var Composer = () => {
4327
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(ComposerRoot, { children: [
4328
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ComposerInput, { autoFocus: true }),
4329
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ComposerAction, {})
3456
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ComposerRoot, { children: [
3457
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerInput, { autoFocus: true }),
3458
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAction, {})
4330
3459
  ] });
4331
3460
  };
4332
3461
  Composer.displayName = "Composer";
@@ -4339,14 +3468,14 @@ var ComposerInputStyled = withDefaults(composer_exports.Input, {
4339
3468
  autoFocus: true,
4340
3469
  className: "aui-composer-input"
4341
3470
  });
4342
- var ComposerInput = (0, import_react62.forwardRef)(
3471
+ var ComposerInput = _react.forwardRef.call(void 0,
4343
3472
  (props, ref) => {
4344
3473
  const {
4345
3474
  strings: {
4346
3475
  composer: { input: { placeholder = "Write a message..." } = {} } = {}
4347
3476
  } = {}
4348
3477
  } = useThreadConfig();
4349
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ComposerInputStyled, { placeholder, ...props, ref });
3478
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerInputStyled, { placeholder, ...props, ref });
4350
3479
  }
4351
3480
  );
4352
3481
  ComposerInput.displayName = "ComposerInput";
@@ -4357,10 +3486,10 @@ var useAllowCancel = () => {
4357
3486
  };
4358
3487
  var ComposerAction = () => {
4359
3488
  const allowCancel = useAllowCancel();
4360
- if (!allowCancel) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ComposerSend, {});
4361
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
4362
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(thread_exports.If, { running: false, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ComposerSend, {}) }),
4363
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(thread_exports.If, { running: true, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ComposerCancel, {}) })
3489
+ if (!allowCancel) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerSend, {});
3490
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3491
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerSend, {}) }),
3492
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { running: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerCancel, {}) })
4364
3493
  ] });
4365
3494
  };
4366
3495
  ComposerAction.displayName = "ComposerAction";
@@ -4368,43 +3497,43 @@ var ComposerSendButton = withDefaults(TooltipIconButton, {
4368
3497
  variant: "default",
4369
3498
  className: "aui-composer-send"
4370
3499
  });
4371
- var ComposerSend = (0, import_react62.forwardRef)((props, ref) => {
3500
+ var ComposerSend = _react.forwardRef.call(void 0, (props, ref) => {
4372
3501
  const {
4373
3502
  strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
4374
3503
  } = useThreadConfig();
4375
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_lucide_react3.SendHorizontalIcon, {}) }) });
3504
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Send, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerSendButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.SendHorizontalIcon, {}))) }) });
4376
3505
  });
4377
3506
  ComposerSend.displayName = "ComposerSend";
4378
3507
  var ComposerCancelButton = withDefaults(TooltipIconButton, {
4379
3508
  variant: "default",
4380
3509
  className: "aui-composer-cancel"
4381
3510
  });
4382
- var ComposerCancel = (0, import_react62.forwardRef)((props, ref) => {
3511
+ var ComposerCancel = _react.forwardRef.call(void 0, (props, ref) => {
4383
3512
  const {
4384
3513
  strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
4385
3514
  } = useThreadConfig();
4386
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CircleStopIcon, {}) }) });
3515
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerCancelButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleStopIcon, {}))) }) });
4387
3516
  });
4388
3517
  ComposerCancel.displayName = "ComposerCancel";
4389
- var exports6 = {
3518
+ var exports5 = {
4390
3519
  Root: ComposerRoot,
4391
3520
  Input: ComposerInput,
4392
3521
  Action: ComposerAction,
4393
3522
  Send: ComposerSend,
4394
3523
  Cancel: ComposerCancel
4395
3524
  };
4396
- var composer_default = Object.assign(Composer, exports6);
3525
+ var composer_default = Object.assign(Composer, exports5);
4397
3526
 
4398
3527
  // src/ui/thread-welcome.tsx
4399
- var import_react63 = require("react");
4400
- var import_jsx_runtime38 = require("react/jsx-runtime");
3528
+
3529
+
4401
3530
  var ThreadWelcome = () => {
4402
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(ThreadWelcomeRoot, { children: [
4403
- /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(ThreadWelcomeCenter, { children: [
4404
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ThreadWelcomeAvatar, {}),
4405
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ThreadWelcomeMessage, {})
3531
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadWelcomeRoot, { children: [
3532
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadWelcomeCenter, { children: [
3533
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeAvatar, {}),
3534
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeMessage, {})
4406
3535
  ] }),
4407
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ThreadWelcomeSuggestions, {})
3536
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestions, {})
4408
3537
  ] });
4409
3538
  };
4410
3539
  ThreadWelcome.displayName = "ThreadWelcome";
@@ -4414,22 +3543,22 @@ var ThreadWelcomeRootStyled = withDefaults("div", {
4414
3543
  var ThreadWelcomeCenter = withDefaults("div", {
4415
3544
  className: "aui-thread-welcome-center"
4416
3545
  });
4417
- var ThreadWelcomeRoot = (0, import_react63.forwardRef)(
3546
+ var ThreadWelcomeRoot = _react.forwardRef.call(void 0,
4418
3547
  (props, ref) => {
4419
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(thread_exports.Empty, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ThreadWelcomeRootStyled, { ...props, ref }) });
3548
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.Empty, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeRootStyled, { ...props, ref }) });
4420
3549
  }
4421
3550
  );
4422
3551
  ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
4423
3552
  var ThreadWelcomeAvatar = () => {
4424
3553
  const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
4425
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Avatar, { ...avatar });
3554
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Avatar, { ...avatar });
4426
3555
  };
4427
3556
  var ThreadWelcomeMessageStyled = withDefaults("p", {
4428
3557
  className: "aui-thread-welcome-message"
4429
3558
  });
4430
- var ThreadWelcomeMessage = (0, import_react63.forwardRef)(({ message: messageProp, ...rest }, ref) => {
3559
+ var ThreadWelcomeMessage = _react.forwardRef.call(void 0, ({ message: messageProp, ...rest }, ref) => {
4431
3560
  const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
4432
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
3561
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeMessageStyled, { ...rest, ref, children: _nullishCoalesce(messageProp, () => ( message)) });
4433
3562
  });
4434
3563
  ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
4435
3564
  var ThreadWelcomeSuggestionContainer = withDefaults("div", {
@@ -4441,25 +3570,25 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
4441
3570
  var ThreadWelcomeSuggestion = ({
4442
3571
  suggestion: { text, prompt }
4443
3572
  }) => {
4444
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3573
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4445
3574
  ThreadWelcomeSuggestionStyled,
4446
3575
  {
4447
3576
  prompt,
4448
3577
  method: "replace",
4449
3578
  autoSend: true,
4450
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
3579
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-thread-welcome-suggestion-text", children: _nullishCoalesce(text, () => ( prompt)) })
4451
3580
  }
4452
3581
  );
4453
3582
  };
4454
3583
  var ThreadWelcomeSuggestions = () => {
4455
3584
  const { welcome: { suggestions } = {} } = useThreadConfig();
4456
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ThreadWelcomeSuggestionContainer, { children: suggestions?.map((suggestion, idx) => {
3585
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _126 => _126.map, 'call', _127 => _127((suggestion, idx) => {
4457
3586
  const key = `${suggestion.prompt}-${idx}`;
4458
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ThreadWelcomeSuggestion, { suggestion }, key);
4459
- }) });
3587
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
3588
+ })]) });
4460
3589
  };
4461
3590
  ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
4462
- var exports7 = {
3591
+ var exports6 = {
4463
3592
  Root: ThreadWelcomeRoot,
4464
3593
  Center: ThreadWelcomeCenter,
4465
3594
  Avatar: ThreadWelcomeAvatar,
@@ -4467,15 +3596,15 @@ var exports7 = {
4467
3596
  Suggestions: ThreadWelcomeSuggestions,
4468
3597
  Suggestion: ThreadWelcomeSuggestion
4469
3598
  };
4470
- var thread_welcome_default = Object.assign(ThreadWelcome, exports7);
3599
+ var thread_welcome_default = Object.assign(ThreadWelcome, exports6);
4471
3600
 
4472
3601
  // src/ui/user-message.tsx
4473
- var import_react65 = require("react");
3602
+
4474
3603
 
4475
3604
  // src/ui/user-action-bar.tsx
4476
- var import_react64 = require("react");
4477
- var import_lucide_react4 = require("lucide-react");
4478
- var import_jsx_runtime39 = require("react/jsx-runtime");
3605
+
3606
+
3607
+
4479
3608
  var useAllowEdit = () => {
4480
3609
  const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
4481
3610
  const { useThreadActions } = useThreadContext();
@@ -4485,35 +3614,35 @@ var useAllowEdit = () => {
4485
3614
  var UserActionBar = () => {
4486
3615
  const allowEdit = useAllowEdit();
4487
3616
  if (!allowEdit) return null;
4488
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(UserActionBarEdit, {}) });
3617
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserActionBarEdit, {}) });
4489
3618
  };
4490
3619
  UserActionBar.displayName = "UserActionBar";
4491
3620
  var UserActionBarRoot = withDefaults(actionBar_exports.Root, {
4492
3621
  className: "aui-user-action-bar-root"
4493
3622
  });
4494
3623
  UserActionBarRoot.displayName = "UserActionBarRoot";
4495
- var UserActionBarEdit = (0, import_react64.forwardRef)((props, ref) => {
3624
+ var UserActionBarEdit = _react.forwardRef.call(void 0, (props, ref) => {
4496
3625
  const {
4497
3626
  strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
4498
3627
  } = useThreadConfig();
4499
3628
  const allowEdit = useAllowEdit();
4500
3629
  if (!allowEdit) return null;
4501
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(actionBar_exports.Edit, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react4.PencilIcon, {}) }) });
3630
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Edit, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.PencilIcon, {}))) }) });
4502
3631
  });
4503
3632
  UserActionBarEdit.displayName = "UserActionBarEdit";
4504
- var exports8 = {
3633
+ var exports7 = {
4505
3634
  Root: UserActionBarRoot,
4506
3635
  Edit: UserActionBarEdit
4507
3636
  };
4508
- var user_action_bar_default = Object.assign(UserActionBar, exports8);
3637
+ var user_action_bar_default = Object.assign(UserActionBar, exports7);
4509
3638
 
4510
3639
  // src/ui/user-message.tsx
4511
- var import_jsx_runtime40 = require("react/jsx-runtime");
3640
+
4512
3641
  var UserMessage = () => {
4513
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(UserMessageRoot, { children: [
4514
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(user_action_bar_default, {}),
4515
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(UserMessageContent, {}),
4516
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(branch_picker_default, {})
3642
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageRoot, { children: [
3643
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, user_action_bar_default, {}),
3644
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContent, {}),
3645
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branch_picker_default, {})
4517
3646
  ] });
4518
3647
  };
4519
3648
  UserMessage.displayName = "UserMessage";
@@ -4524,35 +3653,35 @@ UserMessageRoot.displayName = "UserMessageRoot";
4524
3653
  var UserMessageContentWrapper = withDefaults("div", {
4525
3654
  className: "aui-user-message-content"
4526
3655
  });
4527
- var UserMessageContent = (0, import_react65.forwardRef)(
3656
+ var UserMessageContent = _react.forwardRef.call(void 0,
4528
3657
  ({ components, ...props }, ref) => {
4529
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3658
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4530
3659
  message_exports.Content,
4531
3660
  {
4532
3661
  components: {
4533
3662
  ...components,
4534
- Text: components?.Text ?? content_part_default.Text
3663
+ Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _128 => _128.Text]), () => ( content_part_default.Text))
4535
3664
  }
4536
3665
  }
4537
3666
  ) });
4538
3667
  }
4539
3668
  );
4540
3669
  UserMessageContent.displayName = "UserMessageContent";
4541
- var exports9 = {
3670
+ var exports8 = {
4542
3671
  Root: UserMessageRoot,
4543
3672
  Content: UserMessageContent
4544
3673
  };
4545
- var user_message_default = Object.assign(UserMessage, exports9);
3674
+ var user_message_default = Object.assign(UserMessage, exports8);
4546
3675
 
4547
3676
  // src/ui/edit-composer.tsx
4548
- var import_react66 = require("react");
4549
- var import_jsx_runtime41 = require("react/jsx-runtime");
3677
+
3678
+
4550
3679
  var EditComposer = () => {
4551
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(EditComposerRoot, { children: [
4552
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(EditComposerInput, {}),
4553
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(EditComposerFooter, { children: [
4554
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(EditComposerCancel, {}),
4555
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(EditComposerSend, {})
3680
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, EditComposerRoot, { children: [
3681
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposerInput, {}),
3682
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, EditComposerFooter, { children: [
3683
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposerCancel, {}),
3684
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposerSend, {})
4556
3685
  ] })
4557
3686
  ] });
4558
3687
  };
@@ -4569,53 +3698,53 @@ var EditComposerFooter = withDefaults("div", {
4569
3698
  className: "aui-edit-composer-footer"
4570
3699
  });
4571
3700
  EditComposerFooter.displayName = "EditComposerFooter";
4572
- var EditComposerCancel = (0, import_react66.forwardRef)(
3701
+ var EditComposerCancel = _react.forwardRef.call(void 0,
4573
3702
  (props, ref) => {
4574
3703
  const {
4575
3704
  strings: {
4576
3705
  editComposer: { cancel: { label = "Cancel" } = {} } = {}
4577
3706
  } = {}
4578
3707
  } = useThreadConfig();
4579
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
3708
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { variant: "ghost", ...props, ref, children: _nullishCoalesce(props.children, () => ( label)) }) });
4580
3709
  }
4581
3710
  );
4582
3711
  EditComposerCancel.displayName = "EditComposerCancel";
4583
- var EditComposerSend = (0, import_react66.forwardRef)(
3712
+ var EditComposerSend = _react.forwardRef.call(void 0,
4584
3713
  (props, ref) => {
4585
3714
  const {
4586
3715
  strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
4587
3716
  } = useThreadConfig();
4588
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { ...props, ref, children: props.children ?? label }) });
3717
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Send, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { ...props, ref, children: _nullishCoalesce(props.children, () => ( label)) }) });
4589
3718
  }
4590
3719
  );
4591
3720
  EditComposerSend.displayName = "EditComposerSend";
4592
- var exports10 = {
3721
+ var exports9 = {
4593
3722
  Root: EditComposerRoot,
4594
3723
  Input: EditComposerInput,
4595
3724
  Footer: EditComposerFooter,
4596
3725
  Cancel: EditComposerCancel,
4597
3726
  Send: EditComposerSend
4598
3727
  };
4599
- var edit_composer_default = Object.assign(EditComposer, exports10);
3728
+ var edit_composer_default = Object.assign(EditComposer, exports9);
4600
3729
 
4601
3730
  // src/ui/thread.tsx
4602
- var import_jsx_runtime42 = require("react/jsx-runtime");
3731
+
4603
3732
  var Thread = (config) => {
4604
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ThreadRoot, { config, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(ThreadViewport, { children: [
4605
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(thread_welcome_default, {}),
4606
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ThreadMessages, {}),
4607
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(ThreadViewportFooter, { children: [
4608
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ThreadScrollToBottom, {}),
4609
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(composer_default, {})
3733
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRoot, { config, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewport, { children: [
3734
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_welcome_default, {}),
3735
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessages, {}),
3736
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewportFooter, { children: [
3737
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadScrollToBottom, {}),
3738
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_default, {})
4610
3739
  ] })
4611
3740
  ] }) });
4612
3741
  };
4613
3742
  var ThreadRootStyled = withDefaults(thread_exports.Root, {
4614
3743
  className: "aui-root aui-thread-root"
4615
3744
  });
4616
- var ThreadRoot = (0, import_react67.forwardRef)(
3745
+ var ThreadRoot = _react.forwardRef.call(void 0,
4617
3746
  ({ config, ...props }, ref) => {
4618
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ThreadConfigProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ThreadRootStyled, { ...props, ref }) });
3747
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigProvider, { config, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRootStyled, { ...props, ref }) });
4619
3748
  }
4620
3749
  );
4621
3750
  ThreadRoot.displayName = "ThreadRoot";
@@ -4629,14 +3758,14 @@ var ThreadViewportFooter = withDefaults("div", {
4629
3758
  ThreadViewportFooter.displayName = "ThreadViewportFooter";
4630
3759
  var SystemMessage = () => null;
4631
3760
  var ThreadMessages = ({ components, ...rest }) => {
4632
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
3761
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4633
3762
  thread_exports.Messages,
4634
3763
  {
4635
3764
  components: {
4636
- UserMessage: components?.UserMessage ?? user_message_default,
4637
- EditComposer: components?.EditComposer ?? edit_composer_default,
4638
- AssistantMessage: components?.AssistantMessage ?? assistant_message_default,
4639
- SystemMessage: components?.SystemMessage ?? SystemMessage
3765
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _129 => _129.UserMessage]), () => ( user_message_default)),
3766
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _130 => _130.EditComposer]), () => ( edit_composer_default)),
3767
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _131 => _131.AssistantMessage]), () => ( assistant_message_default)),
3768
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _132 => _132.SystemMessage]), () => ( SystemMessage))
4640
3769
  },
4641
3770
  ...rest
4642
3771
  }
@@ -4647,39 +3776,39 @@ var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
4647
3776
  variant: "outline",
4648
3777
  className: "aui-thread-scroll-to-bottom"
4649
3778
  });
4650
- var ThreadScrollToBottom = (0, import_react67.forwardRef)((props, ref) => {
3779
+ var ThreadScrollToBottom = _react.forwardRef.call(void 0, (props, ref) => {
4651
3780
  const {
4652
3781
  strings: {
4653
3782
  thread: { scrollToBottom: { tooltip = "Scroll to bottom" } = {} } = {}
4654
3783
  } = {}
4655
3784
  } = useThreadConfig();
4656
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react5.ArrowDownIcon, {}) }) });
3785
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArrowDownIcon, {}))) }) });
4657
3786
  });
4658
3787
  ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
4659
- var exports11 = {
3788
+ var exports10 = {
4660
3789
  Root: ThreadRoot,
4661
3790
  Viewport: ThreadViewport,
4662
3791
  Messages: ThreadMessages,
4663
3792
  ScrollToBottom: ThreadScrollToBottom,
4664
3793
  ViewportFooter: ThreadViewportFooter
4665
3794
  };
4666
- var thread_default = Object.assign(Thread, exports11);
3795
+ var thread_default = Object.assign(Thread, exports10);
4667
3796
 
4668
3797
  // src/ui/assistant-modal.tsx
4669
- var import_jsx_runtime43 = require("react/jsx-runtime");
3798
+
4670
3799
  var AssistantModal = (config) => {
4671
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(AssistantModalRoot, { config, children: [
4672
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AssistantModalTrigger, {}),
4673
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AssistantModalContent, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(thread_default, {}) })
3800
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AssistantModalRoot, { config, children: [
3801
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantModalTrigger, {}),
3802
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantModalContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_default, {}) })
4674
3803
  ] });
4675
3804
  };
4676
3805
  AssistantModal.displayName = "AssistantModal";
4677
3806
  var AssistantModalRoot = ({ config, ...props }) => {
4678
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ThreadConfigProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(assistantModal_exports.Root, { ...props }) });
3807
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigProvider, { config, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, assistantModal_exports.Root, { ...props }) });
4679
3808
  };
4680
3809
  AssistantModalRoot.displayName = "AssistantModalRoot";
4681
- var AssistantModalTrigger = (0, import_react68.forwardRef)((props, ref) => {
4682
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AssistantModalAnchor, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AssistantModalButton, { ...props, ref }) }) });
3810
+ var AssistantModalTrigger = _react.forwardRef.call(void 0, (props, ref) => {
3811
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantModalAnchor, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantModalButton, { ...props, ref }) }) });
4683
3812
  });
4684
3813
  AssistantModalTrigger.displayName = "AssistantModalTrigger";
4685
3814
  var AssistantModalAnchor = withDefaults(assistantModal_exports.Anchor, {
@@ -4690,7 +3819,7 @@ var ModalButtonStyled = withDefaults(TooltipIconButton, {
4690
3819
  variant: "default",
4691
3820
  className: "aui-modal-button"
4692
3821
  });
4693
- var AssistantModalButton = (0, import_react68.forwardRef)(({ "data-state": state, ...rest }, ref) => {
3822
+ var AssistantModalButton = _react.forwardRef.call(void 0, ({ "data-state": state, ...rest }, ref) => {
4694
3823
  const {
4695
3824
  strings: {
4696
3825
  assistantModal: {
@@ -4704,7 +3833,7 @@ var AssistantModalButton = (0, import_react68.forwardRef)(({ "data-state": state
4704
3833
  } = {}
4705
3834
  } = useThreadConfig();
4706
3835
  const tooltip = state === "open" ? openTooltip : closedTooltip;
4707
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
3836
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4708
3837
  ModalButtonStyled,
4709
3838
  {
4710
3839
  side: "left",
@@ -4712,22 +3841,22 @@ var AssistantModalButton = (0, import_react68.forwardRef)(({ "data-state": state
4712
3841
  "data-state": state,
4713
3842
  ...rest,
4714
3843
  ref,
4715
- children: rest.children ?? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
4716
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4717
- import_lucide_react6.BotIcon,
3844
+ children: _nullishCoalesce(rest.children, () => ( /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3845
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3846
+ _lucidereact.BotIcon,
4718
3847
  {
4719
3848
  "data-state": state,
4720
3849
  className: "aui-modal-button-closed-icon"
4721
3850
  }
4722
3851
  ),
4723
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4724
- import_lucide_react6.ChevronDownIcon,
3852
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3853
+ _lucidereact.ChevronDownIcon,
4725
3854
  {
4726
3855
  "data-state": state,
4727
3856
  className: "aui-modal-button-open-icon"
4728
3857
  }
4729
3858
  )
4730
- ] })
3859
+ ] })))
4731
3860
  }
4732
3861
  );
4733
3862
  });
@@ -4737,79 +3866,78 @@ var AssistantModalContent = withDefaults(assistantModal_exports.Content, {
4737
3866
  sideOffset: 16
4738
3867
  });
4739
3868
  AssistantModalContent.displayName = "AssistantModalContent";
4740
- var exports12 = {
3869
+ var exports11 = {
4741
3870
  Root: AssistantModalRoot,
4742
3871
  Trigger: AssistantModalTrigger,
4743
3872
  Content: AssistantModalContent
4744
3873
  };
4745
- var assistant_modal_default = Object.assign(AssistantModal, exports12);
4746
- // Annotate the CommonJS export names for ESM import in node:
4747
- 0 && (module.exports = {
4748
- ActionBarPrimitive,
4749
- AssistantActionBar,
4750
- AssistantMessage,
4751
- AssistantModal,
4752
- AssistantModalPrimitive,
4753
- AssistantRuntimeProvider,
4754
- BranchPicker,
4755
- BranchPickerPrimitive,
4756
- Composer,
4757
- ComposerPrimitive,
4758
- ContentPart,
4759
- ContentPartPrimitive,
4760
- EdgeChatAdapter,
4761
- EditComposer,
4762
- ExternalStoreRuntime,
4763
- INTERNAL,
4764
- MessagePrimitive,
4765
- Thread,
4766
- ThreadConfigProvider,
4767
- ThreadPrimitive,
4768
- ThreadWelcome,
4769
- UserActionBar,
4770
- UserMessage,
4771
- fromCoreMessage,
4772
- fromCoreMessages,
4773
- fromLanguageModelMessages,
4774
- fromLanguageModelTools,
4775
- getExternalStoreMessage,
4776
- makeAssistantTool,
4777
- makeAssistantToolUI,
4778
- toCoreMessage,
4779
- toCoreMessages,
4780
- toLanguageModelMessages,
4781
- toLanguageModelTools,
4782
- useActionBarCopy,
4783
- useActionBarEdit,
4784
- useActionBarReload,
4785
- useAppendMessage,
4786
- useAssistantContext,
4787
- useAssistantInstructions,
4788
- useAssistantTool,
4789
- useAssistantToolUI,
4790
- useBranchPickerCount,
4791
- useBranchPickerNext,
4792
- useBranchPickerNumber,
4793
- useBranchPickerPrevious,
4794
- useComposerCancel,
4795
- useComposerContext,
4796
- useComposerIf,
4797
- useComposerSend,
4798
- useContentPartContext,
4799
- useContentPartDisplay,
4800
- useContentPartImage,
4801
- useContentPartText,
4802
- useEdgeRuntime,
4803
- useExternalStoreRuntime,
4804
- useLocalRuntime,
4805
- useMessageContext,
4806
- useMessageIf,
4807
- useSwitchToNewThread,
4808
- useThreadConfig,
4809
- useThreadContext,
4810
- useThreadEmpty,
4811
- useThreadIf,
4812
- useThreadScrollToBottom,
4813
- useThreadSuggestion
4814
- });
3874
+ var assistant_modal_default = Object.assign(AssistantModal, exports11);
3875
+
3876
+
3877
+
3878
+
3879
+
3880
+
3881
+
3882
+
3883
+
3884
+
3885
+
3886
+
3887
+
3888
+
3889
+
3890
+
3891
+
3892
+
3893
+
3894
+
3895
+
3896
+
3897
+
3898
+
3899
+
3900
+
3901
+
3902
+
3903
+
3904
+
3905
+
3906
+
3907
+
3908
+
3909
+
3910
+
3911
+
3912
+
3913
+
3914
+
3915
+
3916
+
3917
+
3918
+
3919
+
3920
+
3921
+
3922
+
3923
+
3924
+
3925
+
3926
+
3927
+
3928
+
3929
+
3930
+
3931
+
3932
+
3933
+
3934
+
3935
+
3936
+
3937
+
3938
+
3939
+
3940
+
3941
+
3942
+ exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerPrimitive = composer_exports; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.toCoreMessage = _chunkNSPHKRLFjs.toCoreMessage; exports.toCoreMessages = _chunkNSPHKRLFjs.toCoreMessages; exports.toLanguageModelMessages = _chunkNSPHKRLFjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkNSPHKRLFjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarReload = useActionBarReload; exports.useAppendMessage = useAppendMessage; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartText = useContentPartText; exports.useEdgeRuntime = useEdgeRuntime; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadSuggestion = useThreadSuggestion;
4815
3943
  //# sourceMappingURL=index.js.map