@copilotkit/react-textarea 0.28.0-alpha.7 → 0.28.0-alpha.9

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 (339) hide show
  1. package/.turbo/turbo-build.log +341 -379
  2. package/CHANGELOG.md +24 -0
  3. package/dist/chunk-224UKA7C.mjs +9 -4
  4. package/dist/chunk-224UKA7C.mjs.map +1 -1
  5. package/dist/chunk-2C7O2EVM.mjs +4 -4
  6. package/dist/chunk-2C7O2EVM.mjs.map +1 -1
  7. package/dist/chunk-2QDCE7PD.mjs +6 -3
  8. package/dist/chunk-2QDCE7PD.mjs.map +1 -1
  9. package/dist/chunk-3PQ7GSFE.mjs +4 -4
  10. package/dist/chunk-3PQ7GSFE.mjs.map +1 -1
  11. package/dist/chunk-4NHVQZ67.mjs +6 -5
  12. package/dist/chunk-4NHVQZ67.mjs.map +1 -1
  13. package/dist/chunk-4OJ3H65F.mjs +5 -2
  14. package/dist/chunk-4OJ3H65F.mjs.map +1 -1
  15. package/dist/chunk-5J3UZV77.mjs +23 -11
  16. package/dist/chunk-5J3UZV77.mjs.map +1 -1
  17. package/dist/chunk-5UNJXFUO.mjs +4 -4
  18. package/dist/chunk-5UNJXFUO.mjs.map +1 -1
  19. package/dist/chunk-72P3KOHZ.mjs +17 -7
  20. package/dist/chunk-72P3KOHZ.mjs.map +1 -1
  21. package/dist/chunk-7LSRNPNI.mjs +4 -4
  22. package/dist/chunk-7LSRNPNI.mjs.map +1 -1
  23. package/dist/chunk-7SUZ6CXM.mjs +15 -6
  24. package/dist/chunk-7SUZ6CXM.mjs.map +1 -1
  25. package/dist/chunk-AZHILHKM.mjs +21 -8
  26. package/dist/chunk-AZHILHKM.mjs.map +1 -1
  27. package/dist/chunk-B6TKVDDY.mjs +58 -22
  28. package/dist/chunk-B6TKVDDY.mjs.map +1 -1
  29. package/dist/chunk-BBZ7AWOB.mjs +8 -4
  30. package/dist/chunk-BBZ7AWOB.mjs.map +1 -1
  31. package/dist/chunk-DE5K76I2.mjs +0 -2
  32. package/dist/chunk-DE5K76I2.mjs.map +1 -1
  33. package/dist/chunk-DRV2FOHZ.mjs +11 -6
  34. package/dist/chunk-DRV2FOHZ.mjs.map +1 -1
  35. package/dist/chunk-ECR45NSD.mjs +7 -4
  36. package/dist/chunk-ECR45NSD.mjs.map +1 -1
  37. package/dist/chunk-FJNUPSQK.mjs +16 -5
  38. package/dist/chunk-FJNUPSQK.mjs.map +1 -1
  39. package/dist/chunk-FP2EKU3L.mjs +4 -4
  40. package/dist/chunk-FP2EKU3L.mjs.map +1 -1
  41. package/dist/chunk-GQN2HYFJ.mjs +4 -4
  42. package/dist/chunk-GQN2HYFJ.mjs.map +1 -1
  43. package/dist/chunk-H4VKQGVU.mjs +0 -2
  44. package/dist/chunk-H4VKQGVU.mjs.map +1 -1
  45. package/dist/chunk-IU3WTXLQ.mjs +0 -2
  46. package/dist/chunk-IU3WTXLQ.mjs.map +1 -1
  47. package/dist/chunk-JJLQVT7S.mjs +6 -3
  48. package/dist/chunk-JJLQVT7S.mjs.map +1 -1
  49. package/dist/chunk-KDVMG3XF.mjs +5 -2
  50. package/dist/chunk-KDVMG3XF.mjs.map +1 -1
  51. package/dist/chunk-KFQZHRPJ.mjs +15 -8
  52. package/dist/chunk-KFQZHRPJ.mjs.map +1 -1
  53. package/dist/chunk-KNQIEOFP.mjs +3 -2
  54. package/dist/chunk-KNQIEOFP.mjs.map +1 -1
  55. package/dist/chunk-L7VVZH4Q.mjs +0 -2
  56. package/dist/chunk-L7VVZH4Q.mjs.map +1 -1
  57. package/dist/chunk-LQ2OWQU7.mjs +11 -7
  58. package/dist/chunk-LQ2OWQU7.mjs.map +1 -1
  59. package/dist/chunk-LYB4B6MK.mjs +6 -5
  60. package/dist/chunk-LYB4B6MK.mjs.map +1 -1
  61. package/dist/chunk-M2DR4KVB.mjs +6 -3
  62. package/dist/chunk-M2DR4KVB.mjs.map +1 -1
  63. package/dist/chunk-MMVDU6DF.mjs +0 -2
  64. package/dist/chunk-MMVDU6DF.mjs.map +1 -1
  65. package/dist/chunk-MRXNTQOX.mjs +6 -2
  66. package/dist/chunk-MRXNTQOX.mjs.map +1 -1
  67. package/dist/chunk-P4QVFRLY.mjs +17 -7
  68. package/dist/chunk-P4QVFRLY.mjs.map +1 -1
  69. package/dist/chunk-PTZVE6NC.mjs +22 -8
  70. package/dist/chunk-PTZVE6NC.mjs.map +1 -1
  71. package/dist/chunk-QCPS6IYI.mjs +15 -6
  72. package/dist/chunk-QCPS6IYI.mjs.map +1 -1
  73. package/dist/chunk-RKQ6RTZM.mjs +5 -2
  74. package/dist/chunk-RKQ6RTZM.mjs.map +1 -1
  75. package/dist/chunk-RT4UTBH3.mjs +15 -6
  76. package/dist/chunk-RT4UTBH3.mjs.map +1 -1
  77. package/dist/chunk-RUV6NBIF.mjs +0 -2
  78. package/dist/chunk-RUV6NBIF.mjs.map +1 -1
  79. package/dist/chunk-SNQEBH5I.mjs +24 -10
  80. package/dist/chunk-SNQEBH5I.mjs.map +1 -1
  81. package/dist/chunk-SX6NY5FW.mjs +11 -6
  82. package/dist/chunk-SX6NY5FW.mjs.map +1 -1
  83. package/dist/chunk-T6MTDQZ7.mjs +4 -4
  84. package/dist/chunk-T6MTDQZ7.mjs.map +1 -1
  85. package/dist/chunk-VB4VNCIQ.mjs +28 -12
  86. package/dist/chunk-VB4VNCIQ.mjs.map +1 -1
  87. package/dist/chunk-VPEH6V7T.mjs +12 -6
  88. package/dist/chunk-VPEH6V7T.mjs.map +1 -1
  89. package/dist/chunk-WADHCMPK.mjs +0 -2
  90. package/dist/chunk-WADHCMPK.mjs.map +1 -1
  91. package/dist/chunk-WFTAAA7R.mjs +16 -8
  92. package/dist/chunk-WFTAAA7R.mjs.map +1 -1
  93. package/dist/chunk-WJHSY5T6.mjs +0 -2
  94. package/dist/chunk-WJHSY5T6.mjs.map +1 -1
  95. package/dist/chunk-WTASPE2W.mjs +41 -22
  96. package/dist/chunk-WTASPE2W.mjs.map +1 -1
  97. package/dist/chunk-XW3ICO4S.mjs +10 -4
  98. package/dist/chunk-XW3ICO4S.mjs.map +1 -1
  99. package/dist/components/base-copilot-textarea/base-copilot-textarea.js +379 -257
  100. package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
  101. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +39 -35
  102. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
  103. package/dist/components/base-copilot-textarea/render-element.js +32 -11
  104. package/dist/components/base-copilot-textarea/render-element.js.map +1 -1
  105. package/dist/components/base-copilot-textarea/render-element.mjs +7 -3
  106. package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
  107. package/dist/components/base-copilot-textarea/render-placeholder.js +29 -8
  108. package/dist/components/base-copilot-textarea/render-placeholder.js.map +1 -1
  109. package/dist/components/base-copilot-textarea/render-placeholder.mjs +7 -3
  110. package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
  111. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js +44 -17
  112. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js.map +1 -1
  113. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +8 -4
  114. package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
  115. package/dist/components/base-copilot-textarea/use-add-branding-css.js +29 -7
  116. package/dist/components/base-copilot-textarea/use-add-branding-css.js.map +1 -1
  117. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +7 -3
  118. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
  119. package/dist/components/copilot-textarea/copilot-textarea.js +414 -272
  120. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  121. package/dist/components/copilot-textarea/copilot-textarea.mjs +48 -44
  122. package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
  123. package/dist/components/hovering-toolbar/hovering-editor-provider.js +35 -12
  124. package/dist/components/hovering-toolbar/hovering-editor-provider.js.map +1 -1
  125. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +9 -3
  126. package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
  127. package/dist/components/hovering-toolbar/hovering-toolbar-components.js +66 -36
  128. package/dist/components/hovering-toolbar/hovering-toolbar-components.js.map +1 -1
  129. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +15 -3
  130. package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
  131. package/dist/components/hovering-toolbar/hovering-toolbar.js +247 -179
  132. package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
  133. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +22 -18
  134. package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
  135. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js +180 -129
  136. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map +1 -1
  137. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +16 -12
  138. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
  139. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js +185 -131
  140. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map +1 -1
  141. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +17 -13
  142. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
  143. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js +71 -55
  144. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map +1 -1
  145. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +11 -5
  146. package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
  147. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js +185 -131
  148. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map +1 -1
  149. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +18 -14
  150. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
  151. package/dist/components/index.js +418 -273
  152. package/dist/components/index.js.map +1 -1
  153. package/dist/components/index.mjs +52 -45
  154. package/dist/components/index.mjs.map +1 -1
  155. package/dist/components/manual-ui/chip-with-icon.js +31 -9
  156. package/dist/components/manual-ui/chip-with-icon.js.map +1 -1
  157. package/dist/components/manual-ui/chip-with-icon.mjs +6 -5
  158. package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
  159. package/dist/components/source-search-box/source-search-box.js +104 -72
  160. package/dist/components/source-search-box/source-search-box.js.map +1 -1
  161. package/dist/components/source-search-box/source-search-box.mjs +12 -6
  162. package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
  163. package/dist/components/ui/button.js +56 -40
  164. package/dist/components/ui/button.js.map +1 -1
  165. package/dist/components/ui/button.mjs +10 -4
  166. package/dist/components/ui/button.mjs.map +1 -1
  167. package/dist/components/ui/card.js +70 -50
  168. package/dist/components/ui/card.js.map +1 -1
  169. package/dist/components/ui/card.mjs +18 -7
  170. package/dist/components/ui/card.mjs.map +1 -1
  171. package/dist/components/ui/command.js +139 -97
  172. package/dist/components/ui/command.js.map +1 -1
  173. package/dist/components/ui/command.mjs +26 -5
  174. package/dist/components/ui/command.mjs.map +1 -1
  175. package/dist/components/ui/dialog.js +90 -69
  176. package/dist/components/ui/dialog.js.map +1 -1
  177. package/dist/components/ui/dialog.mjs +21 -4
  178. package/dist/components/ui/dialog.mjs.map +1 -1
  179. package/dist/components/ui/label.js +55 -40
  180. package/dist/components/ui/label.js.map +1 -1
  181. package/dist/components/ui/label.mjs +9 -4
  182. package/dist/components/ui/label.mjs.map +1 -1
  183. package/dist/components/ui/separator.js +54 -39
  184. package/dist/components/ui/separator.js.map +1 -1
  185. package/dist/components/ui/separator.mjs +15 -8
  186. package/dist/components/ui/separator.mjs.map +1 -1
  187. package/dist/components/ui/textarea.js +50 -35
  188. package/dist/components/ui/textarea.js.map +1 -1
  189. package/dist/components/ui/textarea.mjs +13 -7
  190. package/dist/components/ui/textarea.mjs.map +1 -1
  191. package/dist/context/index.js +17 -2
  192. package/dist/context/index.js.map +1 -1
  193. package/dist/context/index.mjs +1 -2
  194. package/dist/context/index.mjs.map +1 -1
  195. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +43 -18
  196. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +1 -1
  197. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +10 -6
  198. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
  199. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js +50 -25
  200. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map +1 -1
  201. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +8 -4
  202. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
  203. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js +62 -29
  204. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
  205. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +9 -5
  206. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
  207. package/dist/hooks/index.js +17 -2
  208. package/dist/hooks/index.js.map +1 -1
  209. package/dist/hooks/index.mjs +1 -2
  210. package/dist/hooks/index.mjs.map +1 -1
  211. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +35 -11
  212. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
  213. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +8 -4
  214. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
  215. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +38 -14
  216. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
  217. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +8 -4
  218. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
  219. package/dist/hooks/misc/use-autosize-textarea.js +25 -7
  220. package/dist/hooks/misc/use-autosize-textarea.js.map +1 -1
  221. package/dist/hooks/misc/use-autosize-textarea.mjs +7 -3
  222. package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
  223. package/dist/index.js +422 -275
  224. package/dist/index.js.map +1 -1
  225. package/dist/index.mjs +62 -49
  226. package/dist/index.mjs.map +1 -1
  227. package/dist/lib/debouncer.js +27 -5
  228. package/dist/lib/debouncer.js.map +1 -1
  229. package/dist/lib/debouncer.mjs +7 -3
  230. package/dist/lib/debouncer.mjs.map +1 -1
  231. package/dist/lib/editor-to-text.js +30 -8
  232. package/dist/lib/editor-to-text.js.map +1 -1
  233. package/dist/lib/editor-to-text.mjs +7 -3
  234. package/dist/lib/editor-to-text.mjs.map +1 -1
  235. package/dist/lib/get-text-around-cursor.js +49 -24
  236. package/dist/lib/get-text-around-cursor.js.map +1 -1
  237. package/dist/lib/get-text-around-cursor.mjs +13 -3
  238. package/dist/lib/get-text-around-cursor.mjs.map +1 -1
  239. package/dist/lib/retry.js +27 -4
  240. package/dist/lib/retry.js.map +1 -1
  241. package/dist/lib/retry.mjs +7 -3
  242. package/dist/lib/retry.mjs.map +1 -1
  243. package/dist/lib/slatejs-edits/add-autocompletions.js +29 -7
  244. package/dist/lib/slatejs-edits/add-autocompletions.js.map +1 -1
  245. package/dist/lib/slatejs-edits/add-autocompletions.mjs +7 -3
  246. package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
  247. package/dist/lib/slatejs-edits/clear-autocompletions.js +31 -9
  248. package/dist/lib/slatejs-edits/clear-autocompletions.js.map +1 -1
  249. package/dist/lib/slatejs-edits/clear-autocompletions.mjs +7 -3
  250. package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
  251. package/dist/lib/slatejs-edits/replace-text.js +32 -10
  252. package/dist/lib/slatejs-edits/replace-text.js.map +1 -1
  253. package/dist/lib/slatejs-edits/replace-text.mjs +7 -3
  254. package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
  255. package/dist/lib/slatejs-edits/with-partial-history.js +42 -19
  256. package/dist/lib/slatejs-edits/with-partial-history.js.map +1 -1
  257. package/dist/lib/slatejs-edits/with-partial-history.mjs +9 -3
  258. package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
  259. package/dist/lib/stream-promise-flatten.js +27 -5
  260. package/dist/lib/stream-promise-flatten.js.map +1 -1
  261. package/dist/lib/stream-promise-flatten.mjs +7 -3
  262. package/dist/lib/stream-promise-flatten.mjs.map +1 -1
  263. package/dist/lib/utils.js +44 -16
  264. package/dist/lib/utils.js.map +1 -1
  265. package/dist/lib/utils.mjs +17 -3
  266. package/dist/lib/utils.mjs.map +1 -1
  267. package/dist/lib/utils.test.js +1 -2
  268. package/dist/lib/utils.test.js.map +1 -1
  269. package/dist/lib/utils.test.mjs +0 -1
  270. package/dist/lib/utils.test.mjs.map +1 -1
  271. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js +17 -2
  272. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.js.map +1 -1
  273. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
  274. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
  275. package/dist/types/autosuggestions-config/autosuggestions-config.js +35 -9
  276. package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
  277. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +12 -8
  278. package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
  279. package/dist/types/autosuggestions-config/editing-api-config.js +31 -6
  280. package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -1
  281. package/dist/types/autosuggestions-config/editing-api-config.mjs +11 -3
  282. package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
  283. package/dist/types/autosuggestions-config/index.js +35 -9
  284. package/dist/types/autosuggestions-config/index.js.map +1 -1
  285. package/dist/types/autosuggestions-config/index.mjs +13 -9
  286. package/dist/types/autosuggestions-config/index.mjs.map +1 -1
  287. package/dist/types/autosuggestions-config/insertions-api-config.js +31 -6
  288. package/dist/types/autosuggestions-config/insertions-api-config.js.map +1 -1
  289. package/dist/types/autosuggestions-config/insertions-api-config.mjs +11 -3
  290. package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
  291. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js +17 -2
  292. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.js.map +1 -1
  293. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
  294. package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
  295. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js +17 -2
  296. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js.map +1 -1
  297. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
  298. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
  299. package/dist/types/autosuggestions-config/suggestions-api-config.js +31 -6
  300. package/dist/types/autosuggestions-config/suggestions-api-config.js.map +1 -1
  301. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +11 -3
  302. package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
  303. package/dist/types/base/autosuggestion-state.js +17 -2
  304. package/dist/types/base/autosuggestion-state.js.map +1 -1
  305. package/dist/types/base/autosuggestion-state.mjs +0 -2
  306. package/dist/types/base/autosuggestion-state.mjs.map +1 -1
  307. package/dist/types/base/autosuggestions-bare-function.js +17 -2
  308. package/dist/types/base/autosuggestions-bare-function.js.map +1 -1
  309. package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
  310. package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
  311. package/dist/types/base/base-autosuggestions-config.js +29 -7
  312. package/dist/types/base/base-autosuggestions-config.js.map +1 -1
  313. package/dist/types/base/base-autosuggestions-config.mjs +7 -3
  314. package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
  315. package/dist/types/base/base-copilot-textarea-props.js +17 -2
  316. package/dist/types/base/base-copilot-textarea-props.js.map +1 -1
  317. package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
  318. package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
  319. package/dist/types/base/custom-editor.js +17 -2
  320. package/dist/types/base/custom-editor.js.map +1 -1
  321. package/dist/types/base/custom-editor.mjs +0 -2
  322. package/dist/types/base/custom-editor.mjs.map +1 -1
  323. package/dist/types/base/editor-autocomplete-state.js +32 -8
  324. package/dist/types/base/editor-autocomplete-state.js.map +1 -1
  325. package/dist/types/base/editor-autocomplete-state.mjs +8 -4
  326. package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
  327. package/dist/types/base/index.js +30 -6
  328. package/dist/types/base/index.js.map +1 -1
  329. package/dist/types/base/index.mjs +8 -4
  330. package/dist/types/base/index.mjs.map +1 -1
  331. package/dist/types/html-copilot-textarea-element.js +17 -2
  332. package/dist/types/html-copilot-textarea-element.js.map +1 -1
  333. package/dist/types/html-copilot-textarea-element.mjs +1 -2
  334. package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
  335. package/dist/types/index.js +37 -10
  336. package/dist/types/index.js.map +1 -1
  337. package/dist/types/index.mjs +18 -11
  338. package/dist/types/index.mjs.map +1 -1
  339. package/package.json +8 -8
