@buoy-gg/ask-buoy 7.0.40 → 7.0.42

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