@copilotkit/react-textarea 0.35.0-function-calling-fixes.2 → 0.35.0-mme-cloud.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/.turbo/turbo-build.log +428 -432
  2. package/CHANGELOG.md +8 -20
  3. package/dist/{chunk-VPEH6V7T.mjs → chunk-FMQG2ZM3.mjs} +1 -1
  4. package/dist/chunk-FMQG2ZM3.mjs.map +1 -0
  5. package/dist/{chunk-SP5HFO3H.mjs → chunk-HWM2CVKO.mjs} +2 -2
  6. package/dist/{chunk-22TYLEZZ.mjs → chunk-XU5Z5BWV.mjs} +2 -2
  7. package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
  8. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +36 -1752
  9. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
  10. package/dist/components/base-copilot-textarea/render-element.mjs +4 -48
  11. package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
  12. package/dist/components/base-copilot-textarea/render-placeholder.mjs +4 -46
  13. package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
  14. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +5 -83
  15. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
  16. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +4 -54
  17. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
  18. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  19. package/dist/components/copilot-textarea/copilot-textarea.mjs +45 -2196
  20. package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
  21. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +5 -13
  22. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
  23. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +8 -130
  24. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
  25. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +19 -876
  26. package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
  27. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +14 -569
  28. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
  29. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +15 -592
  30. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
  31. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +7 -98
  32. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
  33. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +16 -592
  34. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
  35. package/dist/components/index.js.map +1 -1
  36. package/dist/components/index.mjs +48 -2196
  37. package/dist/components/index.mjs.map +1 -1
  38. package/dist/components/manual-ui/chip-with-icon.mjs +2 -0
  39. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  40. package/dist/components/source-search-box/source-search-box.mjs +8 -207
  41. package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
  42. package/dist/components/ui/button.mjs +6 -81
  43. package/dist/components/ui/button.mjs.map +1 -1
  44. package/dist/components/ui/card.mjs +7 -42
  45. package/dist/components/ui/card.mjs.map +1 -1
  46. package/dist/components/ui/command.mjs +14 -232
  47. package/dist/components/ui/command.mjs.map +1 -1
  48. package/dist/components/ui/dialog.mjs +11 -134
  49. package/dist/components/ui/dialog.mjs.map +1 -1
  50. package/dist/components/ui/label.mjs +5 -56
  51. package/dist/components/ui/label.mjs.map +1 -1
  52. package/dist/components/ui/separator.mjs +7 -42
  53. package/dist/components/ui/separator.mjs.map +1 -1
  54. package/dist/components/ui/textarea.mjs +7 -42
  55. package/dist/components/ui/textarea.mjs.map +1 -1
  56. package/dist/context/index.mjs +1 -0
  57. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +7 -155
  58. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
  59. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +5 -165
  60. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
  61. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
  62. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +6 -145
  63. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
  64. package/dist/hooks/index.mjs +1 -0
  65. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +5 -111
  66. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
  67. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +5 -160
  68. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
  69. package/dist/hooks/misc/use-autosize-textarea.mjs +4 -12
  70. package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +56 -2196
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/lib/debouncer.mjs +4 -48
  75. package/dist/lib/debouncer.mjs.map +1 -1
  76. package/dist/lib/editor-to-text.mjs +4 -40
  77. package/dist/lib/editor-to-text.mjs.map +1 -1
  78. package/dist/lib/get-text-around-cursor.mjs +7 -96
  79. package/dist/lib/get-text-around-cursor.mjs.map +1 -1
  80. package/dist/lib/retry.mjs +4 -14
  81. package/dist/lib/retry.mjs.map +1 -1
  82. package/dist/lib/slatejs-edits/add-autocompletions.mjs +4 -22
  83. package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
  84. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +4 -17
  85. package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
  86. package/dist/lib/slatejs-edits/replace-text.mjs +4 -24
  87. package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
  88. package/dist/lib/slatejs-edits/with-partial-history.mjs +5 -102
  89. package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
  90. package/dist/lib/stream-promise-flatten.mjs +4 -44
  91. package/dist/lib/stream-promise-flatten.mjs.map +1 -1
  92. package/dist/lib/utils.mjs +9 -63
  93. package/dist/lib/utils.mjs.map +1 -1
  94. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +9 -271
  95. package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
  96. package/dist/types/autosuggestions-config/editing-api-config.mjs +6 -82
  97. package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
  98. package/dist/types/autosuggestions-config/index.mjs +10 -271
  99. package/dist/types/autosuggestions-config/index.mjs.map +1 -1
  100. package/dist/types/autosuggestions-config/insertions-api-config.mjs +6 -73
  101. package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
  102. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +6 -59
  103. package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
  104. package/dist/types/base/base-autosuggestions-config.mjs +4 -23
  105. package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
  106. package/dist/types/base/editor-autocomplete-state.mjs +5 -14
  107. package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
  108. package/dist/types/base/index.mjs +5 -23
  109. package/dist/types/base/index.mjs.map +1 -1
  110. package/dist/types/html-copilot-textarea-element.mjs +1 -0
  111. package/dist/types/index.mjs +14 -271
  112. package/dist/types/index.mjs.map +1 -1
  113. package/package.json +6 -6
  114. package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +4 -1
  115. package/dist/chunk-VPEH6V7T.mjs.map +0 -1
  116. /package/dist/{chunk-SP5HFO3H.mjs.map → chunk-HWM2CVKO.mjs.map} +0 -0
  117. /package/dist/{chunk-22TYLEZZ.mjs.map → chunk-XU5Z5BWV.mjs.map} +0 -0