@@ -1,24 +1,59 @@
1
- import { useCopilotTextareaEditor } from './chunk-DRV2FOHZ.mjs';
2
- import { usePopulateCopilotTextareaRef } from './chunk-VPEH6V7T.mjs';
3
- import { addAutocompletionsToEditor } from './chunk-2C7O2EVM.mjs';
4
- import { clearAutocompletionsFromEditor } from './chunk-GQN2HYFJ.mjs';
5
- import { replaceEditorText } from './chunk-5UNJXFUO.mjs';
6
- import { useAutosuggestions } from './chunk-72P3KOHZ.mjs';
7
- import { TrackerTextEditedSinceLastCursorMovement } from './chunk-LQ2OWQU7.mjs';
8
- import { useAddBrandingCss } from './chunk-7LSRNPNI.mjs';
9
- import { HoveringToolbar } from './chunk-5J3UZV77.mjs';
10
- import { HoveringEditorProvider, useHoveringEditorContext } from './chunk-LYB4B6MK.mjs';
11
- import { defaultBaseAutosuggestionsConfig } from './chunk-FP2EKU3L.mjs';
12
- import { makeRenderElementFunction } from './chunk-224UKA7C.mjs';
13
- import { makeRenderPlaceholderFunction } from './chunk-XW3ICO4S.mjs';
14
- import { getTextAroundCollapsedCursor, getFullEditorTextWithNewlines } from './chunk-ECR45NSD.mjs';
15
- import { __spreadProps, __spreadValues, __objRest } from './chunk-MRXNTQOX.mjs';
16
- import React, { useMemo, useState, useCallback, useEffect } from 'react';
17
- import { Editor } from 'slate';
18
- import { Slate, Editable } from 'slate-react';
19
- import { twMerge } from 'tailwind-merge';
20
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import {
2
+ useCopilotTextareaEditor
3
+ } from "./chunk-DRV2FOHZ.mjs";
4
+ import {
5
+ usePopulateCopilotTextareaRef
6
+ } from "./chunk-VPEH6V7T.mjs";
7
+ import {
8
+ addAutocompletionsToEditor
9
+ } from "./chunk-2C7O2EVM.mjs";
10
+ import {
11
+ clearAutocompletionsFromEditor
12
+ } from "./chunk-GQN2HYFJ.mjs";
13
+ import {
14
+ replaceEditorText
15
+ } from "./chunk-5UNJXFUO.mjs";
16
+ import {
17
+ useAutosuggestions
18
+ } from "./chunk-72P3KOHZ.mjs";
19
+ import {
20
+ TrackerTextEditedSinceLastCursorMovement
21
+ } from "./chunk-LQ2OWQU7.mjs";
22
+ import {
23
+ useAddBrandingCss
24
+ } from "./chunk-7LSRNPNI.mjs";
25
+ import {
26
+ HoveringToolbar
27
+ } from "./chunk-5J3UZV77.mjs";
28
+ import {
29
+ HoveringEditorProvider,
30
+ useHoveringEditorContext
31
+ } from "./chunk-LYB4B6MK.mjs";
32
+ import {
33
+ defaultBaseAutosuggestionsConfig
34
+ } from "./chunk-FP2EKU3L.mjs";
35
+ import {
36
+ makeRenderElementFunction
37
+ } from "./chunk-224UKA7C.mjs";
38
+ import {
39
+ makeRenderPlaceholderFunction
40
+ } from "./chunk-XW3ICO4S.mjs";
41
+ import {
42
+ getFullEditorTextWithNewlines,
43
+ getTextAroundCollapsedCursor
44
+ } from "./chunk-ECR45NSD.mjs";
45
+ import {
46
+ __objRest,
47
+ __spreadProps,
48
+ __spreadValues
49
+ } from "./chunk-MRXNTQOX.mjs";
21
50
 
