gloomberb 0.15.7 → 0.16.0

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 (524) hide show
  1. package/README.md +11 -2
  2. package/package.json +1 -1
  3. package/src/api-client/app-attention.ts +147 -0
  4. package/src/api-client/attention.ts +26 -0
  5. package/src/api-client/awards.ts +215 -0
  6. package/src/api-client/catalysts.ts +160 -0
  7. package/src/api-client/chat.ts +137 -14
  8. package/src/api-client/company-kpis.ts +153 -0
  9. package/src/api-client/cpi.ts +52 -0
  10. package/src/api-client/credit-documents.ts +107 -0
  11. package/src/api-client/data.ts +192 -3
  12. package/src/api-client/distress.ts +164 -0
  13. package/src/api-client/doe.ts +75 -0
  14. package/src/api-client/equity-screener.ts +11 -0
  15. package/src/api-client/exposure.ts +202 -0
  16. package/src/api-client/gpu.ts +93 -0
  17. package/src/api-client/hiring.ts +110 -0
  18. package/src/api-client/index.ts +78 -3
  19. package/src/api-client/normalizers.ts +31 -1
  20. package/src/api-client/paths.ts +3 -0
  21. package/src/api-client/perps.ts +127 -0
  22. package/src/api-client/power.ts +148 -0
  23. package/src/api-client/request.ts +58 -1
  24. package/src/api-client/research-activity.ts +172 -13
  25. package/src/api-client/socket.ts +75 -27
  26. package/src/api-client/supply-chain-graph.ts +40 -0
  27. package/src/api-client/supply-chain.ts +98 -0
  28. package/src/api-client/telemetry.ts +29 -0
  29. package/src/api-client/themes.ts +28 -0
  30. package/src/api-client/types.ts +33 -1
  31. package/src/api-client/wall-experiments.ts +100 -0
  32. package/src/api-client/wall-summary.ts +49 -0
  33. package/src/api-client/web-experiments.ts +136 -0
  34. package/src/app/pane-runtime/plugin-bindings.ts +5 -0
  35. package/src/app/pane-runtime/ticker-open-runtime.ts +8 -2
  36. package/src/app/runtime/update.ts +13 -1
  37. package/src/cli/commands/system.ts +2 -0
  38. package/src/cli/desktop-pane-shot.ts +3 -4
  39. package/src/cli/pane-functions/data.ts +78 -0
  40. package/src/cli/pane-functions/financial-ratio-shot.ts +160 -0
  41. package/src/cli/pane-functions/function-help.ts +220 -8
  42. package/src/cli/pane-functions/headless.ts +4 -0
  43. package/src/cli/pane-functions/screenshot-evidence.ts +21 -0
  44. package/src/cli/pane-functions/screenshot.ts +49 -5
  45. package/src/components/chart/composite/composite-chart.tsx +15 -2
  46. package/src/components/chart/composite/format.ts +24 -11
  47. package/src/components/chart/composite/rasterizer.ts +67 -16
  48. package/src/components/chart/composite/scene.ts +53 -2
  49. package/src/components/chart/composite/session-shading.ts +3 -2
  50. package/src/components/chart/composite/text-renderer.ts +52 -1
  51. package/src/components/chart/composite/time-axis.ts +100 -30
  52. package/src/components/chart/composite/tools.ts +2 -1
  53. package/src/components/chart/composite/types.ts +4 -0
  54. package/src/components/chart-table/index.ts +1 -0
  55. package/src/components/chart-table/layout.ts +15 -0
  56. package/src/components/command-bar/action-runtime.ts +1 -0
  57. package/src/components/command-bar/commands/direct/index.ts +32 -0
  58. package/src/components/command-bar/commands/registry.ts +7 -0
  59. package/src/components/command-bar/pane-templates/items.ts +11 -0
  60. package/src/components/command-bar/pane-templates/workflow.ts +19 -4
  61. package/src/components/command-bar/routes/root/command-items.ts +6 -0
  62. package/src/components/command-bar/routes/root/provider-search.ts +2 -0
  63. package/src/components/command-bar/routes/root/results.ts +64 -0
  64. package/src/components/command-bar/routes/root/runtime.ts +8 -0
  65. package/src/components/command-bar/routes/ticker-search/results.ts +89 -24
  66. package/src/components/command-bar/routes/ticker-search/route.ts +2 -0
  67. package/src/components/command-bar/surface/index.tsx +15 -0
  68. package/src/components/command-bar/view-model.ts +3 -0
  69. package/src/components/command-bar/workflow/collection-actions.ts +9 -7
  70. package/src/components/command-bar/workflow/ops.ts +19 -0
  71. package/src/components/command-bar/workflow/tickers.ts +5 -0
  72. package/src/components/company-logo.tsx +15 -2
  73. package/src/components/data-table/table-pane.ts +2 -1
  74. package/src/components/index.ts +1 -0
  75. package/src/components/layout/detached-pane-shell.tsx +12 -1
  76. package/src/components/layout/missing-pane.tsx +87 -23
  77. package/src/components/layout/pane/footer/index.tsx +64 -18
  78. package/src/components/layout/pane/footer/model.ts +85 -0
  79. package/src/components/layout/pane/sidebar.tsx +19 -1
  80. package/src/components/layout/shell/index.tsx +38 -28
  81. package/src/components/layout/shell/pane/management-shortcuts.ts +13 -1
  82. package/src/components/layout/status-bar.tsx +93 -28
  83. package/src/components/layout/status-widget-space.ts +72 -0
  84. package/src/components/onboarding/first-run-workspace.ts +8 -2
  85. package/src/components/onboarding/onboarding-wizard.tsx +35 -16
  86. package/src/components/onboarding/portfolio-step/positions-panel.tsx +14 -5
  87. package/src/components/onboarding/wizard-model.ts +13 -5
  88. package/src/components/onboarding/wizard-positions.ts +56 -7
  89. package/src/components/price-performance.tsx +31 -34
  90. package/src/components/ui/data-table/index.tsx +11 -8
  91. package/src/components/ui/display.tsx +15 -6
  92. package/src/components/ui/fields.tsx +5 -0
  93. package/src/components/ui/figure.tsx +94 -0
  94. package/src/components/ui/header-case.ts +25 -3
  95. package/src/components/ui/icon.tsx +3 -1
  96. package/src/components/ui/message-composer.tsx +8 -1
  97. package/src/components/ui/query-bar.tsx +8 -1
  98. package/src/components/ui/ratio-bar.tsx +84 -0
  99. package/src/components/ui/toggle.tsx +3 -1
  100. package/src/components/use-scrollbox-layout.ts +17 -0
  101. package/src/core/state/app/layout.ts +35 -1
  102. package/src/core/state/app/state.ts +15 -0
  103. package/src/core/state/app/types.ts +1 -0
  104. package/src/data/config/store/normalize.ts +24 -0
  105. package/src/i18n/es.ts +2 -0
  106. package/src/i18n/ja.ts +2 -0
  107. package/src/i18n/ko.ts +2 -0
  108. package/src/i18n/zh-cn.ts +2 -0
  109. package/src/i18n/zh-tw.ts +2 -0
  110. package/src/layout-marketplace/pane-imagery.ts +1 -0
  111. package/src/market-data/coordinator/entries.ts +13 -0
  112. package/src/market-data/coordinator/financials.ts +33 -8
  113. package/src/market-data/market/freshness.ts +16 -5
  114. package/src/market-data/market/trading-sessions.ts +65 -1
  115. package/src/market-data/published-cn-sessions.ts +25 -0
  116. package/src/market-data/published-nse-sessions.ts +20 -0
  117. package/src/news/aggregator.ts +4 -0
  118. package/src/plugins/builtin/account-management/model.ts +6 -1
  119. package/src/plugins/builtin/account-management/pane.tsx +36 -25
  120. package/src/plugins/builtin/alerts/catalysts.ts +77 -0
  121. package/src/plugins/builtin/alerts/events-pane.tsx +3 -0
  122. package/src/plugins/builtin/alerts/events.ts +10 -4
  123. package/src/plugins/builtin/alerts/history-pane.tsx +1 -1
  124. package/src/plugins/builtin/alerts/history.ts +1 -0
  125. package/src/plugins/builtin/alerts/index.tsx +6 -0
  126. package/src/plugins/builtin/alerts/research-builder.ts +10 -3
  127. package/src/plugins/builtin/alerts/research-rules.ts +15 -1
  128. package/src/plugins/builtin/analytics/risk-client.ts +15 -3
  129. package/src/plugins/builtin/analytics/risk-headless.ts +123 -18
  130. package/src/plugins/builtin/attention/client.ts +80 -0
  131. package/src/plugins/builtin/attention/evidence.ts +30 -0
  132. package/src/plugins/builtin/attention/headless.ts +33 -0
  133. package/src/plugins/builtin/attention/index.tsx +18 -0
  134. package/src/plugins/builtin/attention/model.ts +59 -0
  135. package/src/plugins/builtin/attention/pane.tsx +211 -0
  136. package/src/plugins/builtin/attention/trending.tsx +59 -0
  137. package/src/plugins/builtin/awards/alerts.ts +32 -0
  138. package/src/plugins/builtin/awards/client.ts +82 -0
  139. package/src/plugins/builtin/awards/detail.tsx +107 -0
  140. package/src/plugins/builtin/awards/evidence.ts +36 -0
  141. package/src/plugins/builtin/awards/headless.ts +55 -0
  142. package/src/plugins/builtin/awards/index.tsx +20 -0
  143. package/src/plugins/builtin/awards/model.ts +42 -0
  144. package/src/plugins/builtin/awards/pane.tsx +263 -0
  145. package/src/plugins/builtin/catalysts/client.ts +28 -0
  146. package/src/plugins/builtin/catalysts/detail.tsx +88 -0
  147. package/src/plugins/builtin/catalysts/evidence.ts +47 -0
  148. package/src/plugins/builtin/catalysts/headless.ts +42 -0
  149. package/src/plugins/builtin/catalysts/history.ts +26 -0
  150. package/src/plugins/builtin/catalysts/index.tsx +29 -0
  151. package/src/plugins/builtin/catalysts/model.ts +135 -0
  152. package/src/plugins/builtin/catalysts/pane.tsx +159 -0
  153. package/src/plugins/builtin/chart-composer/cli-options.ts +4 -0
  154. package/src/plugins/builtin/chart-composer/headless-schema.ts +6 -0
  155. package/src/plugins/builtin/chart-composer/index.tsx +8 -1
  156. package/src/plugins/builtin/chart-composer/pane.tsx +28 -1
  157. package/src/plugins/builtin/chat/attachments/desktop.tsx +610 -0
  158. package/src/plugins/builtin/chat/attachments/files.ts +45 -0
  159. package/src/plugins/builtin/chat/attachments/model.ts +164 -0
  160. package/src/plugins/builtin/chat/attachments/terminal.tsx +72 -0
  161. package/src/plugins/builtin/chat/attachments/transfer.ts +165 -0
  162. package/src/plugins/builtin/chat/content/channel-navigation.ts +13 -12
  163. package/src/plugins/builtin/chat/content/composer-runtime.ts +25 -4
  164. package/src/plugins/builtin/chat/content/composer.tsx +46 -4
  165. package/src/plugins/builtin/chat/content/footer.tsx +46 -8
  166. package/src/plugins/builtin/chat/content/index.tsx +263 -62
  167. package/src/plugins/builtin/chat/content/layout-metrics.ts +10 -2
  168. package/src/plugins/builtin/chat/content/open-targets.ts +17 -3
  169. package/src/plugins/builtin/chat/content/scroll.ts +7 -1
  170. package/src/plugins/builtin/chat/content/shortcuts.ts +36 -11
  171. package/src/plugins/builtin/chat/content/snapshot.ts +3 -0
  172. package/src/plugins/builtin/chat/content/transcript.tsx +17 -1
  173. package/src/plugins/builtin/chat/content/types.ts +7 -0
  174. package/src/plugins/builtin/chat/controller/attachments.ts +213 -0
  175. package/src/plugins/builtin/chat/controller/connections.ts +3 -1
  176. package/src/plugins/builtin/chat/controller/index.ts +114 -2
  177. package/src/plugins/builtin/chat/controller/lifecycle.ts +9 -0
  178. package/src/plugins/builtin/chat/controller/messages.ts +35 -2
  179. package/src/plugins/builtin/chat/controller/send.ts +128 -25
  180. package/src/plugins/builtin/chat/controller/state.ts +12 -1
  181. package/src/plugins/builtin/chat/controller/utils.ts +7 -5
  182. package/src/plugins/builtin/chat/controller/view.ts +2 -0
  183. package/src/plugins/builtin/chat/index.tsx +21 -0
  184. package/src/plugins/builtin/chat/layout.ts +9 -4
  185. package/src/plugins/builtin/chat/message/desktop.tsx +55 -20
  186. package/src/plugins/builtin/chat/message/header.tsx +30 -5
  187. package/src/plugins/builtin/chat/message/inline-tokens.tsx +9 -0
  188. package/src/plugins/builtin/chat/message/pending-send.ts +35 -0
  189. package/src/plugins/builtin/chat/message/profile-popover.tsx +5 -1
  190. package/src/plugins/builtin/chat/message/render-state.ts +12 -2
  191. package/src/plugins/builtin/chat/message/terminal.tsx +51 -4
  192. package/src/plugins/builtin/chat/message/types.ts +6 -1
  193. package/src/plugins/builtin/chat/pane-state.ts +59 -1
  194. package/src/plugins/builtin/chat/profile-popover.ts +50 -1
  195. package/src/plugins/builtin/chat/sidebar.tsx +8 -3
  196. package/src/plugins/builtin/chat/status-widget.tsx +29 -12
  197. package/src/plugins/builtin/chat/unread-inbox-pane.tsx +143 -0
  198. package/src/plugins/builtin/chat/unread-inbox.ts +91 -0
  199. package/src/plugins/builtin/clinical-trials/client.ts +237 -0
  200. package/src/plugins/builtin/clinical-trials/index.tsx +74 -0
  201. package/src/plugins/builtin/clinical-trials/pane.tsx +225 -0
  202. package/src/plugins/builtin/clinical-trials/types.ts +2 -0
  203. package/src/plugins/builtin/cloud/askg/controller.ts +37 -6
  204. package/src/plugins/builtin/cloud/askg/executor.ts +59 -44
  205. package/src/plugins/builtin/cloud/askg/host.ts +8 -1
  206. package/src/plugins/builtin/cloud/askg/manifest.ts +29 -2
  207. package/src/plugins/builtin/cloud/askg/model.ts +47 -13
  208. package/src/plugins/builtin/cloud/askg/notes.ts +100 -0
  209. package/src/plugins/builtin/cloud/askg/pane.tsx +50 -14
  210. package/src/plugins/builtin/cloud/askg/protocol.ts +39 -1
  211. package/src/plugins/builtin/cloud/askg/result-budget.ts +156 -0
  212. package/src/plugins/builtin/cloud/askg/user-data.ts +89 -0
  213. package/src/plugins/builtin/cloud/auth-actions.tsx +55 -31
  214. package/src/plugins/builtin/cloud/plugin.tsx +4 -1
  215. package/src/plugins/builtin/cloud/team/pane-sections.tsx +10 -1
  216. package/src/plugins/builtin/cloud/team/pane.tsx +3 -2
  217. package/src/plugins/builtin/cloud/thesis/board-pane.tsx +2 -2
  218. package/src/plugins/builtin/cloud/thesis/detail.tsx +1 -1
  219. package/src/plugins/builtin/cloud/thesis/ticker-tab.tsx +2 -2
  220. package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +202 -0
  221. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  222. package/src/plugins/builtin/cloud/upgrade-dialog.tsx +29 -3
  223. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +1 -1
  224. package/src/plugins/builtin/cloud-tweets/table.tsx +1 -1
  225. package/src/plugins/builtin/comment-letters/client.ts +342 -0
  226. package/src/plugins/builtin/comment-letters/index.tsx +74 -0
  227. package/src/plugins/builtin/comment-letters/pane.tsx +295 -0
  228. package/src/plugins/builtin/comment-letters/types.ts +43 -0
  229. package/src/plugins/builtin/company-attention/app-rank.tsx +79 -0
  230. package/src/plugins/builtin/company-attention/client.ts +69 -0
  231. package/src/plugins/builtin/company-attention/evidence.ts +45 -0
  232. package/src/plugins/builtin/company-attention/headless.ts +47 -0
  233. package/src/plugins/builtin/company-attention/index.tsx +30 -0
  234. package/src/plugins/builtin/company-attention/model.ts +129 -0
  235. package/src/plugins/builtin/company-attention/pane.tsx +183 -0
  236. package/src/plugins/builtin/company-kpis/client.ts +92 -0
  237. package/src/plugins/builtin/company-kpis/headless.ts +32 -0
  238. package/src/plugins/builtin/company-kpis/index.tsx +26 -0
  239. package/src/plugins/builtin/company-kpis/model.ts +124 -0
  240. package/src/plugins/builtin/company-kpis/pane.tsx +226 -0
  241. package/src/plugins/builtin/company-kpis/related.ts +11 -0
  242. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +44 -0
  243. package/src/plugins/builtin/composite-plugins.ts +34 -0
  244. package/src/plugins/builtin/correlation/history.ts +4 -1
  245. package/src/plugins/builtin/correlation/index.tsx +139 -80
  246. package/src/plugins/builtin/correlation/matrix/pair-chart.tsx +48 -0
  247. package/src/plugins/builtin/correlation/matrix/selection.ts +77 -0
  248. package/src/plugins/builtin/correlation/relationship/model.ts +2 -2
  249. package/src/plugins/builtin/cpi/client.ts +66 -0
  250. package/src/plugins/builtin/cpi/headless.ts +78 -0
  251. package/src/plugins/builtin/cpi/index.tsx +31 -0
  252. package/src/plugins/builtin/cpi/model.ts +198 -0
  253. package/src/plugins/builtin/cpi/pane.tsx +157 -0
  254. package/src/plugins/builtin/credit-documents/client.ts +99 -0
  255. package/src/plugins/builtin/credit-documents/detail.tsx +109 -0
  256. package/src/plugins/builtin/credit-documents/evidence.ts +64 -0
  257. package/src/plugins/builtin/credit-documents/gauge.tsx +55 -0
  258. package/src/plugins/builtin/credit-documents/headless.ts +40 -0
  259. package/src/plugins/builtin/credit-documents/index.tsx +19 -0
  260. package/src/plugins/builtin/credit-documents/model.ts +336 -0
  261. package/src/plugins/builtin/credit-documents/pane.tsx +185 -0
  262. package/src/plugins/builtin/custom-view/view-spec.ts +14 -2
  263. package/src/plugins/builtin/debt-maturities/pane.tsx +1 -0
  264. package/src/plugins/builtin/dividend-yield/pane.tsx +1 -1
  265. package/src/plugins/builtin/doe/client.ts +73 -0
  266. package/src/plugins/builtin/doe/headless.ts +93 -0
  267. package/src/plugins/builtin/doe/index.tsx +41 -0
  268. package/src/plugins/builtin/doe/model.ts +215 -0
  269. package/src/plugins/builtin/doe/pane.tsx +148 -0
  270. package/src/plugins/builtin/doe/range-bar.tsx +45 -0
  271. package/src/plugins/builtin/earnings/board.tsx +3 -0
  272. package/src/plugins/builtin/earnings/index.tsx +2 -0
  273. package/src/plugins/builtin/earnings-calls/pane.tsx +7 -1
  274. package/src/plugins/builtin/earnings-calls/transcript-view.tsx +7 -7
  275. package/src/plugins/builtin/earnings-ripple/client.ts +60 -0
  276. package/src/plugins/builtin/earnings-ripple/headless.ts +35 -0
  277. package/src/plugins/builtin/earnings-ripple/index.tsx +35 -0
  278. package/src/plugins/builtin/earnings-ripple/model.ts +98 -0
  279. package/src/plugins/builtin/earnings-ripple/pane.tsx +103 -0
  280. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  281. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +1 -1
  282. package/src/plugins/builtin/equity-screener/model.ts +74 -9
  283. package/src/plugins/builtin/equity-screener/pane.tsx +2 -0
  284. package/src/plugins/builtin/estimate-revisions/pane.tsx +3 -0
  285. package/src/plugins/builtin/executives/pane.tsx +7 -5
  286. package/src/plugins/builtin/exposure/charts.tsx +66 -0
  287. package/src/plugins/builtin/exposure/client.ts +53 -0
  288. package/src/plugins/builtin/exposure/drivers.ts +29 -0
  289. package/src/plugins/builtin/exposure/editor.tsx +61 -0
  290. package/src/plugins/builtin/exposure/evidence.ts +39 -0
  291. package/src/plugins/builtin/exposure/headless.ts +51 -0
  292. package/src/plugins/builtin/exposure/holdings.ts +56 -0
  293. package/src/plugins/builtin/exposure/index.tsx +13 -0
  294. package/src/plugins/builtin/exposure/model.ts +104 -0
  295. package/src/plugins/builtin/exposure/pane.tsx +247 -0
  296. package/src/plugins/builtin/fear-greed/charts.tsx +1 -1
  297. package/src/plugins/builtin/fear-greed/pane.tsx +2 -9
  298. package/src/plugins/builtin/filing-events/pane.tsx +2 -1
  299. package/src/plugins/builtin/gpu/board.tsx +163 -0
  300. package/src/plugins/builtin/gpu/changes.tsx +94 -0
  301. package/src/plugins/builtin/gpu/client.ts +130 -0
  302. package/src/plugins/builtin/gpu/equities.tsx +112 -0
  303. package/src/plugins/builtin/gpu/headless.ts +67 -0
  304. package/src/plugins/builtin/gpu/history.tsx +140 -0
  305. package/src/plugins/builtin/gpu/index.tsx +18 -0
  306. package/src/plugins/builtin/gpu/ladder.tsx +127 -0
  307. package/src/plugins/builtin/gpu/model.ts +317 -0
  308. package/src/plugins/builtin/gpu/pane.tsx +63 -0
  309. package/src/plugins/builtin/help/index.tsx +19 -2
  310. package/src/plugins/builtin/holders/pane.tsx +5 -9
  311. package/src/plugins/builtin/insider/detail.tsx +119 -0
  312. package/src/plugins/builtin/insider/display.ts +221 -0
  313. package/src/plugins/builtin/insider/headless.ts +24 -3
  314. package/src/plugins/builtin/insider/index.tsx +206 -108
  315. package/src/plugins/builtin/insider/insider-data.ts +31 -3
  316. package/src/plugins/builtin/insider/model.ts +53 -4
  317. package/src/plugins/builtin/insider/table-model.ts +226 -0
  318. package/src/plugins/builtin/insider/table.tsx +79 -0
  319. package/src/plugins/builtin/iv-history/screen-pane.tsx +1 -1
  320. package/src/plugins/builtin/jobs/pane.tsx +14 -7
  321. package/src/plugins/builtin/kelly-sizer/pane.tsx +1 -1
  322. package/src/plugins/builtin/macro-day/client.ts +50 -0
  323. package/src/plugins/builtin/macro-day/headless.ts +51 -0
  324. package/src/plugins/builtin/macro-day/index.tsx +21 -0
  325. package/src/plugins/builtin/macro-day/model.ts +137 -0
  326. package/src/plugins/builtin/macro-day/pane.tsx +118 -0
  327. package/src/plugins/builtin/macro-day/releases.ts +58 -0
  328. package/src/plugins/builtin/market-halts/model.ts +30 -17
  329. package/src/plugins/builtin/market-halts/pane.tsx +15 -21
  330. package/src/plugins/builtin/market-heatmap/data.ts +1 -1
  331. package/src/plugins/builtin/market-heatmap/index.tsx +198 -50
  332. package/src/plugins/builtin/market-heatmap/portfolio.ts +220 -0
  333. package/src/plugins/builtin/market-movers/index.tsx +1 -0
  334. package/src/plugins/builtin/market-movers/session-body.tsx +5 -2
  335. package/src/plugins/builtin/mna/distress/client.ts +326 -0
  336. package/src/plugins/builtin/mna/distress/detail.tsx +247 -0
  337. package/src/plugins/builtin/mna/distress/headless.ts +257 -0
  338. package/src/plugins/builtin/mna/distress/model.ts +427 -0
  339. package/src/plugins/builtin/mna/distress/pane.tsx +606 -0
  340. package/src/plugins/builtin/mna/index.tsx +15 -0
  341. package/src/plugins/builtin/mna/pane.tsx +42 -1
  342. package/src/plugins/builtin/news/index.tsx +62 -16
  343. package/src/plugins/builtin/news/wire/filter-articles.ts +54 -0
  344. package/src/plugins/builtin/news/wire/index.tsx +37 -3
  345. package/src/plugins/builtin/news/wire/industry-pane.tsx +29 -13
  346. package/src/plugins/builtin/news/wire/mutes.ts +253 -0
  347. package/src/plugins/builtin/news/wire/news/command-bar-search.ts +117 -0
  348. package/src/plugins/builtin/news/wire/news/footer.ts +4 -0
  349. package/src/plugins/builtin/news/wire/news/list-search.ts +34 -0
  350. package/src/plugins/builtin/news/wire/news/pop-out.tsx +158 -0
  351. package/src/plugins/builtin/news/wire/news/preset-pane.tsx +64 -19
  352. package/src/plugins/builtin/openfda/client.ts +300 -0
  353. package/src/plugins/builtin/openfda/index.tsx +71 -0
  354. package/src/plugins/builtin/openfda/pane.tsx +382 -0
  355. package/src/plugins/builtin/openfda/types.ts +76 -0
  356. package/src/plugins/builtin/options/footer.ts +1 -0
  357. package/src/plugins/builtin/options/view.tsx +1 -1
  358. package/src/plugins/builtin/options-calculator/pane.tsx +0 -1
  359. package/src/plugins/builtin/options-positioning/index.tsx +4 -2
  360. package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
  361. package/src/plugins/builtin/pe-band/client.ts +61 -0
  362. package/src/plugins/builtin/pe-band/headless.ts +51 -0
  363. package/src/plugins/builtin/pe-band/index.tsx +20 -0
  364. package/src/plugins/builtin/pe-band/model.ts +267 -0
  365. package/src/plugins/builtin/pe-band/pane.tsx +159 -0
  366. package/src/plugins/builtin/perps/client.ts +66 -0
  367. package/src/plugins/builtin/perps/equity-row.tsx +28 -0
  368. package/src/plugins/builtin/perps/headless.ts +34 -0
  369. package/src/plugins/builtin/perps/index.tsx +14 -0
  370. package/src/plugins/builtin/perps/model.ts +58 -0
  371. package/src/plugins/builtin/perps/pane.tsx +185 -0
  372. package/src/plugins/builtin/plugin-marketplace/pane.tsx +0 -1
  373. package/src/plugins/builtin/portfolio-list/cli/render.ts +177 -87
  374. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +6 -20
  375. package/src/plugins/builtin/portfolio-list/command-bar.ts +6 -2
  376. package/src/plugins/builtin/portfolio-list/headless.ts +237 -0
  377. package/src/plugins/builtin/portfolio-list/index.tsx +2 -0
  378. package/src/plugins/builtin/portfolio-list/mutations.ts +70 -1
  379. package/src/plugins/builtin/portfolio-list/pane/data.ts +17 -0
  380. package/src/plugins/builtin/portfolio-list/pane/index.tsx +88 -5
  381. package/src/plugins/builtin/portfolio-list/pane/remove-ticker.ts +85 -0
  382. package/src/plugins/builtin/portfolio-list/pane/streaming.ts +18 -12
  383. package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +6 -0
  384. package/src/plugins/builtin/power/client.ts +100 -0
  385. package/src/plugins/builtin/power/detail.tsx +82 -0
  386. package/src/plugins/builtin/power/evidence.ts +56 -0
  387. package/src/plugins/builtin/power/generation.tsx +37 -0
  388. package/src/plugins/builtin/power/headless.ts +43 -0
  389. package/src/plugins/builtin/power/index.tsx +16 -0
  390. package/src/plugins/builtin/power/model.ts +89 -0
  391. package/src/plugins/builtin/power/pane.tsx +209 -0
  392. package/src/plugins/builtin/power/query.ts +25 -0
  393. package/src/plugins/builtin/relative-rotation/pane.tsx +3 -3
  394. package/src/plugins/builtin/research/analyst-pane.tsx +1 -1
  395. package/src/plugins/builtin/research/corporate-actions-pane.tsx +13 -4
  396. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +11 -9
  397. package/src/plugins/builtin/research-search/pane.tsx +21 -7
  398. package/src/plugins/builtin/revenue-breakdown/pane.tsx +1 -1
  399. package/src/plugins/builtin/reverse-dcf/client.ts +35 -0
  400. package/src/plugins/builtin/reverse-dcf/headless.ts +44 -0
  401. package/src/plugins/builtin/reverse-dcf/index.tsx +20 -0
  402. package/src/plugins/builtin/reverse-dcf/model.ts +87 -0
  403. package/src/plugins/builtin/reverse-dcf/pane.tsx +107 -0
  404. package/src/plugins/builtin/risk-factors/pane.tsx +6 -5
  405. package/src/plugins/builtin/scanner/denied.tsx +4 -2
  406. package/src/plugins/builtin/scanner/feed.ts +1 -0
  407. package/src/plugins/builtin/scanner/flow-pane.tsx +3 -2
  408. package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
  409. package/src/plugins/builtin/seasonality/client.ts +4 -1
  410. package/src/plugins/builtin/sec/command-bar-search.ts +217 -0
  411. package/src/plugins/builtin/sec/forms.ts +54 -0
  412. package/src/plugins/builtin/sec/headless.ts +31 -5
  413. package/src/plugins/builtin/sec/index.tsx +67 -11
  414. package/src/plugins/builtin/sec/model.ts +35 -5
  415. package/src/plugins/builtin/sectors/headless.ts +1 -0
  416. package/src/plugins/builtin/sectors/index.tsx +72 -26
  417. package/src/plugins/builtin/shared/cloud-upgrade.ts +143 -39
  418. package/src/plugins/builtin/shared/pro-feature-wall.tsx +8 -4
  419. package/src/plugins/builtin/shared/research-cells.tsx +107 -0
  420. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -1
  421. package/src/plugins/builtin/shared/ticker-request.ts +1 -1
  422. package/src/plugins/builtin/shared/wall-teaser-catalog.ts +80 -0
  423. package/src/plugins/builtin/shared/wall-teaser.tsx +192 -0
  424. package/src/plugins/builtin/shared/wall-view-lifecycle.ts +43 -0
  425. package/src/plugins/builtin/short-interest/index.tsx +31 -0
  426. package/src/plugins/builtin/short-interest/watch-client.ts +70 -0
  427. package/src/plugins/builtin/short-interest/watch-headless.ts +49 -0
  428. package/src/plugins/builtin/short-interest/watch-model.ts +185 -0
  429. package/src/plugins/builtin/short-interest/watch-pane.tsx +169 -0
  430. package/src/plugins/builtin/short-volume/pane.tsx +1 -1
  431. package/src/plugins/builtin/social-mentions/pane.tsx +1 -1
  432. package/src/plugins/builtin/supply-chain/client.ts +104 -0
  433. package/src/plugins/builtin/supply-chain/disclosure-quote.tsx +17 -0
  434. package/src/plugins/builtin/supply-chain/evidence.ts +88 -0
  435. package/src/plugins/builtin/supply-chain/flow-layout.ts +133 -0
  436. package/src/plugins/builtin/supply-chain/flow.tsx +323 -0
  437. package/src/plugins/builtin/supply-chain/graph-client.ts +83 -0
  438. package/src/plugins/builtin/supply-chain/graph-evidence.ts +25 -0
  439. package/src/plugins/builtin/supply-chain/graph-model.ts +45 -0
  440. package/src/plugins/builtin/supply-chain/graph-pane.tsx +218 -0
  441. package/src/plugins/builtin/supply-chain/graph.tsx +163 -0
  442. package/src/plugins/builtin/supply-chain/headless.ts +105 -0
  443. package/src/plugins/builtin/supply-chain/index.tsx +17 -0
  444. package/src/plugins/builtin/supply-chain/model.ts +145 -0
  445. package/src/plugins/builtin/supply-chain/pane.tsx +276 -0
  446. package/src/plugins/builtin/supply-chain/row-evidence.tsx +96 -0
  447. package/src/plugins/builtin/supply-chain/trust.ts +34 -0
  448. package/src/plugins/builtin/themes/client.ts +39 -0
  449. package/src/plugins/builtin/themes/headless.ts +38 -0
  450. package/src/plugins/builtin/themes/model.ts +92 -0
  451. package/src/plugins/builtin/themes/pane.tsx +125 -0
  452. package/src/plugins/builtin/thirteenf/pane.tsx +6 -15
  453. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +5 -6
  454. package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +201 -0
  455. package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +327 -0
  456. package/src/plugins/builtin/ticker-detail/financials/period-end-history.ts +5 -2
  457. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +60 -12
  458. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +2 -1
  459. package/src/plugins/builtin/ticker-detail/headless.ts +7 -2
  460. package/src/plugins/builtin/ticker-detail/index.tsx +22 -0
  461. package/src/plugins/builtin/ticker-detail/overview/components.tsx +53 -30
  462. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +2 -0
  463. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +112 -47
  464. package/src/plugins/builtin/ticker-detail/pane.tsx +50 -6
  465. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +21 -42
  466. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +3 -0
  467. package/src/plugins/builtin/time-sales/pane.tsx +1 -1
  468. package/src/plugins/builtin/world-indices/indices.ts +1 -0
  469. package/src/plugins/catalog-browser.ts +40 -0
  470. package/src/plugins/catalog-manifest.ts +3 -0
  471. package/src/plugins/catalog-ui.ts +6 -0
  472. package/src/plugins/current-target.ts +0 -9
  473. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  474. package/src/renderers/browser/cloud-transport.ts +66 -1
  475. package/src/renderers/browser/main.tsx +2 -0
  476. package/src/renderers/dom/data-table/row.tsx +2 -0
  477. package/src/renderers/dom/desktop/controls.tsx +38 -25
  478. package/src/renderers/dom/desktop/icons.tsx +8 -0
  479. package/src/renderers/dom/host/chart-surface.tsx +36 -2
  480. package/src/renderers/dom/host/focus-scope.ts +11 -1
  481. package/src/renderers/dom/styles.css +28 -0
  482. package/src/renderers/electrobun/view/backend-rpc.ts +3 -2
  483. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +1 -1
  484. package/src/renderers/electrobun/view/http-fetch.ts +2 -0
  485. package/src/renderers/electrobun/view/main.tsx +3 -1
  486. package/src/renderers/electrobun/view/rpc-timeout.ts +59 -0
  487. package/src/renderers/opentui/start.tsx +3 -0
  488. package/src/shares/api.ts +3 -1
  489. package/src/sources/gloomberb-cloud/index.ts +47 -13
  490. package/src/sources/history-result.ts +1 -0
  491. package/src/sources/history-retention.ts +16 -0
  492. package/src/sources/provider-router/history.ts +4 -2
  493. package/src/sources/sec-edgar/identity.ts +36 -0
  494. package/src/sources/sec-edgar.ts +1 -34
  495. package/src/state/app/context/index.tsx +8 -0
  496. package/src/sync/core-contributors.ts +20 -2
  497. package/src/telemetry/attention-counts.ts +164 -0
  498. package/src/telemetry/live-config.ts +7 -0
  499. package/src/test-support/rpc-loopback.ts +7 -3
  500. package/src/test-support/shell-pane-keys.tsx +34 -0
  501. package/src/tickers/instrument-kind.ts +12 -6
  502. package/src/tickers/open-target.ts +1 -1
  503. package/src/tickers/search/asset-classes.ts +91 -0
  504. package/src/tickers/search/index.ts +62 -15
  505. package/src/tickers/search/ranking.ts +22 -3
  506. package/src/tickers/search/upsert.ts +4 -1
  507. package/src/time-series/live-bars.ts +8 -3
  508. package/src/time-series/resolve.ts +224 -17
  509. package/src/time-series/spec.ts +1 -0
  510. package/src/time-series/types.ts +9 -1
  511. package/src/types/config.ts +23 -1
  512. package/src/types/data-provider.ts +2 -0
  513. package/src/types/headless.ts +17 -0
  514. package/src/types/price-history.ts +2 -0
  515. package/src/ui/host.tsx +6 -0
  516. package/src/utils/double-escape-close.ts +20 -0
  517. package/src/utils/exchanges.ts +1 -0
  518. package/src/utils/html-entities.ts +15 -0
  519. package/src/utils/http-proxy-response.ts +44 -7
  520. package/src/utils/plugin-proxy-hosts.json +3 -0
  521. package/src/utils/price-history.ts +35 -1
  522. package/src/utils/sec.ts +21 -2
  523. package/src/utils/text-wrap.ts +13 -8
  524. package/src/utils/zoned-date-time.ts +67 -0
