@ai-matrx/rich-content 0.2.4 → 0.2.6

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 (381) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/code-block/CodeBlock.d.ts +44 -0
  3. package/dist/code-block/CodeBlock.js +449 -0
  4. package/dist/code-block/CodeBlockHeader.d.ts +63 -0
  5. package/dist/code-block/CodeBlockHeader.js +472 -0
  6. package/dist/code-block/CodeEditorLoading.d.ts +3 -0
  7. package/dist/code-block/CodeEditorLoading.js +34 -0
  8. package/dist/code-block/LanguageDisplay.d.ts +28 -0
  9. package/dist/code-block/LanguageDisplay.js +279 -0
  10. package/dist/code-block/SmallCodeEditor.d.ts +30 -0
  11. package/dist/code-block/SmallCodeEditor.js +22 -0
  12. package/dist/code-block/StickyButtons.d.ts +35 -0
  13. package/dist/code-block/StickyButtons.js +88 -0
  14. package/dist/code-block/highlight/ShikiCodeView.d.ts +26 -0
  15. package/dist/code-block/highlight/ShikiCodeView.js +134 -0
  16. package/dist/code-block/highlight/shiki-highlighter.d.ts +14 -0
  17. package/dist/code-block/highlight/shiki-highlighter.js +126 -0
  18. package/dist/code-block/highlight/useHighlightedLines.d.ts +18 -0
  19. package/dist/code-block/highlight/useHighlightedLines.js +142 -0
  20. package/dist/code-block/sticky-inset.d.ts +6 -0
  21. package/dist/code-block/sticky-inset.js +10 -0
  22. package/dist/display/block-interaction.d.ts +33 -0
  23. package/dist/display/block-interaction.js +13 -0
  24. package/dist/display/blocks/ChatCollapsibleWrapper.d.ts +13 -0
  25. package/dist/display/blocks/ChatCollapsibleWrapper.js +56 -0
  26. package/dist/display/blocks/buildMediaSource.d.ts +25 -0
  27. package/dist/display/blocks/buildMediaSource.js +43 -0
  28. package/dist/display/blocks/canvas-adaptive.d.ts +118 -0
  29. package/dist/display/blocks/canvas-adaptive.js +127 -0
  30. package/dist/display/blocks/canvas-fit.d.ts +24 -0
  31. package/dist/display/blocks/canvas-fit.js +19 -0
  32. package/dist/display/blocks/chart/ChartBlock.d.ts +8 -0
  33. package/dist/display/blocks/chart/ChartBlock.js +125 -0
  34. package/dist/display/blocks/chart/ChartCanvas.d.ts +18 -0
  35. package/dist/display/blocks/chart/ChartCanvas.js +159 -0
  36. package/dist/display/blocks/chart/TableChart.d.ts +25 -0
  37. package/dist/display/blocks/chart/TableChart.js +97 -0
  38. package/dist/display/blocks/chart/chart-spec.d.ts +39 -0
  39. package/dist/display/blocks/chart/chart-spec.js +128 -0
  40. package/dist/display/blocks/chart/labels.d.ts +20 -0
  41. package/dist/display/blocks/chart/labels.js +7 -0
  42. package/dist/display/blocks/chart/table-chart.d.ts +37 -0
  43. package/dist/display/blocks/chart/table-chart.js +231 -0
  44. package/dist/display/blocks/common/BlockHeaderWrapper.d.ts +56 -0
  45. package/dist/display/blocks/common/BlockHeaderWrapper.js +310 -0
  46. package/dist/display/blocks/common/ContentBlockWrapper.d.ts +40 -0
  47. package/dist/display/blocks/common/ContentBlockWrapper.js +214 -0
  48. package/dist/display/blocks/common/SandboxedHtml.d.ts +27 -0
  49. package/dist/display/blocks/common/SandboxedHtml.js +26 -0
  50. package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
  51. package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
  52. package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
  53. package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
  54. package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
  55. package/dist/display/blocks/diagram/diagram-printer.js +294 -0
  56. package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
  57. package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
  58. package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
  59. package/dist/display/blocks/diagram/layout-utils.js +347 -0
  60. package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
  61. package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
  62. package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
  63. package/dist/display/blocks/diagram/presentation-direction.js +19 -0
  64. package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
  65. package/dist/display/blocks/diagram/ui-utils.js +18 -0
  66. package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
  67. package/dist/display/blocks/diff/DiffBlock.js +119 -0
  68. package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
  69. package/dist/display/blocks/diff/DiffCanvas.js +20 -0
  70. package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
  71. package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
  72. package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
  73. package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
  74. package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
  75. package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
  76. package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
  77. package/dist/display/blocks/images/ImageBlock.js +265 -0
  78. package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
  79. package/dist/display/blocks/json/JsonBlock.js +562 -0
  80. package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
  81. package/dist/display/blocks/json/JsonTableView.js +173 -0
  82. package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
  83. package/dist/display/blocks/json/json-compact-stringify.js +52 -0
  84. package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
  85. package/dist/display/blocks/json/json-tabular-utils.js +121 -0
  86. package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
  87. package/dist/display/blocks/links/LinkComponent.js +373 -0
  88. package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
  89. package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
  90. package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
  91. package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
  92. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
  93. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
  94. package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
  95. package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
  96. package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
  97. package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
  98. package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
  99. package/dist/display/blocks/svg/SvgBlock.js +126 -0
  100. package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
  101. package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
  102. package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
  103. package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
  104. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
  105. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
  106. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
  107. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
  108. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
  109. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
  110. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
  111. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
  112. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
  113. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
  114. package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
  115. package/dist/display/blocks/toml/TomlBlock.js +167 -0
  116. package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
  117. package/dist/display/blocks/tree/TreeBlock.js +163 -0
  118. package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
  119. package/dist/display/blocks/xml/XmlBlock.js +197 -0
  120. package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
  121. package/dist/display/blocks/xml/readXmlTag.js +1 -0
  122. package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
  123. package/dist/display/blocks/xml/xml-tokenize.js +169 -0
  124. package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
  125. package/dist/display/blocks/yaml/YamlBlock.js +191 -0
  126. package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
  127. package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
  128. package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
  129. package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
  130. package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
  131. package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
  132. package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
  133. package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
  134. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
  135. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
  136. package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
  137. package/dist/display/chat-markdown/KindTextGate.js +60 -0
  138. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
  139. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
  140. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
  141. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
  142. package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
  143. package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
  144. package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
  145. package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
  146. package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
  147. package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
  148. package/dist/display/chat-markdown/constants.d.ts +14 -0
  149. package/dist/display/chat-markdown/constants.js +317 -0
  150. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
  151. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
  152. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
  153. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
  154. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
  155. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
  156. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
  157. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
  158. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
  159. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
  160. package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
  161. package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
  162. package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
  163. package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
  164. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
  165. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
  166. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
  167. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
  168. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
  169. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
  170. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
  171. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
  172. package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
  173. package/dist/display/chat-markdown/kind-source-view.js +14 -0
  174. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
  175. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
  176. package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
  177. package/dist/display/chat-markdown/progressive-mount.js +90 -0
  178. package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
  179. package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
  180. package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
  181. package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
  182. package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
  183. package/dist/display/chat-markdown/stable-blocks.js +54 -0
  184. package/dist/display/chat-markdown/types.d.ts +11 -0
  185. package/dist/display/chat-markdown/types.js +26 -0
  186. package/dist/display/specimen/SpecimenContext.d.ts +26 -0
  187. package/dist/display/specimen/SpecimenContext.js +64 -0
  188. package/dist/display/tables/MarkdownTable.d.ts +23 -0
  189. package/dist/display/tables/MarkdownTable.js +769 -0
  190. package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
  191. package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
  192. package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
  193. package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
  194. package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
  195. package/dist/display/tables/SendToWorkbookButton.js +93 -0
  196. package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
  197. package/dist/display/tables/TableSaveToMenu.js +98 -0
  198. package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
  199. package/dist/display/tables/TableWithSeparatedControls.js +574 -0
  200. package/dist/display/tables/ViewTableModal.d.ts +14 -0
  201. package/dist/display/tables/ViewTableModal.js +67 -0
  202. package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
  203. package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
  204. package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
  205. package/dist/display/tables/editing/RowActionsMenu.js +80 -0
  206. package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
  207. package/dist/display/tables/editing/TableEditToolbar.js +63 -0
  208. package/dist/display/tables/editing/tableMutations.d.ts +50 -0
  209. package/dist/display/tables/editing/tableMutations.js +148 -0
  210. package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
  211. package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
  212. package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
  213. package/dist/display/tables/editing/useTableUndo.js +17 -0
  214. package/dist/display/tables/table-action-row.d.ts +8 -0
  215. package/dist/display/tables/table-action-row.js +31 -0
  216. package/dist/display/tables/table-viewer.d.ts +13 -0
  217. package/dist/display/tables/table-viewer.js +18 -0
  218. package/dist/host/ErrorActions.d.ts +1 -1
  219. package/dist/host/ErrorNotice.d.ts +10 -0
  220. package/dist/host/ErrorNotice.js +19 -0
  221. package/dist/host/app-bindings.d.ts +155 -0
  222. package/dist/host/app-bindings.js +160 -0
  223. package/dist/host/diagnostics.d.ts +2 -2
  224. package/dist/host/diagnostics.js +2 -1
  225. package/dist/host/tables.d.ts +1 -6
  226. package/dist/host/types.d.ts +14 -7
  227. package/dist/levels/RichContent.d.ts +3 -0
  228. package/dist/levels/RichContent.js +102 -0
  229. package/dist/levels/RichContentInline.d.ts +28 -0
  230. package/dist/levels/RichContentInline.js +61 -0
  231. package/dist/levels/RichContentPreview.d.ts +12 -0
  232. package/dist/levels/RichContentPreview.js +39 -0
  233. package/dist/levels/RichContentStandardImpl.d.ts +12 -0
  234. package/dist/levels/RichContentStandardImpl.js +27 -0
  235. package/dist/levels/RichContentStaticProse.d.ts +46 -0
  236. package/dist/levels/RichContentStaticProse.js +100 -0
  237. package/dist/levels/depth.d.ts +18 -0
  238. package/dist/levels/depth.js +32 -0
  239. package/dist/levels/prose/inline-level-elements.d.ts +19 -0
  240. package/dist/levels/prose/inline-level-elements.js +103 -0
  241. package/dist/levels/prose/prose-block-elements.d.ts +25 -0
  242. package/dist/levels/prose/prose-block-elements.js +313 -0
  243. package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
  244. package/dist/levels/prose/prose-inline-elements.js +143 -0
  245. package/dist/levels/prose/prose-prepare.d.ts +50 -0
  246. package/dist/levels/prose/prose-prepare.js +246 -0
  247. package/dist/levels/prose/remote-image-policy.d.ts +34 -0
  248. package/dist/levels/prose/remote-image-policy.js +153 -0
  249. package/dist/levels/prose/variant-root.d.ts +9 -0
  250. package/dist/levels/prose/variant-root.js +34 -0
  251. package/dist/levels/rich-content-types.d.ts +93 -0
  252. package/dist/levels/rich-content-types.js +4 -0
  253. package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
  254. package/dist/levels/server/DelimiterViolationReport.js +24 -0
  255. package/dist/levels/server/RichContentServer.d.ts +27 -0
  256. package/dist/levels/server/RichContentServer.js +97 -0
  257. package/dist/levels/standard/NestedRichContent.d.ts +7 -0
  258. package/dist/levels/standard/NestedRichContent.js +70 -0
  259. package/dist/levels/standard/StandardBlocks.d.ts +13 -0
  260. package/dist/levels/standard/StandardBlocks.js +239 -0
  261. package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
  262. package/dist/levels/standard/StandardKindRegion.js +69 -0
  263. package/dist/levels/standard/standard-kind-region.d.ts +19 -0
  264. package/dist/levels/standard/standard-kind-region.js +21 -0
  265. package/dist/levels/standard/static-standard.d.ts +23 -0
  266. package/dist/levels/standard/static-standard.js +187 -0
  267. package/dist/levels/standard/stream-holdback.d.ts +2 -0
  268. package/dist/levels/standard/stream-holdback.js +77 -0
  269. package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
  270. package/dist/mermaid/MermaidFullscreen.js +71 -0
  271. package/dist/mermaid/MermaidRenderer.d.ts +20 -0
  272. package/dist/mermaid/MermaidRenderer.js +267 -0
  273. package/dist/mermaid/MermaidView.d.ts +27 -0
  274. package/dist/mermaid/MermaidView.js +68 -0
  275. package/dist/mermaid/MermaidViewport.d.ts +75 -0
  276. package/dist/mermaid/MermaidViewport.js +286 -0
  277. package/dist/mermaid/adapters/er.d.ts +10 -0
  278. package/dist/mermaid/adapters/er.js +205 -0
  279. package/dist/mermaid/adapters/flowchart.d.ts +17 -0
  280. package/dist/mermaid/adapters/flowchart.js +634 -0
  281. package/dist/mermaid/adapters/journey.d.ts +9 -0
  282. package/dist/mermaid/adapters/journey.js +207 -0
  283. package/dist/mermaid/adapters/mindmap.d.ts +12 -0
  284. package/dist/mermaid/adapters/mindmap.js +252 -0
  285. package/dist/mermaid/adapters/pie.d.ts +7 -0
  286. package/dist/mermaid/adapters/pie.js +172 -0
  287. package/dist/mermaid/adapters/quadrant.d.ts +8 -0
  288. package/dist/mermaid/adapters/quadrant.js +231 -0
  289. package/dist/mermaid/adapters/register.d.ts +7 -0
  290. package/dist/mermaid/adapters/register.js +19 -0
  291. package/dist/mermaid/adapters/sequence.d.ts +8 -0
  292. package/dist/mermaid/adapters/sequence.js +251 -0
  293. package/dist/mermaid/adapters/state.d.ts +12 -0
  294. package/dist/mermaid/adapters/state.js +245 -0
  295. package/dist/mermaid/adapters/timeline.d.ts +8 -0
  296. package/dist/mermaid/adapters/timeline.js +245 -0
  297. package/dist/mermaid/catalog.d.ts +33 -0
  298. package/dist/mermaid/catalog.js +202 -0
  299. package/dist/mermaid/diagram-type.d.ts +39 -0
  300. package/dist/mermaid/diagram-type.js +89 -0
  301. package/dist/mermaid/export.d.ts +21 -0
  302. package/dist/mermaid/export.js +112 -0
  303. package/dist/mermaid/extract-fence.d.ts +15 -0
  304. package/dist/mermaid/extract-fence.js +22 -0
  305. package/dist/mermaid/lazy-draw.d.ts +40 -0
  306. package/dist/mermaid/lazy-draw.js +168 -0
  307. package/dist/mermaid/model/adapter.d.ts +28 -0
  308. package/dist/mermaid/model/adapter.js +16 -0
  309. package/dist/mermaid/model/ops.d.ts +282 -0
  310. package/dist/mermaid/model/ops.js +9 -0
  311. package/dist/mermaid/model/round-trip.d.ts +22 -0
  312. package/dist/mermaid/model/round-trip.js +45 -0
  313. package/dist/mermaid/model/types.d.ts +271 -0
  314. package/dist/mermaid/model/types.js +0 -0
  315. package/dist/mermaid/print-render.d.ts +9 -0
  316. package/dist/mermaid/print-render.js +39 -0
  317. package/dist/mermaid/runtime.d.ts +25 -0
  318. package/dist/mermaid/runtime.js +183 -0
  319. package/dist/mermaid/sanitize.d.ts +46 -0
  320. package/dist/mermaid/sanitize.js +234 -0
  321. package/dist/mermaid/types.d.ts +43 -0
  322. package/dist/mermaid/types.js +21 -0
  323. package/dist/mermaid/view/ViewModePane.d.ts +24 -0
  324. package/dist/mermaid/view/ViewModePane.js +9 -0
  325. package/dist/utils/client-lazy.d.ts +1 -1
  326. package/dist/utils/client-lazy.js +4 -1
  327. package/dist/utils/lifted/DiffView.d.ts +10 -0
  328. package/dist/utils/lifted/DiffView.js +26 -0
  329. package/dist/utils/lifted/IconButton.d.ts +24 -0
  330. package/dist/utils/lifted/IconButton.js +43 -0
  331. package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
  332. package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
  333. package/dist/utils/lifted/ShimmerText.d.ts +5 -0
  334. package/dist/utils/lifted/ShimmerText.js +21 -0
  335. package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
  336. package/dist/utils/lifted/SuspenseLoader.js +42 -0
  337. package/dist/utils/lifted/Tooltip.d.ts +20 -0
  338. package/dist/utils/lifted/Tooltip.js +52 -0
  339. package/dist/utils/lifted/artifactId.d.ts +34 -0
  340. package/dist/utils/lifted/artifactId.js +15 -0
  341. package/dist/utils/lifted/canvasContent.d.ts +63 -0
  342. package/dist/utils/lifted/canvasContent.js +98 -0
  343. package/dist/utils/lifted/captureReactError.d.ts +24 -0
  344. package/dist/utils/lifted/captureReactError.js +28 -0
  345. package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
  346. package/dist/utils/lifted/chunk-load-recovery.js +36 -0
  347. package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
  348. package/dist/utils/lifted/code-editor-agent-types.js +0 -0
  349. package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
  350. package/dist/utils/lifted/code-editor-agents.js +52 -0
  351. package/dist/utils/lifted/code-language-extension.d.ts +1 -0
  352. package/dist/utils/lifted/code-language-extension.js +60 -0
  353. package/dist/utils/lifted/custom-icons.d.ts +16 -0
  354. package/dist/utils/lifted/custom-icons.js +47 -0
  355. package/dist/utils/lifted/durability.d.ts +16 -0
  356. package/dist/utils/lifted/durability.js +45 -0
  357. package/dist/utils/lifted/errors.d.ts +30 -0
  358. package/dist/utils/lifted/errors.js +29 -0
  359. package/dist/utils/lifted/html-document.d.ts +1 -0
  360. package/dist/utils/lifted/html-document.js +12 -0
  361. package/dist/utils/lifted/languageOptions.d.ts +9 -0
  362. package/dist/utils/lifted/languageOptions.js +52 -0
  363. package/dist/utils/lifted/languages.d.ts +34 -0
  364. package/dist/utils/lifted/languages.js +175 -0
  365. package/dist/utils/lifted/loading-spinner.d.ts +18 -0
  366. package/dist/utils/lifted/loading-spinner.js +200 -0
  367. package/dist/utils/lifted/media-refs.d.ts +13 -0
  368. package/dist/utils/lifted/media-refs.js +27 -0
  369. package/dist/utils/lifted/scroll-root.d.ts +1 -0
  370. package/dist/utils/lifted/scroll-root.js +25 -0
  371. package/dist/utils/lifted/syntax-themes.d.ts +32 -0
  372. package/dist/utils/lifted/syntax-themes.js +100 -0
  373. package/dist/utils/lifted/url-utm.d.ts +24 -0
  374. package/dist/utils/lifted/url-utm.js +66 -0
  375. package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
  376. package/dist/utils/lifted/use-is-mounted.js +21 -0
  377. package/dist/utils/lifted/useToastManager.d.ts +1 -0
  378. package/dist/utils/lifted/useToastManager.js +7 -0
  379. package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
  380. package/dist/utils/report-kind-at-raw-renderer.js +32 -0
  381. package/package.json +32 -3
