@buoy-gg/ask-buoy 7.0.41 → 7.0.43

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 (313) hide show
  1. package/README.md +13 -98
  2. package/lib/commonjs/blocks/AskBlocks.js +1 -338
  3. package/lib/commonjs/blocks/BlockRenderer.js +1 -262
  4. package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
  5. package/lib/commonjs/blocks/DataBlocks.js +1 -783
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1862
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -158
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +2 -592
  9. package/lib/commonjs/blocks/blockText.js +1 -60
  10. package/lib/commonjs/blocks/blockText.test.js +1 -53
  11. package/lib/commonjs/blocks/context.js +1 -42
  12. package/lib/commonjs/blocks/icons.js +1 -96
  13. package/lib/commonjs/blocks/index.js +1 -95
  14. package/lib/commonjs/blocks/listRow.test.js +1 -55
  15. package/lib/commonjs/blocks/pageState.js +1 -34
  16. package/lib/commonjs/blocks/pageState.test.js +1 -57
  17. package/lib/commonjs/blocks/primitives.js +1 -457
  18. package/lib/commonjs/blocks/primitivesIndex.js +1 -62
  19. package/lib/commonjs/blocks/ruleStates.js +1 -39
  20. package/lib/commonjs/components/ApprovalCard.js +1 -297
  21. package/lib/commonjs/components/AskBuoyHeader.js +1 -196
  22. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  23. package/lib/commonjs/components/AskBuoyModal.js +2 -482
  24. package/lib/commonjs/components/AskBuoySettings.js +1 -181
  25. package/lib/commonjs/components/ChangesBar.js +1 -212
  26. package/lib/commonjs/components/Composer.js +1 -255
  27. package/lib/commonjs/components/EmptyState.js +1 -161
  28. package/lib/commonjs/components/KeyboardPad.js +1 -80
  29. package/lib/commonjs/components/Markdown.js +1 -310
  30. package/lib/commonjs/components/MessageList.js +1 -970
  31. package/lib/commonjs/components/QueuedMessages.js +1 -145
  32. package/lib/commonjs/components/ThinkingStrip.js +1 -223
  33. package/lib/commonjs/components/TypingDots.js +1 -63
  34. package/lib/commonjs/components/markdownParse.js +1 -131
  35. package/lib/commonjs/components/markdownParse.test.js +1 -99
  36. package/lib/commonjs/components/useCopyAction.js +1 -50
  37. package/lib/commonjs/index.js +1 -252
  38. package/lib/commonjs/preset.js +1 -91
  39. package/lib/commonjs/store/activityGroups.js +1 -110
  40. package/lib/commonjs/store/activityGroups.test.js +1 -78
  41. package/lib/commonjs/store/askBuoySettings.js +1 -72
  42. package/lib/commonjs/store/askBuoyStore.js +2 -588
  43. package/lib/commonjs/store/blockPlacement.js +1 -64
  44. package/lib/commonjs/store/blockPlacement.test.js +1 -123
  45. package/lib/commonjs/store/queue.test.js +1 -150
  46. package/lib/commonjs/store/resetConversation.js +1 -77
  47. package/lib/commonjs/store/restorePending.test.js +1 -63
  48. package/lib/commonjs/store/restoredIds.test.js +1 -47
  49. package/lib/commonjs/store/suggestions.js +1 -54
  50. package/lib/commonjs/store/suggestions.test.js +1 -58
  51. package/lib/commonjs/store/systemLine.test.js +1 -77
  52. package/lib/commonjs/store/ticketPrompt.js +1 -17
  53. package/lib/commonjs/store/traceText.js +1 -81
  54. package/lib/commonjs/store/traceText.test.js +1 -112
  55. package/lib/commonjs/store/transcriptPersistence.js +1 -297
  56. package/lib/commonjs/store/transcriptPersistence.test.js +1 -333
  57. package/lib/commonjs/store/turnRendering.test.js +1 -151
  58. package/lib/commonjs/store/useAskBuoy.js +1 -651
  59. package/lib/commonjs/store/useAskBuoySettings.js +1 -14
  60. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -153
  61. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
  62. package/lib/commonjs/sync/wire.js +1 -58
  63. package/lib/commonjs/types.js +1 -6
  64. package/lib/module/blocks/AskBlocks.js +1 -331
  65. package/lib/module/blocks/BlockRenderer.js +1 -257
  66. package/lib/module/blocks/ChromePrototypes.js +1 -503
  67. package/lib/module/blocks/DataBlocks.js +1 -769
  68. package/lib/module/blocks/ExtraBlocks.js +1 -1835
  69. package/lib/module/blocks/MediaBlocks.js +1 -153
  70. package/lib/module/blocks/ReceiptBlocks.js +2 -580
  71. package/lib/module/blocks/blockText.js +1 -55
  72. package/lib/module/blocks/blockText.test.js +1 -53
  73. package/lib/module/blocks/context.js +1 -35
  74. package/lib/module/blocks/icons.js +1 -91
  75. package/lib/module/blocks/index.js +1 -8
  76. package/lib/module/blocks/listRow.test.js +1 -56
  77. package/lib/module/blocks/pageState.js +1 -30
  78. package/lib/module/blocks/pageState.test.js +1 -56
  79. package/lib/module/blocks/primitives.js +1 -445
  80. package/lib/module/blocks/primitivesIndex.js +1 -5
  81. package/lib/module/blocks/ruleStates.js +1 -35
  82. package/lib/module/components/ApprovalCard.js +1 -292
  83. package/lib/module/components/AskBuoyHeader.js +1 -193
  84. package/lib/module/components/AskBuoyIcon.js +1 -8
  85. package/lib/module/components/AskBuoyModal.js +2 -477
  86. package/lib/module/components/AskBuoySettings.js +1 -176
  87. package/lib/module/components/ChangesBar.js +1 -206
  88. package/lib/module/components/Composer.js +1 -250
  89. package/lib/module/components/EmptyState.js +1 -156
  90. package/lib/module/components/KeyboardPad.js +1 -75
  91. package/lib/module/components/Markdown.js +1 -305
  92. package/lib/module/components/MessageList.js +1 -964
  93. package/lib/module/components/QueuedMessages.js +1 -140
  94. package/lib/module/components/ThinkingStrip.js +1 -218
  95. package/lib/module/components/TypingDots.js +1 -58
  96. package/lib/module/components/markdownParse.js +1 -125
  97. package/lib/module/components/markdownParse.test.js +1 -98
  98. package/lib/module/components/useCopyAction.js +1 -46
  99. package/lib/module/index.js +1 -34
  100. package/lib/module/preset.js +1 -74
  101. package/lib/module/store/activityGroups.js +1 -103
  102. package/lib/module/store/activityGroups.test.js +1 -77
  103. package/lib/module/store/askBuoySettings.js +1 -67
  104. package/lib/module/store/askBuoyStore.js +2 -582
  105. package/lib/module/store/blockPlacement.js +1 -59
  106. package/lib/module/store/blockPlacement.test.js +1 -122
  107. package/lib/module/store/queue.test.js +1 -149
  108. package/lib/module/store/resetConversation.js +1 -72
  109. package/lib/module/store/restorePending.test.js +1 -62
  110. package/lib/module/store/restoredIds.test.js +1 -46
  111. package/lib/module/store/suggestions.js +1 -49
  112. package/lib/module/store/suggestions.test.js +1 -57
  113. package/lib/module/store/systemLine.test.js +1 -76
  114. package/lib/module/store/ticketPrompt.js +1 -13
  115. package/lib/module/store/traceText.js +1 -75
  116. package/lib/module/store/traceText.test.js +1 -111
  117. package/lib/module/store/transcriptPersistence.js +1 -287
  118. package/lib/module/store/transcriptPersistence.test.js +1 -332
  119. package/lib/module/store/turnRendering.test.js +1 -150
  120. package/lib/module/store/useAskBuoy.js +1 -646
  121. package/lib/module/store/useAskBuoySettings.js +1 -9
  122. package/lib/module/sync/askBuoySyncAdapter.js +1 -148
  123. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
  124. package/lib/module/sync/wire.js +1 -47
  125. package/lib/module/types.js +1 -4
  126. package/lib/web/index.mjs +11 -12
  127. package/package.json +8 -12
  128. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  129. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  130. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  131. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  132. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  133. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  134. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  135. package/lib/commonjs/blocks/blockText.js.map +0 -1
  136. package/lib/commonjs/blocks/blockText.test.js.map +0 -1
  137. package/lib/commonjs/blocks/context.js.map +0 -1
  138. package/lib/commonjs/blocks/icons.js.map +0 -1
  139. package/lib/commonjs/blocks/index.js.map +0 -1
  140. package/lib/commonjs/blocks/listRow.test.js.map +0 -1
  141. package/lib/commonjs/blocks/pageState.js.map +0 -1
  142. package/lib/commonjs/blocks/pageState.test.js.map +0 -1
  143. package/lib/commonjs/blocks/primitives.js.map +0 -1
  144. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  145. package/lib/commonjs/blocks/ruleStates.js.map +0 -1
  146. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  147. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  148. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  149. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  150. package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
  151. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  152. package/lib/commonjs/components/Composer.js.map +0 -1
  153. package/lib/commonjs/components/EmptyState.js.map +0 -1
  154. package/lib/commonjs/components/KeyboardPad.js.map +0 -1
  155. package/lib/commonjs/components/Markdown.js.map +0 -1
  156. package/lib/commonjs/components/MessageList.js.map +0 -1
  157. package/lib/commonjs/components/QueuedMessages.js.map +0 -1
  158. package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
  159. package/lib/commonjs/components/TypingDots.js.map +0 -1
  160. package/lib/commonjs/components/markdownParse.js.map +0 -1
  161. package/lib/commonjs/components/markdownParse.test.js.map +0 -1
  162. package/lib/commonjs/components/useCopyAction.js.map +0 -1
  163. package/lib/commonjs/index.js.map +0 -1
  164. package/lib/commonjs/preset.js.map +0 -1
  165. package/lib/commonjs/store/activityGroups.js.map +0 -1
  166. package/lib/commonjs/store/activityGroups.test.js.map +0 -1
  167. package/lib/commonjs/store/askBuoySettings.js.map +0 -1
  168. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  169. package/lib/commonjs/store/blockPlacement.js.map +0 -1
  170. package/lib/commonjs/store/blockPlacement.test.js.map +0 -1
  171. package/lib/commonjs/store/queue.test.js.map +0 -1
  172. package/lib/commonjs/store/resetConversation.js.map +0 -1
  173. package/lib/commonjs/store/restorePending.test.js.map +0 -1
  174. package/lib/commonjs/store/restoredIds.test.js.map +0 -1
  175. package/lib/commonjs/store/suggestions.js.map +0 -1
  176. package/lib/commonjs/store/suggestions.test.js.map +0 -1
  177. package/lib/commonjs/store/systemLine.test.js.map +0 -1
  178. package/lib/commonjs/store/ticketPrompt.js.map +0 -1
  179. package/lib/commonjs/store/traceText.js.map +0 -1
  180. package/lib/commonjs/store/traceText.test.js.map +0 -1
  181. package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
  182. package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
  183. package/lib/commonjs/store/turnRendering.test.js.map +0 -1
  184. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  185. package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
  186. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  187. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  188. package/lib/commonjs/sync/wire.js.map +0 -1
  189. package/lib/commonjs/types.js.map +0 -1
  190. package/lib/module/blocks/AskBlocks.js.map +0 -1
  191. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  192. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  193. package/lib/module/blocks/DataBlocks.js.map +0 -1
  194. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  195. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  196. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  197. package/lib/module/blocks/blockText.js.map +0 -1
  198. package/lib/module/blocks/blockText.test.js.map +0 -1
  199. package/lib/module/blocks/context.js.map +0 -1
  200. package/lib/module/blocks/icons.js.map +0 -1
  201. package/lib/module/blocks/index.js.map +0 -1
  202. package/lib/module/blocks/listRow.test.js.map +0 -1
  203. package/lib/module/blocks/pageState.js.map +0 -1
  204. package/lib/module/blocks/pageState.test.js.map +0 -1
  205. package/lib/module/blocks/primitives.js.map +0 -1
  206. package/lib/module/blocks/primitivesIndex.js.map +0 -1
  207. package/lib/module/blocks/ruleStates.js.map +0 -1
  208. package/lib/module/components/ApprovalCard.js.map +0 -1
  209. package/lib/module/components/AskBuoyHeader.js.map +0 -1
  210. package/lib/module/components/AskBuoyIcon.js.map +0 -1
  211. package/lib/module/components/AskBuoyModal.js.map +0 -1
  212. package/lib/module/components/AskBuoySettings.js.map +0 -1
  213. package/lib/module/components/ChangesBar.js.map +0 -1
  214. package/lib/module/components/Composer.js.map +0 -1
  215. package/lib/module/components/EmptyState.js.map +0 -1
  216. package/lib/module/components/KeyboardPad.js.map +0 -1
  217. package/lib/module/components/Markdown.js.map +0 -1
  218. package/lib/module/components/MessageList.js.map +0 -1
  219. package/lib/module/components/QueuedMessages.js.map +0 -1
  220. package/lib/module/components/ThinkingStrip.js.map +0 -1
  221. package/lib/module/components/TypingDots.js.map +0 -1
  222. package/lib/module/components/markdownParse.js.map +0 -1
  223. package/lib/module/components/markdownParse.test.js.map +0 -1
  224. package/lib/module/components/useCopyAction.js.map +0 -1
  225. package/lib/module/index.js.map +0 -1
  226. package/lib/module/preset.js.map +0 -1
  227. package/lib/module/store/activityGroups.js.map +0 -1
  228. package/lib/module/store/activityGroups.test.js.map +0 -1
  229. package/lib/module/store/askBuoySettings.js.map +0 -1
  230. package/lib/module/store/askBuoyStore.js.map +0 -1
  231. package/lib/module/store/blockPlacement.js.map +0 -1
  232. package/lib/module/store/blockPlacement.test.js.map +0 -1
  233. package/lib/module/store/queue.test.js.map +0 -1
  234. package/lib/module/store/resetConversation.js.map +0 -1
  235. package/lib/module/store/restorePending.test.js.map +0 -1
  236. package/lib/module/store/restoredIds.test.js.map +0 -1
  237. package/lib/module/store/suggestions.js.map +0 -1
  238. package/lib/module/store/suggestions.test.js.map +0 -1
  239. package/lib/module/store/systemLine.test.js.map +0 -1
  240. package/lib/module/store/ticketPrompt.js.map +0 -1
  241. package/lib/module/store/traceText.js.map +0 -1
  242. package/lib/module/store/traceText.test.js.map +0 -1
  243. package/lib/module/store/transcriptPersistence.js.map +0 -1
  244. package/lib/module/store/transcriptPersistence.test.js.map +0 -1
  245. package/lib/module/store/turnRendering.test.js.map +0 -1
  246. package/lib/module/store/useAskBuoy.js.map +0 -1
  247. package/lib/module/store/useAskBuoySettings.js.map +0 -1
  248. package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
  249. package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
  250. package/lib/module/sync/wire.js.map +0 -1
  251. package/lib/module/types.js.map +0 -1
  252. package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
  253. package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
  254. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
  255. package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
  256. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
  257. package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
  258. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
  259. package/lib/typescript/blocks/blockText.d.ts.map +0 -1
  260. package/lib/typescript/blocks/blockText.test.d.ts.map +0 -1
  261. package/lib/typescript/blocks/context.d.ts.map +0 -1
  262. package/lib/typescript/blocks/icons.d.ts.map +0 -1
  263. package/lib/typescript/blocks/index.d.ts.map +0 -1
  264. package/lib/typescript/blocks/listRow.test.d.ts.map +0 -1
  265. package/lib/typescript/blocks/pageState.d.ts.map +0 -1
  266. package/lib/typescript/blocks/pageState.test.d.ts.map +0 -1
  267. package/lib/typescript/blocks/primitives.d.ts.map +0 -1
  268. package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
  269. package/lib/typescript/blocks/ruleStates.d.ts.map +0 -1
  270. package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
  271. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  272. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  273. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  274. package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
  275. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  276. package/lib/typescript/components/Composer.d.ts.map +0 -1
  277. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  278. package/lib/typescript/components/KeyboardPad.d.ts.map +0 -1
  279. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  280. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  281. package/lib/typescript/components/QueuedMessages.d.ts.map +0 -1
  282. package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
  283. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  284. package/lib/typescript/components/markdownParse.d.ts.map +0 -1
  285. package/lib/typescript/components/markdownParse.test.d.ts.map +0 -1
  286. package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
  287. package/lib/typescript/index.d.ts.map +0 -1
  288. package/lib/typescript/preset.d.ts.map +0 -1
  289. package/lib/typescript/store/activityGroups.d.ts.map +0 -1
  290. package/lib/typescript/store/activityGroups.test.d.ts.map +0 -1
  291. package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
  292. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  293. package/lib/typescript/store/blockPlacement.d.ts.map +0 -1
  294. package/lib/typescript/store/blockPlacement.test.d.ts.map +0 -1
  295. package/lib/typescript/store/queue.test.d.ts.map +0 -1
  296. package/lib/typescript/store/resetConversation.d.ts.map +0 -1
  297. package/lib/typescript/store/restorePending.test.d.ts.map +0 -1
  298. package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
  299. package/lib/typescript/store/suggestions.d.ts.map +0 -1
  300. package/lib/typescript/store/suggestions.test.d.ts.map +0 -1
  301. package/lib/typescript/store/systemLine.test.d.ts.map +0 -1
  302. package/lib/typescript/store/ticketPrompt.d.ts.map +0 -1
  303. package/lib/typescript/store/traceText.d.ts.map +0 -1
  304. package/lib/typescript/store/traceText.test.d.ts.map +0 -1
  305. package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
  306. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
  307. package/lib/typescript/store/turnRendering.test.d.ts.map +0 -1
  308. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  309. package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
  310. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  311. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  312. package/lib/typescript/sync/wire.d.ts.map +0 -1
  313. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,769 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Show blocks — data the user should see rather than read.