@@ -0,0 +1,169 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import {
3
+ DataTableView,
4
+ PaneStatusBody,
5
+ QueryBar,
6
+ usePaneFooter,
7
+ usePaneNoticeFooter,
8
+ type DataTableCell,
9
+ type DataTableColumn,
10
+ } from "../../../components";
11
+ import { loadingErrorFooterInfo, usePaneRefreshKey } from "../../../components/data-table/table-pane";
12
+ import { useAsyncResource } from "../../../react/async-resource";
13
+ import { useAutoRefresh } from "../../../react/auto-refresh";
14
+ import { usePaneSettingValue, usePluginAppActions, usePluginPaneState, useTickers } from "../../../public/react";
15
+ import { colors } from "../../../theme/colors";
16
+ import type { PaneProps } from "../../../types/plugin";
17
+ import { Box, TextAttributes } from "../../../ui";
18
+ import { formatShortDate } from "../../../utils/datetime-format";
19
+ import { formatCompact, formatNumber } from "../../../utils/format";
20
+ import { nextHeaderSort, type SortDirection } from "../../../utils/sort-values";
21
+ import { loadShortWatch } from "./watch-client";
22
+ import {
23
+ customUniverse,
24
+ ownNamesUniverse,
25
+ setupLabel,
26
+ sharedDate,
27
+ sortShortWatchRows,
28
+ type ShortWatchRow,
29
+ type ShortWatchSortId,
30
+ } from "./watch-model";
31
+
32
+ export const SHORT_WATCH_SCOPE_OPTIONS = [
33
+ { value: "mine", label: "Portfolios and watchlists" },
34
+ { value: "custom", label: "Custom symbols" },
35
+ ] as const;
36
+ const SCOPE_FILTER_OPTIONS = SHORT_WATCH_SCOPE_OPTIONS.map((option) => ({
37
+ ...option, short: option.value === "mine" ? "My names" : "Custom",
38
+ }));
39
+ const SYMBOLS_FIELD_WIDTH = 24;
40
+ /** Symbols apply once typing pauses, so a half-typed ticker does not start a load. */
41
+ const SYMBOLS_DEBOUNCE_MS = 700;
42
+
43
+ type WatchColumn = DataTableColumn & { id: ShortWatchSortId };
44
+ const COLUMNS: WatchColumn[] = [
45
+ { id: "symbol", label: "Symbol", width: 8, align: "left" },
46
+ { id: "setup", label: "Setup", width: 16, align: "left" },
47
+ { id: "percentFloat", label: "% Float", width: 8, align: "right" },
48
+ { id: "daysToCover", label: "Days", width: 6, align: "right" },
49
+ { id: "changePercent", label: "SI Chg%", width: 8, align: "right" },
50
+ { id: "return1M", label: "1M%", width: 8, align: "right" },
51
+ { id: "sharesShort", label: "Short", width: 8, align: "right" },
52
+ { id: "settlementDate", label: "Settled", width: 8, align: "right" },
53
+ { id: "closeDate", label: "Close", width: 8, align: "right" },
54
+ ];
55
+ const DEFAULT_SORT = { columnId: "setup" as ShortWatchSortId, direction: "desc" as SortDirection };
56
+ const rowKey = (row: ShortWatchRow) => row.symbol;
57
+
58
+ const day = (iso: string | null) => iso ? formatShortDate(`${iso}T00:00:00Z`, { year: false, utc: true, fallback: "--" }) : "--";
59
+ const signed = (value: number | null, digits = 1) => value == null ? "--" : `${value > 0 ? "+" : ""}${formatNumber(value, digits)}%`;
60
+ const signColor = (value: number | null) => value == null || value === 0 ? colors.textDim : value > 0 ? colors.positive : colors.negative;
61
+
62
+ export function ShortWatchPane({ width, height, focused }: Pick<PaneProps, "width" | "height" | "focused">) {
63
+ const [scope, setScope] = usePaneSettingValue("scope", "mine");
64
+ const [symbolsText, setSymbolsText] = usePaneSettingValue("symbols", "");
65
+ const [symbolsActive, setSymbolsActive] = useState(false);
66
+ const tickers = useTickers();
67
+ const { createPaneFromTemplate } = usePluginAppActions();
68
+ const custom = scope === "custom";
69
+ const universe = useMemo(() => custom ? customUniverse(symbolsText) : ownNamesUniverse([...tickers.values()]),
70
+ [custom, symbolsText, tickers]);
71
+ const key = universe.symbols.join(",");
72
+ const controller = useRef<AbortController | null>(null);
73
+ const loader = useCallback(async (force: boolean) => {
74
+ controller.current?.abort();
75
+ const current = new AbortController();
76
+ controller.current = current;
77
+ return loadShortWatch(key.split(","), { signal: current.signal, forceRefresh: force });
78
+ }, [key]);
79
+ useEffect(() => () => controller.current?.abort(), [loader]);
80
+ const resource = useAsyncResource(key ? loader : null, { keepPreviousData: true });
81
+ useAutoRefresh(resource.updatedAt, resource.load);
82
+ usePaneRefreshKey(resource.reload, { focused });
83
+
84
+ const [sort, setSort] = usePluginPaneState<{ columnId: ShortWatchSortId; direction: SortDirection }>("short-watch:sort", DEFAULT_SORT);
85
+ const rows = useMemo(() => sortShortWatchRows(resource.data ?? [], sort.columnId, sort.direction), [resource.data, sort]);
86
+ // A date every row shares moves to the query bar; a column no row fills is left out.
87
+ const settled = useMemo(() => sharedDate(rows, "settlementDate"), [rows]);
88
+ const closed = useMemo(() => sharedDate(rows, "closeDate"), [rows]);
89
+ const columns = useMemo(() => COLUMNS.filter((column) => !(column.id === "settlementDate" && settled)
90
+ && !(column.id === "closeDate" && closed)
91
+ && !(column.id === "percentFloat" && rows.length > 0 && rows.every((row) => row.percentFloat == null))), [rows, settled, closed]);
92
+ const [selected, setSelected] = usePluginPaneState<string | null>("short-watch:selected", null);
93
+
94
+ const unreported = rows.filter((row) => !row.settlementDate).map((row) => row.symbol);
95
+ const unpriced = rows.filter((row) => row.settlementDate && row.return1M == null).map((row) => row.symbol);
96
+ usePaneNoticeFooter({
97
+ registrationId: "short-watch-notices",
98
+ focused,
99
+ notices: [
100
+ universe.symbols.length ? universe.notice : null,
101
+ resource.data ? resource.error : null,
102
+ unreported.length ? `No short interest settlement for ${unreported.join(", ")}.` : null,
103
+ unpriced.length ? `No month of daily closes for ${unpriced.join(", ")}.` : null,
104
+ ].filter((value): value is string => !!value),
105
+ });
106
+ usePaneFooter("short-watch", () => ({
107
+ info: [
108
+ ...loadingErrorFooterInfo(resource.loading && !!resource.data, null),
109
+ ],
110
+ }), [resource.loading, resource.data]);
111
+ // Dates every row shares are the table's as-of context.
112
+ const asOf = [settled ? `settled ${day(settled)}` : null, closed ? `closes to ${day(closed)}` : null]
113
+ .filter(Boolean).join(" · ") || undefined;
114
+
115
+ const renderCell = useCallback((row: ShortWatchRow, column: WatchColumn): DataTableCell => {
116
+ switch (column.id) {
117
+ case "symbol": return { text: row.symbol, color: colors.textBright, attributes: TextAttributes.BOLD };
118
+ case "setup": return { text: setupLabel(row.setup), color: row.setup === "crowded-rising" ? colors.warning : colors.textDim };
119
+ case "percentFloat": return { text: row.percentFloat == null ? "--" : `${formatNumber(row.percentFloat, 1)}%`,
120
+ color: row.setup ? colors.textBright : colors.text, value: row.percentFloat ?? undefined };
121
+ case "daysToCover": return { text: row.daysToCover == null ? "--" : formatNumber(row.daysToCover, 1), value: row.daysToCover ?? undefined };
122
+ case "changePercent": return { text: signed(row.changePercent), value: row.changePercent ?? undefined };
123
+ case "return1M": return { text: signed(row.return1M), color: signColor(row.return1M), value: row.return1M ?? undefined };
124
+ case "sharesShort": return { text: row.sharesShort == null ? "--" : formatCompact(row.sharesShort), color: colors.textDim,
125
+ value: row.sharesShort ?? undefined };
126
+ case "settlementDate": return { text: day(row.settlementDate), color: colors.textDim, value: row.settlementDate ?? undefined };
127
+ case "closeDate": return { text: day(row.closeDate), color: colors.textDim, value: row.closeDate ?? undefined };
128
+ }
129
+ }, []);
130
+
131
+ const emptyTitle = custom ? "Add symbols to watch." : "No US-listed names in your portfolios or watchlists.";
132
+ return <Box width={width} height={height} flexDirection="column" overflow="hidden">
133
+ <QueryBar width={width} meta={asOf} filters={[
134
+ { id: "scope", label: "Names", value: custom ? "custom" : "mine", options: SCOPE_FILTER_OPTIONS, onChange: setScope },
135
+ ...(custom ? [{ id: "symbols", kind: "text" as const, label: "Symbols", value: symbolsText, placeholder: "GME, AMC, CVNA",
136
+ width: SYMBOLS_FIELD_WIDTH, debounceMs: SYMBOLS_DEBOUNCE_MS, focused, active: symbolsActive, onActiveChange: setSymbolsActive,
137
+ onChange: setSymbolsText }] : []),
138
+ ]} />
139
+ <PaneStatusBody
140
+ subject="short interest"
141
+ loading={!!key && !resource.data && resource.loading}
142
+ error={!resource.data ? resource.error : null}
143
+ empty={!key}
144
+ emptyTitle={emptyTitle}
145
+ emptyMessage={universe.notice ?? undefined}
146
+ >
147
+ <DataTableView<ShortWatchRow, WatchColumn>
148
+ focused={focused && !symbolsActive}
149
+ columns={columns}
150
+ items={rows}
151
+ rootWidth={width}
152
+ rootHeight={Math.max(2, height - 1)}
153
+ freezeFirstColumn
154
+ getItemKey={rowKey}
155
+ sortColumnId={sort.columnId}
156
+ sortDirection={sort.direction}
157
+ onHeaderClick={(id) => setSort((current) => nextHeaderSort(current, id as ShortWatchSortId, { firstDirection: "desc" }))}
158
+ selection={{ kind: "id", selectedId: rows.some((row) => row.symbol === selected) ? selected! : rows[0]?.symbol ?? "",
159
+ getId: rowKey, onChange: (id) => setSelected(id) }}
160
+ onActivate={(row) => createPaneFromTemplate("short-interest-pane", { symbol: row.symbol })}
161
+ getExportMetadata={() => [["settled", settled ?? undefined], ["closes to", closed ?? undefined],
162
+ ["% float", "latest settlement's shares short over the current float"], ["1M", "close-to-close over one calendar month"]]}
163
+ renderCell={renderCell}
164
+ selectedTextOverridesCellColor
165
+ emptyStateTitle="No names"
166
+ />
167
+ </PaneStatusBody>
168
+ </Box>;
169
+ }
@@ -86,7 +86,7 @@ export function ShortVolumePane({ width, height, focused }: Pick<PaneProps, "wid
86
86
  info: data && updatedAgo ? [{ id: "updated", parts: [{ text: updatedAgo, tone: "muted" as const }] }] : [],
87
87
  stale: !!data && resource.data?.stale,
88
88
  });