@@ -0,0 +1,128 @@
1
+ import { soleFence } from "@ai-matrx/content-ir/source";
2
+ const CHART_PALETTE = [
3
+ "#6366F1",
4
+ // indigo
5
+ "#059669",
6
+ // emerald
7
+ "#D97706",
8
+ // amber
9
+ "#E11D48",
10
+ // rose
11
+ "#0EA5E9",
12
+ // sky
13
+ "#7C3AED",
14
+ // violet
15
+ "#0D9488",
16
+ // teal
17
+ "#DB2777",
18
+ // pink
19
+ "#65A30D",
20
+ // lime
21
+ "#F59E0B"
22
+ // amber-light
23
+ ];
24
+ const TYPE_SYNONYMS = {
25
+ bar: "bar",
26
+ column: "bar",
27
+ bars: "bar",
28
+ histogram: "bar",
29
+ line: "line",
30
+ lines: "line",
31
+ spline: "line",
32
+ area: "area",
33
+ areas: "area",
34
+ pie: "pie",
35
+ donut: "pie",
36
+ doughnut: "pie",
37
+ scatter: "scatter",
38
+ point: "scatter",
39
+ bubble: "scatter"
40
+ };
41
+ const X_KEYS = ["x", "xkey", "xKey", "category", "name", "label", "axis"];
42
+ const Y_KEYS = ["y", "ykeys", "yKeys", "series", "values", "value"];
43
+ const PIE_LABEL_KEYS = ["label", "name", "category", "key", "x"];
44
+ const PIE_VALUE_KEYS = ["value", "y", "count", "amount", "total"];
45
+ function tolerantParse(raw) {
46
+ let s = raw.trim();
47
+ const fenced = soleFence(s);
48
+ if (fenced && ["", "json", "chart"].includes(fenced.lang.toLowerCase())) s = fenced.body.trim();
49
+ try {
50
+ return JSON.parse(s);
51
+ } catch {
52
+ try {
53
+ return JSON.parse(s.replace(/,(\s*[}\]])/g, "$1"));
54
+ } catch {
55
+ return void 0;
56
+ }
57
+ }
58
+ }
59
+ function firstKey(obj, candidates) {
60
+ const keys = Object.keys(obj);
61
+ for (const c of candidates) {
62
+ const hit = keys.find((k) => k.toLowerCase() === c.toLowerCase());
63
+ if (hit) return hit;
64
+ }
65
+ return void 0;
66
+ }
67
+ function isNumericLike(v) {
68
+ return typeof v === "number" || typeof v === "string" && v.trim() !== "" && !isNaN(Number(v));
69
+ }
70
+ function parseChartSpec(raw) {
71
+ const obj = tolerantParse(raw);
72
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
73
+ return { error: "Chart needs a JSON object with a `type` and `data`." };
74
+ }
75
+ const o = obj;
76
+ const rawType = String(o.type ?? o.chartType ?? "bar").toLowerCase().trim();
77
+ const type = TYPE_SYNONYMS[rawType] ?? TYPE_SYNONYMS[rawType.split(/\s+/)[0]] ?? "bar";
78
+ const title = typeof o.title === "string" ? o.title : void 0;
79
+ const data = Array.isArray(o.data) ? o.data.filter((r) => r && typeof r === "object") : [];
80
+ if (data.length === 0) {
81
+ return { error: "Chart `data` must be a non-empty array of objects." };
82
+ }
83
+ const rows = data;
84
+ const sample = rows[0];
85
+ if (type === "pie") {
86
+ const labelKey = firstKey(sample, PIE_LABEL_KEYS) ?? Object.keys(sample).find((k) => typeof sample[k] === "string");
87
+ const valueKey = firstKey(sample, PIE_VALUE_KEYS) ?? Object.keys(sample).find((k) => isNumericLike(sample[k]));
88
+ if (!labelKey || !valueKey) {
89
+ return { error: "Pie `data` items need a label and a numeric value (e.g. {label, value})." };
90
+ }
91
+ const normalized2 = rows.map((r) => ({ ...r, [valueKey]: Number(r[valueKey]) }));
92
+ return { type, title, xKey: labelKey, series: [], data: normalized2, pie: { labelKey, valueKey }, stacked: false };
93
+ }
94
+ const explicitX = typeof o.x === "string" ? o.x : typeof o.xKey === "string" ? o.xKey : void 0;
95
+ const xKey = explicitX ?? firstKey(sample, X_KEYS) ?? Object.keys(sample).find((k) => typeof sample[k] === "string") ?? Object.keys(sample)[0];
96
+ let yKeys = [];
97
+ const explicitY = o.y ?? o.yKeys ?? o.series;
98
+ if (Array.isArray(explicitY)) {
99
+ yKeys = explicitY.map((s) => typeof s === "string" ? s : typeof s === "object" && s ? String(s.key ?? "") : "").filter(Boolean);
100
+ } else if (typeof explicitY === "string") {
101
+ yKeys = [explicitY];
102
+ }
103
+ if (yKeys.length === 0) {
104
+ yKeys = Object.keys(sample).filter((k) => k !== xKey && isNumericLike(sample[k]));
105
+ }
106
+ if (yKeys.length === 0) {
107
+ return { error: "Chart `data` rows need at least one numeric field to plot." };
108
+ }
109
+ const seriesMeta = Array.isArray(o.series) ? o.series : [];
110
+ const series = yKeys.map((key, i) => {
111
+ const meta = seriesMeta.find((m) => m && typeof m === "object" && m.key === key);
112
+ return {
113
+ key,
114
+ label: typeof meta?.label === "string" ? meta.label : key,
115
+ color: typeof meta?.color === "string" ? meta.color : CHART_PALETTE[i % CHART_PALETTE.length]
116
+ };
117
+ });
118
+ const normalized = rows.map((r) => {
119
+ const out = { ...r };
120
+ for (const s of series) if (isNumericLike(out[s.key])) out[s.key] = Number(out[s.key]);
121
+ return out;
122
+ });
123
+ return { type, title, xKey, series, data: normalized, stacked: Boolean(o.stacked), pie: void 0 };
124
+ }
125
+ export {
126
+ CHART_PALETTE,
127
+ parseChartSpec
128
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Pie-slice label text for <ChartCanvas>'s recharts <Pie label={...}>.
3
+ *
4
+ * A SCREEN NEVER LIES. Recharts omits `percent` whenever it cannot compute
5
+ * one — an all-zero data set, a non-numeric `dataKey`, a slice rendered
6
+ * before the sum is known. The original label read
7
+ * `e.percent != null ? Math.round(e.percent * 100) : 0` and printed "0%",
8
+ * which tells the reader the slice is empty when the truth is that nobody
9
+ * knows its share. Unknown reads as the em-dash (the fleet convention set by
10
+ * `formatFileSize` in `@ai-matrx/kit/format`); a slice whose share is REALLY
11
+ * zero still prints "0%".
12
+ *
13
+ * Lives in its own module rather than inline so it can be tested without
14
+ * pulling recharts into the Jest module graph.
15
+ */
16
+ export interface PieSliceLabelInput {
17
+ name?: string;
18
+ percent?: number;
19
+ }
20
+ export declare function pieSliceLabel(e: PieSliceLabelInput): string;
@@ -0,0 +1,7 @@
1
+ import { formatPercentFromFraction } from "@ai-matrx/kit/format";
2
+ function pieSliceLabel(e) {
3
+ return `${e.name ?? ""} ${formatPercentFromFraction(e.percent)}`;
4
+ }
5
+ export {
6
+ pieSliceLabel
7
+ };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * table-chart — turn a table an answer already shows (markdown table, CSV, TSV)
3
+ * into a ChartSpec for the ONE chart primitive (chart-spec + ChartCanvas).
4
+ * PURE: no recharts, no React — the "Chart this" button and the code-block
5
+ * "Chart this" action both call it, and it is unit-tested on its own.
6
+ *
7
+ * Auto-pick (what ChatGPT's analysis charts and Excel's "Recommended charts"
8
+ * do, reduced to the cases answers actually contain):
9
+ * - no numeric column → not chartable (the button is absent)
10
+ * - every column numeric → scatter (first column vs the rest)
11
+ * - category column reads as time → line
12
+ * - one series, ≤ 8 rows, all ≥ 0, a share (%, "share", or sums to ~100) → pie
13
+ * - otherwise → bar
14
+ * The reader can switch to any type the data can draw (`chartableTypes`).
15
+ */
16
+ import { type ChartSpec, type ChartType } from "./chart-spec.js";
17
+ export interface PlainTable {
18
+ headers: string[];
19
+ rows: string[][];
20
+ }
21
+ /** A table cell as a number, or null when it is not one. Never invents 0. */
22
+ export declare function parseCellNumber(raw: unknown): number | null;
23
+ /** The chart types this table can honestly draw, in menu order. */
24
+ export declare function chartableTypes(table: PlainTable): ChartType[];
25
+ /**
26
+ * Build the ChartSpec for a table. `requested` switches the type; a type the
27
+ * data cannot draw falls back to the auto-pick. Null = not chartable.
28
+ */
29
+ export declare function tableToChartSpec(table: PlainTable, requested?: ChartType): ChartSpec | null;
30
+ /**
31
+ * The sentence a chart owes its reader when it cannot show every row as asked:
32
+ * a pie over negative values (drawn as bars instead), or rows with no number
33
+ * (not plotted). Null when the chart shows everything.
34
+ */
35
+ export declare function chartNotice(table: PlainTable, requested?: ChartType): string | null;
36
+ /** RFC-4180-ish CSV / TSV → table. Null when the text is not a table. */
37
+ export declare function parseDelimitedTable(text: string): PlainTable | null;
@@ -0,0 +1,231 @@
1
+ import { CHART_PALETTE } from "./chart-spec.js";
2
+ const SUFFIX = { k: 1e3, m: 1e6, b: 1e9, bn: 1e9, t: 1e12 };
3
+ function parseCellNumber(raw) {
4
+ if (typeof raw === "number") return Number.isFinite(raw) ? raw : null;
5
+ if (typeof raw !== "string") return null;
6
+ let s = raw.trim().replace(/^\*\*|\*\*$/g, "").replace(/^_|_$/g, "").trim();
7
+ if (!s) return null;
8
+ let negative = false;
9
+ if (/^\(.*\)$/.test(s)) {
10
+ negative = true;
11
+ s = s.slice(1, -1).trim();
12
+ }
13
+ s = s.replace(/^[$€£¥₹]\s*/, "").replace(/\s*(USD|EUR|GBP)$/i, "");
14
+ s = s.replace(/%$/, "");
15
+ const m = /^([-+]?)(\d{1,3}(?:,\d{3})+|\d+)?(\.\d+)?\s*(k|m|bn|b|t)?$/i.exec(s);
16
+ if (!m || !m[2] && !m[3]) return null;
17
+ const whole = (m[2] ?? "0").replace(/,/g, "");
18
+ let n = Number(`${whole}${m[3] ?? ""}`);
19
+ if (!Number.isFinite(n)) return null;
20
+ if (m[4]) n *= SUFFIX[m[4].toLowerCase()] ?? 1;
21
+ if (m[1] === "-") n = -n;
22
+ return negative ? -n : n;
23
+ }
24
+ function numericColumns(table) {
25
+ const out = [];
26
+ table.headers.forEach((_, col) => {
27
+ let filled = 0;
28
+ let numeric = 0;
29
+ for (const row of table.rows) {
30
+ const cell = row[col];
31
+ if (cell == null || String(cell).trim() === "" || /^[-—–]$/.test(String(cell).trim())) continue;
32
+ filled += 1;
33
+ if (parseCellNumber(cell) !== null) numeric += 1;
34
+ }
35
+ if (filled > 0 && numeric / filled >= 0.6) out.push(col);
36
+ });
37
+ return out;
38
+ }
39
+ const MONTHS = /^(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\.?(\s+\d{2,4})?$/i;
40
+ const TIME_HEADER = /^(year|month|date|day|week|quarter|period|time|fy|q)\b/i;
41
+ function looksTemporal(header, values) {
42
+ if (TIME_HEADER.test(header.trim())) return true;
43
+ const vals = values.map((v) => String(v ?? "").trim()).filter(Boolean);
44
+ if (vals.length < 2) return false;
45
+ const temporal = vals.filter(
46
+ (v) => /^(19|20)\d{2}$/.test(v) || MONTHS.test(v) || /^q[1-4]\b/i.test(v) || /^\d{4}-\d{2}(-\d{2})?$/.test(v) || /^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(v)
47
+ );
48
+ return temporal.length / vals.length >= 0.8;
49
+ }
50
+ function shapeOf(table) {
51
+ if (!table.headers.length || !table.rows.length) return null;
52
+ let numeric = numericColumns(table);
53
+ const timeCol = numeric.find(
54
+ (i) => looksTemporal("", table.rows.map((r) => r[i]))
55
+ );
56
+ if (timeCol !== void 0 && numeric.length > 1) {
57
+ numeric = numeric.filter((i) => i !== timeCol);
58
+ }
59
+ if (numeric.length === 0) return null;
60
+ const categoryCol = timeCol !== void 0 && !numeric.includes(timeCol) ? timeCol : table.headers.findIndex((_, i) => !numeric.includes(i));
61
+ return {
62
+ categoryCol: categoryCol === -1 ? null : categoryCol,
63
+ valueCols: numeric
64
+ };
65
+ }
66
+ function chartableTypes(table) {
67
+ const shape = shapeOf(table);
68
+ if (!shape) return [];
69
+ const types = ["bar", "line", "area", "pie"];
70
+ if (shape.valueCols.length >= 2) types.push("scatter");
71
+ return types;
72
+ }
73
+ function autoPick(table, shape) {
74
+ if (shape.categoryCol === null) return shape.valueCols.length >= 2 ? "scatter" : "bar";
75
+ const catHeader = table.headers[shape.categoryCol] ?? "";
76
+ const catValues = table.rows.map((r) => r[shape.categoryCol]);
77
+ if (looksTemporal(catHeader, catValues)) return "line";
78
+ if (shape.valueCols.length === 1 && table.rows.length <= 8) {
79
+ const col = shape.valueCols[0];
80
+ const values = table.rows.map((r) => parseCellNumber(r[col]));
81
+ const allNonNeg = values.every((v) => v !== null && v >= 0);
82
+ const isShare = /share|percent|%|portion|split|mix/i.test(table.headers[col] ?? "") || table.rows.some((r) => /%\s*$/.test(String(r[col] ?? ""))) || Math.abs(values.reduce((a, v) => a + (v ?? 0), 0) - 100) <= 1;
83
+ if (allNonNeg && isShare) return "pie";
84
+ }
85
+ return "bar";
86
+ }
87
+ function tableToChartSpec(table, requested) {
88
+ const shape = shapeOf(table);
89
+ if (!shape) return null;
90
+ const allowed = chartableTypes(table);
91
+ let type = requested && allowed.includes(requested) ? requested : autoPick(table, shape);
92
+ if (type === "pie" && negativeRows(table, shape).length > 0) type = "bar";
93
+ const headers = table.headers.map((h, i) => h && h.trim() || `Column ${i + 1}`);
94
+ if (type === "scatter") {
95
+ const [xCol, ...yCols] = shape.valueCols;
96
+ const xKey = headers[xCol];
97
+ const data2 = table.rows.map((row) => {
98
+ const out = { [xKey]: parseCellNumber(row[xCol]) };
99
+ for (const c of yCols) out[headers[c]] = parseCellNumber(row[c]);
100
+ if (shape.categoryCol !== null) out[headers[shape.categoryCol]] = row[shape.categoryCol];
101
+ return out;
102
+ });
103
+ return {
104
+ type,
105
+ xKey,
106
+ series: yCols.map((c, i) => ({ key: headers[c], label: headers[c], color: CHART_PALETTE[i % CHART_PALETTE.length] })),
107
+ data: data2,
108
+ stacked: false
109
+ };
110
+ }
111
+ const catKey = shape.categoryCol !== null ? headers[shape.categoryCol] : "#";
112
+ const data = table.rows.map((row, i) => {
113
+ const out = {
114
+ [catKey]: shape.categoryCol !== null ? String(row[shape.categoryCol] ?? "").replace(/\*\*/g, "").trim() : String(i + 1)
115
+ };
116
+ for (const c of shape.valueCols) out[headers[c]] = parseCellNumber(row[c]);
117
+ return out;
118
+ });
119
+ if (type === "pie") {
120
+ const valueKey = headers[shape.valueCols[0]];
121
+ return {
122
+ type,
123
+ xKey: catKey,
124
+ series: [],
125
+ data: data.filter((d) => typeof d[valueKey] === "number" && d[valueKey] >= 0),
126
+ pie: { labelKey: catKey, valueKey },
127
+ stacked: false
128
+ };
129
+ }
130
+ return {
131
+ type,
132
+ xKey: catKey,
133
+ series: shape.valueCols.map((c, i) => ({
134
+ key: headers[c],
135
+ label: headers[c],
136
+ color: CHART_PALETTE[i % CHART_PALETTE.length]
137
+ })),
138
+ data,
139
+ stacked: false
140
+ };
141
+ }
142
+ function categoryLabel(table, shape, row, i) {
143
+ return shape.categoryCol !== null ? String(row[shape.categoryCol] ?? "").replace(/\*\*/g, "").trim() : `Row ${i + 1}`;
144
+ }
145
+ function negativeRows(table, shape) {
146
+ const col = shape.valueCols[0];
147
+ const out = [];
148
+ table.rows.forEach((row, i) => {
149
+ const v = parseCellNumber(row[col]);
150
+ if (v !== null && v < 0) out.push({ label: categoryLabel(table, shape, row, i), value: v });
151
+ });
152
+ return out;
153
+ }
154
+ function formatNumber(n) {
155
+ return n < 0 ? `\u2212${Math.abs(n)}` : String(n);
156
+ }
157
+ function chartNotice(table, requested) {
158
+ const shape = shapeOf(table);
159
+ if (!shape) return null;
160
+ const allowed = chartableTypes(table);
161
+ const wanted = requested && allowed.includes(requested) ? requested : autoPick(table, shape);
162
+ if (wanted === "pie") {
163
+ const neg = negativeRows(table, shape);
164
+ if (neg.length > 0) {
165
+ const list = neg.map((r) => `${r.label} ${formatNumber(r.value)}`).join(", ");
166
+ return `A pie can't show negative values (${list}), so this is drawn as bars.`;
167
+ }
168
+ }
169
+ const notes = [];
170
+ if (wanted === "pie" && shape.valueCols.length > 1) {
171
+ const shown = table.headers[shape.valueCols[0]] ?? "the first column";
172
+ const rest = shape.valueCols.slice(1).map((c) => table.headers[c]).join(", ");
173
+ notes.push(`A pie shows one column \u2014 this is ${shown}; ${rest} ${shape.valueCols.length > 2 ? "are" : "is"} not shown.`);
174
+ }
175
+ const missing = [];
176
+ table.rows.forEach((row, i) => {
177
+ if (shape.valueCols.every((c) => parseCellNumber(row[c]) === null)) {
178
+ missing.push(categoryLabel(table, shape, row, i));
179
+ }
180
+ });
181
+ if (missing.length === 1) notes.push(`1 row has no number and is not plotted (${missing[0]}).`);
182
+ else if (missing.length > 1) {
183
+ notes.push(`${missing.length} rows have no number and are not plotted (${missing.join(", ")}).`);
184
+ }
185
+ return notes.length > 0 ? notes.join(" ") : null;
186
+ }
187
+ function parseDelimitedTable(text) {
188
+ const src = text.replace(/\r\n?/g, "\n").trim();
189
+ if (!src) return null;
190
+ const firstLine = src.split("\n", 1)[0];
191
+ const delimiter = firstLine.includes(" ") ? " " : firstLine.includes(",") ? "," : firstLine.includes(";") ? ";" : null;
192
+ if (!delimiter) return null;
193
+ const records = [];
194
+ let row = [];
195
+ let cell = "";
196
+ let quoted = false;
197
+ for (let i = 0; i < src.length; i++) {
198
+ const ch = src[i];
199
+ if (quoted) {
200
+ if (ch === '"') {
201
+ if (src[i + 1] === '"') {
202
+ cell += '"';
203
+ i++;
204
+ } else quoted = false;
205
+ } else cell += ch;
206
+ } else if (ch === '"' && cell === "") quoted = true;
207
+ else if (ch === delimiter) {
208
+ row.push(cell);
209
+ cell = "";
210
+ } else if (ch === "\n") {
211
+ row.push(cell);
212
+ records.push(row);
213
+ row = [];
214
+ cell = "";
215
+ } else cell += ch;
216
+ }
217
+ row.push(cell);
218
+ records.push(row);
219
+ const cleaned = records.filter((r) => r.some((c) => c.trim() !== ""));
220
+ if (cleaned.length < 2) return null;
221
+ const [headers, ...rows] = cleaned;
222
+ if (headers.length < 2) return null;
223
+ return { headers: headers.map((h) => h.trim()), rows: rows.map((r) => r.map((c) => c.trim())) };
224
+ }
225
+ export {
226
+ chartNotice,
227
+ chartableTypes,
228
+ parseCellNumber,
229
+ parseDelimitedTable,
230
+ tableToChartSpec
231
+ };
@@ -0,0 +1,56 @@
1
+ import React, { ReactNode } from "react";
2
+ import { LucideIcon } from "lucide-react";
3
+ import { MenuItem } from "../../../host/app-bindings.js";
4
+ import type { CanvasContentType } from "../../../utils/lifted/canvasContent.js";
5
+ export interface BlockHeaderWrapperProps {
6
+ icon: LucideIcon;
7
+ iconClassName?: string;
8
+ title: string;
9
+ description?: string;
10
+ controls?: ReactNode;
11
+ children: ReactNode;
12
+ canvasType?: CanvasContentType;
13
+ canvasData?: unknown;
14
+ canvasMetadata?: Record<string, unknown>;
15
+ taskId?: string;
16
+ /**
17
+ * The exact data object to export as JSON.
18
+ * When provided, a Download button (desktop) / menu item (mobile) appears.
19
+ */
20
+ exportData?: unknown;
21
+ /** Filename without extension. Defaults to "export". */
22
+ exportFilename?: string;
23
+ /**
24
+ * Called with the parsed JSON object when the user picks a valid JSON file.
25
+ * The block is responsible for validating/applying the new data.
26
+ */
27
+ onDataImport?: (data: unknown) => void;
28
+ /**
29
+ * Extra buttons rendered on desktop alongside the standard action buttons.
30
+ * On mobile these are hidden — use extraMenuItems to expose them in the menu.
31
+ */
32
+ extraActions?: ReactNode;
33
+ /**
34
+ * Extra items injected into the mobile AdvancedMenu (and ignored on desktop,
35
+ * where extraActions handles the same actions visually).
36
+ */
37
+ extraMenuItems?: MenuItem[];
38
+ /** Tailwind gradient classes for the header card background */
39
+ headerGradient?: string;
40
+ /** Tailwind border class for the header card */
41
+ headerBorder?: string;
42
+ /** Classes applied to the import/export/fullscreen buttons */
43
+ actionButtonClassName?: string;
44
+ /** Classes applied to the canvas button */
45
+ canvasButtonClassName?: string;
46
+ }
47
+ /**
48
+ * BlockHeaderWrapper
49
+ *
50
+ * Reusable gradient header wrapper for chat markdown blocks.
51
+ *
52
+ * Desktop: individual icon buttons (Upload, Download, extra actions, Canvas, Fullscreen).
53
+ * Mobile: a single MoreHorizontal trigger that opens an AdvancedMenu with all actions.
54
+ */
55
+ declare const BlockHeaderWrapper: React.FC<BlockHeaderWrapperProps>;
56
+ export default BlockHeaderWrapper;