5
- * Every one honours a cap and says "+N more" rather than growing the page.
6
- */
7
- import { useState } from "react";
8
- import { Image, Pressable, StyleSheet, Text, View } from "react-native";
9
- import { AlertTriangle, Check, Info, night, X } from "@buoy-gg/shared-ui";
10
- import { DataViewer, TreeDiffViewer } from "@buoy-gg/shared-ui/dataViewer";
11
- import { CAPS } from "@buoy-gg/agent-core";
12
- import { ActionRow, blockStyles as b, Card, More, toneColor, useBlockHandlers, usePaged } from "./primitivesIndex";
13
- import { renderInline } from "../components/Markdown";
14
- import { useCopyAction } from "../components/useCopyAction";
15
- import { blockToText } from "./blockText";
16
- import { BlockIcon } from "./icons";
17
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
18
- function fmt(v) {
19
- if (v === undefined) return "—";
20
- if (v === null) return "null";
21
- if (typeof v === "string") return v;
22
- if (typeof v === "number" || typeof v === "boolean") return String(v);
23
- try {
24
- const s = JSON.stringify(v);
25
- return s.length > 120 ? `${s.slice(0, 117)}…` : s;
26
- } catch {
27
- return String(v);
28
- }
29
- }
30
- export function Table({
31
- block
32
- }) {
33
- const paged = usePaged(block.rows, CAPS.tableRows);
34
- const {
35
- visible
36
- } = paged;
37
- const cols = block.columns.slice(0, 4);
38
- return /*#__PURE__*/_jsxs(Card, {
39
- title: block.title,
40
- source: block.source,
41
- testID: `buoy-block-table-${block.id}`,
42
- children: [/*#__PURE__*/_jsx(View, {
43
- style: styles.tableHead,
44
- children: cols.map((c, i) => /*#__PURE__*/_jsx(Text, {
45
- style: [styles.th, i === 0 && styles.firstCol],
46
- numberOfLines: 1,
47
- children: c
48
- }, c))
49
- }), visible.map((row, r) => /*#__PURE__*/_jsx(View, {
50
- style: [styles.tr, r > 0 && b.rowDivider],
51
- children: cols.map((_, i) => {
52
- const cell = row[i];
53
- const text = typeof cell === "string" ? cell : cell?.text ?? "";
54
- const tone = typeof cell === "string" ? undefined : cell?.tone;
55
- return /*#__PURE__*/_jsx(Text, {
56
- style: [styles.td, i === 0 && styles.firstCol, i === 0 && styles.tdFirst, tone && {
57
- color: toneColor(tone)
58
- }],
59
- numberOfLines: 2,
60
- children: renderInline(text, styles.td)
61
- }, i);
62
- })
63
- }, r)), /*#__PURE__*/_jsx(More, {
64
- paged: paged
65
- })]
66
- });
67
- }
68
- export function KeyValue({
69
- block
70
- }) {
71
- const paged = usePaged(block.pairs, CAPS.keyValuePairs);
72
- const {
73
- visible
74
- } = paged;
75
- const [open, setOpen] = useState(null);
76
- return /*#__PURE__*/_jsxs(Card, {
77
- title: block.title,
78
- source: block.source,
79
- testID: `buoy-block-keyvalue-${block.id}`,
80
- children: [visible.map((p, i) => {
81
- const long = typeof p.value === "object" && p.value !== null;
82
- const isOpen = open === p.key;
83
- return /*#__PURE__*/_jsxs(Pressable, {
84
- onPress: long ? () => setOpen(isOpen ? null : p.key) : undefined,
85
- style: [styles.kvRow, i > 0 && b.rowDivider],
86
- children: [/*#__PURE__*/_jsx(Text, {
87
- style: styles.kvKey,
88
- numberOfLines: 1,
89
- children: p.key
90
- }), /*#__PURE__*/_jsx(Text, {
91
- style: [styles.kvValue, isOpen && b.mono],
92
- numberOfLines: isOpen ? undefined : 2,
93
- selectable: true,
94
- children: isOpen ? JSON.stringify(p.value, null, 2) : fmt(p.value)
95
- })]
96
- }, p.key);
97
- }), /*#__PURE__*/_jsx(More, {
98
- paged: paged
99
- })]
100
- });
101
- }
102
-
103
- /**
104
- * Keys carry the index as well as the id.
105
- *
106
- * The ids in here come from the app's own data, and app data is not required
107
- * to be unique — a Poké Mart bag in this repo holds two lines sharing one
108
- * `lineId`, which is a bug in that app but must not be one in a devtool
109
- * rendering it. Paging made it visible: the duplicate sat past the initial cap,
110
- * so React only saw the collision on the first "Show more".
111
- */
112
- /**
113
- * What a tapped list row does.
114
- *
115
- * A row can carry a picture and an action, and they want the same gesture. The
116
- * picture wins the row body — looking at a thing must not fire it — and the
117
- * action keeps its label as its own control. A row with no picture is
118
- * unchanged: the whole row runs the action, which is what it did before rows
119
- * could open.
120
- */
121
- export function listRowBehaviour(item) {
122
- const canExpand = Boolean(item.image);
123
- return {
124
- canExpand,
125
- rowRunsAction: Boolean(item.action) && !canExpand,
126
- actionIsOwnControl: Boolean(item.action) && canExpand
127
- };
128
- }
129
- export function List({
130
- block
131
- }) {
132
- const h = useBlockHandlers();
133
- const paged = usePaged(block.items, CAPS.listItems);
134
- const {
135
- visible
136
- } = paged;
137
- // One row open at a time, keyed the same way the row is — the list can hold
138
- // duplicate ids (see the note above), so the index is part of the key.
139
- const [open, setOpen] = useState(null);
140
- return /*#__PURE__*/_jsxs(Card, {
141
- title: block.title,
142
- source: block.source,
143
- testID: `buoy-block-list-${block.id}`,
144
- children: [visible.map((it, i) => {
145
- const key = `${it.id ?? it.title}-${i}`;
146
- const expanded = open === key;
147
- // A row with a picture opens it; a row without one keeps the old
148
- // behaviour, where the whole row runs its action. When an item has
149
- // BOTH, the body toggles the image and the action label becomes its
150
- // own control — otherwise the two gestures would sit on one target and
151
- // looking at a thing would fire it.
152
- const {
153
- canExpand,
154
- rowRunsAction,
155
- actionIsOwnControl
156
- } = listRowBehaviour(it);
157
- const Row = canExpand || rowRunsAction ? Pressable : View;
158
- const rowProps = canExpand ? {
159
- onPress: () => setOpen(expanded ? null : key),
160
- accessibilityRole: "button",
161
- accessibilityState: {
162
- expanded
163
- },
164
- accessibilityLabel: `${it.title}, ${expanded ? "hide" : "show"} picture`,
165
- testID: `buoy-block-list-row-${key}`
166
- } : rowRunsAction ? {
167
- onPress: () => void h.runAction(it.action, block.id),
168
- accessibilityRole: "button"
169
- } : {};
170
- return /*#__PURE__*/_jsxs(View, {
171
- style: i > 0 ? b.rowDivider : undefined,
172
- children: [expanded && it.image ? /*#__PURE__*/_jsx(Pressable, {
173
- onPress: () => setOpen(null),
174
- accessibilityRole: "button",
175
- accessibilityLabel: `Hide ${it.title}`,
176
- testID: `buoy-block-list-hero-${key}`,
177
- style: styles.listHero,
178
- children: /*#__PURE__*/_jsx(Image, {
179
- testID: "buoy-internal-chat-image",
180
- source: {
181
- uri: it.image
182
- },
183
- style: styles.listHeroImage,
184
- resizeMode: "contain",
185
- accessibilityLabel: it.title
186
- })
187
- }) : null, /*#__PURE__*/_jsxs(Row, {
188
- ...rowProps,
189
- style: b.row,
190
- children: [it.image && !expanded ? /*#__PURE__*/_jsx(Image, {
191
- testID: "buoy-internal-chat-image",
192
- source: {
193
- uri: it.image
194
- },
195
- style: styles.thumb,
196
- resizeMode: "contain",
197
- accessibilityLabel: it.title
198
- }) : it.icon ? /*#__PURE__*/_jsx(BlockIcon, {
199
- name: it.icon
200
- }) : null, /*#__PURE__*/_jsxs(View, {
201
- style: styles.flex,
202
- children: [/*#__PURE__*/_jsx(Text, {
203
- style: [b.rowTitle, it.tone && {
204
- color: toneColor(it.tone)
205
- }],
206
- numberOfLines: expanded ? undefined : 2,
207
- children: renderInline(it.title, b.rowTitle)
208
- }), it.subtitle ? /*#__PURE__*/_jsx(Text, {
209
- style: b.rowSub,
210
- numberOfLines: expanded ? undefined : 2,
211
- children: renderInline(it.subtitle, b.rowSub)
212
- }) : null]
213
- }), it.trailing ? /*#__PURE__*/_jsx(Text, {
214
- style: [b.rowTrailing, it.tone && {
215
- color: toneColor(it.tone)
216
- }],
217
- numberOfLines: 1,
218
- children: it.trailing
219
- }) : null, it.action ? actionIsOwnControl ? /*#__PURE__*/_jsx(Pressable, {
220
- onPress: () => void h.runAction(it.action, block.id),
221
- accessibilityRole: "button",
222
- accessibilityLabel: it.action.label,
223
- hitSlop: 8,
224
- children: /*#__PURE__*/_jsx(Text, {
225
- style: styles.rowAction,
226
- children: it.action.label
227
- })
228
- }) : /*#__PURE__*/_jsx(Text, {
229
- style: styles.rowAction,
230
- children: it.action.label
231
- }) : null]
232
- })]
233
- }, key);
234
- }), /*#__PURE__*/_jsx(More, {
235
- paged: paged
236
- })]
237
- });
238
- }
239
-
240
- /** An object or an array — something the tree viewer can drill into. */
241
- function isStructured(v) {
242
- return v !== null && typeof v === "object";
243
- }
244
-
245
- /**
246
- * The line that stands in for a folded diff: how many fields, and which.
247
- * Names beat a bare count — "1 field · lines" tells you whether to open it.
248
- */
249
- function diffSummary(changes) {
250
- const names = changes.map(c => c.path);
251
- const shown = names.slice(0, 3).join(", ");
252
- const rest = names.length - 3;
253
- const noun = names.length === 1 ? "1 field" : `${names.length} fields`;
254
- return `${noun} · ${shown}${rest > 0 ? `, +${rest}` : ""}`;
255
- }
256
-
257
- /**
258
- * What a write changed. Folded by default (see `Card`), and drilled into
259
- * rather than dumped.
260
- *
261
- * A changed field is rendered by the same tree diff viewer the Zustand and
262
- * Storage tools use, with unchanged branches hidden — so editing one line of a
263
- * bag shows `qty 4 => 14` and not both copies of a fifty-key array serialised
264
- * to JSON, which is what the reader was given before and could not read. Only
265
- * a scalar keeps the plain −/+ pair: a tree of one root node says less than
266
- * the two values side by side.
267
- */
268
- export function Diff({
269
- block
270
- }) {
271
- const paged = usePaged(block.changes, CAPS.keyValuePairs);
272
- return /*#__PURE__*/_jsxs(Card, {
273
- title: block.title ?? "What changed",
274
- source: block.source,
275
- testID: `buoy-block-diff-${block.id}`,
276
- collapsible: true,
277
- summary: diffSummary(block.changes),
278
- children: [paged.visible.map((c, i) => {
279
- const added = c.before === undefined && c.after !== undefined;
280
- const removed = c.after === undefined && c.before !== undefined;
281
- return /*#__PURE__*/_jsxs(View, {
282
- style: [styles.diffRow, i > 0 && b.rowDivider],
283
- children: [/*#__PURE__*/_jsx(Text, {
284
- style: styles.diffPath,
285
- numberOfLines: 1,
286
- children: c.path
287
- }), isStructured(c.before) || isStructured(c.after) ? /*#__PURE__*/_jsx(View, {
288
- style: styles.diffTree,
289
- children: /*#__PURE__*/_jsx(TreeDiffViewer, {
290
- oldValue: c.before,
291
- newValue: c.after,
292
- showUnchanged: false,
293
- scrollEnabled: false
294
- })
295
- }) : /*#__PURE__*/_jsxs(_Fragment, {
296
- children: [!added ? /*#__PURE__*/_jsxs(View, {
297
- style: styles.diffLine,
298
- children: [/*#__PURE__*/_jsx(Text, {
299
- style: [styles.diffMark, {
300
- color: night.color.danger
301
- }],
302
- children: "\u2212"
303
- }), /*#__PURE__*/_jsx(Text, {
304
- style: [styles.diffValue, {
305
- color: night.color.danger
306
- }],
307
- numberOfLines: 3,
308
- selectable: true,
309
- children: fmt(c.before)
310
- })]
311
- }) : null, !removed ? /*#__PURE__*/_jsxs(View, {
312
- style: styles.diffLine,
313
- children: [/*#__PURE__*/_jsx(Text, {
314
- style: [styles.diffMark, {
315
- color: night.color.accent
316
- }],
317
- children: "+"
318
- }), /*#__PURE__*/_jsx(Text, {
319
- style: [styles.diffValue, {
320
- color: night.color.accent
321
- }],
322
- numberOfLines: 3,
323
- selectable: true,
324
- children: fmt(c.after)
325
- })]
326
- }) : null]
327
- })]
328
- }, `${c.path}-${i}`);
329
- }), /*#__PURE__*/_jsx(More, {
330
- paged: paged
331
- })]
332
- });
333
- }
334
- export function Chart({
335
- block
336
- }) {
337
- const bars = block.bars.slice(0, CAPS.chartBars);
338
- const max = block.max ?? Math.max(1, ...bars.map(x => x.value));
339
- return /*#__PURE__*/_jsx(Card, {
340
- title: block.title,
341
- source: block.source,
342
- testID: `buoy-block-chart-${block.id}`,
343
- children: /*#__PURE__*/_jsx(View, {
344
- style: styles.chart,
345
- children: bars.map((x, i) => /*#__PURE__*/_jsxs(View, {
346
- style: styles.barRow,
347
- children: [/*#__PURE__*/_jsx(Text, {
348
- style: styles.barLabel,
349
- numberOfLines: 1,
350
- children: x.label
351
- }), /*#__PURE__*/_jsx(View, {
352
- style: styles.barTrack,
353
- children: /*#__PURE__*/_jsx(View, {
354
- style: [styles.bar, {
355
- width: `${Math.max(2, Math.round(x.value / max * 100))}%`,
356
- backgroundColor: toneColor(x.tone ?? "accent")
357
- }]
358
- })
359
- }), /*#__PURE__*/_jsxs(Text, {
360
- style: styles.barValue,
361
- numberOfLines: 1,
362
- children: [x.value, x.unit ? ` ${x.unit}` : ""]
363
- })]
364
- }, `${x.label}-${i}`))
365
- })
366
- });
367
- }
368
- export function Steps({
369
- block
370
- }) {
371
- return /*#__PURE__*/_jsx(Card, {
372
- title: block.title,
373
- testID: `buoy-block-steps-${block.id}`,
374
- children: block.steps.map((s, i) => /*#__PURE__*/_jsxs(View, {
375
- style: [styles.step, i > 0 && b.rowDivider],
376
- children: [/*#__PURE__*/_jsx(View, {
377
- style: [styles.stepMark, s.state === "done" && styles.stepDone, s.state === "failed" && styles.stepFailed],
378
- children: s.state === "done" ? /*#__PURE__*/_jsx(Check, {
379
- size: 10,
380
- color: night.color.onAccent
381
- }) : s.state === "failed" ? /*#__PURE__*/_jsx(X, {
382
- size: 10,
383
- color: night.color.text
384
- }) : /*#__PURE__*/_jsx(Text, {
385
- style: styles.stepNum,
386
- children: i + 1
387
- })
388
- }), /*#__PURE__*/_jsx(Text, {
389
- style: [b.rowTitle, s.state === "done" && styles.stepTextDone],
390
- children: s.text
391
- })]
392
- }, i))
393
- });
394
- }
395
-
396
- /**
397
- * Parsed JSON, or `undefined` when the payload is not JSON at all.
398
- *
399
- * A bare string, number or boolean parses fine and is deliberately rejected:
400
- * `"hello"` is valid JSON and a tree of one leaf is a worse way to read it
401
- * than the line itself.
402
- */
403
- function parseJson(text) {
404
- try {
405
- const value = JSON.parse(text);
406
- return value !== null && typeof value === "object" ? value : undefined;
407
- } catch {
408
- return undefined;
409
- }
410
- }
411
-
412
- /**
413
- * A JSON payload, in the same explorer Storage and Network use.
414
- *
415
- * Worth the weight over a pretty-printed string: it collapses, it types its
416
- * values, and the thing you are usually hunting — one wrong field deep in a
417
- * response body — is findable instead of buried in forty lines of monospace.
418
- * The explorer's own lists run `scrollEnabled={false}` and grow to their
419
- * content, so nothing nests a scroller inside the transcript.
420
- */
421
- function JsonCode({
422
- block,
423
- value
424
- }) {
425
- return /*#__PURE__*/_jsx(Card, {
426
- title: block.title,
427
- testID: `buoy-block-code-${block.id}`,
428
- children: /*#__PURE__*/_jsx(View, {
429
- style: styles.viewer,
430
- children: /*#__PURE__*/_jsx(DataViewer, {
431
- title: block.title ?? "Payload",
432
- data: value,
433
- initialExpanded: true,
434
- showTypeFilter: false,
435
- testIDPrefix: `buoy-block-code-${block.id}`
436
- })
437
- })
438
- });
439
- }
440
-
441
- /** Anything that is not a JSON object: a log line, a stack, a snippet. */
442
- function TextCode({
443
- block
444
- }) {
445
- return /*#__PURE__*/_jsx(Card, {
446
- title: block.title,
447
- testID: `buoy-block-code-${block.id}`,
448
- children: /*#__PURE__*/_jsx(Text, {
449
- style: [b.mono, styles.code],
450
- selectable: true,
451
- children: block.text
452
- })
453
- });
454
- }
455
-
456
- /**
457
- * Router, per rule4: two specialised components rather than one that changes
458
- * shape. A `cond ? <A/> : <B/>` inside a single component is the Fabric
459
- * view-index hazard, and these two subtrees have nothing in common.
460
- */
461
- export function Code({
462
- block
463
- }) {
464
- const value = parseJson(block.text);
465
- if (value === undefined) return /*#__PURE__*/_jsx(TextCode, {
466
- block: block
467
- });
468
- return /*#__PURE__*/_jsx(JsonCode, {
469
- block: block,
470
- value: value
471
- });
472
- }
473
- export function Notice({
474
- block
475
- }) {
476
- const color = block.tone === "danger" ? night.color.danger : block.tone === "warning" ? night.color.warning : night.color.info;
477
- const Icon = block.tone === "info" ? Info : AlertTriangle;
478
- return /*#__PURE__*/_jsxs(Card, {
479
- tone: block.tone,
480
- testID: `buoy-block-notice-${block.id}`,
481
- children: [/*#__PURE__*/_jsxs(View, {
482
- style: styles.noticeRow,
483
- children: [/*#__PURE__*/_jsx(Icon, {
484
- size: 14,
485
- color: color
486
- }), /*#__PURE__*/_jsx(Text, {
487
- style: styles.noticeText,
488
- children: block.text
489
- })]
490
- }), /*#__PURE__*/_jsx(ActionRow, {
491
- actions: block.actions,
492
- blockId: block.id
493
- })]
494
- });
495
- }
496
- export function Finding({
497
- block
498
- }) {
499
- // A finding exists to leave the phone. Its own Copy, with the title and
500
- // every evidence row — the conversation-wide Copy includes it too, but a
501
- // ticket wants just this.
502
- const {
503
- copied,
504
- copy
505
- } = useCopyAction(() => blockToText(block) ?? block.title);
506
- return /*#__PURE__*/_jsxs(Card, {
507
- title: block.title,
508
- source: block.source,
509
- testID: `buoy-block-finding-${block.id}`,
510
- tone: "warning",
511
- children: [block.evidence.map((e, i) => /*#__PURE__*/_jsxs(View, {
512
- style: [styles.kvRow, i > 0 && b.rowDivider],
513
- children: [/*#__PURE__*/_jsx(Text, {
514
- style: styles.kvKey,
515
- numberOfLines: 1,
516
- children: e.label
517
- }), /*#__PURE__*/_jsx(Text, {
518
- style: [styles.kvValue, e.tone && {
519
- color: toneColor(e.tone)
520
- }],
521
- selectable: true,
522
- children: e.value
523
- })]
524
- }, `${e.label}-${i}`)), /*#__PURE__*/_jsx(View, {
525
- style: styles.findingFoot,
526
- children: /*#__PURE__*/_jsx(Pressable, {
527
- testID: `buoy-block-finding-copy-${block.id}`,
528
- accessibilityRole: "button",
529
- accessibilityLabel: copied ? "Copied" : "Copy this finding",
530
- onPress: copy,
531
- style: ({
532
- pressed
533
- }) => [styles.findingCopy, pressed && {
534
- opacity: 0.7
535
- }],
536
- children: /*#__PURE__*/_jsx(Text, {
537
- style: [styles.findingCopyText, copied && {
538
- color: night.color.accent
539
- }],
540
- children: copied ? "Copied" : "Copy finding"
541
- })
542
- })
543
- }), /*#__PURE__*/_jsx(ActionRow, {
544
- actions: block.actions,
545
- blockId: block.id
546
- })]
547
- });
548
- }
549
- const styles = StyleSheet.create({
550
- flex: {
551
- flex: 1
552
- },
553
- tableHead: {
554
- flexDirection: "row",
555
- paddingHorizontal: 12,
556
- paddingVertical: 6,
557
- gap: 8,
558
- backgroundColor: night.color.fill
559
- },
560
- th: {
561
- flex: 1,
562
- color: night.color.textTertiary,
563
- fontSize: night.font.micro,
564
- fontWeight: "700",
565
- letterSpacing: 0.6,
566
- textTransform: "uppercase"
567
- },
568
- tr: {
569
- flexDirection: "row",
570
- paddingHorizontal: 12,
571
- paddingVertical: 8,
572
- gap: 8,
573
- alignItems: "center"
574
- },
575
- td: {
576
- flex: 1,
577
- color: night.color.textSecondary,
578
- fontSize: night.font.caption,
579
- lineHeight: 17
580
- },
581
- tdFirst: {
582
- color: night.color.text,
583
- fontWeight: "500"
584
- },
585
- firstCol: {
586
- flex: 1.4
587
- },
588
- kvRow: {
589
- flexDirection: "row",
590
- gap: 12,
591
- paddingHorizontal: 12,
592
- paddingVertical: 8,
593
- alignItems: "flex-start"
594
- },
595
- kvKey: {
596
- width: 110,
597
- color: night.color.textSecondary,
598
- fontSize: night.font.caption,
599
- paddingTop: 1
600
- },
601
- kvValue: {
602
- flex: 1,
603
- color: night.color.text,
604
- fontSize: night.font.caption,
605
- lineHeight: 17
606
- },
607
- findingFoot: {
608
- flexDirection: "row",
609
- paddingHorizontal: 12,
610
- paddingVertical: 8,
611
- borderTopWidth: StyleSheet.hairlineWidth,
612
- borderTopColor: night.color.separator
613
- },
614
- findingCopy: {
615
- paddingHorizontal: 10,
616
- paddingVertical: 5,
617
- borderRadius: night.radius.badge,
618
- backgroundColor: night.color.fill
619
- },
620
- findingCopyText: {
621
- color: night.color.textSecondary,
622
- fontSize: night.font.micro,
623
- fontWeight: "600"
624
- },
625
- thumb: {
626
- width: 40,
627
- height: 40,
628
- borderRadius: 8,
629
- backgroundColor: night.color.fill
630
- },
631
- // The enlarged picture, sitting above the row it belongs to. Same height and
632
- // fitting as `imageGrid`'s hero so the two blocks enlarge alike.
633
- listHero: {
634
- paddingHorizontal: 12,
635
- paddingTop: 12
636
- },
637
- listHeroImage: {
638
- width: "100%",
639
- height: 240,
640
- borderRadius: night.radius.row,
641
- backgroundColor: night.color.fill
642
- },
643
- rowAction: {
644
- color: night.color.accent,
645
- fontSize: night.font.caption,
646
- fontWeight: "600"
647
- },
648
- diffRow: {
649
- paddingHorizontal: 12,
650
- paddingVertical: 8,
651
- gap: 3
652
- },
653
- diffPath: {
654
- color: night.color.textSecondary,
655
- fontSize: night.font.micro,
656
- fontWeight: "600",
657
- letterSpacing: 0.3
658
- },
659
- diffLine: {
660
- flexDirection: "row",
661
- gap: 8,
662
- alignItems: "flex-start"
663
- },
664
- diffMark: {
665
- fontFamily: "Menlo",
666
- fontSize: 12,
667
- width: 10
668
- },
669
- diffValue: {
670
- flex: 1,
671
- fontFamily: "Menlo",
672
- fontSize: 12,
673
- lineHeight: 16
674
- },
675
- // The tree viewer paints its own ground; round it so it reads as a well
676
- // inside the card rather than a second card butted against the first.
677
- diffTree: {
678
- borderRadius: night.radius.row,
679
- overflow: "hidden"
680
- },
681
- chart: {
682
- paddingHorizontal: 12,
683
- paddingVertical: 10,
684
- gap: 8
685
- },
686
- barRow: {
687
- flexDirection: "row",
688
- alignItems: "center",
689
- gap: 8
690
- },
691
- barLabel: {
692
- width: 96,
693
- color: night.color.textSecondary,
694
- fontSize: night.font.caption
695
- },
696
- barTrack: {
697
- flex: 1,
698
- height: 10,
699
- borderRadius: 5,
700
- backgroundColor: night.color.fill,
701
- overflow: "hidden"
702
- },
703
- bar: {
704
- height: 10,
705
- borderRadius: 5
706
- },
707
- barValue: {
708
- width: 72,
709
- textAlign: "right",
710
- color: night.color.text,
711
- fontSize: night.font.caption,
712
- fontWeight: "600"
713
- },
714
- step: {
715
- flexDirection: "row",
716
- alignItems: "center",
717
- gap: 10,
718
- paddingHorizontal: 12,
719
- paddingVertical: 9
720
- },
721
- stepMark: {
722
- width: 20,
723
- height: 20,
724
- borderRadius: 10,
725
- backgroundColor: night.color.fillTertiary,
726
- alignItems: "center",
727
- justifyContent: "center"
728
- },
729
- stepDone: {
730
- backgroundColor: night.color.accent
731
- },
732
- stepFailed: {
733
- backgroundColor: night.color.danger
734
- },
735
- stepNum: {
736
- color: night.color.text,
737
- fontSize: night.font.micro,
738
- fontWeight: "700"
739
- },
740
- stepTextDone: {
741
- color: night.color.textSecondary
742
- },
743
- // The explorer draws its own rows; this is only the inset that keeps them
744
- // off the card's edge, matching every other block's 12pt gutter.
745
- viewer: {
746
- paddingHorizontal: 4,
747
- paddingBottom: 8
748
- },
749
- code: {
750
- paddingHorizontal: 12,
751
- paddingVertical: 10,
752
- lineHeight: 17
753
- },
754
- noticeRow: {
755
- flexDirection: "row",
756
- alignItems: "flex-start",
757
- gap: 8,
758
- paddingHorizontal: 12,
759
- paddingTop: 10,
760
- paddingBottom: 4
761
- },
762
- noticeText: {
763
- flex: 1,
764
- color: night.color.text,
765
- fontSize: night.font.caption,
766
- lineHeight: 18
767
- }
768
- });
769
- //# sourceMappingURL=DataBlocks.js.map
1
+ "use strict";import{useState as z}from"react";import{Image as T,Pressable as w,StyleSheet as R,Text as c,View as d}from"react-native";import{AlertTriangle as A,Check as M,Info as k,night as i,X as F}from"@buoy-gg/shared-ui";import{DataViewer as W,TreeDiffViewer as j}from"@buoy-gg/shared-ui/dataViewer";import{CAPS as x}from"@buoy-gg/agent-core";import{ActionRow as H,blockStyles as h,Card as g,More as D,toneColor as S,useBlockHandlers as B,usePaged as I}from"./primitivesIndex";import{renderInline as C}from"../components/Markdown";import{useCopyAction as N}from"../components/useCopyAction";import{blockToText as J}from"./blockText";import{BlockIcon as E}from"./icons";import{jsx as t,jsxs as u,Fragment as K}from"react/jsx-runtime";function $(e){if(e===void 0)return"\u2014";if(e===null)return"null";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);try{const o=JSON.stringify(e);return o.length>120?`${o.slice(0,117)}\u2026`:o}catch{return String(e)}}export function Table({block:e}){const o=I(e.rows,x.tableRows);const{visible:r}=o;const a=e.columns.slice(0,4);return u(g,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[t(d,{style:n.tableHead,children:a.map((f,s)=>t(c,{style:[n.th,s===0&&n.firstCol],numberOfLines:1,children:f},f))}),r.map((f,s)=>t(d,{style:[n.tr,s>0&&h.rowDivider],children:a.map((l,y)=>{const p=f[y];const b=typeof p==="string"?p:p?.text??"";const m=typeof p==="string"?void 0:p?.tone;return t(c,{style:[n.td,y===0&&n.firstCol,y===0&&n.tdFirst,m&&{color:S(m)}],numberOfLines:2,children:C(b,n.td)},y)})},s)),t(D,{paged:o})]})}export function KeyValue({block:e}){const o=I(e.pairs,x.keyValuePairs);const{visible:r}=o;const[a,f]=z(null);return u(g,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[r.map((s,l)=>{const y=typeof s.value==="object"&&s.value!==null;const p=a===s.key;return u(w,{onPress:y?()=>f(p?null:s.key):void 0,style:[n.kvRow,l>0&&h.rowDivider],children:[t(c,{style:n.kvKey,numberOfLines:1,children:s.key}),t(c,{style:[n.kvValue,p&&h.mono],numberOfLines:p?void 0:2,selectable:true,children:p?JSON.stringify(s.value,null,2):$(s.value)})]},s.key)}),t(D,{paged:o})]})}export function listRowBehaviour(e){const o=Boolean(e.image);return{canExpand:o,rowRunsAction:Boolean(e.action)&&!o,actionIsOwnControl:Boolean(e.action)&&o}}export function List({block:e}){const o=B();const r=I(e.items,x.listItems);const{visible:a}=r;const[f,s]=z(null);return u(g,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[a.map((l,y)=>{const p=`${l.id??l.title}-${y}`;const b=f===p;const{canExpand:m,rowRunsAction:v,actionIsOwnControl:V}=listRowBehaviour(l);const O=m||v?w:d;const P=m?{onPress:()=>s(b?null:p),accessibilityRole:"button",accessibilityState:{expanded:b},accessibilityLabel:`${l.title}, ${b?"hide":"show"} picture`,testID:`buoy-block-list-row-${p}`}:v?{onPress:()=>void o.runAction(l.action,e.id),accessibilityRole:"button"}:{};return u(d,{style:y>0?h.rowDivider:void 0,children:[b&&l.image?t(w,{onPress:()=>s(null),accessibilityRole:"button",accessibilityLabel:`Hide ${l.title}`,testID:`buoy-block-list-hero-${p}`,style:n.listHero,children:t(T,{testID:"buoy-internal-chat-image",source:{uri:l.image},style:n.listHeroImage,resizeMode:"contain",accessibilityLabel:l.title})}):null,u(O,{...P,style:h.row,children:[l.image&&!b?t(T,{testID:"buoy-internal-chat-image",source:{uri:l.image},style:n.thumb,resizeMode:"contain",accessibilityLabel:l.title}):l.icon?t(E,{name:l.icon}):null,u(d,{style:n.flex,children:[t(c,{style:[h.rowTitle,l.tone&&{color:S(l.tone)}],numberOfLines:b?void 0:2,children:C(l.title,h.rowTitle)}),l.subtitle?t(c,{style:h.rowSub,numberOfLines:b?void 0:2,children:C(l.subtitle,h.rowSub)}):null]}),l.trailing?t(c,{style:[h.rowTrailing,l.tone&&{color:S(l.tone)}],numberOfLines:1,children:l.trailing}):null,l.action?V?t(w,{onPress:()=>void o.runAction(l.action,e.id),accessibilityRole:"button",accessibilityLabel:l.action.label,hitSlop:8,children:t(c,{style:n.rowAction,children:l.action.label})}):t(c,{style:n.rowAction,children:l.action.label}):null]})]},p)}),t(D,{paged:r})]})}function L(e){return e!==null&&typeof e==="object"}function _(e){const o=e.map(s=>s.path);const r=o.slice(0,3).join(", ");const a=o.length-3;const f=o.length===1?"1 field":`${o.length} fields`;return`${f} \xB7 ${r}${a>0?`, +${a}`:""}`}export function Diff({block:e}){const o=I(e.changes,x.keyValuePairs);return u(g,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:true,summary:_(e.changes),children:[o.visible.map((r,a)=>{const f=r.before===void 0&&r.after!==void 0;const s=r.after===void 0&&r.before!==void 0;return u(d,{style:[n.diffRow,a>0&&h.rowDivider],children:[t(c,{style:n.diffPath,numberOfLines:1,children:r.path}),L(r.before)||L(r.after)?t(d,{style:n.diffTree,children:t(j,{oldValue:r.before,newValue:r.after,showUnchanged:false,scrollEnabled:false})}):u(K,{children:[!f?u(d,{style:n.diffLine,children:[t(c,{style:[n.diffMark,{color:i.color.danger}],children:"\u2212"}),t(c,{style:[n.diffValue,{color:i.color.danger}],numberOfLines:3,selectable:true,children:$(r.before)})]}):null,!s?u(d,{style:n.diffLine,children:[t(c,{style:[n.diffMark,{color:i.color.accent}],children:"+"}),t(c,{style:[n.diffValue,{color:i.color.accent}],numberOfLines:3,selectable:true,children:$(r.after)})]}):null]})]},`${r.path}-${a}`)}),t(D,{paged:o})]})}export function Chart({block:e}){const o=e.bars.slice(0,x.chartBars);const r=e.max??Math.max(1,...o.map(a=>a.value));return t(g,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:t(d,{style:n.chart,children:o.map((a,f)=>u(d,{style:n.barRow,children:[t(c,{style:n.barLabel,numberOfLines:1,children:a.label}),t(d,{style:n.barTrack,children:t(d,{style:[n.bar,{width:`${Math.max(2,Math.round(a.value/r*100))}%`,backgroundColor:S(a.tone??"accent")}]})}),u(c,{style:n.barValue,numberOfLines:1,children:[a.value,a.unit?` ${a.unit}`:""]})]},`${a.label}-${f}`))})})}export function Steps({block:e}){return t(g,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((o,r)=>u(d,{style:[n.step,r>0&&h.rowDivider],children:[t(d,{style:[n.stepMark,o.state==="done"&&n.stepDone,o.state==="failed"&&n.stepFailed],children:o.state==="done"?t(M,{size:10,color:i.color.onAccent}):o.state==="failed"?t(F,{size:10,color:i.color.text}):t(c,{style:n.stepNum,children:r+1})}),t(c,{style:[h.rowTitle,o.state==="done"&&n.stepTextDone],children:o.text})]},r))})}function U(e){try{const o=JSON.parse(e);return o!==null&&typeof o==="object"?o:void 0}catch{return void 0}}function X({block:e,value:o}){return t(g,{title:e.title,testID:`buoy-block-code-${e.id}`,children:t(d,{style:n.viewer,children:t(W,{title:e.title??"Payload",data:o,initialExpanded:true,showTypeFilter:false,testIDPrefix:`buoy-block-code-${e.id}`})})})}function q({block:e}){return t(g,{title:e.title,testID:`buoy-block-code-${e.id}`,children:t(c,{style:[h.mono,n.code],selectable:true,children:e.text})})}export function Code({block:e}){const o=U(e.text);if(o===void 0)return t(q,{block:e});return t(X,{block:e,value:o})}export function Notice({block:e}){const o=e.tone==="danger"?i.color.danger:e.tone==="warning"?i.color.warning:i.color.info;const r=e.tone==="info"?k:A;return u(g,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[u(d,{style:n.noticeRow,children:[t(r,{size:14,color:o}),t(c,{style:n.noticeText,children:e.text})]}),t(H,{actions:e.actions,blockId:e.id})]})}export function Finding({block:e}){const{copied:o,copy:r}=N(()=>J(e)??e.title);return u(g,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((a,f)=>u(d,{style:[n.kvRow,f>0&&h.rowDivider],children:[t(c,{style:n.kvKey,numberOfLines:1,children:a.label}),t(c,{style:[n.kvValue,a.tone&&{color:S(a.tone)}],selectable:true,children:a.value})]},`${a.label}-${f}`)),t(d,{style:n.findingFoot,children:t(w,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:o?"Copied":"Copy this finding",onPress:r,style:({pressed:a})=>[n.findingCopy,a&&{opacity:.7}],children:t(c,{style:[n.findingCopyText,o&&{color:i.color.accent}],children:o?"Copied":"Copy finding"})})}),t(H,{actions:e.actions,blockId:e.id})]})}const n=R.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:i.color.fill},th:{flex:1,color:i.color.textTertiary,fontSize:i.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:i.color.textSecondary,fontSize:i.font.caption,lineHeight:17},tdFirst:{color:i.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:i.color.textSecondary,fontSize:i.font.caption,paddingTop:1},kvValue:{flex:1,color:i.color.text,fontSize:i.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:R.hairlineWidth,borderTopColor:i.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:i.radius.badge,backgroundColor:i.color.fill},findingCopyText:{color:i.color.textSecondary,fontSize:i.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:i.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:i.radius.row,backgroundColor:i.color.fill},rowAction:{color:i.color.accent,fontSize:i.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:i.color.textSecondary,fontSize:i.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:i.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:i.color.textSecondary,fontSize:i.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:i.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:i.color.text,fontSize:i.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:i.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:i.color.accent},stepFailed:{backgroundColor:i.color.danger},stepNum:{color:i.color.text,fontSize:i.font.micro,fontWeight:"700"},stepTextDone:{color:i.color.textSecondary},viewer:{paddingHorizontal:4,paddingBottom:8},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:i.color.text,fontSize:i.font.caption,lineHeight:18}});