51
+ // src/components/base-copilot-textarea/base-copilot-textarea.tsx
52
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
53
+ import { Editor } from "slate";
54
+ import { Editable, Slate } from "slate-react";
55
+ import { twMerge } from "tailwind-merge";
56
+ import { jsx, jsxs } from "react/jsx-runtime";
22
57
  var BaseCopilotTextarea = React.forwardRef(
23
58
  (props, ref) => {
24
59
  return /* @__PURE__ */ jsx(HoveringEditorProvider, { children: /* @__PURE__ */ jsx(BaseCopilotTextareaWithHoveringContext, __spreadProps(__spreadValues({}, props), { ref })) });
@@ -212,6 +247,7 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
212
247
  };
213
248
  }
214
249
 
215
- export { BaseCopilotTextarea };
216
- //# sourceMappingURL=out.js.map
250
+ export {
251
+ BaseCopilotTextarea
252
+ };
217
253
  //# sourceMappingURL=chunk-B6TKVDDY.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/base-copilot-textarea/base-copilot-textarea.tsx"],"names":["_a","value"],"mapp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C,eAAe;AAAA,cACf,mBAAmB;AAAA,cACnB,WAAW,CAAC,UAAU;AA1QhC,oBAAAA;AA2QY,kDAAkC,KAAK;AACvC,gDAAgC,KAAK;AACrC,iBAAAA,MAAA,MAAM,cAAN,gBAAAA,IAAA,YAAkB;AAAA,cACpB;AAAA,cACA,WAAW;AAAA,eACP;AAAA,UACN;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAaA,SAAS,+BACP,aACwC;AACxC,SAAO;AAAA,IACL,QAAQ;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,IACR;AAAA,IACA,eAAe;AAAA,MACb,OAAO;AAAA,MACP,MAAM;AAAA,IACR;AAAA,EACF;AACF","sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Descendant, Editor } from \"slate\";\nimport { Editable, Slate } from \"slate-react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { useAutosuggestions } from \"../../hooks/base-copilot-textarea-implementation/use-autosuggestions\";\nimport { useCopilotTextareaEditor } from \"../../hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor\";\nimport { usePopulateCopilotTextareaRef } from \"../../hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref\";\nimport {\n getFullEditorTextWithNewlines,\n getTextAroundCollapsedCursor,\n} from \"../../lib/get-text-around-cursor\";\nimport { addAutocompletionsToEditor } from \"../../lib/slatejs-edits/add-autocompletions\";\nimport { clearAutocompletionsFromEditor } from \"../../lib/slatejs-edits/clear-autocompletions\";\nimport { replaceEditorText } from \"../../lib/slatejs-edits/replace-text\";\nimport { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from \"../../types/base\";\nimport { AutosuggestionState } from \"../../types/base/autosuggestion-state\";\nimport { BaseCopilotTextareaProps } from \"../../types/base/base-copilot-textarea-props\";\nimport \"./base-copilot-textarea.css\";\nimport { HoveringToolbar } from \"../hovering-toolbar/hovering-toolbar\";\nimport { makeRenderElementFunction } from \"./render-element\";\nimport { makeRenderPlaceholderFunction } from \"./render-placeholder\";\nimport { useAddBrandingCss } from \"./use-add-branding-css\";\nimport {\n HoveringEditorProvider,\n useHoveringEditorContext,\n} from \"../hovering-toolbar/hovering-editor-provider\";\nimport { TrackerTextEditedSinceLastCursorMovement } from \"./track-cursor-moved-since-last-text-change\";\n\n/**\n * Purpose: to be used as the `ref` type for `CopilotTextarea` and `BaseCopilotTextarea`.\n *\n * This interface extends `HTMLElement`, and is the subset of `HTMLTextAreaElement` that \"actually matters\".\n * It provides the core functionality that consumers of `HTMLTextAreaElement` need 99.9% of the time:\n * - `value`: the current value of the textarea\n * - `focus`: make the textarea focused\n * - `blur`: make the textarea unfocused\n */\nexport interface HTMLCopilotTextAreaElement extends HTMLElement {\n /**\n * The current value of the textarea.\n */\n value: string;\n\n /**\n * focus on the textarea\n */\n focus: () => void;\n\n /**\n * unfocus the textarea.\n *\n * Called `blur` for syntactic compatibility with `HTMLTextAreaElement`.\n */\n blur: () => void;\n}\n\n/**\n * Not intended for direct use. Use CopilotTextarea instead.\n *\n * The `BaseCopilotTextarea` includes the basic UX component,\n * without the business logic / AI logic that makes the content useful and coherent.\n *\n * It is useful if you want to build your own backend, with fully custom business logic\n * for figuring out which contnet to fill in.\n */\nexport const BaseCopilotTextarea = React.forwardRef(\n (props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>) => {\n return (\n <HoveringEditorProvider>\n <BaseCopilotTextareaWithHoveringContext {...props} ref={ref} />\n </HoveringEditorProvider>\n );\n },\n);\n\n/**\n * Not intended for direct use. Use `CopilotTextarea` instead.\n *\n * This is the private core of the `BaseCopilotTextarea` component.\n * For practical purposes the implementation is cleaner assuming containment in a `HoveringEditorProviderContext`.\n *\n * Therefore we separate the core logic into this component,\n * and wrap it in a `HoveringEditorProviderContext` in `BaseCopilotTextarea`.\n */\nconst BaseCopilotTextareaWithHoveringContext = React.forwardRef(\n (props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>) => {\n const autosuggestionsConfig: BaseAutosuggestionsConfig = {\n ...defaultBaseAutosuggestionsConfig,\n ...props.baseAutosuggestionsConfig,\n };\n\n const valueOnInitialRender = useMemo(() => props.value ?? \"\", []);\n const [lastKnownFullEditorText, setLastKnownFullEditorText] = useState(valueOnInitialRender);\n const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = useState(false);\n\n // // When the editor text changes, we want to reset the `textEditedSinceLastCursorMovement` state.\n // useEffect(() => {\n // setCursorMovedSinceLastTextChange(false);\n // }, [lastKnownFullEditorText]);\n\n const initialValue: Descendant[] = useMemo(() => {\n return [\n {\n type: \"paragraph\",\n children: [{ text: valueOnInitialRender }],\n },\n ];\n }, [valueOnInitialRender]);\n\n const editor = useCopilotTextareaEditor();\n\n const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } =\n useHoveringEditorContext();\n\n const insertText = useCallback(\n (autosuggestion: AutosuggestionState) => {\n Editor.insertText(editor, autosuggestion.text, {\n at: autosuggestion.point,\n });\n },\n [editor],\n );\n\n const shouldDisableAutosuggestions =\n // textarea is manually disabled:\n autosuggestionsConfig.disabled ||\n // hovering editor is displayed:\n hoveringEditorIsDisplayed ||\n // the cursor has moved since the last text change AND we are configured to disable autosuggestions in this case:\n (cursorMovedSinceLastTextChange &&\n autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText);\n\n const {\n currentAutocompleteSuggestion,\n onChangeHandler: onChangeHandlerForAutocomplete,\n onKeyDownHandler: onKeyDownHandlerForAutocomplete,\n } = useAutosuggestions(\n autosuggestionsConfig.debounceTime,\n autosuggestionsConfig.shouldAcceptAutosuggestionOnKeyPress,\n autosuggestionsConfig.apiConfig.autosuggestionsFunction,\n insertText,\n autosuggestionsConfig.disableWhenEmpty,\n shouldDisableAutosuggestions,\n );\n\n const onKeyDownHandlerForHoveringEditor = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event)) {\n event.preventDefault();\n setHoveringEditorIsDisplayed(!hoveringEditorIsDisplayed);\n }\n },\n [\n hoveringEditorIsDisplayed,\n setHoveringEditorIsDisplayed,\n autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress,\n ],\n );\n\n // sync autosuggestions state with the editor\n useEffect(() => {\n clearAutocompletionsFromEditor(editor);\n if (currentAutocompleteSuggestion) {\n addAutocompletionsToEditor(\n editor,\n currentAutocompleteSuggestion.text,\n currentAutocompleteSuggestion.point,\n );\n }\n }, [currentAutocompleteSuggestion]);\n\n const suggestionStyleAugmented: React.CSSProperties = useMemo(() => {\n return {\n fontStyle: \"italic\",\n color: \"gray\",\n ...props.suggestionsStyle,\n };\n }, [props.suggestionsStyle]);\n\n const renderElementMemoized = useMemo(() => {\n return makeRenderElementFunction(suggestionStyleAugmented);\n }, [suggestionStyleAugmented]);\n\n const renderPlaceholderMemoized = useMemo(() => {\n // For some reason slateJS specifies a top value of 0, which makes for strange styling. We override this here.\n const placeholderStyleSlatejsOverrides: React.CSSProperties = {\n top: undefined,\n };\n\n const placeholderStyleAugmented: React.CSSProperties = {\n ...placeholderStyleSlatejsOverrides,\n ...props.placeholderStyle,\n };\n\n return makeRenderPlaceholderFunction(placeholderStyleAugmented);\n }, [props.placeholderStyle]);\n\n // update the editor text, but only when the value changes from outside the component\n useEffect(() => {\n if (props.value === lastKnownFullEditorText) {\n return;\n }\n\n setLastKnownFullEditorText(props.value ?? \"\");\n replaceEditorText(editor, props.value ?? \"\");\n }, [props.value]);\n\n // separate into TextareaHTMLAttributes<HTMLDivElement> and CopilotTextareaProps\n const {\n placeholderStyle,\n value,\n hoverMenuClassname,\n onValueChange,\n baseAutosuggestionsConfig: autosuggestionsConfigFromProps,\n className,\n onChange,\n onKeyDown,\n disableBranding,\n ...propsToForward\n } = props;\n\n useAddBrandingCss(suggestionStyleAugmented, disableBranding);\n usePopulateCopilotTextareaRef(editor, ref);\n\n const moddedClassName = (() => {\n const baseClassName = \"copilot-textarea\";\n const brandingClass = disableBranding ? \"no-branding\" : \"with-branding\";\n const defaultTailwindClassName = \"bg-white overflow-y-auto resize-y\";\n const mergedClassName = twMerge(defaultTailwindClassName, className ?? \"\");\n return `${baseClassName} ${brandingClass} ${mergedClassName}`;\n })();\n\n return (\n <Slate\n editor={editor}\n initialValue={initialValue}\n onChange={(value) => {\n const newEditorState = getTextAroundCollapsedCursor(editor);\n\n const fullEditorText = newEditorState\n ? newEditorState.textBeforeCursor + newEditorState.textAfterCursor\n : getFullEditorTextWithNewlines(editor); // we don't double-parse the editor. When `newEditorState` is null, we didn't parse the editor yet.\n\n setLastKnownFullEditorText((prev) => {\n if (prev !== fullEditorText) {\n setCursorMovedSinceLastTextChange(false);\n }\n return fullEditorText;\n });\n onChangeHandlerForAutocomplete(newEditorState);\n\n props.onValueChange?.(fullEditorText);\n props.onChange?.(makeSemiFakeReactTextAreaEvent(fullEditorText));\n }}\n >\n <TrackerTextEditedSinceLastCursorMovement\n setCursorMovedSinceLastTextChange={setCursorMovedSinceLastTextChange}\n />\n <HoveringToolbar\n apiConfig={autosuggestionsConfig.apiConfig}\n contextCategories={autosuggestionsConfig.contextCategories}\n hoverMenuClassname={hoverMenuClassname}\n />\n <Editable\n renderElement={renderElementMemoized}\n renderPlaceholder={renderPlaceholderMemoized}\n onKeyDown={(event) => {\n onKeyDownHandlerForHoveringEditor(event); // forward the event for internal use\n onKeyDownHandlerForAutocomplete(event); // forward the event for internal use\n props.onKeyDown?.(event); // forward the event for external use\n }}\n className={moddedClassName}\n {...propsToForward}\n />\n </Slate>\n );\n },\n);\n\n// Consumers of <textarea> expect a `onChange: (React.ChangeEvent<HTMLTextAreaElement>) => void` event handler to be passed in.\n// This is *extremely* common, and we want to support it.\n//\n// We can't support the full functionality, but in 99% of cases, the consumer only cares about the `event.target.value` property --\n// that's how they get the new value of the textarea.\n//\n// So, the tradeoff we are making is minimizing compiler complaint, with a small chance of runtime error.\n// The alternative would be defining a different onChange entrypoint (we actually do have that in `onValueChange`),\n// And starting to explain subtleties to users the moment they try to use the component for the first time for very basic functionality.\n//\n// If this proves problematic, we can always revisit this decision.\nfunction makeSemiFakeReactTextAreaEvent(\n currentText: string,\n): React.ChangeEvent<HTMLTextAreaElement> {\n return {\n target: {\n value: currentText,\n type: \"copilot-textarea\",\n },\n currentTarget: {\n value: currentText,\n type: \"copilot-textarea\",\n },\n } as React.ChangeEvent<HTMLTextAreaElement>;\n}\n"]}
