@visulima/tui 1.0.0-alpha.22 → 1.0.0-alpha.24

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 (307) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +17 -0
  3. package/dist/components/accordion.js +1 -1
  4. package/dist/components/alert.js +1 -1
  5. package/dist/components/animate-presence.js +1 -1
  6. package/dist/components/approval-prompt.js +1 -1
  7. package/dist/components/area-chart.js +1 -1
  8. package/dist/components/badge.js +1 -1
  9. package/dist/components/bar-chart.js +1 -1
  10. package/dist/components/big-text.js +1 -1
  11. package/dist/components/blink-dot.js +1 -1
  12. package/dist/components/box.d.ts +1 -1
  13. package/dist/components/breadcrumb.js +1 -1
  14. package/dist/components/button.js +1 -1
  15. package/dist/components/calendar.js +1 -1
  16. package/dist/components/canvas.d.ts +1 -1
  17. package/dist/components/canvas.js +1 -1
  18. package/dist/components/card.js +1 -1
  19. package/dist/components/checkbox.js +1 -1
  20. package/dist/components/code.js +2 -2
  21. package/dist/components/collapsible.js +1 -1
  22. package/dist/components/command-block.js +4 -4
  23. package/dist/components/command-palette.js +1 -1
  24. package/dist/components/confirm-dialog.js +1 -1
  25. package/dist/components/confirm-input.js +1 -1
  26. package/dist/components/console-overlay.js +1 -1
  27. package/dist/components/content-switcher.js +1 -1
  28. package/dist/components/controlled-scroll-view.d.ts +1 -1
  29. package/dist/components/controlled-scroll-view.js +1 -1
  30. package/dist/components/cursor.d.ts +1 -1
  31. package/dist/components/cursor.js +1 -1
  32. package/dist/components/date-picker.js +1 -1
  33. package/dist/components/definition-list.js +1 -1
  34. package/dist/components/dialog.d.ts +1 -1
  35. package/dist/components/dialog.js +1 -1
  36. package/dist/components/diff-view.js +1 -1
  37. package/dist/components/divider.js +1 -1
  38. package/dist/components/file-picker-entry.js +1 -1
  39. package/dist/components/form.js +1 -1
  40. package/dist/components/gauge.js +1 -1
  41. package/dist/components/gradient.js +1 -1
  42. package/dist/components/heading.js +1 -1
  43. package/dist/components/heatmap.js +1 -1
  44. package/dist/components/help.js +1 -1
  45. package/dist/components/histogram.js +1 -1
  46. package/dist/components/kbd.js +1 -1
  47. package/dist/components/line-chart.js +1 -1
  48. package/dist/components/link.js +1 -1
  49. package/dist/components/loading-indicator.js +1 -1
  50. package/dist/components/markdown.js +1 -1
  51. package/dist/components/masked-input.js +1 -1
  52. package/dist/components/menu.js +1 -1
  53. package/dist/components/message-bubble.js +1 -1
  54. package/dist/components/model-badge.js +1 -1
  55. package/dist/components/multi-select.js +1 -1
  56. package/dist/components/newline.js +2 -2
  57. package/dist/components/operation-tree.js +1 -1
  58. package/dist/components/option-list.js +1 -1
  59. package/dist/components/ordered-list.js +1 -1
  60. package/dist/components/paginator.js +1 -1
  61. package/dist/components/paragraph.js +1 -1
  62. package/dist/components/placeholder.js +1 -1
  63. package/dist/components/progress-bar.js +1 -1
  64. package/dist/components/radio-group.js +1 -1
  65. package/dist/components/scatter-plot.js +1 -1
  66. package/dist/components/scroll-bar-box.d.ts +1 -1
  67. package/dist/components/scroll-bar-box.js +1 -1
  68. package/dist/components/scroll-bar.d.ts +1 -1
  69. package/dist/components/scroll-bar.js +1 -1
  70. package/dist/components/scroll-list.d.ts +1 -1
  71. package/dist/components/scroll-list.js +1 -1
  72. package/dist/components/scroll-view.d.ts +1 -1
  73. package/dist/components/scroll-view.js +1 -1
  74. package/dist/components/search-input.js +1 -1
  75. package/dist/components/select-input-indicator.js +1 -1
  76. package/dist/components/select-input-item.js +1 -1
  77. package/dist/components/select-input.js +1 -1
  78. package/dist/components/shimmer-text.js +1 -1
  79. package/dist/components/slider.js +1 -1
  80. package/dist/components/spacer.js +1 -1
  81. package/dist/components/sparkline.js +1 -1
  82. package/dist/components/spinner.js +1 -1
  83. package/dist/components/static-render.d.ts +1 -1
  84. package/dist/components/static-render.js +1 -1
  85. package/dist/components/static.js +1 -1
  86. package/dist/components/status-line.js +1 -1
  87. package/dist/components/status-message.js +1 -1
  88. package/dist/components/stepper.js +1 -1
  89. package/dist/components/stopwatch.js +1 -1
  90. package/dist/components/streaming-text.js +1 -1
  91. package/dist/components/switch.js +1 -1
  92. package/dist/components/tab.js +1 -1
  93. package/dist/components/table.js +1 -1
  94. package/dist/components/tabs.js +1 -1
  95. package/dist/components/tag.js +1 -1
  96. package/dist/components/text-input.js +1 -1
  97. package/dist/components/text.js +1 -1
  98. package/dist/components/textarea.js +2 -2
  99. package/dist/components/timer.js +1 -1
  100. package/dist/components/toast.js +1 -1
  101. package/dist/components/tooltip.js +1 -1
  102. package/dist/components/transform.js +1 -1
  103. package/dist/components/transition.js +1 -1
  104. package/dist/components/tree-view-entry.d.ts +1 -1
  105. package/dist/components/tree-view-entry.js +1 -1
  106. package/dist/components/unordered-list.js +1 -1
  107. package/dist/core/index.js +1 -1
  108. package/dist/ink/hooks/use-animation.js +1 -1
  109. package/dist/ink/hooks/use-app.js +1 -1
  110. package/dist/ink/hooks/use-box-metrics.d.ts +1 -1
  111. package/dist/ink/hooks/use-box-metrics.js +1 -1
  112. package/dist/ink/hooks/use-clipboard.js +1 -1
  113. package/dist/ink/hooks/use-color-blindness.js +1 -1
  114. package/dist/ink/hooks/use-console-capture.js +1 -1
  115. package/dist/ink/hooks/use-cursor.js +1 -1
  116. package/dist/ink/hooks/use-focus-manager.js +1 -1
  117. package/dist/ink/hooks/use-focus.js +1 -1
  118. package/dist/ink/hooks/use-form.js +1 -1
  119. package/dist/ink/hooks/use-hotkey.js +1 -1
  120. package/dist/ink/hooks/use-input.js +2 -2
  121. package/dist/ink/hooks/use-interval.js +1 -1
  122. package/dist/ink/hooks/use-is-screen-reader-enabled.js +1 -1
  123. package/dist/ink/hooks/use-key-bindings.js +1 -1
  124. package/dist/ink/hooks/use-key-chord.js +1 -1
  125. package/dist/ink/hooks/use-linked-scroll.d.ts +1 -1
  126. package/dist/ink/hooks/use-linked-scroll.js +1 -1
  127. package/dist/ink/hooks/use-paste.js +1 -1
  128. package/dist/ink/hooks/use-persistent-state.d.ts +12 -3
  129. package/dist/ink/hooks/use-persistent-state.js +2 -2
  130. package/dist/ink/hooks/use-scroll-acceleration.js +1 -1
  131. package/dist/ink/hooks/use-scroll-input.js +1 -1
  132. package/dist/ink/hooks/use-stderr.js +1 -1
  133. package/dist/ink/hooks/use-stdin.js +1 -1
  134. package/dist/ink/hooks/use-stdout.js +1 -1
  135. package/dist/ink/hooks/use-stopwatch.js +1 -1
  136. package/dist/ink/hooks/use-terminal-palette.js +1 -1
  137. package/dist/ink/hooks/use-text-buffer.js +4 -4
  138. package/dist/ink/hooks/use-text-selection.d.ts +2 -2
  139. package/dist/ink/hooks/use-text-selection.js +1 -1
  140. package/dist/ink/hooks/use-timeout.js +1 -1
  141. package/dist/ink/hooks/use-timer.js +1 -1
  142. package/dist/ink/hooks/use-window-size.js +1 -1
  143. package/dist/ink/index.d.ts +17 -62
  144. package/dist/ink/index.js +1 -1
  145. package/dist/ink/mouse/use-element-position.d.ts +31 -0
  146. package/dist/ink/mouse/use-element-position.js +1 -0
  147. package/dist/ink/mouse/use-mouse-action.d.ts +5 -0
  148. package/dist/ink/mouse/use-mouse-action.js +1 -0
  149. package/dist/ink/mouse/use-mouse-position.d.ts +5 -0
  150. package/dist/ink/mouse/use-mouse-position.js +1 -0
  151. package/dist/ink/mouse/use-mouse.d.ts +5 -0
  152. package/dist/ink/mouse/use-mouse.js +1 -0
  153. package/dist/ink/mouse/use-on-mouse-click.d.ts +16 -0
  154. package/dist/ink/mouse/use-on-mouse-click.js +1 -0
  155. package/dist/ink/mouse/use-on-mouse-hover.d.ts +10 -0
  156. package/dist/ink/mouse/use-on-mouse-hover.js +1 -0
  157. package/dist/ink/mouse/use-on-mouse-state.d.ts +13 -0
  158. package/dist/ink/mouse/use-on-mouse-state.js +1 -0
  159. package/dist/packem_chunks/devtools.js +1 -1
  160. package/dist/packem_shared/COLOR_BLINDNESS_COMPENSATION-Ilnoyeqc.js +1 -0
  161. package/dist/packem_shared/ControlledScrollView-BoN5Oi-p.js +1 -0
  162. package/dist/packem_shared/DevTools-k6uiVzqv.js +1 -0
  163. package/dist/packem_shared/FilePicker-BLS9nOPz.js +1 -0
  164. package/dist/packem_shared/FocusContext-C2Sosxa4.js +1 -0
  165. package/dist/packem_shared/Fullscreen-BRhuBLBh.js +1 -0
  166. package/dist/packem_shared/IMECompositionBuffer-VhC9HRCv.js +1 -0
  167. package/dist/packem_shared/InputParser-CtwkCbrQ.js +2 -0
  168. package/dist/packem_shared/KEY-C--kOw41.js +1 -0
  169. package/dist/packem_shared/LayoutNode-LPYsuzBg.js +1 -0
  170. package/dist/packem_shared/MouseProvider-DUqQ3Eaa.js +1 -0
  171. package/dist/packem_shared/NAMED_COLORS-82DpREQV.js +1 -0
  172. package/dist/packem_shared/Range-BsVYNWtg.js +1 -0
  173. package/dist/packem_shared/Renderer-DsskdkUd.js +1 -0
  174. package/dist/packem_shared/ResizeObserver-aX8XOr2u.js +1 -0
  175. package/dist/packem_shared/ScrollBar-BKCK8jsb.js +1 -0
  176. package/dist/packem_shared/ScrollBarBox-CBhLo6eZ.js +1 -0
  177. package/dist/packem_shared/ScrollList-DyFyVs6I.js +1 -0
  178. package/dist/packem_shared/ScrollView-BEgrtSnt.js +1 -0
  179. package/dist/packem_shared/Static-DSzsElz4.js +1 -0
  180. package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +1 -0
  181. package/dist/packem_shared/TreeView-BsvLCsf0.js +1 -0
  182. package/dist/packem_shared/TuiApp-BPL8v1i1.js +1 -0
  183. package/dist/packem_shared/TuiContext-BNmP0lMY.js +3 -0
  184. package/dist/packem_shared/ansi-parser-DlgLtOYO.js +1 -0
  185. package/dist/packem_shared/ansi-tokenizer-BU67A126.js +1 -0
  186. package/dist/packem_shared/braille-ch3O5D7I.js +1 -0
  187. package/dist/packem_shared/calculateScroll-D4Y_JR4H.js +1 -0
  188. package/dist/packem_shared/calculateScrollbarLayout--eUVRLw7.js +1 -0
  189. package/dist/packem_shared/clearOsc52-BUpnQOav.js +1 -0
  190. package/dist/packem_shared/clearStringWidthCache-DKFjfJuB.js +1 -0
  191. package/dist/packem_shared/colorize-DU4YZkp3.js +1 -0
  192. package/dist/packem_shared/controlled-scroll-view-t55HU9L8.js +1 -0
  193. package/dist/packem_shared/createInlineLoop-BT40Wpmx.js +2 -0
  194. package/dist/packem_shared/createScreen-DoYpyL0V.js +3 -0
  195. package/dist/packem_shared/dom-rphpG0kf.js +1 -0
  196. package/dist/packem_shared/{dom.d-DzUPFLuP.d.ts → dom.d-B4kXbaVY.d.ts} +36 -1
  197. package/dist/packem_shared/format-time-fjoQHMxD.js +1 -0
  198. package/dist/packem_shared/{getPathToRoot-BuAM_kmj.js → getPathToRoot-PDJeqiEH.js} +1 -1
  199. package/dist/packem_shared/input-utils-BSWCb4F_.js +1 -0
  200. package/dist/packem_shared/isIntersecting-Bo2npvMR.js +1 -0
  201. package/dist/packem_shared/isTerminalPaletteQuerySupported-BYzmqq9-.js +1 -0
  202. package/dist/packem_shared/kittyFlags-g8ALyoCU.js +1 -0
  203. package/dist/packem_shared/line-chart-C7CUrvVs.js +1 -0
  204. package/dist/packem_shared/load-native-root-binding-DDikxNox.js +1 -0
  205. package/dist/packem_shared/measure-element-Cs7_proT.js +2 -0
  206. package/dist/packem_shared/measure-text-B7juNq4Y.js +3 -0
  207. package/dist/packem_shared/mouse-context.d-BfL9xGk_.d.ts +30 -0
  208. package/dist/packem_shared/parseSgrMouse-bUrqPrh-.js +1 -0
  209. package/dist/packem_shared/processLayout-tAee0ytT.js +1 -0
  210. package/dist/packem_shared/reconciler-ClpU7Y-V.js +1 -0
  211. package/dist/packem_shared/reconciler-DhUGYWCr.js +1 -0
  212. package/dist/packem_shared/render-DFZ8NHlG.js +1 -0
  213. package/dist/packem_shared/render-v2x7ZRzT.js +24 -0
  214. package/dist/packem_shared/{render.d-E2MsoY_g.d.ts → render.d-CBnYBDk2.d.ts} +1 -1
  215. package/dist/packem_shared/renderToString-C2YmVNLG.js +4 -0
  216. package/dist/packem_shared/renderToString-L_bpw4OQ.js +2 -0
  217. package/dist/packem_shared/renderTreeToBuffer-C8lS0lJ2.js +2 -0
  218. package/dist/packem_shared/renderer-COXHo5Xk.js +17 -0
  219. package/dist/packem_shared/{selection.d-FWD8cYY2.d.ts → selection.d-CI3_p8wg.d.ts} +1 -1
  220. package/dist/packem_shared/squashTextNodesWithMap-BmUSBPfc.js +1 -0
  221. package/dist/packem_shared/stderr-context-Bvnik0hL.js +1 -0
  222. package/dist/packem_shared/stdin-context-88AhuztD.js +1 -0
  223. package/dist/packem_shared/text-width-e49vlbQH.js +2 -0
  224. package/dist/packem_shared/token-to-elements-D6J6-P2A.js +1 -0
  225. package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +1 -0
  226. package/dist/packem_shared/useTreeView-D5ifGwG3.js +1 -0
  227. package/dist/packem_shared/useTreeViewState-BiTJakkh.js +1 -0
  228. package/dist/packem_shared/utils-Bup8lyK8.js +1 -0
  229. package/dist/packem_shared/waitFor-CTAki32d.js +4 -0
  230. package/dist/packem_shared/wrapOrTruncateStyledLine-46W8bTtv.js +3 -0
  231. package/dist/react/index.js +1 -1
  232. package/dist/testing/index.d.ts +2 -2
  233. package/dist/testing/index.js +1 -1
  234. package/index.js +691 -539
  235. package/package.json +48 -23
  236. package/dist/packem_shared/COLOR_BLINDNESS_SIMULATION-DqErf7XX.js +0 -1
  237. package/dist/packem_shared/ControlledScrollView-CIc-x1Cx.js +0 -1
  238. package/dist/packem_shared/DevTools-ClAYpMVI.js +0 -1
  239. package/dist/packem_shared/FilePicker-tYj_CIau.js +0 -1
  240. package/dist/packem_shared/FocusContext-Xy0cwJpO.js +0 -1
  241. package/dist/packem_shared/Fullscreen-CxLd1-Zu.js +0 -1
  242. package/dist/packem_shared/IMECompositionBuffer-C89PhiOu.js +0 -1
  243. package/dist/packem_shared/InputParser-B_qZcN3r.js +0 -2
  244. package/dist/packem_shared/KEY-Bk8B-3h_.js +0 -1
  245. package/dist/packem_shared/LayoutNode-B8zej4dm.js +0 -1
  246. package/dist/packem_shared/MouseProvider-PnIUKURs.js +0 -1
  247. package/dist/packem_shared/NAMED_COLORS-B9fJsYdg.js +0 -1
  248. package/dist/packem_shared/Renderer-DJXooAsp.js +0 -1
  249. package/dist/packem_shared/ResizeObserverEntry-Dq0dk8Kq.js +0 -1
  250. package/dist/packem_shared/ScrollBar-U_37hlIT.js +0 -1
  251. package/dist/packem_shared/ScrollBarBox-DwiCxilX.js +0 -1
  252. package/dist/packem_shared/ScrollList-C7nZ9ufK.js +0 -1
  253. package/dist/packem_shared/ScrollView-DKZ8OM-m.js +0 -1
  254. package/dist/packem_shared/Static-DLynr5pn.js +0 -1
  255. package/dist/packem_shared/TreeNodeMap-CspqSCpb.js +0 -1
  256. package/dist/packem_shared/TreeView-C0Iv3et8.js +0 -1
  257. package/dist/packem_shared/TuiApp-BVDXP0Cv.js +0 -1
  258. package/dist/packem_shared/TuiContext-BoJvG3NN.js +0 -3
  259. package/dist/packem_shared/ansi-parser-B6uXaq65.js +0 -1
  260. package/dist/packem_shared/ansi-tokenizer-DqX9nJuk.js +0 -1
  261. package/dist/packem_shared/braille-BBjIoaN0.js +0 -1
  262. package/dist/packem_shared/colorize-DbTZMrJO.js +0 -1
  263. package/dist/packem_shared/comparePoints-C3NJirbh.js +0 -1
  264. package/dist/packem_shared/controlled-scroll-view-CcUS50jx.js +0 -1
  265. package/dist/packem_shared/createInlineLoop-DRNZ7jqH.js +0 -2
  266. package/dist/packem_shared/createScreen-CrLrxA6t.js +0 -3
  267. package/dist/packem_shared/dom-CXB-19sK.js +0 -1
  268. package/dist/packem_shared/format-time-C7Q-hQZq.js +0 -1
  269. package/dist/packem_shared/getScrollHeight-ClEOyLHH.js +0 -1
  270. package/dist/packem_shared/input-utils-fAxzSlNh.js +0 -1
  271. package/dist/packem_shared/isIntersecting-B3KbKTmu.js +0 -1
  272. package/dist/packem_shared/isOsc52Supported-DKK7Uee6.js +0 -1
  273. package/dist/packem_shared/isTerminalPaletteQuerySupported-Dn2hFAZ_.js +0 -1
  274. package/dist/packem_shared/kittyFlags-C3rZLbcK.js +0 -1
  275. package/dist/packem_shared/layout-BMo200nF.js +0 -2
  276. package/dist/packem_shared/line-chart-kf7uhR0K.js +0 -1
  277. package/dist/packem_shared/measure-text-Ce2widM1.js +0 -3
  278. package/dist/packem_shared/measureElement-BTtTFZg4.js +0 -1
  279. package/dist/packem_shared/parseSgrMouse-Ccj70ijb.js +0 -1
  280. package/dist/packem_shared/processLayout-FEKj_mWu.js +0 -1
  281. package/dist/packem_shared/reconciler-DIfG72R9.js +0 -1
  282. package/dist/packem_shared/reconciler-DYE5h4K4.js +0 -1
  283. package/dist/packem_shared/render-BRR1ESvR.js +0 -26
  284. package/dist/packem_shared/render-Dh7HMhK1.js +0 -1
  285. package/dist/packem_shared/renderToString-BbQiRHrd.js +0 -2
  286. package/dist/packem_shared/renderToString-vEQyGmv6.js +0 -4
  287. package/dist/packem_shared/renderTreeToBuffer-CZilzyhN.js +0 -2
  288. package/dist/packem_shared/renderer-maLLQcut.js +0 -17
  289. package/dist/packem_shared/setEnableStyledLineCache-DSbMbENc.js +0 -1
  290. package/dist/packem_shared/squashTextNodesWithMap-DCdi3SZ2.js +0 -1
  291. package/dist/packem_shared/stderr-context-BzEaUICS.js +0 -1
  292. package/dist/packem_shared/stdin-context-BTaaFagk.js +0 -1
  293. package/dist/packem_shared/text-width-BU2eeTWn.js +0 -2
  294. package/dist/packem_shared/token-to-elements-BAZpNZsu.js +0 -1
  295. package/dist/packem_shared/treeViewTheme-1RIZyB4M.js +0 -1
  296. package/dist/packem_shared/useElementDimensions-qJ_WXFZ9.js +0 -1
  297. package/dist/packem_shared/useMouseAction-2dRfU1vE.js +0 -1
  298. package/dist/packem_shared/useMouseContext-C746G7kY.js +0 -1
  299. package/dist/packem_shared/useMousePosition-BTWfV4JK.js +0 -1
  300. package/dist/packem_shared/useOnMouseClick-nY8xLZmt.js +0 -1
  301. package/dist/packem_shared/useOnMouseHover-D3DczIol.js +0 -1
  302. package/dist/packem_shared/useOnMouseState-cRK8QvzD.js +0 -1
  303. package/dist/packem_shared/useTreeView-BoMMeRPq.js +0 -1
  304. package/dist/packem_shared/useTreeViewState-CRPCUWrb.js +0 -1
  305. package/dist/packem_shared/utils-CoviI5Vm.js +0 -1
  306. package/dist/packem_shared/waitFor-Dj5zfL5s.js +0 -4
  307. package/dist/packem_shared/wrapOrTruncateStyledLine-C5rcIrNb.js +0 -3