@@ -1,595 +1,18 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __objRest = (source, exclude) => {
18
- var target = {};
19
- for (var prop in source)
20
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
- target[prop] = source[prop];
22
- if (source != null && __getOwnPropSymbols)
23
- for (var prop of __getOwnPropSymbols(source)) {
24
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
- target[prop] = source[prop];
26
- }
27
- return target;
28
- };
29
- var __async = (__this, __arguments, generator) => {
30
- return new Promise((resolve, reject) => {
31
- var fulfilled = (value) => {
32
- try {
33
- step(generator.next(value));
34
- } catch (e) {
35
- reject(e);
36
- }
37
- };
38
- var rejected = (value) => {
39
- try {
40
- step(generator.throw(value));
41
- } catch (e) {
42
- reject(e);
43
- }
44
- };
45
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
- step((generator = generator.apply(__this, __arguments)).next());
47
- });
48
- };
49
-
50
- // src/hooks/misc/use-autosize-textarea.tsx
51
- import { useEffect } from "react";
52
- var useAutosizeTextArea = (textAreaRef, value) => {
53
- useEffect(() => {
54
- if (textAreaRef.current !== null) {
55
- textAreaRef.current.style.height = "0px";
56
- const scrollHeight = textAreaRef.current.scrollHeight;
57
- textAreaRef.current.style.height = scrollHeight + "px";
58
- }
59
- }, [textAreaRef, value]);
60
- };
61
- var use_autosize_textarea_default = useAutosizeTextArea;
62
-
63
- // src/components/source-search-box/source-search-box.tsx
64
- import { useState } from "react";
65
-
66
- // src/components/ui/command.tsx
67
- import * as React from "react";
68
- import { Command as CommandPrimitive } from "cmdk";
69
-
70
- // src/lib/utils.ts
71
- import { clsx } from "clsx";
72
- import { customAlphabet } from "nanoid";
73
- import { twMerge } from "tailwind-merge";
74
- function cn(...inputs) {
75
- return twMerge(clsx(inputs));
76
- }
77
- var nanoid = customAlphabet(
78
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
79
- 7
80
- );
81
-
82
- // src/components/ui/command.tsx
83
- import { jsx } from "react/jsx-runtime";
84
- var Command = React.forwardRef((_a, ref) => {
85
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
86
- return /* @__PURE__ */ jsx(
87
- CommandPrimitive,
88
- __spreadValues({
89
- ref,
90
- className: cn(
91
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
92
- className
93
- )
94
- }, props)
95
- );
96
- });
97
- Command.displayName = CommandPrimitive.displayName;
98
- var CommandInput = React.forwardRef((_a, ref) => {
99
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
100
- return /* @__PURE__ */ jsx("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: /* @__PURE__ */ jsx(
101
- CommandPrimitive.Input,
102
- __spreadValues({
103
- ref,
104
- className: cn(
105
- "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
106
- className
107
- )
108
- }, props)
109
- ) });
110
- });
111
- CommandInput.displayName = CommandPrimitive.Input.displayName;
112
- var CommandList = React.forwardRef((_a, ref) => {
113
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
114
- return /* @__PURE__ */ jsx(
115
- CommandPrimitive.List,
116
- __spreadValues({
117
- ref,
118
- className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)
119
- }, props)
120
- );
121
- });
122
- CommandList.displayName = CommandPrimitive.List.displayName;
123
- var CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(CommandPrimitive.Empty, __spreadValues({ ref, className: "py-6 text-center text-sm" }, props)));
124
- CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
125
- var CommandGroup = React.forwardRef((_a, ref) => {
126
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
127
- return /* @__PURE__ */ jsx(
128
- CommandPrimitive.Group,
129
- __spreadValues({
130
- ref,
131
- className: cn(
132
- "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
133
- className
134
- )
135
- }, props)
136
- );
137
- });
138
- CommandGroup.displayName = CommandPrimitive.Group.displayName;
139
- var CommandSeparator = React.forwardRef((_a, ref) => {
140
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
141
- return /* @__PURE__ */ jsx(
142
- CommandPrimitive.Separator,
143
- __spreadValues({
144
- ref,
145
- className: cn("-mx-1 h-px bg-border", className)
146
- }, props)
147
- );
148
- });
149
- CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
150
- var CommandItem = React.forwardRef((_a, ref) => {
151
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
152
- return /* @__PURE__ */ jsx(
153
- CommandPrimitive.Item,
154
- __spreadValues({
155
- ref,
156
- className: cn(
157
- "relative flex cursor-default select-none items-center rounded-sm text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
158
- className
159
- )
160
- }, props)
161
- );
162
- });
163
- CommandItem.displayName = CommandPrimitive.Item.displayName;
164
- var CommandShortcut = (_a) => {
165
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
166
- return /* @__PURE__ */ jsx(
167
- "span",
168
- __spreadValues({
169
- className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className)
170
- }, props)
171
- );
172
- };
173
- CommandShortcut.displayName = "CommandShortcut";
174
-
175
- // src/components/source-search-box/source-search-box.tsx
176
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
177
- function SourceSearchBox(props) {
178
- const [selectedValue, setSelectedValue] = useState("");
179
- return /* @__PURE__ */ jsxs(
180
- Command,
181
- {
182
- className: "rounded-lg border shadow-md",
183
- value: selectedValue,
184
- onValueChange: (value) => {
185
- setSelectedValue(value);
186
- },
187
- filter: (value, search) => {
188
- if (props.searchTerm === "")
189
- return 1;
190
- if (value.startsWith(props.searchTerm))
191
- return 1;
192
- return 0;
193
- },
194
- children: [
195
- /* @__PURE__ */ jsx2(
196
- CommandInput,
197
- {
198
- value: props.searchTerm,
199
- className: "rounded-t-lg hidden",
200
- placeholder: "Search for a command..."
201
- }
202
- ),
203
- /* @__PURE__ */ jsxs(CommandList, { children: [
204
- /* @__PURE__ */ jsx2(CommandEmpty, { children: "No results found." }),
205
- /* @__PURE__ */ jsx2(CommandGroup, { heading: "Available resources", children: props.suggestedFiles.map((filePointer) => {
206
- return /* @__PURE__ */ jsx2(
207
- CommandItem,
208
- {
209
- value: filePointer.name,
210
- onSelect: (value) => {
211
- props.onSelectedFile(filePointer);
212
- },
213
- children: /* @__PURE__ */ jsxs("div", { className: " px-3 flex flex-row gap-1 items-center", children: [
214
- /* @__PURE__ */ jsx2(Logo, { width: "20px", height: "20px", children: /* @__PURE__ */ jsx2(
215
- "img",
216
- {
217
- src: filePointer.iconImageUri,
218
- alt: filePointer.sourceApplication,
219
- className: "w-full h-full"
220
- }
221
- ) }),
222
- filePointer.name
223
- ] })
224
- },
225
- `word-${filePointer.sourceApplication}.${filePointer.name}`
226
- );
227
- }) }),
228
- /* @__PURE__ */ jsx2(CommandSeparator, {})
229
- ] })
230
- ]
231
- }
232
- );
233
- }
234
- function Logo({
235
- children,
236
- width,
237
- height
238
- }) {
239
- return /* @__PURE__ */ jsx2("div", { className: "flex items-center justify-center", style: { width, height }, children });
240
- }
241
-
242
- // src/components/ui/button.tsx
243
- import * as React2 from "react";
244
- import { Slot } from "@radix-ui/react-slot";
245
- import { cva } from "class-variance-authority";
246
- import { jsx as jsx3 } from "react/jsx-runtime";
247
- var buttonVariants = cva(
248
- "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
249
- {
250
- variants: {
251
- variant: {
252
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
253
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
254
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
255
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
256
- ghost: "hover:bg-accent hover:text-accent-foreground",
257
- link: "text-primary underline-offset-4 hover:underline"
258
- },
259
- size: {
260
- default: "h-10 px-4 py-2",
261
- sm: "h-9 rounded-md px-3",
262
- lg: "h-11 rounded-md px-8",
263
- icon: "h-10 w-10"
264
- }
265
- },
266
- defaultVariants: {
267
- variant: "default",
268
- size: "default"
269
- }
270
- }
271
- );
272
- var Button = React2.forwardRef(
273
- (_a, ref) => {
274
- var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
275
- const Comp = asChild ? Slot : "button";
276
- return /* @__PURE__ */ jsx3(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
277
- }
278
- );
279
- Button.displayName = "Button";
280
-
281
- // src/components/ui/label.tsx
282
- import * as React3 from "react";
283
- import * as LabelPrimitive from "@radix-ui/react-label";
284
- import { cva as cva2 } from "class-variance-authority";
285
- import { jsx as jsx4 } from "react/jsx-runtime";
286
- var labelVariants = cva2(
287
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
288
- );
289
- var Label = React3.forwardRef((_a, ref) => {
290
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
291
- return /* @__PURE__ */ jsx4(LabelPrimitive.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
292
- });
293
- Label.displayName = LabelPrimitive.Root.displayName;
294
-
295
- // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
296
- import { useCallback, useContext as useContext2, useEffect as useEffect2, useRef, useState as useState3 } from "react";
297
-
298
- // src/lib/stream-promise-flatten.ts
299
- function streamPromiseFlatten(promise) {
300
- return new ReadableStream({
301
- start(controller) {
302
- return __async(this, null, function* () {
303
- try {
304
- const stream = yield promise;
305
- const reader = stream.getReader();
306
- while (true) {
307
- const { done, value } = yield reader.read();
308
- if (done) {
309
- controller.close();
310
- return;
311
- }
312
- controller.enqueue(value);
313
- }
314
- } catch (error) {
315
- controller.error(error);
316
- }
317
- });
318
- }
319
- });
320
- }
321
-
322
- // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
323
- import { CopilotContext } from "@copilotkit/react-core";
324
-
325
- // src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
326
- import Chip from "@mui/material/Chip/Chip.js";
327
- import Avatar from "@mui/material/Avatar/Avatar.js";
328
- import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
329
- var IncludedFilesPreview = ({
330
- includedFiles,
331
- setIncludedFiles
332
- }) => {
333
- return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-2 mt-2", children: [
334
- /* @__PURE__ */ jsx5(Label, { className: "", children: "Included context:" }),
335
- /* @__PURE__ */ jsx5("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
336
- return /* @__PURE__ */ jsx5(
337
- FileChipPreview,
338
- {
339
- filePointer,
340
- onDelete: () => {
341
- setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));
342
- }
343
- },
344
- `file-${filePointer.sourceApplication}.${filePointer.name}`
345
- );
346
- }) })
347
- ] });
348
- };
349
- var FileChipPreview = ({ filePointer, onDelete }) => {
350
- return /* @__PURE__ */ jsx5(
351
- Chip,
352
- {
353
- label: filePointer.name,
354
- onDelete,
355
- avatar: /* @__PURE__ */ jsx5(
356
- Avatar,
357
- {
358
- src: filePointer.iconImageUri,
359
- alt: filePointer.sourceApplication,
360
- sx: { backgroundColor: "transparent" }
361
- }
362
- )
363
- }
364
- );
365
- };
366
-
367
- // src/components/hovering-toolbar/hovering-editor-provider.tsx
368
- import { createContext, useState as useState2, useContext } from "react";
369
- import { jsx as jsx6 } from "react/jsx-runtime";
370
- var HoveringEditorContext = createContext({
371
- isDisplayed: false,
372
- setIsDisplayed: () => {
373
- }
374
- });
375
- var useHoveringEditorContext = () => useContext(HoveringEditorContext);
376
-
377
- // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
378
- import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
379
- var HoveringInsertionPromptBoxCore = ({
380
- performInsertion,
381
- state,
382
- insertionOrEditingFunction,
383
- contextCategories
384
- }) => {
385
- const { getDocumentsContext } = useContext2(CopilotContext);
386
- const [editSuggestion, setEditSuggestion] = useState3("");
387
- const [suggestionIsLoading, setSuggestionIsLoading] = useState3(false);
388
- const [adjustmentPrompt, setAdjustmentPrompt] = useState3("");
389
- const [generatingSuggestion, setGeneratingSuggestion] = useState3(
390
- null
391
- );
392
- const adjustmentTextAreaRef = useRef(null);
393
- const suggestionTextAreaRef = useRef(null);
394
- const [filePointers, setFilePointers] = useState3([]);
395
- const [suggestedFiles, setSuggestedFiles] = useState3([]);
396
- useEffect2(() => {
397
- setSuggestedFiles(getDocumentsContext(contextCategories));
398
- }, [contextCategories, getDocumentsContext]);
399
- use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
400
- use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
401
- useEffect2(() => {
402
- var _a;
403
- (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
404
- }, []);
405
- useEffect2(() => {
406
- if (!generatingSuggestion) {
407
- return;
408
- }
409
- if (generatingSuggestion.locked) {
410
- return;
411
- }
412
- setEditSuggestion("");
413
- const reader = generatingSuggestion.getReader();
414
- const read = () => __async(void 0, null, function* () {
415
- setSuggestionIsLoading(true);
416
- while (true) {
417
- const { done, value } = yield reader.read();
418
- if (done) {
419
- break;
420
- }
421
- setEditSuggestion((prev) => {
422
- const newSuggestion = prev + value;
423
- if (suggestionTextAreaRef.current) {
424
- suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;
425
- }
426
- return newSuggestion;
427
- });
428
- }
429
- setSuggestionIsLoading(false);
430
- });
431
- read();
432
- return () => {
433
- const releaseLockIfNotClosed = () => __async(void 0, null, function* () {
434
- try {
435
- yield reader.closed;
436
- } catch (e) {
437
- reader.releaseLock();
438
- }
439
- });
440
- releaseLockIfNotClosed();
441
- };
442
- }, [generatingSuggestion]);
443
- const beginGeneratingAdjustment = useCallback(() => __async(void 0, null, function* () {
444
- if (!adjustmentPrompt.trim()) {
445
- return;
446
- }
447
- let modificationState = state.editorState;
448
- if (editSuggestion !== "") {
449
- modificationState.selectedText = editSuggestion;
450
- }
451
- const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(
452
- modificationState,
453
- adjustmentPrompt,
454
- filePointers,
455
- new AbortController().signal
456
- );
457
- const adjustmentSuggestionTextStream = streamPromiseFlatten(
458
- adjustmentSuggestionTextStreamPromise
459
- );
460
- setGeneratingSuggestion(adjustmentSuggestionTextStream);
461
- }), [
462
- adjustmentPrompt,
463
- editSuggestion,
464
- state.editorState,
465
- insertionOrEditingFunction,
466
- filePointers
467
- ]);
468
- const isLoading = suggestionIsLoading;
469
- const textToEdit = editSuggestion || state.editorState.selectedText;
470
- const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
471
- const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
472
- const { setIsDisplayed } = useHoveringEditorContext();
473
- const AdjustmentPromptComponent = /* @__PURE__ */ jsxs3(Fragment, { children: [
474
- /* @__PURE__ */ jsx7(Label, { className: "", children: adjustmentLabel }),
475
- /* @__PURE__ */ jsxs3("div", { className: "relative w-full flex items-center", children: [
476
- /* @__PURE__ */ jsx7(
477
- "textarea",
478
- {
479
- disabled: suggestionIsLoading,
480
- ref: adjustmentTextAreaRef,
481
- value: adjustmentPrompt,
482
- onChange: (e) => setAdjustmentPrompt(e.target.value),
483
- onKeyDown: (e) => {
484
- if (e.key === "Enter" && e.shiftKey) {
485
- e.preventDefault();
486
- setAdjustmentPrompt(adjustmentPrompt + "\n");
487
- } else if (e.key === "Enter") {
488
- e.preventDefault();
489
- beginGeneratingAdjustment();
490
- } else if (e.key == "Escape") {
491
- e.preventDefault();
492
- setIsDisplayed(false);
493
- }
494
- },
495
- placeholder,
496
- style: { minHeight: "3rem" },
497
- className: "w-full bg-slate-100 h-auto h-min-14 text-sm p-2 rounded-md resize-none overflow-visible focus:outline-none focus:ring-0 focus:border-non pr-[3rem]",
498
- rows: 1
499
- }
500
- ),
501
- /* @__PURE__ */ jsx7(
502
- "button",
503
- {
504
- onClick: beginGeneratingAdjustment,
505
- className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
506
- children: /* @__PURE__ */ jsx7("i", { className: "material-icons", children: "arrow_forward" })
507
- }
508
- )
509
- ] })
510
- ] });
511
- const SuggestionComponent = /* @__PURE__ */ jsxs3(Fragment, { children: [
512
- /* @__PURE__ */ jsxs3("div", { className: "flex justify-between items-end w-full", children: [
513
- /* @__PURE__ */ jsx7(Label, { className: "mt-4", children: "Suggested:" }),
514
- /* @__PURE__ */ jsx7("div", { className: "ml-auto", children: isLoading && /* @__PURE__ */ jsx7("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ jsx7(
515
- "div",
516
- {
517
- className: "inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",
518
- role: "status",
519
- children: /* @__PURE__ */ jsx7("span", { className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]", children: "Loading..." })
520
- }
521
- ) }) })
522
- ] }),
523
- /* @__PURE__ */ jsx7(
524
- "textarea",
525
- {
526
- ref: suggestionTextAreaRef,
527
- value: editSuggestion,
528
- disabled: suggestionIsLoading,
529
- onChange: (e) => setEditSuggestion(e.target.value),
530
- className: "w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50",
531
- style: { overflow: "auto", maxHeight: "10em" }
532
- }
533
- )
534
- ] });
535
- const SubmitComponent = /* @__PURE__ */ jsx7("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ jsxs3(
536
- Button,
537
- {
538
- className: " bg-green-700 text-white",
539
- onClick: () => {
540
- performInsertion(editSuggestion);
541
- },
542
- children: [
543
- "Insert ",
544
- /* @__PURE__ */ jsx7("i", { className: "material-icons", children: "check" })
545
- ]
546
- }
547
- ) });
548
- const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
549
- const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
550
- return /* @__PURE__ */ jsxs3("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
551
- AdjustmentPromptComponent,
552
- filePointers.length > 0 && /* @__PURE__ */ jsx7(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
553
- sourceSearchWord !== void 0 && /* @__PURE__ */ jsx7(
554
- SourceSearchBox,
555
- {
556
- searchTerm: sourceSearchWord,
557
- suggestedFiles,
558
- onSelectedFile: (filePointer) => {
559
- var _a;
560
- setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), ""));
561
- setFilePointers((prev) => [...prev, filePointer]);
562
- (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
563
- }
564
- }
565
- ),
566
- generatingSuggestion ? SuggestionComponent : null,
567
- generatingSuggestion ? SubmitComponent : null
568
- ] });
569
- };
570
-
571
- // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
572
- import { jsx as jsx8 } from "react/jsx-runtime";
573
- var HoveringInsertionPromptBox = (props) => {
574
- return /* @__PURE__ */ jsx8(
575
- "div",
576
- {
577
- className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
578
- style: { width: "35rem" },
579
- children: /* @__PURE__ */ jsx8(
580
- HoveringInsertionPromptBoxCore,
581
- {
582
- state: {
583
- editorState: props.editorState
584
- },
585
- insertionOrEditingFunction: props.apiConfig.insertionOrEditingFunction,
586
- performInsertion: props.performInsertion,
587
- contextCategories: props.contextCategories
588
- }
589
- )
590
- }
591
- );
592
- };
1
+ import {
2
+ HoveringInsertionPromptBox
3
+ } from "../../../chunk-COQISBP2.mjs";
4
+ import "../../../chunk-OGLVRSCO.mjs";
5
+ import "../../../chunk-YNXNMCDX.mjs";
6
+ import "../../../chunk-3PQ7GSFE.mjs";
7
+ import "../../../chunk-WFTAAA7R.mjs";
8
+ import "../../../chunk-YFK5BFEI.mjs";
9
+ import "../../../chunk-LYB4B6MK.mjs";
10
+ import "../../../chunk-4OZR65UB.mjs";
11
+ import "../../../chunk-FFSICDS5.mjs";
12
+ import "../../../chunk-4HBKWUCT.mjs";
13
+ import "../../../chunk-2QDCE7PD.mjs";
14
+ import "../../../chunk-7SUZ6CXM.mjs";
15
+ import "../../../chunk-MRXNTQOX.mjs";
593
16
  export {
594
17
  HoveringInsertionPromptBox
595
18
  };