@copilotkit/react-textarea 1.10.7-next.0 → 1.50.0-beta.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 (95) hide show
  1. package/CHANGELOG.md +0 -8
  2. package/dist/{chunk-HDBI2WN5.mjs → chunk-2IWVZ4PP.mjs} +17 -27
  3. package/dist/chunk-2IWVZ4PP.mjs.map +1 -0
  4. package/dist/{chunk-XW3ICO4S.mjs → chunk-3QJOFG3V.mjs} +1 -1
  5. package/dist/chunk-3QJOFG3V.mjs.map +1 -0
  6. package/dist/{chunk-HBWBHJ64.mjs → chunk-4VCJHANC.mjs} +9 -9
  7. package/dist/{chunk-7WVURIB7.mjs → chunk-5NZNJCP2.mjs} +21 -21
  8. package/dist/{chunk-2DF2AVDU.mjs → chunk-66KFI242.mjs} +2 -2
  9. package/dist/{chunk-C3PMJNQA.mjs → chunk-7VADGLV2.mjs} +6 -6
  10. package/dist/{chunk-RXV67GJN.mjs → chunk-DL3JWL2E.mjs} +4 -2
  11. package/dist/chunk-DL3JWL2E.mjs.map +1 -0
  12. package/dist/{chunk-7L6GIHDM.mjs → chunk-F2ULK22F.mjs} +1 -1
  13. package/dist/chunk-F2ULK22F.mjs.map +1 -0
  14. package/dist/{chunk-6SGWO63I.mjs → chunk-ISKK3RIW.mjs} +4 -4
  15. package/dist/chunk-JD7BAH7U.mjs +1 -0
  16. package/dist/{chunk-LQ2OWQU7.mjs → chunk-JLOABKLH.mjs} +2 -2
  17. package/dist/{chunk-LQ2OWQU7.mjs.map → chunk-JLOABKLH.mjs.map} +1 -1
  18. package/dist/{chunk-3PQ7GSFE.mjs → chunk-NAFNY4FL.mjs} +1 -1
  19. package/dist/chunk-NAFNY4FL.mjs.map +1 -0
  20. package/dist/{chunk-F6GMWOLE.mjs → chunk-ZQSEYPNN.mjs} +6 -25
  21. package/dist/chunk-ZQSEYPNN.mjs.map +1 -0
  22. package/dist/components/base-copilot-textarea/base-copilot-textarea.js +17 -27
  23. package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
  24. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +21 -21
  25. package/dist/components/base-copilot-textarea/render-element.d.ts +3 -2
  26. package/dist/components/base-copilot-textarea/render-element.js.map +1 -1
  27. package/dist/components/base-copilot-textarea/render-element.mjs +1 -1
  28. package/dist/components/base-copilot-textarea/render-placeholder.d.ts +3 -2
  29. package/dist/components/base-copilot-textarea/render-placeholder.js.map +1 -1
  30. package/dist/components/base-copilot-textarea/render-placeholder.mjs +1 -1
  31. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js +1 -1
  32. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js.map +1 -1
  33. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +1 -1
  34. package/dist/components/copilot-textarea/copilot-textarea.js +24 -48
  35. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  36. package/dist/components/copilot-textarea/copilot-textarea.mjs +75 -28
  37. package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
  38. package/dist/components/hovering-toolbar/hovering-toolbar-components.d.ts +1 -1
  39. package/dist/components/hovering-toolbar/hovering-toolbar-components.js +16 -26
  40. package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -1
  41. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +1 -1
  42. package/dist/components/hovering-toolbar/hovering-toolbar.js +16 -26
  43. package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
  44. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +8 -8
  45. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
  46. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +5 -5
  47. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
  48. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +6 -6
  49. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
  50. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +6 -6
  51. package/dist/components/index.d.ts +2 -11
  52. package/dist/components/index.js +25 -531
  53. package/dist/components/index.js.map +1 -1
  54. package/dist/components/index.mjs +23 -35
  55. package/dist/components/ui/command.d.ts +1 -1
  56. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +4 -20
  57. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
  58. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
  59. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +3 -1
  60. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
  61. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +1 -1
  62. package/dist/hooks/misc/use-autosize-textarea.d.ts +1 -1
  63. package/dist/hooks/misc/use-autosize-textarea.js.map +1 -1
  64. package/dist/hooks/misc/use-autosize-textarea.mjs +1 -1
  65. package/dist/index.d.ts +0 -1
  66. package/dist/index.js +76 -368
  67. package/dist/index.js.map +1 -1
  68. package/dist/index.mjs +27 -34
  69. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +2 -2
  70. package/dist/types/autosuggestions-config/index.mjs +2 -2
  71. package/dist/types/index.mjs +3 -3
  72. package/package.json +8 -8
  73. package/src/components/base-copilot-textarea/render-element.tsx +2 -1
  74. package/src/components/base-copilot-textarea/render-placeholder.tsx +2 -1
  75. package/src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx +1 -1
  76. package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +28 -40
  77. package/src/components/index.ts +0 -3
  78. package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +24 -22
  79. package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +2 -1
  80. package/src/hooks/misc/use-autosize-textarea.tsx +1 -1
  81. package/dist/chunk-3PQ7GSFE.mjs.map +0 -1
  82. package/dist/chunk-7L6GIHDM.mjs.map +0 -1
  83. package/dist/chunk-F6GMWOLE.mjs.map +0 -1
  84. package/dist/chunk-HDBI2WN5.mjs.map +0 -1
  85. package/dist/chunk-MMVDU6DF.mjs +0 -1
  86. package/dist/chunk-NZIHZWRU.mjs +0 -60
  87. package/dist/chunk-NZIHZWRU.mjs.map +0 -1
  88. package/dist/chunk-RXV67GJN.mjs.map +0 -1
  89. package/dist/chunk-XW3ICO4S.mjs.map +0 -1
  90. /package/dist/{chunk-HBWBHJ64.mjs.map → chunk-4VCJHANC.mjs.map} +0 -0
  91. /package/dist/{chunk-7WVURIB7.mjs.map → chunk-5NZNJCP2.mjs.map} +0 -0
  92. /package/dist/{chunk-2DF2AVDU.mjs.map → chunk-66KFI242.mjs.map} +0 -0
  93. /package/dist/{chunk-C3PMJNQA.mjs.map → chunk-7VADGLV2.mjs.map} +0 -0
  94. /package/dist/{chunk-6SGWO63I.mjs.map → chunk-ISKK3RIW.mjs.map} +0 -0
  95. /package/dist/{chunk-MMVDU6DF.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
@@ -1,48 +1,95 @@
1
1
  import {
2
- CopilotTextarea
3
- } from "../../chunk-NZIHZWRU.mjs";
4
- import "../../chunk-F6GMWOLE.mjs";
5
- import "../../chunk-RXV67GJN.mjs";
2
+ useMakeStandardInsertionOrEditingFunction
3
+ } from "../../chunk-DL3JWL2E.mjs";
4
+ import {
5
+ useMakeStandardAutosuggestionFunction
6
+ } from "../../chunk-ZQSEYPNN.mjs";
6
7
  import "../../chunk-RUV6NBIF.mjs";
7
- import "../../chunk-6SGWO63I.mjs";
8
- import "../../chunk-MCNXIA4Q.mjs";
8
+ import {
9
+ defaultAutosuggestionsConfig
10
+ } from "../../chunk-ISKK3RIW.mjs";
9
11
  import "../../chunk-QFXR6DOA.mjs";
10
12
  import "../../chunk-EJGGLWWR.mjs";
11
- import "../../chunk-7WVURIB7.mjs";
12
- import "../../chunk-2C7O2EVM.mjs";
13
+ import "../../chunk-MCNXIA4Q.mjs";
14
+ import {
15
+ BaseCopilotTextarea
16
+ } from "../../chunk-5NZNJCP2.mjs";
13
17
  import "../../chunk-GQN2HYFJ.mjs";
14
- import "../../chunk-23Q6A46J.mjs";
15
- import "../../chunk-AJ5OMEXM.mjs";
16
- import "../../chunk-DRV2FOHZ.mjs";
17
- import "../../chunk-4NHVQZ67.mjs";
18
- import "../../chunk-QJNFNPWH.mjs";
19
- import "../../chunk-5UNJXFUO.mjs";
20
- import "../../chunk-7LSRNPNI.mjs";
21
- import "../../chunk-C3PMJNQA.mjs";
18
+ import "../../chunk-7VADGLV2.mjs";
22
19
  import "../../chunk-L7VVZH4Q.mjs";
23
- import "../../chunk-2DF2AVDU.mjs";
24
- import "../../chunk-HBWBHJ64.mjs";
20
+ import "../../chunk-66KFI242.mjs";
21
+ import "../../chunk-4VCJHANC.mjs";
25
22
  import "../../chunk-KMVGEY7Q.mjs";
26
- import "../../chunk-3PQ7GSFE.mjs";
27
- import "../../chunk-D47EKHIF.mjs";
28
- import "../../chunk-LYB4B6MK.mjs";
29
- import "../../chunk-HDBI2WN5.mjs";
23
+ import "../../chunk-2IWVZ4PP.mjs";
30
24
  import "../../chunk-WGWQRALG.mjs";
25
+ import "../../chunk-4PDYALMP.mjs";
31
26
  import "../../chunk-VSVQZUPW.mjs";
32
27
  import "../../chunk-I72DKFHD.mjs";
33
- import "../../chunk-4PDYALMP.mjs";
28
+ import "../../chunk-D47EKHIF.mjs";
29
+ import "../../chunk-2C7O2EVM.mjs";
30
+ import "../../chunk-NAFNY4FL.mjs";
31
+ import "../../chunk-F2ULK22F.mjs";
32
+ import "../../chunk-3QJOFG3V.mjs";
33
+ import "../../chunk-JLOABKLH.mjs";
34
+ import "../../chunk-7LSRNPNI.mjs";
35
+ import "../../chunk-LYB4B6MK.mjs";
34
36
  import "../../chunk-2QDCE7PD.mjs";
35
- import "../../chunk-YLFAIYRY.mjs";
36
37
  import "../../chunk-WJHSY5T6.mjs";
37
38
  import "../../chunk-F6RLSVG3.mjs";
38
- import "../../chunk-7L6GIHDM.mjs";
39
- import "../../chunk-XW3ICO4S.mjs";
40
- import "../../chunk-LQ2OWQU7.mjs";
39
+ import "../../chunk-23Q6A46J.mjs";
40
+ import "../../chunk-AJ5OMEXM.mjs";
41
+ import "../../chunk-YLFAIYRY.mjs";
42
+ import "../../chunk-DRV2FOHZ.mjs";
43
+ import "../../chunk-4NHVQZ67.mjs";
44
+ import "../../chunk-QJNFNPWH.mjs";
45
+ import "../../chunk-5UNJXFUO.mjs";
41
46
  import "../../chunk-DFTV4TST.mjs";
42
47
  import "../../chunk-T6MTDQZ7.mjs";
43
48
  import "../../chunk-ECR45NSD.mjs";
44
49
  import "../../chunk-KNQIEOFP.mjs";
