@dexto/tui 1.6.2

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 (739) hide show
  1. package/LICENSE +44 -0
  2. package/dist/InkCLIRefactored.cjs +319 -0
  3. package/dist/InkCLIRefactored.d.ts +55 -0
  4. package/dist/InkCLIRefactored.d.ts.map +1 -0
  5. package/dist/InkCLIRefactored.js +289 -0
  6. package/dist/assets/sounds/SOURCES.md +35 -0
  7. package/dist/assets/sounds/boot.wav +0 -0
  8. package/dist/assets/sounds/chime.wav +0 -0
  9. package/dist/assets/sounds/coin.wav +0 -0
  10. package/dist/assets/sounds/confirm.wav +0 -0
  11. package/dist/assets/sounds/levelup.wav +0 -0
  12. package/dist/assets/sounds/ping.wav +0 -0
  13. package/dist/assets/sounds/powerup.wav +0 -0
  14. package/dist/assets/sounds/startup.wav +0 -0
  15. package/dist/assets/sounds/success.wav +0 -0
  16. package/dist/assets/sounds/treasure.wav +0 -0
  17. package/dist/assets/sounds/win.wav +0 -0
  18. package/dist/components/ApprovalPrompt.cjs +353 -0
  19. package/dist/components/ApprovalPrompt.d.ts +44 -0
  20. package/dist/components/ApprovalPrompt.d.ts.map +1 -0
  21. package/dist/components/ApprovalPrompt.js +336 -0
  22. package/dist/components/BackgroundTasksPanel.cjs +117 -0
  23. package/dist/components/BackgroundTasksPanel.d.ts +18 -0
  24. package/dist/components/BackgroundTasksPanel.d.ts.map +1 -0
  25. package/dist/components/BackgroundTasksPanel.js +93 -0
  26. package/dist/components/CustomInput.cjs +77 -0
  27. package/dist/components/CustomInput.d.ts +17 -0
  28. package/dist/components/CustomInput.d.ts.map +1 -0
  29. package/dist/components/CustomInput.js +57 -0
  30. package/dist/components/CustomTextInput.cjs +76 -0
  31. package/dist/components/CustomTextInput.d.ts +16 -0
  32. package/dist/components/CustomTextInput.d.ts.map +1 -0
  33. package/dist/components/CustomTextInput.js +46 -0
  34. package/dist/components/EditableMultiLineInput.cjs +151 -0
  35. package/dist/components/EditableMultiLineInput.d.ts +19 -0
  36. package/dist/components/EditableMultiLineInput.d.ts.map +1 -0
  37. package/dist/components/EditableMultiLineInput.js +131 -0
  38. package/dist/components/ElicitationForm.cjs +622 -0
  39. package/dist/components/ElicitationForm.d.ts +24 -0
  40. package/dist/components/ElicitationForm.d.ts.map +1 -0
  41. package/dist/components/ElicitationForm.js +588 -0
  42. package/dist/components/ErrorBoundary.cjs +66 -0
  43. package/dist/components/ErrorBoundary.d.ts +20 -0
  44. package/dist/components/ErrorBoundary.d.ts.map +1 -0
  45. package/dist/components/ErrorBoundary.js +32 -0
  46. package/dist/components/Footer.cjs +165 -0
  47. package/dist/components/Footer.d.ts +23 -0
  48. package/dist/components/Footer.d.ts.map +1 -0
  49. package/dist/components/Footer.js +131 -0
  50. package/dist/components/HistorySearchBar.cjs +40 -0
  51. package/dist/components/HistorySearchBar.d.ts +17 -0
  52. package/dist/components/HistorySearchBar.d.ts.map +1 -0
  53. package/dist/components/HistorySearchBar.js +16 -0
  54. package/dist/components/MultiLineInput.cjs +56 -0
  55. package/dist/components/MultiLineInput.d.ts +12 -0
  56. package/dist/components/MultiLineInput.d.ts.map +1 -0
  57. package/dist/components/MultiLineInput.js +36 -0
  58. package/dist/components/ResourceAutocomplete.cjs +344 -0
  59. package/dist/components/ResourceAutocomplete.d.ts +26 -0
  60. package/dist/components/ResourceAutocomplete.d.ts.map +1 -0
  61. package/dist/components/ResourceAutocomplete.js +322 -0
  62. package/dist/components/SlashCommandAutocomplete.cjs +389 -0
  63. package/dist/components/SlashCommandAutocomplete.d.ts +28 -0
  64. package/dist/components/SlashCommandAutocomplete.d.ts.map +1 -0
  65. package/dist/components/SlashCommandAutocomplete.js +363 -0
  66. package/dist/components/StatusBar.cjs +142 -0
  67. package/dist/components/StatusBar.d.ts +41 -0
  68. package/dist/components/StatusBar.d.ts.map +1 -0
  69. package/dist/components/StatusBar.js +118 -0
  70. package/dist/components/TextBufferInput.cjs +531 -0
  71. package/dist/components/TextBufferInput.d.ts +54 -0
  72. package/dist/components/TextBufferInput.d.ts.map +1 -0
  73. package/dist/components/TextBufferInput.js +507 -0
  74. package/dist/components/TodoPanel.cjs +129 -0
  75. package/dist/components/TodoPanel.d.ts +26 -0
  76. package/dist/components/TodoPanel.d.ts.map +1 -0
  77. package/dist/components/TodoPanel.js +105 -0
  78. package/dist/components/base/BaseAutocomplete.cjs +153 -0
  79. package/dist/components/base/BaseAutocomplete.d.ts +29 -0
  80. package/dist/components/base/BaseAutocomplete.d.ts.map +1 -0
  81. package/dist/components/base/BaseAutocomplete.js +129 -0
  82. package/dist/components/base/BaseSelector.cjs +167 -0
  83. package/dist/components/base/BaseSelector.d.ts +37 -0
  84. package/dist/components/base/BaseSelector.d.ts.map +1 -0
  85. package/dist/components/base/BaseSelector.js +151 -0
  86. package/dist/components/base/index.cjs +31 -0
  87. package/dist/components/base/index.d.ts +6 -0
  88. package/dist/components/base/index.d.ts.map +1 -0
  89. package/dist/components/base/index.js +6 -0
  90. package/dist/components/chat/ChatView.cjs +51 -0
  91. package/dist/components/chat/ChatView.d.ts +19 -0
  92. package/dist/components/chat/ChatView.d.ts.map +1 -0
  93. package/dist/components/chat/ChatView.js +27 -0
  94. package/dist/components/chat/Footer.cjs +32 -0
  95. package/dist/components/chat/Footer.d.ts +9 -0
  96. package/dist/components/chat/Footer.d.ts.map +1 -0
  97. package/dist/components/chat/Footer.js +8 -0
  98. package/dist/components/chat/Header.cjs +86 -0
  99. package/dist/components/chat/Header.d.ts +18 -0
  100. package/dist/components/chat/Header.d.ts.map +1 -0
  101. package/dist/components/chat/Header.js +62 -0
  102. package/dist/components/chat/MessageItem.cjs +269 -0
  103. package/dist/components/chat/MessageItem.d.ts +23 -0
  104. package/dist/components/chat/MessageItem.d.ts.map +1 -0
  105. package/dist/components/chat/MessageItem.js +247 -0
  106. package/dist/components/chat/MessageList.cjs +46 -0
  107. package/dist/components/chat/MessageList.d.ts +16 -0
  108. package/dist/components/chat/MessageList.d.ts.map +1 -0
  109. package/dist/components/chat/MessageList.js +22 -0
  110. package/dist/components/chat/QueuedMessagesDisplay.cjs +59 -0
  111. package/dist/components/chat/QueuedMessagesDisplay.d.ts +16 -0
  112. package/dist/components/chat/QueuedMessagesDisplay.d.ts.map +1 -0
  113. package/dist/components/chat/QueuedMessagesDisplay.js +35 -0
  114. package/dist/components/chat/ToolIcon.cjs +60 -0
  115. package/dist/components/chat/ToolIcon.d.ts +18 -0
  116. package/dist/components/chat/ToolIcon.d.ts.map +1 -0
  117. package/dist/components/chat/ToolIcon.js +36 -0
  118. package/dist/components/chat/index.cjs +43 -0
  119. package/dist/components/chat/index.d.ts +10 -0
  120. package/dist/components/chat/index.d.ts.map +1 -0
  121. package/dist/components/chat/index.js +14 -0
  122. package/dist/components/chat/styled-boxes/ConfigBox.cjs +56 -0
  123. package/dist/components/chat/styled-boxes/ConfigBox.d.ts +10 -0
  124. package/dist/components/chat/styled-boxes/ConfigBox.d.ts.map +1 -0
  125. package/dist/components/chat/styled-boxes/ConfigBox.js +32 -0
  126. package/dist/components/chat/styled-boxes/HelpBox.cjs +53 -0
  127. package/dist/components/chat/styled-boxes/HelpBox.d.ts +10 -0
  128. package/dist/components/chat/styled-boxes/HelpBox.d.ts.map +1 -0
  129. package/dist/components/chat/styled-boxes/HelpBox.js +29 -0
  130. package/dist/components/chat/styled-boxes/LogConfigBox.cjs +54 -0
  131. package/dist/components/chat/styled-boxes/LogConfigBox.d.ts +10 -0
  132. package/dist/components/chat/styled-boxes/LogConfigBox.d.ts.map +1 -0
  133. package/dist/components/chat/styled-boxes/LogConfigBox.js +30 -0
  134. package/dist/components/chat/styled-boxes/SessionHistoryBox.cjs +81 -0
  135. package/dist/components/chat/styled-boxes/SessionHistoryBox.d.ts +10 -0
  136. package/dist/components/chat/styled-boxes/SessionHistoryBox.d.ts.map +1 -0
  137. package/dist/components/chat/styled-boxes/SessionHistoryBox.js +57 -0
  138. package/dist/components/chat/styled-boxes/SessionListBox.cjs +58 -0
  139. package/dist/components/chat/styled-boxes/SessionListBox.d.ts +10 -0
  140. package/dist/components/chat/styled-boxes/SessionListBox.d.ts.map +1 -0
  141. package/dist/components/chat/styled-boxes/SessionListBox.js +34 -0
  142. package/dist/components/chat/styled-boxes/ShortcutsBox.cjs +39 -0
  143. package/dist/components/chat/styled-boxes/ShortcutsBox.d.ts +10 -0
  144. package/dist/components/chat/styled-boxes/ShortcutsBox.d.ts.map +1 -0
  145. package/dist/components/chat/styled-boxes/ShortcutsBox.js +15 -0
  146. package/dist/components/chat/styled-boxes/StatsBox.cjs +123 -0
  147. package/dist/components/chat/styled-boxes/StatsBox.d.ts +10 -0
  148. package/dist/components/chat/styled-boxes/StatsBox.d.ts.map +1 -0
  149. package/dist/components/chat/styled-boxes/StatsBox.js +99 -0
  150. package/dist/components/chat/styled-boxes/StyledBox.cjs +88 -0
  151. package/dist/components/chat/styled-boxes/StyledBox.d.ts +45 -0
  152. package/dist/components/chat/styled-boxes/StyledBox.d.ts.map +1 -0
  153. package/dist/components/chat/styled-boxes/StyledBox.js +61 -0
  154. package/dist/components/chat/styled-boxes/SyspromptBox.cjs +33 -0
  155. package/dist/components/chat/styled-boxes/SyspromptBox.d.ts +10 -0
  156. package/dist/components/chat/styled-boxes/SyspromptBox.d.ts.map +1 -0
  157. package/dist/components/chat/styled-boxes/SyspromptBox.js +9 -0
  158. package/dist/components/chat/styled-boxes/index.cjs +58 -0
  159. package/dist/components/chat/styled-boxes/index.d.ts +13 -0
  160. package/dist/components/chat/styled-boxes/index.d.ts.map +1 -0
  161. package/dist/components/chat/styled-boxes/index.js +23 -0
  162. package/dist/components/input/InputArea.cjs +74 -0
  163. package/dist/components/input/InputArea.d.ts +48 -0
  164. package/dist/components/input/InputArea.d.ts.map +1 -0
  165. package/dist/components/input/InputArea.js +50 -0
  166. package/dist/components/input/index.cjs +28 -0
  167. package/dist/components/input/index.d.ts +5 -0
  168. package/dist/components/input/index.d.ts.map +1 -0
  169. package/dist/components/input/index.js +4 -0
  170. package/dist/components/modes/AlternateBufferCLI.cjs +360 -0
  171. package/dist/components/modes/AlternateBufferCLI.d.ts +28 -0
  172. package/dist/components/modes/AlternateBufferCLI.d.ts.map +1 -0
  173. package/dist/components/modes/AlternateBufferCLI.js +339 -0
  174. package/dist/components/modes/StaticCLI.cjs +303 -0
  175. package/dist/components/modes/StaticCLI.d.ts +30 -0
  176. package/dist/components/modes/StaticCLI.d.ts.map +1 -0
  177. package/dist/components/modes/StaticCLI.js +279 -0
  178. package/dist/components/modes/index.cjs +31 -0
  179. package/dist/components/modes/index.d.ts +10 -0
  180. package/dist/components/modes/index.d.ts.map +1 -0
  181. package/dist/components/modes/index.js +6 -0
  182. package/dist/components/overlays/ApiKeyInput.cjs +131 -0
  183. package/dist/components/overlays/ApiKeyInput.d.ts +26 -0
  184. package/dist/components/overlays/ApiKeyInput.d.ts.map +1 -0
  185. package/dist/components/overlays/ApiKeyInput.js +115 -0
  186. package/dist/components/overlays/CommandOutputOverlay.cjs +103 -0
  187. package/dist/components/overlays/CommandOutputOverlay.d.ts +13 -0
  188. package/dist/components/overlays/CommandOutputOverlay.d.ts.map +1 -0
  189. package/dist/components/overlays/CommandOutputOverlay.js +69 -0
  190. package/dist/components/overlays/ContextStatsOverlay.cjs +354 -0
  191. package/dist/components/overlays/ContextStatsOverlay.d.ts +26 -0
  192. package/dist/components/overlays/ContextStatsOverlay.d.ts.map +1 -0
  193. package/dist/components/overlays/ContextStatsOverlay.js +334 -0
  194. package/dist/components/overlays/CustomModelWizard.cjs +362 -0
  195. package/dist/components/overlays/CustomModelWizard.d.ts +29 -0
  196. package/dist/components/overlays/CustomModelWizard.d.ts.map +1 -0
  197. package/dist/components/overlays/CustomModelWizard.js +356 -0
  198. package/dist/components/overlays/ExportWizard.cjs +382 -0
  199. package/dist/components/overlays/ExportWizard.d.ts +22 -0
  200. package/dist/components/overlays/ExportWizard.d.ts.map +1 -0
  201. package/dist/components/overlays/ExportWizard.js +352 -0
  202. package/dist/components/overlays/LogLevelSelector.cjs +120 -0
  203. package/dist/components/overlays/LogLevelSelector.d.ts +23 -0
  204. package/dist/components/overlays/LogLevelSelector.d.ts.map +1 -0
  205. package/dist/components/overlays/LogLevelSelector.js +100 -0
  206. package/dist/components/overlays/LoginOverlay.cjs +211 -0
  207. package/dist/components/overlays/LoginOverlay.d.ts +22 -0
  208. package/dist/components/overlays/LoginOverlay.d.ts.map +1 -0
  209. package/dist/components/overlays/LoginOverlay.js +194 -0
  210. package/dist/components/overlays/LogoutOverlay.cjs +138 -0
  211. package/dist/components/overlays/LogoutOverlay.d.ts +20 -0
  212. package/dist/components/overlays/LogoutOverlay.d.ts.map +1 -0
  213. package/dist/components/overlays/LogoutOverlay.js +130 -0
  214. package/dist/components/overlays/MarketplaceAddPrompt.cjs +119 -0
  215. package/dist/components/overlays/MarketplaceAddPrompt.d.ts +20 -0
  216. package/dist/components/overlays/MarketplaceAddPrompt.d.ts.map +1 -0
  217. package/dist/components/overlays/MarketplaceAddPrompt.js +99 -0
  218. package/dist/components/overlays/MarketplaceBrowser.cjs +364 -0
  219. package/dist/components/overlays/MarketplaceBrowser.d.ts +31 -0
  220. package/dist/components/overlays/MarketplaceBrowser.d.ts.map +1 -0
  221. package/dist/components/overlays/MarketplaceBrowser.js +358 -0
  222. package/dist/components/overlays/McpAddChoice.cjs +100 -0
  223. package/dist/components/overlays/McpAddChoice.d.ts +22 -0
  224. package/dist/components/overlays/McpAddChoice.d.ts.map +1 -0
  225. package/dist/components/overlays/McpAddChoice.js +80 -0
  226. package/dist/components/overlays/McpAddSelector.cjs +113 -0
  227. package/dist/components/overlays/McpAddSelector.d.ts +26 -0
  228. package/dist/components/overlays/McpAddSelector.d.ts.map +1 -0
  229. package/dist/components/overlays/McpAddSelector.js +93 -0
  230. package/dist/components/overlays/McpCustomTypeSelector.cjs +99 -0
  231. package/dist/components/overlays/McpCustomTypeSelector.d.ts +21 -0
  232. package/dist/components/overlays/McpCustomTypeSelector.d.ts.map +1 -0
  233. package/dist/components/overlays/McpCustomTypeSelector.js +79 -0
  234. package/dist/components/overlays/McpCustomWizard.cjs +258 -0
  235. package/dist/components/overlays/McpCustomWizard.d.ts +29 -0
  236. package/dist/components/overlays/McpCustomWizard.d.ts.map +1 -0
  237. package/dist/components/overlays/McpCustomWizard.js +238 -0
  238. package/dist/components/overlays/McpRemoveSelector.cjs +127 -0
  239. package/dist/components/overlays/McpRemoveSelector.d.ts +22 -0
  240. package/dist/components/overlays/McpRemoveSelector.d.ts.map +1 -0
  241. package/dist/components/overlays/McpRemoveSelector.js +107 -0
  242. package/dist/components/overlays/McpSelector.cjs +94 -0
  243. package/dist/components/overlays/McpSelector.d.ts +21 -0
  244. package/dist/components/overlays/McpSelector.d.ts.map +1 -0
  245. package/dist/components/overlays/McpSelector.js +74 -0
  246. package/dist/components/overlays/McpServerActions.cjs +124 -0
  247. package/dist/components/overlays/McpServerActions.d.ts +28 -0
  248. package/dist/components/overlays/McpServerActions.d.ts.map +1 -0
  249. package/dist/components/overlays/McpServerActions.js +111 -0
  250. package/dist/components/overlays/McpServerList.cjs +152 -0
  251. package/dist/components/overlays/McpServerList.d.ts +29 -0
  252. package/dist/components/overlays/McpServerList.d.ts.map +1 -0
  253. package/dist/components/overlays/McpServerList.js +139 -0
  254. package/dist/components/overlays/ModelSelectorRefactored.cjs +869 -0
  255. package/dist/components/overlays/ModelSelectorRefactored.d.ts +27 -0
  256. package/dist/components/overlays/ModelSelectorRefactored.d.ts.map +1 -0
  257. package/dist/components/overlays/ModelSelectorRefactored.js +870 -0
  258. package/dist/components/overlays/PluginActions.cjs +108 -0
  259. package/dist/components/overlays/PluginActions.d.ts +27 -0
  260. package/dist/components/overlays/PluginActions.d.ts.map +1 -0
  261. package/dist/components/overlays/PluginActions.js +95 -0
  262. package/dist/components/overlays/PluginList.cjs +115 -0
  263. package/dist/components/overlays/PluginList.d.ts +21 -0
  264. package/dist/components/overlays/PluginList.d.ts.map +1 -0
  265. package/dist/components/overlays/PluginList.js +102 -0
  266. package/dist/components/overlays/PluginManager.cjs +106 -0
  267. package/dist/components/overlays/PluginManager.d.ts +21 -0
  268. package/dist/components/overlays/PluginManager.d.ts.map +1 -0
  269. package/dist/components/overlays/PluginManager.js +86 -0
  270. package/dist/components/overlays/PromptAddChoice.cjs +92 -0
  271. package/dist/components/overlays/PromptAddChoice.d.ts +22 -0
  272. package/dist/components/overlays/PromptAddChoice.d.ts.map +1 -0
  273. package/dist/components/overlays/PromptAddChoice.js +72 -0
  274. package/dist/components/overlays/PromptAddWizard.cjs +215 -0
  275. package/dist/components/overlays/PromptAddWizard.d.ts +29 -0
  276. package/dist/components/overlays/PromptAddWizard.d.ts.map +1 -0
  277. package/dist/components/overlays/PromptAddWizard.js +195 -0
  278. package/dist/components/overlays/PromptDeleteSelector.cjs +148 -0
  279. package/dist/components/overlays/PromptDeleteSelector.d.ts +27 -0
  280. package/dist/components/overlays/PromptDeleteSelector.d.ts.map +1 -0
  281. package/dist/components/overlays/PromptDeleteSelector.js +135 -0
  282. package/dist/components/overlays/PromptList.cjs +169 -0
  283. package/dist/components/overlays/PromptList.d.ts +33 -0
  284. package/dist/components/overlays/PromptList.d.ts.map +1 -0
  285. package/dist/components/overlays/PromptList.js +157 -0
  286. package/dist/components/overlays/ReasoningOverlay.cjs +305 -0
  287. package/dist/components/overlays/ReasoningOverlay.d.ts +28 -0
  288. package/dist/components/overlays/ReasoningOverlay.d.ts.map +1 -0
  289. package/dist/components/overlays/ReasoningOverlay.js +278 -0
  290. package/dist/components/overlays/SearchOverlay.cjs +249 -0
  291. package/dist/components/overlays/SearchOverlay.d.ts +23 -0
  292. package/dist/components/overlays/SearchOverlay.d.ts.map +1 -0
  293. package/dist/components/overlays/SearchOverlay.js +236 -0
  294. package/dist/components/overlays/SessionRenameOverlay.cjs +101 -0
  295. package/dist/components/overlays/SessionRenameOverlay.d.ts +21 -0
  296. package/dist/components/overlays/SessionRenameOverlay.d.ts.map +1 -0
  297. package/dist/components/overlays/SessionRenameOverlay.js +81 -0
  298. package/dist/components/overlays/SessionSelectorRefactored.cjs +153 -0
  299. package/dist/components/overlays/SessionSelectorRefactored.d.ts +26 -0
  300. package/dist/components/overlays/SessionSelectorRefactored.d.ts.map +1 -0
  301. package/dist/components/overlays/SessionSelectorRefactored.js +133 -0
  302. package/dist/components/overlays/SessionSubcommandSelector.cjs +84 -0
  303. package/dist/components/overlays/SessionSubcommandSelector.d.ts +21 -0
  304. package/dist/components/overlays/SessionSubcommandSelector.d.ts.map +1 -0
  305. package/dist/components/overlays/SessionSubcommandSelector.js +64 -0
  306. package/dist/components/overlays/SoundsSelector.cjs +632 -0
  307. package/dist/components/overlays/SoundsSelector.d.ts +21 -0
  308. package/dist/components/overlays/SoundsSelector.d.ts.map +1 -0
  309. package/dist/components/overlays/SoundsSelector.js +619 -0
  310. package/dist/components/overlays/StreamSelector.cjs +104 -0
  311. package/dist/components/overlays/StreamSelector.d.ts +20 -0
  312. package/dist/components/overlays/StreamSelector.d.ts.map +1 -0
  313. package/dist/components/overlays/StreamSelector.js +84 -0
  314. package/dist/components/overlays/ToolBrowser.cjs +854 -0
  315. package/dist/components/overlays/ToolBrowser.d.ts +26 -0
  316. package/dist/components/overlays/ToolBrowser.d.ts.map +1 -0
  317. package/dist/components/overlays/ToolBrowser.js +831 -0
  318. package/dist/components/overlays/custom-model-wizard/LocalModelWizard.cjs +784 -0
  319. package/dist/components/overlays/custom-model-wizard/LocalModelWizard.d.ts +25 -0
  320. package/dist/components/overlays/custom-model-wizard/LocalModelWizard.d.ts.map +1 -0
  321. package/dist/components/overlays/custom-model-wizard/LocalModelWizard.js +768 -0
  322. package/dist/components/overlays/custom-model-wizard/index.cjs +26 -0
  323. package/dist/components/overlays/custom-model-wizard/index.d.ts +15 -0
  324. package/dist/components/overlays/custom-model-wizard/index.d.ts.map +1 -0
  325. package/dist/components/overlays/custom-model-wizard/index.js +3 -0
  326. package/dist/components/overlays/custom-model-wizard/provider-config.cjs +549 -0
  327. package/dist/components/overlays/custom-model-wizard/provider-config.d.ts +42 -0
  328. package/dist/components/overlays/custom-model-wizard/provider-config.d.ts.map +1 -0
  329. package/dist/components/overlays/custom-model-wizard/provider-config.js +516 -0
  330. package/dist/components/overlays/custom-model-wizard/provider-config.test.cjs +31 -0
  331. package/dist/components/overlays/custom-model-wizard/provider-config.test.d.ts +2 -0
  332. package/dist/components/overlays/custom-model-wizard/provider-config.test.d.ts.map +1 -0
  333. package/dist/components/overlays/custom-model-wizard/provider-config.test.js +30 -0
  334. package/dist/components/overlays/custom-model-wizard/shared/ApiKeyStep.cjs +59 -0
  335. package/dist/components/overlays/custom-model-wizard/shared/ApiKeyStep.d.ts +25 -0
  336. package/dist/components/overlays/custom-model-wizard/shared/ApiKeyStep.d.ts.map +1 -0
  337. package/dist/components/overlays/custom-model-wizard/shared/ApiKeyStep.js +33 -0
  338. package/dist/components/overlays/custom-model-wizard/shared/ProviderSelector.cjs +64 -0
  339. package/dist/components/overlays/custom-model-wizard/shared/ProviderSelector.d.ts +17 -0
  340. package/dist/components/overlays/custom-model-wizard/shared/ProviderSelector.d.ts.map +1 -0
  341. package/dist/components/overlays/custom-model-wizard/shared/ProviderSelector.js +40 -0
  342. package/dist/components/overlays/custom-model-wizard/shared/SetupInfoBanner.cjs +48 -0
  343. package/dist/components/overlays/custom-model-wizard/shared/SetupInfoBanner.d.ts +20 -0
  344. package/dist/components/overlays/custom-model-wizard/shared/SetupInfoBanner.d.ts.map +1 -0
  345. package/dist/components/overlays/custom-model-wizard/shared/SetupInfoBanner.js +24 -0
  346. package/dist/components/overlays/custom-model-wizard/shared/WizardStepInput.cjs +58 -0
  347. package/dist/components/overlays/custom-model-wizard/shared/WizardStepInput.d.ts +30 -0
  348. package/dist/components/overlays/custom-model-wizard/shared/WizardStepInput.d.ts.map +1 -0
  349. package/dist/components/overlays/custom-model-wizard/shared/WizardStepInput.js +34 -0
  350. package/dist/components/overlays/custom-model-wizard/shared/index.cjs +41 -0
  351. package/dist/components/overlays/custom-model-wizard/shared/index.d.ts +8 -0
  352. package/dist/components/overlays/custom-model-wizard/shared/index.d.ts.map +1 -0
  353. package/dist/components/overlays/custom-model-wizard/shared/index.js +12 -0
  354. package/dist/components/overlays/custom-model-wizard/types.cjs +53 -0
  355. package/dist/components/overlays/custom-model-wizard/types.d.ts +85 -0
  356. package/dist/components/overlays/custom-model-wizard/types.d.ts.map +1 -0
  357. package/dist/components/overlays/custom-model-wizard/types.js +29 -0
  358. package/dist/components/renderers/DiffRenderer.cjs +145 -0
  359. package/dist/components/renderers/DiffRenderer.d.ts +21 -0
  360. package/dist/components/renderers/DiffRenderer.d.ts.map +1 -0
  361. package/dist/components/renderers/DiffRenderer.js +118 -0
  362. package/dist/components/renderers/FilePreviewRenderer.cjs +146 -0
  363. package/dist/components/renderers/FilePreviewRenderer.d.ts +30 -0
  364. package/dist/components/renderers/FilePreviewRenderer.d.ts.map +1 -0
  365. package/dist/components/renderers/FilePreviewRenderer.js +119 -0
  366. package/dist/components/renderers/FileRenderer.cjs +95 -0
  367. package/dist/components/renderers/FileRenderer.d.ts +21 -0
  368. package/dist/components/renderers/FileRenderer.d.ts.map +1 -0
  369. package/dist/components/renderers/FileRenderer.js +71 -0
  370. package/dist/components/renderers/GenericRenderer.cjs +63 -0
  371. package/dist/components/renderers/GenericRenderer.d.ts +21 -0
  372. package/dist/components/renderers/GenericRenderer.d.ts.map +1 -0
  373. package/dist/components/renderers/GenericRenderer.js +39 -0
  374. package/dist/components/renderers/SearchRenderer.cjs +77 -0
  375. package/dist/components/renderers/SearchRenderer.d.ts +20 -0
  376. package/dist/components/renderers/SearchRenderer.d.ts.map +1 -0
  377. package/dist/components/renderers/SearchRenderer.js +43 -0
  378. package/dist/components/renderers/ShellRenderer.cjs +61 -0
  379. package/dist/components/renderers/ShellRenderer.d.ts +21 -0
  380. package/dist/components/renderers/ShellRenderer.d.ts.map +1 -0
  381. package/dist/components/renderers/ShellRenderer.js +37 -0
  382. package/dist/components/renderers/diff-shared.cjs +172 -0
  383. package/dist/components/renderers/diff-shared.d.ts +61 -0
  384. package/dist/components/renderers/diff-shared.d.ts.map +1 -0
  385. package/dist/components/renderers/diff-shared.js +142 -0
  386. package/dist/components/renderers/index.cjs +75 -0
  387. package/dist/components/renderers/index.d.ts +28 -0
  388. package/dist/components/renderers/index.d.ts.map +1 -0
  389. package/dist/components/renderers/index.js +44 -0
  390. package/dist/components/shared/FocusOverlayFrame.cjs +39 -0
  391. package/dist/components/shared/FocusOverlayFrame.d.ts +7 -0
  392. package/dist/components/shared/FocusOverlayFrame.d.ts.map +1 -0
  393. package/dist/components/shared/FocusOverlayFrame.js +15 -0
  394. package/dist/components/shared/HintBar.cjs +33 -0
  395. package/dist/components/shared/HintBar.d.ts +6 -0
  396. package/dist/components/shared/HintBar.d.ts.map +1 -0
  397. package/dist/components/shared/HintBar.js +9 -0
  398. package/dist/components/shared/MarkdownText.cjs +409 -0
  399. package/dist/components/shared/MarkdownText.d.ts +38 -0
  400. package/dist/components/shared/MarkdownText.d.ts.map +1 -0
  401. package/dist/components/shared/MarkdownText.js +373 -0
  402. package/dist/components/shared/VirtualizedList.cjs +365 -0
  403. package/dist/components/shared/VirtualizedList.d.ts +44 -0
  404. package/dist/components/shared/VirtualizedList.d.ts.map +1 -0
  405. package/dist/components/shared/VirtualizedList.js +349 -0
  406. package/dist/components/shared/text-buffer.cjs +1220 -0
  407. package/dist/components/shared/text-buffer.d.ts +185 -0
  408. package/dist/components/shared/text-buffer.d.ts.map +1 -0
  409. package/dist/components/shared/text-buffer.js +1194 -0
  410. package/dist/constants/processingPhrases.cjs +114 -0
  411. package/dist/constants/processingPhrases.d.ts +10 -0
  412. package/dist/constants/processingPhrases.d.ts.map +1 -0
  413. package/dist/constants/processingPhrases.js +89 -0
  414. package/dist/constants/spinnerFrames.cjs +28 -0
  415. package/dist/constants/spinnerFrames.d.ts +2 -0
  416. package/dist/constants/spinnerFrames.d.ts.map +1 -0
  417. package/dist/constants/spinnerFrames.js +4 -0
  418. package/dist/constants/tips.cjs +76 -0
  419. package/dist/constants/tips.d.ts +15 -0
  420. package/dist/constants/tips.d.ts.map +1 -0
  421. package/dist/constants/tips.js +51 -0
  422. package/dist/containers/InputContainer.cjs +706 -0
  423. package/dist/containers/InputContainer.d.ts +62 -0
  424. package/dist/containers/InputContainer.d.ts.map +1 -0
  425. package/dist/containers/InputContainer.js +672 -0
  426. package/dist/containers/OverlayContainer.cjs +2372 -0
  427. package/dist/containers/OverlayContainer.d.ts +42 -0
  428. package/dist/containers/OverlayContainer.d.ts.map +1 -0
  429. package/dist/containers/OverlayContainer.js +2356 -0
  430. package/dist/containers/index.cjs +31 -0
  431. package/dist/containers/index.d.ts +6 -0
  432. package/dist/containers/index.d.ts.map +1 -0
  433. package/dist/containers/index.js +6 -0
  434. package/dist/contexts/KeypressContext.cjs +436 -0
  435. package/dist/contexts/KeypressContext.d.ts +36 -0
  436. package/dist/contexts/KeypressContext.d.ts.map +1 -0
  437. package/dist/contexts/KeypressContext.js +408 -0
  438. package/dist/contexts/MouseContext.cjs +122 -0
  439. package/dist/contexts/MouseContext.d.ts +27 -0
  440. package/dist/contexts/MouseContext.d.ts.map +1 -0
  441. package/dist/contexts/MouseContext.js +101 -0
  442. package/dist/contexts/ScrollProvider.cjs +180 -0
  443. package/dist/contexts/ScrollProvider.d.ts +33 -0
  444. package/dist/contexts/ScrollProvider.d.ts.map +1 -0
  445. package/dist/contexts/ScrollProvider.js +163 -0
  446. package/dist/contexts/SoundContext.cjs +38 -0
  447. package/dist/contexts/SoundContext.d.ts +23 -0
  448. package/dist/contexts/SoundContext.d.ts.map +1 -0
  449. package/dist/contexts/SoundContext.js +13 -0
  450. package/dist/contexts/index.cjs +47 -0
  451. package/dist/contexts/index.d.ts +8 -0
  452. package/dist/contexts/index.d.ts.map +1 -0
  453. package/dist/contexts/index.js +25 -0
  454. package/dist/hooks/index.cjs +54 -0
  455. package/dist/hooks/index.d.ts +12 -0
  456. package/dist/hooks/index.d.ts.map +1 -0
  457. package/dist/hooks/index.js +28 -0
  458. package/dist/hooks/useAgentEvents.cjs +382 -0
  459. package/dist/hooks/useAgentEvents.d.ts +49 -0
  460. package/dist/hooks/useAgentEvents.d.ts.map +1 -0
  461. package/dist/hooks/useAgentEvents.js +360 -0
  462. package/dist/hooks/useAnimationTick.cjs +71 -0
  463. package/dist/hooks/useAnimationTick.d.ts +11 -0
  464. package/dist/hooks/useAnimationTick.d.ts.map +1 -0
  465. package/dist/hooks/useAnimationTick.js +47 -0
  466. package/dist/hooks/useBatchedScroll.cjs +44 -0
  467. package/dist/hooks/useBatchedScroll.d.ts +14 -0
  468. package/dist/hooks/useBatchedScroll.d.ts.map +1 -0
  469. package/dist/hooks/useBatchedScroll.js +20 -0
  470. package/dist/hooks/useCLIState.cjs +222 -0
  471. package/dist/hooks/useCLIState.d.ts +53 -0
  472. package/dist/hooks/useCLIState.d.ts.map +1 -0
  473. package/dist/hooks/useCLIState.js +201 -0
  474. package/dist/hooks/useElapsedTime.cjs +79 -0
  475. package/dist/hooks/useElapsedTime.d.ts +24 -0
  476. package/dist/hooks/useElapsedTime.d.ts.map +1 -0
  477. package/dist/hooks/useElapsedTime.js +55 -0
  478. package/dist/hooks/useGitBranch.cjs +47 -0
  479. package/dist/hooks/useGitBranch.d.ts +13 -0
  480. package/dist/hooks/useGitBranch.d.ts.map +1 -0
  481. package/dist/hooks/useGitBranch.js +23 -0
  482. package/dist/hooks/useHistorySearch.cjs +219 -0
  483. package/dist/hooks/useHistorySearch.d.ts +61 -0
  484. package/dist/hooks/useHistorySearch.d.ts.map +1 -0
  485. package/dist/hooks/useHistorySearch.js +195 -0
  486. package/dist/hooks/useInputHistory.cjs +47 -0
  487. package/dist/hooks/useInputHistory.d.ts +18 -0
  488. package/dist/hooks/useInputHistory.d.ts.map +1 -0
  489. package/dist/hooks/useInputHistory.js +23 -0
  490. package/dist/hooks/useInputOrchestrator.cjs +663 -0
  491. package/dist/hooks/useInputOrchestrator.d.ts +136 -0
  492. package/dist/hooks/useInputOrchestrator.d.ts.map +1 -0
  493. package/dist/hooks/useInputOrchestrator.js +635 -0
  494. package/dist/hooks/useKeyboardShortcuts.cjs +87 -0
  495. package/dist/hooks/useKeyboardShortcuts.d.ts +21 -0
  496. package/dist/hooks/useKeyboardShortcuts.d.ts.map +1 -0
  497. package/dist/hooks/useKeyboardShortcuts.js +63 -0
  498. package/dist/hooks/useKeypress.cjs +41 -0
  499. package/dist/hooks/useKeypress.d.ts +18 -0
  500. package/dist/hooks/useKeypress.d.ts.map +1 -0
  501. package/dist/hooks/useKeypress.js +17 -0
  502. package/dist/hooks/usePhraseCycler.cjs +74 -0
  503. package/dist/hooks/usePhraseCycler.d.ts +30 -0
  504. package/dist/hooks/usePhraseCycler.d.ts.map +1 -0
  505. package/dist/hooks/usePhraseCycler.js +50 -0
  506. package/dist/hooks/useStreaming.cjs +43 -0
  507. package/dist/hooks/useStreaming.d.ts +19 -0
  508. package/dist/hooks/useStreaming.d.ts.map +1 -0
  509. package/dist/hooks/useStreaming.js +24 -0
  510. package/dist/hooks/useTerminalSize.cjs +48 -0
  511. package/dist/hooks/useTerminalSize.d.ts +14 -0
  512. package/dist/hooks/useTerminalSize.d.ts.map +1 -0
  513. package/dist/hooks/useTerminalSize.js +24 -0
  514. package/dist/hooks/useTokenCounter.cjs +105 -0
  515. package/dist/hooks/useTokenCounter.d.ts +46 -0
  516. package/dist/hooks/useTokenCounter.d.ts.map +1 -0
  517. package/dist/hooks/useTokenCounter.js +81 -0
  518. package/dist/host/index.cjs +144 -0
  519. package/dist/host/index.d.ts +108 -0
  520. package/dist/host/index.d.ts.map +1 -0
  521. package/dist/host/index.js +104 -0
  522. package/dist/index.cjs +33 -0
  523. package/dist/index.d.cts +195 -0
  524. package/dist/index.d.ts +3 -0
  525. package/dist/index.d.ts.map +1 -0
  526. package/dist/index.js +7 -0
  527. package/dist/interactive-commands/auth/index.cjs +44 -0
  528. package/dist/interactive-commands/auth/index.d.ts +13 -0
  529. package/dist/interactive-commands/auth/index.d.ts.map +1 -0
  530. package/dist/interactive-commands/auth/index.js +19 -0
  531. package/dist/interactive-commands/command-parser.cjs +184 -0
  532. package/dist/interactive-commands/command-parser.d.ts +56 -0
  533. package/dist/interactive-commands/command-parser.d.ts.map +1 -0
  534. package/dist/interactive-commands/command-parser.js +146 -0
  535. package/dist/interactive-commands/commands.cjs +135 -0
  536. package/dist/interactive-commands/commands.d.ts +52 -0
  537. package/dist/interactive-commands/commands.d.ts.map +1 -0
  538. package/dist/interactive-commands/commands.js +99 -0
  539. package/dist/interactive-commands/documentation-commands.cjs +61 -0
  540. package/dist/interactive-commands/documentation-commands.d.ts +15 -0
  541. package/dist/interactive-commands/documentation-commands.d.ts.map +1 -0
  542. package/dist/interactive-commands/documentation-commands.js +27 -0
  543. package/dist/interactive-commands/exit-handler.cjs +40 -0
  544. package/dist/interactive-commands/exit-handler.d.ts +12 -0
  545. package/dist/interactive-commands/exit-handler.d.ts.map +1 -0
  546. package/dist/interactive-commands/exit-handler.js +15 -0
  547. package/dist/interactive-commands/exit-stats.cjs +41 -0
  548. package/dist/interactive-commands/exit-stats.d.ts +24 -0
  549. package/dist/interactive-commands/exit-stats.d.ts.map +1 -0
  550. package/dist/interactive-commands/exit-stats.js +15 -0
  551. package/dist/interactive-commands/export/index.cjs +36 -0
  552. package/dist/interactive-commands/export/index.d.ts +13 -0
  553. package/dist/interactive-commands/export/index.d.ts.map +1 -0
  554. package/dist/interactive-commands/export/index.js +12 -0
  555. package/dist/interactive-commands/general-commands.cjs +478 -0
  556. package/dist/interactive-commands/general-commands.d.ts +22 -0
  557. package/dist/interactive-commands/general-commands.d.ts.map +1 -0
  558. package/dist/interactive-commands/general-commands.js +443 -0
  559. package/dist/interactive-commands/mcp/index.cjs +35 -0
  560. package/dist/interactive-commands/mcp/index.d.ts +13 -0
  561. package/dist/interactive-commands/mcp/index.d.ts.map +1 -0
  562. package/dist/interactive-commands/mcp/index.js +11 -0
  563. package/dist/interactive-commands/model/index.cjs +36 -0
  564. package/dist/interactive-commands/model/index.d.ts +13 -0
  565. package/dist/interactive-commands/model/index.d.ts.map +1 -0
  566. package/dist/interactive-commands/model/index.js +12 -0
  567. package/dist/interactive-commands/plugin/index.cjs +35 -0
  568. package/dist/interactive-commands/plugin/index.d.ts +13 -0
  569. package/dist/interactive-commands/plugin/index.d.ts.map +1 -0
  570. package/dist/interactive-commands/plugin/index.js +11 -0
  571. package/dist/interactive-commands/prompt-commands.cjs +269 -0
  572. package/dist/interactive-commands/prompt-commands.d.ts +25 -0
  573. package/dist/interactive-commands/prompt-commands.d.ts.map +1 -0
  574. package/dist/interactive-commands/prompt-commands.js +244 -0
  575. package/dist/interactive-commands/session/index.cjs +32 -0
  576. package/dist/interactive-commands/session/index.d.ts +16 -0
  577. package/dist/interactive-commands/session/index.d.ts.map +1 -0
  578. package/dist/interactive-commands/session/index.js +6 -0
  579. package/dist/interactive-commands/session/session-commands.cjs +64 -0
  580. package/dist/interactive-commands/session/session-commands.d.ts +32 -0
  581. package/dist/interactive-commands/session/session-commands.d.ts.map +1 -0
  582. package/dist/interactive-commands/session/session-commands.js +38 -0
  583. package/dist/interactive-commands/system/index.cjs +28 -0
  584. package/dist/interactive-commands/system/index.d.ts +13 -0
  585. package/dist/interactive-commands/system/index.d.ts.map +1 -0
  586. package/dist/interactive-commands/system/index.js +4 -0
  587. package/dist/interactive-commands/system/system-commands.cjs +217 -0
  588. package/dist/interactive-commands/system/system-commands.d.ts +6 -0
  589. package/dist/interactive-commands/system/system-commands.d.ts.map +1 -0
  590. package/dist/interactive-commands/system/system-commands.js +195 -0
  591. package/dist/interactive-commands/tool-commands.cjs +38 -0
  592. package/dist/interactive-commands/tool-commands.d.ts +15 -0
  593. package/dist/interactive-commands/tool-commands.d.ts.map +1 -0
  594. package/dist/interactive-commands/tool-commands.js +14 -0
  595. package/dist/interactive-commands/utils/arg-parser.cjs +59 -0
  596. package/dist/interactive-commands/utils/arg-parser.d.ts +57 -0
  597. package/dist/interactive-commands/utils/arg-parser.d.ts.map +1 -0
  598. package/dist/interactive-commands/utils/arg-parser.js +34 -0
  599. package/dist/interactive-commands/utils/command-output.cjs +75 -0
  600. package/dist/interactive-commands/utils/command-output.d.ts +40 -0
  601. package/dist/interactive-commands/utils/command-output.d.ts.map +1 -0
  602. package/dist/interactive-commands/utils/command-output.js +51 -0
  603. package/dist/interactive-commands/utils/format-output.cjs +36 -0
  604. package/dist/interactive-commands/utils/format-output.d.ts +14 -0
  605. package/dist/interactive-commands/utils/format-output.d.ts.map +1 -0
  606. package/dist/interactive-commands/utils/format-output.js +11 -0
  607. package/dist/services/CommandService.cjs +68 -0
  608. package/dist/services/CommandService.d.ts +58 -0
  609. package/dist/services/CommandService.d.ts.map +1 -0
  610. package/dist/services/CommandService.js +41 -0
  611. package/dist/services/InputService.cjs +97 -0
  612. package/dist/services/InputService.d.ts +40 -0
  613. package/dist/services/InputService.d.ts.map +1 -0
  614. package/dist/services/InputService.js +78 -0
  615. package/dist/services/MessageService.cjs +69 -0
  616. package/dist/services/MessageService.d.ts +35 -0
  617. package/dist/services/MessageService.d.ts.map +1 -0
  618. package/dist/services/MessageService.js +51 -0
  619. package/dist/services/index.cjs +39 -0
  620. package/dist/services/index.d.ts +8 -0
  621. package/dist/services/index.d.ts.map +1 -0
  622. package/dist/services/index.js +16 -0
  623. package/dist/services/processStream.cjs +877 -0
  624. package/dist/services/processStream.d.ts +79 -0
  625. package/dist/services/processStream.d.ts.map +1 -0
  626. package/dist/services/processStream.js +843 -0
  627. package/dist/services/processStream.test.cjs +255 -0
  628. package/dist/services/processStream.test.d.ts +2 -0
  629. package/dist/services/processStream.test.d.ts.map +1 -0
  630. package/dist/services/processStream.test.js +254 -0
  631. package/dist/state/actions.cjs +16 -0
  632. package/dist/state/actions.d.ts +124 -0
  633. package/dist/state/actions.d.ts.map +1 -0
  634. package/dist/state/actions.js +0 -0
  635. package/dist/state/index.cjs +28 -0
  636. package/dist/state/index.d.ts +10 -0
  637. package/dist/state/index.d.ts.map +1 -0
  638. package/dist/state/index.js +4 -0
  639. package/dist/state/initialState.cjs +78 -0
  640. package/dist/state/initialState.d.ts +12 -0
  641. package/dist/state/initialState.d.ts.map +1 -0
  642. package/dist/state/initialState.js +54 -0
  643. package/dist/state/reducer.cjs +340 -0
  644. package/dist/state/reducer.d.ts +15 -0
  645. package/dist/state/reducer.d.ts.map +1 -0
  646. package/dist/state/reducer.js +316 -0
  647. package/dist/state/streaming-state.cjs +52 -0
  648. package/dist/state/streaming-state.d.ts +27 -0
  649. package/dist/state/streaming-state.d.ts.map +1 -0
  650. package/dist/state/streaming-state.js +25 -0
  651. package/dist/state/types.cjs +16 -0
  652. package/dist/state/types.d.ts +388 -0
  653. package/dist/state/types.d.ts.map +1 -0
  654. package/dist/state/types.js +0 -0
  655. package/dist/utils/bracketedPaste.cjs +37 -0
  656. package/dist/utils/bracketedPaste.d.ts +22 -0
  657. package/dist/utils/bracketedPaste.d.ts.map +1 -0
  658. package/dist/utils/bracketedPaste.js +12 -0
  659. package/dist/utils/clipboardUtils.cjs +297 -0
  660. package/dist/utils/clipboardUtils.d.ts +49 -0
  661. package/dist/utils/clipboardUtils.d.ts.map +1 -0
  662. package/dist/utils/clipboardUtils.js +261 -0
  663. package/dist/utils/commandOverlays.cjs +69 -0
  664. package/dist/utils/commandOverlays.d.ts +22 -0
  665. package/dist/utils/commandOverlays.d.ts.map +1 -0
  666. package/dist/utils/commandOverlays.js +44 -0
  667. package/dist/utils/debugLog.cjs +63 -0
  668. package/dist/utils/debugLog.d.ts +38 -0
  669. package/dist/utils/debugLog.d.ts.map +1 -0
  670. package/dist/utils/debugLog.js +39 -0
  671. package/dist/utils/elicitationSchema.cjs +85 -0
  672. package/dist/utils/elicitationSchema.d.ts +11 -0
  673. package/dist/utils/elicitationSchema.d.ts.map +1 -0
  674. package/dist/utils/elicitationSchema.js +61 -0
  675. package/dist/utils/elicitationSchema.test.cjs +78 -0
  676. package/dist/utils/elicitationSchema.test.d.ts +2 -0
  677. package/dist/utils/elicitationSchema.test.d.ts.map +1 -0
  678. package/dist/utils/elicitationSchema.test.js +77 -0
  679. package/dist/utils/idGenerator.cjs +31 -0
  680. package/dist/utils/idGenerator.d.ts +10 -0
  681. package/dist/utils/idGenerator.d.ts.map +1 -0
  682. package/dist/utils/idGenerator.js +7 -0
  683. package/dist/utils/index.cjs +62 -0
  684. package/dist/utils/index.d.ts +9 -0
  685. package/dist/utils/index.d.ts.map +1 -0
  686. package/dist/utils/index.js +39 -0
  687. package/dist/utils/input.cjs +72 -0
  688. package/dist/utils/input.d.ts +25 -0
  689. package/dist/utils/input.d.ts.map +1 -0
  690. package/dist/utils/input.js +39 -0
  691. package/dist/utils/inputParsing.cjs +76 -0
  692. package/dist/utils/inputParsing.d.ts +31 -0
  693. package/dist/utils/inputParsing.d.ts.map +1 -0
  694. package/dist/utils/inputParsing.js +48 -0
  695. package/dist/utils/llm-provider-display.cjs +49 -0
  696. package/dist/utils/llm-provider-display.d.ts +3 -0
  697. package/dist/utils/llm-provider-display.d.ts.map +1 -0
  698. package/dist/utils/llm-provider-display.js +25 -0
  699. package/dist/utils/messageFormatting.cjs +447 -0
  700. package/dist/utils/messageFormatting.d.ts +131 -0
  701. package/dist/utils/messageFormatting.d.ts.map +1 -0
  702. package/dist/utils/messageFormatting.js +393 -0
  703. package/dist/utils/messageFormatting.test.cjs +16 -0
  704. package/dist/utils/messageFormatting.test.d.ts +2 -0
  705. package/dist/utils/messageFormatting.test.d.ts.map +1 -0
  706. package/dist/utils/messageFormatting.test.js +15 -0
  707. package/dist/utils/mouse.cjs +196 -0
  708. package/dist/utils/mouse.d.ts +61 -0
  709. package/dist/utils/mouse.d.ts.map +1 -0
  710. package/dist/utils/mouse.js +172 -0
  711. package/dist/utils/overlayPresentation.cjs +48 -0
  712. package/dist/utils/overlayPresentation.d.ts +19 -0
  713. package/dist/utils/overlayPresentation.d.ts.map +1 -0
  714. package/dist/utils/overlayPresentation.js +22 -0
  715. package/dist/utils/overlaySizing.cjs +39 -0
  716. package/dist/utils/overlaySizing.d.ts +19 -0
  717. package/dist/utils/overlaySizing.d.ts.map +1 -0
  718. package/dist/utils/overlaySizing.js +15 -0
  719. package/dist/utils/soundNotification.cjs +217 -0
  720. package/dist/utils/soundNotification.d.ts +77 -0
  721. package/dist/utils/soundNotification.d.ts.map +1 -0
  722. package/dist/utils/soundNotification.js +188 -0
  723. package/dist/utils/soundNotification.test.cjs +126 -0
  724. package/dist/utils/soundNotification.test.d.ts +2 -0
  725. package/dist/utils/soundNotification.test.d.ts.map +1 -0
  726. package/dist/utils/soundNotification.test.js +125 -0
  727. package/dist/utils/streamSplitter.cjs +126 -0
  728. package/dist/utils/streamSplitter.d.ts +44 -0
  729. package/dist/utils/streamSplitter.d.ts.map +1 -0
  730. package/dist/utils/streamSplitter.js +100 -0
  731. package/dist/utils/textUtils.cjs +223 -0
  732. package/dist/utils/textUtils.d.ts +63 -0
  733. package/dist/utils/textUtils.d.ts.map +1 -0
  734. package/dist/utils/textUtils.js +174 -0
  735. package/dist/utils/toolUtils.cjs +40 -0
  736. package/dist/utils/toolUtils.d.ts +20 -0
  737. package/dist/utils/toolUtils.d.ts.map +1 -0
  738. package/dist/utils/toolUtils.js +14 -0
  739. package/package.json +51 -0