@@ -0,0 +1 @@
1
+ import e from"yoga-layout";const o={black:0,blackBright:8,blue:4,blueBright:12,cyan:6,cyanBright:14,gray:8,green:2,greenBright:10,grey:8,magenta:5,magentaBright:13,red:1,redBright:9,white:7,whiteBright:15,yellow:3,yellowBright:11};function a(n,t,r){const i=Math.round(n/51),s=Math.round(t/51),E=Math.round(r/51);return 16+36*i+6*s+E}function I(n){if(n===void 0)return 255;if(typeof n=="number")return n;if(n in o)return o[n];const t=/^ansi256\(\s*(\d+)\s*\)$/.exec(n);if(t)return Number(t[1]);const r=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(n);if(r)return a(Number.parseInt(r[1]+r[1],16),Number.parseInt(r[2]+r[2],16),Number.parseInt(r[3]+r[3],16));const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(n);if(i)return a(Number.parseInt(i[1],16),Number.parseInt(i[2],16),Number.parseInt(i[3],16));const s=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/.exec(n);return s?a(Number(s[1]),Number(s[2]),Number(s[3])):255}const g=[["top",e.EDGE_TOP],["right",e.EDGE_RIGHT],["bottom",e.EDGE_BOTTOM],["left",e.EDGE_LEFT]],d=(n,t)=>{"position"in t&&n.setPositionType(t.position==="absolute"?e.POSITION_TYPE_ABSOLUTE:e.POSITION_TYPE_RELATIVE);for(const[r,i]of g)if(r in t){const s=t[r];typeof s=="string"?n.setPositionPercent(i,Number.parseFloat(s)):n.setPosition(i,s)}},_=(n,t)=>{"margin"in t&&n.setMargin(e.EDGE_ALL,t.margin??0),"marginX"in t&&n.setMargin(e.EDGE_HORIZONTAL,t.marginX??0),"marginY"in t&&n.setMargin(e.EDGE_VERTICAL,t.marginY??0),"marginLeft"in t&&n.setMargin(e.EDGE_LEFT,t.marginLeft??0),"marginRight"in t&&n.setMargin(e.EDGE_RIGHT,t.marginRight??0),"marginTop"in t&&n.setMargin(e.EDGE_TOP,t.marginTop??0),"marginBottom"in t&&n.setMargin(e.EDGE_BOTTOM,t.marginBottom??0)},f=(n,t)=>{"padding"in t&&n.setPadding(e.EDGE_ALL,t.padding??0),"paddingX"in t&&n.setPadding(e.EDGE_HORIZONTAL,t.paddingX??0),"paddingY"in t&&n.setPadding(e.EDGE_VERTICAL,t.paddingY??0),"paddingLeft"in t&&n.setPadding(e.EDGE_LEFT,t.paddingLeft??0),"paddingRight"in t&&n.setPadding(e.EDGE_RIGHT,t.paddingRight??0),"paddingTop"in t&&n.setPadding(e.EDGE_TOP,t.paddingTop??0),"paddingBottom"in t&&n.setPadding(e.EDGE_BOTTOM,t.paddingBottom??0)},l=(n,t)=>{if("flexGrow"in t&&n.setFlexGrow(t.flexGrow??0),"flexShrink"in t&&n.setFlexShrink(t.flexShrink??1),"flexWrap"in t&&n.setFlexWrap(t.flexWrap==="nowrap"?e.WRAP_NO_WRAP:t.flexWrap==="wrap"?e.WRAP_WRAP:e.WRAP_WRAP_REVERSE),"flexDirection"in t&&(t.flexDirection==="row"&&n.setFlexDirection(e.FLEX_DIRECTION_ROW),t.flexDirection==="row-reverse"&&n.setFlexDirection(e.FLEX_DIRECTION_ROW_REVERSE),t.flexDirection==="column"&&n.setFlexDirection(e.FLEX_DIRECTION_COLUMN),t.flexDirection==="column-reverse"&&n.setFlexDirection(e.FLEX_DIRECTION_COLUMN_REVERSE)),"flexBasis"in t&&(typeof t.flexBasis=="number"?n.setFlexBasis(t.flexBasis):typeof t.flexBasis=="string"?n.setFlexBasisPercent(Number.parseInt(t.flexBasis,10)):n.setFlexBasis(Number.NaN)),"alignItems"in t){const r={baseline:e.ALIGN_BASELINE,center:e.ALIGN_CENTER,"flex-end":e.ALIGN_FLEX_END,"flex-start":e.ALIGN_FLEX_START,stretch:e.ALIGN_STRETCH};n.setAlignItems(r[t.alignItems||"stretch"])}if("alignSelf"in t){const r={auto:e.ALIGN_AUTO,baseline:e.ALIGN_BASELINE,center:e.ALIGN_CENTER,"flex-end":e.ALIGN_FLEX_END,"flex-start":e.ALIGN_FLEX_START,stretch:e.ALIGN_STRETCH};n.setAlignSelf(r[t.alignSelf||"auto"])}if("alignContent"in t){const r={center:e.ALIGN_CENTER,"flex-end":e.ALIGN_FLEX_END,"flex-start":e.ALIGN_FLEX_START,"space-around":e.ALIGN_SPACE_AROUND,"space-between":e.ALIGN_SPACE_BETWEEN,stretch:e.ALIGN_STRETCH};n.setAlignContent(r[t.alignContent||"flex-start"])}if("justifyContent"in t){const r={center:e.JUSTIFY_CENTER,"flex-end":e.JUSTIFY_FLEX_END,"flex-start":e.JUSTIFY_FLEX_START,"space-around":e.JUSTIFY_SPACE_AROUND,"space-between":e.JUSTIFY_SPACE_BETWEEN,"space-evenly":e.JUSTIFY_SPACE_EVENLY};n.setJustifyContent(r[t.justifyContent||"flex-start"])}},p=(n,t)=>{"width"in t&&(typeof t.width=="number"?n.setWidth(t.width):typeof t.width=="string"?n.setWidthPercent(Number.parseInt(t.width,10)):n.setWidthAuto()),"height"in t&&(typeof t.height=="number"?n.setHeight(t.height):typeof t.height=="string"?n.setHeightPercent(Number.parseInt(t.height,10)):n.setHeightAuto()),"minWidth"in t&&(typeof t.minWidth=="string"?n.setMinWidthPercent(Number.parseInt(t.minWidth,10)):n.setMinWidth(t.minWidth??0)),"minHeight"in t&&(typeof t.minHeight=="string"?n.setMinHeightPercent(Number.parseInt(t.minHeight,10)):n.setMinHeight(t.minHeight??0)),"maxWidth"in t&&(typeof t.maxWidth=="string"?n.setMaxWidthPercent(Number.parseInt(t.maxWidth,10)):n.setMaxWidth(t.maxWidth)),"maxHeight"in t&&(typeof t.maxHeight=="string"?n.setMaxHeightPercent(Number.parseInt(t.maxHeight,10)):n.setMaxHeight(t.maxHeight)),"aspectRatio"in t&&n.setAspectRatio(t.aspectRatio)},T=(n,t)=>{"display"in t&&n.setDisplay(t.display==="flex"?e.DISPLAY_FLEX:e.DISPLAY_NONE)},h=(n,t,r)=>{if(!("borderStyle"in t||"borderTop"in t||"borderBottom"in t||"borderLeft"in t||"borderRight"in t))return;const i=r.borderStyle?1:0;n.setBorder(e.EDGE_TOP,r.borderTop===!1?0:i),n.setBorder(e.EDGE_BOTTOM,r.borderBottom===!1?0:i),n.setBorder(e.EDGE_LEFT,r.borderLeft===!1?0:i),n.setBorder(e.EDGE_RIGHT,r.borderRight===!1?0:i)},m=(n,t)=>{"gap"in t&&n.setGap(e.GUTTER_ALL,t.gap??0),"columnGap"in t&&n.setGap(e.GUTTER_COLUMN,t.columnGap??0),"rowGap"in t&&n.setGap(e.GUTTER_ROW,t.rowGap??0)},c=(n,t={},r=t)=>{d(n,t),_(n,t),f(n,t),l(n,t),p(n,t),T(n,t),h(n,t,r),m(n,t)};export{o as NAMED_COLORS,c as applyStyles,I as resolveColor};
@@ -0,0 +1 @@
1
+ import{g}from"./dom-rphpG0kf.js";import{t as p}from"./measure-text-B7juNq4Y.js";import{squashTextNodesWithMap as m}from"./squashTextNodesWithMap-BmUSBPfc.js";const O=r=>{if(r.nodeName==="#text"){const s=p(r.nodeValue);return{charOffsetMap:new Map([[r,{end:s.length,start:0}]]),styledLine:s}}const t=new Map,e=m(r,t,{current:0}),n=p(e);return t.set(r,{end:n.length,start:0}),{charOffsetMap:t,styledLine:n}},N=(r,t)=>{if(!r.startContainer||!r.endContainer)return;const e=(i,h)=>{const o=t.get(i);if(!o)return;if(i.nodeName==="#text")return o.start+h;const d=i;if(h>=d.childNodes.length)return o.end;const a=d.childNodes[h],c=t.get(a);if(c)return c.start;for(let f=h-1;f>=0;f--){const l=d.childNodes[f],u=t.get(l);if(u)return u.end}return o.start},n=e(r.startContainer,r.startOffset),s=e(r.endContainer,r.endOffset);if(!(n===void 0||s===void 0))return{end:s,start:n}},C=(r,t,e,n)=>{if(r===e)return t===n?0:t<n?-1:1;const s=g(r),i=g(e);let h,o=0;for(;o<s.length&&o<i.length&&s[o]===i[o];)h=s[o],o++;if(!h)return 0;if(o===s.length){const l=i[o],u=r.childNodes.indexOf(l);return t<=u?-1:1}if(o===i.length){const l=s[o];return e.childNodes.indexOf(l)<n?-1:1}const d=s[o],a=i[o],c=h.childNodes.indexOf(d),f=h.childNodes.indexOf(a);return c<f?-1:1};class S{startContainer=void 0;startOffset=0;endContainer=void 0;endOffset=0;collapsed=!0;commonAncestorContainer=void 0;setStart(t,e){this.startContainer=t,this.startOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}setEnd(t,e){this.endContainer=t,this.endOffset=e,this.updateCollapsed(),this.updateCommonAncestor()}collapse(t){t?(this.endContainer=this.startContainer,this.endOffset=this.startOffset):(this.startContainer=this.endContainer,this.startOffset=this.endOffset),this.collapsed=!0,this.updateCommonAncestor()}selectNode(t){if(!t.parentNode)throw new Error("Node has no parent");const e=t.parentNode.childNodes.indexOf(t);this.setStart(t.parentNode,e),this.setEnd(t.parentNode,e+1)}selectNodeContents(t){this.setStart(t,0),t.nodeName==="#text"?this.setEnd(t,t.nodeValue.length):this.setEnd(t,t.childNodes.length)}toString(){if(this.collapsed||!this.startContainer||!this.endContainer||!this.commonAncestorContainer)return"";const{charOffsetMap:t,styledLine:e}=O(this.commonAncestorContainer),n=N(this,t);if(!n)return"";const s=e.slice(n.start,n.end);return s.getTextRange(0,s.length)}updateCollapsed(){this.collapsed=this.startContainer===this.endContainer&&this.startOffset===this.endOffset}updateCommonAncestor(){if(!this.startContainer||!this.endContainer){this.commonAncestorContainer=void 0;return}if(this.startContainer===this.endContainer){this.commonAncestorContainer=this.startContainer;return}const t=g(this.startContainer),e=g(this.endContainer);let n;for(let s=0;s<Math.min(t.length,e.length)&&t[s]===e[s];s++)n=t[s];this.commonAncestorContainer=n}}class y{anchorNode=void 0;anchorOffset=0;focusNode=void 0;focusOffset=0;isCollapsed=!0;rangeCount=0;ranges=[];listeners=new Set;onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}toString(){return this.ranges.map(t=>t.toString()).join("")}getRangeAt(t){return this.ranges[t]}addRange(t){this.ranges.includes(t)||(this.ranges.push(t),this.rangeCount=this.ranges.length,this.rangeCount===1&&(this.anchorNode=t.startContainer,this.anchorOffset=t.startOffset,this.focusNode=t.endContainer,this.focusOffset=t.endOffset,this.isCollapsed=t.collapsed),this.notifyChange())}removeRange(t){const e=this.ranges.indexOf(t);e!==-1&&(this.ranges.splice(e,1),this.rangeCount=this.ranges.length,this.rangeCount===0&&this.clearState(),this.notifyChange())}removeAllRanges(){this.ranges=[],this.rangeCount=0,this.clearState(),this.notifyChange()}collapse(t,e){this.removeAllRanges();const n=new S;n.setStart(t,e),n.setEnd(t,e),this.addRange(n)}containsNode(t,e=!1){if(!t.parentNode)return!1;const n=t.parentNode,s=n.childNodes.indexOf(t),i=n,h=s,o=n,d=s+1;return this.ranges.some(a=>{if(!a.startContainer||!a.endContainer)return!1;const c=C(a.startContainer,a.startOffset,i,h),f=C(a.endContainer,a.endOffset,o,d);if(e){const l=C(a.startContainer,a.startOffset,o,d),u=C(a.endContainer,a.endOffset,i,h);return l<0&&u>0}return c<=0&&f>=0})}clearState(){this.anchorNode=void 0,this.anchorOffset=0,this.focusNode=void 0,this.focusOffset=0,this.isCollapsed=!0}notifyChange(){for(const t of this.listeners)t()}}const M=(r,t)=>{if(r.length===0||t.start>=t.end)return r;const e=r.clone(),n=Math.max(0,t.start),s=Math.min(r.length,t.end);for(let i=n;i<s;i++)e.setInverted(i,!0);return e};export{S as Range,y as Selection,M as applySelectionToStyledLine,C as comparePoints};
@@ -0,0 +1 @@
1
+ import{p as r}from"./load-native-root-binding-DDikxNox.js";const n=r(import.meta.url),e=n,m=e.Renderer,t=e.TerminalGuard,a=e.terminalSize;export{m as Renderer,t as TerminalGuard,a as terminalSize};
@@ -0,0 +1 @@
1
+ class d{constructor(e,s){this.target=e,this.contentRect=s}target;contentRect}class l{callback;observedElements=new Set;constructor(e){this.callback=e}observe(e){if(this.observedElements.has(e))return;this.observedElements.add(e),e.resizeObservers??=new Set,e.resizeObservers.add(this);let s=e.internal_lastMeasuredSize;if(s===void 0&&e.yogaNode){const i=Math.round(e.yogaNode.getComputedWidth()),t=Math.round(e.yogaNode.getComputedHeight());!Number.isNaN(i)&&!Number.isNaN(t)&&(s={height:t,width:i},e.internal_lastMeasuredSize=s)}if(s){const i=new d(e,s);try{this.callback([i],this)}catch(t){console.error(t)}}}unobserve(e){this.observedElements.delete(e),e.resizeObservers?.delete(this)}disconnect(){for(const e of this.observedElements)e.resizeObservers?.delete(this);this.observedElements.clear()}internalTrigger(e){try{this.callback(e,this)}catch(s){console.error(s)}}}function h(r,e,s=!1){const i=r.resizeObservers&&r.resizeObservers.size>0;if((i||s)&&r.yogaNode){const t=Math.round(r.yogaNode.getComputedWidth()),o=Math.round(r.yogaNode.getComputedHeight());if(!Number.isNaN(t)&&!Number.isNaN(o)){const a=r.internal_lastMeasuredSize;if((a?.width!==t||a.height!==o)&&(r.internal_lastMeasuredSize={height:o,width:t},i)){const c=new d(r,{height:o,width:t});for(const n of r.resizeObservers)e.has(n)||e.set(n,[]),e.get(n).push(c)}}}}function b(r,e=!1){const s=new Map;function i(t){if(h(t,s,e),!t.internal_static)for(const o of t.childNodes)o.nodeName!=="#text"&&i(o)}i(r);for(const[t,o]of s)t.internalTrigger(o)}export{d as ResizeObserverEntry,l as default,h as measureAndExtractObservers,b as triggerResizeObservers};
@@ -0,0 +1 @@
1
+ import{jsx as i,jsxs as F}from"react/jsx-runtime";import{useMemo as I}from"react";import{Box as H}from"../components/box.js";import{Text as n}from"../components/text.js";const S={arrow:{lowerThumb:"╽",thumb:"┃",track:"|",upperThumb:"╿"},block:{thumb:"█",track:"░"},bold:{lowerThumb:"╿",thumb:"│",track:"┃",upperThumb:"╽"},classic:{thumb:"┃",track:"|"},dots:{thumb:"●",track:"·"},double:{thumb:"┃",track:"║"},doubleSingle:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},line:{thumb:"│",track:" "},round:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},single:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},singleDouble:{thumb:"┃",track:"║"},thick:{thumb:"┃",track:"╏"}},B={arrow:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},bold:{bottomLeft:"┗",bottomRight:"┛",topLeft:"┏",topRight:"┓"},classic:{bottomLeft:"+",bottomRight:"+",topLeft:"+",topRight:"+"},double:{bottomLeft:"╚",bottomRight:"╝",topLeft:"╔",topRight:"╗"},doubleSingle:{bottomLeft:"╘",bottomRight:"╛",topLeft:"╒",topRight:"╕"},round:{bottomLeft:"╰",bottomRight:"╯",topLeft:"╭",topRight:"╮"},single:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},singleDouble:{bottomLeft:"╙",bottomRight:"╜",topLeft:"╓",topRight:"╖"}},Y=t=>S[typeof t=="string"?t:"single"]??S.single??{thumb:"┃",track:"│"},_=t=>B[typeof t=="string"?t:"single"]??B.single??{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},N=({autoHide:t=!1,color:m,contentHeight:L,dimColor:l,placement:p="right",scrollOffset:R,style:c,thumbChar:k,trackChar:x,viewportHeight:e})=>{const a=I(()=>{const r=Math.max(L,e);if(t&&r<=e)return null;const o=Y(c),f=k??o.thumb,q=x??o.track,w=e*2,v=Math.min(e/r,1),T=Math.max(2,Math.round(w*v)),M=r-e,A=M>0?Math.min(Math.max(R/M,0),1):0,E=w-T,s=Math.round(A*E),C=s+T,h=[];for(let b=0;b<e;b+=1){const D=b*2,y=b*2+1,g=D>=s&&D<C,d=y>=s&&y<C;g&&d?h.push(f):g&&!d?h.push(o.lowerThumb??f):!g&&d?h.push(o.upperThumb??f):h.push(q)}return h},[L,e,R,c,k,x,t]);if(a===null)return null;if(p==="inset")return i(H,{flexDirection:"column",flexShrink:0,width:1,children:a.map((r,o)=>i(n,{color:m,dimColor:l,children:r},o))});const u=_(c),j=p==="left"?u.topLeft:u.topRight,O=p==="left"?u.bottomLeft:u.bottomRight;return F(H,{flexDirection:"column",flexShrink:0,width:1,children:[i(n,{color:m,dimColor:l,children:j}),a.map((r,o)=>i(n,{color:m,dimColor:l,children:r},o)),i(n,{color:m,dimColor:l,children:O})]})};export{N as ScrollBar,N as default};
@@ -0,0 +1 @@
1
+ import{jsxs as D,jsx as l}from"react/jsx-runtime";import{Box as a}from"../components/box.js";import{ScrollBar as b}from"./ScrollBar-BKCK8jsb.js";const L=({borderColor:r,borderDimColor:e,borderLeftColor:g,borderLeftDimColor:C,borderRightColor:p,borderRightDimColor:H,borderStyle:t="single",children:u,contentHeight:i,height:x,scrollBarAutoHide:h=!1,scrollBarPosition:w="right",scrollOffset:d,thumbChar:s,viewportHeight:f,...B})=>{const o=w==="left",c=o?"left":"right",m=o?g??r:p??r,n=o?C??e:H??e;return D(a,{flexDirection:"row",height:x,...B,children:[o&&l(b,{autoHide:h,color:m,contentHeight:i,dimColor:n,placement:c,scrollOffset:d,style:t,thumbChar:s,viewportHeight:f}),l(a,{borderColor:r,borderDimColor:e,borderLeft:!o,borderRight:o,borderStyle:t,flexGrow:1,overflow:"hidden",children:u}),!o&&l(b,{autoHide:h,color:m,contentHeight:i,dimColor:n,placement:c,scrollOffset:d,style:t,thumbChar:s,viewportHeight:f})]})};export{L as ScrollBarBox,L as default};
@@ -0,0 +1 @@
1
+ import{jsx as Y}from"react/jsx-runtime";import{useRef as d,useState as K,useEffect as y,useCallback as g,useImperativeHandle as N}from"react";import Q from"../ink/hooks/use-scroll-input.js";import{C as U}from"./controlled-scroll-view-t55HU9L8.js";const et=O=>{const{children:P,keyboard:A=!1,onContentHeightChange:V,onItemHeightChange:B,onScroll:T,onViewportSizeChange:b,overscan:E,ref:L,scrollAlignment:h="auto",selectedIndex:p,vimBindings:R=!1,virtualize:j,...q}=O,n=d(null),[s,D]=K(0),C=d(0);y(()=>{C.current=s},[s]);const o=g(t=>{t!==C.current&&(D(t),T?.(t))},[T]),a=d(p);a.current=p;const S=g(()=>{const t=a.current;if(t===void 0||t<0)return null;const e=n.current?.getItemPosition(t);if(!e)return null;const i=n.current?.getViewportHeight()??0,l=n.current?.getContentHeight()??0;let r=e.top+e.height-i,c=e.top;r>c&&([r,c]=[c,r]);const M=Math.max(0,l-i);return{max:Math.min(M,c),min:Math.max(0,r)}},[]),u=g(t=>{const e=n.current?.getContentHeight()??0,i=n.current?.getViewportHeight()??0,l=Math.max(0,e-i);let r=Math.max(0,Math.min(t,l));const c=S();return c&&(r=Math.max(c.min,Math.min(r,c.max))),r},[S]),m=g((t,e,i,l)=>{const r=n.current?.getItemPosition(t);if(!r)return e;const c=l??n.current?.getViewportHeight()??0,M=n.current?.getContentHeight()??0;let f=e;switch(i){case"bottom":{f=r.top+r.height-c;break}case"center":{f=r.top+r.height/2-c/2;break}case"top":{f=r.top;break}default:{const w=r.top+r.height;r.top<=e&&w>=e+c?f=e:r.top<e?f=r.top:w>e+c&&(f=w-c)}}const X=Math.max(0,M-c);return Math.max(0,Math.min(f,X))},[]);let H=s;p!==void 0&&p>=0&&(H=m(p,s,h)),y(()=>{H!==s&&o(H)},[H,s,o]);const k=g((t,e)=>{if(a.current!==void 0&&a.current>=0){const i=m(a.current,s,h,t.height);o(i)}b?.(t,e)},[b,m,s,h,o]),F=g((t,e,i)=>{const l=a.current;if(l!==void 0&&l>=0){if(t<l){const r=u(s+(e-i));o(r)}else if(t===l){const r=m(t,s,h);o(r)}}B?.(t,e,i)},[B,m,h,s,u,o]),G=g((t,e)=>{if(a.current!==void 0&&a.current>=0){const i=m(a.current,s,h);o(i)}V?.(t,e)},[V,m,s,h,o]),z=d(0),x=g(t=>{const e=C.current,i=u(e+t);o(i)},[u,o]),v=g(()=>{const t=n.current?.getContentHeight()??0,e=n.current?.getViewportHeight()??0,i=Math.max(0,t-e),l=u(i);o(l)},[u,o]),I=g(()=>{const t=u(0);o(t)},[u,o]),J=g(()=>z.current,[]);Q({getViewportHeight:J,isActive:A,scrollBy:x,scrollToBottom:v,scrollToTop:I,vimBindings:R}),N(L,()=>({getBottomOffset:()=>n.current?.getBottomOffset()??0,getContentHeight:()=>n.current?.getContentHeight()??0,getItemHeight:t=>n.current?.getItemHeight(t)??0,getItemPosition:t=>n.current?.getItemPosition(t)??null,getScrollOffset:()=>C.current,getViewportHeight:()=>n.current?.getViewportHeight()??0,remeasure:()=>n.current?.remeasure(),remeasureItem:t=>n.current?.remeasureItem(t),scrollBy:x,scrollTo:t=>{const e=u(t);o(e)},scrollToBottom:v,scrollToTop:I}),[u,o,x,v,I]);const W=g((t,e)=>{z.current=t.height,k(t,e)},[k]);return Y(U,{onContentHeightChange:G,onItemHeightChange:F,onViewportSizeChange:W,overscan:E,ref:n,scrollOffset:H,virtualize:j,...q,children:P})};export{et as ScrollList};
@@ -0,0 +1 @@
1
+ import{jsxs as X,jsx as v}from"react/jsx-runtime";import{useRef as h,useState as E,useCallback as o,useImperativeHandle as _}from"react";import $ from"../ink/hooks/use-scroll-input.js";import{Box as ee}from"../components/box.js";import{f as re,C as F}from"./controlled-scroll-view-t55HU9L8.js";import{ScrollBar as te}from"./ScrollBar-BKCK8jsb.js";const se=({children:I,debug:B=!1,followOutput:M=!1,followThreshold:T=3,keyboard:W=!1,onContentHeightChange:z,onItemHeightChange:y,onReachEnd:g,onReachStart:p,onScroll:V,onViewportSizeChange:N,overscan:O,reachThreshold:a=5,ref:Y,scrollbar:Z=!1,scrollbarColor:q,scrollbarStyle:J="line",vimBindings:K=!1,virtualize:G,...m})=>{const[d,k,n]=re(0),c=h(null),s=h(0),l=h(0),[D,L]=E(0),[x,Q]=E(0),C=h(!1),w=h(!1),i=o(()=>Math.max(0,s.current-l.current),[]),P=o(e=>{const t=i();g&&e>=t-a&&!C.current?(C.current=!0,g()):e<t-a&&(C.current=!1),p&&e<=a&&!w.current?(w.current=!0,p()):e>a&&(w.current=!1)},[g,p,a,i]),r=o(e=>{e!==n()&&(k(e),V?.(e),P(e))},[n,k,V,P]),j=o((e,t)=>{const u=n()>=i()-T;if(s.current=e,L(e),z?.(e,t),M&&u&&e>t){const f=Math.max(0,e-l.current);r(f)}else{const f=Math.max(0,e-l.current);n()>f&&r(f)}},[z,M,T,n,i,r]),A=o((e,t)=>{l.current=e.height,Q(e.height),N?.(e,t)},[N]),H=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const t=Math.max(0,s.current-l.current),u=Math.max(0,Math.min(n()+e,t));r(u)},[n,r]),R=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const t=Math.max(0,s.current-l.current),u=Math.max(0,Math.min(e,t));r(u)},[r]),b=o(()=>{const e=i();r(e)},[i,r]),S=o(()=>{r(0)},[r]),U=o(()=>l.current,[]);return $({getViewportHeight:U,isActive:W,scrollBy:H,scrollToBottom:b,scrollToTop:S,vimBindings:K}),_(Y,()=>({getBottomOffset:i,getContentHeight:()=>s.current,getItemHeight:e=>c.current?.getItemHeight(e)??0,getItemPosition:e=>c.current?.getItemPosition(e)??null,getScrollOffset:n,getViewportHeight:()=>l.current,remeasure:()=>c.current?.remeasure(),remeasureItem:e=>c.current?.remeasureItem(e),scrollBy:H,scrollTo:R,scrollToBottom:b,scrollToTop:S}),[i,n,H,R,b,S]),Z&&D>x&&x>0?X(ee,{flexDirection:"row",flexGrow:m.flexGrow,flexShrink:m.flexShrink,overflow:"hidden",children:[v(F,{children:I,debug:B,onContentHeightChange:j,onItemHeightChange:y,onViewportSizeChange:A,overscan:O,ref:c,scrollOffset:d,virtualize:G,...m,flexGrow:1}),v(te,{color:q,contentHeight:D,placement:"inset",scrollOffset:d,style:J,viewportHeight:x})]}):v(F,{children:I,debug:B,onContentHeightChange:j,onItemHeightChange:y,onViewportSizeChange:A,overscan:O,ref:c,scrollOffset:d,virtualize:G,...m})};export{se as ScrollView};
@@ -0,0 +1 @@
1
+ import i,{useRef as o,useMemo as s}from"react";function m({children:u,items:t,style:r}){const c=o([]),n=o(0);if(t.length>n.current){for(let e=n.current;e<t.length;e++)c.current.push(u(t[e],e));n.current=t.length}const l=s(()=>({flexDirection:"column",...r}),[r]);return i.createElement("box",l,...c.current)}export{m as Static};
@@ -0,0 +1 @@
1
+ class g{orderedIds;rootIds;map;constructor(i){this.map=new Map,this.orderedIds=[],this.rootIds=[],this.buildFromData(i)}entries(){return this.map.entries()}get(i){return this.map.get(i)}get size(){return this.map.size}getVisibleIds(i){const d=[],n=[];for(let e=this.rootIds.length-1;e>=0;e--)n.push(this.rootIds[e]);for(;n.length>0;){const e=n.pop();d.push(e);const s=this.map.get(e);if(s&&i.has(e)&&s.childrenIds.length>0)for(let t=s.childrenIds.length-1;t>=0;t--)n.push(s.childrenIds[t])}return d}isDescendantOf(i,d){let n=i;for(;n!==void 0;){const e=this.map.get(n);if(!e)return!1;if(e.parentId===d)return!0;n=e.parentId}return!1}withChildren(i,d){if(!this.map.get(i))return this;const n=s=>{const t=this.map.get(s);return s===i?{...t.node,children:d}:t.childrenIds.length>0?{...t.node,children:t.childrenIds.map(p=>n(p))}:t.node},e=this.rootIds.map(s=>n(s));return new g(e)}buildFromData(i){const d=[];for(let e=i.length-1;e>=0;e--)d.push({depth:0,node:i[e],parentId:void 0,siblingIndex:e,siblings:i});for(const e of i)this.rootIds.push(e.id);let n=0;for(;d.length>0;){const e=d.pop(),{depth:s,node:t,parentId:p,siblingIndex:o,siblings:l}=e;if(this.map.has(t.id))throw new Error(`TreeView: Duplicate node id '${t.id}' found. All node ids must be unique.`);const h=t.children??[],a=h.length>0||t.isParent===!0,u=h.map(r=>r.id),I=o>0?l[o-1].id:void 0,c=o<l.length-1?l[o+1].id:void 0,f={childrenIds:u,depth:s,flatIndex:n,hasChildren:a,nextSiblingId:c,node:t,parentId:p,previousSiblingId:I,siblingCount:l.length,siblingIndex:o};if(this.map.set(t.id,f),this.orderedIds.push(t.id),n++,a)for(let r=h.length-1;r>=0;r--)d.push({depth:s+1,node:h[r],parentId:t.id,siblingIndex:r,siblings:h})}}}export{g as TreeNodeMap};
@@ -0,0 +1 @@
1
+ import{jsxs as b,jsx as a}from"react/jsx-runtime";import L from"../ink/hooks/use-is-screen-reader-enabled.js";import{Box as v}from"../components/box.js";import{Text as n}from"../components/text.js";import{theme as M}from"./treeViewTheme-Dq3ekRAC.js";import{useTreeView as y}from"./useTreeView-D5ifGwG3.js";import{useTreeViewState as j}from"./useTreeViewState-BiTJakkh.js";const V="❯",D="▾",k="▸",A="☒",P="☐",R="✔",B="⟳";function N(t,r,i,l){const{depth:c,hasChildren:m,isExpanded:o,isLoading:u,isSelected:x}=r,d=[t,`item ${i} of ${l}`];return c>0&&d.push(`depth ${c}`),m&&d.push(o?"expanded":"collapsed"),u&&d.push("loading"),x&&d.push("selected"),d.join(", ")}function F(t,r){const i={};return t.hasChildren&&(i.expanded=t.isExpanded),r!=="none"&&(i.selected=t.isSelected),Object.keys(i).length>0?i:void 0}function O({isScreenReaderEnabled:t,node:r,nodeState:i,selectionMode:l,siblingCount:c,siblingPosition:m,styles:o}){const{depth:u,hasChildren:x,isExpanded:d,isFocused:h,isLoading:s,isSelected:C}=i;let e=" ";s?e=B:x&&(e=d?D:k);const f=t?N(r.label,i,m,c):void 0;return b(v,{...o.node({isFocused:h}),"aria-role":"listitem","aria-state":F(i,l),children:[f&&a(n,{"aria-label":f}),h&&a(n,{...o.focusIndicator(),"aria-hidden":!0,children:V}),u>0&&a(v,{...o.indent({depth:u}),"aria-hidden":!0}),l==="multiple"&&a(n,{...o.selectedIndicator(),"aria-hidden":!0,children:C?A:P}),a(n,{...s?o.loadingIndicator():o.expandIndicator({isExpanded:d}),"aria-hidden":!0,children:e}),a(n,{...o.label({isFocused:h,isSelected:C}),children:r.label}),l==="single"&&C&&b(n,{...o.selectedIndicator(),"aria-hidden":!0,children:[" ",R]})]})}function Q({ariaLabel:t="Tree view",data:r,defaultExpanded:i,defaultSelected:l,isDisabled:c=!1,loadChildren:m,onExpandChange:o,onFocusChange:u,onLoadError:x,onSelectChange:d,renderNode:h,selectionMode:s="none",visibleNodeCount:C}){const e=j({data:r,defaultExpanded:i,defaultSelected:l,onExpandChange:o,onFocusChange:u,onSelectChange:d,selectionMode:s,visibleNodeCount:C});y({isDisabled:c,loadChildren:m,onLoadError:x,selectionMode:s,state:e});const{styles:f}=M,w=L();return b(v,{...f.container(),"aria-role":"list",children:[w&&a(n,{"aria-label":t}),e.hasScrollUp&&b(n,{"aria-label":`${e.viewportFromIndex} more items above`,dimColor:!0,children:[" ","↑",e.viewportFromIndex," ","more above"]}),e.viewportNodes.map(({node:p,state:g})=>{const S=e.nodeMap.get(p.id),E=S?S.siblingIndex+1:1,I=S?S.siblingCount:1;if(h){const T=w?N(p.label,g,E,I):void 0;return b(v,{"aria-role":"listitem","aria-state":F(g,s),children:[T&&a(n,{"aria-label":T}),h({node:p,state:g})]},p.id)}return a(O,{isScreenReaderEnabled:w,node:p,nodeState:g,selectionMode:s,siblingCount:I,siblingPosition:E,styles:f},p.id)}),e.hasScrollDown&&b(n,{"aria-label":`${e.visibleCount-e.viewportToIndex} more items below`,dimColor:!0,children:[" ","↓",e.visibleCount-e.viewportToIndex," ","more below"]})]})}export{Q as TreeView};
@@ -0,0 +1 @@
1
+ import{createDecMode as h,setMode as n,resetMode as u}from"@visulima/ansi";import{EventEmitter as f}from"tseep";import{Renderer as i,TerminalGuard as o}from"./Renderer-DsskdkUd.js";const s=h(2026),d=n(s),w=u(s);class B extends f{renderer;terminal=null;backBuffer;width;height;isRunning=!1;stdoutBuffer=[];stderrBuffer=[];constructor(){super(),this.width=process.stdout.columns||80,this.height=process.stdout.rows||24,this.renderer=new i(this.width,this.height),this.backBuffer=new Uint32Array(this.width*this.height*2)}start(){this.isRunning||(this.terminal=new o(!0),this.isRunning=!0)}quit(){this.emit("quit")}stop(){this.isRunning=!1,this.terminal?.leave(),this.terminal=null,this.stdoutBuffer.length>0&&(process.stdout.write(this.stdoutBuffer.join("")),this.stdoutBuffer=[]),this.stderrBuffer.length>0&&(process.stderr.write(this.stderrBuffer.join("")),this.stderrBuffer=[])}writeStdout(t){this.isRunning?this.stdoutBuffer.push(t):process.stdout.write(t)}writeStderr(t){this.isRunning?this.stderrBuffer.push(t):process.stderr.write(t)}getBuffer(){return this.backBuffer}getSize(){return{height:this.height,width:this.width}}resize(t,e){this.width=t,this.height=e,this.renderer=new i(t,e),this.backBuffer=new Uint32Array(t*e*2)}beforeFlushListeners=[];onBeforeFlush(t){return this.beforeFlushListeners.push(t),()=>{this.beforeFlushListeners=this.beforeFlushListeners.filter(e=>e!==t)}}paintNow(t,e){if(this.isRunning){t(this.width,this.height),e(this.backBuffer,this.width,this.height);for(const r of this.beforeFlushListeners)r(this.backBuffer,this.width,this.height);this.renderer.writeRaw(d);try{this.renderer.render(this.backBuffer)}finally{this.renderer.writeRaw(w)}}}}export{B as TuiApp};
@@ -0,0 +1,3 @@
1
+ import{createContext as z,useContext as g,useState as M,useCallback as x,useEffect as d,useMemo as I,useRef as b}from"react";const m=z(null),k=Object.freeze({backspace:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,leftArrow:!1,meta:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,tab:!1,upArrow:!1}),f=e=>({...k,...e}),B=e=>{const t=g(m);if(!t)throw new Error("useInput must be used within a TUI App environment");const r=b(e);d(()=>{r.current=e}),d(()=>{const u=n=>{switch(n){case"backspace":return r.current("",f({backspace:!0}));case"delete":return r.current("",f({delete:!0}));case"down":return r.current("",f({downArrow:!0}));case"end":return r.current("",f({end:!0}));case"enter":return r.current("",f({return:!0}));case"escape":return r.current("",f({escape:!0}));case"home":return r.current("",f({home:!0}));case"left":return r.current("",f({leftArrow:!0}));case"pageDown":return r.current("",f({pageDown:!0}));case"pageUp":return r.current("",f({pageUp:!0}));case"right":return r.current("",f({rightArrow:!0}));case"shift-tab":return r.current("",f({shift:!0,tab:!0}));case"tab":return r.current("",f({tab:!0}));case"up":return r.current("",f({upArrow:!0}))}},c=n=>{r.current(n,f({ctrl:!0}))},s=n=>{r.current(n,f({meta:!0}))},o=(n,w)=>{n.startsWith("\x1B")||n==="\r"||n===`
2
+ `||r.current(n,f({ctrl:w?.ctrl??!1,meta:w?.meta??!1}))};return t.input.on("keydown",u),t.input.on("ctrl",c),t.input.on("meta",s),t.input.on("data",o),()=>{t.input.off("keydown",u),t.input.off("ctrl",c),t.input.off("meta",s),t.input.off("data",o)}},[t])},N=(e,t={})=>{const r=g(m);if(!r)throw new Error("usePaste must be used within a TUI App environment");const{isActive:u=!0}=t,c=b(e);d(()=>{c.current=e}),d(()=>{if(!u)return;const s=o=>{c.current(o)};return r.input.on("paste",s),()=>{r.input.off("paste",s)}},[r,u])},W=()=>{const e=g(m);if(!e)throw new Error("useTuiContext must be used within a TUI App environment");return e},q=()=>{const e=g(m);if(!e)throw new Error("useApp must be used within a TUI App environment");return{exit:()=>e.app.quit(),quit:()=>e.app.quit()}},H=()=>{const e=g(m);if(!e)throw new Error("useWindowSize must be used within a TUI App environment");const[t,r]=M(()=>e.app.getSize());return d(()=>{const u=()=>r(e.app.getSize());return e.app.on("resize",u),()=>{e.app.off("resize",u)}},[e]),{columns:t.width,rows:t.height}},E=e=>e.replaceAll(/\r?\n/g,`\r
3
+ `),P=()=>{const e=g(m);return{stdout:process.stdout,write:t=>{e?e.writeStdout(t):process.stdout.write(E(t))}}},F=()=>{const e=g(m);return{stderr:process.stderr,write:t=>{e?e.writeStderr(t):process.stderr.write(E(t))}}},V=()=>{const e=!!process.stdin.setRawMode;return{isRawModeSupported:e,setRawMode:t=>{e&&process.stdin.setRawMode(t)},stdin:process.stdin}},j=e=>!e||!e.yogaNode?{height:0,width:0}:{height:e.yogaNode.getComputedHeight()??0,width:e.yogaNode.getComputedWidth()??0},R={height:0,left:0,top:0,width:0},L=e=>{const t=g(m),[r,u]=M(R),[c,s]=M(!1),o=x(()=>{if(!e.current?.yogaNode){s(!1);return}const n=e.current.getLayout();u(w=>w.width===n.width&&w.height===n.height&&w.left===n.left&&w.top===n.top?w:{height:n.height,left:n.left,top:n.top,width:n.width}),s(!0)},[e]);return d(o),d(()=>{if(t?.app)return t.app.on("resize",o),()=>{t.app.off("resize",o)}},[t,o]),I(()=>({...r,hasMeasured:c}),[r,c])},O=()=>!1,$=()=>({setCursorPosition:e=>{}}),G=({contentHeight:e,viewportHeight:t})=>{const[r,u]=M(0),c=Math.max(0,e-t),s=x(o=>Math.max(0,Math.min(o,c)),[c]);return d(()=>{u(o=>s(o))},[c,s]),I(()=>({atBottom:s(r)>=c,atTop:s(r)<=0,offset:s(r),scrollBy:o=>u(n=>s(n+o)),scrollDown:()=>u(o=>s(o+1)),scrollToBottom:()=>u(c),scrollToTop:()=>u(0),scrollUp:()=>u(o=>s(o-1))}),[r,c,s])},J=e=>{const t=g(m);if(!t)throw new Error("useMouse must be used within a TUI App environment");const r=b(e);d(()=>{r.current=e}),d(()=>{const u=c=>r.current(c);return t.input.on("mouse",u),()=>{t.input.off("mouse",u)}},[t])},K=({initialValue:e="",isActive:t=!0,onChange:r,onSubmit:u}={})=>{const[c,s]=M(e),[o,n]=M(e.length),w=b(c),v=b(o);d(()=>{w.current=c}),d(()=>{v.current=o});const A=b(r);d(()=>{A.current=r});const C=b(u);d(()=>{C.current=u});const U=x(h=>{s(h),n(h.length)},[]),y=x(()=>{s(""),n(0),A.current?.("")},[]);B((h,p)=>{if(!t)return;const{current:a}=v,l=w.current;if(p.return){C.current?.(l);return}if(!p.escape){if(p.leftArrow){n(Math.max(0,a-1));return}if(p.rightArrow){n(Math.min(l.length,a+1));return}if(p.home||p.ctrl&&h==="a"){n(0);return}if(p.end||p.ctrl&&h==="e"){n(l.length);return}if(p.backspace){if(a===0)return;const i=l.slice(0,a-1)+l.slice(a);s(i),n(a-1),A.current?.(i);return}if(p.delete){if(a>=l.length)return;const i=l.slice(0,a)+l.slice(a+1);s(i),A.current?.(i);return}if(p.ctrl&&h==="u"){const i=l.slice(a);s(i),n(0),A.current?.(i);return}if(p.ctrl&&h==="k"){const i=l.slice(0,a);s(i),A.current?.(i);return}if(p.ctrl&&h==="w"){const i=l.slice(0,a).replace(/\S+\s*$/,""),S=i+l.slice(a);s(S),n(i.length),A.current?.(S);return}if(!(p.ctrl||p.meta)&&h&&h.length>0){const i=l.slice(0,a)+h+l.slice(a);s(i),n(a+h.length),A.current?.(i)}}});const T=g(m);return d(()=>{if(!T||!t)return;const h=p=>{const a=p.replaceAll(/[\u0000-\u0008\u000B-\u001F\u007F]/g,"").replaceAll(/\r\n?/g," "),{current:l}=v,i=w.current,S=i.slice(0,l)+a+i.slice(l);s(S),n(l+a.length),A.current?.(S)};return T.input.on("paste",h),()=>{T.input.off("paste",h)}},[T,t]),{clear:y,cursor:o,setValue:U,value:c}};export{m as TuiContext,j as measureElement,q as useApp,L as useBoxMetrics,$ as useCursor,B as useInput,O as useIsScreenReaderEnabled,J as useMouse,N as usePaste,G as useScrollable,F as useStderr,V as useStdin,P as useStdout,K as useTextInput,W as useTuiContext,H as useWindowSize};
@@ -0,0 +1 @@
1
+ import{enableNormalMouse as f,enableAnyEventMouse as m,enableSgrMouse as c,disableSgrMouse as d,disableAnyEventMouse as a,disableNormalMouse as b}from"@visulima/ansi";const g={mouseButton:{off:b,on:f},mouseMotion:{off:a,on:m},mouseMotionOthers:{off:"\x1B[?1015l",on:"\x1B[?1015h"},mouseSGR:{off:d,on:c}},p=/\[<(\d+);(\d+);(\d+)(M)$/i,y={0:"left",1:"middle",2:"right"},M={32:"left",33:"middle",34:"right"},N=i=>{const o=p.exec(i);if(!o)return;const l=Number(o[1]),t=Number(o[2]),r=Number(o[3]),n=o[4]==="m",e=l&-29;if(e===64||e===65)return{direction:e===64?"scrollup":"scrolldown",type:"scroll",x:t,y:r};if(e===35)return{type:"move",x:t,y:r};const s=M[e];if(s)return{action:n?"release":"press",button:s,type:"drag",x:t,y:r};const u=y[e];if(u)return{action:n?"release":"press",button:u,type:"click",x:t,y:r}};export{g as M,N as d};
@@ -0,0 +1 @@
1
+ const v=t=>{const r=t.codePointAt(0);return r!==void 0&&r>=48&&r<=63},y=t=>{const r=t.codePointAt(0);return r!==void 0&&r>=32&&r<=47},m=t=>{const r=t.codePointAt(0);return r!==void 0&&r>=64&&r<=126},f=t=>{const r=t.codePointAt(0);return r!==void 0&&r>=32&&r<=47},x=t=>{const r=t.codePointAt(0);return r!==void 0&&r>=48&&r<=126},h=t=>{const r=t.codePointAt(0);return r!==void 0&&r>=128&&r<=159},p=(t,r)=>{let n=r;for(;n<t.length;){const s=t[n];if(!v(s))break;n++}const e=t.slice(r,n),a=n;for(;n<t.length;){const s=t[n];if(!y(s))break;n++}const l=t.slice(a,n),i=t[n];if(!(i===void 0||!m(i)))return{endIndex:n+1,finalCharacter:i,intermediateString:l,parameterString:e}},d=(t,r,n)=>{for(let e=r;e<t.length;e++){const a=t[e];if(n&&a==="\x07"||a==="œ")return e+1;if(a==="\x1B"){const l=t[e+1];if(l==="\x1B"){e++;continue}if(l==="\\")return e+2}}},g=(t,r)=>{let n=r;for(;n<t.length;){const l=t[n];if(!f(l))break;n++}const e=t.slice(r,n),a=t[n];if(!(a===void 0||!x(a)))return{endIndex:n+1,finalCharacter:a,intermediateString:e}},B=t=>{switch(t){case"]":return{allowBellTerminator:!0,type:"osc"};case"^":return{allowBellTerminator:!1,type:"pm"};case"_":return{allowBellTerminator:!1,type:"apc"};case"P":return{allowBellTerminator:!1,type:"dcs"};case"X":return{allowBellTerminator:!1,type:"sos"};default:return}},w=t=>{switch(t){case"Ÿ":return{allowBellTerminator:!1,type:"apc"};case"":return{allowBellTerminator:!1,type:"dcs"};case"":return{allowBellTerminator:!0,type:"osc"};case"ž":return{allowBellTerminator:!1,type:"pm"};case"˜":return{allowBellTerminator:!1,type:"sos"};default:return}},S=t=>{if(t.includes("\x1B"))return!0;for(const r of t)if(h(r))return!0;return!1},c=(t,r,n,e)=>(e>n&&t.push({type:"text",value:r.slice(n,e)}),t.push({type:"invalid",value:r.slice(e)}),t),T=t=>{if(!S(t))return[{type:"text",value:t}];const r=[];let n=0;for(let e=0;e<t.length;){const a=t[e];if(a===void 0)break;if(a==="\x1B"){const i=t[e+1];if(i===void 0)return c(r,t,n,e);if(i==="["){const o=p(t,e+2);if(o===void 0)return c(r,t,n,e);e>n&&r.push({type:"text",value:t.slice(n,e)}),r.push({finalCharacter:o.finalCharacter,intermediateString:o.intermediateString,parameterString:o.parameterString,type:"csi",value:t.slice(e,o.endIndex)}),e=o.endIndex,n=e;continue}const s=B(i);if(s!==void 0){const o=d(t,e+2,s.allowBellTerminator);if(o===void 0)return c(r,t,n,e);e>n&&r.push({type:"text",value:t.slice(n,e)}),r.push({type:s.type,value:t.slice(e,o)}),e=o,n=e;continue}const u=g(t,e+1);if(u===void 0){if(f(i))return c(r,t,n,e);e>n&&r.push({type:"text",value:t.slice(n,e)}),e++,n=e;continue}e>n&&r.push({type:"text",value:t.slice(n,e)}),r.push({finalCharacter:u.finalCharacter,intermediateString:u.intermediateString,type:"esc",value:t.slice(e,u.endIndex)}),e=u.endIndex,n=e;continue}if(a==="›"){const i=p(t,e+1);if(i===void 0)return c(r,t,n,e);e>n&&r.push({type:"text",value:t.slice(n,e)}),r.push({finalCharacter:i.finalCharacter,intermediateString:i.intermediateString,parameterString:i.parameterString,type:"csi",value:t.slice(e,i.endIndex)}),e=i.endIndex,n=e;continue}const l=w(a);if(l!==void 0){const i=d(t,e+1,l.allowBellTerminator);if(i===void 0)return c(r,t,n,e);e>n&&r.push({type:"text",value:t.slice(n,e)}),r.push({type:l.type,value:t.slice(e,i)}),e=i,n=e;continue}if(a==="œ"){e>n&&r.push({type:"text",value:t.slice(n,e)}),r.push({type:"st",value:a}),e++,n=e;continue}if(h(a)){e>n&&r.push({type:"text",value:t.slice(n,e)}),r.push({type:"c1",value:a}),e++,n=e;continue}e++}return n<t.length&&r.push({type:"text",value:t.slice(n)}),r};export{S as h,T as t};
@@ -0,0 +1 @@
1
+ const w=[1,8,2,16,4,32,64,128],A=(l,c)=>{const p=Math.max(0,l*2),x=Math.max(0,c*4),f=new Uint8Array(l*c),s=new Uint8Array(l*c),m=(a,r)=>{if(a<0||r<0||a>=p||r>=x)return;const h=Math.floor(a/2),i=Math.floor(r/4),t=a%2,o=r%4,e=w[o*2+t],n=i*l+h;(f[n]&e)===0&&(f[n]=(f[n]??0)|e,s[n]=1)};return{cellHeight:c,cellWidth:l,clear:()=>{f.fill(0),s.fill(0)},flush:(a,r)=>{for(const[h,i]of f.entries()){if(s[h]===0)continue;const t=h%l,o=Math.floor(h/l),e=10240+i;a.setCell(t,o,e,r)}},pixelHeight:x,pixelWidth:p,plotLine:(a,r,h,i)=>{let t=Math.round(a),o=Math.round(r);const e=Math.round(h),n=Math.round(i),M=Math.abs(e-t),g=t<e?1:-1,u=-Math.abs(n-o),k=o<n?1:-1;let d=M+u;for(;m(t,o),!(t===e&&o===n);){const y=2*d;if(y>=u){if(t===e)break;d+=u,t+=g}if(y<=M){if(o===n)break;d+=M,o+=k}}},plotPoint:m}};export{A as c};
@@ -0,0 +1 @@
1
+ import o from"yoga-layout";const m=t=>{const{yogaNode:e}=t;if(!e)return{scrollHeight:0,scrollWidth:0};const a=e.getComputedBorder(o.EDGE_TOP),s=e.getComputedBorder(o.EDGE_LEFT);let c=a,r=e.getComputedPadding(o.EDGE_LEFT);for(let n=0;n<e.getChildCount();n++){const l=e.getChild(n),i=l.getComputedTop()+l.getComputedHeight()+l.getComputedMargin(o.EDGE_BOTTOM);i>c&&(c=i);const d=l.getComputedLeft()+l.getComputedWidth()+l.getComputedMargin(o.EDGE_RIGHT);d>r&&(r=d)}const h=c-a+e.getComputedPadding(o.EDGE_BOTTOM),g=r-s+e.getComputedPadding(o.EDGE_RIGHT);return{scrollHeight:Math.round(h),scrollWidth:Math.round(g)}},p=t=>Math.round(t.internal_scrollState?.scrollHeight??0),E=t=>Math.round(t.internal_scrollState?.scrollWidth??0),T=t=>{const{yogaNode:e}=t;if(!e)return;const{scrollHeight:a,scrollWidth:s}=m(t);let c=a;const r=Math.max(0,e.getComputedHeight()-e.getComputedBorder(o.EDGE_TOP)-e.getComputedBorder(o.EDGE_BOTTOM));if(t.style.stableScrollback&&t.style.overflowToBackbuffer){const l=Math.max(0,a-r);if(t.internal_isScrollbackDirty)t.internal_maxScrollTop=l,t.internal_isScrollbackDirty=!1;else{const i=Math.max(t.internal_maxScrollTop??0,l),{maxScrollbackLength:d}=t.style;t.internal_maxScrollTop=d===void 0?i:Math.min(i,l+Math.max(0,d))}c=Math.max(a,(t.internal_maxScrollTop??0)+r)}const h=Math.max(0,Math.min(t.style.scrollTop??0,c-r)),g=Math.max(0,e.getComputedWidth()-e.getComputedBorder(o.EDGE_LEFT)-e.getComputedBorder(o.EDGE_RIGHT)),n=Math.max(0,Math.min(t.style.scrollLeft??0,s-g));t.internal_scrollState={actualScrollHeight:a,clientHeight:r,clientWidth:g,scrollHeight:c,scrollLeft:n,scrollTop:h,scrollWidth:s}},M=t=>Math.round(t.internal_scrollState?.scrollTop??0),_=t=>Math.round(t.internal_scrollState?.scrollLeft??0);export{T as calculateScroll,p as getScrollHeight,_ as getScrollLeft,M as getScrollTop,E as getScrollWidth};
@@ -0,0 +1 @@
1
+ import"yoga-layout";import{c as r,a as g,b as i,R as s,g as c,d as n,e as d,f as u,h as b,i as m,j as B,k as S,l as h}from"./measure-element-Cs7_proT.js";import"./calculateScroll-D4Y_JR4H.js";import"./squashTextNodesWithMap-BmUSBPfc.js";export{r as calculateScrollbarLayout,g as calculateScrollbarThumb,i as collectSortedFragments,s as default,c as getAddedScrollHeight,n as getBoundingBox,d as getHorizontalScrollbarBoundingBox,u as getInnerHeight,b as getInnerWidth,m as getRelativeLeft,B as getRelativeTop,S as getText,h as getVerticalScrollbarBoundingBox};
@@ -0,0 +1 @@
1
+ const o=new Set(["Alacritty","contour","foot","Ghostty","iTerm2","iTerm.app","kitty","rio","WezTerm"]),n=()=>{const r=process.env.TERM_PROGRAM??"";if(o.has(r))return!0;const t=process.env.TERM??"";return!!(t.startsWith("xterm")||process.env.WT_SESSION||process.env.TMUX||t.startsWith("screen"))},c=new Set(["c","p","s"]),i=(r,t,e="c")=>{if(!c.has(e))throw new Error(`Invalid clipboard target: ${e}`);const s=Buffer.from(t,"utf8").toString("base64");r.write(`\x1B]52;${e};${s}\x07`)},a=(r,t="c")=>{r.write(`\x1B]52;${t};\x07`)};export{a as clearOsc52,n as isOsc52Supported,i as writeOsc52};
@@ -0,0 +1 @@
1
+ import"@visulima/string";import{c as i,a as s,y as n,i as d,m as l,s as r,b as c,k as h,d as y,t as S}from"./measure-text-B7juNq4Y.js";export{i as clearStringWidthCache,s as clearStyledLineCache,n as default,d as inkCharacterWidth,l as measureStyledLine,r as setEnableStyledLineCache,c as setStringWidthFunction,h as splitStyledLineByNewline,y as styledLineWidth,S as toStyledLine};
@@ -0,0 +1 @@
1
+ import t from"@visulima/colorize";const g=/^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/,c=/^ansi256\(\s?(\d+)\s?\)$/,f=r=>r in t,b=(r,n,i)=>{if(!n)return r;if(f(n)){if(i==="foreground")return t[n](r);const s=`bg${n[0].toUpperCase()+n.slice(1)}`;return t[s](r)}if(n.startsWith("#"))return i==="foreground"?t.hex(n)(r):t.bgHex(n)(r);if(n.startsWith("ansi256")){const s=c.exec(n);if(!s)return r;const o=Number(s[1]);return i==="foreground"?t.ansi256(o)(r):t.bgAnsi256(o)(r)}if(n.startsWith("rgb")){const s=g.exec(n);if(!s)return r;const o=Number(s[1]),u=Number(s[2]),e=Number(s[3]);return i==="foreground"?t.rgb(o,u,e)(r):t.bgRgb(o,u,e)(r)}return r},d=r=>{const n=b("x",r,"background");if(n!=="x")return n.split("x")[0]};export{b as a,d as g};
@@ -0,0 +1 @@
1
+ import{jsx as v,jsxs as rr}from"react/jsx-runtime";import{useState as J,useRef as d,useCallback as j,useLayoutEffect as T,isValidElement as z,useImperativeHandle as tr,Fragment as q}from"react";import{R as K}from"./measure-element-Cs7_proT.js";import{Box as H}from"../components/box.js";const G=u=>{const[g,m]=J(u),l=d(u),k=j(C=>{const E=typeof C=="function"?C(l.current):C;l.current=E,m(E)},[]),y=j(()=>l.current,[]);return[g,k,y]},er=({children:u,index:g,measureKey:m,onMeasure:l,width:k})=>{const y=d(null);return T(()=>{if(y.current){const{height:C}=K(y.current);l(g,C)}},[g,l,k,m,u]),v(H,{flexDirection:"column",flexShrink:0,ref:y,width:"100%",children:u})},B=u=>{if(u==null)return[];if(Array.isArray(u)){const g=[];for(let m=0;m<u.length;m+=1){const l=u[m];z(l)&&l.type===q?g.push(...B(l.props.children)):g.push(l)}return g}return z(u)&&u.type===q?B(u.props.children):[u]},ir=({children:u,debug:g=!1,onContentHeightChange:m,onItemHeightChange:l,onViewportSizeChange:k,overscan:y=3,ref:C,scrollOffset:E,virtualize:N=!1,...Q})=>{const D=d(!1),[$,X,S]=G({height:0,width:0}),[I,O,R]=G(0),[U,Z]=J({}),V=d(null),b=d(0);T(()=>{I!==b.current&&(m?.(I,b.current),b.current=I)},[I,m]);const o=d({}),h=d([]),p=d([]),f=d(0),W=j((r,t)=>{const e=h.current[r]??r;if(o.current[e]!==t){const i=o.current[e]??0;o.current={...o.current,[e]:t};let n=0;for(let s=0;s<h.current.length;s+=1){const x=h.current[s];x!=null&&(n+=o.current[x]??0)}const c=R();n!==c&&O(n),l?.(r,t,i),f.current=Math.min(f.current,r+1)}},[l,R,O]),F=j(()=>{if(V.current){const{height:r,width:t}=K(V.current),e=S();(t!==e.width||r!==e.height)&&(k?.({height:r,width:t},e),X({height:r,width:t}))}},[V,k,S,X]);T(()=>{F()});const _=d(null);if(_.current!==u){_.current=u;const r=[],t={};B(u).forEach((n,c)=>{if(!n)return;const s=(z(n)?n.key:null)??c;r[c]=s;const x=o.current[s]??0;t[s]=x}),o.current=t,h.current=r,p.current=Array.from({length:r.length}).fill(0),f.current=0;let e=0;r.forEach(n=>{e+=t[n]??0});const i=R();e!==i&&O(e)}tr(C,()=>({getBottomOffset:()=>Math.max(0,R()-S().height),getContentHeight:R,getItemHeight:r=>{const t=h.current[r]??r;return o.current[t]??0},getItemPosition:r=>{if(r<0||r>=h.current.length)return null;if(r>=f.current){let i=0,n=0;if(f.current>0){n=f.current;const c=n-1,s=h.current[c]??c,x=o.current[s]??0;i=(p.current[c]??0)+x}for(let c=n;c<=r;c+=1){p.current[c]=i;const s=h.current[c]??c,x=o.current[s]??0;i+=x}f.current=r+1}const t=p.current[r]??0,e=h.current[r]??r;return{height:o.current[e]??0,top:t}},getViewportHeight:()=>S().height,remeasure:F,remeasureItem:r=>{Z(t=>({...t,[r]:(t[r]??0)+1}))}}),[F,R,S,Z]);const M=B(u);!D.current&&I>0&&(D.current=!0);let w=0,a=M.length-1,L=0,P=0;const Y=M.length>0&&M.every((r,t)=>{const e=h.current[t]??t;return(o.current[e]??0)>0}),A=N&&D.current&&Y;if(A){const r=h.current.length;if(f.current<r){let e=0,i=0;if(f.current>0){i=f.current;const n=i-1,c=h.current[n]??n,s=o.current[c]??0;e=(p.current[n]??0)+s}for(let n=i;n<r;n+=1){p.current[n]=e;const c=h.current[n]??n;e+=o.current[c]??0}f.current=r}const t=E+$.height;w=M.length,a=-1;for(let e=0;e<r;e+=1){const i=p.current[e]??0,n=h.current[e]??e,c=o.current[n]??0;i+c>E&&i<t&&(e<w&&(w=e),a=e)}if(w>a&&(w=0,a=-1),w=Math.max(0,w-y),a=Math.min(M.length-1,Math.max(-1,a)+y),L=p.current[w]??0,a<M.length-1){const e=h.current[a]??a,i=(p.current[a]??0)+(o.current[e]??0);P=I-i}}return v(H,{...Q,children:v(H,{ref:V,width:"100%",children:v(H,{overflow:g?void 0:"hidden",width:"100%",children:rr(H,{flexDirection:"column",marginTop:-E,width:"100%",children:[A&&L>0&&v(H,{height:L}),M.map((r,t)=>!r||A&&(t<w||t>a)?null:v(er,{index:t,measureKey:U[t],onMeasure:W,width:$.width,children:r},z(r)?r.key??t:t)),A&&P>0&&v(H,{height:P})]})})})})};export{ir as C,G as f};
@@ -0,0 +1,2 @@
1
+ import{createDecMode as P,setMode as w,resetMode as M,BracketedPasteMode as R,cursorUp as U,cursorToColumn1 as L,cursorHide as b,REQUEST_CURSOR_POSITION as z,cursorPosition as u,eraseLine as A,cursorShow as B}from"@visulima/ansi";import{terminalSize as C,Renderer as Y}from"./Renderer-DsskdkUd.js";const T=P(2026),_=w(T),g=M(T),k=w(R),D=M(R);function Q(I,d={}){const S=d.rows??10,E=d.fps??60,O=d.onExit??"preserve";let n=null,o=null,c=null,i=80,t=10,h=0,r=1;function e(s){o.writeRaw(s)}function a(){c.fill(0),I(c,i,t,h++),e(_);try{o.render(c)}finally{e(g)}}function v(s){r=s-t,e(U(t)+L),o.setRowOffset(r),a(),n=setInterval(()=>{a()},Math.round(1e3/E))}function x(){const s=C();i=s.cols;const y=s.rows;t=Math.min(S,y),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8"),o=new Y(i,t),c=new Uint32Array(i*t*2),e(b),e(k),e(`
2
+ `.repeat(t)),e(z),process.on("SIGINT",l);let p="";const f=N=>{p+=N;const m=p.match(/\u001B\[(\d+);(\d+)R/);m&&(process.stdin.off("data",f),v(Number.parseInt(m[1],10)))};process.stdin.on("data",f)}function l(){if(n&&(clearInterval(n),n=null),o){if(O==="destroy"){for(let s=0;s<t;s++)e(u(r+1+s,1)+A);e(u(r+1,1))}else e(u(r+t+1,1));e(D),e(B)}process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause(),process.exit(0)}return{start:x,stop:l}}export{Q as createInlineLoop};
@@ -0,0 +1,3 @@
1
+ import{strip as i}from"@visulima/ansi";const u=(r,e)=>{const n=t=>t===void 0?"":i(t);return{contains(t){return this.text().includes(t)},frames(){return e.map(t=>i(t))},line(t){return this.text().split(`
2
+ `)[t]??""},lines(){return this.text().split(`
3
+ `).filter(t=>t.trim()!=="")},matches(t){return t.test(this.text())},rawFrames(){return[...e]},rawText(){return r()??""},text(){return n(r())}}};export{u as createScreen};
@@ -0,0 +1 @@
1
+ import h from"yoga-layout";import{y as l}from"./measure-text-B7juNq4Y.js";import g from"./squashTextNodesWithMap-BmUSBPfc.js";import{wordWrap as p,truncate as f}from"@visulima/string";const N={},m={hard:"STRICT_WIDTH",wrap:"BREAK_WORDS","wrap-anywhere":"BREAK_AT_CHARACTERS","wrap-preserve-words":"PRESERVE_WORDS","wrap-strict":"STRICT_WIDTH"},C=(e,t,o)=>{const n=e+String(t)+String(o),r=N[n];if(r)return r;let a=e;const s=m[o];if(s)a=p(e,{trim:!1,width:t,wrapMode:s}).replace(/\n$/,"");else if(o.startsWith("truncate")){let d="end";o==="truncate-middle"&&(d="middle"),o==="truncate-start"&&(d="start"),a=f(e,t,{position:d})}return N[n]=a,a};let x=0;const T=e=>{const t={attributes:{},childNodes:[],internal_accessibility:{},internal_id:x++,nodeName:e,parentNode:void 0,style:{},yogaNode:e==="ink-virtual-text"||e==="ink-cursor"?void 0:h.Node.create()};return e==="ink-text"&&t.yogaNode?.setMeasureFunc(R.bind(null,t)),t},i=e=>{y(e.nodeName==="ink-static-render"&&e.cachedRender?e.parentNode:e)},b=(e,t)=>{t.parentNode&&c(t.parentNode,t),t.parentNode=e,e.childNodes.push(t),t.yogaNode&&e.yogaNode?.insertChild(t.yogaNode,e.yogaNode.getChildCount()),i(e)},L=(e,t,o)=>{t.parentNode&&c(t.parentNode,t),t.parentNode=e;const n=e.childNodes.indexOf(o);if(n===-1)e.childNodes.push(t),t.yogaNode&&e.yogaNode?.insertChild(t.yogaNode,e.yogaNode.getChildCount());else if(e.childNodes.splice(n,0,t),t.yogaNode){const r=e.childNodes.slice(0,n).filter(a=>!!a.yogaNode).length;e.yogaNode?.insertChild(t.yogaNode,r)}i(e)},c=(e,t)=>{if(t.yogaNode){const n=t.yogaNode.getParent();n&&n.removeChild(t.yogaNode)}t.parentNode=void 0;const o=e.childNodes.indexOf(t);o!==-1&&e.childNodes.splice(o,1),i(e)},W=(e,t,o)=>{if(t==="internal_accessibility"){e.internal_accessibility=o;return}e.attributes[t]=o},A=(e,t)=>{e.style=t??{}},D=e=>{const t={nodeName:"#text",nodeValue:e,parentNode:void 0,style:{},yogaNode:void 0};return _(t,e),t},R=function(e,t){const o=e.nodeName==="#text"?e.nodeValue:g(e),n=l(o);if(n.width<=t||n.width>=1&&t>0&&t<1)return n;const r=e.style?.textWrap??"wrap",a=C(o,Math.floor(t),r);return l(a)},u=e=>{if(e?.parentNode)return e.yogaNode??u(e.parentNode)},y=e=>{(e?.nodeName==="#text"||e?.nodeName==="ink-text"||e?.nodeName==="ink-virtual-text")&&u(e)?.markDirty();let t=e;for(;t;){if((t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text")&&(t.internal_textCache=void 0),"childNodes"in t){if(t!==e&&t.nodeName==="ink-static-render"&&t.cachedRender)break;t.cachedRender=void 0}t=t.parentNode}},_=(e,t)=>{typeof t!="string"&&(t=String(t)),e.nodeValue=t,y(e)},E=(e,t)=>e.nodeName!=="ink-root"?()=>{}:(e.internal_layoutListeners??=new Set,e.internal_layoutListeners.add(t),()=>{e.internal_layoutListeners?.delete(t)}),V=e=>{if(!(e.nodeName!=="ink-root"||!e.internal_layoutListeners))for(const t of e.internal_layoutListeners)t()},H=(e,t)=>{if(e.cachedRender=t,e.yogaNode){for(e.yogaNode.setWidth(t.width),e.yogaNode.setHeight(t.height);e.yogaNode.getChildCount()>0;)e.yogaNode.removeChild(e.yogaNode.getChild(0));e.isYogaTreeDetached=!0}},I=e=>{const t=[];let o=e;for(;o;)t.unshift(o),o=o.parentNode;return t},O=e=>{let t=e;for(;t;){const{userSelect:o}=t.style;if(o==="none")return!1;if(o==="text"||o==="all")return!0;t=t.parentNode}return!0};export{E as a,L as b,T as c,b as d,V as e,D as f,I as g,A as h,O as i,W as j,H as k,C as l,y as m,c as r,_ as s};
@@ -3,6 +3,41 @@ import { C as CursorShape } from "./cursor-helpers.d-BONB9tky.js";
3
3
  import '@visulima/colorize';
4
4
  import 'cli-boxes';
5
5
  import { S as Styles } from "./styles.d-cMo36xQz.js";
6
+
7
+ /**
8
+ * Columnar data structure for a single line of styled terminal text.
9
+ *
10
+ * Instead of one heap-allocated object per visible character, StyledLine stores:
11
+ *
12
+ * - `text: string` — concatenated raw character values
13
+ * - `charData: number[]` — per-character: 30-bit offset into text | 1-bit full-width flag
14
+ * - `spans: StyleSpan[]` — run-length encoded style information
15
+ *
16
+ * For an 80-column line this reduces allocations from ~80 objects to
17
+ * 1 string + 1 array + typically 1-5 span objects.
18
+ *
19
+ * Ported from jacob314/ink (Google LLC, Apache-2.0).
20
+ * @license Apache-2.0
21
+ * Copyright 2026 Google LLC
22
+ * SPDX-License-Identifier: Apache-2.0
23
+ */
24
+ /**
25
+ * Columnar data structure for a single line of styled terminal text.
26
+ *
27
+ * Instead of one heap-allocated object per visible character, StyledLine stores:
28
+ *
29
+ * - `text: string` — concatenated raw character values
30
+ * - `charData: number[]` — per-character: 30-bit offset into text | 1-bit full-width flag
31
+ * - `spans: StyleSpan[]` — run-length encoded style information
32
+ *
33
+ * For an 80-column line this reduces allocations from ~80 objects to
34
+ * 1 string + 1 array + typically 1-5 span objects.
35
+ *
36
+ * Ported from jacob314/ink (Google LLC, Apache-2.0).
37
+ * @license Apache-2.0
38
+ * Copyright 2026 Google LLC
39
+ * SPDX-License-Identifier: Apache-2.0
40
+ */
6
41
  type StyleSpan = {
7
42
  bgColor?: string;
8
43
  fgColor?: string;
@@ -411,4 +446,4 @@ declare const getPathToRoot: (node: DOMNode) => DOMNode[];
411
446
  * Ported from jacob314/ink fork (Google LLC, Apache-2.0).
412
447
  */
413
448
  declare const isNodeSelectable: (node: DOMElement) => boolean;
414
- export { DOMNode as D, ResizeObserver as R, StyledLine as S, DOMElement as a, ResizeObserverCallback as b, ResizeObserverEntry as c, ScrollState as d, StickyHeader as e, calculateScroll as f, getPathToRoot as g, getScrollHeight as h, getScrollLeft as i, getScrollTop as j, getScrollWidth as k, isNodeSelectable as l };
449
+ export { DOMElement as D, ResizeObserver as R, StyledLine as S, DOMNode as a, ResizeObserverCallback as b, ResizeObserverEntry as c, ScrollState as d, StickyHeader as e, calculateScroll as f, getPathToRoot as g, getScrollHeight as h, getScrollLeft as i, getScrollTop as j, getScrollWidth as k, isNodeSelectable as l };
@@ -0,0 +1 @@
1
+ function S(o){const t=Math.max(0,Math.floor(o/1e3)),a=Math.floor(t/3600),r=Math.floor(t%3600/60),n=t%60;return a>0?`${String(a).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`}export{S as f};
@@ -1 +1 @@
1
- import"yoga-layout";import"./measure-text-Ce2widM1.js";import"./squashTextNodesWithMap-DCdi3SZ2.js";import{a as r,d,c as i,f as m,e as N,g as l,b as p,i as c,m as h,r as n,j as u,k as y,h as L,s as b}from"./dom-CXB-19sK.js";export{r as addLayoutListener,d as appendChildNode,i as createNode,m as createTextNode,N as emitLayoutListeners,l as getPathToRoot,p as insertBeforeNode,c as isNodeSelectable,h as markNodeAsDirty,n as removeChildNode,u as setAttribute,y as setCachedRender,L as setStyle,b as setTextNodeValue};
1
+ import"yoga-layout";import"./measure-text-B7juNq4Y.js";import"./squashTextNodesWithMap-BmUSBPfc.js";import{a as r,d,c as i,f as m,e as N,g as l,b as p,i as c,m as h,r as n,j as u,k as y,h as L,s as b}from"./dom-rphpG0kf.js";export{r as addLayoutListener,d as appendChildNode,i as createNode,m as createTextNode,N as emitLayoutListeners,l as getPathToRoot,p as insertBeforeNode,c as isNodeSelectable,h as markNodeAsDirty,n as removeChildNode,u as setAttribute,y as setCachedRender,L as setStyle,b as setTextNodeValue};
@@ -0,0 +1 @@
1
+ const e=/^[a-z]$/i,n=r=>{const t=r.codePointAt(0);return t!==void 0&&(t<32||t===127)},o=(r,t)=>r.length===0||n(r)?!1:t.ctrl&&t.meta?!e.test(r):!(t.ctrl||t.meta);export{o as i};
@@ -0,0 +1 @@
1
+ const n=({element:e,mouse:{x:t,y:o}})=>{const s=t<e.left||t>=e.left+e.width,l=o<e.top||o>=e.top+e.height;return!s&&!l};export{n as default};
@@ -0,0 +1 @@
1
+ const u=e=>{const r=/rgb:([\da-f]{2,4})\/([\da-f]{2,4})\/([\da-f]{2,4})/i.exec(e);if(!r)return null;const n=s=>s.length<=2?s.padStart(2,"0"):s.slice(0,2);return`#${n(r[1])}${n(r[2])}${n(r[3])}`},d=()=>{const e=process.env.TERM_PROGRAM??"";return new Set(["Alacritty","contour","foot","Ghostty","iTerm2","iTerm.app","kitty","rio","WezTerm"]).has(e)?!0:(process.env.TERM??"").startsWith("xterm")||!!process.env.WT_SESSION},f=(e,r,n,s=500)=>new Promise(a=>{let o="",i;const c=()=>{i&&clearTimeout(i),e.removeListener("data",t)},t=l=>{if(o+=l.toString(),o.length>256){c(),a(null);return}(o.includes("\x07")||o.includes("\x1B\\"))&&(c(),a(o))};i=setTimeout(()=>{c(),a(null)},s),e.on("data",t),r.write(n)}),m=async(e,r,n=500)=>{const s={},a=await f(e,r,"\x1B]10;?\x07",n);if(a){const t=u(a);t&&(s.foreground=t)}const o=await f(e,r,"\x1B]11;?\x07",n);if(o){const t=u(o);t&&(s.background=t)}const i=await f(e,r,"\x1B]12;?\x07",n);if(i){const t=u(i);t&&(s.cursor=t)}const c=[];for(let t=0;t<16;t++){const l=await f(e,r,`\x1B]4;${t};?\x07`,n);if(l){const x=u(l);c.push(x??"")}else c.push("")}return c.some(t=>t.length>0)&&(s.colors=c),s};export{d as isTerminalPaletteQuerySupported,m as queryTerminalPalette};
@@ -0,0 +1 @@
1
+ const o={disambiguateEscapeCodes:1,reportAllKeysAsEscapeCodes:8,reportAlternateKeys:4,reportAssociatedText:16,reportEventTypes:2};function r(t){let e=0;for(const s of t)e|=o[s];return e}const a={alt:2,capsLock:64,ctrl:4,hyper:16,meta:32,numLock:128,shift:1,super:8};export{o as kittyFlags,a as kittyModifiers,r as resolveFlags};
@@ -0,0 +1 @@
1
+ import{jsxs as N,jsx as I}from"react/jsx-runtime";import{useMemo as u}from"react";import{c as d}from"./braille-ch3O5D7I.js";import{Box as h}from"../components/box.js";import{Canvas as f}from"../components/canvas.js";import{Text as y}from"../components/text.js";const T=["cyan","magenta","yellow","green","blue","red"],g=e=>e.length===0?[]:typeof e[0]=="number"?e.map((o,t)=>({x:t,y:o})):e,E=(e,o,t)=>e.color??t[o%t.length]??"cyan",b=e=>{let o=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const{points:x}of e)for(const n of x)n.x<o&&(o=n.x),n.x>t&&(t=n.x),n.y<r&&(r=n.y),n.y>s&&(s=n.y);return{xMax:t,xMin:o,yMax:s,yMin:r}},Y=T,M=(e,o,t,r)=>{const s=o.xMax-o.xMin||1,x=o.yMax-o.yMin||1,n=(e.x-o.xMin)/s,c=(e.y-o.yMin)/x;return{px:Math.max(0,Math.min(t-1,Math.round(n*(t-1)))),py:Math.max(0,Math.min(r-1,Math.round((1-c)*(r-1))))}},_=(e,o,t)=>{e.clear();const{axisColor:r,seriesList:s}=t,x=Math.max(1,e.width*2),n=Math.max(1,e.height*4);for(let c=0;c<e.width;c+=2)e.setCell(c,e.height-1,"·",{color:r,dim:!0});for(const{color:c,points:m}of s){if(m.length===0)continue;const l=d(e.width,e.height);if(o==="scatter")for(const i of m){const a=M(i,t,x,n);l.plotPoint(a.px,a.py)}else{let i=M(m[0],t,x,n);l.plotPoint(i.px,i.py);for(let a=1;a<m.length;a+=1){const p=M(m[a],t,x,n);l.plotLine(i.px,i.py,p.px,p.py),i=p}}l.flush(e,{color:c})}};function L({axisColor:e="gray",height:o=10,maxY:t,minY:r,palette:s=Y,series:x,showLegend:n=!0,width:c=40}){const m=u(()=>{const l=x.map((a,p)=>({color:E(a,p,s),points:g(a.data),series:a})),i=b(l);return{axisColor:e,palette:s,seriesList:l,xMax:i.xMax===Number.NEGATIVE_INFINITY?1:i.xMax,xMin:i.xMin===Number.POSITIVE_INFINITY?0:i.xMin,yMax:t??(i.yMax===Number.NEGATIVE_INFINITY?1:i.yMax),yMin:r??(i.yMin===Number.POSITIVE_INFINITY?0:i.yMin)}},[x,e,s,r,t]);return N(h,{flexDirection:"column",children:[I(f,{draw:l=>{_(l,"line",m)},height:o,version:[x,c,o,r,t,e,s],width:c}),n?I(h,{gap:2,marginTop:1,children:m.seriesList.map(({color:l,series:i},a)=>N(h,{gap:1,children:[I(y,{color:l,children:"●"}),I(y,{children:i.label??`Series ${a+1}`})]},`${a}:${i.label??""}`))}):void 0]})}export{T as D,M as a,b as c,_ as d,L as h,E as p,g as t};
@@ -0,0 +1 @@
1
+ import{createRequire as l}from"node:module";const f=l(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,i=s=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,n]=t.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return t.getBuiltinModule(s)}return f(s)},{existsSync:u}=i("node:fs"),{createRequire:p}=i("node:module"),{dirname:a,join:r}=i("node:path"),{fileURLToPath:_}=i("node:url"),j=12,g=s=>{const e=p(s),n=a(_(s));let o=n;for(let c=0;c<j;c+=1){if(u(r(o,"package.json"))&&u(r(o,"index.js")))return e(r(o,"index.js"));const d=a(o);if(d===o)break;o=d}return e(r(n,"..","index.js"))};export{g as p};
@@ -0,0 +1,2 @@
1
+ import i from"yoga-layout";import{getScrollTop as P,getScrollLeft as R}from"./calculateScroll-D4Y_JR4H.js";import X from"./squashTextNodesWithMap-BmUSBPfc.js";const G=t=>{let e=t,o=0,r=0;for(;e?.parentNode;){if(!e.yogaNode)return;o+=e.yogaNode.getComputedLeft(),r+=e.yogaNode.getComputedTop(),e=e.parentNode}return{x:o,y:r}},k=t=>G(t),z=t=>{const e=G(t);if(!(!e||!t.yogaNode))return{x:e.x+t.yogaNode.getComputedBorder(i.EDGE_LEFT)+t.yogaNode.getComputedPadding(i.EDGE_LEFT),y:e.y+t.yogaNode.getComputedBorder(i.EDGE_TOP)+t.yogaNode.getComputedPadding(i.EDGE_TOP)}},A=(t,e)=>{const{initialState:o,onNewline:r,onSpace:s,onText:n}=e;if(t.nodeName!=="ink-box"&&t.nodeName!=="ink-root"&&t.nodeName!=="ink-text"&&t.nodeName!=="ink-virtual-text"||!t.yogaNode)return{lineBottom:0,state:o()};const{fragments:l}=W(t),a=o();a.currentX=0,a.lineBottom=0,a.yieldedContent=!1;for(const d of l){if(d.y>=a.lineBottom){const g=d.y-a.lineBottom,u=a.yieldedContent?1+g:g;u>0&&(r(u,a),a.currentX=0),a.lineBottom=d.y}if(d.x>a.currentX){const g=d.x-a.currentX;s(g,a),a.currentX=d.x}if(d.text.length>0&&(a.yieldedContent=!0,n(d,a)),(d.text.match(/\n/g)??[]).length>0){const g=d.text.lastIndexOf(`
2
+ `);a.currentX=d.text.length-g-1}else a.currentX+=d.text.length;a.lineBottom=Math.max(a.lineBottom,d.y+d.height)}return{lineBottom:a.lineBottom,state:a}},U=t=>{const e=k(t);return{height:Math.round(t.yogaNode?.getComputedHeight()??0),width:Math.round(t.yogaNode?.getComputedWidth()??0),x:Math.round(e?.x??0),y:Math.round(e?.y??0)}},j=t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedWidth()??0,r=e.getComputedBorder(i.EDGE_LEFT),s=e.getComputedBorder(i.EDGE_RIGHT);return Math.round(o-r-s)},q=t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedHeight()??0,r=e.getComputedBorder(i.EDGE_TOP),s=e.getComputedBorder(i.EDGE_BOTTOM);return Math.round(o-r-s)},S=t=>{const{yogaNode:e}=t;if(!e)return{height:0,width:0,x:0,y:0};const o=e.getComputedWidth()??0,r=e.getComputedHeight()??0;let s=e.getComputedLeft(),n=e.getComputedTop(),l=t.parentNode;for(;l?.yogaNode;){if(s+=l.yogaNode.getComputedLeft(),n+=l.yogaNode.getComputedTop(),l.nodeName==="ink-box"){const a=l.style.overflow??"visible",d=l.style.overflowX??a;(l.style.overflowY??a)==="scroll"&&(n-=P(l)),d==="scroll"&&(s-=R(l))}l=l.parentNode}return{height:Math.round(r),width:Math.round(o),x:Math.round(s),y:Math.round(n)}},J=t=>{const e=t.internal_scrollState?.scrollHeight??0,o=t.internal_scrollState?.actualScrollHeight??0;return Math.max(0,e-o)},H=t=>{const{axis:e,clientDimension:o,scrollbarDimension:r,scrollDimension:s,scrollPosition:n}=t,l=r*2,a=Math.max(e==="vertical"?2:1,Math.round(o/s*l)),d=s-o,g=l-a,u=d>0?Math.round(n/d*g):0,h=u,m=u+a,c=Math.floor(h/2);return{endIndex:Math.min(r,Math.ceil(m/2)),startIndex:c,thumbEndHalf:m,thumbStartHalf:h}},b=t=>{const{axis:e,clientDimension:o,hasOppositeScrollbar:r,height:s,marginBottom:n,marginRight:l,scrollDimension:a,scrollPosition:d,width:g,x:u,y:h}=t;if(a<=o)return;if(e==="vertical"){const{endIndex:C,startIndex:x,thumbEndHalf:D,thumbStartHalf:T}=H({axis:e,clientDimension:o,scrollbarDimension:s,scrollDimension:a,scrollPosition:d}),f=u+g-1-l;return{height:s,thumb:{end:C,endHalf:D,height:C-x,start:x,startHalf:T,width:1,x:f,y:h+x},width:1,x:f,y:h}}const m=g-(r?1:0),{endIndex:c,startIndex:p,thumbEndHalf:N,thumbStartHalf:y}=H({axis:e,clientDimension:o,scrollbarDimension:m,scrollDimension:a,scrollPosition:d}),B=h+s-1-n;return{height:1,thumb:{end:c,endHalf:N,height:1,start:p,startHalf:y,width:c-p,x:u+p,y:B},width:m,x:u,y:B}},K=(t,e)=>{const{yogaNode:o}=t;if(!o)return;const r=t.style.overflow??"visible";if((t.style.overflowY??r)!=="scroll")return;const s=t.internal_scrollState?.clientHeight??0,n=t.internal_scrollState?.scrollHeight??0;if(n<=s)return;const{x:l,y:a}=e??S(t),d=o.getComputedHeight()-o.getComputedBorder(i.EDGE_TOP)-o.getComputedBorder(i.EDGE_BOTTOM);return b({axis:"vertical",clientDimension:s,hasOppositeScrollbar:!1,height:d,marginBottom:o.getComputedBorder(i.EDGE_BOTTOM),marginRight:o.getComputedBorder(i.EDGE_RIGHT),scrollDimension:n,scrollPosition:t.internal_scrollState?.scrollTop??0,width:o.getComputedWidth()-o.getComputedBorder(i.EDGE_LEFT),x:l+o.getComputedBorder(i.EDGE_LEFT),y:a+o.getComputedBorder(i.EDGE_TOP)})},Q=(t,e)=>{const{yogaNode:o}=t;if(!o)return;const r=t.style.overflow??"visible";if((t.style.overflowX??r)!=="scroll")return;const s=t.internal_scrollState?.clientWidth??0,n=t.internal_scrollState?.scrollWidth??0;if(n<=s)return;const{x:l,y:a}=e??S(t),d=t.style.overflowY??r,g=t.internal_scrollState?.clientHeight??0,u=t.internal_scrollState?.scrollHeight??0,h=d==="scroll"&&u>g;return b({axis:"horizontal",clientDimension:s,hasOppositeScrollbar:h,height:o.getComputedHeight()-o.getComputedBorder(i.EDGE_TOP),marginBottom:o.getComputedBorder(i.EDGE_BOTTOM),marginRight:o.getComputedBorder(i.EDGE_RIGHT),scrollDimension:n,scrollPosition:t.internal_scrollState?.scrollLeft??0,width:o.getComputedWidth()-o.getComputedBorder(i.EDGE_LEFT)-o.getComputedBorder(i.EDGE_RIGHT),x:l+o.getComputedBorder(i.EDGE_LEFT),y:a+o.getComputedBorder(i.EDGE_TOP)})},Z=(t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedTop(),r=t.parentNode;for(;r&&r!==e;)r.yogaNode&&(o+=r.yogaNode.getComputedTop()),r=r.parentNode;if(!(e!==void 0&&r!==e))return Math.round(o)},tt=(t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedLeft(),r=t.parentNode;for(;r&&r!==e;)r.yogaNode&&(o+=r.yogaNode.getComputedLeft()),r=r.parentNode;if(!(e!==void 0&&r!==e))return Math.round(o)},F=t=>t.nodeName==="#text"?t.nodeValue:t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text"?X(t):"",W=t=>{const e=[],o=(n,l,a)=>{const{visualX:d,visualY:g,x:u,y:h}=l;let m=0,c=0,p=a;const{userSelect:N}=n.style;if(N==="none"?p=!1:(N==="text"||N==="all")&&(p=!0),n.nodeName==="ink-text"||n.nodeName==="ink-virtual-text"){if(p){const y=F(n);return e.push({height:Math.round(n.yogaNode?.getComputedHeight()??0),node:n,text:y,visualX:Math.round(d),visualY:Math.round(g),width:Math.round(n.yogaNode?.getComputedWidth()??0),x:Math.round(u),y:Math.round(h)}),{h:0,hasContent:!0,v:0}}return{h:n.yogaNode?.getComputedWidth()??0,hasContent:!1,v:n.yogaNode?.getComputedHeight()??0}}if(n.nodeName==="ink-box"||n.nodeName==="ink-root"){if(!n.yogaNode||n.yogaNode.getDisplay()===i.DISPLAY_NONE)return{h:0,hasContent:!1,v:0};const y=n.yogaNode.getComputedBorder(i.EDGE_TOP),B=n.yogaNode.getComputedBorder(i.EDGE_BOTTOM),C=n.yogaNode.getComputedBorder(i.EDGE_LEFT),x=n.yogaNode.getComputedBorder(i.EDGE_RIGHT);m+=y+B,c+=C+x;const D=n.yogaNode.getFlexDirection(),T=D===i.FLEX_DIRECTION_COLUMN||D===i.FLEX_DIRECTION_COLUMN_REVERSE;let f=0,_=0,M=!1;for(const E of n.childNodes)if(E.yogaNode){const O=u+E.yogaNode.getComputedLeft()-C-f,L=h+E.yogaNode.getComputedTop()-y-_,w=d+E.yogaNode.getComputedLeft(),I=g+E.yogaNode.getComputedTop(),v=o(E,{visualX:w,visualY:I,x:O,y:L},p);v.hasContent&&(M=!0),T?_+=v.v:f+=v.h}return T?m+=_:c+=f,{h:c,hasContent:M,v:m}}return{h:0,hasContent:!1,v:0}},{h:r,v:s}=o(t,{visualX:0,visualY:0,x:0,y:0},!0);return e.sort((n,l)=>n.y!==l.y?n.y-l.y:n.x-l.x),{fragments:e,removedHorizontal:Math.round(r),removedVertical:Math.round(s)}};export{U as R,H as a,W as b,b as c,S as d,Q as e,q as f,J as g,j as h,tt as i,Z as j,F as k,K as l,A as p,z as x,k as y};
@@ -0,0 +1,3 @@
1
+ import{isFullwidthCodePoint as G,getStringWidth as q}from"@visulima/string";import{t as J}from"./ansi-tokenizer-BU67A126.js";let N=class{map;maxDataSize;maxKeys;currentDataSize=0;constructor(t,e){this.map=new Map,this.maxKeys=t,this.maxDataSize=e}get size(){return this.map.size}clear(){this.map.clear(),this.currentDataSize=0}get(t){if(!this.map.has(t))return;const e=this.map.get(t);return this.map.delete(t),this.map.set(t,e),e}set(t,e){const s=t.length;if(!(s>this.maxDataSize)){for(this.map.has(t)&&(this.map.delete(t),this.currentDataSize-=s);this.currentDataSize+s>this.maxDataSize&&this.map.size>0;){const n=this.map.keys().next().value;if(n===void 0)break;this.map.delete(n),this.currentDataSize-=n.length}for(;this.map.size>=this.maxKeys;){const n=this.map.keys().next().value;if(n===void 0)break;this.map.delete(n),this.currentDataSize-=n.length}this.map.set(t,e),this.currentDataSize+=s}}};const Q=1,X=2,K=4,E=8,O=16,A=32,R=64,x=128,d=1073741823,k=1073741824;class m{length=0;static emptyCache=new Map;text;charData;spans;_cachedTrimmedLength;static empty(t){if(t<=0)return new m;const e=m.emptyCache.get(t);if(e)return e.clone();const s=new m;s.length=t,s.text=" ".repeat(t),s.charData=Array.from({length:t});for(let n=0;n<t;n++)s.charData[n]=n;return s.spans=[{formatFlags:0,length:t}],s._cachedTrimmedLength=0,Object.freeze(s.spans[0]),Object.freeze(s.spans),Object.freeze(s),m.emptyCache.set(t,s),s.clone()}getValue(t){if(this.text===void 0||t<0||t>=this.length)return"";const e=this.charData[t]&d,s=t+1<this.length?this.charData[t+1]&d:this.text.length;return this.text.slice(e,s)}getTextRange(t,e){if(this.text===void 0||t<0||e>this.length||t>=e)return"";const s=this.charData[t]&d,n=e<this.length?this.charData[e]&d:this.text.length;return this.text.slice(s,n)}getSpan(t){if(this.spans===void 0||t<0||t>=this.length)return;let e=0;for(const s of this.spans){if(t<e+s.length)return s;e+=s.length}}getFullWidth(t){return this.charData===void 0||t<0||t>=this.length?!1:(this.charData[t]&k)!==0}hasStyles(t){const e=this.getSpan(t);return e?(e.formatFlags&~x)!==0||e.fgColor!==void 0||e.bgColor!==void 0||e.link!==void 0:!1}getFormatFlags(t){let e=this.getSpan(t)?.formatFlags??0;return this.getFullWidth(t)&&(e|=x),e}getFgColor(t){return this.getSpan(t)?.fgColor}getBgColor(t){return this.getSpan(t)?.bgColor}getLink(t){return this.getSpan(t)?.link}setInverted(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{e?s.formatFlags|=A:s.formatFlags&=~A})}setBackgroundColor(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{s.bgColor=e})}setForegroundColor(t,e){this._cachedTrimmedLength=void 0,this.updateSpanAt(t,s=>{s.fgColor=e})}setChar(t,e,s,n,a,h){if(t<0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const i=(s&x)!==0,o=s&~x,l=this.charData[t]&d,c=t+1<this.length?this.charData[t+1]&d:this.text.length,p=c-l,b=e.length;if(this.text=this.text.slice(0,l)+e+this.text.slice(c),p!==b){const f=b-p;for(let C=t+1;C<this.length;C++){const S=this.charData[C],F=S&d,T=S&k;this.charData[C]=F+f|T}}if(this.charData[t]=l|(i?k:0),this.trySetStyleAtIndex(t,o,n,a,h))return;this.splitSpansAt(t),this.splitSpansAt(t+1);let u=0;for(let f=0;f<this.spans.length;f++){const C=this.spans[f];if(u===t&&C.length===1){this.spans[f]={bgColor:a,fgColor:n,formatFlags:o,length:1,link:h};break}u+=C.length}this.mergeSpans()}setCharFast(t,e,s,n,a,h){if(t<0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const i=(s&x)!==0,o=s&~x,l=this.charData[t]&d,c=t+1<this.length?this.charData[t+1]&d:this.text.length,p=c-l;if(e.length===p)e!==this.text.slice(l,c)&&(this.text=this.text.slice(0,l)+e+this.text.slice(c)),this.charData[t]=l|(i?k:0);else{if(this.text=this.text.slice(0,l)+e+this.text.slice(c),p!==e.length){const u=e.length-p;for(let f=t+1;f<this.length;f++){const C=this.charData[f];this.charData[f]=(C&d)+u|C&k}}this.charData[t]=l|(i?k:0)}if(this.trySetStyleAtIndex(t,o,n,a,h))return;this.splitSpansAt(t),this.splitSpansAt(t+1);let b=0;for(let u=0;u<this.spans.length;u++){const f=this.spans[u];if(b===t&&f.length===1){this.spans[u]={bgColor:a,fgColor:n,formatFlags:o,length:1,link:h};break}b+=f.length}this.mergeSpans()}writeFrom(t,e,s=0,n){const a=n??e.length-s;if(a<=0||t>=this.length)return;this._cachedTrimmedLength=void 0,this.ensureInitialized();const h=Math.min(a,this.length-t,e.length-s),i=this.charData[t]&d,o=t+h<this.length?this.charData[t+h]&d:this.text.length;let l="";for(let g=0;g<h;g++)l+=e.getValue(s+g);const c=o-i,p=l.length-c;this.text=this.text.slice(0,i)+l+this.text.slice(o);let b=i;for(let g=0;g<h;g++){const D=e.getFullWidth(s+g);this.charData[t+g]=b|(D?k:0),b+=e.getValue(s+g).length}if(p!==0)for(let g=t+h;g<this.length;g++){const D=this.charData[g];this.charData[g]=(D&d)+p|D&k}this.splitSpansAt(t),this.splitSpansAt(t+h);const u=[];let f=0;for(const g of e.getSpans()){const D=f+g.length,$=Math.max(s,f),W=Math.min(s+h,D);if($<W&&u.push({...g,length:W-$}),f=D,f>=s+h)break}let C=0,S=0;for(let g=0;g<this.spans.length;g++){if(S===t){C=g;break}S+=this.spans[g].length}let F=0,T=0;for(let g=C;g<this.spans.length&&T<h;g++)T+=this.spans[g].length,F++;this.spans.splice(C,F,...u),this.mergeSpans()}pushChar(t,e,s,n,a){this._cachedTrimmedLength=void 0,this.ensureInitialized();const h=(e&x)!==0,i=e&~x,o=this.text.length;this.text=(this.text??"")+t,this.charData.push(o|(h?k:0));const l=this.spans.at(-1);l?.formatFlags===i&&l.fgColor===s&&l.bgColor===n&&l.link===a?l.length++:this.spans.push({bgColor:n,fgColor:s,formatFlags:i,length:1,link:a}),this.length++}clone(){if(this.charData===void 0)return new m;const t=new m;return t.length=this.length,t.text=this.text,t.charData=[...this.charData],t.spans=this.spans.map(e=>({...e})),t._cachedTrimmedLength=this._cachedTrimmedLength,t}slice(t,e){if(this.charData===void 0)return new m;const s=Math.max(0,t),n=e===void 0?this.length:Math.min(this.length,e);if(s>=n)return new m;if(s===0&&n===this.length)return this.clone();const a=new m;a.length=n-s,a.charData=Array.from({length:a.length});const h=this.charData[s]&d,i=n<this.length?this.charData[n]&d:this.text.length;a.text=this.text.slice(h,i);for(let c=0;c<a.length;c++){const p=this.charData[s+c],b=p&d,u=p&k;a.charData[c]=b-h|u}const o=[];let l=0;for(const c of this.spans){const p=l,b=l+c.length,u=Math.max(s,p),f=Math.min(n,b);if(u<f&&o.push({...c,length:f-u}),l+=c.length,l>=n)break}return a.spans=o,a.mergeSpans(),a}combine(...t){if(t.length===0)return this.clone();const e=[this,...t].filter(i=>i.length>0);if(e.length===0)return new m;if(e.length===1)return e[0].clone();let s=0;for(const i of e)s+=i.length;const n=new m;n.length=s,n.text=e.map(i=>i.getText()).join(""),n.charData=Array.from({length:s});let a=0,h=0;for(const i of e){const o=i.charData,l=i.getText();if(o)for(let c=0;c<i.length;c++){const p=o[c],b=p&d,u=p&k;n.charData[a+c]=h+b|u}else for(let c=0;c<i.length;c++)n.charData[a+c]=h+c;a+=i.length,h+=l.length}return n.spans=e.flatMap(i=>i.getSpans().map(o=>({...o}))),n.mergeSpans(),n}getTrimmedLength(){if(this._cachedTrimmedLength!==void 0)return this._cachedTrimmedLength;if(this.length===0)return this._cachedTrimmedLength=0,0;if(this.text===void 0||this.charData===void 0)return this._cachedTrimmedLength=0,0;let t=this.length-1;if(this.spans)for(let e=this.spans.length-1;e>=0;e--){const s=this.spans[e];if((s.formatFlags&~x)!==0||s.fgColor!==void 0||s.bgColor!==void 0||s.link!==void 0)return this._cachedTrimmedLength=t+1,this._cachedTrimmedLength;for(let n=0;n<s.length;n++){const a=this.charData[t]&d;if((t+1<this.length?this.charData[t+1]&d:this.text.length)-a!==1||this.text[a]!==" ")return this._cachedTrimmedLength=t+1,this._cachedTrimmedLength;t--}}return this._cachedTrimmedLength=0,0}trimEnd(){const t=this.getTrimmedLength();return t===this.length?this:t===0?new m:this.slice(0,t)}equals(t){if(this.length!==t.length)return!1;if(this.length===0)return!0;if(this.getText()!==t.getText())return!1;const e=this.getSpans(),s=t.getSpans();if(e.length!==s.length)return!1;for(const[h,i]of e.entries()){const o=i,l=s[h];if(o.length!==l.length||o.formatFlags!==l.formatFlags||o.fgColor!==l.fgColor||o.bgColor!==l.bgColor||o.link!==l.link)return!1}const n=this.charData,a=t.charData;if(n&&a){for(let h=0;h<this.length;h++)if(n[h]!==a[h])return!1}return!0}getText(){return this.text??""}getSpans(){return this.spans??[]}getValues(){return Array.from({length:this.length},(t,e)=>this.getValue(e))}*[Symbol.iterator](){if(this.length===0)return;let t=0,e=0;const s=this.getSpans();for(let n=0;n<this.length;n++){const a=s[t],h=a?a.formatFlags:0,i=this.getFullWidth(n);yield{bgColor:a?.bgColor,fgColor:a?.fgColor,formatFlags:h|(i?x:0),fullWidth:i,hasStyles:(h&~x)!==0||a?.fgColor!==void 0||a?.bgColor!==void 0||a?.link!==void 0,link:a?.link,value:this.getValue(n)},a&&(e++,e>=a.length&&(t++,e=0))}}updateSpanAt(t,e){if(t<0||t>=this.length)return;this.ensureInitialized(),this.splitSpansAt(t),this.splitSpansAt(t+1);let s=0;for(const n of this.spans){if(s===t&&n.length===1){e(n);break}s+=n.length}this.mergeSpans()}ensureWidth(t){if(t<=this.length)return;this.ensureInitialized();const e=this.length,s=t-e,n=this.text.length;for(let h=0;h<s;h++)this.charData.push(n);this.length=t;const a=this.spans.at(-1);a?.formatFlags===0&&a.fgColor===void 0&&a.bgColor===void 0&&a.link===void 0?a.length+=s:this.spans.push({formatFlags:0,length:s})}ensureInitialized(){if(this.charData===void 0&&(this.text="",this.charData=Array.from({length:this.length}),this.spans=this.length>0?[{formatFlags:0,length:this.length}]:[],this.length>0&&this.text.length===0)){this.text=" ".repeat(this.length);for(let t=0;t<this.length;t++)this.charData[t]=t}}splitSpansAt(t){if(this.spans===void 0||t<=0||t>=this.length)return;let e=0;for(let s=0;s<this.spans.length;s++){const n=this.spans[s];if(t>e&&t<e+n.length){const a=t-e,h=n.length-a;this.spans.splice(s,1,{...n,length:a},{...n,length:h});return}e+=n.length}}trySetStyleAtIndex(t,e,s,n,a){if(!this.spans)return!1;let h=0,i=-1,o;for(let l=0;l<this.spans.length;l++){const c=this.spans[l];if(h<=t&&h+c.length>t){i=l,o=c;break}h+=c.length}if(!o)return!1;if(o.formatFlags===e&&o.fgColor===s&&o.bgColor===n&&o.link===a)return!0;if(t===h&&i>0){const l=this.spans[i-1];if(l.formatFlags===e&&l.fgColor===s&&l.bgColor===n&&l.link===a)return l.length+=1,o.length===1?this.spans.splice(i,1):o.length-=1,!0}if(t===h+o.length-1&&i<this.spans.length-1){const l=this.spans[i+1];if(l.formatFlags===e&&l.fgColor===s&&l.bgColor===n&&l.link===a)return l.length+=1,o.length===1?this.spans.splice(i,1):o.length-=1,!0}return!1}mergeSpans(){if(this.spans===void 0)return;const t=[];for(const e of this.spans){if(e.length===0)continue;const s=t.at(-1);s?.formatFlags===e.formatFlags&&s.fgColor===e.fgColor&&s.bgColor===e.bgColor&&s.link===e.link?s.length+=e.length:t.push({...e})}this.spans=t}}const V={black:0,blue:4,cyan:6,gray:8,green:2,grey:8,magenta:5,red:1,white:7,yellow:3},P={blackBright:8,blueBright:12,cyanBright:14,greenBright:10,magentaBright:13,redBright:9,whiteBright:15,yellowBright:11},H=/^ansi256\(\s?(\d+)\s?\)$/,j=/^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/,xt=r=>{const t=V[r];if(t!==void 0)return t;const e=P[r];if(e!==void 0)return e;const s=H.exec(r);if(s)return Number(s[1])&255;if(r.startsWith("#")&&r.length===7){const a=Number.parseInt(r.slice(1,3),16),h=Number.parseInt(r.slice(3,5),16),i=Number.parseInt(r.slice(5,7),16);return 16+36*Math.round(a/51)+6*Math.round(h/51)+Math.round(i/51)}const n=j.exec(r);return n?16+36*Math.round(Number(n[1])/51)+6*Math.round(Number(n[2])/51)+Math.round(Number(n[3])/51):255},kt=(r,t)=>{const e=t?30:40,s=V[r];if(s!==void 0)return[e+s];const n=P[r];if(n!==void 0)return[e+60+(n-8)];if(r.startsWith("#")&&r.length===7){const i=Number.parseInt(r.slice(1,3),16),o=Number.parseInt(r.slice(3,5),16),l=Number.parseInt(r.slice(5,7),16);return[t?38:48,2,i,o,l]}const a=H.exec(r);if(a)return[t?38:48,5,Number(a[1])];const h=j.exec(r);return h?[t?38:48,2,Number(h[1]),Number(h[2]),Number(h[3])]:[]},w=r=>{const t=["black","red","green","yellow","blue","magenta","cyan","white"];return r>=0&&r<=7?t[r]:`ansi256(${r})`},_=()=>({bgColor:void 0,fgColor:void 0,formatFlags:0,link:void 0}),Y=(r,t)=>{if(t.length===0)return _();const e=(t.includes(":")?t.replaceAll(":",";"):t).split(";").filter(o=>o.length>0).map(Number);let{bgColor:s,fgColor:n,formatFlags:a,link:h}=r,i=0;for(;i<e.length;){const o=e[i];switch(o){case 0:{a=0,n=void 0,s=void 0,h=void 0;break}case 1:{a|=Q;break}case 2:{a|=X;break}case 3:{a|=K;break}case 4:{a|=E;break}case 7:{a|=A;break}case 8:{a|=R;break}case 9:{a|=O;break}case 22:{a&=-4;break}case 23:{a&=~K;break}case 24:{a&=~E;break}case 27:{a&=~A;break}case 28:{a&=~R;break}case 29:{a&=~O;break}case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:{n=w(o-30);break}case 38:{e[i+1]===5&&e[i+2]!==void 0?(n=w(e[i+2]),i+=2):e[i+1]===2&&i+4<e.length&&(n=`rgb(${e[i+2]}, ${e[i+3]}, ${e[i+4]})`,i+=4);break}case 39:{n=void 0;break}case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:{s=w(o-40);break}case 48:{e[i+1]===5&&e[i+2]!==void 0?(s=w(e[i+2]),i+=2):e[i+1]===2&&i+4<e.length&&(s=`rgb(${e[i+2]}, ${e[i+3]}, ${e[i+4]})`,i+=4);break}case 49:{s=void 0;break}case 90:case 91:case 92:case 93:case 94:case 95:case 96:case 97:{n=`ansi256(${o-90+8})`;break}case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:{s=`ansi256(${o-100+8})`;break}}i++}return{bgColor:s,fgColor:n,formatFlags:a,link:h}},y=127462,L=127487,Z=127995,tt=127999,et=8205,st=917504,nt=917631,at=new RegExp("\\p{Mark}","u"),rt=new Intl.Segmenter(void 0,{granularity:"grapheme"}),it=(r,t)=>!!(G(t)||r.includes("️")||t>=y&&t<=L),ht=/(?:\u001B\]|\u009D)8;([^;]*);(.*?)(?:\u001B\\|\u0007|\u009C)/,lt=r=>{const t=ht.exec(r);return!t?.[2]||t[2].length===0?void 0:r.endsWith("\x1B\\")?`ST:${t[2]}`:t[2]},U=(r,t,e)=>{const s=rt.segment(r),n=[];for(const{segment:a}of s)n.push(a);for(let a=0;a<n.length;a++){let h=n[a];if(h===" "){for(let l=0;l<4;l++)t.pushChar(" ",e.formatFlags,e.fgColor,e.bgColor,e.link);continue}if(h==="\b")continue;const i=h.codePointAt(0);if(!i)continue;if(i>=y&&i<=L&&a+1<n.length){const l=n[a+1],c=l.codePointAt(0);c&&c>=y&&c<=L&&(h+=l,a++)}else for(;a+1<n.length;){const l=n[a+1],c=l.codePointAt(0);if(!c)break;const p=at.test(String.fromCodePoint(c)),b=c>=Z&&c<=tt,u=c===et,f=c>=st&&c<=nt;if(!p&&!b&&!u&&!f)break;h+=l,a++,u&&a+1<n.length&&(h+=n[a+1],a++)}const o=it(h,i)?e.formatFlags|x:e.formatFlags;t.pushChar(h,o,e.fgColor,e.bgColor,e.link)}},ot=r=>{if(r.length===0)return new m;const t=J(r),e=new m;let s=_();for(const n of t)switch(n.type){case"csi":{n.finalCharacter==="m"&&(s=Y(s,n.parameterString));break}case"osc":{const a=lt(n.value);a!==void 0?s={...s,link:a}:n.value.includes("8;")&&(s={...s,link:void 0});break}case"text":{U(n.value,e,s);break}}return e},ct=/^[\u0020-\u007E]*$/,Dt=r=>{if(r.length===0)return new m;const t=new m;if(ct.test(r)){for(const e of r)t.pushChar(e,0);return t}return U(r,t,_()),t},I=new N(1e4,1e6),M=new N(1e4,1e6),v=new N(1e4,1e6);let z=!0,B=q;const St=r=>{z=r,r||v.clear()},vt=()=>{v.clear()},Ft=r=>{B=r,gt()},gt=()=>{I.clear(),M.clear(),v.clear()},ft=r=>{if(r.length===1){const s=r.codePointAt(0);if(s!==void 0&&s>=32&&s<127)return 1}const t=M.get(r);if(t!==void 0)return t;let e;try{e=B(r)}catch{e=1}return M.set(r,e),e},ut=r=>{try{return B(r)}catch{return 1}},Tt=r=>{if(r.length===0)return{height:0,width:0};const t=I.get(r);if(t)return t;const e=r.split(`
2
+ `);let s=0;for(const a of e){const h=ut(a);h>s&&(s=h)}const n={height:e.length,width:s};return I.set(r,n),n},wt=r=>{if(z){const e=v.get(r);if(e!==void 0)return e}const t=ot(r);return z&&v.set(r,t),t},mt=r=>{let t=0;for(let e=0;e<r.length;e++)t+=ft(r.getValue(e));return t},pt=r=>{if(r.length===0)return[new m];const t=[];let e=0;for(let s=0;s<r.length;s++)r.getValue(s)===`
3
+ `&&(t.push(s>e?r.slice(e,s):new m),e=s+1);return t.push(e<r.length?r.slice(e):new m),t},At=r=>{if(r.length===0)return{height:0,width:0};const t=pt(r);let e=0;for(const s of t)e=Math.max(e,mt(s));return{height:t.length,width:e}};export{Q as B,X as D,x as F,R as H,K as I,m as S,E as U,vt as a,Ft as b,gt as c,mt as d,A as e,O as f,kt as g,xt as h,ft as i,ot as j,pt as k,At as m,Dt as p,St as s,wt as t,Tt as y};
@@ -0,0 +1,30 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import 'react';
3
+ type MousePosition = {
4
+ x: number;
5
+ y: number;
6
+ };
7
+ type MouseButton = "left" | "middle" | "right";
8
+ type MouseClickAction = "press" | "release" | null;
9
+ type MouseScrollAction = "scrolldown" | "scrollup" | null;
10
+ type MouseDragAction = "dragging" | null;
11
+ type MouseAction = MouseClickAction | MouseDragAction | MouseScrollAction;
12
+ /**
13
+ * Internal event emitter for mouse state changes.
14
+ *
15
+ * Events:
16
+ * - "position" (position: MousePosition)
17
+ * - "click" (position: MousePosition, action: MouseClickAction, button: MouseButton)
18
+ * - "scroll" (position: MousePosition, direction: MouseScrollAction)
19
+ * - "drag" (position: MousePosition, action: MouseDragAction, button: MouseButton)
20
+ */
21
+ type MouseEvents = EventEmitter;
22
+ type MouseContextShape = {
23
+ readonly button: MouseButton | null;
24
+ readonly click: MouseClickAction;
25
+ readonly drag: MouseDragAction;
26
+ readonly events: MouseEvents;
27
+ readonly position: MousePosition;
28
+ readonly scroll: MouseScrollAction;
29
+ };
30
+ export { MouseContextShape as M, MouseClickAction as a, MouseDragAction as b, MouseScrollAction as c, MousePosition as d, MouseButton as e, MouseAction as f, MouseEvents as g };
@@ -0,0 +1 @@
1
+ import{d as o}from"./ansi-parser-DlgLtOYO.js";export{o as parseSgrMouse};
@@ -0,0 +1 @@
1
+ import"yoga-layout";import{x as e,y as i,p as a}from"./measure-element-Cs7_proT.js";export{e as getAbsoluteContentPosition,i as getAbsolutePosition,a as processLayout};
@@ -0,0 +1 @@
1
+ import{createContext as C}from"react";import y from"react-reconciler";import{NoEventPriority as h,DiscreteEventPriority as v,DefaultEventPriority as b}from"react-reconciler/constants.js";import{unstable_shouldYield as T,unstable_scheduleCallback as x,unstable_now as k,unstable_cancelCallback as I}from"scheduler";import{LayoutNode as c}from"./LayoutNode-LPYsuzBg.js";import{applyStyles as m,resolveColor as f}from"./NAMED_COLORS-82DpREQV.js";import{g as P}from"./text-width-e49vlbQH.js";let u=null;function H(e){u=e}let d=h;function p(e){const t=f(e.fg===void 0?e.color===void 0?void 0:e.color:e.fg),n=f(e.bg===void 0?e.backgroundColor===void 0?void 0:e.backgroundColor:e.bg);let r;return e.styles===void 0?(r=0,e.bold&&(r|=1),(e.dim||e.dimColor)&&(r|=2),e.italic&&(r|=4),e.underline&&(r|=8),e.blink&&(r|=16),e.inverse&&(r|=32),e.hidden&&(r|=64),e.strikethrough&&(r|=128)):r=e.styles,{bg:n,fg:t,styles:r}}const N={afterActiveInstanceBlur:()=>{},appendChild(e,t){e.insertChild(t,e.children.length)},appendChildToContainer(e,t){e.insertChild(t,e.children.length)},appendInitialChild(e,t){e.insertChild(t,e.children.length)},beforeActiveInstanceBlur:()=>{},cancelCallback:I,cancelTimeout:clearTimeout,clearContainer(e){},commitTextUpdate(e,t,n){e.text=n,e.yogaNode.markDirty()},commitUpdate(e,t,n,r,s){m(e.yogaNode,r);const{bg:o,fg:i,styles:a}=p(r);e.fg=i,e.bg=o,e.styles=a,e._style=r,e.transform=typeof r.transform=="function"?r.transform:void 0},createInstance(e,t,n,r,s){const o=new c,i={...t};i.flexDirection===void 0&&(i.flexDirection="row"),i.flexShrink===void 0&&(i.flexShrink=1),m(o.yogaNode,i);const{bg:a,fg:l,styles:g}=p(t);return o.fg=l,o.bg=a,o.styles=g,o._style=t,typeof t.transform=="function"&&(o.transform=t.transform),o},createTextInstance(e,t,n,r){const s=new c;return s.text=e,s.yogaNode.setWidth(P(e)),s.yogaNode.setHeight(1),s},detachDeletedInstance:e=>{e.destroy()},finalizeInitialChildren(e,t,n,r,s){return!1},getChildHostContext(e,t,n){return{isInsideText:t==="text"}},getCurrentEventPriority:()=>v,getCurrentUpdatePriority:()=>d,getInstanceFromNode:()=>null,getPublicInstance(e){return e},getRootHostContext(e){return{isInsideText:!1}},hideInstance(e){e._hidden=!0},hideTextInstance(e){e._hidden=!0},HostTransitionContext:C(null),insertBefore(e,t,n){t.parent&&t.remove();const r=e.children.indexOf(n);e.insertChild(t,r)},isPrimaryRenderer:!0,maySuspendCommit:()=>!0,noTimeout:-1,NotPendingTransition:void 0,now:k,preloadInstance:()=>!0,prepareForCommit(e){return null},preparePortalMount:()=>{},prepareScopeUpdate:()=>{},prepareUpdate(e,t,n,r,s,o){if(n===r)return null;let i=0;for(const l of Object.keys(n))l!=="children"&&(i+=1);let a=0;for(const l of Object.keys(r))if(l!=="children"&&(a+=1,n[l]!==r[l]))return!0;return i===a?null:!0},removeChild(e,t){t.remove()},removeChildFromContainer(e,t){t.remove()},requestPostPaintCallback:()=>{},resetAfterCommit(e){typeof u=="function"&&u()},resolveEventTimeStamp:()=>-1.1,resolveEventType:()=>null,resolveUpdatePriority(){return d!==h?d:b},scheduleCallback:x,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){d=e},shouldAttemptEagerTransition:()=>!1,shouldSetTextContent(e,t){return!1},shouldYield:T,startSuspendingCommit:()=>{},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance:()=>{},trackSchedulerEvent:()=>{},unhideInstance(e,t){e._hidden=!1},unhideTextInstance(e,t){e._hidden=!1},waitForCommitToBeReady:()=>null,warnsIfNotActing:!0},M=y(N);export{M as T,H as s};
@@ -0,0 +1 @@
1
+ import{createRequire as x}from"node:module";import{version as L,createContext as R}from"react";import b from"react-reconciler";import{NoEventPriority as A,DefaultEventPriority as P}from"react-reconciler/constants.js";import{unstable_shouldYield as D,unstable_scheduleCallback as O,unstable_now as G,unstable_cancelCallback as F}from"scheduler";import n from"yoga-layout";import{b as _,d as f,s as m,m as p,e as v,r as T,f as w,c as W,h,j as I}from"./dom-rphpG0kf.js";const z=x(import.meta.url),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=S,k=[["top",n.EDGE_TOP],["right",n.EDGE_RIGHT],["bottom",n.EDGE_BOTTOM],["left",n.EDGE_LEFT]],B=(t,e)=>{if("position"in e){let r=n.POSITION_TYPE_RELATIVE;e.position==="absolute"?r=n.POSITION_TYPE_ABSOLUTE:e.position==="static"&&(r=n.POSITION_TYPE_STATIC),t.setPositionType(r)}for(const[r,s]of k){if(!(r in e))continue;const l=e[r];if(typeof l=="string"){t.setPositionPercent(s,Number.parseFloat(l));continue}t.setPosition(s,l)}},H=(t,e)=>{"margin"in e&&t.setMargin(n.EDGE_ALL,e.margin??0),"marginX"in e&&t.setMargin(n.EDGE_HORIZONTAL,e.marginX??0),"marginY"in e&&t.setMargin(n.EDGE_VERTICAL,e.marginY??0),"marginLeft"in e&&t.setMargin(n.EDGE_START,e.marginLeft||0),"marginRight"in e&&t.setMargin(n.EDGE_END,e.marginRight||0),"marginTop"in e&&t.setMargin(n.EDGE_TOP,e.marginTop||0),"marginBottom"in e&&t.setMargin(n.EDGE_BOTTOM,e.marginBottom||0)},M=(t,e)=>{"padding"in e&&t.setPadding(n.EDGE_ALL,e.padding??0),"paddingX"in e&&t.setPadding(n.EDGE_HORIZONTAL,e.paddingX??0),"paddingY"in e&&t.setPadding(n.EDGE_VERTICAL,e.paddingY??0),"paddingLeft"in e&&t.setPadding(n.EDGE_LEFT,e.paddingLeft||0),"paddingRight"in e&&t.setPadding(n.EDGE_RIGHT,e.paddingRight||0),"paddingTop"in e&&t.setPadding(n.EDGE_TOP,e.paddingTop||0),"paddingBottom"in e&&t.setPadding(n.EDGE_BOTTOM,e.paddingBottom||0)},U=(t,e)=>{"flexGrow"in e&&t.setFlexGrow(e.flexGrow??0),"flexShrink"in e&&t.setFlexShrink(typeof e.flexShrink=="number"?e.flexShrink:1),"flexWrap"in e&&(e.flexWrap==="nowrap"&&t.setFlexWrap(n.WRAP_NO_WRAP),e.flexWrap==="wrap"&&t.setFlexWrap(n.WRAP_WRAP),e.flexWrap==="wrap-reverse"&&t.setFlexWrap(n.WRAP_WRAP_REVERSE)),"flexDirection"in e&&(e.flexDirection==="row"&&t.setFlexDirection(n.FLEX_DIRECTION_ROW),e.flexDirection==="row-reverse"&&t.setFlexDirection(n.FLEX_DIRECTION_ROW_REVERSE),e.flexDirection==="column"&&t.setFlexDirection(n.FLEX_DIRECTION_COLUMN),e.flexDirection==="column-reverse"&&t.setFlexDirection(n.FLEX_DIRECTION_COLUMN_REVERSE)),"flexBasis"in e&&(typeof e.flexBasis=="number"?t.setFlexBasis(e.flexBasis):typeof e.flexBasis=="string"?t.setFlexBasisPercent(Number.parseInt(e.flexBasis,10)):t.setFlexBasis(Number.NaN)),"alignItems"in e&&((e.alignItems==="stretch"||!e.alignItems)&&t.setAlignItems(n.ALIGN_STRETCH),e.alignItems==="flex-start"&&t.setAlignItems(n.ALIGN_FLEX_START),e.alignItems==="center"&&t.setAlignItems(n.ALIGN_CENTER),e.alignItems==="flex-end"&&t.setAlignItems(n.ALIGN_FLEX_END),e.alignItems==="baseline"&&t.setAlignItems(n.ALIGN_BASELINE)),"alignSelf"in e&&((e.alignSelf==="auto"||!e.alignSelf)&&t.setAlignSelf(n.ALIGN_AUTO),e.alignSelf==="flex-start"&&t.setAlignSelf(n.ALIGN_FLEX_START),e.alignSelf==="center"&&t.setAlignSelf(n.ALIGN_CENTER),e.alignSelf==="flex-end"&&t.setAlignSelf(n.ALIGN_FLEX_END),e.alignSelf==="stretch"&&t.setAlignSelf(n.ALIGN_STRETCH),e.alignSelf==="baseline"&&t.setAlignSelf(n.ALIGN_BASELINE)),"alignContent"in e&&((e.alignContent==="flex-start"||!e.alignContent)&&t.setAlignContent(n.ALIGN_FLEX_START),e.alignContent==="center"&&t.setAlignContent(n.ALIGN_CENTER),e.alignContent==="flex-end"&&t.setAlignContent(n.ALIGN_FLEX_END),e.alignContent==="space-between"&&t.setAlignContent(n.ALIGN_SPACE_BETWEEN),e.alignContent==="space-around"&&t.setAlignContent(n.ALIGN_SPACE_AROUND),e.alignContent==="space-evenly"&&t.setAlignContent(n.ALIGN_SPACE_EVENLY),e.alignContent==="stretch"&&t.setAlignContent(n.ALIGN_STRETCH)),"justifyContent"in e&&((e.justifyContent==="flex-start"||!e.justifyContent)&&t.setJustifyContent(n.JUSTIFY_FLEX_START),e.justifyContent==="center"&&t.setJustifyContent(n.JUSTIFY_CENTER),e.justifyContent==="flex-end"&&t.setJustifyContent(n.JUSTIFY_FLEX_END),e.justifyContent==="space-between"&&t.setJustifyContent(n.JUSTIFY_SPACE_BETWEEN),e.justifyContent==="space-around"&&t.setJustifyContent(n.JUSTIFY_SPACE_AROUND),e.justifyContent==="space-evenly"&&t.setJustifyContent(n.JUSTIFY_SPACE_EVENLY))},Y=(t,e)=>{"width"in e&&(typeof e.width=="number"?t.setWidth(e.width):typeof e.width=="string"?t.setWidthPercent(Number.parseInt(e.width,10)):t.setWidthAuto()),"height"in e&&(typeof e.height=="number"?t.setHeight(e.height):typeof e.height=="string"?t.setHeightPercent(Number.parseInt(e.height,10)):t.setHeightAuto()),"minWidth"in e&&(typeof e.minWidth=="string"?t.setMinWidthPercent(Number.parseInt(e.minWidth,10)):t.setMinWidth(e.minWidth??0)),"minHeight"in e&&(typeof e.minHeight=="string"?t.setMinHeightPercent(Number.parseInt(e.minHeight,10)):t.setMinHeight(e.minHeight??0)),"maxWidth"in e&&(typeof e.maxWidth=="string"?t.setMaxWidthPercent(Number.parseInt(e.maxWidth,10)):t.setMaxWidth(e.maxWidth)),"maxHeight"in e&&(typeof e.maxHeight=="string"?t.setMaxHeightPercent(Number.parseInt(e.maxHeight,10)):t.setMaxHeight(e.maxHeight)),"aspectRatio"in e&&t.setAspectRatio(e.aspectRatio)},j=(t,e)=>{"display"in e&&t.setDisplay(e.display==="flex"?n.DISPLAY_FLEX:n.DISPLAY_NONE)},X=(t,e,r)=>{if(!("borderStyle"in e||"borderTop"in e||"borderBottom"in e||"borderLeft"in e||"borderRight"in e))return;const s=r.borderStyle?1:0;t.setBorder(n.EDGE_TOP,r.borderTop===!1?0:s),t.setBorder(n.EDGE_BOTTOM,r.borderBottom===!1?0:s),t.setBorder(n.EDGE_LEFT,r.borderLeft===!1?0:s),t.setBorder(n.EDGE_RIGHT,r.borderRight===!1?0:s)},V=(t,e)=>{"gap"in e&&t.setGap(n.GUTTER_ALL,e.gap??0),"columnGap"in e&&t.setGap(n.GUTTER_COLUMN,e.columnGap??0),"rowGap"in e&&t.setGap(n.GUTTER_ROW,e.rowGap??0)},J=(t,e)=>{const r=e.overflow??"visible",s=e.overflowX??r,l=e.overflowY??r;s==="scroll"||l==="scroll"?t.setOverflow(n.OVERFLOW_SCROLL):s==="hidden"||l==="hidden"?t.setOverflow(n.OVERFLOW_HIDDEN):t.setOverflow(n.OVERFLOW_VISIBLE)},C=(t,e={},r=e)=>{B(t,e),H(t,e),M(t,e),U(t,e),Y(t,e),j(t,e),X(t,e,r),V(t,e),J(t,r)};if(y.env.DEV==="true"){let t=!1;try{import.meta.resolve("react-devtools-core"),t=!0}catch{}t&&await import("../packem_chunks/devtools.js")}const N=(t,e)=>{if(t===e)return;if(!t)return e;const r={};let s=!1;for(const l of Object.keys(t))(!e||!Object.hasOwn(e,l))&&(r[l]=void 0,s=!0);if(e)for(const l of Object.keys(e))e[l]!==t[l]&&(r[l]=e[l],s=!0);return s?r:void 0},E=t=>{if(t){if(t.yogaNode?.unsetMeasureFunc(),"resizeObservers"in t&&t.resizeObservers?.clear(),"childNodes"in t&&t.childNodes)for(const e of t.childNodes)E(e);t.yogaNode?.free(),"cachedRender"in t&&(t.cachedRender=void 0),"childNodes"in t&&(t.childNodes=[]),t.parentNode=void 0}};let u=A,g;async function q(){const t=(await import("node:fs")).readFileSync(new URL("../package.json",import.meta.url),"utf8"),e=JSON.parse(t);return{name:e?.name,version:e?.version}}let d={name:"ink",version:L};if(y.env.DEV==="true")try{const t=await q();d={name:t.name||d.name,version:t.version||d.version}}catch(t){console.warn("Failed to load package.json in development mode. Falling back to default renderer metadata.",t)}const rt=b({afterActiveInstanceBlur(){},appendChild:f,appendChildToContainer:f,appendInitialChild:f,beforeActiveInstanceBlur(){},cancelCallback:F,cancelTimeout:clearTimeout,clearContainer:()=>!1,commitTextUpdate(t,e,r){m(t,r)},commitUpdate(t,e,r,s){g&&t.internal_static&&(g.isStaticDirty=!0);const l=N(r,s),a=N(r.style,s.style);if(!l&&!a)return;let i=!!a;if(l){for(const[o,c]of Object.entries(l))if(o!=="children"){if(o==="style"){h(t,c);continue}if(o==="internal_transform"){t.internal_transform=c,i=!0;continue}if(o==="internal_cursor"){t.internal_cursor=c,i=!0;continue}if(o==="internal_static"){t.internal_static=!0,i=!0;continue}if(o==="sticky"){t.internal_sticky=c,i=!0;continue}if(o==="internalStickyAlternate"){t.internal_stickyAlternate=c,i=!0;continue}if(o==="opaque"){t.internal_opaque=c,i=!0;continue}if(o==="scrollbar"){t.internal_scrollbar=c,i=!0;continue}if(o==="internal_terminalCursorFocus"){t.internal_terminalCursorFocus=c,i=!0;continue}if(o==="internal_terminalCursorPosition"){t.internal_terminalCursorPosition=c,i=!0;continue}if(o==="cachedRender"){t.cachedRender=c,i=!0;continue}I(t,o,c),i=!0}}a&&t.yogaNode&&C(t.yogaNode,a,s.style??{}),i&&p(t)},createInstance(t,e,r,s){if(s.isInsideText&&t==="ink-box")throw new Error("<Box> can’t be nested inside <Text> component");if(s.isInsideText&&t==="ink-cursor")throw new Error("<Cursor> can’t be nested inside <Text> component");const l=t==="ink-text"&&s.isInsideText?"ink-virtual-text":t,a=W(l);for(const[i,o]of Object.entries(e))if(i!=="children"){if(i==="style"){h(a,o),a.yogaNode&&C(a.yogaNode,o);continue}if(i==="internal_transform"){a.internal_transform=o;continue}if(i==="internal_cursor"){a.internal_cursor=o;continue}if(i==="internal_static"){g=r,a.internal_static=!0,r.isStaticDirty=!0,r.staticNode=a;continue}if(i==="sticky"){a.internal_sticky=o;continue}if(i==="internalStickyAlternate"){a.internal_stickyAlternate=o;continue}if(i==="opaque"){a.internal_opaque=o;continue}if(i==="scrollbar"){a.internal_scrollbar=o;continue}if(i==="internal_terminalCursorFocus"){a.internal_terminalCursorFocus=o;continue}if(i==="internal_terminalCursorPosition"){a.internal_terminalCursorPosition=o;continue}if(i==="internal_static"){a.internal_static=!0;continue}if(i==="cachedRender"){a.cachedRender=o;continue}I(a,i,o)}return a},createTextInstance(t,e,r){if(!r.isInsideText)throw new Error(`Text string "${t}" must be rendered inside <Text> component`);return w(t)},detachDeletedInstance(){},finalizeInitialChildren(){return!1},getChildHostContext(t,e){const r=t.isInsideText,s=e==="ink-text"||e==="ink-virtual-text";return r===s?t:{isInsideText:s}},getCurrentUpdatePriority:()=>u,getInstanceFromNode:()=>null,getInstanceFromScope:()=>null,getPublicInstance:t=>t,getRootHostContext:()=>({isInsideText:!1}),hideInstance(t){t.internal_hidden=!0,t.yogaNode?.setDisplay(n.DISPLAY_NONE),p(t)},hideTextInstance(t){m(t,"")},HostTransitionContext:R(null),insertBefore:_,insertInContainerBefore:_,isPrimaryRenderer:!0,maySuspendCommit(){return!0},noTimeout:-1,NotPendingTransition:void 0,now:G,preloadInstance(){return!0},prepareForCommit:()=>null,preparePortalMount:()=>null,prepareScopeUpdate(){},removeChild(t,e){T(t,e),E(e)},removeChildFromContainer(t,e){T(t,e),E(e)},rendererPackageName:d.name,rendererVersion:d.version,requestPostPaintCallback(){},resetAfterCommit(t){if(typeof t.onComputeLayout=="function"&&t.onComputeLayout(),v(t),t.staticNode!==t.previousStaticNode&&(t.previousStaticNode=t.staticNode,typeof t.onStaticChange=="function"&&t.onStaticChange()),t.isStaticDirty){t.isStaticDirty=!1,typeof t.onImmediateRender=="function"&&t.onImmediateRender();return}typeof t.onRender=="function"&&t.onRender()},resetFormInstance(){},resetTextContent(){},resolveEventTimeStamp(){return-1.1},resolveEventType(){return null},resolveUpdatePriority(){return u!==A?u:P},scheduleCallback:O,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(t){u=t},shouldAttemptEagerTransition(){return!1},shouldSetTextContent:()=>!1,shouldYield:D,startSuspendingCommit(){},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance(){},trackSchedulerEvent(){},unhideInstance(t){t.internal_hidden=!1,t.yogaNode?.setDisplay(n.DISPLAY_FLEX),p(t)},unhideTextInstance(t,e){m(t,e)},waitForCommitToBeReady(){return null}});export{C as c,rt as j};
@@ -0,0 +1 @@
1
+ import i from"react";import{FocusProvider as y,useFocusManager as W}from"./FocusContext-C2Sosxa4.js";import{TuiContext as I,useInput as z}from"./TuiContext-BNmP0lMY.js";import{LayoutNode as v}from"./LayoutNode-LPYsuzBg.js";import{T as f,s as P}from"./reconciler-ClpU7Y-V.js";import{renderTreeToBuffer as F}from"./renderTreeToBuffer-C8lS0lJ2.js";import{TuiApp as L}from"./TuiApp-BPL8v1i1.js";import{InputParser as T}from"./InputParser-CtwkCbrQ.js";import{terminalSize as G}from"./Renderer-DsskdkUd.js";import{createInlineLoop as M}from"./createInlineLoop-BT40Wpmx.js";const R=n=>i.createElement("box",n,n.children),K=n=>i.createElement("text",n,n.children),Q=()=>i.createElement(R,{flexGrow:1}),b=({children:n})=>{const{disableFocus:c,enableFocus:e,focusNext:a,focusPrevious:o}=W();return z((w,s)=>{s.tab&&!s.shift&&a(),s.tab&&s.shift&&o(),s.escape&&(c(),e())}),i.createElement(i.Fragment,null,n)};function V(n,c){const e=new L,a=new T(process.stdin),o=new v,{height:w,width:s}=e.getSize();o.yogaNode.setWidth(s),o.yogaNode.setHeight(w);const u=f.createContainer(o,0,null,!1,null,"",t=>console.error(t),null),p=t=>i.createElement(I.Provider,{value:{app:e,input:a,writeStderr:l=>e.writeStderr(l),writeStdout:l=>e.writeStdout(l)}},i.createElement(y,null,i.createElement(b,null,t)));f.updateContainer(p(n),u,null,()=>{});const h=(t,l)=>o.calculateLayout(t,l),x=(t,l,H)=>F(o,t,l,H),g=()=>e.paintNow(h,x);let S=!1;P(()=>{S=!0});const d=Math.round(1e3/(c?.maxFps??60)),E=setInterval(()=>{S&&(S=!1,g())},d);let N;const r=new Promise(t=>{N=t}),m=()=>{clearInterval(E),f.updateContainer(null,u,null,()=>{}),o.destroy(),e.stop(),a.stop(),process.off("SIGWINCH",C),N()};a.on("exit",()=>{m(),process.exit(0)}),e.on("quit",()=>{m(),process.exit(0)}),a.start(),e.start();const C=()=>{const t=process.stdout.columns||80,l=process.stdout.rows||24;e.resize(t,l),o.yogaNode.setWidth(t),o.yogaNode.setHeight(l),e.emit("resize"),g()};return process.on("SIGWINCH",C),g(),{app:e,input:a,rerender(t){f.updateContainer(p(t),u,null,()=>{})},unmount(){m()},waitUntilExit(){return r}}}function X(n,c){const e=G(),a=c?.rows??10,{cols:o}=e,w=Math.min(a,e.rows),s=new T(process.stdin),u=new v;u.yogaNode.setWidth(o),u.yogaNode.setHeight(w);const p=[],h=[],x={quit:()=>d.stop(),writeStderr:r=>h.push(r),writeStdout:r=>p.push(r)},g=f.createContainer(u,0,null,!1,null,"",r=>console.error(r),null),S=r=>i.createElement(I.Provider,{value:{app:x,input:s,writeStderr:x.writeStderr,writeStdout:x.writeStdout}},i.createElement(y,null,i.createElement(b,null,r)));f.updateContainer(S(n),g,null,()=>{}),P(()=>{});const d=M((r,m,C)=>{u.calculateLayout(m,C),F(u,r,m,C)},{...c,fps:c?.maxFps??c?.fps??60,rows:w});s.on("exit",()=>d.stop());let E;const N=new Promise(r=>{E=r});return process.on("exit",()=>{p.length>0&&process.stdout.write(p.join("")),h.length>0&&process.stderr.write(h.join("")),E()}),d.start(),s.start(),{unmount(){d.stop()},waitUntilExit(){return N}}}export{R as _Box,Q as _Spacer,K as _Text,V as render,X as renderInline};
@@ -0,0 +1,24 @@
1
+ import{createRequire as we}from"node:module";import{jsxs as $,jsx as x}from"react/jsx-runtime";import{cursorShow as nt,setMode as Vt,BracketedPasteMode as Xt,resetMode as Zt,cursorUp as yt,cursorTo as Ct,cursorHide as q,cursorDown as Te,setCursorStyle as Re,eraseLines as j,cursorNextLine as Se,eraseLineEnd as Ee,createDecMode as Oe,ALT_SCREEN_ON as Pe,clearScreenAndHomeCursor as Ne,ALT_SCREEN_OFF as ke}from"@visulima/ansi";import{wordWrap as De}from"@visulima/string";import Jt from"is-in-ci";import Le from"patch-console";import{ConcurrentRoot as Ie,LegacyRoot as $e}from"react-reconciler/constants.js";import{onExit as We}from"signal-exit";import A from"yoga-layout";import{a as Me}from"./accessibility-context-DDyHTwmA.js";import{PureComponent as Ae,useState as ct,useRef as W,useCallback as b,useEffect as vt,useMemo as F}from"react";import{e as Be}from"./animation-context-DW3p-vpk.js";import{t as He}from"./app-context-BVpKlG1z.js";import{o as Ue}from"./cursor-context-CFviBqPX.js";import{parseStacktrace as Ye}from"@visulima/error/stacktrace";import je from"code-excerpt";import{Box as _}from"../components/box.js";import{Text as M}from"../components/text.js";import{o as qe}from"./focus-context-CsT69klR.js";import{t as ze}from"./stderr-context-Bvnik0hL.js";import{e as Ge}from"./stdin-context-88AhuztD.js";import{t as Ve}from"./stdout-context-BnblEPez.js";import{I as Xe,v as Ze,r as Je,H as Qe}from"./renderer-COXHo5Xk.js";import{c as ti,e as ei}from"./dom-rphpG0kf.js";import{resolveFlags as ii}from"./kittyFlags-g8ALyoCU.js";import{p as ri}from"./load-native-root-binding-DDikxNox.js";import{a as oi}from"./measure-text-B7juNq4Y.js";import{j as D,c as si}from"./reconciler-DhUGYWCr.js";import{measureAndExtractObservers as ni}from"./ResizeObserver-aX8XOr2u.js";import{calculateScroll as ui}from"./calculateScroll-D4Y_JR4H.js";import{g as X}from"./utils-Bup8lyK8.js";const be=we(import.meta.url),Q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,st=e=>{if(typeof Q<"u"&&Q.versions&&Q.versions.node){const[t,i]=Q.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return Q.getBuiltinModule(e)}return be(e)},L=Q,{cwd:ye}=L,{Stream:xe}=st("node:stream"),{Buffer:Ht}=st("node:buffer"),{Console:Ce}=st("node:console"),{EventEmitter:_e}=st("node:events"),{existsSync:Ke,readFileSync:Fe}=st("node:fs"),Qt="\x1B[200~",Ut="\x1B[201~",ai=e=>e>=48&&e<=63,li=e=>e>=32&&e<=47,te=e=>e>=64&&e<=126,di=(e,t,i)=>{const r=t+i+1;let s=r;for(;s<e.length;s++){const a=e.codePointAt(s);if(a===void 0)return"pending";if(!(ai(a)||li(a))&&!(a===91&&s===r))return te(a)?{nextIndex:s+1,sequence:e.slice(t,s+1)}:void 0}return"pending"},ci=(e,t,i)=>{const r=t+i+2;if(r>e.length)return"pending";const s=e.codePointAt(r-1);if(!(s===void 0||!te(s)))return{nextIndex:r,sequence:e.slice(t,r)}},Kt=(e,t,i)=>{const r=e[t+i];if(r===void 0)return"pending";if(r==="[")return di(e,t,i);if(r==="O")return ci(e,t,i)},hi=(e,t)=>{const i=e.codePointAt(t+1),r=i!==void 0&&i>65535?2:1,s=t+1+r;return{nextIndex:s,sequence:e.slice(t,s)}},fi=(e,t)=>{if(t===e.length-1)return"pending";if(e[t+1]==="\x1B"){if(t+2>=e.length)return"pending";const r=Kt(e,t,2);return r==="pending"?"pending":r||{nextIndex:t+2,sequence:e.slice(t,t+2)}}const i=Kt(e,t,1);return i==="pending"?"pending":i||hi(e,t)},Ft=(e,t)=>{let i=0;for(let r=0;r<e.length;r++){const s=e[r];(s===""||s==="\b")&&(r>i&&t.push(e.slice(i,r)),t.push(s),i=r+1)}i<e.length&&t.push(e.slice(i))},pi=e=>{const t=[];let i=0;const r=s=>({events:t,pending:e.slice(s)});for(;i<e.length;){const s=e.indexOf("\x1B",i);if(s===-1)return Ft(e.slice(i),t),{events:t,pending:""};s>i&&Ft(e.slice(i,s),t);const a=fi(e,s);if(a==="pending")return r(s);if(a.sequence===Qt){const l=a.nextIndex,n=e.indexOf(Ut,l);if(n===-1)return r(s);t.push({paste:e.slice(l,n)}),i=n+Ut.length;continue}t.push(a.sequence),i=a.nextIndex}return{events:t,pending:""}},mi=()=>{let e="";return{flushPendingEscape(){if(!e.startsWith("\x1B"))return;const t=e;return e="",t},hasPendingEscape(){return e.startsWith("\x1B")&&!e.startsWith(Qt)&&e!=="\x1B[200"},push(t){const i=pi(e+t);return e=i.pending,i.events},reset(){e=""}}},wt=e=>{if(!e)return e;const t=ye();return e.replace(`file://${t}/`,"").replace(`${t}/`,"")};function gi({error:e}){const t=Ye(e),i=new Map,r=t.map(o=>{const u=!o.methodName&&!o.file?`raw:${o.raw}`:`${wt(o.file)??""}:${o.line}:${o.column}:${o.methodName??""}`,m=i.get(u)??0;return i.set(u,m+1),{key:`${u}#${m}`,trace:o}}),s=t[0],a=wt(s?.file);let l,n=0;if(a&&s?.line&&Ke(a)){const o=Fe(a,"utf8");if(l=je(o,s.line),l)for(const{line:u}of l)n=Math.max(n,String(u).length)}return $(_,{flexDirection:"column",padding:1,children:[$(_,{children:[$(M,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),$(M,{children:[" ",e.message]})]}),s&&a?x(_,{marginTop:1,children:$(M,{dimColor:!0,children:[a,":",s.line,":",s.column]})}):null,s&&l?x(_,{flexDirection:"column",marginTop:1,children:l.map(({line:o,value:u})=>$(_,{children:[x(_,{width:n+1,children:$(M,{"aria-label":o===s.line?`Line ${o}, error`:`Line ${o}`,backgroundColor:o===s.line?"red":void 0,color:o===s.line?"white":void 0,dimColor:o!==s.line,children:[String(o).padStart(n," "),":"]})}),x(M,{backgroundColor:o===s.line?"red":void 0,color:o===s.line?"white":void 0,children:` ${u}`})]},`excerpt-${o}`))}):null,t.length>0?x(_,{flexDirection:"column",marginTop:1,children:r.map(({key:o,trace:u})=>{const m=wt(u.file)??"";return!u.methodName&&!u.file?$(_,{children:[x(M,{dimColor:!0,children:"- "}),x(M,{bold:!0,dimColor:!0,children:u.raw})]},o):$(_,{children:[x(M,{dimColor:!0,children:"- "}),x(M,{bold:!0,dimColor:!0,children:u.methodName??"<anonymous>"}),$(M,{"aria-label":`at ${m} line ${u.line} column ${u.column}`,color:"gray",dimColor:!0,children:[" ","(",m,":",u.line,":",u.column,")"]})]},o)})}):null]})}class vi extends Ae{static displayName="InternalErrorBoundary";static getDerivedStateFromError(t){return{error:t}}state={error:void 0};componentDidCatch(t){this.props.onError(t)}render(){return this.state.error?x(gi,{error:this.state.error}):this.props.children}}const wi=" ",bi="\x1B[Z",yi="\x1B",xi=Vt(Xt),Yt=Zt(Xt),ee=({children:e,exitOnCtrlC:t,interactive:i,onExit:r,onWaitUntilRenderFlush:s,renderThrottleMs:a,setCursorPosition:l,stderr:n,stdin:o,stdout:u,writeToStderr:m,writeToStdout:y})=>{const[g,c]=ct(!0),[h,v]=ct(void 0),[,w]=ct([]),P=W(0),T=W(new Map),k=W(void 0),N=W(0),I=W(!1),E=W(0),[S]=ct(()=>{const d=new _e;return d.setMaxListeners(1/0),d}),K=W(void 0),R=W(void 0);R.current??=mi();const B=W(void 0),Tt=W(!1),ae=20,z=b(()=>{B.current&&(clearTimeout(B.current),B.current=void 0)},[]),G=b(()=>{k.current&&(clearTimeout(k.current),k.current=void 0)},[]),ut=b(()=>{if(G(),T.current.size===0)return;let d=Number.POSITIVE_INFINITY;for(const f of T.current.values())d=Math.min(d,f.nextDueTime);const p=Math.max(0,d-performance.now());k.current=setTimeout(()=>{k.current=void 0;const f=performance.now(),C=[...T.current.values()];for(const O of C){if(f<O.nextDueTime)continue;O.callback(f);const ge=f-O.startTime,ve=Math.floor(ge/O.interval)+1;O.nextDueTime=O.startTime+ve*O.interval}ut()},p)},[G]),Rt=b((d,p)=>{const f=performance.now();return T.current.set(d,{callback:d,interval:p,nextDueTime:f+p,startTime:f}),ut(),{startTime:f,unsubscribe(){if(T.current.delete(d),T.current.size===0){G();return}ut()}}},[G,ut]);vt(()=>()=>{G()},[G]);const H=o.isTTY,St=b(()=>{K.current&&(o.removeListener("readable",K.current),K.current=void 0)},[o]),at=b(()=>{R.current?.reset(),z(),St()},[z,St]),V=b(()=>{I.current=!1,o.setRawMode(!1),o.unref(),N.current=0,at()},[o,at]),et=b(d=>{H&&(N.current>0||I.current)&&V(),r(d)},[H,V,r]),Et=b(d=>{if(d.includes("")&&t){et();return}d===yi&&g&&v(p=>{if(!p)return p})},[t,et,g]),it=b(d=>{Et(d),S.emit("input",d)},[Et,S]),Ot=b(()=>{z(),B.current=setTimeout(()=>{B.current=void 0;const d=R.current.flushPendingEscape();d&&it(d)},ae)},[z,it]),gt=b(()=>{z();let d;for(;(d=o.read())!==null;){const p=R.current.push(d);for(const f of p)if(typeof f=="string")it(f);else{if(S.listenerCount("paste")===0){Tt.current||(Tt.current=!0,m(`Warning: useInput() received bracketed paste because no usePaste() handler is active. This fallback is deprecated and will be removed in the next major version. Migrate paste handling to usePaste().
2
+ `)),it(f.paste);continue}S.emit("paste",f.paste)}}R.current.hasPendingEscape()&&Ot()},[o,it,z,Ot,m,S]),Pt=b(()=>{K.current||(K.current=gt,o.addListener("readable",gt))},[o,gt]),Nt=b(d=>{if(!H)throw o===L.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
3
+ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`):new Error(`Raw mode is not supported on the stdin provided to Ink.
4
+ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(o.setEncoding("utf8"),d){if(N.current===0){const p=I.current;I.current=!1,p||(o.ref(),o.setRawMode(!0)),Pt()}N.current++;return}N.current!==0&&--N.current===0&&(at(),I.current=!0,queueMicrotask(()=>{I.current&&V()}))},[H,o,Pt,at,V]),kt=b(d=>{if(u.isTTY){if(d){E.current===0&&u.write(xi),E.current++;return}E.current!==0&&--E.current===0&&u.write(Yt)}},[u]),Dt=b((d,p)=>{const f=d.findIndex(C=>C.id===p);for(let C=f+1;C<d.length;C++){const O=d[C];if(O?.isActive)return O.id}},[]),Lt=b((d,p)=>{const f=d.findIndex(C=>C.id===p);for(let C=f-1;C>=0;C--){const O=d[C];if(O?.isActive)return O.id}},[]),lt=b(()=>{w(d=>(v(p=>{const f=d.find(C=>C.isActive)?.id;return Dt(d,p)??f}),d))},[Dt]),dt=b(()=>{w(d=>(v(p=>{const f=d.findLast(C=>C.isActive)?.id;return Lt(d,p)??f}),d))},[Lt]);vt(()=>{const d=f=>{!g||P.current===0||(f===wi&&lt(),f===bi&&dt())};S.on("input",d);const p=S;return()=>{p.off("input",d)}},[g,lt,dt,S]);const It=b(()=>{c(!0)},[]),$t=b(()=>{c(!1)},[]),Wt=b(d=>{w(p=>(p.some(f=>f?.id===d)&&v(d),p))},[]),Mt=b((d,{autoFocus:p})=>{w(f=>(P.current=f.length+1,[...f,{id:d,isActive:!0}])),p&&v(f=>f||d)},[]),_t=b(d=>{v(p=>{if(p!==d)return p}),w(p=>{const f=p.filter(C=>C.id!==d);return P.current=f.length,f})},[]),At=b(d=>{w(p=>p.map(f=>f.id!==d?f:{id:d,isActive:!0}))},[]),Bt=b(d=>{v(p=>{if(p!==d)return p}),w(p=>p.map(f=>f.id!==d?f:{id:d,isActive:!1}))},[]);vt(()=>()=>{const d=!u.destroyed&&!u.writableEnded;i&&d&&u.write(nt),H&&(N.current>0||I.current)&&V(),E.current>0&&(u.isTTY&&d&&u.write(Yt),E.current=0)},[u,H,V,i]);const le=F(()=>({exit:et,waitUntilRenderFlush:s}),[et,s]),de=F(()=>({internal_eventEmitter:S,internal_exitOnCtrlC:t,isRawModeSupported:H,setBracketedPasteMode:kt,setRawMode:Nt,stdin:o}),[o,Nt,kt,H,t,S]),ce=F(()=>({stdout:u,write:y}),[u,y]),he=F(()=>({stderr:n,write:m}),[n,m]),fe=F(()=>({setCursorPosition:l}),[l]),pe=F(()=>({activate:At,activeId:h,add:Mt,deactivate:Bt,disableFocus:$t,enableFocus:It,focus:Wt,focusNext:lt,focusPrevious:dt,remove:_t}),[h,Mt,_t,At,Bt,It,$t,lt,dt,Wt]),me=F(()=>({renderThrottleMs:a,subscribe:Rt}),[Rt,a]);return x(He.Provider,{value:le,children:x(Ge.Provider,{value:de,children:x(Ve.Provider,{value:ce,children:x(ze.Provider,{value:he,children:x(qe.Provider,{value:pe,children:x(Be.Provider,{value:me,children:x(Ue.Provider,{value:fe,children:x(vi,{onError:et,children:e})})})})})})})})};ee.displayName="InternalApp";const Ci=(e,t,i)=>{if(i<=0||!e.yogaNode)return"";const{yogaNode:r}=e,s=r.getComputedBorder(A.EDGE_LEFT),a=r.getComputedBorder(A.EDGE_RIGHT),l=r.getComputedBorder(A.EDGE_TOP),n=r.getComputedPadding(A.EDGE_LEFT),o=r.getComputedPadding(A.EDGE_RIGHT),u=r.getComputedPadding(A.EDGE_TOP),m=Math.round(r.getComputedWidth()-s-a-n-o);if(m<=0)return"";const y=new Xe({height:i,width:m}),g=-(e.internal_scrollState?.scrollLeft??0)-s-n,c=-t-l-u;for(const h of e.childNodes)Ze(h,y,{absoluteOffsetX:g,absoluteOffsetY:c,offsetX:g,offsetY:c,skipStaticElements:!1});return y.get().output},xt=new WeakMap,Ti={bar:6,"blinking-bar":5,"blinking-block":1,"blinking-underline":3,block:2,default:0,underline:4},jt=e=>Re(Ti[e]),ft=(e,t)=>e?.x!==t?.x||e?.y!==t?.y,tt=(e,t)=>{if(!t)return"";const i=e-t.y;return(i>0?yt(i):"")+Ct(t.x)+nt},ie=(e,t)=>{if(!t)return"";const i=e-1-t.y;return(i>0?Te(i):"")+Ct(0)},re=e=>{const t=e.cursorWasShown?q:"",i=ie(e.previousLineCount,e.previousCursorPosition),r=tt(e.visibleLineCount,e.cursorPosition);return t+i+r},pt=(e,t,i)=>e?q+ie(t,i):"",Z=e=>e??"default",oe=()=>{let e,t;return{consumeDelta:()=>{if(Z(t)===Z(e))return"";const i=Z(t);return e=t,jt(i)},consumeRestoreOnDone:()=>{const i=Z(e)!=="default";return e=void 0,t=void 0,i?jt("default"):""},isDirty:()=>Z(t)!==Z(e),setPending:i=>{t=i}}},ot=(e,t)=>t.endsWith(`
5
+ `)?e.length-1:e.length,se=e=>e.rows||1/0,mt=(e,t)=>Math.min(e,se(t)),Ri=(e,{showCursor:t=!1}={})=>{let i=0,r="",s=!1,a,l=!1,n,o=!1;const u=oe(),m=()=>l?a:void 0,y=(c,h)=>{const v=ft(h,n);return c!==r||v||u.isDirty()},g=c=>{!t&&!s&&(e.write(q),s=!0);const h=m();l=!1;const v=ft(h,n);if(!y(c,h))return!1;const w=u.consumeDelta(),P=c.split(`
6
+ `),T=ot(P,c),k=tt(T,h);if(c===r&&v)e.write(w+re({cursorPosition:h,cursorWasShown:o,previousCursorPosition:n,previousLineCount:i,visibleLineCount:T}));else if(c===r&&w!=="")e.write(w);else{r=c;const N=pt(o,i,n);e.write(w+N+j(mt(i,e))+c+k),i=P.length}return n=h?{...h}:void 0,o=h!==void 0,!0};return g.clear=()=>{const c=pt(o,i,n);e.write(c+j(mt(i,e))),r="",i=0,n=void 0,o=!1},g.done=()=>{r="",i=0,n=void 0,o=!1;const c=u.consumeRestoreOnDone();c!==""&&e.write(c),t||(e.write(nt),s=!1)},g.reset=()=>{r="",i=0,n=void 0,o=!1},g.sync=c=>{const h=l?a:void 0;l=!1;const v=c.split(`
7
+ `);r=c,i=v.length;const w=u.consumeDelta();w!==""&&e.write(w),!h&&o&&e.write(q),h&&e.write(tt(ot(v,c),h)),n=h?{...h}:void 0,o=h!==void 0},g.setCursorPosition=c=>{a=c,l=!0},g.setCursorShape=u.setPending,g.isCursorDirty=()=>l||u.isDirty(),g.willRender=c=>y(c,m()),g},Si=(e,{showCursor:t=!1}={})=>{let i=[],r="",s=!1,a,l=!1,n,o=!1;const u=oe(),m=()=>l?a:void 0,y=(c,h)=>{const v=ft(h,n);return c!==r||v||u.isDirty()},g=c=>{!t&&!s&&(e.write(q),s=!0);const h=m();l=!1;const v=ft(h,n);if(!y(c,h))return!1;const w=u.consumeDelta(),P=c.split(`
8
+ `),T=ot(P,c),k=ot(i,r);if(c===r&&v)return e.write(w+re({cursorPosition:h,cursorWasShown:o,previousCursorPosition:n,previousLineCount:i.length,visibleLineCount:T})),n=h?{...h}:void 0,o=h!==void 0,!0;if(c===r&&w!=="")return e.write(w),!0;const N=pt(o,i.length,n);if(c===`
9
+ `||r.length===0){const R=tt(T,h);return e.write(w+N+j(mt(i.length,e))+c+R),o=h!==void 0,n=h?{...h}:void 0,r=c,i=P,!0}const I=c.endsWith(`
10
+ `),E=[w,N],S=se(e);if(T<k){const R=r.endsWith(`
11
+ `)?1:0;E.push(j(Math.min(k-T+R,S)),yt(Math.min(T,S-1)))}else E.push(yt(Math.min(k-1,S-1)));for(let R=0;R<T;R++){const B=R===T-1;if(P[R]===i[R]){(!B||I)&&E.push(Se());continue}E.push(Ct(0)+P[R]+Ee+(B&&!I?"":`
12
+ `))}const K=tt(T,h);return E.push(K),e.write(E.join("")),o=h!==void 0,n=h?{...h}:void 0,r=c,i=P,!0};return g.clear=()=>{const c=pt(o,i.length,n);e.write(c+j(mt(i.length,e))),r="",i=[],n=void 0,o=!1},g.done=()=>{r="",i=[],n=void 0,o=!1;const c=u.consumeRestoreOnDone();c!==""&&e.write(c),t||(e.write(nt),s=!1)},g.reset=()=>{r="",i=[],n=void 0,o=!1},g.sync=c=>{const h=l?a:void 0;l=!1;const v=c.split(`
13
+ `);r=c,i=v;const w=u.consumeDelta();w!==""&&e.write(w),!h&&o&&e.write(q),h&&e.write(tt(ot(v,c),h)),n=h?{...h}:void 0,o=h!==void 0},g.setCursorPosition=c=>{a=c,l=!0},g.setCursorShape=u.setPending,g.isCursorDirty=()=>l||u.isDirty(),g.willRender=c=>y(c,m()),g},Ei=(e,{incremental:t=!1,showCursor:i=!1}={})=>t?Si(e,{showCursor:i}):Ri(e,{showCursor:i}),Oi={create:Ei},ne=Oe(2026),Y=Vt(ne),U=Zt(ne);function Pi(e,t){return"isTTY"in e&&e.isTTY&&(t??!Jt)}let J;const Ni=()=>{if(J!==!1){if(J!==void 0)return J;try{return J=ri(import.meta.url).Renderer,J}catch{J=!1;return}}},ki=e=>{const t=Ni();if(!t)return;let i,r=0,s=0;const a=(l,n)=>{(!i||r!==l||s!==n)&&(i?i.resize(l,n):i=new t(l,n),r=l,s=n)};return{clear(){if(i){const l=new Uint32Array(r*s*2),n=65535;for(let o=0;o<l.length;o+=2)l[o]=32,l[o+1]=n;i.render(l)}},destroy(){i=void 0},render(l,n,o){if(a(n,o),!!i){e.isTTY&&i.writeRaw(Y);try{i.render(l)}finally{e.isTTY&&i.writeRaw(U)}}},resize(l,n){a(l,n)}}};function qt(e,t=0,i={}){const r=i.leading??!0,s=i.trailing??!0;let a,l,n,o;const u=()=>{if(l===void 0)return;const h=l;l=void 0,o=e(...h)},m=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},y=()=>{a=void 0,s&&u(),l=void 0,n=void 0},g=()=>{m(),a=setTimeout(y,t)},c=function(...h){const v=Date.now();if(n??=v,v-n>=t)return l=h,u(),n=v,g(),o;l=h;const w=a===void 0;return g(),r&&w&&u(),o};return c.cancel=()=>{m(),l=void 0,n=void 0},c.flush=()=>(m(),u(),n=void 0,o),c}console.Console||(console.Console=Ce);const rt=()=>{},zt=async()=>new Promise(e=>{setImmediate(e)}),Di=27,Li=91,Ii=63,$i=117,Wi=48,Mi=57,_i=e=>e>=Wi&&e<=Mi,ue=(e,t)=>{if(e[t]!==Di||e[t+1]!==Li||e[t+2]!==Ii)return;let i=t+3;const r=i;for(;i<e.length&&_i(e[i]);)i++;if(i!==r){if(i===e.length)return{state:"partial"};if(e[i]===$i)return{endIndex:i,state:"complete"}}},Ai=e=>{for(let t=0;t<e.length;t++)if(ue(e,t)?.state==="complete")return!0;return!1},Bi=e=>{const t=[];let i=0;for(;i<e.length;){const r=ue(e,i);if(r?.state==="complete"){i=r.endIndex+1;continue}if(r?.state==="partial")break;t.push(e[i]),i++}return t},Hi=({isTty:e,isUnmounting:t,nextOutputHeight:i,previousOutputHeight:r,viewportRows:s})=>{if(!e)return!1;const a=r>0,l=r>=s,n=r>s,o=i>s,u=l&&i<s;return n||o&&a||u||t&&l},bt=e=>e instanceof Error||Object.prototype.toString.call(e)==="[object Error]",Gt=e=>{const t=!e.destroyed&&!e.writableEnded&&(e.writable??!0),i=e._writableState!==void 0||e.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:i}},ht=(e,t)=>{if(!e||typeof e.flush!="function")return;const i=e;t?i.flush():typeof i.cancel=="function"&&i.cancel()};class Ui{isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;backbufferNode;backbufferMultiWarned=!1;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=ti("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??L.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const i=t.debug||this.isScreenReaderEnabled,r=t.maxFps??30,s=r>0?Math.max(1,Math.ceil(1e3/r)):0;this.renderThrottleMs=i?0:s;const a=i?this.onRender:(()=>{const n=qt(this.onRender,s,{leading:!0,trailing:!0});return this.throttledOnRender=n,()=>{this.hasPendingThrottledRender=!0,n()}})();if(i&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let n=!1;const o=()=>{n||(n=!0,queueMicrotask(()=>{n=!1,this.onRender()}))};this.rootNode.onRender=o,this.rootNode.onImmediateRender=o}else this.rootNode.onRender=a,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=Oi.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=ki(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=i?this.log:qt(n=>{const o=this.log.willRender(n),u=this.shouldSync();u&&o&&this.options.stdout.write(Y),this.log(n),u&&o&&this.options.stdout.write(U)},void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.isUnmounting=!1,this.isConcurrent=t.concurrent??!1,this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.lastTerminalWidth=X(this.options.stdout).columns,this.fullStaticOutput="";const l=t.concurrent?Ie:$e;this.container=D.createContainer(this.rootNode,l,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=We(this.unmount,{alwaysLast:!1}),this.setAlternateScreen(!!t.alternateScreen),t.patchConsole&&this.patchConsole(),this.interactive&&(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)}),this.initImmediateKittyKeyboard(),L.env.DEV==="true"&&D.injectIntoDevTools(),this.exitPromise=new Promise((n,o)=>{this.resolveExitPromise=n,this.rejectExitPromise=o}),this.exitPromise.catch(rt)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=()=>{const t=X(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),oi(),this.calculateLayout(),ei(this.rootNode),this.onRender(),this.lastTerminalWidth=t};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};handleAppExit=t=>{if(!(this.isUnmounted||this.isUnmounting)){if(bt(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}};getActiveCursorPosition=()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition;setCursorPosition=t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())};restoreLastOutput=()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
14
+ `))};calculateLayout=()=>{const t=r=>{const s=new Map;this.calculateScrollAndTriggerObservers(r,s);for(const[a,l]of s)a.internalTrigger(l)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const i=X(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(i),this.rootNode.yogaNode.calculateLayout(void 0,void 0,A.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,i){if(t.nodeName==="ink-box"){const{style:r}=t,s=r.overflow??"visible",a=r.overflowX??s,l=r.overflowY??s;a==="scroll"||l==="scroll"?(ui(t),r.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(ni(t,i),!t.internal_static)for(const r of t.childNodes)r.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(r,i)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,i){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),si(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let r=0;for(const s of t.childNodes){const a=s;s.nodeName!=="#text"&&a.yogaNode&&(t.yogaNode.insertChild(a.yogaNode,r),r++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const r of t.childNodes)r.nodeName!=="#text"&&this.prepareYogaTree(r,i);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const r=X(this.options.stdout).columns,{width:s}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof s=="number"?s:r),t.yogaNode.calculateLayout(void 0,void 0,A.DIRECTION_LTR)),i(t),Je(t,{skipStaticElements:!1}),t.internal_onRendered?.()}}markAllTextNodesDirty(t){if(!t.cachedRender){t.nodeName==="ink-text"&&t.yogaNode&&t.yogaNode.markDirty();for(const i of t.childNodes)i.nodeName!=="#text"&&this.markAllTextNodesDirty(i)}}handleStaticChange=()=>{this.fullStaticOutput=""};computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const i=Math.round(t.internal_scrollState.scrollTop),r=t.yogaNode?.getComputedPadding(A.EDGE_TOP)??0,s=Math.max(0,i-Math.round(r)),a=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:l}=t.style,n=l===void 0?a:Math.max(a,s-Math.max(0,l)),o=s-n;if(o<=0)return"";const u=Ci(t,n,o);return u===""?"":(t.internal_maxPushedScrollTop=s,`${u}\x1B[0m
15
+ `)}onRender=()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=Qe(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:i,cursorRequested:r,cursorShape:s,output:a,outputBuffer:l,outputHeight:n,outputWidth:o,staticOutput:u}=t;this.renderedCursorRequested=r,this.renderedCursorPosition=i,this.log.setCursorShape(r?s:void 0);const m=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&l&&o){u&&u!==`
16
+ `&&this.options.stdout.write(u),m&&this.options.stdout.write(m),this.nativeLog.render(l,o,n),this.lastOutputHeight=n;return}r&&this.log.setCursorPosition(this.getActiveCursorPosition());const y=u&&u!==`
17
+ `;if(this.options.debug){y&&(this.fullStaticOutput+=u),this.lastOutput=a,this.lastOutputToRender=a,this.lastOutputHeight=n,this.options.stdout.write(this.fullStaticOutput+a);return}if(!this.interactive){y&&this.options.stdout.write(u),this.lastOutput=a,this.lastOutputToRender=`${a}
18
+ `,this.lastOutputHeight=n;return}if(this.isScreenReaderEnabled){const g=this.shouldSync();if(g&&this.options.stdout.write(Y),y){const v=this.lastOutputHeight>0?j(this.lastOutputHeight):"";this.options.stdout.write(v+u),this.lastOutputHeight=0}if(a===this.lastOutput&&!y){g&&this.options.stdout.write(U);return}const c=X(this.options.stdout).columns,h=De(a,{trim:!1,width:c,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(y)this.options.stdout.write(h);else{const v=this.lastOutputHeight>0?j(this.lastOutputHeight):"";this.options.stdout.write(v+h)}this.lastOutput=a,this.lastOutputToRender=h,this.lastOutputHeight=h===""?0:h.split(`
19
+ `).length,g&&this.options.stdout.write(U);return}y&&(this.fullStaticOutput+=u),this.renderInteractiveFrame(a,n,y?u:"",m)};accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const i=x(Me.Provider,{value:this.accessibilityContextValue,children:x(ee,{exitOnCtrlC:this.options.exitOnCtrlC,interactive:this.interactive,onExit:this.handleAppExit,onWaitUntilRenderFlush:this.waitUntilRenderFlush,renderThrottleMs:this.renderThrottleMs,setCursorPosition:this.setCursorPosition,stderr:this.options.stderr,stdin:this.options.stdin,stdout:this.options.stdout,writeToStderr:this.writeToStderr,writeToStdout:this.writeToStdout,children:t})});this.options.concurrent?D.updateContainer(i,this.container,null,rt):(D.updateContainerSync(i,this.container,null,rt),D.flushSyncWork())}writeToStdout=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stdout.write(t);return}const i=this.shouldSync();i&&this.options.stdout.write(Y),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),i&&this.options.stdout.write(U)};writeToStderr=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stderr.write(t);return}const i=this.shouldSync();i&&this.options.stdout.write(Y),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),i&&this.options.stdout.write(U)};unmount=t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(L.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const i=this.options.stdout,{canWriteToStdout:r,hasWritableState:s}=Gt(i);ht(this.throttledOnRender,r),r&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),ht(this.throttledLog,r),typeof this.restoreConsole=="function"&&this.restoreConsole();const a=()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),r&&(this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen?(this.log.clear(),this.log.done(),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.fullStaticOutput="",this.writeBestEffort(this.options.stdout,ke),this.writeBestEffort(this.options.stdout,nt),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
20
+ `:`${this.lastOutput}
21
+ `)),this.kittyProtocolEnabled=!1,xt.delete(this.options.stdout);const{exitResult:n}=this,o=()=>{bt(t)?this.rejectExitPromise(t):this.resolveExitPromise(n)};t!==void 0&&!bt(t)?o():r&&s?this.options.stdout.write("",o):setImmediate(o)},l=D;this.options.concurrent?(D.updateContainerSync(null,this.container,null,rt),D.flushSyncWork(),l.flushPassiveEffects?.(),a()):(D.updateContainerSync(null,this.container,null,rt),D.flushSyncWork(),a())};async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},L.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await zt(),this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(this.isConcurrent&&this.hasPendingConcurrentWork()&&(await Promise.race([this.awaitNextRender(),this.awaitExit()]),this.isUnmounted||this.isUnmounting)){this.nextRenderCommit=void 0,await this.awaitExit();return}D.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:i,hasWritableState:r}=Gt(t);if(ht(this.throttledOnRender,i),ht(this.throttledLog,i),i&&r){await new Promise(s=>{this.options.stdout.write("",()=>{s()})});return}await zt()}clear(){this.interactive&&!this.options.debug&&(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
22
+ `))}patchConsole(){this.options.debug||(this.restoreConsole=Le((t,i)=>{t==="stdout"&&this.writeToStdout(i),t==="stderr"&&(i.startsWith("The above error occurred")||this.writeToStderr(i))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,Pe),this.writeBestEffort(this.options.stdout,q))}resolveInteractiveOption(t){return t??(!Jt&&!!this.options.stdout.isTTY)}resolveAlternateScreenOption(t,i){return!!t&&i&&!!this.options.stdout.isTTY}shouldSync(){return Pi(this.options.stdout,this.interactive)}writeBestEffort(t,i){try{t.write(i)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){const t=this.container;return(t.pendingLanes??0)!==0&&t.callbackNode!==void 0&&t.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let t;const i=new Promise(r=>{t=r});this.nextRenderCommit={promise:i,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,i,r,s=""){const a=r+s,l=a!=="",n=this.options.stdout.isTTY,o=n?X(this.options.stdout).rows:24,u=n&&i>=o?t:`${t}
23
+ `;if(Hi({isTty:n,isUnmounting:this.isUnmounting,nextOutputHeight:i,previousOutputHeight:this.lastOutputHeight,viewportRows:o})){if(this.options.incrementalRendering){l&&(this.log.clear(),this.options.stdout.write(a)),(t!==this.lastOutput||this.log.isCursorDirty()||l)&&this.throttledLog(u),this.lastOutput=t,this.lastOutputToRender=u,this.lastOutputHeight=i;return}const m=this.shouldSync();m&&this.options.stdout.write(Y),this.options.stdout.write(Ne+this.fullStaticOutput+s+t),this.lastOutput=t,this.lastOutputToRender=u,this.lastOutputHeight=i,this.log.sync(u),m&&this.options.stdout.write(U);return}if(l){const m=this.shouldSync();m&&this.options.stdout.write(Y),this.log.clear(),this.options.stdout.write(a),this.log(u),m&&this.options.stdout.write(U)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(u);this.lastOutput=t,this.lastOutputToRender=u,this.lastOutputHeight=i}initImmediateKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="enabled")return;const i=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(i)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const i=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(i)}confirmKittySupport(t){const{stdin:i,stdout:r}=this.options;let s=[];const a=()=>{this.cancelKittyDetection=void 0,clearTimeout(n),i.removeListener("data",l);const o=Bi(s);s=[],o.length>0&&i.unshift(Ht.from(o))},l=o=>{const u=typeof o=="string"?Ht.from(o):o;for(const m of u)s.push(m);Ai(s)&&(a(),this.isUnmounted||this.enableKittyProtocol(t))};i.on("data",l);const n=setTimeout(a,200);this.cancelKittyDetection=a,r.write("\x1B[?u")}enableKittyProtocol(t){this.options.stdout.write(`\x1B[>${ii(t)}u`),this.kittyProtocolEnabled=!0}}const xr=(e,t)=>{const i={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:L.stderr,stdin:L.stdin,stdout:L.stdout,...Ki(t)},r=Fi(i.stdout,()=>new Ui(i));return r.render(e),{cleanup(){r.unmount()},clear(){r.clear()},rerender(s){r.render(s)},rootNode:r.rootNode,unmount(){r.unmount()},waitUntilExit(){return r.waitUntilExit()},waitUntilRenderFlush(){return r.waitUntilRenderFlush()}}},Ki=(e={})=>e instanceof xe?{stdin:L.stdin,stdout:e}:e,Fi=(e,t)=>{const i=xt.get(e);if(i===void 0){const r=t();return xt.set(e,r),r}return L.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
24
+ `),i};export{xr as default};
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { a as DOMElement } from "./dom.d-DzUPFLuP.js";
2
+ import { D as DOMElement } from "./dom.d-B4kXbaVY.js";
3
3
  import 'node:stream';
4
4
  import { a as CursorPosition } from "./cursor-helpers.d-BONB9tky.js";
5
5
  declare const kittyFlags: {