89
- if (!data && isCloudSessionRequired(resource.error)) return <SignInWall action="view daily short volume" needsVerification={session.needsVerification} />;
89
+ if (!data && isCloudSessionRequired(resource.error)) return <SignInWall placement="short-volume-signin" action="view daily short volume" needsVerification={session.needsVerification} />;
90
90
  if (!symbol) return <EmptyState title="No ticker selected." message="Select a ticker to view daily short volume." />;
91
91
  return <Box flexDirection="column" width={width} height={height}>
92
92
  <PaneStatusBody loading={resource.loading && !data} error={!data ? resource.error : null} subject="daily short volume"
@@ -119,7 +119,7 @@ export function SocialMentionsPane({ width, height, focused }: Pick<PaneProps, "
119
119
  ...(resource.data?.stale ? [{ id: "stale", parts: [{ text: "stale", tone: "warning" as const }] }] : []),
120
120
  ] : [],
121
121
  });
122
- if (!data && isCloudSessionRequired(resource.error)) return <SignInWall action="view social mentions" needsVerification={session.needsVerification} />;
122
+ if (!data && isCloudSessionRequired(resource.error)) return <SignInWall placement="social-mentions-signin" action="view social mentions" needsVerification={session.needsVerification} />;
123
123
  if (!listing?.symbol) return <EmptyState title="No ticker selected." message="Select a ticker to view social mentions." />;