1
+ {"version":3,"sources":["../src/components/base-copilot-textarea/base-copilot-textarea.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Descendant, Editor } from \"slate\";\nimport { Editable, Slate } from \"slate-react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { useAutosuggestions } from \"../../hooks/base-copilot-textarea-implementation/use-autosuggestions\";\nimport { useCopilotTextareaEditor } from \"../../hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor\";\nimport { usePopulateCopilotTextareaRef } from \"../../hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref\";\nimport {\n getFullEditorTextWithNewlines,\n getTextAroundCollapsedCursor,\n} from \"../../lib/get-text-around-cursor\";\nimport { addAutocompletionsToEditor } from \"../../lib/slatejs-edits/add-autocompletions\";\nimport { clearAutocompletionsFromEditor } from \"../../lib/slatejs-edits/clear-autocompletions\";\nimport { replaceEditorText } from \"../../lib/slatejs-edits/replace-text\";\nimport { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from \"../../types/base\";\nimport { AutosuggestionState } from \"../../types/base/autosuggestion-state\";\nimport { BaseCopilotTextareaProps } from \"../../types/base/base-copilot-textarea-props\";\nimport \"./base-copilot-textarea.css\";\nimport { HoveringToolbar } from \"../hovering-toolbar/hovering-toolbar\";\nimport { makeRenderElementFunction } from \"./render-element\";\nimport { makeRenderPlaceholderFunction } from \"./render-placeholder\";\nimport { useAddBrandingCss } from \"./use-add-branding-css\";\nimport {\n HoveringEditorProvider,\n useHoveringEditorContext,\n} from \"../hovering-toolbar/hovering-editor-provider\";\nimport { TrackerTextEditedSinceLastCursorMovement } from \"./track-cursor-moved-since-last-text-change\";\n\n/**\n * Purpose: to be used as the `ref` type for `CopilotTextarea` and `BaseCopilotTextarea`.\n *\n * This interface extends `HTMLElement`, and is the subset of `HTMLTextAreaElement` that \"actually matters\".\n * It provides the core functionality that consumers of `HTMLTextAreaElement` need 99.9% of the time:\n * - `value`: the current value of the textarea\n * - `focus`: make the textarea focused\n * - `blur`: make the textarea unfocused\n */\nexport interface HTMLCopilotTextAreaElement extends HTMLElement {\n /**\n * The current value of the textarea.\n */\n value: string;\n\n /**\n * focus on the textarea\n */\n focus: () => void;\n\n /**\n * unfocus the textarea.\n *\n * Called `blur` for syntactic compatibility with `HTMLTextAreaElement`.\n */\n blur: () => void;\n}\n\n/**\n * Not intended for direct use. Use CopilotTextarea instead.\n *\n * The `BaseCopilotTextarea` includes the basic UX component,\n * without the business logic / AI logic that makes the content useful and coherent.\n *\n * It is useful if you want to build your own backend, with fully custom business logic\n * for figuring out which contnet to fill in.\n */\nexport const BaseCopilotTextarea = React.forwardRef(\n (props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>) => {\n return (\n <HoveringEditorProvider>\n <BaseCopilotTextareaWithHoveringContext {...props} ref={ref} />\n </HoveringEditorProvider>\n );\n },\n);\n\n/**\n * Not intended for direct use. Use `CopilotTextarea` instead.\n *\n * This is the private core of the `BaseCopilotTextarea` component.\n * For practical purposes the implementation is cleaner assuming containment in a `HoveringEditorProviderContext`.\n *\n * Therefore we separate the core logic into this component,\n * and wrap it in a `HoveringEditorProviderContext` in `BaseCopilotTextarea`.\n */\nconst BaseCopilotTextareaWithHoveringContext = React.forwardRef(\n (props: BaseCopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>) => {\n const autosuggestionsConfig: BaseAutosuggestionsConfig = {\n ...defaultBaseAutosuggestionsConfig,\n ...props.baseAutosuggestionsConfig,\n };\n\n const valueOnInitialRender = useMemo(() => props.value ?? \"\", []);\n const [lastKnownFullEditorText, setLastKnownFullEditorText] = useState(valueOnInitialRender);\n const [cursorMovedSinceLastTextChange, setCursorMovedSinceLastTextChange] = useState(false);\n\n // // When the editor text changes, we want to reset the `textEditedSinceLastCursorMovement` state.\n // useEffect(() => {\n // setCursorMovedSinceLastTextChange(false);\n // }, [lastKnownFullEditorText]);\n\n const initialValue: Descendant[] = useMemo(() => {\n return [\n {\n type: \"paragraph\",\n children: [{ text: valueOnInitialRender }],\n },\n ];\n }, [valueOnInitialRender]);\n\n const editor = useCopilotTextareaEditor();\n\n const { isDisplayed: hoveringEditorIsDisplayed, setIsDisplayed: setHoveringEditorIsDisplayed } =\n useHoveringEditorContext();\n\n const insertText = useCallback(\n (autosuggestion: AutosuggestionState) => {\n Editor.insertText(editor, autosuggestion.text, {\n at: autosuggestion.point,\n });\n },\n [editor],\n );\n\n const shouldDisableAutosuggestions =\n // textarea is manually disabled:\n autosuggestionsConfig.disabled ||\n // hovering editor is displayed:\n hoveringEditorIsDisplayed ||\n // the cursor has moved since the last text change AND we are configured to disable autosuggestions in this case:\n (cursorMovedSinceLastTextChange &&\n autosuggestionsConfig.temporarilyDisableWhenMovingCursorWithoutChangingText);\n\n const {\n currentAutocompleteSuggestion,\n onChangeHandler: onChangeHandlerForAutocomplete,\n onKeyDownHandler: onKeyDownHandlerForAutocomplete,\n } = useAutosuggestions(\n autosuggestionsConfig.debounceTime,\n autosuggestionsConfig.shouldAcceptAutosuggestionOnKeyPress,\n autosuggestionsConfig.apiConfig.autosuggestionsFunction,\n insertText,\n autosuggestionsConfig.disableWhenEmpty,\n shouldDisableAutosuggestions,\n );\n\n const onKeyDownHandlerForHoveringEditor = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress(event)) {\n event.preventDefault();\n setHoveringEditorIsDisplayed(!hoveringEditorIsDisplayed);\n }\n },\n [\n hoveringEditorIsDisplayed,\n setHoveringEditorIsDisplayed,\n autosuggestionsConfig.shouldToggleHoveringEditorOnKeyPress,\n ],\n );\n\n // sync autosuggestions state with the editor\n useEffect(() => {\n clearAutocompletionsFromEditor(editor);\n if (currentAutocompleteSuggestion) {\n addAutocompletionsToEditor(\n editor,\n currentAutocompleteSuggestion.text,\n currentAutocompleteSuggestion.point,\n );\n }\n }, [currentAutocompleteSuggestion]);\n\n const suggestionStyleAugmented: React.CSSProperties = useMemo(() => {\n return {\n fontStyle: \"italic\",\n color: \"gray\",\n ...props.suggestionsStyle,\n };\n }, [props.suggestionsStyle]);\n\n const renderElementMemoized = useMemo(() => {\n return makeRenderElementFunction(suggestionStyleAugmented);\n }, [suggestionStyleAugmented]);\n\n const renderPlaceholderMemoized = useMemo(() => {\n // For some reason slateJS specifies a top value of 0, which makes for strange styling. We override this here.\n const placeholderStyleSlatejsOverrides: React.CSSProperties = {\n top: undefined,\n };\n\n const placeholderStyleAugmented: React.CSSProperties = {\n ...placeholderStyleSlatejsOverrides,\n ...props.placeholderStyle,\n };\n\n return makeRenderPlaceholderFunction(placeholderStyleAugmented);\n }, [props.placeholderStyle]);\n\n // update the editor text, but only when the value changes from outside the component\n useEffect(() => {\n if (props.value === lastKnownFullEditorText) {\n return;\n }\n\n setLastKnownFullEditorText(props.value ?? \"\");\n replaceEditorText(editor, props.value ?? \"\");\n }, [props.value]);\n\n // separate into TextareaHTMLAttributes<HTMLDivElement> and CopilotTextareaProps\n const {\n placeholderStyle,\n value,\n hoverMenuClassname,\n onValueChange,\n baseAutosuggestionsConfig: autosuggestionsConfigFromProps,\n className,\n onChange,\n onKeyDown,\n disableBranding,\n ...propsToForward\n } = props;\n\n useAddBrandingCss(suggestionStyleAugmented, disableBranding);\n usePopulateCopilotTextareaRef(editor, ref);\n\n const moddedClassName = (() => {\n const baseClassName = \"copilot-textarea\";\n const brandingClass = disableBranding ? \"no-branding\" : \"with-branding\";\n const defaultTailwindClassName = \"bg-white overflow-y-auto resize-y\";\n const mergedClassName = twMerge(defaultTailwindClassName, className ?? \"\");\n return `${baseClassName} ${brandingClass} ${mergedClassName}`;\n })();\n\n return (\n <Slate\n editor={editor}\n initialValue={initialValue}\n onChange={(value) => {\n const newEditorState = getTextAroundCollapsedCursor(editor);\n\n const fullEditorText = newEditorState\n ? newEditorState.textBeforeCursor + newEditorState.textAfterCursor\n : getFullEditorTextWithNewlines(editor); // we don't double-parse the editor. When `newEditorState` is null, we didn't parse the editor yet.\n\n setLastKnownFullEditorText((prev) => {\n if (prev !== fullEditorText) {\n setCursorMovedSinceLastTextChange(false);\n }\n return fullEditorText;\n });\n onChangeHandlerForAutocomplete(newEditorState);\n\n props.onValueChange?.(fullEditorText);\n props.onChange?.(makeSemiFakeReactTextAreaEvent(fullEditorText));\n }}\n >\n <TrackerTextEditedSinceLastCursorMovement\n setCursorMovedSinceLastTextChange={setCursorMovedSinceLastTextChange}\n />\n <HoveringToolbar\n apiConfig={autosuggestionsConfig.apiConfig}\n contextCategories={autosuggestionsConfig.contextCategories}\n hoverMenuClassname={hoverMenuClassname}\n />\n <Editable\n renderElement={renderElementMemoized}\n renderPlaceholder={renderPlaceholderMemoized}\n onKeyDown={(event) => {\n onKeyDownHandlerForHoveringEditor(event); // forward the event for internal use\n onKeyDownHandlerForAutocomplete(event); // forward the event for internal use\n props.onKeyDown?.(event); // forward the event for external use\n }}\n className={moddedClassName}\n {...propsToForward}\n />\n </Slate>\n );\n },\n);\n\n// Consumers of <textarea> expect a `onChange: (React.ChangeEvent<HTMLTextAreaElement>) => void` event handler to be passed in.\n// This is *extremely* common, and we want to support it.\n//\n// We can't support the full functionality, but in 99% of cases, the consumer only cares about the `event.target.value` property --\n// that's how they get the new value of the textarea.\n//\n// So, the tradeoff we are making is minimizing compiler complaint, with a small chance of runtime error.\n// The alternative would be defining a different onChange entrypoint (we actually do have that in `onValueChange`),\n// And starting to explain subtleties to users the moment they try to use the component for the first time for very basic functionality.\n//\n// If this proves problematic, we can always revisit this decision.\nfunction makeSemiFakeReactTextAreaEvent(\n currentText: string,\n): React.ChangeEvent<HTMLTextAreaElement> {\n return {\n target: {\n value: currentText,\n type: \"copilot-textarea\",\n },\n currentTarget: {\n value: currentText,\n type: \"copilot-textarea\",\n },\n } as React.ChangeEvent<HTMLTextAreaElement>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,SAAS,aAAa,WAAW,SAAS,gBAAgB;AACjE,SAAqB,cAAc;AACnC,SAAS,UAAU,aAAa;AAChC,SAAS,eAAe;AAkEhB,cAoKF,YApKE;AAJD,IAAM,sBAAsB,MAAM;AAAA,EACvC,CAAC,OAAiC,QAA+C;AAC/E,WACE,oBAAC,0BACC,8BAAC,yEAA2C,QAA3C,EAAkD,MAAU,GAC/D;AAAA,EAEJ;AACF;AAWA,IAAM,yCAAyC,MAAM;AAAA,EACnD,CAAC,OAAiC,QAA+C;AAC/E,UAAM,wBAAmD,kCACpD,mCACA,MAAM;AAGX,UAAM,uBAAuB,QAAQ,MAAG;AA3F5C,UAAAA;AA2F+C,cAAAA,MAAA,MAAM,UAAN,OAAAA,MAAe;AAAA,OAAI,CAAC,CAAC;AAChE,UAAM,CAAC,yBAAyB,0BAA0B,IAAI,SAAS,oBAAoB;AAC3F,UAAM,CAAC,gCAAgC,iCAAiC,IAAI,SAAS,KAAK;AAO1F,UAAM,eAA6B,QAAQ,MAAM;AAC/C,aAAO;AAAA,QACL;AAAA,UACE,MAAM;AAAA,UACN,UAAU,CAAC,EAAE,MAAM,qBAAqB,CAAC;AAAA,QAC3C;AAAA,MACF;AAAA,IACF,GAAG,CAAC,oBAAoB,CAAC;AAEzB,UAAM,SAAS,yBAAyB;AAExC,UAAM,EAAE,aAAa,2BAA2B,gBAAgB,6BAA6B,IAC3F,yBAAyB;AAE3B,UAAM,aAAa;AAAA,MACjB,CAAC,mBAAwC;AACvC,eAAO,WAAW,QAAQ,eAAe,MAAM;AAAA,UA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;AAAA,YAAC;AAAA;AAAA,cACC;AAAA;AAAA,UACF;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW,sBAAsB;AAAA,cACjC,mBAAmB,sBAAsB;AAAA,cACzC;AAAA;AAAA,UACF;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,eAAe;AAAA,cACf,mBAAmB;AAAA,cACnB,WAAW,CAAC,UAAU;AA1QhC,oBAAAA;AA2QY,kDAAkC,KAAK;AACvC,gDAAgC,KAAK;AACrC,iBAAAA,MAAA,MAAM,cAAN,gBAAAA,IAAA,YAAkB;AAAA,cACpB;AAAA,cACA,WAAW;AAAA,eACP;AAAA,UACN;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAaA,SAAS,+BACP,aACwC;AACxC,SAAO;AAAA,IACL,QAAQ;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,IACR;AAAA,IACA,eAAe;AAAA,MACb,OAAO;AAAA,MACP,MAAM;AAAA,IACR;AAAA,EACF;AACF;","names":["_a","value"]}
@@ -1,6 +1,9 @@
1
- import { HoveringInsertionPromptBoxCore } from './chunk-VB4VNCIQ.mjs';
2
- import { jsx } from 'react/jsx-runtime';
1
+ import {
2
+ HoveringInsertionPromptBoxCore
3
+ } from "./chunk-VB4VNCIQ.mjs";
3
4
 
5
+ // src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
6
+ import { jsx } from "react/jsx-runtime";
4
7
  var HoveringInsertionPromptBox = (props) => {
5
8
  return /* @__PURE__ */ jsx(
6
9
  "div",
@@ -22,6 +25,7 @@ var HoveringInsertionPromptBox = (props) => {
22
25
  );
23
26
  };
24
27
 
25
- export { HoveringInsertionPromptBox };
26
- //# sourceMappingURL=out.js.map
28
+ export {
29
+ HoveringInsertionPromptBox
30
+ };
27
31
  //# sourceMappingURL=chunk-BBZ7AWOB.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx"],"names":[],"mappings":";;;;;AAoBM;AANC,IAAM,6BAA6B,CAAC,UAAiB;AAC1D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,QAAQ;AAAA,MAExB;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,aAAa,MAAM;AAAA,UACrB;AAAA,UACA,4BAA4B,MAAM,UAAU;AAAA,UAC5C,kBAAkB,MAAM;AAAA,UACxB,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EACF;AAEJ","sourcesContent":["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 closeWindow: () => 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"]}
1
+ {"version":3,"sources":["../src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx"],"sourcesContent":["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 closeWindow: () => 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":";;;;;AAoBM;AANC,IAAM,6BAA6B,CAAC,UAAiB;AAC1D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,QAAQ;AAAA,MAExB;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,aAAa,MAAM;AAAA,UACrB;AAAA,UACA,4BAA4B,MAAM,UAAU;AAAA,UAC5C,kBAAkB,MAAM;AAAA,UACxB,mBAAmB,MAAM;AAAA;AAAA,MAC3B;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-DE5K76I2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,8 +1,12 @@
1
- import { withPartialHistory, defaultShouldSave } from './chunk-4NHVQZ67.mjs';
2
- import { useMemo } from 'react';
3
- import { createEditor, Element } from 'slate';
4
- import { withReact } from 'slate-react';
1
+ import {
2
+ defaultShouldSave,
3
+ withPartialHistory
4
+ } from "./chunk-4NHVQZ67.mjs";
5
5
 
6
+ // src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx
7
+ import { useMemo } from "react";
8
+ import { createEditor, Element } from "slate";
9
+ import { withReact } from "slate-react";
6
10
  var shouldSave = (op, prev) => {
7
11
  const excludedNodeType = "suggestion";
8
12
  if (op.type === "insert_node" && Element.isElement(op.node) && op.node.type === excludedNodeType) {
@@ -60,6 +64,7 @@ function useCopilotTextareaEditor() {
60
64
  return editor;
61
65
  }
62
66
 
63
- export { useCopilotTextareaEditor };
64
- //# sourceMappingURL=out.js.map
67
+ export {
68
+ useCopilotTextareaEditor
69
+ };
65
70
  //# sourceMappingURL=chunk-DRV2FOHZ.mjs.map
@@ -1 +1 @@
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,MAAI,GAAG,QAAQ,cAAc,UAAU,GAAG,cAAc,GAAG,WAAW,SAAS,kBAAkB;AAC/F,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 (op.type == \"set_node\" && \"type\" in op.properties && op.properties.type === excludedNodeType) {\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
+ {"version":3,"sources":["../src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx"],"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 (op.type == \"set_node\" && \"type\" in op.properties && op.properties.type === excludedNodeType) {\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"],"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,MAAI,GAAG,QAAQ,cAAc,UAAU,GAAG,cAAc,GAAG,WAAW,SAAS,kBAAkB;AAC/F,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;","names":["editor"]}
@@ -1,6 +1,5 @@
1
- import { Range, Editor, Text, Element, Path, Point } from 'slate';
2
-
3
1
  // src/lib/get-text-around-cursor.ts
2
+ import { Editor, Path, Range, Text, Element, Point } from "slate";
4
3
  function getTextAroundCollapsedCursor(editor) {
5
4
  const { selection } = editor;
6
5
  if (!selection || !Range.isCollapsed(selection)) {
@@ -96,6 +95,10 @@ function wellOrderedRange(range) {
96
95
  };
97
96
  }
98
97
 
99
- export { extractTextWithNewlines, getFullEditorTextWithNewlines, getTextAroundCollapsedCursor, getTextAroundSelection };
100
- //# sourceMappingURL=out.js.map
98
+ export {
99
+ getTextAroundCollapsedCursor,
100
+ getTextAroundSelection,
101
+ getFullEditorTextWithNewlines,
102
+ extractTextWithNewlines
103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AO;AAAA,EACT;AACF","sourcesContent":["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"]}
1
+ {"version":3,"sources":["../src/lib/get-text-around-cursor.ts"],"sourcesContent":["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;\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 +1,16 @@
1
- import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator } from './chunk-WTASPE2W.mjs';
2
- import { useState } from 'react';
3
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import {
2
+ Command,
3
+ CommandEmpty,
4
+ CommandGroup,
5
+ CommandInput,
6
+ CommandItem,
7
+ CommandList,
8
+ CommandSeparator
9
+ } from "./chunk-WTASPE2W.mjs";
4
10
 
11
+ // src/components/source-search-box/source-search-box.tsx
12
+ import { useState } from "react";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
5
14
  function SourceSearchBox(props) {
6
15
  const [selectedValue, setSelectedValue] = useState("");
7
16
  return /* @__PURE__ */ jsxs(
@@ -67,6 +76,8 @@ function Logo({
67
76
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", style: { width, height }, children });
68
77
  }
69
78
 
70
- export { Logo, SourceSearchBox };
71
- //# sourceMappingURL=out.js.map
79
+ export {
80
+ SourceSearchBox,
81
+ Logo
82
+ };
72
83
  //# sourceMappingURL=chunk-FJNUPSQK.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/source-search-box/source-search-box.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,gBAAgB;AA4CnB,cAkBU,YAlBV;AArBC,SAAS,gBAAgB,OAA6B;AAC3D,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiB,EAAE;AAE7D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO;AAAA,MACP,eAAe,CAAC,UAAU;AACxB,yBAAiB,KAAK;AAAA,MACxB;AAAA,MACA,QAAQ,CAAC,OAAO,WAAW;AAEzB,YAAI,MAAM,eAAe;AAAI,iBAAO;AAGpC,YAAI,MAAM,WAAW,MAAM,UAAU;AAAG,iBAAO;AAG/C,eAAO;AAAA,MACT;AAAA,MAEA;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,MAAM;AAAA,YACb,WAAU;AAAA,YACV,aAAY;AAAA;AAAA,QACd;AAAA,QACA,qBAAC,eACC;AAAA,8BAAC,gBAAa,+BAAiB;AAAA,UAE/B,oBAAC,gBAAa,SAAQ,uBACnB,gBAAM,eAAe,IAAI,CAAC,gBAAgB;AACzC,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEC,OAAO,YAAY;AAAA,gBACnB,UAAU,CAAC,UAAU;AACnB,wBAAM,eAAe,WAAW;AAAA,gBAClC;AAAA,gBAEA,+BAAC,SAAI,WAAU,2CACb;AAAA,sCAAC,QAAK,OAAM,QAAO,QAAO,QACxB;AAAA,oBAAC;AAAA;AAAA,sBACC,KAAK,YAAY;AAAA,sBACjB,KAAK,YAAY;AAAA,sBACjB,WAAU;AAAA;AAAA,kBACZ,GACF;AAAA,kBACC,YAAY;AAAA,mBACf;AAAA;AAAA,cAfK,QAAQ,YAAY,qBAAqB,YAAY;AAAA,YAgB5D;AAAA,UAEJ,CAAC,GACH;AAAA,UAqBA,oBAAC,oBAAiB;AAAA,WACpB;AAAA;AAAA;AAAA,EACF;AAEJ;AAEO,SAAS,KAAK;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,SACE,oBAAC,SAAI,WAAU,oCAAmC,OAAO,EAAE,OAAc,OAAe,GACrF,UACH;AAEJ","sourcesContent":["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"]}
1
+ {"version":3,"sources":["../src/components/source-search-box/source-search-box.tsx"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;AAAA,SAAS,gBAAgB;AA4CnB,cAkBU,YAlBV;AArBC,SAAS,gBAAgB,OAA6B;AAC3D,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiB,EAAE;AAE7D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO;AAAA,MACP,eAAe,CAAC,UAAU;AACxB,yBAAiB,KAAK;AAAA,MACxB;AAAA,MACA,QAAQ,CAAC,OAAO,WAAW;AAEzB,YAAI,MAAM,eAAe;AAAI,iBAAO;AAGpC,YAAI,MAAM,WAAW,MAAM,UAAU;AAAG,iBAAO;AAG/C,eAAO;AAAA,MACT;AAAA,MAEA;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,MAAM;AAAA,YACb,WAAU;AAAA,YACV,aAAY;AAAA;AAAA,QACd;AAAA,QACA,qBAAC,eACC;AAAA,8BAAC,gBAAa,+BAAiB;AAAA,UAE/B,oBAAC,gBAAa,SAAQ,uBACnB,gBAAM,eAAe,IAAI,CAAC,gBAAgB;AACzC,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEC,OAAO,YAAY;AAAA,gBACnB,UAAU,CAAC,UAAU;AACnB,wBAAM,eAAe,WAAW;AAAA,gBAClC;AAAA,gBAEA,+BAAC,SAAI,WAAU,2CACb;AAAA,sCAAC,QAAK,OAAM,QAAO,QAAO,QACxB;AAAA,oBAAC;AAAA;AAAA,sBACC,KAAK,YAAY;AAAA,sBACjB,KAAK,YAAY;AAAA,sBACjB,WAAU;AAAA;AAAA,kBACZ,GACF;AAAA,kBACC,YAAY;AAAA,mBACf;AAAA;AAAA,cAfK,QAAQ,YAAY,qBAAqB,YAAY;AAAA,YAgB5D;AAAA,UAEJ,CAAC,GACH;AAAA,UAqBA,oBAAC,oBAAiB;AAAA,WACpB;AAAA;AAAA;AAAA,EACF;AAEJ;AAEO,SAAS,KAAK;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,SACE,oBAAC,SAAI,WAAU,oCAAmC,OAAO,EAAE,OAAc,OAAe,GACrF,UACH;AAEJ;","names":[]}
@@ -1,6 +1,5 @@
1
- import { defaultCopilotContextCategories } from '@copilotkit/react-core';
2
-
3
1
  // src/types/base/base-autosuggestions-config.tsx
2
+ import { defaultCopilotContextCategories } from "@copilotkit/react-core";
4
3
  var defaultShouldToggleHoveringEditorOnKeyPress = (event) => {
5
4
  if (event.key === "k" && event.metaKey) {
6
5
  return true;
@@ -23,6 +22,7 @@ var defaultBaseAutosuggestionsConfig = {
23
22
  shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress
24
23
  };
25
24
 
26
- export { defaultBaseAutosuggestionsConfig };
27
- //# sourceMappingURL=out.js.map
25
+ export {
26
+ defaultBaseAutosuggestionsConfig
27
+ };
28
28
  //# sourceMappingURL=chunk-FP2EKU3L.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/base/base-autosuggestions-config.tsx"],"names":[],"mappings":";AACA,SAAS,uCAAuC;AAyDhD,IAAM,8CAA8C,CAClD,UACG;AAEH,MAAI,MAAM,QAAQ,OAAO,MAAM,SAAS;AACtC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,IAAM,8CAA8C,CAClD,UACG;AAEH,MAAI,MAAM,QAAQ,OAAO;AACvB,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAcO,IAAM,mCAGT;AAAA,EACF,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,uDAAuD;AAAA,EACvD,sCAAsC;AAAA,EACtC,sCAAsC;AACxC","sourcesContent":["import { BaseCopilotTextareaApiConfig } from \"./autosuggestions-bare-function\";\nimport { defaultCopilotContextCategories } from \"@copilotkit/react-core\";\n\n/**\n * @interface BaseAutosuggestionsConfig\n *\n * @property {string} textareaPurpose - The purpose of the textarea. This is used to guide the autosuggestions.\n *\n * @property {string[]} contextCategories - The categories of context to consider when providing autosuggestions.\n *\n * @property {number} debounceTime - The amount of time (in milliseconds) to wait before triggering autosuggestions after the user has stopped typing.\n *\n * @property {BaseCopilotTextareaApiConfig} apiConfig - The configuration for the API that provides the autosuggestions.\n *\n * @property {boolean} disableWhenEmpty - Whether to disable autosuggestions when the textarea is empty.\n *\n * @property {boolean} disabled - Whether to disable autosuggestions entirely.\n *\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable autosuggestions when the user moves the cursor without changing the text.\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the current autosuggestion based on a key press event. By default, the Tab key is used to accept the autosuggestion. Example code:\n *\n * ```typescript\n * const defaultShouldAcceptAutosuggestionOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if tab, accept the autosuggestion\n * if (event.key === \"Tab\") {\n * return true;\n * }\n * return false;\n * }\n * ```\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event. By default, the Command + K key combination is used to toggle the hovering editor. Example code:\n *\n * ```typescript\n * const defaultShouldToggleHoveringEditorOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if command-k, toggle the hovering editor\n * if (event.key === \"k\" && event.metaKey) {\n * return true;\n * }\n * return false;\n * }\n * ```\n */\nexport interface BaseAutosuggestionsConfig {\n textareaPurpose: string;\n contextCategories: string[];\n debounceTime: number;\n apiConfig: BaseCopilotTextareaApiConfig;\n\n disableWhenEmpty: boolean;\n disabled: boolean;\n temporarilyDisableWhenMovingCursorWithoutChangingText: boolean;\n shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;\n shouldToggleHoveringEditorOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;\n}\n\n// by default, command-k toggles the hovering editor\nconst defaultShouldToggleHoveringEditorOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n) => {\n // if command-k, toggle the hovering editor\n if (event.key === \"k\" && event.metaKey) {\n return true;\n }\n return false;\n};\n\nconst defaultShouldAcceptAutosuggestionOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n) => {\n // if tab, accept the autosuggestion\n if (event.key === \"Tab\") {\n return true;\n }\n return false;\n};\n\n/**\n * Default configuration for the BaseAutosuggestions.\n *\n * @property {number} debounceTime - The amount of time to wait before triggering the autosuggestions API call.\n * @property {string[]} contextCategories - The categories to use for context when making the autosuggestions API call.\n * @property {boolean} disableWhenEmpty - Whether to disable the autosuggestions when the textarea is empty.\n * @property {boolean} disabled - Whether to disable the autosuggestions feature entirely.\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable the autosuggestions when the cursor is moved without changing the text.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the autosuggestion based on a key press event.\n */\n\nexport const defaultBaseAutosuggestionsConfig: Omit<\n BaseAutosuggestionsConfig,\n \"textareaPurpose\" | \"apiConfig\"\n> = {\n debounceTime: 250,\n contextCategories: defaultCopilotContextCategories,\n disableWhenEmpty: true,\n disabled: false,\n temporarilyDisableWhenMovingCursorWithoutChangingText: true,\n shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,\n shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress,\n};\n"]}
1
+ {"version":3,"sources":["../src/types/base/base-autosuggestions-config.tsx"],"sourcesContent":["import { BaseCopilotTextareaApiConfig } from \"./autosuggestions-bare-function\";\nimport { defaultCopilotContextCategories } from \"@copilotkit/react-core\";\n\n/**\n * @interface BaseAutosuggestionsConfig\n *\n * @property {string} textareaPurpose - The purpose of the textarea. This is used to guide the autosuggestions.\n *\n * @property {string[]} contextCategories - The categories of context to consider when providing autosuggestions.\n *\n * @property {number} debounceTime - The amount of time (in milliseconds) to wait before triggering autosuggestions after the user has stopped typing.\n *\n * @property {BaseCopilotTextareaApiConfig} apiConfig - The configuration for the API that provides the autosuggestions.\n *\n * @property {boolean} disableWhenEmpty - Whether to disable autosuggestions when the textarea is empty.\n *\n * @property {boolean} disabled - Whether to disable autosuggestions entirely.\n *\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable autosuggestions when the user moves the cursor without changing the text.\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the current autosuggestion based on a key press event. By default, the Tab key is used to accept the autosuggestion. Example code:\n *\n * ```typescript\n * const defaultShouldAcceptAutosuggestionOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if tab, accept the autosuggestion\n * if (event.key === \"Tab\") {\n * return true;\n * }\n * return false;\n * }\n * ```\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event. By default, the Command + K key combination is used to toggle the hovering editor. Example code:\n *\n * ```typescript\n * const defaultShouldToggleHoveringEditorOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if command-k, toggle the hovering editor\n * if (event.key === \"k\" && event.metaKey) {\n * return true;\n * }\n * return false;\n * }\n * ```\n */\nexport interface BaseAutosuggestionsConfig {\n textareaPurpose: string;\n contextCategories: string[];\n debounceTime: number;\n apiConfig: BaseCopilotTextareaApiConfig;\n\n disableWhenEmpty: boolean;\n disabled: boolean;\n temporarilyDisableWhenMovingCursorWithoutChangingText: boolean;\n shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;\n shouldToggleHoveringEditorOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;\n}\n\n// by default, command-k toggles the hovering editor\nconst defaultShouldToggleHoveringEditorOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n) => {\n // if command-k, toggle the hovering editor\n if (event.key === \"k\" && event.metaKey) {\n return true;\n }\n return false;\n};\n\nconst defaultShouldAcceptAutosuggestionOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n) => {\n // if tab, accept the autosuggestion\n if (event.key === \"Tab\") {\n return true;\n }\n return false;\n};\n\n/**\n * Default configuration for the BaseAutosuggestions.\n *\n * @property {number} debounceTime - The amount of time to wait before triggering the autosuggestions API call.\n * @property {string[]} contextCategories - The categories to use for context when making the autosuggestions API call.\n * @property {boolean} disableWhenEmpty - Whether to disable the autosuggestions when the textarea is empty.\n * @property {boolean} disabled - Whether to disable the autosuggestions feature entirely.\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable the autosuggestions when the cursor is moved without changing the text.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the autosuggestion based on a key press event.\n */\n\nexport const defaultBaseAutosuggestionsConfig: Omit<\n BaseAutosuggestionsConfig,\n \"textareaPurpose\" | \"apiConfig\"\n> = {\n debounceTime: 250,\n contextCategories: defaultCopilotContextCategories,\n disableWhenEmpty: true,\n disabled: false,\n temporarilyDisableWhenMovingCursorWithoutChangingText: true,\n shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,\n shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress,\n};\n"],"mappings":";AACA,SAAS,uCAAuC;AAyDhD,IAAM,8CAA8C,CAClD,UACG;AAEH,MAAI,MAAM,QAAQ,OAAO,MAAM,SAAS;AACtC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,IAAM,8CAA8C,CAClD,UACG;AAEH,MAAI,MAAM,QAAQ,OAAO;AACvB,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAcO,IAAM,mCAGT;AAAA,EACF,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,uDAAuD;AAAA,EACvD,sCAAsC;AAAA,EACtC,sCAAsC;AACxC;","names":[]}
@@ -1,6 +1,5 @@
1
- import { Node, Element, Transforms } from 'slate';
2
-
3
1
  // src/lib/slatejs-edits/clear-autocompletions.ts
2
+ import { Element, Node, Transforms } from "slate";
4
3
  function clearAutocompletionsFromEditor(editor) {
5
4
  const paths = [];
6
5
  for (const [node, path] of Node.nodes(editor)) {
@@ -17,6 +16,7 @@ function clearAutocompletionsFromEditor(editor) {
17
16
  }
18
17
  }
19
18
 
20
- export { clearAutocompletionsFromEditor };
21
- //# sourceMappingURL=out.js.map
19
+ export {
20
+ clearAutocompletionsFromEditor
21
+ };
22
22
  //# sourceMappingURL=chunk-GQN2HYFJ.mjs.map
@@ -1 +1 @@
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,IAAI,uEAAuE,CAAC;AAAA,IACtF;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(\"CopilotTextarea.clearAutocompletionsFromEditor: error removing node\", e);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/slatejs-edits/clear-autocompletions.ts"],"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(\"CopilotTextarea.clearAutocompletionsFromEditor: error removing node\", e);\n }\n }\n}\n"],"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,IAAI,uEAAuE,CAAC;AAAA,IACtF;AAAA,EACF;AACF;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-H4VKQGVU.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-IU3WTXLQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,10 +1,13 @@
1
- import { arraysAreEqual } from './chunk-7SUZ6CXM.mjs';
1
+ import {
2
+ arraysAreEqual
3
+ } from "./chunk-7SUZ6CXM.mjs";
2
4
 
3
5
  // src/types/base/editor-autocomplete-state.ts
4
6
  function areEqual_autocompleteState(prev, next) {
5
7
  return prev.cursorPoint.offset === next.cursorPoint.offset && arraysAreEqual(prev.cursorPoint.path, next.cursorPoint.path) && prev.textBeforeCursor === next.textBeforeCursor && prev.textAfterCursor === next.textAfterCursor;
6
8
  }
7
9
 
8
- export { areEqual_autocompleteState };
9
- //# sourceMappingURL=out.js.map
10
+ export {
11
+ areEqual_autocompleteState
12
+ };
10
13
  //# sourceMappingURL=chunk-JJLQVT7S.mjs.map
@@ -1 +1 @@
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
+ {"version":3,"sources":["../src/types/base/editor-autocomplete-state.ts"],"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"],"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;","names":[]}
@@ -58,6 +58,9 @@ var defaultSuggestionsApiConfig = {
58
58
  forwardedParams: void 0
59
59
  };
60
60
 
61
- export { defaultSuggestionsApiConfig, defaultSuggestionsFewShotMessages, defaultSuggestionsMakeSystemPrompt };
62
- //# sourceMappingURL=out.js.map
61
+ export {
62
+ defaultSuggestionsMakeSystemPrompt,
63
+ defaultSuggestionsFewShotMessages,
64
+ defaultSuggestionsApiConfig
65
+ };
63
66
  //# sourceMappingURL=chunk-KDVMG3XF.mjs.map
@@ -1 +1 @@
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,SAAS;AAAA,EACX;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: \"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"]}
1
+ {"version":3,"sources":["../src/types/autosuggestions-config/suggestions-api-config.tsx"],"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: \"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"],"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,SAAS;AAAA,EACX;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;","names":[]}
@@ -1,10 +1,16 @@
1
- import { cn } from './chunk-7SUZ6CXM.mjs';
2
- import { __objRest, __spreadValues } from './chunk-MRXNTQOX.mjs';
3
- import * as React from 'react';
4
- import * as LabelPrimitive from '@radix-ui/react-label';
5
- import { cva } from 'class-variance-authority';
6
- import { jsx } from 'react/jsx-runtime';
1
+ import {
2
+ cn
3
+ } from "./chunk-7SUZ6CXM.mjs";
4
+ import {
5
+ __objRest,
6
+ __spreadValues
7
+ } from "./chunk-MRXNTQOX.mjs";
7
8
 
9
+ // src/components/ui/label.tsx
10
+ import * as React from "react";
11
+ import * as LabelPrimitive from "@radix-ui/react-label";
12
+ import { cva } from "class-variance-authority";
13
+ import { jsx } from "react/jsx-runtime";
8
14
  var labelVariants = cva(
9
15
  "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
10
16
  );
@@ -14,6 +20,7 @@ var Label = React.forwardRef((_a, ref) => {
14
20
  });
15
21
  Label.displayName = LabelPrimitive.Root.displayName;
16
22
 
17
- export { Label };
18
- //# sourceMappingURL=out.js.map
23
+ export {
24
+ Label
25
+ };
19
26
  //# sourceMappingURL=chunk-KFQZHRPJ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/ui/label.tsx"],"names":[],"mappings":";;;;;;;;;AAEA,YAAY,WAAW;AACvB,YAAY,oBAAoB;AAChC,SAAS,WAA8B;AAYrC;AARF,IAAM,gBAAgB;AAAA,EACpB;AACF;AAEA,IAAM,QAAc,iBAGlB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAfL,IAeG,IAAgB,kBAAhB,IAAgB,CAAd;AACH,6BAAgB,qBAAf,iBAAoB,KAAU,WAAW,GAAG,cAAc,GAAG,SAAS,KAAO,MAAO;AAAA,CACtF;AACD,MAAM,cAA6B,oBAAK","sourcesContent":["\"use client\";\n\nimport * 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"]}
1
+ {"version":3,"sources":["../src/components/ui/label.tsx"],"sourcesContent":["\"use client\";\n\nimport * 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"],"mappings":";;;;;;;;;AAEA,YAAY,WAAW;AACvB,YAAY,oBAAoB;AAChC,SAAS,WAA8B;AAYrC;AARF,IAAM,gBAAgB;AAAA,EACpB;AACF;AAEA,IAAM,QAAc,iBAGlB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAfL,IAeG,IAAgB,kBAAhB,IAAgB,CAAd;AACH,6BAAgB,qBAAf,iBAAoB,KAAU,WAAW,GAAG,cAAc,GAAG,SAAS,KAAO,MAAO;AAAA,CACtF;AACD,MAAM,cAA6B,oBAAK;","names":[]}
@@ -13,6 +13,7 @@ function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
13
13
  });
14
14
  }
15
15
 
16
- export { retry };
17
- //# sourceMappingURL=out.js.map
16
+ export {
17
+ retry
18
+ };
18
19
  //# sourceMappingURL=chunk-KNQIEOFP.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/retry.tsx"],"names":[],"mappings":";AAAO,SAAS,MACd,IACA,cAAsB,GACtB,WAAmB,KACnB,UAAkB,KACN;AACZ,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,OAAG,EACA,KAAK,OAAO,EACZ,MAAM,CAAC,UAAU;AAChB,UAAI,gBAAgB,GAAG;AACrB,eAAO,KAAK;AACZ;AAAA,MACF;AAEA,iBAAW,MAAM;AACf,cAAM,IAAI,cAAc,GAAG,WAAW,SAAS,OAAO,EACnD,KAAK,OAAO,EACZ,MAAM,MAAM;AAAA,MACjB,GAAG,QAAQ;AAAA,IACb,CAAC;AAAA,EACL,CAAC;AACH","sourcesContent":["export function retry<T>(\n fn: () => Promise<T>,\n retriesLeft: number = 2,\n interval: number = 200,\n backoff: number = 1.5,\n): Promise<T> {\n return new Promise((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n if (retriesLeft === 1) {\n reject(error);\n return;\n }\n\n setTimeout(() => {\n retry(fn, retriesLeft - 1, interval * backoff, backoff)\n .then(resolve)\n .catch(reject);\n }, interval);\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/retry.tsx"],"sourcesContent":["export function retry<T>(\n fn: () => Promise<T>,\n retriesLeft: number = 2,\n interval: number = 200,\n backoff: number = 1.5,\n): Promise<T> {\n return new Promise((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n if (retriesLeft === 1) {\n reject(error);\n return;\n }\n\n setTimeout(() => {\n retry(fn, retriesLeft - 1, interval * backoff, backoff)\n .then(resolve)\n .catch(reject);\n }, interval);\n });\n });\n}\n"],"mappings":";AAAO,SAAS,MACd,IACA,cAAsB,GACtB,WAAmB,KACnB,UAAkB,KACN;AACZ,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,OAAG,EACA,KAAK,OAAO,EACZ,MAAM,CAAC,UAAU;AAChB,UAAI,gBAAgB,GAAG;AACrB,eAAO,KAAK;AACZ;AAAA,MACF;AAEA,iBAAW,MAAM;AACf,cAAM,IAAI,cAAc,GAAG,WAAW,SAAS,OAAO,EACnD,KAAK,OAAO,EACZ,MAAM,MAAM;AAAA,MACjB,GAAG,QAAQ;AAAA,IACb,CAAC;AAAA,EACL,CAAC;AACH;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-L7VVZH4Q.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}