@@ -0,0 +1,1220 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var text_buffer_exports = {};
20
+ __export(text_buffer_exports, {
21
+ findNextWordAcrossLines: () => findNextWordAcrossLines,
22
+ findNextWordStartInLine: () => findNextWordStartInLine,
23
+ findPrevWordAcrossLines: () => findPrevWordAcrossLines,
24
+ findPrevWordStartInLine: () => findPrevWordStartInLine,
25
+ findWordEndInLine: () => findWordEndInLine,
26
+ getLineRangeOffsets: () => getLineRangeOffsets,
27
+ getPositionFromOffsets: () => getPositionFromOffsets,
28
+ logicalPosToOffset: () => logicalPosToOffset,
29
+ offsetToLogicalPos: () => offsetToLogicalPos,
30
+ pushUndo: () => pushUndo,
31
+ replaceRangeInternal: () => replaceRangeInternal,
32
+ textBufferReducer: () => textBufferReducer,
33
+ useTextBuffer: () => useTextBuffer
34
+ });
35
+ module.exports = __toCommonJS(text_buffer_exports);
36
+ var import_react = require("react");
37
+ var import_textUtils = require("../../utils/textUtils.js");
38
+ const findNextWordStartInLine = (line, col) => {
39
+ const chars = (0, import_textUtils.toCodePoints)(line);
40
+ let i = col;
41
+ if (i >= chars.length) return null;
42
+ const currentChar = chars[i];
43
+ if ((0, import_textUtils.isWordCharStrict)(currentChar)) {
44
+ while (i < chars.length && (0, import_textUtils.isWordCharWithCombining)(chars[i])) {
45
+ if (i + 1 < chars.length && (0, import_textUtils.isWordCharStrict)(chars[i + 1]) && (0, import_textUtils.isDifferentScript)(chars[i], chars[i + 1])) {
46
+ i++;
47
+ break;
48
+ }
49
+ i++;
50
+ }
51
+ } else if (!(0, import_textUtils.isWhitespace)(currentChar)) {
52
+ while (i < chars.length && !(0, import_textUtils.isWordCharStrict)(chars[i]) && !(0, import_textUtils.isWhitespace)(chars[i])) {
53
+ i++;
54
+ }
55
+ }
56
+ while (i < chars.length && (0, import_textUtils.isWhitespace)(chars[i])) {
57
+ i++;
58
+ }
59
+ return i < chars.length ? i : null;
60
+ };
61
+ const findPrevWordStartInLine = (line, col) => {
62
+ const chars = (0, import_textUtils.toCodePoints)(line);
63
+ let i = col;
64
+ if (i <= 0) return null;
65
+ i--;
66
+ while (i >= 0 && (0, import_textUtils.isWhitespace)(chars[i])) {
67
+ i--;
68
+ }
69
+ if (i < 0) return null;
70
+ if ((0, import_textUtils.isWordCharStrict)(chars[i])) {
71
+ while (i >= 0 && (0, import_textUtils.isWordCharStrict)(chars[i])) {
72
+ if (i - 1 >= 0 && (0, import_textUtils.isWordCharStrict)(chars[i - 1]) && (0, import_textUtils.isDifferentScript)(chars[i], chars[i - 1])) {
73
+ return i;
74
+ }
75
+ i--;
76
+ }
77
+ return i + 1;
78
+ } else {
79
+ while (i >= 0 && !(0, import_textUtils.isWordCharStrict)(chars[i]) && !(0, import_textUtils.isWhitespace)(chars[i])) {
80
+ i--;
81
+ }
82
+ return i + 1;
83
+ }
84
+ };
85
+ const findWordEndInLine = (line, col) => {
86
+ const chars = (0, import_textUtils.toCodePoints)(line);
87
+ let i = col;
88
+ const atEndOfWordChar = i < chars.length && (0, import_textUtils.isWordCharWithCombining)(chars[i]) && (i + 1 >= chars.length || !(0, import_textUtils.isWordCharWithCombining)(chars[i + 1]) || (0, import_textUtils.isWordCharStrict)(chars[i]) && i + 1 < chars.length && (0, import_textUtils.isWordCharStrict)(chars[i + 1]) && (0, import_textUtils.isDifferentScript)(chars[i], chars[i + 1]));
89
+ const atEndOfPunctuation = i < chars.length && !(0, import_textUtils.isWordCharWithCombining)(chars[i]) && !(0, import_textUtils.isWhitespace)(chars[i]) && (i + 1 >= chars.length || (0, import_textUtils.isWhitespace)(chars[i + 1]) || (0, import_textUtils.isWordCharWithCombining)(chars[i + 1]));
90
+ if (atEndOfWordChar || atEndOfPunctuation) {
91
+ i++;
92
+ while (i < chars.length && (0, import_textUtils.isWhitespace)(chars[i])) {
93
+ i++;
94
+ }
95
+ }
96
+ if (i < chars.length && !(0, import_textUtils.isWordCharWithCombining)(chars[i])) {
97
+ while (i < chars.length && (0, import_textUtils.isWhitespace)(chars[i])) {
98
+ i++;
99
+ }
100
+ }
101
+ let foundWord = false;
102
+ let lastBaseCharPos = -1;
103
+ if (i < chars.length && (0, import_textUtils.isWordCharWithCombining)(chars[i])) {
104
+ while (i < chars.length && (0, import_textUtils.isWordCharWithCombining)(chars[i])) {
105
+ foundWord = true;
106
+ if ((0, import_textUtils.isWordCharStrict)(chars[i])) {
107
+ lastBaseCharPos = i;
108
+ }
109
+ if (i + 1 < chars.length && (0, import_textUtils.isWordCharStrict)(chars[i + 1]) && (0, import_textUtils.isDifferentScript)(chars[i], chars[i + 1])) {
110
+ i++;
111
+ if ((0, import_textUtils.isWordCharStrict)(chars[i - 1])) {
112
+ lastBaseCharPos = i - 1;
113
+ }
114
+ break;
115
+ }
116
+ i++;
117
+ }
118
+ } else if (i < chars.length && !(0, import_textUtils.isWhitespace)(chars[i])) {
119
+ while (i < chars.length && !(0, import_textUtils.isWordCharStrict)(chars[i]) && !(0, import_textUtils.isWhitespace)(chars[i])) {
120
+ foundWord = true;
121
+ lastBaseCharPos = i;
122
+ i++;
123
+ }
124
+ }
125
+ if (foundWord && lastBaseCharPos >= col) {
126
+ return lastBaseCharPos;
127
+ }
128
+ return null;
129
+ };
130
+ const segmenter = new Intl.Segmenter(void 0, { granularity: "word" });
131
+ function findPrevWordBoundary(line, cursorCol) {
132
+ const codePoints = (0, import_textUtils.toCodePoints)(line);
133
+ const prefix = codePoints.slice(0, cursorCol).join("");
134
+ const cursorIdx = prefix.length;
135
+ let targetIdx = 0;
136
+ for (const seg of segmenter.segment(line)) {
137
+ if (seg.index >= cursorIdx) break;
138
+ if (seg.isWordLike) {
139
+ targetIdx = seg.index;
140
+ }
141
+ }
142
+ return (0, import_textUtils.toCodePoints)(line.slice(0, targetIdx)).length;
143
+ }
144
+ function findNextWordBoundary(line, cursorCol) {
145
+ const codePoints = (0, import_textUtils.toCodePoints)(line);
146
+ const prefix = codePoints.slice(0, cursorCol).join("");
147
+ const cursorIdx = prefix.length;
148
+ let targetIdx = line.length;
149
+ for (const seg of segmenter.segment(line)) {
150
+ const segEnd = seg.index + seg.segment.length;
151
+ if (segEnd > cursorIdx) {
152
+ if (seg.isWordLike) {
153
+ targetIdx = segEnd;
154
+ break;
155
+ }
156
+ }
157
+ }
158
+ return (0, import_textUtils.toCodePoints)(line.slice(0, targetIdx)).length;
159
+ }
160
+ const findNextWordAcrossLines = (lines, cursorRow, cursorCol, searchForWordStart) => {
161
+ const currentLine = lines[cursorRow] || "";
162
+ const colInCurrentLine = searchForWordStart ? findNextWordStartInLine(currentLine, cursorCol) : findWordEndInLine(currentLine, cursorCol);
163
+ if (colInCurrentLine !== null) {
164
+ return { row: cursorRow, col: colInCurrentLine };
165
+ }
166
+ for (let row = cursorRow + 1; row < lines.length; row++) {
167
+ const line = lines[row] || "";
168
+ const chars = (0, import_textUtils.toCodePoints)(line);
169
+ if (chars.length === 0) {
170
+ let hasWordsInLaterLines = false;
171
+ for (let laterRow = row + 1; laterRow < lines.length; laterRow++) {
172
+ const laterLine = lines[laterRow] || "";
173
+ const laterChars = (0, import_textUtils.toCodePoints)(laterLine);
174
+ let firstNonWhitespace2 = 0;
175
+ while (firstNonWhitespace2 < laterChars.length && (0, import_textUtils.isWhitespace)(laterChars[firstNonWhitespace2])) {
176
+ firstNonWhitespace2++;
177
+ }
178
+ if (firstNonWhitespace2 < laterChars.length) {
179
+ hasWordsInLaterLines = true;
180
+ break;
181
+ }
182
+ }
183
+ if (!hasWordsInLaterLines) {
184
+ return { row, col: 0 };
185
+ }
186
+ continue;
187
+ }
188
+ let firstNonWhitespace = 0;
189
+ while (firstNonWhitespace < chars.length && (0, import_textUtils.isWhitespace)(chars[firstNonWhitespace])) {
190
+ firstNonWhitespace++;
191
+ }
192
+ if (firstNonWhitespace < chars.length) {
193
+ if (searchForWordStart) {
194
+ return { row, col: firstNonWhitespace };
195
+ } else {
196
+ const endCol = findWordEndInLine(line, firstNonWhitespace);
197
+ if (endCol !== null) {
198
+ return { row, col: endCol };
199
+ }
200
+ }
201
+ }
202
+ }
203
+ return null;
204
+ };
205
+ const findPrevWordAcrossLines = (lines, cursorRow, cursorCol) => {
206
+ const currentLine = lines[cursorRow] || "";
207
+ const colInCurrentLine = findPrevWordStartInLine(currentLine, cursorCol);
208
+ if (colInCurrentLine !== null) {
209
+ return { row: cursorRow, col: colInCurrentLine };
210
+ }
211
+ for (let row = cursorRow - 1; row >= 0; row--) {
212
+ const line = lines[row] || "";
213
+ const chars = (0, import_textUtils.toCodePoints)(line);
214
+ if (chars.length === 0) continue;
215
+ let lastWordStart = chars.length;
216
+ while (lastWordStart > 0 && (0, import_textUtils.isWhitespace)(chars[lastWordStart - 1])) {
217
+ lastWordStart--;
218
+ }
219
+ if (lastWordStart > 0) {
220
+ const wordStart = findPrevWordStartInLine(line, lastWordStart);
221
+ if (wordStart !== null) {
222
+ return { row, col: wordStart };
223
+ }
224
+ }
225
+ }
226
+ return null;
227
+ };
228
+ const getPositionFromOffsets = (startOffset, endOffset, lines) => {
229
+ let offset = 0;
230
+ let startRow = 0;
231
+ let startCol = 0;
232
+ let endRow = 0;
233
+ let endCol = 0;
234
+ for (let i = 0; i < lines.length; i++) {
235
+ const lineLength = lines[i].length + 1;
236
+ if (offset + lineLength > startOffset) {
237
+ startRow = i;
238
+ startCol = startOffset - offset;
239
+ break;
240
+ }
241
+ offset += lineLength;
242
+ }
243
+ offset = 0;
244
+ for (let i = 0; i < lines.length; i++) {
245
+ const lineLength = lines[i].length + (i < lines.length - 1 ? 1 : 0);
246
+ if (offset + lineLength >= endOffset) {
247
+ endRow = i;
248
+ endCol = endOffset - offset;
249
+ break;
250
+ }
251
+ offset += lineLength;
252
+ }
253
+ return { startRow, startCol, endRow, endCol };
254
+ };
255
+ const getLineRangeOffsets = (startRow, lineCount, lines) => {
256
+ let startOffset = 0;
257
+ for (let i = 0; i < startRow; i++) {
258
+ startOffset += lines[i].length + 1;
259
+ }
260
+ let endOffset = startOffset;
261
+ for (let i = 0; i < lineCount; i++) {
262
+ const lineIndex = startRow + i;
263
+ if (lineIndex < lines.length) {
264
+ endOffset += lines[lineIndex].length;
265
+ if (lineIndex < lines.length - 1) {
266
+ endOffset += 1;
267
+ }
268
+ }
269
+ }
270
+ return { startOffset, endOffset };
271
+ };
272
+ const replaceRangeInternal = (state, startRow, startCol, endRow, endCol, text) => {
273
+ const currentLine = (row) => state.lines[row] || "";
274
+ const currentLineLen = (row) => (0, import_textUtils.cpLen)(currentLine(row));
275
+ const clamp2 = (value, min, max) => Math.min(Math.max(value, min), max);
276
+ if (startRow > endRow || startRow === endRow && startCol > endCol || startRow < 0 || startCol < 0 || endRow >= state.lines.length || endRow < state.lines.length && endCol > currentLineLen(endRow)) {
277
+ return state;
278
+ }
279
+ const newLines = [...state.lines];
280
+ const sCol = clamp2(startCol, 0, currentLineLen(startRow));
281
+ const eCol = clamp2(endCol, 0, currentLineLen(endRow));
282
+ const prefix = (0, import_textUtils.cpSlice)(currentLine(startRow), 0, sCol);
283
+ const suffix = (0, import_textUtils.cpSlice)(currentLine(endRow), eCol);
284
+ const normalisedReplacement = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
285
+ const replacementParts = normalisedReplacement.split("\n");
286
+ const firstLine = prefix + replacementParts[0];
287
+ if (replacementParts.length === 1) {
288
+ newLines.splice(startRow, endRow - startRow + 1, firstLine + suffix);
289
+ } else {
290
+ const lastLine = replacementParts[replacementParts.length - 1] + suffix;
291
+ const middleLines = replacementParts.slice(1, -1);
292
+ newLines.splice(startRow, endRow - startRow + 1, firstLine, ...middleLines, lastLine);
293
+ }
294
+ const finalCursorRow = startRow + replacementParts.length - 1;
295
+ const finalCursorCol = (replacementParts.length > 1 ? 0 : sCol) + (0, import_textUtils.cpLen)(replacementParts[replacementParts.length - 1]);
296
+ return {
297
+ ...state,
298
+ lines: newLines,
299
+ cursorRow: Math.min(Math.max(finalCursorRow, 0), newLines.length - 1),
300
+ cursorCol: Math.max(0, Math.min(finalCursorCol, (0, import_textUtils.cpLen)(newLines[finalCursorRow] || ""))),
301
+ preferredCol: null
302
+ };
303
+ };
304
+ function clamp(v, min, max) {
305
+ return v < min ? min : v > max ? max : v;
306
+ }
307
+ function calculateInitialCursorPosition(initialLines, offset) {
308
+ let remainingChars = offset;
309
+ let row = 0;
310
+ while (row < initialLines.length) {
311
+ const lineLength = (0, import_textUtils.cpLen)(initialLines[row]);
312
+ const totalCharsInLineAndNewline = lineLength + (row < initialLines.length - 1 ? 1 : 0);
313
+ if (remainingChars <= lineLength) {
314
+ return [row, remainingChars];
315
+ }
316
+ remainingChars -= totalCharsInLineAndNewline;
317
+ row++;
318
+ }
319
+ if (initialLines.length > 0) {
320
+ const lastRow = initialLines.length - 1;
321
+ return [lastRow, (0, import_textUtils.cpLen)(initialLines[lastRow])];
322
+ }
323
+ return [0, 0];
324
+ }
325
+ function offsetToLogicalPos(text, offset) {
326
+ let row = 0;
327
+ let col = 0;
328
+ let currentOffset = 0;
329
+ if (offset === 0) return [0, 0];
330
+ const lines = text.split("\n");
331
+ for (let i = 0; i < lines.length; i++) {
332
+ const line = lines[i];
333
+ const lineLength = (0, import_textUtils.cpLen)(line);
334
+ const lineLengthWithNewline = lineLength + (i < lines.length - 1 ? 1 : 0);
335
+ if (offset <= currentOffset + lineLength) {
336
+ row = i;
337
+ col = offset - currentOffset;
338
+ return [row, col];
339
+ } else if (offset <= currentOffset + lineLengthWithNewline) {
340
+ row = i;
341
+ col = lineLength;
342
+ if (offset === currentOffset + lineLengthWithNewline && i < lines.length - 1) {
343
+ return [i + 1, 0];
344
+ }
345
+ return [row, col];
346
+ }
347
+ currentOffset += lineLengthWithNewline;
348
+ }
349
+ if (lines.length > 0) {
350
+ row = lines.length - 1;
351
+ col = (0, import_textUtils.cpLen)(lines[row]);
352
+ } else {
353
+ row = 0;
354
+ col = 0;
355
+ }
356
+ return [row, col];
357
+ }
358
+ function logicalPosToOffset(lines, row, col) {
359
+ let offset = 0;
360
+ const actualRow = Math.min(row, lines.length - 1);
361
+ for (let i = 0; i < actualRow; i++) {
362
+ offset += (0, import_textUtils.cpLen)(lines[i]) + 1;
363
+ }
364
+ if (actualRow >= 0 && actualRow < lines.length) {
365
+ offset += Math.min(col, (0, import_textUtils.cpLen)(lines[actualRow]));
366
+ }
367
+ return offset;
368
+ }
369
+ function calculateLayout(logicalLines, viewportWidth) {
370
+ const visualLines = [];
371
+ const logicalToVisualMap = [];
372
+ const visualToLogicalMap = [];
373
+ logicalLines.forEach((logLine, logIndex) => {
374
+ logicalToVisualMap[logIndex] = [];
375
+ if (logLine.length === 0) {
376
+ logicalToVisualMap[logIndex].push([visualLines.length, 0]);
377
+ visualToLogicalMap.push([logIndex, 0]);
378
+ visualLines.push("");
379
+ } else {
380
+ let currentPosInLogLine = 0;
381
+ const codePointsInLogLine = (0, import_textUtils.toCodePoints)(logLine);
382
+ while (currentPosInLogLine < codePointsInLogLine.length) {
383
+ let currentChunk = "";
384
+ let currentChunkVisualWidth = 0;
385
+ let numCodePointsInChunk = 0;
386
+ let lastWordBreakPoint = -1;
387
+ let numCodePointsAtLastWordBreak = 0;
388
+ for (let i = currentPosInLogLine; i < codePointsInLogLine.length; i++) {
389
+ const char = codePointsInLogLine[i];
390
+ const charVisualWidth = (0, import_textUtils.getCachedStringWidth)(char);
391
+ if (currentChunkVisualWidth + charVisualWidth > viewportWidth) {
392
+ if (lastWordBreakPoint !== -1 && numCodePointsAtLastWordBreak > 0 && currentPosInLogLine + numCodePointsAtLastWordBreak < i) {
393
+ currentChunk = codePointsInLogLine.slice(
394
+ currentPosInLogLine,
395
+ currentPosInLogLine + numCodePointsAtLastWordBreak
396
+ ).join("");
397
+ numCodePointsInChunk = numCodePointsAtLastWordBreak;
398
+ } else {
399
+ if (numCodePointsInChunk === 0 && charVisualWidth > viewportWidth) {
400
+ currentChunk = char;
401
+ numCodePointsInChunk = 1;
402
+ } else if (numCodePointsInChunk === 0 && charVisualWidth <= viewportWidth) {
403
+ }
404
+ }
405
+ break;
406
+ }
407
+ currentChunk += char;
408
+ currentChunkVisualWidth += charVisualWidth;
409
+ numCodePointsInChunk++;
410
+ if (char === " ") {
411
+ lastWordBreakPoint = i;
412
+ numCodePointsAtLastWordBreak = numCodePointsInChunk - 1;
413
+ }
414
+ }
415
+ if (numCodePointsInChunk === 0 && currentPosInLogLine < codePointsInLogLine.length) {
416
+ const firstChar = codePointsInLogLine[currentPosInLogLine];
417
+ currentChunk = firstChar;
418
+ numCodePointsInChunk = 1;
419
+ }
420
+ if (numCodePointsInChunk === 0 && currentPosInLogLine < codePointsInLogLine.length) {
421
+ currentChunk = codePointsInLogLine[currentPosInLogLine];
422
+ numCodePointsInChunk = 1;
423
+ }
424
+ logicalToVisualMap[logIndex].push([visualLines.length, currentPosInLogLine]);
425
+ visualToLogicalMap.push([logIndex, currentPosInLogLine]);
426
+ visualLines.push(currentChunk);
427
+ const logicalStartOfThisChunk = currentPosInLogLine;
428
+ currentPosInLogLine += numCodePointsInChunk;
429
+ if (logicalStartOfThisChunk + numCodePointsInChunk < codePointsInLogLine.length && currentPosInLogLine < codePointsInLogLine.length && // Redundant if previous is true, but safe
430
+ codePointsInLogLine[currentPosInLogLine] === " ") {
431
+ currentPosInLogLine++;
432
+ }
433
+ }
434
+ }
435
+ });
436
+ if (logicalLines.length === 0 || logicalLines.length === 1 && logicalLines[0] === "") {
437
+ if (visualLines.length === 0) {
438
+ visualLines.push("");
439
+ if (!logicalToVisualMap[0]) logicalToVisualMap[0] = [];
440
+ logicalToVisualMap[0].push([0, 0]);
441
+ visualToLogicalMap.push([0, 0]);
442
+ }
443
+ }
444
+ return {
445
+ visualLines,
446
+ logicalToVisualMap,
447
+ visualToLogicalMap
448
+ };
449
+ }
450
+ function calculateVisualCursorFromLayout(layout, logicalCursor) {
451
+ const { logicalToVisualMap, visualLines } = layout;
452
+ const [logicalRow, logicalCol] = logicalCursor;
453
+ const segmentsForLogicalLine = logicalToVisualMap[logicalRow];
454
+ if (!segmentsForLogicalLine || segmentsForLogicalLine.length === 0) {
455
+ return [0, 0];
456
+ }
457
+ let targetSegmentIndex = segmentsForLogicalLine.findIndex(([, startColInLogical2], index) => {
458
+ const nextStartColInLogical = index + 1 < segmentsForLogicalLine.length ? segmentsForLogicalLine[index + 1][1] : Infinity;
459
+ return logicalCol >= startColInLogical2 && logicalCol < nextStartColInLogical;
460
+ });
461
+ if (targetSegmentIndex === -1) {
462
+ if (logicalCol === 0) {
463
+ targetSegmentIndex = 0;
464
+ } else {
465
+ targetSegmentIndex = segmentsForLogicalLine.length - 1;
466
+ }
467
+ }
468
+ const [visualRow, startColInLogical] = segmentsForLogicalLine[targetSegmentIndex];
469
+ const visualCol = logicalCol - startColInLogical;
470
+ const clampedVisualCol = Math.min(visualCol, (0, import_textUtils.cpLen)(visualLines[visualRow] ?? ""));
471
+ return [visualRow, clampedVisualCol];
472
+ }
473
+ const historyLimit = 100;
474
+ const pushUndo = (currentState) => {
475
+ const snapshot = {
476
+ lines: [...currentState.lines],
477
+ cursorRow: currentState.cursorRow,
478
+ cursorCol: currentState.cursorCol
479
+ };
480
+ const newStack = [...currentState.undoStack, snapshot];
481
+ if (newStack.length > historyLimit) {
482
+ newStack.shift();
483
+ }
484
+ return { ...currentState, undoStack: newStack, redoStack: [] };
485
+ };
486
+ function textBufferReducerLogic(state, action, options = {}) {
487
+ const pushUndoLocal = pushUndo;
488
+ const currentLine = (r) => state.lines[r] ?? "";
489
+ const currentLineLen = (r) => (0, import_textUtils.cpLen)(currentLine(r));
490
+ switch (action.type) {
491
+ case "set_text": {
492
+ let nextState = state;
493
+ if (action.pushToUndo !== false) {
494
+ nextState = pushUndoLocal(state);
495
+ }
496
+ const newContentLines = action.payload.replace(/\r\n?/g, "\n").split("\n");
497
+ const lines = newContentLines.length === 0 ? [""] : newContentLines;
498
+ const lastNewLineIndex = lines.length - 1;
499
+ return {
500
+ ...nextState,
501
+ lines,
502
+ cursorRow: lastNewLineIndex,
503
+ cursorCol: (0, import_textUtils.cpLen)(lines[lastNewLineIndex] ?? ""),
504
+ preferredCol: null
505
+ };
506
+ }
507
+ case "insert": {
508
+ let payload = action.payload;
509
+ if (options.singleLine) {
510
+ payload = payload.replace(/[\r\n]/g, "");
511
+ }
512
+ if (options.inputFilter) {
513
+ payload = options.inputFilter(payload);
514
+ }
515
+ if (payload.length === 0) {
516
+ return state;
517
+ }
518
+ const nextState = pushUndoLocal(state);
519
+ const newLines = [...nextState.lines];
520
+ let newCursorRow = nextState.cursorRow;
521
+ let newCursorCol = nextState.cursorCol;
522
+ const currentLine2 = (r) => newLines[r] ?? "";
523
+ const str = (0, import_textUtils.stripUnsafeCharacters)(payload.replace(/\r\n/g, "\n").replace(/\r/g, "\n"));
524
+ const parts = str.split("\n");
525
+ const lineContent = currentLine2(newCursorRow);
526
+ const before = (0, import_textUtils.cpSlice)(lineContent, 0, newCursorCol);
527
+ const after = (0, import_textUtils.cpSlice)(lineContent, newCursorCol);
528
+ if (parts.length > 1) {
529
+ newLines[newCursorRow] = before + parts[0];
530
+ const remainingParts = parts.slice(1);
531
+ const lastPartOriginal = remainingParts.pop() ?? "";
532
+ newLines.splice(newCursorRow + 1, 0, ...remainingParts);
533
+ newLines.splice(newCursorRow + parts.length - 1, 0, lastPartOriginal + after);
534
+ newCursorRow = newCursorRow + parts.length - 1;
535
+ newCursorCol = (0, import_textUtils.cpLen)(lastPartOriginal);
536
+ } else {
537
+ newLines[newCursorRow] = before + parts[0] + after;
538
+ newCursorCol = (0, import_textUtils.cpLen)(before) + (0, import_textUtils.cpLen)(parts[0]);
539
+ }
540
+ return {
541
+ ...nextState,
542
+ lines: newLines,
543
+ cursorRow: newCursorRow,
544
+ cursorCol: newCursorCol,
545
+ preferredCol: null
546
+ };
547
+ }
548
+ case "backspace": {
549
+ if (state.cursorCol === 0 && state.cursorRow === 0) return state;
550
+ const nextState = pushUndoLocal(state);
551
+ const newLines = [...nextState.lines];
552
+ let newCursorRow = nextState.cursorRow;
553
+ let newCursorCol = nextState.cursorCol;
554
+ const currentLine2 = (r) => newLines[r] ?? "";
555
+ if (newCursorCol > 0) {
556
+ const lineContent = currentLine2(newCursorRow);
557
+ newLines[newCursorRow] = (0, import_textUtils.cpSlice)(lineContent, 0, newCursorCol - 1) + (0, import_textUtils.cpSlice)(lineContent, newCursorCol);
558
+ newCursorCol--;
559
+ } else if (newCursorRow > 0) {
560
+ const prevLineContent = currentLine2(newCursorRow - 1);
561
+ const currentLineContentVal = currentLine2(newCursorRow);
562
+ const newCol = (0, import_textUtils.cpLen)(prevLineContent);
563
+ newLines[newCursorRow - 1] = prevLineContent + currentLineContentVal;
564
+ newLines.splice(newCursorRow, 1);
565
+ newCursorRow--;
566
+ newCursorCol = newCol;
567
+ }
568
+ return {
569
+ ...nextState,
570
+ lines: newLines,
571
+ cursorRow: newCursorRow,
572
+ cursorCol: newCursorCol,
573
+ preferredCol: null
574
+ };
575
+ }
576
+ case "set_viewport": {
577
+ const { width, height } = action.payload;
578
+ if (width === state.viewportWidth && height === state.viewportHeight) {
579
+ return state;
580
+ }
581
+ return {
582
+ ...state,
583
+ viewportWidth: width,
584
+ viewportHeight: height
585
+ };
586
+ }
587
+ case "move": {
588
+ const { dir } = action.payload;
589
+ const { cursorRow, cursorCol, lines, visualLayout, preferredCol } = state;
590
+ if (dir === "left" || dir === "right" || dir === "up" || dir === "down" || dir === "home" || dir === "end") {
591
+ const visualCursor = calculateVisualCursorFromLayout(visualLayout, [
592
+ cursorRow,
593
+ cursorCol
594
+ ]);
595
+ const { visualLines, visualToLogicalMap } = visualLayout;
596
+ let newVisualRow = visualCursor[0];
597
+ let newVisualCol = visualCursor[1];
598
+ let newPreferredCol = preferredCol;
599
+ const currentVisLineLen = (0, import_textUtils.cpLen)(visualLines[newVisualRow] ?? "");
600
+ switch (dir) {
601
+ case "left":
602
+ newPreferredCol = null;
603
+ if (newVisualCol > 0) {
604
+ newVisualCol--;
605
+ } else if (newVisualRow > 0) {
606
+ newVisualRow--;
607
+ newVisualCol = (0, import_textUtils.cpLen)(visualLines[newVisualRow] ?? "");
608
+ }
609
+ break;
610
+ case "right":
611
+ newPreferredCol = null;
612
+ if (newVisualCol < currentVisLineLen) {
613
+ newVisualCol++;
614
+ } else if (newVisualRow < visualLines.length - 1) {
615
+ newVisualRow++;
616
+ newVisualCol = 0;
617
+ }
618
+ break;
619
+ case "up":
620
+ if (newVisualRow > 0) {
621
+ if (newPreferredCol === null) newPreferredCol = newVisualCol;
622
+ newVisualRow--;
623
+ newVisualCol = clamp(
624
+ newPreferredCol,
625
+ 0,
626
+ (0, import_textUtils.cpLen)(visualLines[newVisualRow] ?? "")
627
+ );
628
+ }
629
+ break;
630
+ case "down":
631
+ if (newVisualRow < visualLines.length - 1) {
632
+ if (newPreferredCol === null) newPreferredCol = newVisualCol;
633
+ newVisualRow++;
634
+ newVisualCol = clamp(
635
+ newPreferredCol,
636
+ 0,
637
+ (0, import_textUtils.cpLen)(visualLines[newVisualRow] ?? "")
638
+ );
639
+ }
640
+ break;
641
+ case "home":
642
+ newPreferredCol = null;
643
+ newVisualCol = 0;
644
+ break;
645
+ case "end":
646
+ newPreferredCol = null;
647
+ newVisualCol = currentVisLineLen;
648
+ break;
649
+ default:
650
+ return state;
651
+ }
652
+ if (visualToLogicalMap[newVisualRow]) {
653
+ const [logRow, logStartCol] = visualToLogicalMap[newVisualRow];
654
+ return {
655
+ ...state,
656
+ cursorRow: logRow,
657
+ cursorCol: clamp(logStartCol + newVisualCol, 0, (0, import_textUtils.cpLen)(lines[logRow] ?? "")),
658
+ preferredCol: newPreferredCol
659
+ };
660
+ }
661
+ return state;
662
+ }
663
+ switch (dir) {
664
+ case "wordLeft": {
665
+ if (cursorCol === 0 && cursorRow === 0) return state;
666
+ let newCursorRow = cursorRow;
667
+ let newCursorCol = cursorCol;
668
+ if (cursorCol === 0) {
669
+ newCursorRow--;
670
+ newCursorCol = (0, import_textUtils.cpLen)(lines[newCursorRow] ?? "");
671
+ } else {
672
+ const lineContent = lines[cursorRow] ?? "";
673
+ newCursorCol = findPrevWordBoundary(lineContent, cursorCol);
674
+ }
675
+ return {
676
+ ...state,
677
+ cursorRow: newCursorRow,
678
+ cursorCol: newCursorCol,
679
+ preferredCol: null
680
+ };
681
+ }
682
+ case "wordRight": {
683
+ const lineContent = lines[cursorRow] ?? "";
684
+ if (cursorRow === lines.length - 1 && cursorCol === (0, import_textUtils.cpLen)(lineContent)) {
685
+ return state;
686
+ }
687
+ let newCursorRow = cursorRow;
688
+ let newCursorCol = cursorCol;
689
+ const lineLen = (0, import_textUtils.cpLen)(lineContent);
690
+ if (cursorCol >= lineLen) {
691
+ newCursorRow++;
692
+ newCursorCol = 0;
693
+ } else {
694
+ newCursorCol = findNextWordBoundary(lineContent, cursorCol);
695
+ }
696
+ return {
697
+ ...state,
698
+ cursorRow: newCursorRow,
699
+ cursorCol: newCursorCol,
700
+ preferredCol: null
701
+ };
702
+ }
703
+ default:
704
+ return state;
705
+ }
706
+ }
707
+ case "set_cursor": {
708
+ return {
709
+ ...state,
710
+ ...action.payload
711
+ };
712
+ }
713
+ case "delete": {
714
+ const { cursorRow, cursorCol, lines } = state;
715
+ const lineContent = currentLine(cursorRow);
716
+ if (cursorCol < currentLineLen(cursorRow)) {
717
+ const nextState = pushUndoLocal(state);
718
+ const newLines = [...nextState.lines];
719
+ newLines[cursorRow] = (0, import_textUtils.cpSlice)(lineContent, 0, cursorCol) + (0, import_textUtils.cpSlice)(lineContent, cursorCol + 1);
720
+ return {
721
+ ...nextState,
722
+ lines: newLines,
723
+ preferredCol: null
724
+ };
725
+ } else if (cursorRow < lines.length - 1) {
726
+ const nextState = pushUndoLocal(state);
727
+ const nextLineContent = currentLine(cursorRow + 1);
728
+ const newLines = [...nextState.lines];
729
+ newLines[cursorRow] = lineContent + nextLineContent;
730
+ newLines.splice(cursorRow + 1, 1);
731
+ return {
732
+ ...nextState,
733
+ lines: newLines,
734
+ preferredCol: null
735
+ };
736
+ }
737
+ return state;
738
+ }
739
+ case "delete_word_left": {
740
+ const { cursorRow, cursorCol } = state;
741
+ if (cursorCol === 0 && cursorRow === 0) return state;
742
+ const nextState = pushUndoLocal(state);
743
+ const newLines = [...nextState.lines];
744
+ let newCursorRow = cursorRow;
745
+ let newCursorCol = cursorCol;
746
+ if (newCursorCol > 0) {
747
+ const lineContent = currentLine(newCursorRow);
748
+ const prevWordStart = findPrevWordStartInLine(lineContent, newCursorCol);
749
+ const start = prevWordStart === null ? 0 : prevWordStart;
750
+ newLines[newCursorRow] = (0, import_textUtils.cpSlice)(lineContent, 0, start) + (0, import_textUtils.cpSlice)(lineContent, newCursorCol);
751
+ newCursorCol = start;
752
+ } else {
753
+ const prevLineContent = currentLine(cursorRow - 1);
754
+ const currentLineContentVal = currentLine(cursorRow);
755
+ const newCol = (0, import_textUtils.cpLen)(prevLineContent);
756
+ newLines[cursorRow - 1] = prevLineContent + currentLineContentVal;
757
+ newLines.splice(cursorRow, 1);
758
+ newCursorRow--;
759
+ newCursorCol = newCol;
760
+ }
761
+ return {
762
+ ...nextState,
763
+ lines: newLines,
764
+ cursorRow: newCursorRow,
765
+ cursorCol: newCursorCol,
766
+ preferredCol: null
767
+ };
768
+ }
769
+ case "delete_word_right": {
770
+ const { cursorRow, cursorCol, lines } = state;
771
+ const lineContent = currentLine(cursorRow);
772
+ const lineLen = (0, import_textUtils.cpLen)(lineContent);
773
+ if (cursorCol >= lineLen && cursorRow === lines.length - 1) {
774
+ return state;
775
+ }
776
+ const nextState = pushUndoLocal(state);
777
+ const newLines = [...nextState.lines];
778
+ if (cursorCol >= lineLen) {
779
+ const nextLineContent = currentLine(cursorRow + 1);
780
+ newLines[cursorRow] = lineContent + nextLineContent;
781
+ newLines.splice(cursorRow + 1, 1);
782
+ } else {
783
+ const nextWordStart = findNextWordStartInLine(lineContent, cursorCol);
784
+ const end = nextWordStart === null ? lineLen : nextWordStart;
785
+ newLines[cursorRow] = (0, import_textUtils.cpSlice)(lineContent, 0, cursorCol) + (0, import_textUtils.cpSlice)(lineContent, end);
786
+ }
787
+ return {
788
+ ...nextState,
789
+ lines: newLines,
790
+ preferredCol: null
791
+ };
792
+ }
793
+ case "kill_line_right": {
794
+ const { cursorRow, cursorCol, lines } = state;
795
+ const lineContent = currentLine(cursorRow);
796
+ if (cursorCol < currentLineLen(cursorRow)) {
797
+ const nextState = pushUndoLocal(state);
798
+ const newLines = [...nextState.lines];
799
+ newLines[cursorRow] = (0, import_textUtils.cpSlice)(lineContent, 0, cursorCol);
800
+ return {
801
+ ...nextState,
802
+ lines: newLines
803
+ };
804
+ } else if (cursorRow < lines.length - 1) {
805
+ const nextState = pushUndoLocal(state);
806
+ const nextLineContent = currentLine(cursorRow + 1);
807
+ const newLines = [...nextState.lines];
808
+ newLines[cursorRow] = lineContent + nextLineContent;
809
+ newLines.splice(cursorRow + 1, 1);
810
+ return {
811
+ ...nextState,
812
+ lines: newLines,
813
+ preferredCol: null
814
+ };
815
+ }
816
+ return state;
817
+ }
818
+ case "kill_line_left": {
819
+ const { cursorRow, cursorCol } = state;
820
+ if (cursorCol > 0) {
821
+ const nextState = pushUndoLocal(state);
822
+ const lineContent = currentLine(cursorRow);
823
+ const newLines = [...nextState.lines];
824
+ newLines[cursorRow] = (0, import_textUtils.cpSlice)(lineContent, cursorCol);
825
+ return {
826
+ ...nextState,
827
+ lines: newLines,
828
+ cursorCol: 0,
829
+ preferredCol: null
830
+ };
831
+ }
832
+ return state;
833
+ }
834
+ case "undo": {
835
+ const stateToRestore = state.undoStack[state.undoStack.length - 1];
836
+ if (!stateToRestore) return state;
837
+ const currentSnapshot = {
838
+ lines: [...state.lines],
839
+ cursorRow: state.cursorRow,
840
+ cursorCol: state.cursorCol
841
+ };
842
+ return {
843
+ ...state,
844
+ ...stateToRestore,
845
+ undoStack: state.undoStack.slice(0, -1),
846
+ redoStack: [...state.redoStack, currentSnapshot]
847
+ };
848
+ }
849
+ case "redo": {
850
+ const stateToRestore = state.redoStack[state.redoStack.length - 1];
851
+ if (!stateToRestore) return state;
852
+ const currentSnapshot = {
853
+ lines: [...state.lines],
854
+ cursorRow: state.cursorRow,
855
+ cursorCol: state.cursorCol
856
+ };
857
+ return {
858
+ ...state,
859
+ ...stateToRestore,
860
+ redoStack: state.redoStack.slice(0, -1),
861
+ undoStack: [...state.undoStack, currentSnapshot]
862
+ };
863
+ }
864
+ case "replace_range": {
865
+ const { startRow, startCol, endRow, endCol, text } = action.payload;
866
+ const nextState = pushUndoLocal(state);
867
+ return replaceRangeInternal(nextState, startRow, startCol, endRow, endCol, text);
868
+ }
869
+ case "move_to_offset": {
870
+ const { offset } = action.payload;
871
+ const [newRow, newCol] = offsetToLogicalPos(state.lines.join("\n"), offset);
872
+ return {
873
+ ...state,
874
+ cursorRow: newRow,
875
+ cursorCol: newCol,
876
+ preferredCol: null
877
+ };
878
+ }
879
+ case "create_undo_snapshot": {
880
+ return pushUndoLocal(state);
881
+ }
882
+ default:
883
+ return state;
884
+ }
885
+ }
886
+ function textBufferReducer(state, action, options = {}) {
887
+ const newState = textBufferReducerLogic(state, action, options);
888
+ if (newState.lines !== state.lines || newState.viewportWidth !== state.viewportWidth) {
889
+ return {
890
+ ...newState,
891
+ visualLayout: calculateLayout(newState.lines, newState.viewportWidth)
892
+ };
893
+ }
894
+ return newState;
895
+ }
896
+ function useTextBuffer({
897
+ initialText = "",
898
+ initialCursorOffset = 0,
899
+ viewport,
900
+ onChange,
901
+ inputFilter,
902
+ singleLine = false
903
+ }) {
904
+ const initialState = (0, import_react.useMemo)(() => {
905
+ const lines2 = initialText.split("\n");
906
+ const [initialCursorRow, initialCursorCol] = calculateInitialCursorPosition(
907
+ lines2.length === 0 ? [""] : lines2,
908
+ initialCursorOffset
909
+ );
910
+ const visualLayout2 = calculateLayout(lines2.length === 0 ? [""] : lines2, viewport.width);
911
+ return {
912
+ lines: lines2.length === 0 ? [""] : lines2,
913
+ cursorRow: initialCursorRow,
914
+ cursorCol: initialCursorCol,
915
+ preferredCol: null,
916
+ undoStack: [],
917
+ redoStack: [],
918
+ viewportWidth: viewport.width,
919
+ viewportHeight: viewport.height,
920
+ visualLayout: visualLayout2
921
+ };
922
+ }, [initialText, initialCursorOffset, viewport.width, viewport.height]);
923
+ const [state, dispatch] = (0, import_react.useReducer)(
924
+ (s, a) => textBufferReducer(s, a, { inputFilter, singleLine }),
925
+ initialState
926
+ );
927
+ const { lines, cursorRow, cursorCol, preferredCol, visualLayout } = state;
928
+ const text = (0, import_react.useMemo)(() => lines.join("\n"), [lines]);
929
+ const visualCursor = (0, import_react.useMemo)(
930
+ () => calculateVisualCursorFromLayout(visualLayout, [cursorRow, cursorCol]),
931
+ [visualLayout, cursorRow, cursorCol]
932
+ );
933
+ const { visualLines, visualToLogicalMap } = visualLayout;
934
+ const [visualScrollRow, setVisualScrollRow] = (0, import_react.useState)(0);
935
+ (0, import_react.useEffect)(() => {
936
+ if (onChange) {
937
+ onChange(text);
938
+ }
939
+ }, [text, onChange]);
940
+ (0, import_react.useEffect)(() => {
941
+ dispatch({
942
+ type: "set_viewport",
943
+ payload: { width: viewport.width, height: viewport.height }
944
+ });
945
+ }, [viewport.width, viewport.height]);
946
+ (0, import_react.useEffect)(() => {
947
+ const { height } = viewport;
948
+ const totalVisualLines = visualLines.length;
949
+ const maxScrollStart = Math.max(0, totalVisualLines - height);
950
+ let newVisualScrollRow = visualScrollRow;
951
+ if (visualCursor[0] < visualScrollRow) {
952
+ newVisualScrollRow = visualCursor[0];
953
+ } else if (visualCursor[0] >= visualScrollRow + height) {
954
+ newVisualScrollRow = visualCursor[0] - height + 1;
955
+ }
956
+ newVisualScrollRow = clamp(newVisualScrollRow, 0, maxScrollStart);
957
+ if (newVisualScrollRow !== visualScrollRow) {
958
+ setVisualScrollRow(newVisualScrollRow);
959
+ }
960
+ }, [visualCursor, visualScrollRow, viewport, visualLines.length]);
961
+ const insert = (0, import_react.useCallback)(
962
+ (ch, { paste: _paste = false } = {}) => {
963
+ if (!singleLine && /[\n\r]/.test(ch)) {
964
+ dispatch({ type: "insert", payload: ch });
965
+ return;
966
+ }
967
+ let currentText = "";
968
+ for (const char of (0, import_textUtils.toCodePoints)(ch)) {
969
+ if (char.codePointAt(0) === 127) {
970
+ if (currentText.length > 0) {
971
+ dispatch({ type: "insert", payload: currentText });
972
+ currentText = "";
973
+ }
974
+ dispatch({ type: "backspace" });
975
+ } else {
976
+ currentText += char;
977
+ }
978
+ }
979
+ if (currentText.length > 0) {
980
+ dispatch({ type: "insert", payload: currentText });
981
+ }
982
+ },
983
+ [singleLine]
984
+ );
985
+ const newline = (0, import_react.useCallback)(() => {
986
+ if (singleLine) {
987
+ return;
988
+ }
989
+ dispatch({ type: "insert", payload: "\n" });
990
+ }, [singleLine]);
991
+ const backspace = (0, import_react.useCallback)(() => {
992
+ dispatch({ type: "backspace" });
993
+ }, []);
994
+ const del = (0, import_react.useCallback)(() => {
995
+ dispatch({ type: "delete" });
996
+ }, []);
997
+ const move = (0, import_react.useCallback)(
998
+ (dir) => {
999
+ dispatch({ type: "move", payload: { dir } });
1000
+ },
1001
+ [dispatch]
1002
+ );
1003
+ const undo = (0, import_react.useCallback)(() => {
1004
+ dispatch({ type: "undo" });
1005
+ }, []);
1006
+ const redo = (0, import_react.useCallback)(() => {
1007
+ dispatch({ type: "redo" });
1008
+ }, []);
1009
+ const setText = (0, import_react.useCallback)((newText) => {
1010
+ dispatch({ type: "set_text", payload: newText });
1011
+ }, []);
1012
+ const deleteWordLeft = (0, import_react.useCallback)(() => {
1013
+ dispatch({ type: "delete_word_left" });
1014
+ }, []);
1015
+ const deleteWordRight = (0, import_react.useCallback)(() => {
1016
+ dispatch({ type: "delete_word_right" });
1017
+ }, []);
1018
+ const killLineRight = (0, import_react.useCallback)(() => {
1019
+ dispatch({ type: "kill_line_right" });
1020
+ }, []);
1021
+ const killLineLeft = (0, import_react.useCallback)(() => {
1022
+ dispatch({ type: "kill_line_left" });
1023
+ }, []);
1024
+ const setViewport = (0, import_react.useCallback)((width, height) => {
1025
+ dispatch({ type: "set_viewport", payload: { width, height } });
1026
+ }, []);
1027
+ const handleInput = (0, import_react.useCallback)(
1028
+ (key) => {
1029
+ const { sequence: input } = key;
1030
+ if (key.paste) {
1031
+ insert(input, { paste: key.paste });
1032
+ return;
1033
+ }
1034
+ if (!singleLine && (key.name === "return" || input === "\r" || input === "\n" || input === "\\r"))
1035
+ newline();
1036
+ else if (key.name === "left" && !key.meta && !key.ctrl) move("left");
1037
+ else if (key.ctrl && key.name === "b") move("left");
1038
+ else if (key.name === "right" && !key.meta && !key.ctrl) move("right");
1039
+ else if (key.ctrl && key.name === "f") move("right");
1040
+ else if (key.name === "up") move("up");
1041
+ else if (key.name === "down") move("down");
1042
+ else if ((key.ctrl || key.meta) && key.name === "left") move("wordLeft");
1043
+ else if (key.meta && key.name === "b") move("wordLeft");
1044
+ else if ((key.ctrl || key.meta) && key.name === "right") move("wordRight");
1045
+ else if (key.meta && key.name === "f") move("wordRight");
1046
+ else if (key.name === "home") move("home");
1047
+ else if (key.ctrl && key.name === "a") move("home");
1048
+ else if (key.name === "end") move("end");
1049
+ else if (key.ctrl && key.name === "e") move("end");
1050
+ else if (key.ctrl && key.name === "w") deleteWordLeft();
1051
+ else if ((key.meta || key.ctrl) && (key.name === "backspace" || input === "\x7F"))
1052
+ deleteWordLeft();
1053
+ else if ((key.meta || key.ctrl) && key.name === "delete") deleteWordRight();
1054
+ else if (key.name === "backspace" || input === "\x7F" || key.ctrl && key.name === "h")
1055
+ backspace();
1056
+ else if (key.name === "delete" || key.ctrl && key.name === "d") del();
1057
+ else if (key.ctrl && !key.shift && key.name === "z") undo();
1058
+ else if (key.ctrl && key.shift && key.name === "z") redo();
1059
+ else if (key.insertable) {
1060
+ insert(input, { paste: key.paste });
1061
+ }
1062
+ },
1063
+ [
1064
+ newline,
1065
+ move,
1066
+ deleteWordLeft,
1067
+ deleteWordRight,
1068
+ backspace,
1069
+ del,
1070
+ insert,
1071
+ undo,
1072
+ redo,
1073
+ singleLine
1074
+ ]
1075
+ );
1076
+ const renderedVisualLines = (0, import_react.useMemo)(
1077
+ () => visualLines.slice(visualScrollRow, visualScrollRow + viewport.height),
1078
+ [visualLines, visualScrollRow, viewport.height]
1079
+ );
1080
+ const replaceRange = (0, import_react.useCallback)(
1081
+ (startRow, startCol, endRow, endCol, text2) => {
1082
+ dispatch({
1083
+ type: "replace_range",
1084
+ payload: { startRow, startCol, endRow, endCol, text: text2 }
1085
+ });
1086
+ },
1087
+ []
1088
+ );
1089
+ const replaceRangeByOffset = (0, import_react.useCallback)(
1090
+ (startOffset, endOffset, replacementText) => {
1091
+ const [startRow, startCol] = offsetToLogicalPos(text, startOffset);
1092
+ const [endRow, endCol] = offsetToLogicalPos(text, endOffset);
1093
+ replaceRange(startRow, startCol, endRow, endCol, replacementText);
1094
+ },
1095
+ [text, replaceRange]
1096
+ );
1097
+ const moveToOffset = (0, import_react.useCallback)((offset) => {
1098
+ dispatch({ type: "move_to_offset", payload: { offset } });
1099
+ }, []);
1100
+ const moveToVisualPosition = (0, import_react.useCallback)(
1101
+ (visRow, visCol) => {
1102
+ const { visualLines: visualLines2, visualToLogicalMap: visualToLogicalMap2 } = visualLayout;
1103
+ const clampedVisRow = Math.max(0, Math.min(visRow, visualLines2.length - 1));
1104
+ const visualLine = visualLines2[clampedVisRow] || "";
1105
+ if (visualToLogicalMap2[clampedVisRow]) {
1106
+ const [logRow, logStartCol] = visualToLogicalMap2[clampedVisRow];
1107
+ const codePoints = (0, import_textUtils.toCodePoints)(visualLine);
1108
+ let currentVisX = 0;
1109
+ let charOffset = 0;
1110
+ for (const char of codePoints) {
1111
+ const charWidth = (0, import_textUtils.getCachedStringWidth)(char);
1112
+ if (visCol < currentVisX + charWidth) {
1113
+ if (charWidth > 1 && visCol >= currentVisX + charWidth / 2) {
1114
+ charOffset++;
1115
+ }
1116
+ break;
1117
+ }
1118
+ currentVisX += charWidth;
1119
+ charOffset++;
1120
+ }
1121
+ charOffset = Math.min(charOffset, codePoints.length);
1122
+ const newCursorRow = logRow;
1123
+ const newCursorCol = logStartCol + charOffset;
1124
+ dispatch({
1125
+ type: "set_cursor",
1126
+ payload: {
1127
+ cursorRow: newCursorRow,
1128
+ cursorCol: newCursorCol,
1129
+ preferredCol: charOffset
1130
+ }
1131
+ });
1132
+ }
1133
+ },
1134
+ [visualLayout]
1135
+ );
1136
+ const getOffset = (0, import_react.useCallback)(
1137
+ () => logicalPosToOffset(lines, cursorRow, cursorCol),
1138
+ [lines, cursorRow, cursorCol]
1139
+ );
1140
+ const returnValue = (0, import_react.useMemo)(
1141
+ () => ({
1142
+ lines,
1143
+ text,
1144
+ cursor: [cursorRow, cursorCol],
1145
+ preferredCol,
1146
+ allVisualLines: visualLines,
1147
+ viewportVisualLines: renderedVisualLines,
1148
+ visualCursor,
1149
+ visualScrollRow,
1150
+ visualToLogicalMap,
1151
+ setText,
1152
+ insert,
1153
+ newline,
1154
+ backspace,
1155
+ del,
1156
+ move,
1157
+ undo,
1158
+ redo,
1159
+ replaceRange,
1160
+ replaceRangeByOffset,
1161
+ moveToOffset,
1162
+ getOffset,
1163
+ moveToVisualPosition,
1164
+ deleteWordLeft,
1165
+ deleteWordRight,
1166
+ killLineRight,
1167
+ killLineLeft,
1168
+ handleInput,
1169
+ setViewport
1170
+ }),
1171
+ [
1172
+ lines,
1173
+ text,
1174
+ cursorRow,
1175
+ cursorCol,
1176
+ preferredCol,
1177
+ visualLines,
1178
+ renderedVisualLines,
1179
+ visualCursor,
1180
+ visualScrollRow,
1181
+ visualToLogicalMap,
1182
+ setText,
1183
+ insert,
1184
+ newline,
1185
+ backspace,
1186
+ del,
1187
+ move,
1188
+ undo,
1189
+ redo,
1190
+ replaceRange,
1191
+ replaceRangeByOffset,
1192
+ moveToOffset,
1193
+ getOffset,
1194
+ moveToVisualPosition,
1195
+ deleteWordLeft,
1196
+ deleteWordRight,
1197
+ killLineRight,
1198
+ killLineLeft,
1199
+ handleInput,
1200
+ setViewport
1201
+ ]
1202
+ );
1203
+ return returnValue;
1204
+ }
1205
+ // Annotate the CommonJS export names for ESM import in node:
1206
+ 0 && (module.exports = {
1207
+ findNextWordAcrossLines,
1208
+ findNextWordStartInLine,
1209
+ findPrevWordAcrossLines,
1210
+ findPrevWordStartInLine,
1211
+ findWordEndInLine,
1212
+ getLineRangeOffsets,
1213
+ getPositionFromOffsets,
1214
+ logicalPosToOffset,
1215
+ offsetToLogicalPos,
1216
+ pushUndo,
1217
+ replaceRangeInternal,
1218
+ textBufferReducer,
1219
+ useTextBuffer
1220
+ });