@copilotkit/react-textarea 0.24.0 → 0.26.0-alpha.0

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 (277) hide show
  1. package/.turbo/turbo-build.log +313 -309
  2. package/CHANGELOG.md +22 -0
  3. package/dist/components/base-copilot-textarea/base-copilot-textarea.d.ts +29 -0
  4. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +1745 -35
  5. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
  6. package/dist/components/base-copilot-textarea/render-element.mjs +51 -3
  7. package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
  8. package/dist/components/base-copilot-textarea/render-placeholder.mjs +49 -3
  9. package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
  10. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +86 -4
  11. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
  12. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +57 -3
  13. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
  14. package/dist/components/copilot-textarea/copilot-textarea.d.ts +3 -0
  15. package/dist/components/copilot-textarea/copilot-textarea.mjs +2202 -47
  16. package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
  17. package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +7 -3
  18. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +17 -3
  19. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
  20. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +137 -3
  21. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
  22. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +875 -18
  23. package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
  24. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +558 -12
  25. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
  26. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +581 -13
  27. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
  28. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +102 -5
  29. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
  30. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +581 -14
  31. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
  32. package/dist/components/index.mjs +2203 -48
  33. package/dist/components/index.mjs.map +1 -1
  34. package/dist/components/manual-ui/chip-with-icon.mjs +11 -27
  35. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  36. package/dist/components/source-search-box/source-search-box.mjs +211 -6
  37. package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
  38. package/dist/components/ui/button.mjs +85 -4
  39. package/dist/components/ui/button.mjs.map +1 -1
  40. package/dist/components/ui/card.mjs +96 -52
  41. package/dist/components/ui/card.mjs.map +1 -1
  42. package/dist/components/ui/command.mjs +244 -5
  43. package/dist/components/ui/command.mjs.map +1 -1
  44. package/dist/components/ui/dialog.mjs +144 -4
  45. package/dist/components/ui/dialog.mjs.map +1 -1
  46. package/dist/components/ui/label.mjs +60 -4
  47. package/dist/components/ui/label.mjs.map +1 -1
  48. package/dist/components/ui/separator.mjs +58 -15
  49. package/dist/components/ui/separator.mjs.map +1 -1
  50. package/dist/components/ui/textarea.mjs +58 -14
  51. package/dist/components/ui/textarea.mjs.map +1 -1
  52. package/dist/context/index.d.ts +1 -0
  53. package/dist/context/index.mjs +0 -2
  54. package/dist/context/index.mjs.map +1 -1
  55. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.ts +1 -1
  56. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +158 -6
  57. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
  58. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +168 -4
  59. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
  60. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +148 -5
  61. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
  62. package/dist/hooks/index.d.ts +1 -0
  63. package/dist/hooks/index.mjs +0 -2
  64. package/dist/hooks/index.mjs.map +1 -1
  65. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +147 -14
  66. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
  67. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +193 -14
  68. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
  69. package/dist/hooks/misc/use-autosize-textarea.mjs +15 -3
  70. package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
  71. package/dist/index.mjs +2206 -50
  72. package/dist/index.mjs.map +1 -1
  73. package/dist/lib/debouncer.mjs +51 -3
  74. package/dist/lib/debouncer.mjs.map +1 -1
  75. package/dist/lib/editor-to-text.mjs +43 -3
  76. package/dist/lib/editor-to-text.mjs.map +1 -1
  77. package/dist/lib/get-text-around-cursor.mjs +102 -3
  78. package/dist/lib/get-text-around-cursor.mjs.map +1 -1
  79. package/dist/lib/retry.mjs +17 -3
  80. package/dist/lib/retry.mjs.map +1 -1
  81. package/dist/lib/slatejs-edits/add-autocompletions.mjs +25 -3
  82. package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
  83. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +20 -3
  84. package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
  85. package/dist/lib/slatejs-edits/replace-text.mjs +27 -3
  86. package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
  87. package/dist/lib/slatejs-edits/with-partial-history.mjs +106 -3
  88. package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
  89. package/dist/lib/stream-promise-flatten.mjs +47 -3
  90. package/dist/lib/stream-promise-flatten.mjs.map +1 -1
  91. package/dist/lib/utils.mjs +71 -3
  92. package/dist/lib/utils.mjs.map +1 -1
  93. package/dist/lib/utils.test.d.ts +1 -0
  94. package/dist/lib/utils.test.mjs +0 -1
  95. package/dist/lib/utils.test.mjs.map +1 -1
  96. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
  97. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
  98. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +265 -8
  99. package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
  100. package/dist/types/autosuggestions-config/editing-api-config.mjs +81 -3
  101. package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
  102. package/dist/types/autosuggestions-config/index.mjs +327 -10
  103. package/dist/types/autosuggestions-config/index.mjs.map +1 -1
  104. package/dist/types/autosuggestions-config/insertions-api-config.mjs +75 -3
  105. package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
  106. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +83 -3
  107. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -1
  108. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
  109. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
  110. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
  111. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
  112. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +64 -3
  113. package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
  114. package/dist/types/base/autosuggestion-state.mjs +0 -2
  115. package/dist/types/base/autosuggestion-state.mjs.map +1 -1
  116. package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
  117. package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
  118. package/dist/types/base/base-autosuggestions-config.d.ts +55 -2
  119. package/dist/types/base/base-autosuggestions-config.mjs +26 -3
  120. package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
  121. package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
  122. package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
  123. package/dist/types/base/custom-editor.mjs +0 -2
  124. package/dist/types/base/custom-editor.mjs.map +1 -1
  125. package/dist/types/base/editor-autocomplete-state.mjs +17 -4
  126. package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
  127. package/dist/types/base/index.mjs +26 -4
  128. package/dist/types/base/index.mjs.map +1 -1
  129. package/dist/types/html-copilot-textarea-element.mjs +0 -2
  130. package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
  131. package/dist/types/index.mjs +328 -12
  132. package/dist/types/index.mjs.map +1 -1
  133. package/package.json +7 -7
  134. package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +79 -45
  135. package/src/components/base-copilot-textarea/render-element.tsx +3 -5
  136. package/src/components/base-copilot-textarea/render-placeholder.tsx +2 -4
  137. package/src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx +22 -3
  138. package/src/components/base-copilot-textarea/use-add-branding-css.tsx +2 -4
  139. package/src/components/copilot-textarea/copilot-textarea.tsx +14 -18
  140. package/src/components/hovering-toolbar/hovering-editor-provider.tsx +7 -5
  141. package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +14 -31
  142. package/src/components/hovering-toolbar/hovering-toolbar.tsx +4 -16
  143. package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +11 -25
  144. package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +2 -7
  145. package/src/components/manual-ui/chip-with-icon.tsx +3 -12
  146. package/src/components/source-search-box/source-search-box.tsx +2 -12
  147. package/src/components/ui/button.tsx +6 -13
  148. package/src/components/ui/card.tsx +35 -65
  149. package/src/components/ui/command.tsx +8 -21
  150. package/src/components/ui/dialog.tsx +8 -29
  151. package/src/components/ui/label.tsx +3 -8
  152. package/src/components/ui/separator.tsx +13 -18
  153. package/src/components/ui/textarea.tsx +3 -4
  154. package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +13 -27
  155. package/src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx +1 -5
  156. package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +4 -11
  157. package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +5 -10
  158. package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +15 -35
  159. package/src/hooks/misc/use-autosize-textarea.tsx +1 -4
  160. package/src/lib/debouncer.ts +1 -3
  161. package/src/lib/editor-to-text.ts +4 -7
  162. package/src/lib/get-text-around-cursor.ts +2 -14
  163. package/src/lib/retry.tsx +1 -1
  164. package/src/lib/slatejs-edits/add-autocompletions.ts +2 -2
  165. package/src/lib/slatejs-edits/clear-autocompletions.ts +1 -4
  166. package/src/lib/slatejs-edits/replace-text.ts +1 -1
  167. package/src/lib/slatejs-edits/with-partial-history.ts +4 -11
  168. package/src/lib/stream-promise-flatten.ts +1 -3
  169. package/src/lib/utils.ts +4 -8
  170. package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +3 -7
  171. package/src/types/autosuggestions-config/autosuggestions-config.tsx +5 -18
  172. package/src/types/autosuggestions-config/editing-api-config.tsx +3 -5
  173. package/src/types/autosuggestions-config/insertions-api-config.tsx +2 -3
  174. package/src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx +18 -26
  175. package/src/types/autosuggestions-config/subtypes/make-system-prompt.ts +1 -4
  176. package/src/types/autosuggestions-config/suggestions-api-config.tsx +2 -3
  177. package/src/types/base/autosuggestions-bare-function.ts +2 -2
  178. package/src/types/base/base-autosuggestions-config.tsx +80 -3
  179. package/src/types/base/editor-autocomplete-state.ts +1 -1
  180. package/dist/chunk-2NURR2DX.mjs +0 -47
  181. package/dist/chunk-2NURR2DX.mjs.map +0 -1
  182. package/dist/chunk-3L6CNVCE.mjs +0 -108
  183. package/dist/chunk-3L6CNVCE.mjs.map +0 -1
  184. package/dist/chunk-463BFNUP.mjs +0 -77
  185. package/dist/chunk-463BFNUP.mjs.map +0 -1
  186. package/dist/chunk-4HHYJGZE.mjs +0 -117
  187. package/dist/chunk-4HHYJGZE.mjs.map +0 -1
  188. package/dist/chunk-4LOLCQGR.mjs +0 -50
  189. package/dist/chunk-4LOLCQGR.mjs.map +0 -1
  190. package/dist/chunk-4S5ZJH3I.mjs +0 -18
  191. package/dist/chunk-4S5ZJH3I.mjs.map +0 -1
  192. package/dist/chunk-4UYKBG35.mjs +0 -57
  193. package/dist/chunk-4UYKBG35.mjs.map +0 -1
  194. package/dist/chunk-5EJ5XOGP.mjs +0 -22
  195. package/dist/chunk-5EJ5XOGP.mjs.map +0 -1
  196. package/dist/chunk-5FO6ISW4.mjs +0 -3
  197. package/dist/chunk-5FO6ISW4.mjs.map +0 -1
  198. package/dist/chunk-6Z2ATUNY.mjs +0 -15
  199. package/dist/chunk-6Z2ATUNY.mjs.map +0 -1
  200. package/dist/chunk-AQHORK66.mjs +0 -49
  201. package/dist/chunk-AQHORK66.mjs.map +0 -1
  202. package/dist/chunk-AXN37AHC.mjs +0 -80
  203. package/dist/chunk-AXN37AHC.mjs.map +0 -1
  204. package/dist/chunk-CSGFJU3L.mjs +0 -65
  205. package/dist/chunk-CSGFJU3L.mjs.map +0 -1
  206. package/dist/chunk-DE5K76I2.mjs +0 -3
  207. package/dist/chunk-DE5K76I2.mjs.map +0 -1
  208. package/dist/chunk-F3MHL6ZY.mjs +0 -25
  209. package/dist/chunk-F3MHL6ZY.mjs.map +0 -1
  210. package/dist/chunk-GCMQHIRF.mjs +0 -29
  211. package/dist/chunk-GCMQHIRF.mjs.map +0 -1
  212. package/dist/chunk-GIJ3JZ4P.mjs +0 -224
  213. package/dist/chunk-GIJ3JZ4P.mjs.map +0 -1
  214. package/dist/chunk-GUH3Y2H4.mjs +0 -19
  215. package/dist/chunk-GUH3Y2H4.mjs.map +0 -1
  216. package/dist/chunk-H4VKQGVU.mjs +0 -3
  217. package/dist/chunk-H4VKQGVU.mjs.map +0 -1
  218. package/dist/chunk-IU3WTXLQ.mjs +0 -3
  219. package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
  220. package/dist/chunk-IXJ2HCOA.mjs +0 -101
  221. package/dist/chunk-IXJ2HCOA.mjs.map +0 -1
  222. package/dist/chunk-JAFCXEPU.mjs +0 -10
  223. package/dist/chunk-JAFCXEPU.mjs.map +0 -1
  224. package/dist/chunk-JHTAOLEW.mjs +0 -63
  225. package/dist/chunk-JHTAOLEW.mjs.map +0 -1
  226. package/dist/chunk-JYVC4AW3.mjs +0 -205
  227. package/dist/chunk-JYVC4AW3.mjs.map +0 -1
  228. package/dist/chunk-KCHYD3EB.mjs +0 -107
  229. package/dist/chunk-KCHYD3EB.mjs.map +0 -1
  230. package/dist/chunk-KGKLUWKW.mjs +0 -47
  231. package/dist/chunk-KGKLUWKW.mjs.map +0 -1
  232. package/dist/chunk-L7VVZH4Q.mjs +0 -3
  233. package/dist/chunk-L7VVZH4Q.mjs.map +0 -1
  234. package/dist/chunk-LNAIMEB2.mjs +0 -34
  235. package/dist/chunk-LNAIMEB2.mjs.map +0 -1
  236. package/dist/chunk-MMVDU6DF.mjs +0 -3
  237. package/dist/chunk-MMVDU6DF.mjs.map +0 -1
  238. package/dist/chunk-MPME5BW2.mjs +0 -59
  239. package/dist/chunk-MPME5BW2.mjs.map +0 -1
  240. package/dist/chunk-MRXNTQOX.mjs +0 -55
  241. package/dist/chunk-MRXNTQOX.mjs.map +0 -1
  242. package/dist/chunk-ND5PXTAW.mjs +0 -17
  243. package/dist/chunk-ND5PXTAW.mjs.map +0 -1
  244. package/dist/chunk-NKW5OU2S.mjs +0 -33
  245. package/dist/chunk-NKW5OU2S.mjs.map +0 -1
  246. package/dist/chunk-O4MHJSK2.mjs +0 -21
  247. package/dist/chunk-O4MHJSK2.mjs.map +0 -1
  248. package/dist/chunk-O5OWT5GE.mjs +0 -114
  249. package/dist/chunk-O5OWT5GE.mjs.map +0 -1
  250. package/dist/chunk-OD7ZMOVE.mjs +0 -45
  251. package/dist/chunk-OD7ZMOVE.mjs.map +0 -1
  252. package/dist/chunk-OELUUJZY.mjs +0 -16
  253. package/dist/chunk-OELUUJZY.mjs.map +0 -1
  254. package/dist/chunk-QJDMIGLU.mjs +0 -38
  255. package/dist/chunk-QJDMIGLU.mjs.map +0 -1
  256. package/dist/chunk-RQHOUUXQ.mjs +0 -29
  257. package/dist/chunk-RQHOUUXQ.mjs.map +0 -1
  258. package/dist/chunk-RR6OQGTI.mjs +0 -74
  259. package/dist/chunk-RR6OQGTI.mjs.map +0 -1
  260. package/dist/chunk-UHD44NC5.mjs +0 -101
  261. package/dist/chunk-UHD44NC5.mjs.map +0 -1
  262. package/dist/chunk-WADHCMPK.mjs +0 -3
  263. package/dist/chunk-WADHCMPK.mjs.map +0 -1
  264. package/dist/chunk-WJHSY5T6.mjs +0 -3
  265. package/dist/chunk-WJHSY5T6.mjs.map +0 -1
  266. package/dist/chunk-WJYQWL4I.mjs +0 -27
  267. package/dist/chunk-WJYQWL4I.mjs.map +0 -1
  268. package/dist/chunk-WLPYYGES.mjs +0 -109
  269. package/dist/chunk-WLPYYGES.mjs.map +0 -1
  270. package/dist/chunk-XHUMROEY.mjs +0 -91
  271. package/dist/chunk-XHUMROEY.mjs.map +0 -1
  272. package/dist/chunk-YQU7WG7T.mjs +0 -83
  273. package/dist/chunk-YQU7WG7T.mjs.map +0 -1
  274. package/dist/chunk-YTOPHPSG.mjs +0 -45
  275. package/dist/chunk-YTOPHPSG.mjs.map +0 -1
  276. package/dist/chunk-YW3REYX6.mjs +0 -23
  277. package/dist/chunk-YW3REYX6.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx"],"names":["editor"],"mappings":";;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,cAAc,eAAe;AACtC,SAAS,iBAAiB;AAQ1B,IAAM,aAAkC,CAAC,IAAI,SAAS;AACpD,QAAM,mBAAmB;AAEzB,MACE,GAAG,SAAS,iBACZ,QAAQ,UAAU,GAAG,IAAI,KACzB,GAAG,KAAK,SAAS,kBACjB;AACA,WAAO;AAAA,EACT;AAEA,MACE,GAAG,SAAS,iBACZ,QAAQ,UAAU,GAAG,IAAI,KACzB,GAAG,KAAK,SAAS,kBACjB;AACA,WAAO;AAAA,EACT;AAEA,MACE,GAAG,SAAS,cACZ,UAAU,GAAG,iBACb,GAAG,cAAc,SAAS,kBAC1B;AACA,WAAO;AAAA,EACT;AAEA,MACE,GAAG,QAAQ,cACX,UAAU,GAAG,cACb,GAAG,WAAW,SAAS,kBACvB;AACA,WAAO;AAAA,EACT;AAEA,MACE,GAAG,SAAS,gBACZ,UAAU,GAAG,cACb,GAAG,WAAW,SAAS,kBACvB;AACA,WAAO;AAAA,EACT;AAEA,MACE,GAAG,SAAS,gBACZ,UAAU,GAAG,cACb,GAAG,WAAW,SAAS,kBACvB;AACA,WAAO;AAAA,EACT;AAGA,SAAO,kBAAkB,IAAI,IAAI;AACnC;AAEO,SAAS,2BAAyC;AACvD,QAAM,SAAS,QAAQ,MAAM;AAC3B,UAAMA,UAAS,mBAAmB,UAAU,aAAa,CAAC,GAAG,UAAU;AAEvE,UAAM,EAAE,OAAO,IAAIA;AACnB,IAAAA,QAAO,SAAS,CAAC,YAAY;AAC3B,cAAQ,QAAQ,MAAM;AAAA,QACpB,KAAK;AACH,iBAAO;AAAA,QACT;AACE,iBAAO,OAAO,OAAO;AAAA,MACzB;AAAA,IACF;AAEA,UAAM,EAAE,aAAa,IAAIA;AACzB,IAAAA,QAAO,eAAe,CAAC,YAAY;AACjC,cAAQ,QAAQ,MAAM;AAAA,QACpB,KAAK;AACH,iBAAO;AAAA,QACT;AACE,iBAAO,aAAa,OAAO;AAAA,MAC/B;AAAA,IACF;AAEA,UAAM,EAAE,SAAS,IAAIA;AACrB,IAAAA,QAAO,WAAW,CAAC,YAAY;AAC7B,cAAQ,QAAQ,MAAM;AAAA,QACpB,KAAK;AACH,iBAAO,QAAQ;AAAA,QACjB;AACE,iBAAO,SAAS,OAAO;AAAA,MAC3B;AAAA,IACF;AAEA,WAAOA;AAAA,EACT,GAAG,CAAC,CAAC;AAEL,SAAO;AACT","sourcesContent":["import { useMemo } from \"react\";\nimport { createEditor, Element } from \"slate\";\nimport { withReact } from \"slate-react\";\nimport {\n defaultShouldSave,\n ShouldSaveToHistory,\n withPartialHistory,\n} from \"../../lib/slatejs-edits/with-partial-history\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nconst shouldSave: ShouldSaveToHistory = (op, prev) => {\n const excludedNodeType = \"suggestion\";\n // Check if the operation involves the suggestion inline node type\n if (\n op.type === \"insert_node\" &&\n Element.isElement(op.node) &&\n op.node.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"remove_node\" &&\n Element.isElement(op.node) &&\n op.node.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"set_node\" &&\n \"type\" in op.newProperties &&\n op.newProperties.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type == \"set_node\" &&\n \"type\" in op.properties &&\n op.properties.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"merge_node\" &&\n \"type\" in op.properties &&\n op.properties.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"split_node\" &&\n \"type\" in op.properties &&\n op.properties.type === excludedNodeType\n ) {\n return false;\n }\n\n // Otherwise, save the operation to history\n return defaultShouldSave(op, prev);\n};\n\nexport function useCopilotTextareaEditor(): CustomEditor {\n const editor = useMemo(() => {\n const editor = withPartialHistory(withReact(createEditor()), shouldSave);\n\n const { isVoid } = editor;\n editor.isVoid = (element) => {\n switch (element.type) {\n case \"suggestion\":\n return true;\n default:\n return isVoid(element);\n }\n };\n\n const { markableVoid } = editor;\n editor.markableVoid = (element) => {\n switch (element.type) {\n case \"suggestion\":\n return true;\n default:\n return markableVoid(element);\n }\n };\n\n const { isInline } = editor;\n editor.isInline = (element) => {\n switch (element.type) {\n case \"suggestion\":\n return element.inline;\n default:\n return isInline(element);\n }\n };\n\n return editor;\n }, []);\n\n return editor;\n}\n"]}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