45
- import "../../chunk-MRXNTQOX.mjs";
50
+ import {
51
+ __objRest,
52
+ __spreadProps,
53
+ __spreadValues
54
+ } from "../../chunk-MRXNTQOX.mjs";
55
+
56
+ // src/components/copilot-textarea/copilot-textarea.tsx
57
+ import React from "react";
58
+ import merge from "lodash.merge";
59
+ import { Fragment, jsx } from "react/jsx-runtime";
60
+ var CopilotTextarea = React.forwardRef(
61
+ (props, ref) => {
62
+ const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
63
+ const autosuggestionsConfig = merge(
64
+ defaultAutosuggestionsConfig,
65
+ autosuggestionsConfigUserSpecified
66
+ );
67
+ const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(
68
+ autosuggestionsConfig.textareaPurpose,
69
+ autosuggestionsConfig.contextCategories,
70
+ autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig
71
+ );
72
+ const insertionOrEditingFunction = useMakeStandardInsertionOrEditingFunction(
73
+ autosuggestionsConfig.textareaPurpose,
74
+ autosuggestionsConfig.contextCategories,
75
+ autosuggestionsConfig.chatApiConfigs.insertionApiConfig,
76
+ autosuggestionsConfig.chatApiConfigs.editingApiConfig
77
+ );
78
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
79
+ BaseCopilotTextarea,
80
+ __spreadProps(__spreadValues({
81
+ ref
82
+ }, forwardedProps), {
83
+ baseAutosuggestionsConfig: __spreadProps(__spreadValues({}, autosuggestionsConfig), {
84
+ apiConfig: {
85
+ insertionOrEditingFunction,
86
+ autosuggestionsFunction
87
+ }
88
+ })
89
+ })
90
+ ) });
91
+ }
92
+ );
46
93
  export {
47
94
  CopilotTextarea
48
95
  };
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/components/copilot-textarea/copilot-textarea.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"https://cdn.copilotkit.ai/docs/copilotkit/images/CopilotTextarea.gif\" width=\"500\" />\n *\n * `<CopilotTextarea>` is a React component that acts as a drop-in replacement for the standard `<textarea>`,\n * offering enhanced autocomplete features powered by AI. It is context-aware, integrating seamlessly with the\n * [`useCopilotReadable`](/reference/hooks/useCopilotReadable) hook to provide intelligent suggestions based on the application context.\n *\n * In addition, it provides a hovering editor window (available by default via `Cmd + K` on Mac and `Ctrl + K` on Windows) that allows the user to\n * suggest changes to the text, for example providing a summary or rephrasing the text.\n *\n * ## Example\n *\n * ```tsx\n * import { CopilotTextarea } from '@copilotkit/react-textarea';\n * import \"@copilotkit/react-textarea/styles.css\";\n *\n * <CopilotTextarea\n * autosuggestionsConfig={{\n * textareaPurpose:\n * \"the body of an email message\",\n * chatApiConfigs: {},\n * }}\n * />\n * ```\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-textarea](https://npmjs.com/package/@copilotkit/react-textarea) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-textarea\"\\\n * npm install @copilotkit/react-core @copilotkit/react-textarea\n * ```\n *\n * ### Usage\n *\n * Use the CopilotTextarea component in your React application similarly to a standard `<textarea />`,\n * with additional configurations for AI-powered features.\n *\n * For example:\n *\n * ```tsx\n * import { useState } from \"react\";\n * import { CopilotTextarea } from \"@copilotkit/react-textarea\";\n * import \"@copilotkit/react-textarea/styles.css\";\n *\n * export function ExampleComponent() {\n * const [text, setText] = useState(\"\");\n *\n * return (\n * <CopilotTextarea\n * className=\"custom-textarea-class\"\n * value={text}\n * onValueChange={(value: string) => setText(value)}\n * placeholder=\"Enter your text here...\"\n * autosuggestionsConfig={{\n * textareaPurpose: \"Provide context or purpose of the textarea.\",\n * chatApiConfigs: {\n * suggestionsApiConfig: {\n * maxTokens: 20,\n * stop: [\".\", \"?\", \"!\"],\n * },\n * },\n * }}\n * />\n * );\n * }\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx title=\"YourRootComponent.tsx\"\n * ...\n * import \"@copilotkit/react-textarea/styles.css\"; // [!code highlight]\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.\n * */\nimport React from \"react\";\nimport { useMakeStandardAutosuggestionFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { BaseCopilotTextareaProps } from \"../../types/base/base-copilot-textarea-props\";\nimport {\n AutosuggestionsConfig,\n defaultAutosuggestionsConfig,\n} from \"../../types/autosuggestions-config\";\nimport { BaseCopilotTextarea } from \"../base-copilot-textarea/base-copilot-textarea\";\nimport { useMakeStandardInsertionOrEditingFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-insertion-function\";\nimport merge from \"lodash.merge\";\nimport { AutosuggestionsConfigUserSpecified } from \"../../types/autosuggestions-config/autosuggestions-config-user-specified\";\n\n// Like the base copilot textarea props,\n// but with baseAutosuggestionsConfig replaced with autosuggestionsConfig.\nexport interface CopilotTextareaProps\n extends Omit<BaseCopilotTextareaProps, \"baseAutosuggestionsConfig\"> {\n /**\n * Configuration settings for the autosuggestions feature.\n * For full reference, [check the interface on GitHub](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-textarea/src/types/base/base-copilot-textarea-props.tsx#L8).\n *\n * <PropertyReference name=\"textareaPurpose\" type=\"string\" required={true} >\n * The purpose of the text area in plain text.\n *\n * Example: *\"The body of the email response\"*\n * </PropertyReference>\n *\n * <PropertyReference name=\"chatApiConfigs\" type=\"ChatApiConfigs\" >\n * The chat API configurations.\n *\n * <strong>NOTE:</strong> You must provide specify at least one of `suggestionsApiConfig` or `insertionApiConfig`.\n *\n * <PropertyReference name=\"suggestionsApiConfig\" type=\"SuggestionsApiConfig\">\n * For full reference, please [click here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-textarea/src/types/autosuggestions-config/suggestions-api-config.tsx#L4).\n * </PropertyReference>\n * <PropertyReference name=\"insertionApiConfig\" type=\"InsertionApiConfig\">\n * For full reference, please [click here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-textarea/src/types/autosuggestions-config/insertions-api-config.tsx#L4).\n * </PropertyReference>\n * </PropertyReference>\n *\n * <PropertyReference name=\"disabled\" type=\"boolean\" >\n * Whether the textarea is disabled.\n * </PropertyReference>\n *\n * <PropertyReference name=\"disableBranding\" type=\"boolean\" >\n * Whether to disable the CopilotKit branding.\n * </PropertyReference>\n *\n * <PropertyReference name=\"placeholderStyle\" type=\"React.CSSProperties\" >\n * Specifies the CSS styles to apply to the placeholder text.\n * </PropertyReference>\n *\n * <PropertyReference name=\"suggestionsStyle\" type=\"React.CSSProperties\" >\n * Specifies the CSS styles to apply to the suggestions list.\n * </PropertyReference>\n *\n * <PropertyReference name=\"hoverMenuClassname\" type=\"string\" >\n * A class name to apply to the editor popover window.\n * </PropertyReference>\n *\n * <PropertyReference name=\"value\" type=\"string\" >\n * The initial value of the textarea. Can be controlled via `onValueChange`.\n * </PropertyReference>\n *\n * <PropertyReference name=\"onValueChange\" type=\"(value: string) => void\" >\n * Callback invoked when the value of the textarea changes.\n * </PropertyReference>\n *\n * <PropertyReference name=\"onChange\" type=\"(event: React.ChangeEvent<HTMLTextAreaElement>) => void\" >\n * Callback invoked when a `change` event is triggered on the textarea element.\n * </PropertyReference>\n *\n * <PropertyReference name=\"shortcut\" type=\"string\" >\n * The shortcut to use to open the editor popover window. Default is `\"Cmd-k\"`.\n * </PropertyReference>\n */\n autosuggestionsConfig: AutosuggestionsConfigUserSpecified;\n}\n\n/**\n * A copilot textarea that uses the standard autosuggestions function.\n */\nexport const CopilotTextarea = React.forwardRef(\n (props: CopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>) => {\n // separate the AutosuggestionsConfigUserSpecified from the rest of the props\n const { autosuggestionsConfig: autosuggestionsConfigUserSpecified, ...forwardedProps } = props;\n\n const autosuggestionsConfig: AutosuggestionsConfig = merge(\n defaultAutosuggestionsConfig,\n autosuggestionsConfigUserSpecified,\n );\n\n const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.contextCategories,\n autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig,\n );\n\n const insertionOrEditingFunction = useMakeStandardInsertionOrEditingFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.contextCategories,\n autosuggestionsConfig.chatApiConfigs.insertionApiConfig,\n autosuggestionsConfig.chatApiConfigs.editingApiConfig,\n );\n\n return (\n <>\n <BaseCopilotTextarea\n ref={ref}\n {...forwardedProps}\n baseAutosuggestionsConfig={{\n ...autosuggestionsConfig,\n apiConfig: {\n insertionOrEditingFunction: insertionOrEditingFunction,\n autosuggestionsFunction: autosuggestionsFunction,\n },\n }}\n />\n </>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,OAAO,WAAW;AAUlB,OAAO,WAAW;AAgGZ,mBACE,WADF;AAxBC,IAAM,kBAAkB,MAAM;AAAA,EACnC,CAAC,OAA6B,QAA+C;AAE3E,UAAyF,YAAjF,yBAAuB,mCA7KnC,IA6K6F,IAAnB,2BAAmB,IAAnB,CAA9D;AAER,UAAM,wBAA+C;AAAA,MACnD;AAAA,MACA;AAAA,IACF;AAEA,UAAM,0BAA0B;AAAA,MAC9B,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,IACvC;AAEA,UAAM,6BAA6B;AAAA,MACjC,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,MACrC,sBAAsB,eAAe;AAAA,IACvC;AAEA,WACE,gCACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,SACI,iBAFL;AAAA,QAGC,2BAA2B,iCACtB,wBADsB;AAAA,UAEzB,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import React__default from 'react';
2
2
 
3
3
  interface BaseProps {
4
- className: string;
4
+ className?: string;
5
5
  [key: string]: unknown;
6
6
  }