124
124
  if (!symbol) return <EmptyState title="This ticker cannot be searched as a cashtag." message="Use a symbol of up to six letters and digits, starting with a letter." />;
125
125
  const latest = summary?.latest ?? null;
@@ -0,0 +1,104 @@
1
+ import { apiClient } from "../../../api-client";
2
+ import type { SupplyChainPayload, SupplyEntity, SupplyEvidenceItem, SupplyOptions, SupplyRow } from "../../../api-client/supply-chain";
3
+ import { createPluginCache } from "../../../data/plugin-cache";
4
+ import { cachedCloudResource, loadCloudResource, unavailableOnServer } from "../shared/cloud-resource";
5
+ import { activeRelationship, canShowQuote, isUnconfirmed, publicEvidence, supplyOptions, TIER_OPTIONS, trustTier } from "./trust";
6
+
7
+ export const SUPPLY_UNAVAILABLE = "Supply chain disclosures are not available yet.";
8
+ const SUPPLY_ROLES = ["customer", "supplier", "partner", "competitor", "investee"] as const;
9
+ export const supplyChainCache = createPluginCache<SupplyChainPayload>({
10
+ kind: "supply-chain", source: "gloom-cloud", schemaVersion: 2,
11
+ policy: { staleMs: 60 * 60_000, expireMs: 30 * 86_400_000 },
12
+ });
13
+ const text = (value: unknown): value is string => typeof value === "string";
14
+ const nullableText = (value: unknown) => value === null || text(value);
15
+ const finite = (value: unknown): value is number => typeof value === "number" && Number.isFinite(value);
16
+ const nonnegative = (value: unknown) => finite(value) && value >= 0;
17
+ const nullableNumber = (value: unknown) => value === null || nonnegative(value);
18
+ const optionalText = (value: unknown) => value === undefined || nullableText(value);
19
+ const date = (value: unknown) => text(value) && /^\d{4}-\d{2}-\d{2}$/.test(value) && Number.isFinite(Date.parse(value)) && new Date(value).toISOString().slice(0, 10) === value;
20
+ const timestamp = (value: unknown) => text(value) && Number.isFinite(Date.parse(value));
21
+ const tier = (value: unknown) => Number.isInteger(value) && Number(value) >= 1 && Number(value) <= 6;
22
+ const claim = (value: unknown) => ["disclosed", "company_confirmed", "reported", "rumored"].includes(String(value));
23
+ const url = (value: unknown) => { try { return text(value) && ["http:", "https:"].includes(new URL(value).protocol); } catch { return false; } };
24
+ function evidence(value: SupplyEvidenceItem): boolean {
25
+ return !!value && text(value.id) && tier(value.tier) && claim(value.claimType) && url(value.url)
26
+ && text(value.title) && text(value.publisher) && timestamp(value.publishedAt) && timestamp(value.fetchedAt)
27
+ && nullableText(value.quote) && ["full", "short", "link_only"].includes(value.quoteRights)
28
+ && ["publisher_text", "asr", "ocr", "snippet"].includes(value.textOrigin)
29
+ && nullableText(value.quoteLanguage) && nullableText(value.englishGloss) && text(value.originKey)
30
+ && finite(value.confidence) && value.confidence >= 0 && value.confidence <= 1
31
+ && ["active", "superseded", "rejected", "stale"].includes(value.status)
32
+ && (value.verificationStatus === undefined || ["verified", "lead"].includes(value.verificationStatus))
33
+ && nullableText(value.valueKind) && (value.value === null || finite(value.value)) && nullableText(value.valueUnit) && nullableText(value.currency);
34
+ }
35
+ export function validSupplyEntity(value: SupplyEntity): boolean {
36
+ return !!value && text(value.id) && text(value.name) && nullableText(value.ticker) && nullableText(value.exchange)
37
+ && nullableText(value.country) && ["listed", "private", "government", "unknown"].includes(value.kind)
38
+ && !!value.identifiers && typeof value.identifiers === "object" && !Array.isArray(value.identifiers)
39
+ && typeof value.anonymous === "boolean" && (!value.anonymous || value.ticker === null)
40
+ && (value.aggregate === undefined || typeof value.aggregate === "boolean");
41
+ }
42
+ export function validSupplyRow(value: SupplyRow): boolean {
43
+ return !!value && text(value.id) && validSupplyEntity(value.counterparty) && validSupplyEntity(value.reportingEntity)
44
+ && SUPPLY_ROLES.includes(value.role) && ["in", "out", "mutual"].includes(value.direction)
45
+ && nullableText(value.pctScope) && nullableNumber(value.pctOfRevenue) && (value.pctOfRevenue === null || value.pctOfRevenue <= 100)
46
+ && [null, "revenue", "receivables", "cost", "purchases"].includes(value.pctBasis)
47
+ && nullableNumber(value.usd) && [null, "disclosed", "derived"].includes(value.usdBasis)
48
+ && (value.nativeAmount == null || nonnegative(value.nativeAmount))
49
+ && (value.nativeCurrency == null || (text(value.nativeCurrency) && /^[A-Z]{3}$/.test(value.nativeCurrency)))
50
+ && (value.nativeScale == null || (finite(value.nativeScale) && value.nativeScale > 0))
51
+ && (value.nativeAmount == null || (value.nativeCurrency != null && value.nativeScale != null && Number.isFinite(value.nativeAmount * value.nativeScale)))
52
+ && (value.jurisdiction == null || (text(value.jurisdiction) && /^[A-Z]{2}$/.test(value.jurisdiction)))
53
+ && [undefined, null, "entity", "group", "anonymous", "aggregate"].includes(value.entityScope)
54
+ && (value.pctOfRevenue === null || value.pctBasis !== null) && (value.usd === null || value.usdBasis !== null)
55
+ && text(value.period) && nullableText(value.fiscalYear) && ["xbrl", "filing_text", "call", "news", "web", "import", "press_release"].includes(value.sourceKind)
56
+ && nullableText(value.form) && (value.filedDate === null || date(value.filedDate)) && date(value.asOf)
57
+ && finite(value.confidence) && value.confidence >= 0 && value.confidence <= 1
58
+ && text(value.quote) && (value.quote.trim().length > 0 || !!value.evidence?.length) && nullableText(value.quoteLanguage)
59
+ && optionalText(value.quoteGloss) && optionalText(value.sectionRef) && optionalText(value.sourceAttribution)
60
+ && [null, "exact", "whitespace", "nfkc_whitespace"].includes(value.quoteMatchMode)
61
+ && url(value.filingUrl) && nullableText(value.accession)
62
+ && (value.tier === undefined || tier(value.tier)) && (value.claimType === undefined || claim(value.claimType))
63
+ && (value.corroboration === undefined || Number.isInteger(value.corroboration) && value.corroboration >= 0)
64
+ && (value.leadStatus === undefined || ["none", "lead", "verified", "rejected", "stale"].includes(value.leadStatus))
65
+ && [value.firstSeenAt, value.lastSeenAt, value.lastConfirmedAt].every((value) => value === undefined || value === null || timestamp(value))
66
+ && (value.whyUnconfirmed === undefined || nullableText(value.whyUnconfirmed))
67
+ && (value.evidence === undefined || Array.isArray(value.evidence) && value.evidence.every(evidence));
68
+ }
69
+ export function normalizeSupplyRow(value: SupplyRow): SupplyRow {
70
+ const items = value.evidence?.map(publicEvidence);
71
+ const unconfirmed = isUnconfirmed(value) || !activeRelationship(value);
72
+ // Restrict again before cache, exports or screenshot metadata, even if a server regresses.
73
+ const selected = items?.find((item) => item.status === "active" && item.tier === trustTier(value)) ?? items?.find((item) => item.status === "active");
74
+ return { ...value, counterparty: { ...value.counterparty, aggregate: value.counterparty.aggregate ?? false }, reportingEntity: { ...value.reportingEntity, aggregate: value.reportingEntity.aggregate ?? false },
75
+ ...(trustTier(value) !== 1 || unconfirmed ? { pctOfRevenue: null, pctBasis: null, pctScope: null } : {}),
76
+ ...(unconfirmed ? { usd: null, usdBasis: null, nativeAmount: null, nativeCurrency: null, nativeScale: null, lastConfirmedAt: null } : {}),
77
+ ...(items?.length ? { evidence: items, quote: selected && canShowQuote(selected) ? selected.quote ?? "" : "",
78
+ quoteLanguage: selected?.quoteLanguage ?? null, quoteGloss: selected && canShowQuote(selected) ? selected.englishGloss : null } : {}) };
79
+ }
80
+ export function validateSupplyChain(data: SupplyChainPayload): SupplyChainPayload {
81
+ const valid = !!data && text(data.symbol) && (data.entity === null || validSupplyEntity(data.entity))
82
+ && (data.asOf === null || date(data.asOf)) && ["available", "unavailable"].includes(data.status)
83
+ && ["says", "names"].every((view) => {
84
+ const key = view as "says" | "names";
85
+ const rows = data[key];
86
+ return Array.isArray(rows) && rows.every(validSupplyRow) && new Set(rows.map((entry) => entry.id)).size === rows.length
87
+ && SUPPLY_ROLES.every((role) => Number.isInteger(data.counts?.[key]?.[role])
88
+ && data.counts[key][role] >= rows.filter((entry) => entry.role === role).length);
89
+ }) && Number.isInteger(data.totalRows) && data.totalRows >= data.says.length + data.names.length
90
+ && ["full", "preview"].includes(data.access) && Number.isInteger(data.lockedRows) && data.lockedRows >= 0
91
+ && typeof data.truncated === "boolean" && [3, null].includes(data.previewRowsPerRole)
92
+ && text(data.disclaimer) && (data.tierCounts === undefined || TIER_OPTIONS.every(({ value }) => Number.isInteger(data.tierCounts?.[value]) && data.tierCounts![value] >= 0));
93
+ if (!valid) throw new Error("The server returned unreadable supply chain disclosures");
94
+ const normalizeEntity = (value: SupplyEntity): SupplyEntity => ({ ...value, aggregate: value.aggregate ?? false });
95
+ return { ...data, entity: data.entity ? normalizeEntity(data.entity) : null, says: data.says.map(normalizeSupplyRow), names: data.names.map(normalizeSupplyRow) };
96
+ }
97
+ export async function fetchSupplyChain(symbol: string, client: Pick<typeof apiClient, "getCloudSupplyChain"> = apiClient, options: SupplyOptions = {}) {
98
+ try { return validateSupplyChain(await client.getCloudSupplyChain(symbol, options)); }
99
+ catch (error) { throw unavailableOnServer(error, SUPPLY_UNAVAILABLE, [404, 503]); }
100
+ }
101
+ // Account and plan belong in the key: signing out must never reveal a paid cached response.
102
+ const cacheKey = (symbol: string, access: string, options: SupplyOptions) => `${symbol.toUpperCase()}:${access}:${JSON.stringify(supplyOptions(options.tiers))}:${!!options.includeLeads}`;
103
+ export const cachedSupplyChain = (symbol: string, access: string, options: SupplyOptions = {}) => cachedCloudResource(supplyChainCache, cacheKey(symbol, access, options), validateSupplyChain);
104
+ export const loadSupplyChain = (symbol: string, access: string, force = false, options: SupplyOptions = {}) => loadCloudResource(supplyChainCache, cacheKey(symbol, access, options), () => fetchSupplyChain(symbol, apiClient, options), { force, validate: validateSupplyChain });
@@ -0,0 +1,17 @@
1
+ import type { SupplyRole } from "../../../api-client/supply-chain";
2
+ import { Prose } from "../../../components";
3
+ import { blendHex } from "../../../theme/colors";
4
+ import { useThemeColors } from "../../../theme/theme-context";
5
+ import { Box, Text, useUiCapabilities } from "../../../ui";
6
+ import { quoteLanguageLabel, ROLE_COLORS } from "./model";
7
+
8
+ /** A literal filing quote, with the same relationship accent in every SPLC view. */
9
+ export function DisclosureQuote({ role, quote, quoteLanguage, width }: { role: SupplyRole; quote: string; quoteLanguage?: string | null; width: number }) {
10
+ const colors = useThemeColors();
11
+ const desktop = !!useUiCapabilities().nativePaneChrome;
12
+ return <Box marginY={1} paddingLeft={desktop ? 0 : 1} border={desktop ? undefined : ["left"]} borderColor={ROLE_COLORS[role]}
13
+ style={desktop ? { borderLeft: `3px solid ${ROLE_COLORS[role]}`, paddingLeft: 12, paddingTop: 4, paddingBottom: 4, backgroundColor: blendHex(colors.bg, ROLE_COLORS[role], 0.07), borderRadius: 2 } : undefined}>
14
+ <Text fg={colors.textDim}>{`Original quote · ${quoteLanguageLabel({ quoteLanguage: quoteLanguage ?? null })}`}</Text>
15
+ <Prose text={quote} width={Math.max(1, width - 6)} figures={false} />
16
+ </Box>;
17
+ }
@@ -0,0 +1,88 @@
1
+ import type { SupplyChainPayload, SupplyTierFilter } from "../../../api-client/supply-chain";
2
+ import type { GraphPayload } from "../../../api-client/supply-chain-graph";
3
+ import type { PaneScreenshotEvidenceHook } from "../../../cli/pane-functions/screenshot-evidence";
4
+ import { useRemoteUiNode } from "../../../remote/semantic-tree";
5
+ import { isRecord } from "../../../utils/guards";
6
+ import { fetchSupplyChain, validateSupplyChain } from "./client";
7
+ import { isUnconfirmed, matchesSupplyOptions, supplyOptions } from "./trust";
8
+ import { fetchSupplyGraph, graphOptions, validateGraph } from "./graph-client";
9
+
10
+ type SupplyTab = "table" | "flow" | "graph" | "path";
11
+ interface SupplyEvidence {
12
+ kind: "supply-chain";
13
+ version: 1;
14
+ complete: boolean;
15
+ plottedValueCount: number;
16
+ payload: SupplyChainPayload | GraphPayload;
17
+ tab: SupplyTab;
18
+ view?: string;
19
+ rowIds: string[];
20
+ evidenceOpen?: boolean;
21
+ evidenceId?: string | null;
22
+ tiers?: SupplyTierFilter[];
23
+ }
24
+ const graphTab = (tab: unknown) => tab === "graph" || tab === "path";
25
+ export function useSupplyEvidence(payload: SupplyChainPayload | null, tab: string, view: string, rowIds: string[], evidenceId: string | null = null, tiers: SupplyTierFilter[] = supplyOptions().tiers) {
26
+ useRemoteUiNode(graphTab(tab) ? null : { role: "chart-data", label: "Rendered supply chain disclosures", getMetadata: () => ({
27
+ kind: "supply-chain", version: 1, complete: !!payload, ready: !!payload,
28
+ plottedValueCount: rowIds.length, payload, tab, view, rowIds, evidenceOpen: !!evidenceId, evidenceId, tiers,
29
+ }) });
30
+ }
31
+ export const supplyScreenshotEvidence: PaneScreenshotEvidenceHook<SupplyEvidence> = {
32
+ paneId: "supply-chain", kind: "supply-chain", label: "supply chain",
33
+ async prepare({ resolved }) {
34
+ const symbol = resolved.createOptions?.symbol ?? resolved.createOptions?.arg;
35
+ if (!symbol) throw new Error("A supply chain screenshot requires a ticker");
36
+ // A filing pane needs an identity, never fabricated prices or unrelated market requests.
37
+ if (graphTab(resolved.options.tab)) {
38
+ const target = String(resolved.options.to ?? "").trim();
39
+ if (resolved.options.tab === "path" && !target) throw new Error("Path requires a target company: --to TICKER");
40
+ const payload = await fetchSupplyGraph(symbol, graphOptions(resolved.options), target);
41
+ return { settings: { graphSnapshot: payload }, financials: [[payload.symbol, { annualStatements: [], quarterlyStatements: [], priceHistory: [] }]] };
42
+ }
43
+ const payload = await fetchSupplyChain(symbol, undefined, supplyOptions(resolved.options.tiers));
44
+ return { settings: { supplySnapshot: payload }, financials: [[payload.symbol, { annualStatements: [], quarterlyStatements: [], priceHistory: [] }]] };
45
+ },
46
+ read(value) {
47
+ if (!isRecord(value) || value.kind !== "supply-chain" || value.version !== 1 || !isRecord(value.payload)
48
+ || !["table", "flow", "graph", "path"].includes(String(value.tab))
49
+ || !Array.isArray(value.rowIds) || !value.rowIds.every((id) => typeof id === "string") || value.complete !== true
50
+ || value.evidenceOpen !== undefined && typeof value.evidenceOpen !== "boolean"
51
+ || value.plottedValueCount !== value.rowIds.length || new Set(value.rowIds).size !== value.rowIds.length) return null;
52
+ try {
53
+ if (graphTab(value.tab)) {
54
+ const payload = validateGraph(value.payload as unknown as GraphPayload);
55
+ const eligible = new Set((value.tab === "graph" ? payload.links : payload.paths).map(row => row.id));
56
+ if (value.rowIds.some(id => !eligible.has(id))) return null;
57
+ const paths = [...payload.paths, ...[...payload.upstream, ...payload.downstream, ...payload.related].flatMap(row => [row.bestPath, row.shortestPath])];
58
+ if (value.evidenceOpen && !paths.some(path => path.id === value.evidenceId)) return null;
59
+ return { ...value, payload } as unknown as SupplyEvidence;
60
+ } else {
61
+ if (!["says", "names"].includes(String(value.view))) return null;
62
+ const payload = validateSupplyChain(value.payload as unknown as SupplyChainPayload);
63
+ const options = supplyOptions(value.tiers);
64
+ const eligible = (value.tab === "flow" ? [...payload.says, ...payload.names].filter(row => !isUnconfirmed(row)) : payload[value.view as "says" | "names"])
65
+ .filter(row => matchesSupplyOptions(row, options));
66
+ if (value.rowIds.some(id => !eligible.some(row => row.id === id))) return null;
67
+ if ((value.evidenceOpen || value.evidenceId != null) && !eligible.some(row => row.id === value.evidenceId)) return null;
68
+ // Return the validated payload: restricted quotes and glosses have been removed.
69
+ return { ...value, payload } as unknown as SupplyEvidence;
70
+ }
71
+ } catch { return null; }
72
+ },
73
+ mismatches(evidence, { resolved, payload }) {
74
+ const settings = payload.config.layout.instances.find(entry => entry.instanceId === payload.paneId)?.settings;
75
+ const snapshot = settings?.[graphTab(evidence.tab) ? "graphSnapshot" : "supplySnapshot"];
76
+ const mismatches: string[] = [];
77
+ if (JSON.stringify(evidence.payload) !== JSON.stringify(snapshot)) mismatches.push("Supply chain disclosures differ from the captured filing data");
78
+ if (resolved.options.evidence === true && (!evidence.evidenceOpen || !evidence.evidenceId)) mismatches.push("Supply chain evidence detail was not opened");
79
+ if (evidence.tab !== (resolved.options.tab ?? "table")) mismatches.push("Supply chain tab does not match");
80
+ if (!graphTab(evidence.tab)) {
81
+ if (evidence.view !== (resolved.options.view ?? "says")) mismatches.push("Supply chain direction does not match");
82
+ if (JSON.stringify(evidence.tiers) !== JSON.stringify(supplyOptions(resolved.options.tiers).tiers)) mismatches.push("Supply chain evidence tiers do not match");
83
+ }
84
+ return mismatches;
85
+ },
86
+ unavailable(evidence) { return evidence?.complete ? [] : ["supply chain disclosures"]; },
87
+ symbols({ payload }) { return payload.financials.map(([symbol]) => symbol); },
88
+ };
@@ -0,0 +1,133 @@
1
+ import type { SupplyRole, SupplyRow } from "../../../api-client/supply-chain";
2
+ import { displayWidth } from "../../../utils/format";
3
+ import { flowBands, flowGroups, type FlowBand, type FlowNode } from "./model";
4
+
5
+ /** A node card or a related chip, in pane cells. */
6
+ export interface PositionedNode extends FlowNode { x: number; y: number; width: number; height: number; role: SupplyRole | null }
7
+
8
+ /**
9
+ * One ribbon from a node's edge to the focus card's edge, in pane cells. The
10
+ * thickness is in rows and is null for a relationship with no comparable
11
+ * figure, which draws as a hairline.
12
+ */
13
+ export interface FlowRibbon { id: string; band: "suppliers" | "customers"; x0: number; y0: number; x1: number; y1: number; thickness: number | null; role: SupplyRole }
14
+
15
+ interface FlowRelatedRow { role: SupplyRole; y: number; chips: PositionedNode[]; total: number }
16
+
17
+ export interface FlowGeometry {
18
+ center: { x: number; y: number; width: number; height: number };
19
+ /** Supplier and customer cards, then related chips, in keyboard order. */
20
+ nodes: PositionedNode[];
21
+ ribbons: FlowRibbon[];
22
+ related: FlowRelatedRow[];
23
+ groups: SupplyRow[];
24
+ groupRow: number | null;
25
+ headerRow: number;
26
+ legendRow: number;
27
+ /** What sets ribbon widths in each column, when any ribbon there has a figure. */
28
+ scale: { suppliers: "revenue" | "usd" | null; customers: "revenue" | "usd" | null; scope: string | null };
29
+ cardWidth: number;
30
+ }
31
+
32
+ const CARD_ROWS = 2;
33
+ const MAX_CARDS = 12;
34
+ const MAX_CARD_GAP = 2;
35
+ const RELATED_ROLES: SupplyRole[] = ["partner", "competitor", "investee"];
36
+ /** The thickest ribbon stays inside its two-row card. */
37
+ const MAX_RIBBON_ROWS = 1.5;
38
+ export const RELATED_LABEL_CELLS = 13;
39
+
40
+ /** The curve every ribbon follows: horizontal at both ends, eased between. */
41
+ export function ribbonY(ribbon: Pick<FlowRibbon, "x0" | "y0" | "x1" | "y1">, x: number): number {
42
+ const t = ribbon.x1 === ribbon.x0 ? 0 : Math.max(0, Math.min(1, (x - ribbon.x0) / (ribbon.x1 - ribbon.x0)));
43
+ return ribbon.y0 + (ribbon.y1 - ribbon.y0) * t * t * (3 - 2 * t);
44
+ }
45
+
46
+ /** Width in rows, proportional to the figure on its column's scale, so two ribbons compare exactly. */
47
+ const ribbonRows = (weight: number | null) => weight === null ? null : weight * MAX_RIBBON_ROWS;
48
+
49
+ const chipLabel = (node: FlowNode) => node.more ? `+${node.more} more` : node.row?.counterparty.ticker ?? node.label;
50
+ const chipWidth = (node: FlowNode) => Math.min(24, displayWidth(chipLabel(node)) + 2);
51
+ export { chipLabel as flowChipLabel };
52
+
53
+ /**
54
+ * Where everything in the flow sits for a pane size: supplier cards on the
55
+ * left, customers on the right, the focus card between them with every ribbon
56
+ * ending on its edge in node order (so ribbons never cross), and the
57
+ * partners, competitors, investees and cohort groups in a band underneath.
58
+ */
59
+ export function flowGeometry(rows: readonly SupplyRow[], options: {
60
+ width: number; height: number; focusId?: string; focusLabelWidth: number;
61
+ pages?: Partial<Record<FlowBand, number>>; relatedPages?: Partial<Record<SupplyRole, number>>;
62
+ }): FlowGeometry {
63
+ const { width, height } = options;
64
+ const all = flowBands([...rows], Number.MAX_SAFE_INTEGER, {}, options.focusId);
65
+ const relatedRoles = RELATED_ROLES.filter((role) => all.related.some((node) => node.row?.role === role));
66
+ const groups = flowGroups(rows);
67
+ const bandRows = relatedRoles.length + (groups.length ? 1 : 0);
68
+ const legendRow = height - 1;
69
+ const bandTop = legendRow - bandRows - (bandRows ? 1 : 0);
70
+ const headerRow = 0;
71
+ const plotTop = 1, plotRows = Math.max(CARD_ROWS, bandTop - plotTop);
72
+ // As many cards as fit with a row between them (up to a dozen a side), packed tight only when the pane is short.
73
+ const spaced = Math.floor((plotRows + 1) / (CARD_ROWS + 1));
74
+ const limit = Math.max(2, Math.min(MAX_CARDS, spaced >= 3 ? spaced : Math.floor(plotRows / CARD_ROWS)));
75
+ const bands = flowBands([...rows], limit, options.pages ?? {}, options.focusId);
76
+ const longest = Math.max(bands.suppliers.length, bands.customers.length, 1);
77
+ // A tall pane spreads the cards rather than leaving a band of empty rows above and below them.
78
+ const gap = longest < 2 ? 0 : Math.max(spaced >= 3 ? 1 : 0, Math.min(MAX_CARD_GAP, Math.floor((plotRows - longest * CARD_ROWS) / (longest - 1))));
79
+ const cardWidth = Math.max(16, Math.min(40, Math.floor(width * (width < 120 ? 0.28 : 0.24))));
80
+ const centerWidth = Math.max(12, Math.min(26, options.focusLabelWidth + 4));
81
+ const centerHeight = Math.max(3, Math.min(16, Math.floor(plotRows * 0.45)));
82
+ const center = { x: Math.floor((width - centerWidth) / 2), y: plotTop + Math.floor((plotRows - centerHeight) / 2), width: centerWidth, height: centerHeight };
83
+ const nodes: PositionedNode[] = [];
84
+ const ribbons: FlowRibbon[] = [];
85
+ for (const band of ["suppliers", "customers"] as const) {
86
+ const entries = bands[band];
87
+ const stack = entries.length * CARD_ROWS + Math.max(0, entries.length - 1) * gap;
88
+ const top = plotTop + Math.max(0, Math.floor((plotRows - stack) / 2));
89
+ const x = band === "suppliers" ? 1 : width - cardWidth - 1;
90
+ const drawn = entries.filter((node) => node.row);
91
+ entries.forEach((node, index) => {
92
+ const y = top + index * (CARD_ROWS + gap);
93
+ nodes.push({ ...node, x, y, width: cardWidth, height: CARD_ROWS, role: node.row?.role ?? null });
94
+ const order = drawn.indexOf(node);
95
+ if (!node.row || order < 0) return;
96
+ // Ribbons meet the focus card in the order their cards stand, spread over its edge.
97
+ const end = center.y + (center.height * (order + 0.5)) / drawn.length;
98
+ const edge = y + CARD_ROWS / 2;
99
+ ribbons.push(band === "suppliers"
100
+ ? { id: node.id, band, x0: x + cardWidth, y0: edge, x1: center.x, y1: end, thickness: ribbonRows(node.weight), role: node.row.role }
101
+ : { id: node.id, band, x0: center.x + center.width, y0: end, x1: x, y1: edge, thickness: ribbonRows(node.weight), role: node.row.role });
102
+ });
103
+ }
104
+ const related: FlowRelatedRow[] = relatedRoles.map((role, index) => {
105
+ const members = all.related.filter((node) => node.row?.role === role);
106
+ const room = width - RELATED_LABEL_CELLS - 2;
107
+ const fit = (count: number) => members.slice(0, count).reduce((sum, node) => sum + chipWidth(node) + 1, 0);
108
+ let count = members.length;
109
+ while (count > 0 && fit(count) + (count < members.length ? 11 : 0) > room) count--;
110
+ const pageSize = Math.max(1, count);
111
+ const pages = Math.max(1, Math.ceil(members.length / pageSize));
112
+ const start = count < members.length ? ((options.relatedPages?.[role] ?? 0) % pages) * pageSize : 0;
113
+ const shown = members.slice(start, start + pageSize);
114
+ const y = bandTop + 1 + index;
115
+ let x = RELATED_LABEL_CELLS + 1;
116
+ const chips: PositionedNode[] = shown.map((node) => {
117
+ const chip = { ...node, id: node.id, band: "related" as const, x, y, width: chipWidth(node), height: 1, role };
118
+ x += chip.width + 1;
119
+ return chip;
120
+ });
121
+ if (shown.length < members.length) {
122
+ const more: FlowNode = { id: `more:related:${role}`, label: "", row: null, band: "related", more: members.length - shown.length, weight: null, weightScope: null, weightBasis: null };
123
+ chips.push({ ...more, x, y, width: chipWidth(more), height: 1, role });
124
+ }
125
+ return { role, y, chips, total: members.length };
126
+ });
127
+ nodes.push(...related.flatMap((row) => row.chips));
128
+ const basis = (band: "suppliers" | "customers") => bands[band].some((node) => node.weight !== null) ? bands[band].find((node) => node.weightBasis)?.weightBasis ?? null : null;
129
+ return {
130
+ center, nodes, ribbons, related, groups, groupRow: groups.length ? bandTop + 1 + relatedRoles.length : null, headerRow, legendRow, cardWidth,
131
+ scale: { suppliers: basis("suppliers"), customers: basis("customers"), scope: bands.customers.find((node) => node.weightScope)?.weightScope ?? null },
132
+ };
133
+ }