- //# sourceMappingURL=chunk-DE5K76I2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,25 +0,0 @@
1
- import { Node, Element, Transforms } from 'slate';
2
-
3
- // src/lib/slatejs-edits/clear-autocompletions.ts
4
- function clearAutocompletionsFromEditor(editor) {
5
- const paths = [];
6
- for (const [node, path] of Node.nodes(editor)) {
7
- if (Element.isElement(node) && node.type === "suggestion") {
8
- paths.push(path);
9
- }
10
- }
11
- for (const path of paths) {
12
- try {
13
- Transforms.removeNodes(editor, { at: path });
14
- } catch (e) {
15
- console.log(
16
- "CopilotTextarea.clearAutocompletionsFromEditor: error removing node",
17
- e
18
- );
19
- }
20
- }
21
- }
22
-
23
- export { clearAutocompletionsFromEditor };
24
- //# sourceMappingURL=out.js.map
25
- //# sourceMappingURL=chunk-F3MHL6ZY.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/slatejs-edits/clear-autocompletions.ts"],"names":[],"mappings":";AAAA,SAAS,SAAS,MAAY,kBAAkB;AAGzC,SAAS,+BAA+B,QAAsB;AAEnE,QAAM,QAAgB,CAAC;AACvB,aAAW,CAAC,MAAM,IAAI,KAAK,KAAK,MAAM,MAAM,GAAG;AAC7C,QAAI,QAAQ,UAAU,IAAI,KAAK,KAAK,SAAS,cAAc;AACzD,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,aAAW,QAAQ,OAAO;AACxB,QAAI;AACF,iBAAW,YAAY,QAAQ,EAAE,IAAI,KAAK,CAAC;AAAA,IAC7C,SAAS,GAAP;AACA,cAAQ;AAAA,QACN;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["import { Element, Node, Path, Transforms } from \"slate\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function clearAutocompletionsFromEditor(editor: CustomEditor) {\n // clear previous suggestion\n const paths: Path[] = [];\n for (const [node, path] of Node.nodes(editor)) {\n if (Element.isElement(node) && node.type === \"suggestion\") {\n paths.push(path);\n }\n }\n for (const path of paths) {\n try {\n Transforms.removeNodes(editor, { at: path });\n } catch (e) {\n console.log(\n \"CopilotTextarea.clearAutocompletionsFromEditor: error removing node\",\n e\n );\n }\n }\n}\n"]}
@@ -1,29 +0,0 @@
1
- import { __async } from './chunk-MRXNTQOX.mjs';
2
-
3
- // src/lib/stream-promise-flatten.ts
4
- function streamPromiseFlatten(promise) {
5
- return new ReadableStream({
6
- start(controller) {
7
- return __async(this, null, function* () {
8
- try {
9
- const stream = yield promise;
10
- const reader = stream.getReader();
11
- while (true) {
12
- const { done, value } = yield reader.read();
13
- if (done) {
14
- controller.close();
15
- return;
16
- }
17
- controller.enqueue(value);
18
- }
19
- } catch (error) {
20
- controller.error(error);
21
- }
22
- });
23
- }
24
- });
25
- }
26
-
27
- export { streamPromiseFlatten };
28
- //# sourceMappingURL=out.js.map
29
- //# sourceMappingURL=chunk-GCMQHIRF.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/stream-promise-flatten.ts"],"names":[],"mappings":";;;;;AAUO,SAAS,qBACd,SACmB;AACnB,SAAO,IAAI,eAAkB;AAAA,IACrB,MAAM,YAAY;AAAA;AACtB,YAAI;AACF,gBAAM,SAAS,MAAM;AACrB,gBAAM,SAAS,OAAO,UAAU;AAEhC,iBAAO,MAAM;AACX,kBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAE1C,gBAAI,MAAM;AACR,yBAAW,MAAM;AACjB;AAAA,YACF;AAEA,uBAAW,QAAQ,KAAK;AAAA,UAC1B;AAAA,QACF,SAAS,OAAP;AACA,qBAAW,MAAM,KAAK;AAAA,QACxB;AAAA,MACF;AAAA;AAAA,EACF,CAAC;AACH","sourcesContent":["/**\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>(\n promise: Promise<ReadableStream<A>>\n): 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"]}
@@ -1,224 +0,0 @@
1
- import { IncludedFilesPreview } from './chunk-4LOLCQGR.mjs';
2
- import { use_autosize_textarea_default } from './chunk-ND5PXTAW.mjs';
3
- import { Button } from './chunk-2NURR2DX.mjs';
4
- import { Label } from './chunk-5EJ5XOGP.mjs';
5
- import { SourceSearchBox } from './chunk-463BFNUP.mjs';
6
- import { streamPromiseFlatten } from './chunk-GCMQHIRF.mjs';
7
- import { __async } from './chunk-MRXNTQOX.mjs';
8
- import { useContext, useState, useRef, useEffect, useCallback } from 'react';
9
- import { CopilotContext } from '@copilotkit/react-core';
10
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
11
-
12
- var HoveringInsertionPromptBoxCore = ({
13
- performInsertion,
14
- state,
15
- insertionOrEditingFunction,
16
- contextCategories
17
- }) => {
18
- const { getDocumentsContext } = useContext(CopilotContext);
19
- const [editSuggestion, setEditSuggestion] = useState("");
20
- const [suggestionIsLoading, setSuggestionIsLoading] = useState(false);
21
- const [adjustmentPrompt, setAdjustmentPrompt] = useState("");
22
- const [generatingSuggestion, setGeneratingSuggestion] = useState(null);
23
- const adjustmentTextAreaRef = useRef(null);
24
- const suggestionTextAreaRef = useRef(null);
25
- const [filePointers, setFilePointers] = useState([]);
26
- const [suggestedFiles, setSuggestedFiles] = useState([]);
27
- useEffect(() => {
28
- setSuggestedFiles(getDocumentsContext(contextCategories));
29
- }, [contextCategories, getDocumentsContext]);
30
- use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
31
- use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
32
- useEffect(() => {
33
- var _a;
34
- (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
35
- }, []);
36
- useEffect(() => {
37
- if (!generatingSuggestion) {
38
- return;
39
- }
40
- if (generatingSuggestion.locked) {
41
- return;
42
- }
43
- setEditSuggestion("");
44
- const reader = generatingSuggestion.getReader();
45
- const read = () => __async(void 0, null, function* () {
46
- setSuggestionIsLoading(true);
47
- while (true) {
48
- const { done, value } = yield reader.read();
49
- if (done) {
50
- break;
51
- }
52
- setEditSuggestion((prev) => {
53
- const newSuggestion = prev + value;
54
- if (suggestionTextAreaRef.current) {
55
- suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;
56
- }
57
- return newSuggestion;
58
- });
59
- }
60
- setSuggestionIsLoading(false);
61
- });
62
- read();
63
- return () => {
64
- const releaseLockIfNotClosed = () => __async(void 0, null, function* () {
65
- try {
66
- yield reader.closed;
67
- } catch (e) {
68
- reader.releaseLock();
69
- }
70
- });
71
- releaseLockIfNotClosed();
72
- };
73
- }, [generatingSuggestion]);
74
- const beginGeneratingAdjustment = useCallback(() => __async(void 0, null, function* () {
75
- if (!adjustmentPrompt.trim()) {
76
- return;
77
- }
78
- let modificationState = state.editorState;
79
- if (editSuggestion !== "") {
80
- modificationState.selectedText = editSuggestion;
81
- }
82
- const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(
83
- modificationState,
84
- adjustmentPrompt,
85
- filePointers,
86
- new AbortController().signal
87
- );
88
- const adjustmentSuggestionTextStream = streamPromiseFlatten(
89
- adjustmentSuggestionTextStreamPromise
90
- );
91
- setGeneratingSuggestion(adjustmentSuggestionTextStream);
92
- }), [
93
- adjustmentPrompt,
94
- editSuggestion,
95
- state.editorState,
96
- insertionOrEditingFunction,
97
- filePointers
98
- ]);
99
- const isLoading = suggestionIsLoading;
100
- const textToEdit = editSuggestion || state.editorState.selectedText;
101
- const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
102
- const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
103
- const AdjustmentPromptComponent = /* @__PURE__ */ jsxs(Fragment, {
104
- children: [
105
- /* @__PURE__ */ jsx(Label, {
106
- className: "",
107
- children: adjustmentLabel
108
- }),
109
- /* @__PURE__ */ jsxs("div", {
110
- className: "relative w-full flex items-center",
111
- children: [
112
- /* @__PURE__ */ jsx("textarea", {
113
- disabled: suggestionIsLoading,
114
- ref: adjustmentTextAreaRef,
115
- value: adjustmentPrompt,
116
- onChange: (e) => setAdjustmentPrompt(e.target.value),
117
- onKeyDown: (e) => {
118
- if (e.key === "Enter" && e.shiftKey) {
119
- e.preventDefault();
120
- setAdjustmentPrompt(adjustmentPrompt + "\n");
121
- } else if (e.key === "Enter") {
122
- e.preventDefault();
123
- beginGeneratingAdjustment();
124
- }
125
- },
126
- placeholder,
127
- style: { minHeight: "3rem" },
128
- 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]",
129
- rows: 1
130
- }),
131
- /* @__PURE__ */ jsx("button", {
132
- onClick: beginGeneratingAdjustment,
133
- className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
134
- children: /* @__PURE__ */ jsx("i", {
135
- className: "material-icons",
136
- children: "arrow_forward"
137
- })
138
- })
139
- ]
140
- })
141
- ]
142
- });
143
- const SuggestionComponent = /* @__PURE__ */ jsxs(Fragment, {
144
- children: [
145
- /* @__PURE__ */ jsxs("div", {
146
- className: "flex justify-between items-end w-full",
147
- children: [
148
- /* @__PURE__ */ jsx(Label, {
149
- className: "mt-4",
150
- children: "Suggested:"
151
- }),
152
- /* @__PURE__ */ jsx("div", {
153
- className: "ml-auto",
154
- children: isLoading && /* @__PURE__ */ jsx("div", {
155
- className: "flex justify-center items-center",
156
- children: /* @__PURE__ */ jsx("div", {
157
- 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]",
158
- role: "status",
159
- children: /* @__PURE__ */ jsx("span", {
160
- className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]",
161
- children: "Loading..."
162
- })
163
- })
164
- })
165
- })
166
- ]
167
- }),
168
- /* @__PURE__ */ jsx("textarea", {
169
- ref: suggestionTextAreaRef,
170
- value: editSuggestion,
171
- disabled: suggestionIsLoading,
172
- onChange: (e) => setEditSuggestion(e.target.value),
173
- className: "w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50",
174
- style: { overflow: "auto", maxHeight: "10em" }
175
- })
176
- ]
177
- });
178
- const SubmitComponent = /* @__PURE__ */ jsx("div", {
179
- className: "flex w-full gap-4 justify-start",
180
- children: /* @__PURE__ */ jsxs(Button, {
181
- className: " bg-green-700 text-white",
182
- onClick: () => {
183
- performInsertion(editSuggestion);
184
- },
185
- children: [
186
- "Insert ",
187
- /* @__PURE__ */ jsx("i", {
188
- className: "material-icons",
189
- children: "check"
190
- })
191
- ]
192
- })
193
- });
194
- const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
195
- const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
196
- return /* @__PURE__ */ jsxs("div", {
197
- className: "w-full flex flex-col items-start relative gap-2",
198
- children: [
199
- AdjustmentPromptComponent,
200
- filePointers.length > 0 && /* @__PURE__ */ jsx(IncludedFilesPreview, {
201
- includedFiles: filePointers,
202
- setIncludedFiles: setFilePointers
203
- }),
204
- sourceSearchWord !== void 0 && /* @__PURE__ */ jsx(SourceSearchBox, {
205
- searchTerm: sourceSearchWord,
206
- suggestedFiles,
207
- onSelectedFile: (filePointer) => {
208
- var _a;
209
- setAdjustmentPrompt(
210
- adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), "")
211
- );
212
- setFilePointers((prev) => [...prev, filePointer]);
213
- (_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
214
- }
215
- }),
216
- generatingSuggestion ? SuggestionComponent : null,
217
- generatingSuggestion ? SubmitComponent : null
218
- ]
219
- });
220
- };
221
-
222
- export { HoveringInsertionPromptBoxCore };
223
- //# sourceMappingURL=out.js.map
224
- //# sourceMappingURL=chunk-GIJ3JZ4P.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAUA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,sBAAsB;AAwJ3B,mBACE,KACA,YAFF;AA1IG,IAAM,iCAET,CAAC;AAAA,EACH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,oBAAoB,IAAI,WAAW,cAAc;AAEzD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAiB,EAAE;AAC/D,QAAM,CAAC,qBAAqB,sBAAsB,IAChD,SAAkB,K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AAA,OACpB;AAAA,MAED,qBAAqB,UACpB,oBAAC;AAAA,QACC,YAAY;AAAA,QACZ;AAAA,QACA,gBAAgB,CAAC,gBAAgB;AA1Q3C;AA2QY;AAAA,YACE,iBAAiB,QAAQ,IAAI,OAAO,IAAI,mBAAmB,GAAG,EAAE;AAAA,UAClE;AACA,0BAAgB,CAAC,SAAS,CAAC,GAAG,MAAM,WAAW,CAAC;AAGhD,sCAAsB,YAAtB,mBAA+B;AAAA,QACjC;AAAA,OACF;AAAA,MAED,uBAAuB,sBAAsB;AAAA,MAC7C,uBAAuB,kBAAkB;AAAA;AAAA,GAC5C;AAEJ","sourcesContent":["import useAutosizeTextArea from \"../../../hooks/misc/use-autosize-textarea\";\nimport { MinimalChatGPTMessage } from \"../../../types\";\nimport {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n} from \"../../../types/base/autosuggestions-bare-function\";\nimport { SourceSearchBox } from \"../../source-search-box/source-search-box\";\nimport { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Button } from \"../../ui/button\";\nimport { Label } from \"../../ui/label\";\nimport React, {\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nimport { streamPromiseFlatten } from \"../../../lib/stream-promise-flatten\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { IncludedFilesPreview } from \"./included-files-preview\";\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: React.FC<\n HoveringInsertionPromptBoxCoreProps\n> = ({\n performInsertion,\n state,\n insertionOrEditingFunction,\n contextCategories,\n}) => {\n const { getDocumentsContext } = useContext(CopilotContext);\n\n const [editSuggestion, setEditSuggestion] = useState<string>(\"\");\n const [suggestionIsLoading, setSuggestionIsLoading] =\n useState<boolean>(false);\n\n const [adjustmentPrompt, setAdjustmentPrompt] = useState<string>(\"\");\n\n const [generatingSuggestion, setGeneratingSuggestion] =\n useState<ReadableStream<string> | null>(null);\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 =\n 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 AdjustmentPromptComponent = (\n <>\n <Label className=\"\">{adjustmentLabel}</Label>\n <div className=\"relative w-full flex items-center\">\n <textarea\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 >\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 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 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\n includedFiles={filePointers}\n setIncludedFiles={setFilePointers}\n />\n )}\n {sourceSearchWord !== undefined && (\n <SourceSearchBox\n searchTerm={sourceSearchWord}\n suggestedFiles={suggestedFiles}\n onSelectedFile={(filePointer) => {\n setAdjustmentPrompt(\n adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), \"\")\n );\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"]}
@@ -1,19 +0,0 @@
1
- import { defaultEditingApiConfig } from './chunk-AXN37AHC.mjs';
2
- import { defaultInsertionsApiConfig } from './chunk-RR6OQGTI.mjs';
3
- import { defaultSuggestionsApiConfig } from './chunk-JHTAOLEW.mjs';
4
- import { defaultBaseAutosuggestionsConfig } from './chunk-6Z2ATUNY.mjs';
5
- import { __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
6
- import { defaultCopilotContextCategories } from '@copilotkit/react-core';
7
-
8
- var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseAutosuggestionsConfig), {
9
- contextCategories: defaultCopilotContextCategories,
10
- chatApiConfigs: {
11
- suggestionsApiConfig: defaultSuggestionsApiConfig,
12
- insertionApiConfig: defaultInsertionsApiConfig,
13
- editingApiConfig: defaultEditingApiConfig
14
- }
15
- });
16
-
17
- export { defaultAutosuggestionsConfig };
18
- //# sourceMappingURL=out.js.map
19
- //# sourceMappingURL=chunk-GUH3Y2H4.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/autosuggestions-config/autosuggestions-config.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAS,uCAAuC;AAezC,IAAM,+BAGT,iCACC,mCADD;AAAA,EAEF,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,IACd,sBAAsB;AAAA,IACtB,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,EACpB;AACF","sourcesContent":["import {\n BaseAutosuggestionsConfig,\n defaultBaseAutosuggestionsConfig,\n} from \"../base\";\nimport {\n SuggestionsApiConfig,\n defaultSuggestionsApiConfig,\n} from \"./suggestions-api-config\";\nimport {\n InsertionsApiConfig,\n defaultInsertionsApiConfig,\n} from \"./insertions-api-config\";\nimport { ChatlikeApiEndpoint } from \".\";\nimport {\n EditingApiConfig,\n defaultEditingApiConfig,\n} from \"./editing-api-config\";\nimport { defaultCopilotContextCategories } from \"@copilotkit/react-core\";\n\n// Like the base autosuggestions config, with 2 additional fields:\n// 1. contextCategories: string[] | undefined;\n// 2. instead of apiConfigs, we have chatApiConfigs: a higher-level abstraction that uses a ChatGPT-like API endpoint.\nexport interface AutosuggestionsConfig\n extends Omit<BaseAutosuggestionsConfig, \"apiConfig\"> {\n contextCategories: string[];\n chatApiConfigs: {\n suggestionsApiConfig: SuggestionsApiConfig;\n insertionApiConfig: InsertionsApiConfig;\n editingApiConfig: EditingApiConfig;\n };\n}\n\nexport const defaultAutosuggestionsConfig: Omit<\n AutosuggestionsConfig,\n \"textareaPurpose\" | \"apiEndpoint\"\n> = {\n ...defaultBaseAutosuggestionsConfig,\n contextCategories: defaultCopilotContextCategories,\n chatApiConfigs: {\n suggestionsApiConfig: defaultSuggestionsApiConfig,\n insertionApiConfig: defaultInsertionsApiConfig,\n editingApiConfig: defaultEditingApiConfig,\n },\n};\n"]}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
- //# sourceMappingURL=chunk-H4VKQGVU.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
- //# sourceMappingURL=chunk-IU3WTXLQ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,101 +0,0 @@
1
- import { Range, Editor, Text, Element, Path, Point } from 'slate';
2
-
3
- // src/lib/get-text-around-cursor.ts
4
- function getTextAroundCollapsedCursor(editor) {
5
- const { selection } = editor;
6
- if (!selection || !Range.isCollapsed(selection)) {
7
- return null;
8
- }
9
- const cursorPoint = selection.anchor;
10
- const beforeRange = {
11
- anchor: Editor.start(editor, []),
12
- focus: cursorPoint
13
- };
14
- const afterRange = {
15
- anchor: cursorPoint,
16
- focus: Editor.end(editor, [])
17
- };
18
- const before = extractTextWithNewlines(editor, beforeRange);
19
- const after = extractTextWithNewlines(editor, afterRange);
20
- return {
21
- cursorPoint,
22
- textBeforeCursor: before,
23
- textAfterCursor: after
24
- };
25
- }
26
- function getTextAroundSelection(editor) {
27
- const { selection } = editor;
28
- if (!selection) {
29
- return null;
30
- }
31
- const wellOrderedSelection = wellOrderedRange(selection);
32
- const beforeRange = {
33
- anchor: Editor.start(editor, []),
34
- focus: wellOrderedSelection.anchor
35
- };
36
- const afterRange = {
37
- anchor: wellOrderedSelection.focus,
38
- focus: Editor.end(editor, [])
39
- };
40
- const before = extractTextWithNewlines(editor, beforeRange);
41
- const after = extractTextWithNewlines(editor, afterRange);
42
- const selectedText = extractTextWithNewlines(editor, wellOrderedSelection);
43
- return {
44
- selection: wellOrderedSelection,
45
- textBeforeCursor: before,
46
- selectedText,
47
- textAfterCursor: after
48
- };
49
- }
50
- function getFullEditorTextWithNewlines(editor) {
51
- const fullDocumentRange = {
52
- anchor: Editor.start(editor, []),
53
- focus: Editor.end(editor, [])
54
- };
55
- return extractTextWithNewlines(editor, fullDocumentRange);
56
- }
57
- function extractTextWithNewlines(editor, range) {
58
- const voids = false;
59
- const [start, end] = Range.edges(range);
60
- let text = "";
61
- let lastBlock = null;
62
- for (const [node, path] of Editor.nodes(editor, {
63
- at: range,
64
- match: Text.isText,
65
- voids
66
- })) {
67
- let t = node.text;
68
- const [block] = Editor.above(editor, {
69
- at: path,
70
- match: (n) => Element.isElement(n) && n.type === "paragraph"
71
- }) || [null];
72
- if (lastBlock !== block && block) {
73
- if (lastBlock) {
74
- text += "\n";
75
- }
76
- lastBlock = block;
77
- }
78
- if (Path.equals(path, end.path)) {
79
- t = t.slice(0, end.offset);
80
- }
81
- if (Path.equals(path, start.path)) {
82
- t = t.slice(start.offset);
83
- }
84
- text += t;
85
- }
86
- return text;
87
- }
88
- function wellOrderedRange(range) {
89
- const { anchor, focus } = range;
90
- if (Point.isBefore(anchor, focus)) {
91
- return range;
92
- }
93
- return {
94
- anchor: focus,
95
- focus: anchor
96
- };
97
- }
98
-
99
- export { extractTextWithNewlines, getFullEditorTextWithNewlines, getTextAroundCollapsedCursor, getTextAroundSelection };
100
- //# sourceMappingURL=out.js.map
101
- //# sourceMappingURL=chunk-IXJ2HCOA.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/get-text-around-cursor.ts"],"names":[],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AAWA,SAAS,6BACd,QACgC;AAChC,QAAM,EAAE,UAAU,IAAI;AACtB,MAAI,CAAC,aAAa,CAAC,MAAM,YAAY,SAAS,GAAG;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,UAAU;AAG9B,QAAM,cAAqB;AAAA,IACzB,QAAQ,OAAO,MAAM,QAAQ,CAAC,CAAC;AAAA,IAC/B,OAAO;AAAA,EACT;AACA,QAAM,aAAoB;AAAA,IACxB,QAAQ;AAAA,IACR,OAAO,OAAO,IAAI,QAAQ,CAAC,CAAC;AAAA,EAC9B;AAGA,QAAM,SAAS,wBAAwB,QAAQ,WAAW;AAC1D,QAAM,QAAQ,wBAAwB,QAAQ,UAAU;AAExD,SAAO;AAAA,IACL;AAAA,IACA,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,EACnB;AACF;AAEO,SAAS,uBAAuB,QAAwC;AAC7E,QAAM,EAAE,UAAU,IAAI;AACtB,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,QAAM,uBAAuB,iBAAiB,SAAS;AAGvD,QAAM,cAAqB;AAAA,IACzB,QAAQ,OAAO,MAAM,QAAQ,CAAC,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IAAI,MAAM;AAAA,IAC3B;AAEA,QAAI,KAAK,OAAO,MAAM,MAAM,IAAI,GAAG;AACjC,UAAI,EAAE,MAAM,MAAM,MAAM;AAAA,IAC1B;AAEA,YAAQ;AAAA,EACV;AAEA,SAAO;AACT;AAEA,SAAS,iBAAiB,OAA6B;AACrD,QAAM,EAAE,QAAQ,MAAM,IAAI;AAE1B,MAAI,MAAM,SAAS,QAAQ,KAAK,GAAG;AACjC,WAAO;AAAA,EACT;AAGA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF","sourcesContent":["import {\n Editor,\n Node,\n Path,\n Range,\n Text,\n Element,\n BasePoint,\n BaseRange,\n Point,\n} 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(\n editor: Editor\n): 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"]}
@@ -1,10 +0,0 @@
1
- import { arraysAreEqual } from './chunk-KGKLUWKW.mjs';
2
-
3
- // src/types/base/editor-autocomplete-state.ts
4
- function areEqual_autocompleteState(prev, next) {
5
- return prev.cursorPoint.offset === next.cursorPoint.offset && arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) && prev.textBeforeCursor === next.textBeforeCursor && prev.textAfterCursor === next.textAfterCursor;
6
- }
7
-
8
- export { areEqual_autocompleteState };
9
- //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=chunk-JAFCXEPU.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/base/editor-autocomplete-state.ts"],"names":[],"mappings":";;;;;AASO,SAAS,2BACd,MACA,MACA;AACA,SACE,KAAK,YAAY,WAAW,KAAK,YAAY,UAC7C,eAAe,KAAK,YAAY,MAAM,KAAK,YAAY,IAAI,KAC3D,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,oBAAoB,KAAK;AAElC","sourcesContent":["import { BasePoint } from \"slate\";\nimport { arraysAreEqual } from \"../../lib/utils\";\n\nexport interface EditorAutocompleteState {\n cursorPoint: BasePoint;\n textBeforeCursor: string;\n textAfterCursor: string;\n}\n\nexport function areEqual_autocompleteState(\n prev: EditorAutocompleteState,\n next: EditorAutocompleteState\n) {\n return (\n prev.cursorPoint.offset === next.cursorPoint.offset &&\n arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) &&\n prev.textBeforeCursor === next.textBeforeCursor &&\n prev.textAfterCursor === next.textAfterCursor\n );\n}\n"]}
@@ -1,63 +0,0 @@
1
- // src/types/autosuggestions-config/suggestions-api-config.tsx
2
- var defaultSuggestionsMakeSystemPrompt = (textareaPurpose, contextString) => {
3
- return `You are a versatile writing assistant.
4
-
5
- The user is writing some text.
6
- The purpose is: "${textareaPurpose}"
7
-
8
- Your job is to guess what the user will write next AS BEST YOU CAN.
9
- Only guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.
10
-
11
- Adjust yourself to the user's style and implied intent.
12
-
13
- The user will provide both the text before and after the cursor. You should use this to infer what the user is likely to write next.
14
- <TextAfterCursor>
15
- <TextBeforeCursor>
16
- <YourSuggestion>
17
-
18
- If we need to add a whitespace character to the suggested text, make sure to explicitly add it in.
19
-
20
- The following external context is also provided. Use it to help you make better suggestions!!!
21
- \`\`\`
22
- ${contextString}
23
- \`\`\`
24
- `;
25
- };
26
- var defaultSuggestionsFewShotMessages = [
27
- {
28
- role: "user",
29
- name: "TextAfterCursor",
30
- content: "While I was there I also picked up some apples, oranges, and bananas."
31
- },
32
- {
33
- role: "user",
34
- content: "This morning I woke up and went straight to the grocery store."
35
- },
36
- {
37
- role: "assistant",
38
- content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
39
- },
40
- {
41
- role: "user",
42
- name: "TextAfterCursor",
43
- content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
44
- },
45
- {
46
- role: "user",
47
- name: "TextBeforeCursor",
48
- content: `The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;`
49
- },
50
- {
51
- role: "assistant",
52
- content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
53
- }
54
- ];
55
- var defaultSuggestionsApiConfig = {
56
- makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,
57
- fewShotMessages: defaultSuggestionsFewShotMessages,
58
- forwardedParams: void 0
59
- };
60
-
61
- export { defaultSuggestionsApiConfig, defaultSuggestionsFewShotMessages, defaultSuggestionsMakeSystemPrompt };
62
- //# sourceMappingURL=out.js.map
63
- //# sourceMappingURL=chunk-JHTAOLEW.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/autosuggestions-config/suggestions-api-config.tsx"],"names":[],"mappings":";AASO,IAAM,qCAAuD,CAClE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBlB;AAAA;AAAA;AAGF;AAEO,IAAM,oCAA6D;AAAA,EACxE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,8BAAoD;AAAA,EAC/D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB","sourcesContent":["import { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\n\nexport interface SuggestionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultSuggestionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nYour job is to guess what the user will write next AS BEST YOU CAN.\nOnly guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide both the text before and after the cursor. You should use this to infer what the user is likely to write next.\n<TextAfterCursor>\n<TextBeforeCursor>\n<YourSuggestion>\n\nIf we need to add a whitespace character to the suggested text, make sure to explicitly add it in.\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n`;\n};\n\nexport const defaultSuggestionsFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"While I was there I also picked up some apples, oranges, and bananas.\",\n },\n {\n role: \"user\",\n content: \"This morning I woke up and went straight to the grocery store.\",\n },\n {\n role: \"assistant\",\n content:\n \" When I arrived I went straight to the produce section and picked out a big watermelon. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content:\n 'The Optionholder, in the Optionholder\\'s capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an \"Equityholder\" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an \"Equityholder\" thereunder;',\n },\n {\n role: \"assistant\",\n content:\n ' (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder\\'s \"Pro Rata Share\"; ',\n },\n];\n\nexport const defaultSuggestionsApiConfig: SuggestionsApiConfig = {\n makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,\n fewShotMessages: defaultSuggestionsFewShotMessages,\n forwardedParams: undefined,\n};\n"]}