7
7
  declare const Button: React__default.ForwardRefExoticComponent<Omit<React__default.PropsWithChildren<{
@@ -70,32 +70,22 @@ var import_css = require("@emotion/css");
70
70
  var import_react = __toESM(require("react"));
71
71
  var import_react_dom = __toESM(require("react-dom"));
72
72
  var import_jsx_runtime = require("react/jsx-runtime");
73
- var Button = import_react.default.forwardRef(
74
- (_a, ref) => {
75
- var _b = _a, {
76
- className,
77
- active,
78
- reversed
79
- } = _b, props = __objRest(_b, [
80
- "className",
81
- "active",
82
- "reversed"
83
- ]);
84
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
- "span",
86
- __spreadProps(__spreadValues({}, props), {
87
- ref,
88
- className: (0, import_css.cx)(
89
- className,
90
- import_css.css`
91
- cursor: pointer;
92
- color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
93
- `
94
- )
95
- })
96
- );
97
- }
98
- );
73
+ var Button = import_react.default.forwardRef((_a, ref) => {
74
+ var _b = _a, { className, active, reversed } = _b, props = __objRest(_b, ["className", "active", "reversed"]);
75
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
+ "span",
77
+ __spreadProps(__spreadValues({}, props), {
78
+ ref,
79
+ className: (0, import_css.cx)(
80
+ className,
81
+ import_css.css`
82
+ cursor: pointer;
83
+ color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
84
+ `
85
+ )
86
+ })
87
+ );
88
+ });
99
89
  var Icon = import_react.default.forwardRef(
100
90
  (_a, ref) => {
101
91
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/hovering-toolbar/hovering-toolbar-components.tsx"],"sourcesContent":["import { css, cx } from \"@emotion/css\";\nimport React, { PropsWithChildren, Ref } from \"react\";\nimport ReactDOM from \"react-dom\";\n\ninterface BaseProps {\n className: string;\n [key: string]: unknown;\n}\n\nexport const Button = React.forwardRef(\n (\n {\n className,\n active,\n reversed,\n ...props\n }: PropsWithChildren<\n {\n active: boolean;\n reversed: boolean;\n } & BaseProps\n >,\n ref: Ref<HTMLSpanElement | null>,\n ) => (\n <span\n {...props}\n ref={ref as Ref<HTMLSpanElement>}\n className={cx(\n className,\n css`\n cursor: pointer;\n color: ${reversed ? (active ? \"white\" : \"#aaa\") : active ? \"black\" : \"#ccc\"};\n `,\n )}\n />\n ),\n);\n\nexport const Icon = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLSpanElement | null>) => (\n <span\n {...props}\n ref={ref as Ref<HTMLSpanElement>}\n className={cx(\n \"material-icons\",\n className,\n css`\n font-size: 18px;\n vertical-align: text-bottom;\n `,\n )}\n />\n ),\n);\n\nexport const Menu = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLDivElement | null>) => {\n return (\n <div\n {...props}\n data-testid=\"menu\"\n ref={ref as Ref<HTMLDivElement>}\n className={cx(\n className,\n css`\n & > * {\n display: inline-block;\n }\n\n & > * + * {\n margin-left: 15px;\n }\n `,\n )}\n />\n );\n },\n);\nexport const Portal = ({ children }: { children: React.ReactNode }) => {\n return typeof document === \"object\" ? ReactDOM.createPortal(children, document.body) : null;\n};\n\nexport const Toolbar = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref?: Ref<HTMLDivElement>) => (\n <Menu\n {...props}\n ref={ref}\n className={cx(\n className,\n css`\n position: relative;\n padding: 1px 18px 17px;\n margin: 0 -20px;\n border-bottom: 2px solid #eee;\n margin-bottom: 20px;\n `,\n )}\n />\n ),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAwB;AACxB,mBAA8C;AAC9C,uBAAqB;AAsBjB;AAfG,IAAM,SAAS,aAAAA,QAAM;AAAA,EAC1B,CACE,IAWA,QACA;AAZA,iBACE;AAAA;AAAA,MACA;AAAA,MACA;AAAA,IAdN,IAWI,IAIK,kBAJL,IAIK;AAAA,MAHH;AAAA,MACA;AAAA,MACA;AAAA;AAUF;AAAA,MAAC;AAAA,uCACK,QADL;AAAA,QAEC;AAAA,QACA,eAAW;AAAA,UACT;AAAA,UACA;AAAA;AAAA,mBAEW,WAAY,SAAS,UAAU,SAAU,SAAS,UAAU;AAAA;AAAA,QAEzE;AAAA;AAAA,IACF;AAAA;AAEJ;AAEO,IAAM,OAAO,aAAAA,QAAM;AAAA,EACxB,CAAC,IAAuD,QAAkC;AAAzF,iBAAE,YAvCL,IAuCG,IAAgB,kBAAhB,IAAgB,CAAd;AACD;AAAA,MAAC;AAAA,uCACK,QADL;AAAA,QAEC;AAAA,QACA,eAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA;AAAA;AAAA;AAAA,QAIF;AAAA;AAAA,IACF;AAAA;AAEJ;AAEO,IAAM,OAAO,aAAAA,QAAM;AAAA,EACxB,CAAC,IAAuD,QAAoC;AAA3F,iBAAE,YAxDL,IAwDG,IAAgB,kBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA,uCACK,QADL;AAAA,QAEC,eAAY;AAAA,QACZ;AAAA,QACA,eAAW;AAAA,UACT;AAAA,UACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QASF;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AACO,IAAM,SAAS,CAAC,EAAE,SAAS,MAAqC;AACrE,SAAO,OAAO,aAAa,WAAW,iBAAAC,QAAS,aAAa,UAAU,SAAS,IAAI,IAAI;AACzF;AAEO,IAAM,UAAU,aAAAD,QAAM;AAAA,EAC3B,CAAC,IAAuD,QAA2B;AAAlF,iBAAE,YAnFL,IAmFG,IAAgB,kBAAhB,IAAgB,CAAd;AACD;AAAA,MAAC;AAAA,uCACK,QADL;AAAA,QAEC;AAAA,QACA,eAAW;AAAA,UACT;AAAA,UACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOF;AAAA;AAAA,IACF;AAAA;AAEJ;","names":["React","ReactDOM"]}
1
+ {"version":3,"sources":["../../../src/components/hovering-toolbar/hovering-toolbar-components.tsx"],"sourcesContent":["import { css, cx } from \"@emotion/css\";\nimport React, { PropsWithChildren, Ref } from \"react\";\nimport ReactDOM from \"react-dom\";\n\ninterface BaseProps {\n className?: string;\n [key: string]: unknown;\n}\n\nexport const Button = React.forwardRef<\n HTMLSpanElement,\n PropsWithChildren<{ active: boolean; reversed: boolean } & BaseProps>\n>(({ className, active, reversed, ...props }, ref) => (\n <span\n {...props}\n ref={ref}\n className={cx(\n className as string,\n css`\n cursor: pointer;\n color: ${reversed ? (active ? \"white\" : \"#aaa\") : active ? \"black\" : \"#ccc\"};\n `,\n )}\n />\n));\n\nexport const Icon = React.forwardRef<HTMLSpanElement, PropsWithChildren<BaseProps>>(\n ({ className, ...props }, ref) => (\n <span\n {...props}\n ref={ref}\n className={cx(\n \"material-icons\",\n className as string,\n css`\n font-size: 18px;\n vertical-align: text-bottom;\n `,\n )}\n />\n ),\n);\n\nexport const Menu = React.forwardRef<HTMLDivElement, PropsWithChildren<BaseProps>>(\n ({ className, ...props }, ref) => {\n return (\n <div\n {...props}\n data-testid=\"menu\"\n ref={ref}\n className={cx(\n className as string,\n css`\n & > * {\n display: inline-block;\n }\n\n & > * + * {\n margin-left: 15px;\n }\n `,\n )}\n />\n );\n },\n);\nexport const Portal = ({ children }: { children: React.ReactNode }) => {\n return typeof document === \"object\" ? ReactDOM.createPortal(children, document.body) : null;\n};\n\nexport const Toolbar = React.forwardRef<HTMLDivElement, PropsWithChildren<BaseProps>>(\n ({ className, ...props }, ref) => (\n <Menu\n {...props}\n ref={ref}\n className={cx(\n className as string,\n css`\n position: relative;\n padding: 1px 18px 17px;\n margin: 0 -20px;\n border-bottom: 2px solid #eee;\n margin-bottom: 20px;\n `,\n )}\n />\n ),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAwB;AACxB,mBAA8C;AAC9C,uBAAqB;AAWnB;AAJK,IAAM,SAAS,aAAAA,QAAM,WAG1B,CAAC,IAA2C,QAAK;AAAhD,eAAE,aAAW,QAAQ,SAZxB,IAYG,IAAkC,kBAAlC,IAAkC,CAAhC,aAAW,UAAQ;AACtB;AAAA,IAAC;AAAA,qCACK,QADL;AAAA,MAEC;AAAA,MACA,eAAW;AAAA,QACT;AA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from "../../chunk-2IWVZ4PP.mjs";
8
8
  import "../../chunk-MRXNTQOX.mjs";
9
9
  export {
10
10
  Button,
@@ -176,32 +176,22 @@ var import_css = require("@emotion/css");
176
176
  var import_react2 = __toESM(require("react"));
177
177
  var import_react_dom = __toESM(require("react-dom"));
178
178
  var import_jsx_runtime2 = require("react/jsx-runtime");
179
- var Button = import_react2.default.forwardRef(
180
- (_a, ref) => {
181
- var _b = _a, {
182
- className,
183
- active,
184
- reversed
185
- } = _b, props = __objRest(_b, [
186
- "className",
187
- "active",
188
- "reversed"
189
- ]);
190
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
191
- "span",
192
- __spreadProps(__spreadValues({}, props), {
193
- ref,
194
- className: (0, import_css.cx)(
195
- className,
196
- import_css.css`
197
- cursor: pointer;
198
- color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
199
- `
200
- )
201
- })
202
- );
203
- }
204
- );
179
+ var Button = import_react2.default.forwardRef((_a, ref) => {
180
+ var _b = _a, { className, active, reversed } = _b, props = __objRest(_b, ["className", "active", "reversed"]);
181
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
182
+ "span",
183
+ __spreadProps(__spreadValues({}, props), {
184
+ ref,
185
+ className: (0, import_css.cx)(
186
+ className,
187
+ import_css.css`
188
+ cursor: pointer;
189
+ color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
190
+ `
191
+ )
192
+ })
193
+ );
194
+ });
205
195
  var Icon = import_react2.default.forwardRef(
206
196
  (_a, ref) => {
207
197
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/hovering-toolbar/hovering-toolbar.tsx","../../../src/lib/get-text-around-cursor.ts","../../../src/components/hovering-toolbar/hovering-editor-provider.tsx","../../../src/components/hovering-toolbar/hovering-toolbar-components.tsx","../../../src/hooks/misc/use-autosize-textarea.tsx","../../../src/components/source-search-box/source-search-box.tsx","../../../src/components/ui/command.tsx","../../../src/lib/utils.ts","../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx","../../../src/components/ui/button.tsx","../../../src/components/ui/label.tsx","../../../src/lib/stream-promise-flatten.ts","../../../src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx","../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { Editor, Location, Transforms } from \"slate\";\nimport { useSlate, useSlateSelection } from \"slate-react\";\nimport {\n getFullEditorTextWithNewlines,\n getTextAroundSelection,\n} from \"../../lib/get-text-around-cursor\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../types/base/autosuggestions-bare-function\";\nimport { useHoveringEditorContext } from \"./hovering-editor-provider\";\nimport { Menu, Portal } from \"./hovering-toolbar-components\";\nimport { HoveringInsertionPromptBox } from \"./text-insertion-prompt-box\";\n\nexport interface HoveringToolbarProps {\n apiConfig: InsertionEditorApiConfig;\n contextCategories: string[];\n hoverMenuClassname: string | undefined;\n}\n\nexport const HoveringToolbar = (props: HoveringToolbarProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const editor = useSlate();\n const selection = useSlateSelection();\n const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();\n\n // only render on client\n const [isClient, setIsClient] = useState(false);\n useEffect(() => {\n setIsClient(true);\n }, []);\n\n const isShown = isClient && isDisplayed && selection;\n\n useLayoutEffect(() => {\n const el = ref.current;\n const { selection } = editor;\n\n if (!el || !isShown) {\n return;\n }\n\n if (!selection) {\n el.removeAttribute(\"style\");\n return;\n }\n\n const domSelection = window.getSelection();\n if (!domSelection || domSelection.rangeCount === 0) {\n return;\n }\n\n const domRange = domSelection.getRangeAt(0);\n const rect = domRange.getBoundingClientRect();\n\n // We use window = (0,0,0,0) as a signal that the selection is not in the original copilot-textarea,\n // but inside the hovering window.\n //\n // in such case, we simply do nothing.\n if (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0) {\n return;\n }\n\n const verticalOffsetFromCorner = 0;\n const horizontalOffsetFromCorner = 0;\n\n // position the toolbar below the selection\n let top = rect.bottom + window.scrollY + verticalOffsetFromCorner;\n\n // no space left at bottom, move up\n if (rect.bottom + el.offsetHeight > window.innerHeight - verticalOffsetFromCorner) {\n top = rect.top + window.scrollY - el.offsetHeight - verticalOffsetFromCorner;\n }\n\n // position the toolbar in the center of the selection\n let left =\n rect.left + window.scrollX - el.offsetWidth / 2 + rect.width / 2 + horizontalOffsetFromCorner;\n\n // no space left at left, move right\n if (left < horizontalOffsetFromCorner) {\n left = horizontalOffsetFromCorner;\n }\n // no space left at right, move left\n else if (left + el.offsetWidth > window.innerWidth - horizontalOffsetFromCorner) {\n left = window.innerWidth - el.offsetWidth - horizontalOffsetFromCorner;\n }\n\n el.style.opacity = \"1\";\n el.style.position = \"absolute\";\n\n el.style.top = `${top}px`;\n el.style.left = `${left}px`;\n }, [isShown]);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n setIsDisplayed(false);\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [ref, setIsDisplayed]);\n\n if (!isShown) {\n return null;\n }\n\n return (\n <Portal>\n <Menu\n ref={ref}\n className={\n \"copilot-kit-textarea-css-scope \" +\n (props.hoverMenuClassname ||\n \"p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700\")\n }\n data-testid=\"hovering-toolbar\"\n >\n <HoveringInsertionPromptBox\n editorState={editorState(editor, selection)}\n apiConfig={props.apiConfig}\n performInsertion={(insertedText) => {\n // replace the selection with the inserted text\n Transforms.delete(editor, { at: selection });\n Transforms.insertText(editor, insertedText, {\n at: selection,\n });\n setIsDisplayed(false);\n }}\n contextCategories={props.contextCategories}\n />\n </Menu>\n </Portal>\n );\n};\n\nfunction editorState(editor: Editor, selection: Location): EditingEditorState {\n const textAroundCursor = getTextAroundSelection(editor);\n if (textAroundCursor) {\n return textAroundCursor;\n }\n\n return {\n textBeforeCursor: getFullEditorTextWithNewlines(editor),\n textAfterCursor: \"\",\n selectedText: \"\",\n };\n}\n","import { Editor, Node, Path, Range, Text, Element, BasePoint, BaseRange, Point } from \"slate\";\nimport { EditorAutocompleteState } from \"../types/base/editor-autocomplete-state\";\n\nexport interface EditorTextState {\n selection: BaseRange;\n\n textBeforeCursor: string;\n selectedText: string;\n textAfterCursor: string;\n}\n\nexport function getTextAroundCollapsedCursor(editor: Editor): EditorAutocompleteState | null {\n const { selection } = editor;\n if (!selection || !Range.isCollapsed(selection)) {\n return null;\n }\n\n const cursorPoint = selection.anchor;\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: cursorPoint,\n };\n const afterRange: Range = {\n anchor: cursorPoint,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n\n return {\n cursorPoint: cursorPoint,\n textBeforeCursor: before,\n textAfterCursor: after,\n };\n}\n\nexport function getTextAroundSelection(editor: Editor): EditorTextState | null {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n\n const wellOrderedSelection = wellOrderedRange(selection);\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: wellOrderedSelection.anchor,\n };\n const afterRange: Range = {\n anchor: wellOrderedSelection.focus,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);\n\n return {\n selection: wellOrderedSelection,\n textBeforeCursor: before,\n selectedText,\n textAfterCursor: after,\n };\n}\n\nexport function getFullEditorTextWithNewlines(editor: Editor): string {\n const fullDocumentRange: Range = {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n };\n return extractTextWithNewlines(editor, fullDocumentRange);\n}\n\n// Helper function to extract text with newlines\nexport function extractTextWithNewlines(editor: Editor, range: Range): string {\n const voids = false;\n const [start, end] = Range.edges(range);\n let text = \"\";\n let lastBlock: Node | null = null;\n\n for (const [node, path] of Editor.nodes(editor, {\n at: range,\n match: Text.isText,\n voids,\n })) {\n let t = node.text;\n\n // Determine the parent block of the current text node\n const [block] = Editor.above(editor, {\n at: path,\n match: (n) => Element.isElement(n) && n.type === \"paragraph\",\n }) || [null];\n\n // If we encounter a new block, prepend a newline\n if (lastBlock !== block && block) {\n // check that lastBlock is not null to avoid adding a newline at the beginning\n if (lastBlock) {\n text += \"\\n\";\n }\n lastBlock = block;\n }\n\n if (Path.equals(path, end.path)) {\n t = t.slice(0, end.offset);\n }\n\n if (Path.equals(path, start.path)) {\n t = t.slice(start.offset);\n }\n\n text += t;\n }\n\n return text;\n}\n\nfunction wellOrderedRange(range: BaseRange): BaseRange {\n const { anchor, focus } = range;\n // if anchor is before focus, return range as is\n if (Point.isBefore(anchor, focus)) {\n return range;\n }\n\n // if focus is before anchor, return range with anchor and focus swapped\n return {\n anchor: focus,\n focus: anchor,\n };\n}\n","import { createContext, useState, useContext, ReactNode } from \"react\";\n\ninterface HoveringEditorContextProps {\n isDisplayed: boolean;\n setIsDisplayed: (value: boolean) => void;\n}\n\nconst HoveringEditorContext = createContext<HoveringEditorContextProps>({\n isDisplayed: false,\n setIsDisplayed: () => {},\n});\n\nexport interface HoveringEditorProviderProps {\n children: ReactNode;\n}\n\n/**\n * A context provider for the hovering editor over the `CopilotTextarea`\n * (used to edit and insert text into the `CopilotTextarea`).\n */\nexport const HoveringEditorProvider = ({ children }: HoveringEditorProviderProps) => {\n const [isDisplayed, setIsDisplayed] = useState<boolean>(false);\n\n return (\n <HoveringEditorContext.Provider value={{ isDisplayed, setIsDisplayed }}>\n {children}\n </HoveringEditorContext.Provider>\n );\n};\n\nexport const useHoveringEditorContext = () => useContext(HoveringEditorContext);\n","import { css, cx } from \"@emotion/css\";\nimport React, { PropsWithChildren, Ref } from \"react\";\nimport ReactDOM from \"react-dom\";\n\ninterface BaseProps {\n className: string;\n [key: string]: unknown;\n}\n\nexport const Button = React.forwardRef(\n (\n {\n className,\n active,\n reversed,\n ...props\n }: PropsWithChildren<\n {\n active: boolean;\n reversed: boolean;\n } & BaseProps\n >,\n ref: Ref<HTMLSpanElement | null>,\n ) => (\n <span\n {...props}\n ref={ref as Ref<HTMLSpanElement>}\n className={cx(\n className,\n css`\n cursor: pointer;\n color: ${reversed ? (active ? \"white\" : \"#aaa\") : active ? \"black\" : \"#ccc\"};\n `,\n )}\n />\n ),\n);\n\nexport const Icon = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLSpanElement | null>) => (\n <span\n {...props}\n ref={ref as Ref<HTMLSpanElement>}\n className={cx(\n \"material-icons\",\n className,\n css`\n font-size: 18px;\n vertical-align: text-bottom;\n `,\n )}\n />\n ),\n);\n\nexport const Menu = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLDivElement | null>) => {\n return (\n <div\n {...props}\n data-testid=\"menu\"\n ref={ref as Ref<HTMLDivElement>}\n className={cx(\n className,\n css`\n & > * {\n display: inline-block;\n }\n\n & > * + * {\n margin-left: 15px;\n }\n `,\n )}\n />\n );\n },\n);\nexport const Portal = ({ children }: { children: React.ReactNode }) => {\n return typeof document === \"object\" ? ReactDOM.createPortal(children, document.body) : null;\n};\n\nexport const Toolbar = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref?: Ref<HTMLDivElement>) => (\n <Menu\n {...props}\n ref={ref}\n className={cx(\n className,\n css`\n position: relative;\n padding: 1px 18px 17px;\n margin: 0 -20px;\n border-bottom: 2px solid #eee;\n margin-bottom: 20px;\n `,\n )}\n />\n ),\n);\n","import { Ref, RefObject, useEffect } from \"react\";\n\n// Updates the height of a <textarea> when the value changes.\nconst useAutosizeTextArea = (textAreaRef: RefObject<HTMLTextAreaElement>, value: string) => {\n useEffect(() => {\n if (textAreaRef.current !== null) {\n // We need to reset the height momentarily to get the correct scrollHeight for the textarea\n textAreaRef.current.style.height = \"0px\";\n const scrollHeight = textAreaRef.current.scrollHeight;\n\n // We then set the height directly, outside of the render loop\n // Trying to set this with state or a ref will product an incorrect value.\n textAreaRef.current.style.height = scrollHeight + \"px\";\n }\n }, [textAreaRef, value]);\n};\n\nexport default useAutosizeTextArea;\n","import { useState } from \"react\";\nimport {\n Command,\n CommandDialog,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n CommandShortcut,\n} from \"../ui/command\";\n\nimport { Calculator, Calendar, CreditCard, Settings, Smile, User } from \"lucide-react\";\n\nimport { DocumentPointer } from \"@copilotkit/react-core\";\n\nexport interface SourceSearchBoxProps {\n searchTerm: string;\n suggestedFiles: DocumentPointer[];\n onSelectedFile: (filePointer: DocumentPointer) => void;\n}\n\nexport function SourceSearchBox(props: SourceSearchBoxProps) {\n const [selectedValue, setSelectedValue] = useState<string>(\"\");\n\n return (\n <Command\n className=\"rounded-lg border shadow-md\"\n value={selectedValue}\n onValueChange={(value) => {\n setSelectedValue(value);\n }}\n filter={(value, search) => {\n // if the search term is empty, show all commands\n if (props.searchTerm === \"\") return 1;\n\n // if the search term is a prefix of the command, show it\n if (value.startsWith(props.searchTerm)) return 1;\n\n // otherwise, don't show it\n return 0;\n }}\n >\n <CommandInput\n value={props.searchTerm}\n className=\"rounded-t-lg hidden\"\n placeholder=\"Search for a command...\"\n />\n <CommandList>\n <CommandEmpty>No results found.</CommandEmpty>\n\n <CommandGroup heading=\"Available resources\">\n {props.suggestedFiles.map((filePointer) => {\n return (\n <CommandItem\n key={`word-${filePointer.sourceApplication}.${filePointer.name}`}\n value={filePointer.name}\n onSelect={(value) => {\n props.onSelectedFile(filePointer);\n }}\n >\n <div className=\" px-3 flex flex-row gap-1 items-center\">\n <Logo width=\"20px\" height=\"20px\">\n <img\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n className=\"w-full h-full\"\n />\n </Logo>\n {filePointer.name}\n </div>\n </CommandItem>\n );\n })}\n </CommandGroup>\n\n {/* <CommandGroup heading=\"Suggestions\">\n <CommandItem\n onSelect={(value) => {\n console.log(value);\n console.log(value);\n }}\n >\n <Calendar className=\"mr-2 h-4 w-4\" />\n <span>Calendar</span>\n </CommandItem>\n <CommandItem>\n <Smile className=\"mr-2 h-4 w-4\" />\n <span>Search Emoji</span>\n </CommandItem>\n <CommandItem>\n <Calculator className=\"mr-2 h-4 w-4\" />\n <span>Calculator</span>\n </CommandItem>\n </CommandGroup> */}\n <CommandSeparator />\n </CommandList>\n </Command>\n );\n}\n\nexport function Logo({\n children,\n width,\n height,\n}: {\n children: React.ReactNode;\n width: string;\n height: string;\n}) {\n return (\n <div className=\"flex items-center justify-center\" style={{ width: width, height: height }}>\n {children}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { cn } from \"../../lib/utils\";\nimport { Dialog, DialogContent } from \"./dialog\";\n\nconst Command = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive\n ref={ref}\n className={cn(\n \"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground\",\n className,\n )}\n {...props}\n />\n));\nCommand.displayName = CommandPrimitive.displayName;\n\ninterface CommandDialogProps extends DialogProps {}\n\nconst CommandDialog = ({ children, ...props }: CommandDialogProps) => {\n return (\n <Dialog {...props}>\n <DialogContent className=\"overflow-hidden p-0 shadow-lg\">\n <Command className=\"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\">\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n );\n};\n\nconst CommandInput = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Input>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>\n>(({ className, ...props }, ref) => (\n <div className=\"flex items-center border-b px-3\" cmdk-input-wrapper=\"\">\n {/* <Search className=\"mr-2 h-4 w-4 shrink-0 opacity-50\" /> */}\n <CommandPrimitive.Input\n ref={ref}\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n />\n </div>\n));\n\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\nconst CommandList = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.List>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.List\n ref={ref}\n className={cn(\"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2\", className)}\n {...props}\n />\n));\n\nCommandList.displayName = CommandPrimitive.List.displayName;\n\nconst CommandEmpty = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Empty>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>\n>((props, ref) => (\n <CommandPrimitive.Empty ref={ref} className=\"py-6 text-center text-sm\" {...props} />\n));\n\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\nconst CommandGroup = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Group>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Group\n ref={ref}\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n />\n));\n\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\nconst CommandSeparator = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 h-px bg-border\", className)}\n {...props}\n />\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\nconst CommandItem = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Item\n ref={ref}\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n />\n));\n\nCommandItem.displayName = CommandPrimitive.Item.displayName;\n\nconst CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\"ml-auto text-xs tracking-widest text-muted-foreground\", className)}\n {...props}\n />\n );\n};\nCommandShortcut.displayName = \"CommandShortcut\";\n\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandShortcut,\n CommandSeparator,\n};\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport async function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined,\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n","import useAutosizeTextArea from \"../../../hooks/misc/use-autosize-textarea\";\nimport {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n} from \"../../../types/base/autosuggestions-bare-function\";\nimport { SourceSearchBox } from \"../../source-search-box/source-search-box\";\nimport { DocumentPointer, useCopilotContext } from \"@copilotkit/react-core\";\nimport { Button } from \"../../ui/button\";\nimport { Label } from \"../../ui/label\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { streamPromiseFlatten } from \"../../../lib/stream-promise-flatten\";\nimport { IncludedFilesPreview } from \"./included-files-preview\";\nimport { useHoveringEditorContext } from \"../hovering-editor-provider\";\n\nexport type SuggestionState = {\n editorState: EditingEditorState;\n};\n\nexport interface HoveringInsertionPromptBoxCoreProps {\n state: SuggestionState;\n performInsertion: (insertedText: string) => void;\n insertionOrEditingFunction: Generator_InsertionOrEditingSuggestion;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBoxCore = ({\n performInsertion,\n state,\n insertionOrEditingFunction,\n contextCategories,\n}: HoveringInsertionPromptBoxCoreProps) => {\n const { getDocumentsContext } = useCopilotContext();\n\n const [editSuggestion, setEditSuggestion] = useState<string>(\"\");\n const [suggestionIsLoading, setSuggestionIsLoading] = useState<boolean>(false);\n\n const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>(\"\");\n\n const [generatingSuggestion, setGeneratingSuggestion] = useState<ReadableStream<string> | null>(\n null,\n );\n\n const adjustmentTextAreaRef = useRef<HTMLTextAreaElement>(null);\n const suggestionTextAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [filePointers, setFilePointers] = useState<DocumentPointer[]>([]);\n\n const [suggestedFiles, setSuggestedFiles] = useState<DocumentPointer[]>([]);\n useEffect(() => {\n setSuggestedFiles(getDocumentsContext(contextCategories));\n }, [contextCategories, getDocumentsContext]);\n\n useAutosizeTextArea(suggestionTextAreaRef, editSuggestion || \"\");\n useAutosizeTextArea(adjustmentTextAreaRef, adjustmentPrompt || \"\");\n\n // initially focus on the adjustment prompt text area\n useEffect(() => {\n adjustmentTextAreaRef.current?.focus();\n }, []);\n\n // continuously read the generating suggestion stream and update the edit suggestion\n useEffect(() => {\n // if no generating suggestion, do nothing\n if (!generatingSuggestion) {\n return;\n }\n\n // Check if the stream is already locked (i.e. already reading from it)\n if (generatingSuggestion.locked) {\n return;\n }\n\n // reset the edit suggestion\n setEditSuggestion(\"\");\n\n // read the generating suggestion stream and continuously update the edit suggestion\n const reader = generatingSuggestion.getReader();\n const read = async () => {\n setSuggestionIsLoading(true);\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n setEditSuggestion((prev) => {\n const newSuggestion = prev + value;\n\n // Scroll to the bottom of the textarea. We call this here to make sure scroll-to-bottom is synchronous with the state update.\n if (suggestionTextAreaRef.current) {\n suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;\n }\n return newSuggestion;\n });\n }\n\n setSuggestionIsLoading(false);\n };\n read();\n\n return () => {\n // release the lock if the reader is not closed on unmount\n const releaseLockIfNotClosed = async () => {\n try {\n await reader.closed;\n } catch {\n reader.releaseLock();\n }\n };\n\n releaseLockIfNotClosed();\n };\n }, [generatingSuggestion]);\n\n // generate an adjustment to the completed text, based on the adjustment prompt\n const beginGeneratingAdjustment = useCallback(async () => {\n // don't generate text if the prompt is empty\n if (!adjustmentPrompt.trim()) {\n return;\n }\n\n // editor state includes the text being edited, and the text before/after the selection\n // if the current edit suggestion is not empty, then use *it* as the \"selected text\" - instead of the editor state's selected text\n let modificationState = state.editorState;\n if (editSuggestion !== \"\") {\n modificationState.selectedText = editSuggestion;\n }\n\n // generate the adjustment suggestion\n const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(\n modificationState,\n adjustmentPrompt,\n filePointers,\n new AbortController().signal,\n );\n const adjustmentSuggestionTextStream = streamPromiseFlatten(\n adjustmentSuggestionTextStreamPromise,\n );\n\n setGeneratingSuggestion(adjustmentSuggestionTextStream);\n }, [\n adjustmentPrompt,\n editSuggestion,\n state.editorState,\n insertionOrEditingFunction,\n filePointers,\n ]);\n\n const isLoading = suggestionIsLoading;\n\n const textToEdit = editSuggestion || state.editorState.selectedText;\n const adjustmentLabel =\n textToEdit === \"\"\n ? \"Describe the text you want to insert\"\n : \"Describe adjustments to the suggested text\";\n const placeholder =\n textToEdit === \"\"\n ? \"e.g. 'summarize the client's top 3 pain-points from @CallTranscript'\"\n : \"e.g. 'make it more formal', 'be more specific', ...\";\n\n const { setIsDisplayed } = useHoveringEditorContext();\n\n const AdjustmentPromptComponent = (\n <>\n <Label className=\"\">{adjustmentLabel}</Label>\n <div className=\"relative w-full flex items-center\">\n <textarea\n data-testid=\"adjustment-prompt\"\n disabled={suggestionIsLoading}\n ref={adjustmentTextAreaRef}\n value={adjustmentPrompt}\n onChange={(e) => setAdjustmentPrompt(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && e.shiftKey) {\n e.preventDefault();\n setAdjustmentPrompt(adjustmentPrompt + \"\\n\");\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n beginGeneratingAdjustment();\n }\n }}\n placeholder={placeholder}\n style={{ minHeight: \"3rem\" }}\n 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]\"\n rows={1}\n />\n <button\n onClick={beginGeneratingAdjustment}\n className=\"absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center\"\n data-testid=\"generate-button\"\n >\n <i className=\"material-icons\">arrow_forward</i>\n </button>\n </div>\n </>\n );\n\n const SuggestionComponent = (\n <>\n <div className=\"flex justify-between items-end w-full\">\n <Label className=\"mt-4\">Suggested:</Label>\n <div className=\"ml-auto\">\n {isLoading && (\n <div className=\"flex justify-center items-center\">\n <div\n 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]\"\n role=\"status\"\n >\n <span className=\"!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]\">\n Loading...\n </span>\n </div>\n </div>\n )}\n </div>\n </div>\n <textarea\n data-testid=\"suggestion-result\"\n ref={suggestionTextAreaRef}\n value={editSuggestion}\n disabled={suggestionIsLoading}\n onChange={(e) => setEditSuggestion(e.target.value)}\n className=\"w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50\"\n style={{ overflow: \"auto\", maxHeight: \"10em\" }}\n />\n </>\n );\n\n const SubmitComponent = (\n <div className=\"flex w-full gap-4 justify-start\">\n <Button\n data-testid=\"insert-button\"\n className=\" bg-green-700 text-white\"\n onClick={() => {\n performInsertion(editSuggestion);\n }}\n >\n Insert <i className=\"material-icons\">check</i>\n </Button>\n </div>\n );\n\n // show source search if the last word in the adjustment prompt BEGINS with an @\n const sourceSearchCandidate = adjustmentPrompt.split(\" \").pop();\n // if the candidate is @someCandidate, then 'someCandidate', otherwise undefined\n const sourceSearchWord = sourceSearchCandidate?.startsWith(\"@\")\n ? sourceSearchCandidate.slice(1)\n : undefined;\n\n return (\n <div className=\"w-full flex flex-col items-start relative gap-2\">\n {AdjustmentPromptComponent}\n {filePointers.length > 0 && (\n <IncludedFilesPreview includedFiles={filePointers} setIncludedFiles={setFilePointers} />\n )}\n {sourceSearchWord !== undefined && (\n <SourceSearchBox\n searchTerm={sourceSearchWord}\n suggestedFiles={suggestedFiles}\n onSelectedFile={(filePointer) => {\n setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), \"\"));\n setFilePointers((prev) => [...prev, filePointer]);\n\n // focus back on the adjustment prompt, and move the cursor to the end\n adjustmentTextAreaRef.current?.focus();\n }}\n />\n )}\n {generatingSuggestion ? SuggestionComponent : null}\n {generatingSuggestion ? SubmitComponent : null}\n </div>\n );\n};\n","import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst buttonVariants = cva(\n \"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\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline: \"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\n secondary: \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-10 px-4 py-2\",\n sm: \"h-9 rounded-md px-3\",\n lg: \"h-11 rounded-md px-8\",\n icon: \"h-10 w-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />\n );\n },\n);\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n","import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst labelVariants = cva(\n \"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n);\n\nconst Label = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n","/**\n * Flatten a promise of a stream, into a stream.\n *\n * Useful because a stream already includes the notion of async value delivery,\n * so it often makes sense to simply await the values rather than the generator of the values.\n *\n * @param {Promise<ReadableStream<A>>} promise - The promise to flatten.\n * @returns {ReadableStream<A>} - The flattened stream.\n */\n\nexport function streamPromiseFlatten<A>(promise: Promise<ReadableStream<A>>): ReadableStream<A> {\n return new ReadableStream<A>({\n async start(controller) {\n try {\n const stream = await promise;\n const reader = stream.getReader();\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n controller.close();\n return;\n }\n\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n }\n },\n });\n}\n","import { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Label } from \"../../ui/label\";\nimport React from \"react\";\nimport Chip from \"@mui/material/Chip/Chip.js\";\nimport Avatar from \"@mui/material/Avatar/Avatar.js\";\n\nexport interface IncludedFilesPreviewProps {\n includedFiles: DocumentPointer[];\n setIncludedFiles: React.Dispatch<React.SetStateAction<DocumentPointer[]>>;\n}\n\nexport const IncludedFilesPreview = ({\n includedFiles,\n setIncludedFiles,\n}: IncludedFilesPreviewProps) => {\n return (\n <div className=\"flex flex-col gap-2 mt-2\">\n <Label className=\"\">Included context:</Label>\n <div className=\"flex flex-wrap gap-2\">\n {includedFiles.map((filePointer, index) => {\n return (\n <FileChipPreview\n key={`file-${filePointer.sourceApplication}.${filePointer.name}`}\n filePointer={filePointer}\n onDelete={() => {\n setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));\n }}\n />\n );\n })}\n </div>\n </div>\n );\n};\n\nexport interface FileChipPreviewProps {\n filePointer: DocumentPointer;\n onDelete: () => void;\n}\n\nexport const FileChipPreview = ({ filePointer, onDelete }: FileChipPreviewProps) => {\n return (\n <Chip\n label={filePointer.name}\n onDelete={onDelete}\n avatar={\n <Avatar\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n sx={{ backgroundColor: \"transparent\" }}\n ></Avatar>\n }\n />\n );\n};\n","import { HoveringInsertionPromptBoxCore } from \"./hovering-insertion-prompt-box-core\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../../types/base/autosuggestions-bare-function\";\n\nexport interface Props {\n editorState: EditingEditorState;\n apiConfig: InsertionEditorApiConfig;\n performInsertion: (insertedText: string) => void;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBox = (props: Props) => {\n return (\n <div\n className=\"flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white\"\n style={{ width: \"35rem\" }}\n >\n <HoveringInsertionPromptBoxCore\n state={{\n editorState: props.editorState,\n }}\n insertionOrEditingFunction={props.apiConfig.insertionOrEditingFunction}\n performInsertion={props.performInsertion}\n contextCategories={props.contextCategories}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAA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M;AACX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAC9D;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,SACE,8CAAC,UACC;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WACE,qCACC,MAAM,sBACL;AAAA,MAEJ,eAAY;AAAA,MAEZ;AAAA,QAAC;AAAA;AAAA,UACC,aAAa,YAAY,QAAQ,SAAS;AAAA,UAC1C,WAAW,MAAM;AAAA,UACjB,kBAAkB,CAAC,iBAAiB;AAElC,qCAAW,OAAO,QAAQ,EAAE,IAAI,UAAU,CAAC;AAC3C,qCAAW,WAAW,QAAQ,cAAc;AAAA,cAC1C,IAAI;AAAA,YACN,CAAC;AACD,2BAAe,KAAK;AAAA,UACtB;AAAA,UACA,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EACF,GACF;AAEJ;AAEA,SAAS,YAAY,QAAgB,WAAyC;AAC5E,QAAM,mBAAmB,uBAAuB,MAAM;AACtD,MAAI,kBAAkB;AACpB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,kBAAkB,8BAA8B,MAAM;AAAA,IACtD,iBAAiB;AAAA,IACjB,cAAc;AAAA,EAChB;AACF;","names":["import_react","import_slate","import_react","import_jsx_runtime","React","ReactDOM","import_react","import_react","React","import_jsx_runtime","CommandPrimitive","CommandPrimitive","import_jsx_runtime","React","import_jsx_runtime","Button","React","import_class_variance_authority","import_jsx_runtime","import_react","import_jsx_runtime","Chip","Avatar","import_jsx_runtime","Button","import_jsx_runtime","import_jsx_runtime","selection"]}
1
+ {"version":3,"sources":["../../../src/components/hovering-toolbar/hovering-toolbar.tsx","../../../src/lib/get-text-around-cursor.ts","../../../src/components/hovering-toolbar/hovering-editor-provider.tsx","../../../src/components/hovering-toolbar/hovering-toolbar-components.tsx","../../../src/hooks/misc/use-autosize-textarea.tsx","../../../src/components/source-search-box/source-search-box.tsx","../../../src/components/ui/command.tsx","../../../src/lib/utils.ts","../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx","../../../src/components/ui/button.tsx","../../../src/components/ui/label.tsx","../../../src/lib/stream-promise-flatten.ts","../../../src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx","../../../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { Editor, Location, Transforms } from \"slate\";\nimport { useSlate, useSlateSelection } from \"slate-react\";\nimport {\n getFullEditorTextWithNewlines,\n getTextAroundSelection,\n} from \"../../lib/get-text-around-cursor\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../types/base/autosuggestions-bare-function\";\nimport { useHoveringEditorContext } from \"./hovering-editor-provider\";\nimport { Menu, Portal } from \"./hovering-toolbar-components\";\nimport { HoveringInsertionPromptBox } from \"./text-insertion-prompt-box\";\n\nexport interface HoveringToolbarProps {\n apiConfig: InsertionEditorApiConfig;\n contextCategories: string[];\n hoverMenuClassname: string | undefined;\n}\n\nexport const HoveringToolbar = (props: HoveringToolbarProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const editor = useSlate();\n const selection = useSlateSelection();\n const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();\n\n // only render on client\n const [isClient, setIsClient] = useState(false);\n useEffect(() => {\n setIsClient(true);\n }, []);\n\n const isShown = isClient && isDisplayed && selection;\n\n useLayoutEffect(() => {\n const el = ref.current;\n const { selection } = editor;\n\n if (!el || !isShown) {\n return;\n }\n\n if (!selection) {\n el.removeAttribute(\"style\");\n return;\n }\n\n const domSelection = window.getSelection();\n if (!domSelection || domSelection.rangeCount === 0) {\n return;\n }\n\n const domRange = domSelection.getRangeAt(0);\n const rect = domRange.getBoundingClientRect();\n\n // We use window = (0,0,0,0) as a signal that the selection is not in the original copilot-textarea,\n // but inside the hovering window.\n //\n // in such case, we simply do nothing.\n if (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0) {\n return;\n }\n\n const verticalOffsetFromCorner = 0;\n const horizontalOffsetFromCorner = 0;\n\n // position the toolbar below the selection\n let top = rect.bottom + window.scrollY + verticalOffsetFromCorner;\n\n // no space left at bottom, move up\n if (rect.bottom + el.offsetHeight > window.innerHeight - verticalOffsetFromCorner) {\n top = rect.top + window.scrollY - el.offsetHeight - verticalOffsetFromCorner;\n }\n\n // position the toolbar in the center of the selection\n let left =\n rect.left + window.scrollX - el.offsetWidth / 2 + rect.width / 2 + horizontalOffsetFromCorner;\n\n // no space left at left, move right\n if (left < horizontalOffsetFromCorner) {\n left = horizontalOffsetFromCorner;\n }\n // no space left at right, move left\n else if (left + el.offsetWidth > window.innerWidth - horizontalOffsetFromCorner) {\n left = window.innerWidth - el.offsetWidth - horizontalOffsetFromCorner;\n }\n\n el.style.opacity = \"1\";\n el.style.position = \"absolute\";\n\n el.style.top = `${top}px`;\n el.style.left = `${left}px`;\n }, [isShown]);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n setIsDisplayed(false);\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [ref, setIsDisplayed]);\n\n if (!isShown) {\n return null;\n }\n\n return (\n <Portal>\n <Menu\n ref={ref}\n className={\n \"copilot-kit-textarea-css-scope \" +\n (props.hoverMenuClassname ||\n \"p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700\")\n }\n data-testid=\"hovering-toolbar\"\n >\n <HoveringInsertionPromptBox\n editorState={editorState(editor, selection)}\n apiConfig={props.apiConfig}\n performInsertion={(insertedText) => {\n // replace the selection with the inserted text\n Transforms.delete(editor, { at: selection });\n Transforms.insertText(editor, insertedText, {\n at: selection,\n });\n setIsDisplayed(false);\n }}\n contextCategories={props.contextCategories}\n />\n </Menu>\n </Portal>\n );\n};\n\nfunction editorState(editor: Editor, selection: Location): EditingEditorState {\n const textAroundCursor = getTextAroundSelection(editor);\n if (textAroundCursor) {\n return textAroundCursor;\n }\n\n return {\n textBeforeCursor: getFullEditorTextWithNewlines(editor),\n textAfterCursor: \"\",\n selectedText: \"\",\n };\n}\n","import { Editor, Node, Path, Range, Text, Element, BasePoint, BaseRange, Point } from \"slate\";\nimport { EditorAutocompleteState } from \"../types/base/editor-autocomplete-state\";\n\nexport interface EditorTextState {\n selection: BaseRange;\n\n textBeforeCursor: string;\n selectedText: string;\n textAfterCursor: string;\n}\n\nexport function getTextAroundCollapsedCursor(editor: Editor): EditorAutocompleteState | null {\n const { selection } = editor;\n if (!selection || !Range.isCollapsed(selection)) {\n return null;\n }\n\n const cursorPoint = selection.anchor;\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: cursorPoint,\n };\n const afterRange: Range = {\n anchor: cursorPoint,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n\n return {\n cursorPoint: cursorPoint,\n textBeforeCursor: before,\n textAfterCursor: after,\n };\n}\n\nexport function getTextAroundSelection(editor: Editor): EditorTextState | null {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n\n const wellOrderedSelection = wellOrderedRange(selection);\n\n // Create two ranges: one before the anchor and one after\n const beforeRange: Range = {\n anchor: Editor.start(editor, []),\n focus: wellOrderedSelection.anchor,\n };\n const afterRange: Range = {\n anchor: wellOrderedSelection.focus,\n focus: Editor.end(editor, []),\n };\n\n // Extract text for these ranges\n const before = extractTextWithNewlines(editor, beforeRange);\n const after = extractTextWithNewlines(editor, afterRange);\n const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);\n\n return {\n selection: wellOrderedSelection,\n textBeforeCursor: before,\n selectedText,\n textAfterCursor: after,\n };\n}\n\nexport function getFullEditorTextWithNewlines(editor: Editor): string {\n const fullDocumentRange: Range = {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n };\n return extractTextWithNewlines(editor, fullDocumentRange);\n}\n\n// Helper function to extract text with newlines\nexport function extractTextWithNewlines(editor: Editor, range: Range): string {\n const voids = false;\n const [start, end] = Range.edges(range);\n let text = \"\";\n let lastBlock: Node | null = null;\n\n for (const [node, path] of Editor.nodes(editor, {\n at: range,\n match: Text.isText,\n voids,\n })) {\n let t = node.text;\n\n // Determine the parent block of the current text node\n const [block] = Editor.above(editor, {\n at: path,\n match: (n) => Element.isElement(n) && n.type === \"paragraph\",\n }) || [null];\n\n // If we encounter a new block, prepend a newline\n if (lastBlock !== block && block) {\n // check that lastBlock is not null to avoid adding a newline at the beginning\n if (lastBlock) {\n text += \"\\n\";\n }\n lastBlock = block;\n }\n\n if (Path.equals(path, end.path)) {\n t = t.slice(0, end.offset);\n }\n\n if (Path.equals(path, start.path)) {\n t = t.slice(start.offset);\n }\n\n text += t;\n }\n\n return text;\n}\n\nfunction wellOrderedRange(range: BaseRange): BaseRange {\n const { anchor, focus } = range;\n // if anchor is before focus, return range as is\n if (Point.isBefore(anchor, focus)) {\n return range;\n }\n\n // if focus is before anchor, return range with anchor and focus swapped\n return {\n anchor: focus,\n focus: anchor,\n };\n}\n","import { createContext, useState, useContext, ReactNode } from \"react\";\n\ninterface HoveringEditorContextProps {\n isDisplayed: boolean;\n setIsDisplayed: (value: boolean) => void;\n}\n\nconst HoveringEditorContext = createContext<HoveringEditorContextProps>({\n isDisplayed: false,\n setIsDisplayed: () => {},\n});\n\nexport interface HoveringEditorProviderProps {\n children: ReactNode;\n}\n\n/**\n * A context provider for the hovering editor over the `CopilotTextarea`\n * (used to edit and insert text into the `CopilotTextarea`).\n */\nexport const HoveringEditorProvider = ({ children }: HoveringEditorProviderProps) => {\n const [isDisplayed, setIsDisplayed] = useState<boolean>(false);\n\n return (\n <HoveringEditorContext.Provider value={{ isDisplayed, setIsDisplayed }}>\n {children}\n </HoveringEditorContext.Provider>\n );\n};\n\nexport const useHoveringEditorContext = () => useContext(HoveringEditorContext);\n","import { css, cx } from \"@emotion/css\";\nimport React, { PropsWithChildren, Ref } from \"react\";\nimport ReactDOM from \"react-dom\";\n\ninterface BaseProps {\n className?: string;\n [key: string]: unknown;\n}\n\nexport const Button = React.forwardRef<\n HTMLSpanElement,\n PropsWithChildren<{ active: boolean; reversed: boolean } & BaseProps>\n>(({ className, active, reversed, ...props }, ref) => (\n <span\n {...props}\n ref={ref}\n className={cx(\n className as string,\n css`\n cursor: pointer;\n color: ${reversed ? (active ? \"white\" : \"#aaa\") : active ? \"black\" : \"#ccc\"};\n `,\n )}\n />\n));\n\nexport const Icon = React.forwardRef<HTMLSpanElement, PropsWithChildren<BaseProps>>(\n ({ className, ...props }, ref) => (\n <span\n {...props}\n ref={ref}\n className={cx(\n \"material-icons\",\n className as string,\n css`\n font-size: 18px;\n vertical-align: text-bottom;\n `,\n )}\n />\n ),\n);\n\nexport const Menu = React.forwardRef<HTMLDivElement, PropsWithChildren<BaseProps>>(\n ({ className, ...props }, ref) => {\n return (\n <div\n {...props}\n data-testid=\"menu\"\n ref={ref}\n className={cx(\n className as string,\n css`\n & > * {\n display: inline-block;\n }\n\n & > * + * {\n margin-left: 15px;\n }\n `,\n )}\n />\n );\n },\n);\nexport const Portal = ({ children }: { children: React.ReactNode }) => {\n return typeof document === \"object\" ? ReactDOM.createPortal(children, document.body) : null;\n};\n\nexport const Toolbar = React.forwardRef<HTMLDivElement, PropsWithChildren<BaseProps>>(\n ({ className, ...props }, ref) => (\n <Menu\n {...props}\n ref={ref}\n className={cx(\n className as string,\n css`\n position: relative;\n padding: 1px 18px 17px;\n margin: 0 -20px;\n border-bottom: 2px solid #eee;\n margin-bottom: 20px;\n `,\n )}\n />\n ),\n);\n","import { Ref, RefObject, useEffect } from \"react\";\n\n// Updates the height of a <textarea> when the value changes.\nconst useAutosizeTextArea = (textAreaRef: RefObject<HTMLTextAreaElement | null>, value: string) => {\n useEffect(() => {\n if (textAreaRef.current !== null) {\n // We need to reset the height momentarily to get the correct scrollHeight for the textarea\n textAreaRef.current.style.height = \"0px\";\n const scrollHeight = textAreaRef.current.scrollHeight;\n\n // We then set the height directly, outside of the render loop\n // Trying to set this with state or a ref will product an incorrect value.\n textAreaRef.current.style.height = scrollHeight + \"px\";\n }\n }, [textAreaRef, value]);\n};\n\nexport default useAutosizeTextArea;\n","import { useState } from \"react\";\nimport {\n Command,\n CommandDialog,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n CommandShortcut,\n} from \"../ui/command\";\n\nimport { Calculator, Calendar, CreditCard, Settings, Smile, User } from \"lucide-react\";\n\nimport { DocumentPointer } from \"@copilotkit/react-core\";\n\nexport interface SourceSearchBoxProps {\n searchTerm: string;\n suggestedFiles: DocumentPointer[];\n onSelectedFile: (filePointer: DocumentPointer) => void;\n}\n\nexport function SourceSearchBox(props: SourceSearchBoxProps) {\n const [selectedValue, setSelectedValue] = useState<string>(\"\");\n\n return (\n <Command\n className=\"rounded-lg border shadow-md\"\n value={selectedValue}\n onValueChange={(value) => {\n setSelectedValue(value);\n }}\n filter={(value, search) => {\n // if the search term is empty, show all commands\n if (props.searchTerm === \"\") return 1;\n\n // if the search term is a prefix of the command, show it\n if (value.startsWith(props.searchTerm)) return 1;\n\n // otherwise, don't show it\n return 0;\n }}\n >\n <CommandInput\n value={props.searchTerm}\n className=\"rounded-t-lg hidden\"\n placeholder=\"Search for a command...\"\n />\n <CommandList>\n <CommandEmpty>No results found.</CommandEmpty>\n\n <CommandGroup heading=\"Available resources\">\n {props.suggestedFiles.map((filePointer) => {\n return (\n <CommandItem\n key={`word-${filePointer.sourceApplication}.${filePointer.name}`}\n value={filePointer.name}\n onSelect={(value) => {\n props.onSelectedFile(filePointer);\n }}\n >\n <div className=\" px-3 flex flex-row gap-1 items-center\">\n <Logo width=\"20px\" height=\"20px\">\n <img\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n className=\"w-full h-full\"\n />\n </Logo>\n {filePointer.name}\n </div>\n </CommandItem>\n );\n })}\n </CommandGroup>\n\n {/* <CommandGroup heading=\"Suggestions\">\n <CommandItem\n onSelect={(value) => {\n console.log(value);\n console.log(value);\n }}\n >\n <Calendar className=\"mr-2 h-4 w-4\" />\n <span>Calendar</span>\n </CommandItem>\n <CommandItem>\n <Smile className=\"mr-2 h-4 w-4\" />\n <span>Search Emoji</span>\n </CommandItem>\n <CommandItem>\n <Calculator className=\"mr-2 h-4 w-4\" />\n <span>Calculator</span>\n </CommandItem>\n </CommandGroup> */}\n <CommandSeparator />\n </CommandList>\n </Command>\n );\n}\n\nexport function Logo({\n children,\n width,\n height,\n}: {\n children: React.ReactNode;\n width: string;\n height: string;\n}) {\n return (\n <div className=\"flex items-center justify-center\" style={{ width: width, height: height }}>\n {children}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { cn } from \"../../lib/utils\";\nimport { Dialog, DialogContent } from \"./dialog\";\n\nconst Command = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive\n ref={ref}\n className={cn(\n \"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground\",\n className,\n )}\n {...props}\n />\n));\nCommand.displayName = CommandPrimitive.displayName;\n\ninterface CommandDialogProps extends DialogProps {}\n\nconst CommandDialog = ({ children, ...props }: CommandDialogProps) => {\n return (\n <Dialog {...props}>\n <DialogContent className=\"overflow-hidden p-0 shadow-lg\">\n <Command className=\"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\">\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n );\n};\n\nconst CommandInput = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Input>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>\n>(({ className, ...props }, ref) => (\n <div className=\"flex items-center border-b px-3\" cmdk-input-wrapper=\"\">\n {/* <Search className=\"mr-2 h-4 w-4 shrink-0 opacity-50\" /> */}\n <CommandPrimitive.Input\n ref={ref}\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n />\n </div>\n));\n\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\nconst CommandList = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.List>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.List\n ref={ref}\n className={cn(\"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2\", className)}\n {...props}\n />\n));\n\nCommandList.displayName = CommandPrimitive.List.displayName;\n\nconst CommandEmpty = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Empty>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>\n>((props, ref) => (\n <CommandPrimitive.Empty ref={ref} className=\"py-6 text-center text-sm\" {...props} />\n));\n\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\nconst CommandGroup = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Group>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Group\n ref={ref}\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n />\n));\n\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\nconst CommandSeparator = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 h-px bg-border\", className)}\n {...props}\n />\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\nconst CommandItem = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Item\n ref={ref}\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n />\n));\n\nCommandItem.displayName = CommandPrimitive.Item.displayName;\n\nconst CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\"ml-auto text-xs tracking-widest text-muted-foreground\", className)}\n {...props}\n />\n );\n};\nCommandShortcut.displayName = \"CommandShortcut\";\n\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandShortcut,\n CommandSeparator,\n};\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport async function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\nexport const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>\n arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);\n\nexport function nullableCompatibleEqualityCheck<T>(\n naiveEqualityCheck: (a: T, b: T) => boolean,\n a: T | null | undefined,\n b: T | null | undefined,\n): boolean {\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n return naiveEqualityCheck(a, b);\n}\n","import useAutosizeTextArea from \"../../../hooks/misc/use-autosize-textarea\";\nimport {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n} from \"../../../types/base/autosuggestions-bare-function\";\nimport { SourceSearchBox } from \"../../source-search-box/source-search-box\";\nimport { DocumentPointer, useCopilotContext } from \"@copilotkit/react-core\";\nimport { Button } from \"../../ui/button\";\nimport { Label } from \"../../ui/label\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { streamPromiseFlatten } from \"../../../lib/stream-promise-flatten\";\nimport { IncludedFilesPreview } from \"./included-files-preview\";\nimport { useHoveringEditorContext } from \"../hovering-editor-provider\";\n\nexport type SuggestionState = {\n editorState: EditingEditorState;\n};\n\nexport interface HoveringInsertionPromptBoxCoreProps {\n state: SuggestionState;\n performInsertion: (insertedText: string) => void;\n insertionOrEditingFunction: Generator_InsertionOrEditingSuggestion;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBoxCore = ({\n performInsertion,\n state,\n insertionOrEditingFunction,\n contextCategories,\n}: HoveringInsertionPromptBoxCoreProps) => {\n const { getDocumentsContext } = useCopilotContext();\n\n const [editSuggestion, setEditSuggestion] = useState<string>(\"\");\n const [suggestionIsLoading, setSuggestionIsLoading] = useState<boolean>(false);\n\n const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>(\"\");\n\n const [generatingSuggestion, setGeneratingSuggestion] = useState<ReadableStream<string> | null>(\n null,\n );\n\n const adjustmentTextAreaRef = useRef<HTMLTextAreaElement>(null);\n const suggestionTextAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [filePointers, setFilePointers] = useState<DocumentPointer[]>([]);\n\n const [suggestedFiles, setSuggestedFiles] = useState<DocumentPointer[]>([]);\n useEffect(() => {\n setSuggestedFiles(getDocumentsContext(contextCategories));\n }, [contextCategories, getDocumentsContext]);\n\n useAutosizeTextArea(suggestionTextAreaRef, editSuggestion || \"\");\n useAutosizeTextArea(adjustmentTextAreaRef, adjustmentPrompt || \"\");\n\n // initially focus on the adjustment prompt text area\n useEffect(() => {\n adjustmentTextAreaRef.current?.focus();\n }, []);\n\n // continuously read the generating suggestion stream and update the edit suggestion\n useEffect(() => {\n // if no generating suggestion, do nothing\n if (!generatingSuggestion) {\n return;\n }\n\n // Check if the stream is already locked (i.e. already reading from it)\n if (generatingSuggestion.locked) {\n return;\n }\n\n // reset the edit suggestion\n setEditSuggestion(\"\");\n\n // read the generating suggestion stream and continuously update the edit suggestion\n const reader = generatingSuggestion.getReader();\n const read = async () => {\n setSuggestionIsLoading(true);\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n setEditSuggestion((prev) => {\n const newSuggestion = prev + value;\n\n // Scroll to the bottom of the textarea. We call this here to make sure scroll-to-bottom is synchronous with the state update.\n if (suggestionTextAreaRef.current) {\n suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;\n }\n return newSuggestion;\n });\n }\n\n setSuggestionIsLoading(false);\n };\n read();\n\n return () => {\n // release the lock if the reader is not closed on unmount\n const releaseLockIfNotClosed = async () => {\n try {\n await reader.closed;\n } catch {\n reader.releaseLock();\n }\n };\n\n releaseLockIfNotClosed();\n };\n }, [generatingSuggestion]);\n\n // generate an adjustment to the completed text, based on the adjustment prompt\n const beginGeneratingAdjustment = useCallback(async () => {\n // don't generate text if the prompt is empty\n if (!adjustmentPrompt.trim()) {\n return;\n }\n\n // editor state includes the text being edited, and the text before/after the selection\n // if the current edit suggestion is not empty, then use *it* as the \"selected text\" - instead of the editor state's selected text\n let modificationState = state.editorState;\n if (editSuggestion !== \"\") {\n modificationState.selectedText = editSuggestion;\n }\n\n // generate the adjustment suggestion\n const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(\n modificationState,\n adjustmentPrompt,\n filePointers,\n new AbortController().signal,\n );\n const adjustmentSuggestionTextStream = streamPromiseFlatten(\n adjustmentSuggestionTextStreamPromise,\n );\n\n setGeneratingSuggestion(adjustmentSuggestionTextStream);\n }, [\n adjustmentPrompt,\n editSuggestion,\n state.editorState,\n insertionOrEditingFunction,\n filePointers,\n ]);\n\n const isLoading = suggestionIsLoading;\n\n const textToEdit = editSuggestion || state.editorState.selectedText;\n const adjustmentLabel =\n textToEdit === \"\"\n ? \"Describe the text you want to insert\"\n : \"Describe adjustments to the suggested text\";\n const placeholder =\n textToEdit === \"\"\n ? \"e.g. 'summarize the client's top 3 pain-points from @CallTranscript'\"\n : \"e.g. 'make it more formal', 'be more specific', ...\";\n\n const { setIsDisplayed } = useHoveringEditorContext();\n\n const AdjustmentPromptComponent = (\n <>\n <Label className=\"\">{adjustmentLabel}</Label>\n <div className=\"relative w-full flex items-center\">\n <textarea\n data-testid=\"adjustment-prompt\"\n disabled={suggestionIsLoading}\n ref={adjustmentTextAreaRef}\n value={adjustmentPrompt}\n onChange={(e) => setAdjustmentPrompt(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && e.shiftKey) {\n e.preventDefault();\n setAdjustmentPrompt(adjustmentPrompt + \"\\n\");\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n beginGeneratingAdjustment();\n }\n }}\n placeholder={placeholder}\n style={{ minHeight: \"3rem\" }}\n 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]\"\n rows={1}\n />\n <button\n onClick={beginGeneratingAdjustment}\n className=\"absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center\"\n data-testid=\"generate-button\"\n >\n <i className=\"material-icons\">arrow_forward</i>\n </button>\n </div>\n </>\n );\n\n const SuggestionComponent = (\n <>\n <div className=\"flex justify-between items-end w-full\">\n <Label className=\"mt-4\">Suggested:</Label>\n <div className=\"ml-auto\">\n {isLoading && (\n <div className=\"flex justify-center items-center\">\n <div\n 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]\"\n role=\"status\"\n >\n <span className=\"!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]\">\n Loading...\n </span>\n </div>\n </div>\n )}\n </div>\n </div>\n <textarea\n data-testid=\"suggestion-result\"\n ref={suggestionTextAreaRef}\n value={editSuggestion}\n disabled={suggestionIsLoading}\n onChange={(e) => setEditSuggestion(e.target.value)}\n className=\"w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50\"\n style={{ overflow: \"auto\", maxHeight: \"10em\" }}\n />\n </>\n );\n\n const SubmitComponent = (\n <div className=\"flex w-full gap-4 justify-start\">\n <Button\n data-testid=\"insert-button\"\n className=\" bg-green-700 text-white\"\n onClick={() => {\n performInsertion(editSuggestion);\n }}\n >\n Insert <i className=\"material-icons\">check</i>\n </Button>\n </div>\n );\n\n // show source search if the last word in the adjustment prompt BEGINS with an @\n const sourceSearchCandidate = adjustmentPrompt.split(\" \").pop();\n // if the candidate is @someCandidate, then 'someCandidate', otherwise undefined\n const sourceSearchWord = sourceSearchCandidate?.startsWith(\"@\")\n ? sourceSearchCandidate.slice(1)\n : undefined;\n\n return (\n <div className=\"w-full flex flex-col items-start relative gap-2\">\n {AdjustmentPromptComponent}\n {filePointers.length > 0 && (\n <IncludedFilesPreview includedFiles={filePointers} setIncludedFiles={setFilePointers} />\n )}\n {sourceSearchWord !== undefined && (\n <SourceSearchBox\n searchTerm={sourceSearchWord}\n suggestedFiles={suggestedFiles}\n onSelectedFile={(filePointer) => {\n setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), \"\"));\n setFilePointers((prev) => [...prev, filePointer]);\n\n // focus back on the adjustment prompt, and move the cursor to the end\n adjustmentTextAreaRef.current?.focus();\n }}\n />\n )}\n {generatingSuggestion ? SuggestionComponent : null}\n {generatingSuggestion ? SubmitComponent : null}\n </div>\n );\n};\n","import * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst buttonVariants = cva(\n \"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\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive: \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline: \"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\n secondary: \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-10 px-4 py-2\",\n sm: \"h-9 rounded-md px-3\",\n lg: \"h-11 rounded-md px-8\",\n icon: \"h-10 w-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />\n );\n },\n);\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n","import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst labelVariants = cva(\n \"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n);\n\nconst Label = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n","/**\n * Flatten a promise of a stream, into a stream.\n *\n * Useful because a stream already includes the notion of async value delivery,\n * so it often makes sense to simply await the values rather than the generator of the values.\n *\n * @param {Promise<ReadableStream<A>>} promise - The promise to flatten.\n * @returns {ReadableStream<A>} - The flattened stream.\n */\n\nexport function streamPromiseFlatten<A>(promise: Promise<ReadableStream<A>>): ReadableStream<A> {\n return new ReadableStream<A>({\n async start(controller) {\n try {\n const stream = await promise;\n const reader = stream.getReader();\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n controller.close();\n return;\n }\n\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n }\n },\n });\n}\n","import { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Label } from \"../../ui/label\";\nimport React from \"react\";\nimport Chip from \"@mui/material/Chip/Chip.js\";\nimport Avatar from \"@mui/material/Avatar/Avatar.js\";\n\nexport interface IncludedFilesPreviewProps {\n includedFiles: DocumentPointer[];\n setIncludedFiles: React.Dispatch<React.SetStateAction<DocumentPointer[]>>;\n}\n\nexport const IncludedFilesPreview = ({\n includedFiles,\n setIncludedFiles,\n}: IncludedFilesPreviewProps) => {\n return (\n <div className=\"flex flex-col gap-2 mt-2\">\n <Label className=\"\">Included context:</Label>\n <div className=\"flex flex-wrap gap-2\">\n {includedFiles.map((filePointer, index) => {\n return (\n <FileChipPreview\n key={`file-${filePointer.sourceApplication}.${filePointer.name}`}\n filePointer={filePointer}\n onDelete={() => {\n setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));\n }}\n />\n );\n })}\n </div>\n </div>\n );\n};\n\nexport interface FileChipPreviewProps {\n filePointer: DocumentPointer;\n onDelete: () => void;\n}\n\nexport const FileChipPreview = ({ filePointer, onDelete }: FileChipPreviewProps) => {\n return (\n <Chip\n label={filePointer.name}\n onDelete={onDelete}\n avatar={\n <Avatar\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n sx={{ backgroundColor: \"transparent\" }}\n ></Avatar>\n }\n />\n );\n};\n","import { HoveringInsertionPromptBoxCore } from \"./hovering-insertion-prompt-box-core\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../../types/base/autosuggestions-bare-function\";\n\nexport interface Props {\n editorState: EditingEditorState;\n apiConfig: InsertionEditorApiConfig;\n performInsertion: (insertedText: string) => void;\n contextCategories: string[];\n}\n\nexport const HoveringInsertionPromptBox = (props: Props) => {\n return (\n <div\n className=\"flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white\"\n style={{ width: \"35rem\" }}\n >\n <HoveringInsertionPromptBoxCore\n state={{\n editorState: props.editorState,\n }}\n insertionOrEditingFunction={props.apiConfig.insertionOrEditingFunction}\n performInsertion={props.performInsertion}\n contextCategories={props.contextCategories}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA6D;AAC7D,IAAAC,gBAA6C;AAC7C,yBAA4C;;;ACF5C,mBAAsF;AAw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ACT;AAEA,SACE,8CAAC,UACC;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WACE,qCACC,MAAM,sBACL;AAAA,MAEJ,eAAY;AAAA,MAEZ;AAAA,QAAC;AAAA;AAAA,UACC,aAAa,YAAY,QAAQ,SAAS;AAAA,UAC1C,WAAW,MAAM;AAAA,UACjB,kBAAkB,CAAC,iBAAiB;AAElC,qCAAW,OAAO,QAAQ,EAAE,IAAI,UAAU,CAAC;AAC3C,qCAAW,WAAW,QAAQ,cAAc;AAAA,cAC1C,IAAI;AAAA,YACN,CAAC;AACD,2BAAe,KAAK;AAAA,UACtB;AAAA,UACA,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EACF,GACF;AAEJ;AAEA,SAAS,YAAY,QAAgB,WAAyC;AAC5E,QAAM,mBAAmB,uBAAuB,MAAM;AACtD,MAAI,kBAAkB;AACpB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,kBAAkB,8BAA8B,MAAM;AAAA,IACtD,iBAAiB;AAAA,IACjB,cAAc;AAAA,EAChB;AACF;","names":["import_react","import_slate","import_react","import_jsx_runtime","React","ReactDOM","import_react","import_react","React","import_jsx_runtime","CommandPrimitive","CommandPrimitive","import_jsx_runtime","React","import_jsx_runtime","Button","React","import_class_variance_authority","import_jsx_runtime","import_react","import_jsx_runtime","Chip","Avatar","import_jsx_runtime","Button","import_jsx_runtime","import_jsx_runtime","selection"]}
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  HoveringToolbar
3
- } from "../../chunk-C3PMJNQA.mjs";
3
+ } from "../../chunk-7VADGLV2.mjs";
4
4
  import "../../chunk-L7VVZH4Q.mjs";
5
- import "../../chunk-2DF2AVDU.mjs";
6
- import "../../chunk-HBWBHJ64.mjs";
5
+ import "../../chunk-66KFI242.mjs";
6
+ import "../../chunk-4VCJHANC.mjs";
7
7
  import "../../chunk-KMVGEY7Q.mjs";
8
- import "../../chunk-3PQ7GSFE.mjs";
9
- import "../../chunk-D47EKHIF.mjs";
10
- import "../../chunk-LYB4B6MK.mjs";
11
- import "../../chunk-HDBI2WN5.mjs";
8
+ import "../../chunk-2IWVZ4PP.mjs";
12
9
  import "../../chunk-WGWQRALG.mjs";
10
+ import "../../chunk-4PDYALMP.mjs";
13
11
  import "../../chunk-VSVQZUPW.mjs";
14
12
  import "../../chunk-I72DKFHD.mjs";
15
- import "../../chunk-4PDYALMP.mjs";
13
+ import "../../chunk-D47EKHIF.mjs";
14
+ import "../../chunk-NAFNY4FL.mjs";
15
+ import "../../chunk-LYB4B6MK.mjs";
16
16
  import "../../chunk-2QDCE7PD.mjs";
17
17
  import "../../chunk-YLFAIYRY.mjs";
18
18
  import "../../chunk-ECR45NSD.mjs";