@buoy-gg/ask-buoy 7.0.34 → 7.0.35

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