@adea-ai/ui 0.151.12 → 0.151.14

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 (961) hide show
  1. package/dist/NOTICE +3 -2
  2. package/dist/components/composites/about-dialog/about-dialog.d.ts.map +1 -1
  3. package/dist/components/composites/about-dialog/about-dialog.js +27 -48
  4. package/dist/components/composites/about-dialog/about-dialog.js.map +1 -1
  5. package/dist/components/composites/account-menu/account-menu.d.ts +2 -2
  6. package/dist/components/composites/account-menu/account-menu.d.ts.map +1 -1
  7. package/dist/components/composites/account-menu/account-menu.js +4 -22
  8. package/dist/components/composites/account-menu/account-menu.js.map +1 -1
  9. package/dist/components/composites/action-button/action-button.d.ts.map +1 -1
  10. package/dist/components/composites/action-button/action-button.js +2 -4
  11. package/dist/components/composites/action-button/action-button.js.map +1 -1
  12. package/dist/components/composites/appearance-editor/accent-swatch-groups.d.ts +1 -10
  13. package/dist/components/composites/appearance-editor/accent-swatch-groups.d.ts.map +1 -1
  14. package/dist/components/composites/appearance-editor/accent-swatch-groups.js +2 -1
  15. package/dist/components/composites/appearance-editor/accent-swatch-groups.js.map +1 -1
  16. package/dist/components/composites/appearance-editor/appearance-choices.d.ts.map +1 -1
  17. package/dist/components/composites/appearance-editor/appearance-choices.js +3 -2
  18. package/dist/components/composites/appearance-editor/appearance-choices.js.map +1 -1
  19. package/dist/components/composites/appearance-editor/appearance-editor.d.ts.map +1 -1
  20. package/dist/components/composites/appearance-editor/appearance-editor.js +1 -0
  21. package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
  22. package/dist/components/composites/appearance-editor/appearance-rows.d.ts.map +1 -1
  23. package/dist/components/composites/appearance-editor/appearance-rows.js +12 -50
  24. package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
  25. package/dist/components/composites/appearance-editor/font-settings-group.d.ts.map +1 -1
  26. package/dist/components/composites/appearance-editor/font-settings-group.js +7 -47
  27. package/dist/components/composites/appearance-editor/font-settings-group.js.map +1 -1
  28. package/dist/components/composites/appearance-editor/index.d.ts +1 -0
  29. package/dist/components/composites/appearance-editor/index.d.ts.map +1 -1
  30. package/dist/components/composites/appearance-editor/index.js +2 -1
  31. package/dist/components/composites/catalog-browser/catalog-browser.d.ts.map +1 -1
  32. package/dist/components/composites/catalog-browser/catalog-browser.js +8 -11
  33. package/dist/components/composites/catalog-browser/catalog-browser.js.map +1 -1
  34. package/dist/components/composites/chain-of-thought/chain-of-thought.d.ts +5 -4
  35. package/dist/components/composites/chain-of-thought/chain-of-thought.d.ts.map +1 -1
  36. package/dist/components/composites/chain-of-thought/chain-of-thought.js +5 -12
  37. package/dist/components/composites/chain-of-thought/chain-of-thought.js.map +1 -1
  38. package/dist/components/composites/chat/chat.d.ts +2 -2
  39. package/dist/components/composites/chat/chat.d.ts.map +1 -1
  40. package/dist/components/composites/chat/chat.js.map +1 -1
  41. package/dist/components/composites/checkpoint/checkpoint-model.js +1 -1
  42. package/dist/components/composites/checkpoint/checkpoint-model.js.map +1 -1
  43. package/dist/components/composites/checkpoint/checkpoint.js +3 -3
  44. package/dist/components/composites/checkpoint/checkpoint.js.map +1 -1
  45. package/dist/components/composites/confirmation/confirmation-model.d.ts +3 -12
  46. package/dist/components/composites/confirmation/confirmation-model.d.ts.map +1 -1
  47. package/dist/components/composites/confirmation/confirmation-model.js +5 -17
  48. package/dist/components/composites/confirmation/confirmation-model.js.map +1 -1
  49. package/dist/components/composites/confirmation/confirmation.js +1 -1
  50. package/dist/components/composites/confirmation/confirmation.js.map +1 -1
  51. package/dist/components/composites/context/context-model.js +1 -1
  52. package/dist/components/composites/context/context-model.js.map +1 -1
  53. package/dist/components/composites/file-tree/build-file-tree.d.ts +5 -12
  54. package/dist/components/composites/file-tree/build-file-tree.d.ts.map +1 -1
  55. package/dist/components/composites/file-tree/build-file-tree.js +26 -30
  56. package/dist/components/composites/file-tree/build-file-tree.js.map +1 -1
  57. package/dist/components/composites/file-tree/file-tree.d.ts +2 -2
  58. package/dist/components/composites/file-tree/file-tree.d.ts.map +1 -1
  59. package/dist/components/composites/file-tree/file-tree.js +4 -30
  60. package/dist/components/composites/file-tree/file-tree.js.map +1 -1
  61. package/dist/components/composites/file-tree/index.d.ts +2 -1
  62. package/dist/components/composites/file-tree/index.d.ts.map +1 -1
  63. package/dist/components/composites/file-tree/index.js +2 -1
  64. package/dist/components/composites/help-center/help-center.d.ts.map +1 -1
  65. package/dist/components/composites/help-center/help-center.js +9 -20
  66. package/dist/components/composites/help-center/help-center.js.map +1 -1
  67. package/dist/components/composites/icon-picker/icon-picker.d.ts.map +1 -1
  68. package/dist/components/composites/icon-picker/icon-picker.js +7 -11
  69. package/dist/components/composites/icon-picker/icon-picker.js.map +1 -1
  70. package/dist/components/composites/inline-citation/citation.d.ts.map +1 -1
  71. package/dist/components/composites/inline-citation/citation.js +2 -1
  72. package/dist/components/composites/inline-citation/citation.js.map +1 -1
  73. package/dist/components/composites/inline-citation/inline-citation.d.ts.map +1 -1
  74. package/dist/components/composites/inline-citation/inline-citation.js +2 -1
  75. package/dist/components/composites/inline-citation/inline-citation.js.map +1 -1
  76. package/dist/components/composites/message-scroller/message-scroller.d.ts +4 -5
  77. package/dist/components/composites/message-scroller/message-scroller.d.ts.map +1 -1
  78. package/dist/components/composites/message-scroller/message-scroller.js +19 -13
  79. package/dist/components/composites/message-scroller/message-scroller.js.map +1 -1
  80. package/dist/components/composites/message-scroller/scroll-anchor.d.ts +4 -3
  81. package/dist/components/composites/message-scroller/scroll-anchor.d.ts.map +1 -1
  82. package/dist/components/composites/message-scroller/scroll-anchor.js +5 -3
  83. package/dist/components/composites/message-scroller/scroll-anchor.js.map +1 -1
  84. package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -1
  85. package/dist/components/composites/model-selector/model-selector.js +1 -1
  86. package/dist/components/composites/model-selector/model-selector.js.map +1 -1
  87. package/dist/components/composites/model-selector/models.js +1 -1
  88. package/dist/components/composites/model-selector/models.js.map +1 -1
  89. package/dist/components/composites/plan/plan.d.ts.map +1 -1
  90. package/dist/components/composites/plan/plan.js +2 -3
  91. package/dist/components/composites/plan/plan.js.map +1 -1
  92. package/dist/components/composites/queue/queue.d.ts +2 -2
  93. package/dist/components/composites/queue/queue.d.ts.map +1 -1
  94. package/dist/components/composites/queue/queue.js +57 -64
  95. package/dist/components/composites/queue/queue.js.map +1 -1
  96. package/dist/components/composites/reasoning/index.js +3 -1
  97. package/dist/components/composites/reasoning/reasoning.d.ts +2 -3
  98. package/dist/components/composites/reasoning/reasoning.d.ts.map +1 -1
  99. package/dist/components/composites/reasoning/reasoning.js +5 -20
  100. package/dist/components/composites/reasoning/reasoning.js.map +1 -1
  101. package/dist/components/composites/settings/settings-layout.d.ts.map +1 -1
  102. package/dist/components/composites/settings/settings-layout.js +3 -2
  103. package/dist/components/composites/settings/settings-layout.js.map +1 -1
  104. package/dist/components/composites/settings/settings-navigation.d.ts.map +1 -1
  105. package/dist/components/composites/settings/settings-navigation.js +1 -1
  106. package/dist/components/composites/settings/settings-navigation.js.map +1 -1
  107. package/dist/components/composites/sources/index.js +2 -1
  108. package/dist/components/composites/sources/source.d.ts +3 -8
  109. package/dist/components/composites/sources/source.d.ts.map +1 -1
  110. package/dist/components/composites/sources/source.js +5 -30
  111. package/dist/components/composites/sources/source.js.map +1 -1
  112. package/dist/components/composites/sources/sources.js +2 -1
  113. package/dist/components/composites/sources/sources.js.map +1 -1
  114. package/dist/components/composites/stack-trace/stack-trace.d.ts.map +1 -1
  115. package/dist/components/composites/stack-trace/stack-trace.js +3 -12
  116. package/dist/components/composites/stack-trace/stack-trace.js.map +1 -1
  117. package/dist/components/composites/subagent/subagent.d.ts +3 -1
  118. package/dist/components/composites/subagent/subagent.d.ts.map +1 -1
  119. package/dist/components/composites/subagent/subagent.js +5 -17
  120. package/dist/components/composites/subagent/subagent.js.map +1 -1
  121. package/dist/components/composites/suggestion/suggestion.d.ts.map +1 -1
  122. package/dist/components/composites/suggestion/suggestion.js +3 -2
  123. package/dist/components/composites/suggestion/suggestion.js.map +1 -1
  124. package/dist/components/composites/task/task.d.ts +2 -3
  125. package/dist/components/composites/task/task.d.ts.map +1 -1
  126. package/dist/components/composites/task/task.js +49 -109
  127. package/dist/components/composites/task/task.js.map +1 -1
  128. package/dist/components/composites/terminal/terminal-model.d.ts +1 -2
  129. package/dist/components/composites/terminal/terminal-model.d.ts.map +1 -1
  130. package/dist/components/composites/terminal/terminal-model.js +7 -1
  131. package/dist/components/composites/terminal/terminal-model.js.map +1 -1
  132. package/dist/components/composites/terminal/terminal.d.ts.map +1 -1
  133. package/dist/components/composites/terminal/terminal.js +3 -12
  134. package/dist/components/composites/terminal/terminal.js.map +1 -1
  135. package/dist/components/composites/test-results/test-results.d.ts.map +1 -1
  136. package/dist/components/composites/test-results/test-results.js +3 -12
  137. package/dist/components/composites/test-results/test-results.js.map +1 -1
  138. package/dist/components/composites/tool/tool.d.ts +0 -1
  139. package/dist/components/composites/tool/tool.d.ts.map +1 -1
  140. package/dist/components/composites/tool/tool.js +47 -41
  141. package/dist/components/composites/tool/tool.js.map +1 -1
  142. package/dist/components/composites/tree/tree-navigation.d.ts +6 -2
  143. package/dist/components/composites/tree/tree-navigation.d.ts.map +1 -1
  144. package/dist/components/composites/tree/tree-navigation.js +18 -1
  145. package/dist/components/composites/tree/tree-navigation.js.map +1 -1
  146. package/dist/components/composites/tree/tree.d.ts +6 -0
  147. package/dist/components/composites/tree/tree.d.ts.map +1 -1
  148. package/dist/components/composites/tree/tree.js +30 -4
  149. package/dist/components/composites/tree/tree.js.map +1 -1
  150. package/dist/components/composites/update-dialog/channel-control.d.ts.map +1 -1
  151. package/dist/components/composites/update-dialog/channel-control.js +7 -8
  152. package/dist/components/composites/update-dialog/channel-control.js.map +1 -1
  153. package/dist/components/composites/update-dialog/update-dialog.d.ts +2 -26
  154. package/dist/components/composites/update-dialog/update-dialog.d.ts.map +1 -1
  155. package/dist/components/composites/update-dialog/update-dialog.js +47 -125
  156. package/dist/components/composites/update-dialog/update-dialog.js.map +1 -1
  157. package/dist/components/composites/update-dialog/update-model.d.ts +65 -0
  158. package/dist/components/composites/update-dialog/update-model.d.ts.map +1 -0
  159. package/dist/components/composites/update-dialog/update-model.js +75 -0
  160. package/dist/components/composites/update-dialog/update-model.js.map +1 -0
  161. package/dist/components/composites/workspace-mark/workspace-mark.js.map +1 -1
  162. package/dist/components/composites/workspace-switcher/workspace-reorder-dialog.d.ts.map +1 -1
  163. package/dist/components/composites/workspace-switcher/workspace-reorder-dialog.js +3 -16
  164. package/dist/components/composites/workspace-switcher/workspace-reorder-dialog.js.map +1 -1
  165. package/dist/components/composites/workspace-switcher/workspace-switcher.d.ts.map +1 -1
  166. package/dist/components/composites/workspace-switcher/workspace-switcher.js +10 -14
  167. package/dist/components/composites/workspace-switcher/workspace-switcher.js.map +1 -1
  168. package/dist/components/conversation/busy-send-button.d.ts +3 -5
  169. package/dist/components/conversation/busy-send-button.d.ts.map +1 -1
  170. package/dist/components/conversation/busy-send-button.js +4 -15
  171. package/dist/components/conversation/busy-send-button.js.map +1 -1
  172. package/dist/components/conversation/chat-composer.d.ts +1 -1
  173. package/dist/components/conversation/chat-composer.d.ts.map +1 -1
  174. package/dist/components/conversation/chat-composer.js +1 -1
  175. package/dist/components/conversation/chat-composer.js.map +1 -1
  176. package/dist/components/conversation/composer-core.d.ts +35 -0
  177. package/dist/components/conversation/composer-core.d.ts.map +1 -0
  178. package/dist/components/conversation/composer-core.js +68 -0
  179. package/dist/components/conversation/composer-core.js.map +1 -0
  180. package/dist/components/conversation/composer-menu.d.ts +1 -1
  181. package/dist/components/conversation/composer-menu.d.ts.map +1 -1
  182. package/dist/components/conversation/composer-menu.js.map +1 -1
  183. package/dist/components/conversation/conversation-pane.d.ts +4 -1
  184. package/dist/components/conversation/conversation-pane.d.ts.map +1 -1
  185. package/dist/components/conversation/conversation-pane.js +4 -0
  186. package/dist/components/conversation/conversation-pane.js.map +1 -1
  187. package/dist/components/conversation/conversation-surface.d.ts +9 -6
  188. package/dist/components/conversation/conversation-surface.d.ts.map +1 -1
  189. package/dist/components/conversation/conversation-surface.js +7 -5
  190. package/dist/components/conversation/conversation-surface.js.map +1 -1
  191. package/dist/components/conversation/ime-guard.d.ts +1 -0
  192. package/dist/components/conversation/ime-guard.d.ts.map +1 -1
  193. package/dist/components/conversation/ime-guard.js +5 -0
  194. package/dist/components/conversation/ime-guard.js.map +1 -1
  195. package/dist/components/conversation/internal/chat-composer-shell.d.ts.map +1 -1
  196. package/dist/components/conversation/internal/chat-composer-shell.js +16 -50
  197. package/dist/components/conversation/internal/chat-composer-shell.js.map +1 -1
  198. package/dist/components/conversation/message-composer.d.ts +1 -3
  199. package/dist/components/conversation/message-composer.d.ts.map +1 -1
  200. package/dist/components/conversation/message-composer.js +15 -32
  201. package/dist/components/conversation/message-composer.js.map +1 -1
  202. package/dist/components/conversation/message-row.d.ts +10 -11
  203. package/dist/components/conversation/message-row.d.ts.map +1 -1
  204. package/dist/components/conversation/message-row.js +24 -49
  205. package/dist/components/conversation/message-row.js.map +1 -1
  206. package/dist/components/conversation/paste-token-editor.d.ts.map +1 -1
  207. package/dist/components/conversation/paste-token-editor.js +7 -17
  208. package/dist/components/conversation/paste-token-editor.js.map +1 -1
  209. package/dist/components/conversation/paste-tokens.d.ts +10 -1
  210. package/dist/components/conversation/paste-tokens.d.ts.map +1 -1
  211. package/dist/components/conversation/paste-tokens.js +26 -2
  212. package/dist/components/conversation/paste-tokens.js.map +1 -1
  213. package/dist/components/conversation/scroll-follow-core.d.ts +30 -79
  214. package/dist/components/conversation/scroll-follow-core.d.ts.map +1 -1
  215. package/dist/components/conversation/scroll-follow-core.js +65 -54
  216. package/dist/components/conversation/scroll-follow-core.js.map +1 -1
  217. package/dist/components/conversation/scroll-follow.d.ts +5 -1
  218. package/dist/components/conversation/scroll-follow.d.ts.map +1 -1
  219. package/dist/components/conversation/scroll-follow.js +27 -91
  220. package/dist/components/conversation/scroll-follow.js.map +1 -1
  221. package/dist/components/conversation/thread-panel.d.ts +0 -2
  222. package/dist/components/conversation/thread-panel.d.ts.map +1 -1
  223. package/dist/components/conversation/thread-panel.js.map +1 -1
  224. package/dist/components/conversation/transcript-composition.d.ts.map +1 -1
  225. package/dist/components/conversation/transcript-composition.js +4 -16
  226. package/dist/components/conversation/transcript-composition.js.map +1 -1
  227. package/dist/components/conversation/transcript-folding.d.ts +0 -1
  228. package/dist/components/conversation/transcript-folding.d.ts.map +1 -1
  229. package/dist/components/conversation/transcript-folding.js +1 -1
  230. package/dist/components/conversation/transcript-folding.js.map +1 -1
  231. package/dist/components/conversation/transcript-grouping.d.ts +8 -0
  232. package/dist/components/conversation/transcript-grouping.d.ts.map +1 -1
  233. package/dist/components/conversation/transcript-grouping.js +17 -3
  234. package/dist/components/conversation/transcript-grouping.js.map +1 -1
  235. package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts.map +1 -1
  236. package/dist/components/layout/contextual-sidebar/contextual-sidebar.js +2 -1
  237. package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -1
  238. package/dist/components/layout/contextual-sidebar/mobile-contextual-sidebar.js +1 -1
  239. package/dist/components/layout/contextual-sidebar/mobile-contextual-sidebar.js.map +1 -1
  240. package/dist/components/layout/floating-preview/index.js +2 -2
  241. package/dist/components/layout/floating-preview/model.d.ts +21 -55
  242. package/dist/components/layout/floating-preview/model.d.ts.map +1 -1
  243. package/dist/components/layout/floating-preview/model.js +33 -88
  244. package/dist/components/layout/floating-preview/model.js.map +1 -1
  245. package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts.map +1 -1
  246. package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js +11 -5
  247. package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js.map +1 -1
  248. package/dist/components/layout/shell-top-bar/shell-top-bar.d.ts +2 -12
  249. package/dist/components/layout/shell-top-bar/shell-top-bar.d.ts.map +1 -1
  250. package/dist/components/layout/shell-top-bar/shell-top-bar.js +2 -1
  251. package/dist/components/layout/shell-top-bar/shell-top-bar.js.map +1 -1
  252. package/dist/components/layout/side-rail/side-rail-context.d.ts +0 -1
  253. package/dist/components/layout/side-rail/side-rail-context.d.ts.map +1 -1
  254. package/dist/components/layout/side-rail/side-rail-context.js +2 -8
  255. package/dist/components/layout/side-rail/side-rail-context.js.map +1 -1
  256. package/dist/components/layout/side-rail/side-rail.d.ts +0 -9
  257. package/dist/components/layout/side-rail/side-rail.d.ts.map +1 -1
  258. package/dist/components/layout/side-rail/side-rail.js +148 -128
  259. package/dist/components/layout/side-rail/side-rail.js.map +1 -1
  260. package/dist/components/layout/sidebar-nav/index.d.ts +2 -1
  261. package/dist/components/layout/sidebar-nav/index.d.ts.map +1 -1
  262. package/dist/components/layout/sidebar-nav/index.js +2 -1
  263. package/dist/components/layout/sidebar-nav/sidebar-nav-classes.d.ts +10 -0
  264. package/dist/components/layout/sidebar-nav/sidebar-nav-classes.d.ts.map +1 -0
  265. package/dist/components/layout/sidebar-nav/sidebar-nav-classes.js +18 -0
  266. package/dist/components/layout/sidebar-nav/sidebar-nav-classes.js.map +1 -0
  267. package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts +1 -1
  268. package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts.map +1 -1
  269. package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.js.map +1 -1
  270. package/dist/components/layout/sidebar-nav/sidebar-nav.d.ts +5 -9
  271. package/dist/components/layout/sidebar-nav/sidebar-nav.d.ts.map +1 -1
  272. package/dist/components/layout/sidebar-nav/sidebar-nav.js +5 -23
  273. package/dist/components/layout/sidebar-nav/sidebar-nav.js.map +1 -1
  274. package/dist/components/layout/split-layout/geometry.d.ts.map +1 -1
  275. package/dist/components/layout/split-layout/geometry.js +2 -2
  276. package/dist/components/layout/split-layout/geometry.js.map +1 -1
  277. package/dist/components/layout/split-layout/index.js +2 -2
  278. package/dist/components/layout/split-layout/model.d.ts.map +1 -1
  279. package/dist/components/layout/split-layout/model.js +4 -4
  280. package/dist/components/layout/split-layout/model.js.map +1 -1
  281. package/dist/components/layout/split-layout/resize-controller-core-retry.d.ts +5 -0
  282. package/dist/components/layout/split-layout/resize-controller-core-retry.d.ts.map +1 -1
  283. package/dist/components/layout/split-layout/resize-controller-core-retry.js +17 -10
  284. package/dist/components/layout/split-layout/resize-controller-core-retry.js.map +1 -1
  285. package/dist/components/layout/split-layout/resize-controller-core.d.ts +5 -0
  286. package/dist/components/layout/split-layout/resize-controller-core.d.ts.map +1 -1
  287. package/dist/components/layout/split-layout/resize-controller-core.js +17 -10
  288. package/dist/components/layout/split-layout/resize-controller-core.js.map +1 -1
  289. package/dist/components/layout/split-layout/split-layout.d.ts.map +1 -1
  290. package/dist/components/layout/split-layout/split-layout.js +54 -47
  291. package/dist/components/layout/split-layout/split-layout.js.map +1 -1
  292. package/dist/components/layout/split-layout/tree.d.ts +2 -0
  293. package/dist/components/layout/split-layout/tree.d.ts.map +1 -1
  294. package/dist/components/layout/split-layout/tree.js +5 -1
  295. package/dist/components/layout/split-layout/tree.js.map +1 -1
  296. package/dist/components/layout/top-bar/top-bar.d.ts +2 -9
  297. package/dist/components/layout/top-bar/top-bar.d.ts.map +1 -1
  298. package/dist/components/layout/top-bar/top-bar.js +4 -8
  299. package/dist/components/layout/top-bar/top-bar.js.map +1 -1
  300. package/dist/components/layout/top-bar/window-chrome.d.ts +13 -0
  301. package/dist/components/layout/top-bar/window-chrome.d.ts.map +1 -0
  302. package/dist/components/layout/top-bar/window-chrome.js +12 -0
  303. package/dist/components/layout/top-bar/window-chrome.js.map +1 -0
  304. package/dist/components/motion/presence.d.ts +1 -1
  305. package/dist/components/motion/presence.d.ts.map +1 -1
  306. package/dist/components/motion/presence.js +1 -4
  307. package/dist/components/motion/presence.js.map +1 -1
  308. package/dist/components/theme/appearance-panel.d.ts +3 -1
  309. package/dist/components/theme/appearance-panel.d.ts.map +1 -1
  310. package/dist/components/theme/appearance-panel.js +17 -9
  311. package/dist/components/theme/appearance-panel.js.map +1 -1
  312. package/dist/components/theme/index.d.ts +1 -1
  313. package/dist/components/theme/index.d.ts.map +1 -1
  314. package/dist/components/theme/index.js +5 -4
  315. package/dist/components/theme/lazy.d.ts +31 -5
  316. package/dist/components/theme/lazy.d.ts.map +1 -1
  317. package/dist/components/theme/lazy.js +39 -6
  318. package/dist/components/theme/lazy.js.map +1 -0
  319. package/dist/components/theme/script-projection.js +3 -2
  320. package/dist/components/theme/script-projection.js.map +1 -1
  321. package/dist/components/theme/script.js +3 -1
  322. package/dist/components/theme/theme-api.d.ts +14 -0
  323. package/dist/components/theme/theme-api.d.ts.map +1 -0
  324. package/dist/components/theme/theme-catalogue-source.d.ts.map +1 -1
  325. package/dist/components/theme/theme-catalogue-source.js +3 -2
  326. package/dist/components/theme/theme-catalogue-source.js.map +1 -1
  327. package/dist/components/theme/theme-document.d.ts +112 -10
  328. package/dist/components/theme/theme-document.d.ts.map +1 -1
  329. package/dist/components/theme/{theme-document-core.js → theme-document.js} +7 -7
  330. package/dist/components/theme/theme-document.js.map +1 -0
  331. package/dist/components/theme/theme-mode-toggle.d.ts +1 -1
  332. package/dist/components/theme/theme-mode-toggle.d.ts.map +1 -1
  333. package/dist/components/theme/theme-mode-toggle.js.map +1 -1
  334. package/dist/components/theme/theme-persistence.d.ts +6 -5
  335. package/dist/components/theme/theme-persistence.d.ts.map +1 -1
  336. package/dist/components/theme/theme-persistence.js +48 -80
  337. package/dist/components/theme/theme-persistence.js.map +1 -1
  338. package/dist/components/theme/theme-picker.d.ts +1 -1
  339. package/dist/components/theme/theme-picker.d.ts.map +1 -1
  340. package/dist/components/theme/theme-picker.js.map +1 -1
  341. package/dist/components/theme/theme-provider-value.d.ts +14 -15
  342. package/dist/components/theme/theme-provider-value.d.ts.map +1 -1
  343. package/dist/components/theme/theme-provider-value.js +26 -42
  344. package/dist/components/theme/theme-provider-value.js.map +1 -1
  345. package/dist/components/theme/theme-provider.d.ts +3 -9
  346. package/dist/components/theme/theme-provider.d.ts.map +1 -1
  347. package/dist/components/theme/theme-provider.js +8 -7
  348. package/dist/components/theme/theme-provider.js.map +1 -1
  349. package/dist/components/theme/theme-script.d.ts +12 -25
  350. package/dist/components/theme/theme-script.d.ts.map +1 -1
  351. package/dist/components/theme/theme-script.js +35 -38
  352. package/dist/components/theme/theme-script.js.map +1 -1
  353. package/dist/components/theme/theme-state.d.ts +241 -9
  354. package/dist/components/theme/theme-state.d.ts.map +1 -1
  355. package/dist/components/theme/{theme-state-core.js → theme-state.js} +10 -11
  356. package/dist/components/theme/theme-state.js.map +1 -0
  357. package/dist/components/theme/theme-toggle.d.ts +1 -1
  358. package/dist/components/theme/theme-toggle.d.ts.map +1 -1
  359. package/dist/components/theme/theme-toggle.js.map +1 -1
  360. package/dist/components/ui/alert-dialog/alert-dialog.d.ts +7 -5
  361. package/dist/components/ui/alert-dialog/alert-dialog.d.ts.map +1 -1
  362. package/dist/components/ui/alert-dialog/alert-dialog.js +40 -36
  363. package/dist/components/ui/alert-dialog/alert-dialog.js.map +1 -1
  364. package/dist/components/ui/attachment/attachment.d.ts.map +1 -1
  365. package/dist/components/ui/attachment/attachment.js +5 -16
  366. package/dist/components/ui/attachment/attachment.js.map +1 -1
  367. package/dist/components/ui/avatar/avatar.d.ts.map +1 -1
  368. package/dist/components/ui/avatar/avatar.js +5 -2
  369. package/dist/components/ui/avatar/avatar.js.map +1 -1
  370. package/dist/components/ui/board/board.d.ts +0 -3
  371. package/dist/components/ui/board/board.d.ts.map +1 -1
  372. package/dist/components/ui/board/board.js +3 -6
  373. package/dist/components/ui/board/board.js.map +1 -1
  374. package/dist/components/ui/button-group/button-group.d.ts +1 -1
  375. package/dist/components/ui/button-group/button-group.d.ts.map +1 -1
  376. package/dist/components/ui/button-group/button-group.js.map +1 -1
  377. package/dist/components/ui/chart/chart.d.ts +0 -3
  378. package/dist/components/ui/chart/chart.d.ts.map +1 -1
  379. package/dist/components/ui/chart/chart.js.map +1 -1
  380. package/dist/components/ui/code-block/code-block.d.ts +0 -2
  381. package/dist/components/ui/code-block/code-block.d.ts.map +1 -1
  382. package/dist/components/ui/code-block/code-block.js +8 -24
  383. package/dist/components/ui/code-block/code-block.js.map +1 -1
  384. package/dist/components/ui/command/command.d.ts.map +1 -1
  385. package/dist/components/ui/command/command.js +56 -48
  386. package/dist/components/ui/command/command.js.map +1 -1
  387. package/dist/components/ui/context-menu/context-menu.d.ts +8 -30
  388. package/dist/components/ui/context-menu/context-menu.d.ts.map +1 -1
  389. package/dist/components/ui/context-menu/context-menu.js +13 -121
  390. package/dist/components/ui/context-menu/context-menu.js.map +1 -1
  391. package/dist/components/ui/dialog/dialog-layer.d.ts +46 -0
  392. package/dist/components/ui/dialog/dialog-layer.d.ts.map +1 -0
  393. package/dist/components/ui/dialog/dialog-layer.js +169 -0
  394. package/dist/components/ui/dialog/dialog-layer.js.map +1 -0
  395. package/dist/components/ui/dialog/dialog.d.ts +20 -26
  396. package/dist/components/ui/dialog/dialog.d.ts.map +1 -1
  397. package/dist/components/ui/dialog/dialog.js +69 -187
  398. package/dist/components/ui/dialog/dialog.js.map +1 -1
  399. package/dist/components/ui/drawer/drawer.d.ts.map +1 -1
  400. package/dist/components/ui/drawer/drawer.js +5 -8
  401. package/dist/components/ui/drawer/drawer.js.map +1 -1
  402. package/dist/components/ui/dropdown-menu/dropdown-menu.d.ts +39 -53
  403. package/dist/components/ui/dropdown-menu/dropdown-menu.d.ts.map +1 -1
  404. package/dist/components/ui/dropdown-menu/dropdown-menu.js +135 -191
  405. package/dist/components/ui/dropdown-menu/dropdown-menu.js.map +1 -1
  406. package/dist/components/ui/dropdown-menu/menu-parts.d.ts +46 -0
  407. package/dist/components/ui/dropdown-menu/menu-parts.d.ts.map +1 -0
  408. package/dist/components/ui/dropdown-menu/menu-parts.js +176 -0
  409. package/dist/components/ui/dropdown-menu/menu-parts.js.map +1 -0
  410. package/dist/components/ui/field/field.js.map +1 -1
  411. package/dist/components/ui/field/number-field.js.map +1 -1
  412. package/dist/components/ui/hover-card/hover-card.d.ts +1 -2
  413. package/dist/components/ui/hover-card/hover-card.d.ts.map +1 -1
  414. package/dist/components/ui/hover-card/hover-card.js +4 -21
  415. package/dist/components/ui/hover-card/hover-card.js.map +1 -1
  416. package/dist/components/ui/menubar/menubar.d.ts +19 -33
  417. package/dist/components/ui/menubar/menubar.d.ts.map +1 -1
  418. package/dist/components/ui/menubar/menubar.js +21 -116
  419. package/dist/components/ui/menubar/menubar.js.map +1 -1
  420. package/dist/components/ui/message/index.js +2 -1
  421. package/dist/components/ui/message/message.d.ts +0 -1
  422. package/dist/components/ui/message/message.d.ts.map +1 -1
  423. package/dist/components/ui/message/message.js.map +1 -1
  424. package/dist/components/ui/message/parse-message-text.d.ts +20 -2
  425. package/dist/components/ui/message/parse-message-text.d.ts.map +1 -1
  426. package/dist/components/ui/message/parse-message-text.js +94 -28
  427. package/dist/components/ui/message/parse-message-text.js.map +1 -1
  428. package/dist/components/ui/modal-dialog/modal-dialog.d.ts +5 -12
  429. package/dist/components/ui/modal-dialog/modal-dialog.d.ts.map +1 -1
  430. package/dist/components/ui/modal-dialog/modal-dialog.js +61 -77
  431. package/dist/components/ui/modal-dialog/modal-dialog.js.map +1 -1
  432. package/dist/components/ui/navigation-menu/navigation-menu.d.ts +0 -1
  433. package/dist/components/ui/navigation-menu/navigation-menu.d.ts.map +1 -1
  434. package/dist/components/ui/navigation-menu/navigation-menu.js.map +1 -1
  435. package/dist/components/ui/popover/popover.d.ts +1 -3
  436. package/dist/components/ui/popover/popover.d.ts.map +1 -1
  437. package/dist/components/ui/popover/popover.js +1 -22
  438. package/dist/components/ui/popover/popover.js.map +1 -1
  439. package/dist/components/ui/resizable/resizable.d.ts.map +1 -1
  440. package/dist/components/ui/resizable/resizable.js +12 -6
  441. package/dist/components/ui/resizable/resizable.js.map +1 -1
  442. package/dist/components/ui/sheet/sheet.d.ts +4 -6
  443. package/dist/components/ui/sheet/sheet.d.ts.map +1 -1
  444. package/dist/components/ui/sheet/sheet.js +31 -32
  445. package/dist/components/ui/sheet/sheet.js.map +1 -1
  446. package/dist/components/ui/text-link/index.d.ts.map +1 -1
  447. package/dist/components/ui/toggle-group/toggle-group.d.ts +1 -1
  448. package/dist/components/ui/toggle-group/toggle-group.d.ts.map +1 -1
  449. package/dist/components/ui/toggle-group/toggle-group.js +2 -7
  450. package/dist/components/ui/toggle-group/toggle-group.js.map +1 -1
  451. package/dist/components/ui/tooltip/tooltip.d.ts +17 -1
  452. package/dist/components/ui/tooltip/tooltip.d.ts.map +1 -1
  453. package/dist/components/ui/tooltip/tooltip.js +40 -20
  454. package/dist/components/ui/tooltip/tooltip.js.map +1 -1
  455. package/dist/components/ui/trace/index.d.ts +1 -1
  456. package/dist/components/ui/trace/index.d.ts.map +1 -1
  457. package/dist/components/ui/trace/index.js +1 -1
  458. package/dist/components/ui/trace/trace.d.ts +44 -3
  459. package/dist/components/ui/trace/trace.d.ts.map +1 -1
  460. package/dist/components/ui/trace/trace.js +87 -15
  461. package/dist/components/ui/trace/trace.js.map +1 -1
  462. package/dist/index.js +34 -28
  463. package/dist/lib/accent-presets.d.ts +7 -4
  464. package/dist/lib/accent-presets.d.ts.map +1 -1
  465. package/dist/lib/accent-presets.js +10 -5
  466. package/dist/lib/accent-presets.js.map +1 -1
  467. package/dist/lib/accent-roles.d.ts +20 -1
  468. package/dist/lib/accent-roles.d.ts.map +1 -1
  469. package/dist/lib/accent-roles.js +34 -26
  470. package/dist/lib/accent-roles.js.map +1 -1
  471. package/dist/lib/appearance-font-settings.d.ts.map +1 -1
  472. package/dist/lib/appearance-font-settings.js +4 -4
  473. package/dist/lib/appearance-font-settings.js.map +1 -1
  474. package/dist/lib/async-action.d.ts +42 -0
  475. package/dist/lib/async-action.d.ts.map +1 -0
  476. package/dist/lib/async-action.js +61 -0
  477. package/dist/lib/async-action.js.map +1 -0
  478. package/dist/lib/breakpoints.d.ts +8 -0
  479. package/dist/lib/breakpoints.d.ts.map +1 -0
  480. package/dist/lib/breakpoints.js +11 -0
  481. package/dist/lib/breakpoints.js.map +1 -0
  482. package/dist/lib/bytes.d.ts +8 -0
  483. package/dist/lib/bytes.d.ts.map +1 -0
  484. package/dist/lib/bytes.js +20 -0
  485. package/dist/lib/bytes.js.map +1 -0
  486. package/dist/lib/clipboard.d.ts +13 -0
  487. package/dist/lib/clipboard.d.ts.map +1 -1
  488. package/dist/lib/clipboard.js +32 -1
  489. package/dist/lib/clipboard.js.map +1 -1
  490. package/dist/lib/events.d.ts +14 -0
  491. package/dist/lib/events.d.ts.map +1 -0
  492. package/dist/lib/events.js +16 -0
  493. package/dist/lib/events.js.map +1 -0
  494. package/dist/lib/external-link.d.ts +19 -0
  495. package/dist/lib/external-link.d.ts.map +1 -0
  496. package/dist/lib/external-link.js +27 -0
  497. package/dist/lib/external-link.js.map +1 -0
  498. package/dist/lib/font-catalog.d.ts +3 -6
  499. package/dist/lib/font-catalog.d.ts.map +1 -1
  500. package/dist/lib/font-catalog.js +16 -12
  501. package/dist/lib/font-catalog.js.map +1 -1
  502. package/dist/lib/font-zoom.d.ts +4 -4
  503. package/dist/lib/font-zoom.d.ts.map +1 -1
  504. package/dist/lib/font-zoom.js +9 -12
  505. package/dist/lib/font-zoom.js.map +1 -1
  506. package/dist/lib/overlay.d.ts +29 -1
  507. package/dist/lib/overlay.d.ts.map +1 -1
  508. package/dist/lib/overlay.js +32 -16
  509. package/dist/lib/overlay.js.map +1 -1
  510. package/dist/lib/preference-store.d.ts +13 -3
  511. package/dist/lib/preference-store.d.ts.map +1 -1
  512. package/dist/lib/preference-store.js +27 -37
  513. package/dist/lib/preference-store.js.map +1 -1
  514. package/dist/lib/resize-separator.d.ts +15 -0
  515. package/dist/lib/resize-separator.d.ts.map +1 -0
  516. package/dist/lib/resize-separator.js +23 -0
  517. package/dist/lib/resize-separator.js.map +1 -0
  518. package/dist/lib/safe-script.d.ts +19 -1
  519. package/dist/lib/safe-script.d.ts.map +1 -1
  520. package/dist/lib/safe-script.js +19 -1
  521. package/dist/lib/safe-script.js.map +1 -1
  522. package/dist/lib/scroll-geometry.d.ts +33 -0
  523. package/dist/lib/scroll-geometry.d.ts.map +1 -0
  524. package/dist/lib/scroll-geometry.js +48 -0
  525. package/dist/lib/scroll-geometry.js.map +1 -0
  526. package/dist/lib/text.d.ts +13 -0
  527. package/dist/lib/text.d.ts.map +1 -0
  528. package/dist/lib/text.js +30 -0
  529. package/dist/lib/text.js.map +1 -0
  530. package/dist/lib/theme-accents.d.ts +2 -0
  531. package/dist/lib/theme-accents.d.ts.map +1 -1
  532. package/dist/lib/theme-accents.js +2 -2
  533. package/dist/lib/theme-accents.js.map +1 -1
  534. package/dist/lib/theme-catalogue.d.ts.map +1 -1
  535. package/dist/lib/theme-catalogue.js +3 -4
  536. package/dist/lib/theme-catalogue.js.map +1 -1
  537. package/dist/lib/theme-css.d.ts +14 -1
  538. package/dist/lib/theme-css.d.ts.map +1 -1
  539. package/dist/lib/theme-css.js +25 -48
  540. package/dist/lib/theme-css.js.map +1 -1
  541. package/dist/lib/theme-defaults.d.ts +33 -5
  542. package/dist/lib/theme-defaults.d.ts.map +1 -1
  543. package/dist/lib/theme-defaults.generated.d.ts +1 -1
  544. package/dist/lib/theme-defaults.generated.d.ts.map +1 -1
  545. package/dist/lib/theme-defaults.generated.js.map +1 -1
  546. package/dist/lib/theme-defaults.js +59 -3
  547. package/dist/lib/theme-defaults.js.map +1 -1
  548. package/dist/lib/theme-engine-light.d.ts +6 -0
  549. package/dist/lib/theme-engine-light.d.ts.map +1 -1
  550. package/dist/lib/theme-engine-light.js +71 -57
  551. package/dist/lib/theme-engine-light.js.map +1 -1
  552. package/dist/lib/theme-engine.d.ts +20 -22
  553. package/dist/lib/theme-engine.d.ts.map +1 -1
  554. package/dist/lib/theme-engine.js +19 -6
  555. package/dist/lib/theme-engine.js.map +1 -1
  556. package/dist/lib/theme-records.d.ts +3 -3
  557. package/dist/lib/theme-records.d.ts.map +1 -1
  558. package/dist/lib/theme-records.js +20 -59
  559. package/dist/lib/theme-records.js.map +1 -1
  560. package/dist/lib/theme-types.d.ts +174 -0
  561. package/dist/lib/theme-types.d.ts.map +1 -0
  562. package/dist/lib/theme-types.js +105 -0
  563. package/dist/lib/theme-types.js.map +1 -0
  564. package/dist/lib/themes.d.ts +4 -159
  565. package/dist/lib/themes.d.ts.map +1 -1
  566. package/dist/lib/themes.js +14 -33
  567. package/dist/lib/themes.js.map +1 -1
  568. package/dist/lib/tokens.d.ts.map +1 -1
  569. package/dist/lib/tokens.js +0 -1
  570. package/dist/lib/tokens.js.map +1 -1
  571. package/dist/lib/url.d.ts +9 -0
  572. package/dist/lib/url.d.ts.map +1 -0
  573. package/dist/lib/url.js +24 -0
  574. package/dist/lib/url.js.map +1 -0
  575. package/dist/lib/version-notes.d.ts.map +1 -1
  576. package/dist/lib/version-notes.js +3 -10
  577. package/dist/lib/version-notes.js.map +1 -1
  578. package/dist/r/about-dialog.json +2 -1
  579. package/dist/r/action-button.json +2 -1
  580. package/dist/r/alert-dialog.json +1 -0
  581. package/dist/r/checkpoint.json +0 -2
  582. package/dist/r/code-block.json +1 -0
  583. package/dist/r/confirmation.json +0 -1
  584. package/dist/r/context-menu.json +2 -2
  585. package/dist/r/context.json +0 -1
  586. package/dist/r/conversation.json +6 -5
  587. package/dist/r/dialog.json +5 -0
  588. package/dist/r/drawer.json +0 -1
  589. package/dist/r/dropdown-menu.json +5 -0
  590. package/dist/r/lib.json +50 -0
  591. package/dist/r/menubar.json +2 -2
  592. package/dist/r/model-selector.json +0 -1
  593. package/dist/r/reasoning.json +2 -1
  594. package/dist/r/registry.json +102 -43
  595. package/dist/r/shell-top-bar.json +1 -0
  596. package/dist/r/sidebar-nav.json +5 -0
  597. package/dist/r/sources.json +2 -2
  598. package/dist/r/src/components/composites/about-dialog/about-dialog.tsx +22 -42
  599. package/dist/r/src/components/composites/account-menu/account-menu.tsx +9 -35
  600. package/dist/r/src/components/composites/action-button/action-button.tsx +5 -7
  601. package/dist/r/src/components/composites/appearance-editor/accent-swatch-groups.tsx +3 -11
  602. package/dist/r/src/components/composites/appearance-editor/appearance-choices.tsx +8 -5
  603. package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +8 -6
  604. package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +14 -74
  605. package/dist/r/src/components/composites/appearance-editor/font-settings-group.tsx +11 -77
  606. package/dist/r/src/components/composites/appearance-editor/index.ts +1 -0
  607. package/dist/r/src/components/composites/catalog-browser/catalog-browser.tsx +9 -13
  608. package/dist/r/src/components/composites/chain-of-thought/chain-of-thought.tsx +16 -18
  609. package/dist/r/src/components/composites/chat/chat.tsx +2 -2
  610. package/dist/r/src/components/composites/checkpoint/checkpoint-model.ts +3 -3
  611. package/dist/r/src/components/composites/checkpoint/checkpoint.tsx +3 -3
  612. package/dist/r/src/components/composites/confirmation/confirmation-model.ts +9 -17
  613. package/dist/r/src/components/composites/confirmation/confirmation.tsx +2 -2
  614. package/dist/r/src/components/composites/context/context-model.ts +1 -1
  615. package/dist/r/src/components/composites/file-tree/build-file-tree.ts +21 -39
  616. package/dist/r/src/components/composites/file-tree/file-tree.tsx +5 -58
  617. package/dist/r/src/components/composites/file-tree/index.ts +1 -1
  618. package/dist/r/src/components/composites/help-center/help-center.tsx +8 -21
  619. package/dist/r/src/components/composites/icon-picker/icon-picker.tsx +10 -11
  620. package/dist/r/src/components/composites/inline-citation/citation.ts +2 -1
  621. package/dist/r/src/components/composites/inline-citation/inline-citation.tsx +3 -2
  622. package/dist/r/src/components/composites/message-scroller/message-scroller.tsx +30 -30
  623. package/dist/r/src/components/composites/message-scroller/scroll-anchor.ts +5 -5
  624. package/dist/r/src/components/composites/model-selector/model-selector.tsx +3 -2
  625. package/dist/r/src/components/composites/model-selector/models.ts +1 -1
  626. package/dist/r/src/components/composites/plan/plan.tsx +1 -4
  627. package/dist/r/src/components/composites/queue/queue.tsx +8 -11
  628. package/dist/r/src/components/composites/reasoning/reasoning.tsx +5 -23
  629. package/dist/r/src/components/composites/settings/settings-layout.tsx +3 -2
  630. package/dist/r/src/components/composites/settings/settings-navigation.tsx +4 -1
  631. package/dist/r/src/components/composites/sources/source.ts +7 -53
  632. package/dist/r/src/components/composites/stack-trace/stack-trace.tsx +3 -12
  633. package/dist/r/src/components/composites/subagent/subagent.tsx +7 -17
  634. package/dist/r/src/components/composites/suggestion/suggestion.tsx +4 -3
  635. package/dist/r/src/components/composites/task/task.tsx +21 -64
  636. package/dist/r/src/components/composites/terminal/terminal-model.ts +4 -4
  637. package/dist/r/src/components/composites/terminal/terminal.tsx +3 -12
  638. package/dist/r/src/components/composites/test-results/test-results.tsx +3 -12
  639. package/dist/r/src/components/composites/tool/tool.tsx +34 -40
  640. package/dist/r/src/components/composites/tree/tree-navigation.ts +22 -2
  641. package/dist/r/src/components/composites/tree/tree.tsx +47 -3
  642. package/dist/r/src/components/composites/update-dialog/channel-control.tsx +10 -14
  643. package/dist/r/src/components/composites/update-dialog/update-dialog.tsx +66 -200
  644. package/dist/r/src/components/composites/update-dialog/update-model.ts +137 -0
  645. package/dist/r/src/components/composites/workspace-mark/workspace-mark.tsx +1 -1
  646. package/dist/r/src/components/composites/workspace-switcher/workspace-reorder-dialog.tsx +1 -18
  647. package/dist/r/src/components/composites/workspace-switcher/workspace-switcher.tsx +16 -19
  648. package/dist/r/src/components/conversation/busy-send-button.tsx +7 -34
  649. package/dist/r/src/components/conversation/chat-composer.tsx +1 -1
  650. package/dist/r/src/components/conversation/composer-core.ts +76 -0
  651. package/dist/r/src/components/conversation/composer-menu.tsx +1 -1
  652. package/dist/r/src/components/conversation/conversation-pane.tsx +4 -1
  653. package/dist/r/src/components/conversation/conversation-surface.tsx +23 -10
  654. package/dist/r/src/components/conversation/ime-guard.ts +6 -0
  655. package/dist/r/src/components/conversation/internal/chat-composer-shell.tsx +24 -65
  656. package/dist/r/src/components/conversation/message-composer.tsx +24 -54
  657. package/dist/r/src/components/conversation/message-row.tsx +33 -47
  658. package/dist/r/src/components/conversation/paste-token-editor.tsx +13 -16
  659. package/dist/r/src/components/conversation/paste-tokens.ts +36 -1
  660. package/dist/r/src/components/conversation/scroll-follow-core.ts +66 -137
  661. package/dist/r/src/components/conversation/scroll-follow.ts +26 -67
  662. package/dist/r/src/components/conversation/thread-panel.tsx +2 -4
  663. package/dist/r/src/components/conversation/transcript-composition.tsx +9 -33
  664. package/dist/r/src/components/conversation/transcript-folding.ts +2 -2
  665. package/dist/r/src/components/conversation/transcript-grouping.ts +18 -3
  666. package/dist/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +4 -3
  667. package/dist/r/src/components/layout/contextual-sidebar/mobile-contextual-sidebar.tsx +1 -1
  668. package/dist/r/src/components/layout/floating-preview/model.ts +57 -195
  669. package/dist/r/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +6 -12
  670. package/dist/r/src/components/layout/shell-top-bar/shell-top-bar.tsx +32 -47
  671. package/dist/r/src/components/layout/side-rail/side-rail-context.ts +1 -11
  672. package/dist/r/src/components/layout/side-rail/side-rail.tsx +95 -107
  673. package/dist/r/src/components/layout/sidebar-nav/index.ts +1 -2
  674. package/dist/r/src/components/layout/sidebar-nav/sidebar-nav-classes.ts +15 -0
  675. package/dist/r/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +1 -4
  676. package/dist/r/src/components/layout/sidebar-nav/sidebar-nav.tsx +9 -27
  677. package/dist/r/src/components/layout/split-layout/geometry.ts +2 -9
  678. package/dist/r/src/components/layout/split-layout/model.ts +3 -6
  679. package/dist/r/src/components/layout/split-layout/resize-controller-core-retry.tsx +12 -6
  680. package/dist/r/src/components/layout/split-layout/resize-controller-core.tsx +12 -6
  681. package/dist/r/src/components/layout/split-layout/split-layout.tsx +46 -61
  682. package/dist/r/src/components/layout/split-layout/tree.ts +5 -0
  683. package/dist/r/src/components/layout/top-bar/top-bar.tsx +16 -38
  684. package/dist/r/src/components/layout/top-bar/window-chrome.ts +23 -0
  685. package/dist/r/src/components/motion/presence.tsx +1 -3
  686. package/dist/r/src/components/theme/appearance-panel.tsx +28 -19
  687. package/dist/r/src/components/theme/index.ts +1 -22
  688. package/dist/r/src/components/theme/lazy.ts +36 -26
  689. package/dist/r/src/components/theme/theme-api.ts +30 -0
  690. package/dist/r/src/components/theme/theme-catalogue-source.ts +3 -2
  691. package/dist/r/src/components/theme/theme-document.ts +248 -23
  692. package/dist/r/src/components/theme/theme-mode-toggle.tsx +1 -1
  693. package/dist/r/src/components/theme/theme-persistence.ts +74 -130
  694. package/dist/r/src/components/theme/theme-picker.tsx +2 -2
  695. package/dist/r/src/components/theme/theme-provider-value.ts +53 -68
  696. package/dist/r/src/components/theme/theme-provider.tsx +5 -24
  697. package/dist/r/src/components/theme/theme-script.ts +48 -43
  698. package/dist/r/src/components/theme/theme-state.ts +350 -10
  699. package/dist/r/src/components/theme/theme-toggle.tsx +1 -1
  700. package/dist/r/src/components/ui/alert-dialog/alert-dialog.tsx +43 -43
  701. package/dist/r/src/components/ui/attachment/attachment.tsx +4 -17
  702. package/dist/r/src/components/ui/avatar/avatar.tsx +3 -2
  703. package/dist/r/src/components/ui/board/board.tsx +4 -10
  704. package/dist/r/src/components/ui/button-group/button-group.tsx +1 -1
  705. package/dist/r/src/components/ui/chart/chart.tsx +0 -3
  706. package/dist/r/src/components/ui/code-block/code-block.tsx +7 -26
  707. package/dist/r/src/components/ui/command/command.tsx +43 -39
  708. package/dist/r/src/components/ui/context-menu/context-menu.tsx +18 -168
  709. package/dist/r/src/components/ui/dialog/dialog-layer.tsx +266 -0
  710. package/dist/r/src/components/ui/dialog/dialog.tsx +77 -271
  711. package/dist/r/src/components/ui/drawer/drawer.tsx +5 -23
  712. package/dist/r/src/components/ui/dropdown-menu/dropdown-menu.tsx +204 -226
  713. package/dist/r/src/components/ui/dropdown-menu/menu-parts.tsx +220 -0
  714. package/dist/r/src/components/ui/field/field.tsx +1 -1
  715. package/dist/r/src/components/ui/field/number-field.tsx +1 -1
  716. package/dist/r/src/components/ui/hover-card/hover-card.tsx +4 -11
  717. package/dist/r/src/components/ui/menubar/menubar.tsx +36 -169
  718. package/dist/r/src/components/ui/message/message.tsx +0 -1
  719. package/dist/r/src/components/ui/message/parse-message-text.ts +80 -32
  720. package/dist/r/src/components/ui/modal-dialog/modal-dialog.tsx +9 -39
  721. package/dist/r/src/components/ui/navigation-menu/navigation-menu.tsx +0 -1
  722. package/dist/r/src/components/ui/popover/popover.tsx +5 -11
  723. package/dist/r/src/components/ui/resizable/resizable.tsx +6 -16
  724. package/dist/r/src/components/ui/sheet/sheet.tsx +30 -42
  725. package/dist/r/src/components/ui/text-link/index.ts +0 -1
  726. package/dist/r/src/components/ui/toggle-group/toggle-group.tsx +3 -11
  727. package/dist/r/src/components/ui/tooltip/tooltip.tsx +47 -26
  728. package/dist/r/src/components/ui/trace/index.ts +7 -0
  729. package/dist/r/src/components/ui/trace/trace.tsx +100 -9
  730. package/dist/r/src/lib/accent-presets.ts +12 -8
  731. package/dist/r/src/lib/accent-roles.ts +43 -29
  732. package/dist/r/src/lib/appearance-font-settings.ts +5 -5
  733. package/dist/r/src/lib/async-action.ts +72 -0
  734. package/dist/r/src/lib/breakpoints.ts +7 -0
  735. package/dist/r/src/lib/bytes.ts +20 -0
  736. package/dist/r/src/lib/clipboard.ts +43 -0
  737. package/dist/r/src/lib/events.ts +17 -0
  738. package/dist/r/src/lib/external-link.ts +42 -0
  739. package/dist/r/src/lib/font-catalog.ts +4 -6
  740. package/dist/r/src/lib/font-zoom.ts +9 -14
  741. package/dist/r/src/lib/overlay.ts +55 -18
  742. package/dist/r/src/lib/preference-store.ts +36 -34
  743. package/dist/r/src/lib/resize-separator.ts +36 -0
  744. package/dist/r/src/lib/safe-script.ts +19 -1
  745. package/dist/r/src/lib/scroll-geometry.ts +69 -0
  746. package/dist/r/src/lib/text.ts +49 -0
  747. package/dist/r/src/lib/theme-accents.ts +1 -1
  748. package/dist/r/src/lib/theme-catalogue.ts +3 -4
  749. package/dist/r/src/lib/theme-css.ts +33 -54
  750. package/dist/r/src/lib/theme-defaults.generated.ts +1 -1
  751. package/dist/r/src/lib/theme-defaults.ts +55 -7
  752. package/dist/r/src/lib/theme-engine-light.ts +88 -72
  753. package/dist/r/src/lib/theme-engine.ts +29 -33
  754. package/dist/r/src/lib/theme-records.ts +33 -69
  755. package/dist/r/src/lib/theme-types.ts +199 -0
  756. package/dist/r/src/lib/themes.ts +33 -196
  757. package/dist/r/src/lib/tokens.ts +0 -1
  758. package/dist/r/src/lib/url.ts +25 -0
  759. package/dist/r/src/lib/version-notes.ts +3 -9
  760. package/dist/r/src/styles/theme-variants.css +32 -32
  761. package/dist/r/src/styles/theme.css +17 -13
  762. package/dist/r/subagent.json +0 -2
  763. package/dist/r/suggestion.json +0 -1
  764. package/dist/r/theming.json +5 -20
  765. package/dist/r/top-bar.json +5 -0
  766. package/dist/r/trace.json +1 -0
  767. package/dist/r/update-dialog.json +5 -0
  768. package/package.json +9 -7
  769. package/registry.json +102 -43
  770. package/src/components/composites/about-dialog/about-dialog.tsx +22 -42
  771. package/src/components/composites/account-menu/account-menu.tsx +9 -35
  772. package/src/components/composites/action-button/action-button.tsx +5 -7
  773. package/src/components/composites/appearance-editor/accent-swatch-groups.tsx +3 -11
  774. package/src/components/composites/appearance-editor/appearance-choices.tsx +8 -5
  775. package/src/components/composites/appearance-editor/appearance-editor.tsx +8 -6
  776. package/src/components/composites/appearance-editor/appearance-rows.tsx +14 -74
  777. package/src/components/composites/appearance-editor/font-settings-group.tsx +11 -77
  778. package/src/components/composites/appearance-editor/index.ts +1 -0
  779. package/src/components/composites/catalog-browser/catalog-browser.tsx +9 -13
  780. package/src/components/composites/chain-of-thought/chain-of-thought.tsx +16 -18
  781. package/src/components/composites/chat/chat.tsx +2 -2
  782. package/src/components/composites/checkpoint/checkpoint-model.ts +3 -3
  783. package/src/components/composites/checkpoint/checkpoint.tsx +3 -3
  784. package/src/components/composites/confirmation/confirmation-model.ts +9 -17
  785. package/src/components/composites/confirmation/confirmation.tsx +2 -2
  786. package/src/components/composites/context/context-model.ts +1 -1
  787. package/src/components/composites/file-tree/build-file-tree.ts +21 -39
  788. package/src/components/composites/file-tree/file-tree.tsx +5 -58
  789. package/src/components/composites/file-tree/index.ts +1 -1
  790. package/src/components/composites/help-center/help-center.tsx +8 -21
  791. package/src/components/composites/icon-picker/icon-picker.tsx +10 -11
  792. package/src/components/composites/inline-citation/citation.ts +2 -1
  793. package/src/components/composites/inline-citation/inline-citation.tsx +3 -2
  794. package/src/components/composites/message-scroller/message-scroller.tsx +30 -30
  795. package/src/components/composites/message-scroller/scroll-anchor.ts +5 -5
  796. package/src/components/composites/model-selector/model-selector.tsx +3 -2
  797. package/src/components/composites/model-selector/models.ts +1 -1
  798. package/src/components/composites/plan/plan.tsx +1 -4
  799. package/src/components/composites/queue/queue.tsx +8 -11
  800. package/src/components/composites/reasoning/reasoning.tsx +5 -23
  801. package/src/components/composites/settings/settings-layout.tsx +3 -2
  802. package/src/components/composites/settings/settings-navigation.tsx +4 -1
  803. package/src/components/composites/sources/source.ts +7 -53
  804. package/src/components/composites/stack-trace/stack-trace.tsx +3 -12
  805. package/src/components/composites/subagent/subagent.tsx +7 -17
  806. package/src/components/composites/suggestion/suggestion.tsx +4 -3
  807. package/src/components/composites/task/task.tsx +21 -64
  808. package/src/components/composites/terminal/terminal-model.ts +4 -4
  809. package/src/components/composites/terminal/terminal.tsx +3 -12
  810. package/src/components/composites/test-results/test-results.tsx +3 -12
  811. package/src/components/composites/tool/tool.tsx +34 -40
  812. package/src/components/composites/tree/tree-navigation.ts +22 -2
  813. package/src/components/composites/tree/tree.tsx +47 -3
  814. package/src/components/composites/update-dialog/channel-control.tsx +10 -14
  815. package/src/components/composites/update-dialog/update-dialog.tsx +66 -200
  816. package/src/components/composites/update-dialog/update-model.ts +137 -0
  817. package/src/components/composites/workspace-mark/workspace-mark.tsx +1 -1
  818. package/src/components/composites/workspace-switcher/workspace-reorder-dialog.tsx +1 -18
  819. package/src/components/composites/workspace-switcher/workspace-switcher.tsx +16 -19
  820. package/src/components/conversation/busy-send-button.tsx +7 -34
  821. package/src/components/conversation/chat-composer.tsx +1 -1
  822. package/src/components/conversation/composer-core.ts +76 -0
  823. package/src/components/conversation/composer-menu.tsx +1 -1
  824. package/src/components/conversation/conversation-pane.tsx +4 -1
  825. package/src/components/conversation/conversation-surface.tsx +23 -10
  826. package/src/components/conversation/ime-guard.ts +6 -0
  827. package/src/components/conversation/internal/chat-composer-shell.tsx +24 -65
  828. package/src/components/conversation/message-composer.tsx +24 -54
  829. package/src/components/conversation/message-row.tsx +33 -47
  830. package/src/components/conversation/paste-token-editor.tsx +13 -16
  831. package/src/components/conversation/paste-tokens.ts +36 -1
  832. package/src/components/conversation/scroll-follow-core.ts +66 -137
  833. package/src/components/conversation/scroll-follow.ts +26 -67
  834. package/src/components/conversation/thread-panel.tsx +2 -4
  835. package/src/components/conversation/transcript-composition.tsx +9 -33
  836. package/src/components/conversation/transcript-folding.ts +2 -2
  837. package/src/components/conversation/transcript-grouping.ts +18 -3
  838. package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +4 -3
  839. package/src/components/layout/contextual-sidebar/mobile-contextual-sidebar.tsx +1 -1
  840. package/src/components/layout/floating-preview/model.ts +57 -195
  841. package/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +6 -12
  842. package/src/components/layout/shell-top-bar/shell-top-bar.tsx +32 -47
  843. package/src/components/layout/side-rail/side-rail-context.ts +1 -11
  844. package/src/components/layout/side-rail/side-rail.tsx +95 -107
  845. package/src/components/layout/sidebar-nav/index.ts +1 -2
  846. package/src/components/layout/sidebar-nav/sidebar-nav-classes.ts +15 -0
  847. package/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +1 -4
  848. package/src/components/layout/sidebar-nav/sidebar-nav.tsx +9 -27
  849. package/src/components/layout/split-layout/geometry.ts +2 -9
  850. package/src/components/layout/split-layout/model.ts +3 -6
  851. package/src/components/layout/split-layout/resize-controller-core-retry.tsx +12 -6
  852. package/src/components/layout/split-layout/resize-controller-core.tsx +12 -6
  853. package/src/components/layout/split-layout/split-layout.tsx +46 -61
  854. package/src/components/layout/split-layout/tree.ts +5 -0
  855. package/src/components/layout/top-bar/top-bar.tsx +16 -38
  856. package/src/components/layout/top-bar/window-chrome.ts +23 -0
  857. package/src/components/motion/presence.tsx +1 -3
  858. package/src/components/theme/appearance-panel.tsx +28 -19
  859. package/src/components/theme/index.ts +1 -22
  860. package/src/components/theme/lazy.ts +36 -26
  861. package/src/components/theme/theme-api.ts +30 -0
  862. package/src/components/theme/theme-catalogue-source.ts +3 -2
  863. package/src/components/theme/theme-document.ts +248 -23
  864. package/src/components/theme/theme-mode-toggle.tsx +1 -1
  865. package/src/components/theme/theme-persistence.ts +74 -130
  866. package/src/components/theme/theme-picker.tsx +2 -2
  867. package/src/components/theme/theme-provider-value.ts +53 -68
  868. package/src/components/theme/theme-provider.tsx +5 -24
  869. package/src/components/theme/theme-script.ts +48 -43
  870. package/src/components/theme/theme-state.ts +350 -10
  871. package/src/components/theme/theme-toggle.tsx +1 -1
  872. package/src/components/ui/alert-dialog/alert-dialog.tsx +43 -43
  873. package/src/components/ui/attachment/attachment.tsx +4 -17
  874. package/src/components/ui/avatar/avatar.tsx +3 -2
  875. package/src/components/ui/board/board.tsx +4 -10
  876. package/src/components/ui/button-group/button-group.tsx +1 -1
  877. package/src/components/ui/chart/chart.tsx +0 -3
  878. package/src/components/ui/code-block/code-block.tsx +7 -26
  879. package/src/components/ui/command/command.tsx +43 -39
  880. package/src/components/ui/context-menu/context-menu.tsx +18 -168
  881. package/src/components/ui/dialog/dialog-layer.tsx +266 -0
  882. package/src/components/ui/dialog/dialog.tsx +77 -271
  883. package/src/components/ui/drawer/drawer.tsx +5 -23
  884. package/src/components/ui/dropdown-menu/dropdown-menu.tsx +204 -226
  885. package/src/components/ui/dropdown-menu/menu-parts.tsx +220 -0
  886. package/src/components/ui/field/field.tsx +1 -1
  887. package/src/components/ui/field/number-field.tsx +1 -1
  888. package/src/components/ui/hover-card/hover-card.tsx +4 -11
  889. package/src/components/ui/menubar/menubar.tsx +36 -169
  890. package/src/components/ui/message/message.tsx +0 -1
  891. package/src/components/ui/message/parse-message-text.ts +80 -32
  892. package/src/components/ui/modal-dialog/modal-dialog.tsx +9 -39
  893. package/src/components/ui/navigation-menu/navigation-menu.tsx +0 -1
  894. package/src/components/ui/popover/popover.tsx +5 -11
  895. package/src/components/ui/resizable/resizable.tsx +6 -16
  896. package/src/components/ui/sheet/sheet.tsx +30 -42
  897. package/src/components/ui/text-link/index.ts +0 -1
  898. package/src/components/ui/toggle-group/toggle-group.tsx +3 -11
  899. package/src/components/ui/tooltip/tooltip.tsx +47 -26
  900. package/src/components/ui/trace/index.ts +7 -0
  901. package/src/components/ui/trace/trace.tsx +100 -9
  902. package/src/lib/accent-presets.ts +12 -8
  903. package/src/lib/accent-roles.ts +43 -29
  904. package/src/lib/appearance-font-settings.ts +5 -5
  905. package/src/lib/async-action.ts +72 -0
  906. package/src/lib/breakpoints.ts +7 -0
  907. package/src/lib/bytes.ts +20 -0
  908. package/src/lib/clipboard.ts +43 -0
  909. package/src/lib/events.ts +17 -0
  910. package/src/lib/external-link.ts +42 -0
  911. package/src/lib/font-catalog.ts +4 -6
  912. package/src/lib/font-zoom.ts +9 -14
  913. package/src/lib/overlay.ts +55 -18
  914. package/src/lib/preference-store.ts +36 -34
  915. package/src/lib/resize-separator.ts +36 -0
  916. package/src/lib/safe-script.ts +19 -1
  917. package/src/lib/scroll-geometry.ts +69 -0
  918. package/src/lib/text.ts +49 -0
  919. package/src/lib/theme-accents.ts +1 -1
  920. package/src/lib/theme-catalogue.ts +3 -4
  921. package/src/lib/theme-css.ts +33 -54
  922. package/src/lib/theme-defaults.generated.ts +1 -1
  923. package/src/lib/theme-defaults.ts +55 -7
  924. package/src/lib/theme-engine-light.ts +88 -72
  925. package/src/lib/theme-engine.ts +29 -33
  926. package/src/lib/theme-records.ts +33 -69
  927. package/src/lib/theme-types.ts +199 -0
  928. package/src/lib/themes.ts +33 -196
  929. package/src/lib/tokens.ts +0 -1
  930. package/src/lib/url.ts +25 -0
  931. package/src/lib/version-notes.ts +3 -9
  932. package/src/styles/theme-variants.css +32 -32
  933. package/src/styles/theme.css +17 -13
  934. package/dist/components/conversation/paste-preview.d.ts +0 -11
  935. package/dist/components/conversation/paste-preview.d.ts.map +0 -1
  936. package/dist/components/conversation/paste-preview.js +0 -27
  937. package/dist/components/conversation/paste-preview.js.map +0 -1
  938. package/dist/components/theme/theme-document-core.d.ts +0 -124
  939. package/dist/components/theme/theme-document-core.d.ts.map +0 -1
  940. package/dist/components/theme/theme-document-core.js.map +0 -1
  941. package/dist/components/theme/theme-provider-core.d.ts +0 -19
  942. package/dist/components/theme/theme-provider-core.d.ts.map +0 -1
  943. package/dist/components/theme/theme-provider-core.js +0 -27
  944. package/dist/components/theme/theme-provider-core.js.map +0 -1
  945. package/dist/components/theme/theme-provider-lazy.d.ts +0 -28
  946. package/dist/components/theme/theme-provider-lazy.d.ts.map +0 -1
  947. package/dist/components/theme/theme-provider-lazy.js +0 -35
  948. package/dist/components/theme/theme-provider-lazy.js.map +0 -1
  949. package/dist/components/theme/theme-state-core.d.ts +0 -254
  950. package/dist/components/theme/theme-state-core.d.ts.map +0 -1
  951. package/dist/components/theme/theme-state-core.js.map +0 -1
  952. package/dist/r/src/components/conversation/paste-preview.ts +0 -35
  953. package/dist/r/src/components/theme/theme-document-core.ts +0 -275
  954. package/dist/r/src/components/theme/theme-provider-core.tsx +0 -40
  955. package/dist/r/src/components/theme/theme-provider-lazy.tsx +0 -34
  956. package/dist/r/src/components/theme/theme-state-core.ts +0 -370
  957. package/src/components/conversation/paste-preview.ts +0 -35
  958. package/src/components/theme/theme-document-core.ts +0 -275
  959. package/src/components/theme/theme-provider-core.tsx +0 -40
  960. package/src/components/theme/theme-provider-lazy.tsx +0 -34
  961. package/src/components/theme/theme-state-core.ts +0 -370
@@ -1 +1 @@
1
- {"version":3,"file":"icon-picker.js","names":["RadioGroup","Radio","ChevronDown","ImageUp","Trash2","JSX","For","Show","createSignal","createUniqueId","splitProps","Dynamic","cn","Button","Popover","PopoverContent","PopoverTrigger","MarkImageError","markImageFromFile","markImageProblemCopy","MARK_IMAGE_MAX_SOURCE_BYTES","resolveShellIcon","shellIconEntries","shellIconLabel","IconPickerProps","label","value","onValueChange","key","defaultKey","image","onImageChange","disabled","class","IconPicker","props","inputId","problem","setProblem","busy","setBusy","fileInput","setFileInput","HTMLInputElement","upload","file","File","undefined","error","_el$","_tmpl$3","_$insert","_$createComponent","when","children","_el$2","_tmpl$","_el$3","firstChild","_el$4","nextSibling","_el$5","fallback","src","_el$0","_tmpl$4","_$effect","_$setAttribute","addEventListener","event","input","currentTarget","files","_$use","type","variant","size","onClick","click","_$memo","_p$","_v$","_v$2","e","t","message","_el$1","_tmpl$5","_el$6","_tmpl$2","_el$7","_el$9","_el$8","aria-label","onChange","each","entry","Icon","Item","ItemInput","ItemLabel","title","_el$10","_tmpl$6","_$className","IconPickerDropdownProps","trigger","Element","IconPickerDropdown","open","setOpen","local","picker","Current","onOpenChange","placement","as","_el$11","_tmpl$7","component","_el$12","_tmpl$8","_$mergeProps","_$createComponent","_$setAttribute","_$memo","Radio","_$className","_$mergeProps"],"sources":["../../../../src/components/composites/icon-picker/icon-picker.tsx"],"sourcesContent":["import { RadioGroup as Radio } from '@kobalte/core/radio-group'\nimport { ChevronDown, ImageUp, Trash2 } from 'lucide-solid'\nimport type { JSX } from 'solid-js'\nimport { For, Show, createSignal, createUniqueId, splitProps } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'\nimport {\n MarkImageError,\n markImageFromFile,\n markImageProblemCopy,\n MARK_IMAGE_MAX_SOURCE_BYTES,\n} from './image-data-url'\nimport { resolveShellIcon, shellIconEntries, shellIconLabel } from './shell-icons'\n\n/**\n * IconPicker.\n *\n * The control behind \"choose an icon\" for a workspace or a project: a grid of\n * curated glyphs, and optionally an uploaded picture in their place.\n *\n * It is a single-choice group. The glyph grid is a Kobalte radio group, so\n * arrow keys move the choice and Tab enters and leaves the grid as one stop,\n * which is the contract a 56-cell grid needs to stay usable from a keyboard. An\n * uploaded image is a separate state, not a 57th cell: while `image` is set no\n * glyph is checked, and choosing a glyph asks the caller to drop the image, so\n * the stored mark is never both.\n *\n * The picker does not persist anything. The caller owns `value` and `image`\n * and saves them with the rest of its form; the image arrives already resized\n * to the stored square (see `markImageFromFile`).\n */\nexport type IconPickerProps = {\n /** The group's accessible name, e.g. \"Workspace icon\". */\n label: string\n /** The checked icon key; ignored while `image` is set. */\n value: string | undefined\n onValueChange(key: string): void\n /** The key the surface treats as unset, labelled \"default\" in the grid. */\n defaultKey?: string\n /** An uploaded mark (a data URL) currently chosen in place of a glyph. */\n image?: string\n /**\n * Called with the resized upload, or `undefined` for Remove. Omit it for a\n * surface that offers glyphs only; the upload row then does not render.\n */\n onImageChange?(image: string | undefined): void\n disabled?: boolean\n class?: string\n}\n\nexport function IconPicker(props: IconPickerProps) {\n const inputId = createUniqueId()\n const [problem, setProblem] = createSignal<string>()\n const [busy, setBusy] = createSignal(false)\n const [fileInput, setFileInput] = createSignal<HTMLInputElement>()\n\n const upload = async (file: File | undefined) => {\n if (!file || !props.onImageChange) return\n setProblem(undefined)\n setBusy(true)\n try {\n props.onImageChange(await markImageFromFile(file))\n } catch (error) {\n setProblem(\n markImageProblemCopy[error instanceof MarkImageError ? error.problem : 'unreadable']\n )\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <div data-slot=\"icon-picker\" class={cn('flex flex-col gap-3', props.class)}>\n <Show when={props.onImageChange}>\n <div class=\"flex items-center gap-3\" data-slot=\"icon-picker-upload\">\n <span\n aria-hidden=\"true\"\n class=\"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-muted\"\n >\n <Show\n when={props.image}\n fallback={<ImageUp class=\"size-5 text-muted-foreground\" aria-hidden=\"true\" />}\n >\n {(src) => <img src={src()} alt=\"\" class=\"size-full object-cover\" />}\n </Show>\n </span>\n <div class=\"flex flex-wrap items-center gap-2\">\n <input\n ref={setFileInput}\n id={inputId}\n type=\"file\"\n class=\"sr-only\"\n tabIndex={-1}\n // The visible button drives this input; hide the duplicate from assistive\n // technology but keep a name so the form-label rule is satisfied.\n aria-hidden=\"true\"\n aria-label={props.image ? 'Replace image' : 'Upload image'}\n accept=\"image/png,image/jpeg,image/webp,image/gif\"\n disabled={props.disabled}\n onChange={(event) => {\n const input = event.currentTarget\n void upload(input.files?.[0])\n // Clearing the value lets the same file be chosen again after Remove.\n input.value = ''\n }}\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={props.disabled || busy()}\n onClick={() => fileInput()?.click()}\n >\n <ImageUp aria-hidden=\"true\" />\n {props.image ? 'Replace image' : 'Upload image'}\n </Button>\n <Show when={props.image}>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n disabled={props.disabled || busy()}\n onClick={() => {\n setProblem(undefined)\n props.onImageChange?.(undefined)\n }}\n >\n <Trash2 aria-hidden=\"true\" />\n Remove image\n </Button>\n </Show>\n </div>\n </div>\n <Show when={problem()}>\n {(message) => (\n <p role=\"alert\" class=\"text-sm text-destructive\">\n {message()}\n </p>\n )}\n </Show>\n <p class=\"text-xs text-muted-foreground\">\n PNG, JPEG, WebP or GIF up to {MARK_IMAGE_MAX_SOURCE_BYTES / 1024 / 1024} MB. It is cropped\n to a square.\n </p>\n </Show>\n <Radio\n aria-label={props.label}\n value={props.image ? '' : (props.value ?? '')}\n disabled={props.disabled}\n onChange={(key) => {\n if (key) props.onValueChange(key)\n }}\n class=\"grid grid-cols-[repeat(auto-fill,minmax(2.5rem,1fr))] gap-1.5\"\n >\n <For each={shellIconEntries}>\n {(entry) => {\n const Icon = resolveShellIcon(entry.key)\n return (\n <Radio.Item value={entry.key} class=\"contents\">\n <Radio.ItemInput class=\"peer\" />\n <Radio.ItemLabel\n title={entry.key === props.defaultKey ? `${entry.label} (default)` : entry.label}\n class={cn(\n 'flex size-10 cursor-pointer items-center justify-center rounded-lg border border-border bg-card text-muted-foreground',\n 'transition-colors ease-out',\n 'hover:bg-surface-hover hover:text-foreground',\n 'peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-primary-subtle',\n 'data-[checked]:border-primary data-[checked]:bg-primary-subtle data-[checked]:text-primary',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50'\n )}\n >\n <Icon class=\"size-5\" aria-hidden=\"true\" />\n <span class=\"sr-only\">\n {entry.label}\n {entry.key === props.defaultKey ? ' (default)' : ''}\n </span>\n </Radio.ItemLabel>\n </Radio.Item>\n )\n }}\n </For>\n </Radio>\n </div>\n )\n}\n\n/**\n * IconPickerDropdown.\n *\n * The compact form of the picker for a settings row: one button showing the\n * current mark, opening the full grid (and the upload row, when the host offers\n * it) in a popover. Choosing a glyph applies it and closes the popover; an\n * upload or Remove leaves it open so the result is visible. The host owns the\n * value exactly as it does for `IconPicker`.\n */\nexport type IconPickerDropdownProps = IconPickerProps & {\n /** The mark shown on the trigger; defaults to the checked glyph or the uploaded image. */\n trigger?: JSX.Element\n}\n\nexport function IconPickerDropdown(props: IconPickerDropdownProps) {\n const [open, setOpen] = createSignal(false)\n const [local, picker] = splitProps(props, ['trigger', 'class'])\n const Current = () => resolveShellIcon(props.value ?? props.defaultKey ?? '')\n return (\n <Popover open={open()} onOpenChange={setOpen} placement=\"bottom-start\">\n <PopoverTrigger\n as={Button}\n type=\"button\"\n variant=\"outline\"\n data-slot=\"icon-picker-trigger\"\n aria-label={`${props.label}: ${props.image ? 'uploaded image' : shellIconLabel(props.value ?? props.defaultKey ?? '')}`}\n disabled={props.disabled}\n class={cn('gap-2', local.class)}\n >\n <span aria-hidden=\"true\" class=\"flex size-5 items-center justify-center overflow-hidden\">\n <Show\n when={local.trigger}\n fallback={\n <Show\n when={props.image}\n fallback={<Dynamic component={Current()} class=\"size-4\" aria-hidden=\"true\" />}\n >\n {(src) => <img src={src()} alt=\"\" class=\"size-full rounded-sm object-cover\" />}\n </Show>\n }\n >\n {local.trigger}\n </Show>\n </span>\n <ChevronDown class=\"size-4 text-muted-foreground\" aria-hidden=\"true\" />\n </PopoverTrigger>\n <PopoverContent class=\"w-[min(22rem,var(--kb-popper-available-width))]\">\n <IconPicker\n {...picker}\n onValueChange={(key) => {\n picker.onValueChange(key)\n setOpen(false)\n }}\n />\n </PopoverContent>\n </Popover>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoDA,SAAgBkC,WAAWC,OAAwB;CACjD,MAAMC,UAAU3B,eAAe;CAC/B,MAAM,CAAC4B,SAASC,cAAc9B,aAAqB;CACnD,MAAM,CAAC+B,MAAMC,WAAWhC,aAAa,KAAK;CAC1C,MAAM,CAACiC,WAAWC,gBAAgBlC,aAA+B;CAEjE,MAAMoC,SAAS,OAAOC,SAA2B;EAC/C,IAAI,CAACA,QAAQ,CAACV,MAAMJ,eAAe;EACnCO,WAAWS,KAAAA,CAAS;EACpBP,QAAQ,IAAI;EACZ,IAAI;GACFL,MAAMJ,cAAc,MAAMb,kBAAkB2B,IAAI,CAAC;EACnD,SAASG,OAAO;GACdV,WACEnB,qBAAqB6B,iBAAiB/B,iBAAiB+B,MAAMX,UAAU,aACzE;EACF,UAAU;GACRG,QAAQ,KAAK;EACf;CACF;CAEA,cAAA;EAAA,IAAAS,OAAAC,QAAA;EAAAC,OAAAF,MAAAG,gBAEK7C,MAAI;GAAA,IAAC8C,OAAI;IAAA,OAAElB,MAAMJ;GAAa;GAAA,IAAAuB,WAAA;IAAA,OAAA;YAAA;MAAA,IAAAC,QAAAC,OAAA,GAAAC,QAAAF,MAAAG,YAAAC,QAAAF,MAAAG,aAAAC,QAAAF,MAAAD;MAAAP,OAAAM,OAAAL,gBAMxB7C,MAAI;OAAA,IACH8C,OAAI;QAAA,OAAElB,MAAML;OAAK;OAAA,IACjBgC,WAAQ;QAAA,OAAAV,gBAAGjD,SAAO;SAAA,SAAA;SAAA,eA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AA,CAAA;AAKX"}
1
+ {"version":3,"file":"icon-picker.js","names":["RadioGroup","Radio","ChevronDown","ImageUp","Trash2","JSX","For","Show","createSignal","createUniqueId","splitProps","Dynamic","createLatestAction","cn","Button","Popover","PopoverContent","PopoverTrigger","MarkImageError","markImageFromFile","markImageProblemCopy","MARK_IMAGE_MAX_SOURCE_BYTES","resolveShellIcon","shellIconEntries","shellIconLabel","IconPickerProps","label","value","onValueChange","key","defaultKey","image","onImageChange","disabled","class","IconPicker","props","inputId","problem","setProblem","uploads","fileInput","setFileInput","HTMLInputElement","upload","file","File","undefined","outcome","run","status","error","_el$","_tmpl$3","_$insert","_$createComponent","when","children","_el$2","_tmpl$","_el$3","firstChild","_el$4","nextSibling","_el$5","fallback","src","_el$0","_tmpl$4","_$effect","_$setAttribute","addEventListener","event","input","currentTarget","files","_$use","type","variant","size","pending","onClick","click","_$memo","_p$","_v$","_v$2","e","t","message","_el$1","_tmpl$5","_el$6","_tmpl$2","_el$7","_el$9","_el$8","aria-label","onChange","each","entry","Icon","Item","ItemInput","ItemLabel","title","_el$10","_tmpl$6","_$className","IconPickerDropdownProps","trigger","Element","IconPickerDropdown","open","setOpen","local","picker","Current","onOpenChange","placement","as","_el$11","_tmpl$7","component","_el$12","_tmpl$8","_$mergeProps","_$createComponent","_$setAttribute","_$memo","Radio","_$className","_$mergeProps"],"sources":["../../../../src/components/composites/icon-picker/icon-picker.tsx"],"sourcesContent":["import { RadioGroup as Radio } from '@kobalte/core/radio-group'\nimport { ChevronDown, ImageUp, Trash2 } from 'lucide-solid'\nimport type { JSX } from 'solid-js'\nimport { For, Show, createSignal, createUniqueId, splitProps } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { createLatestAction } from '#lib/async-action'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'\nimport {\n MarkImageError,\n markImageFromFile,\n markImageProblemCopy,\n MARK_IMAGE_MAX_SOURCE_BYTES,\n} from './image-data-url'\nimport { resolveShellIcon, shellIconEntries, shellIconLabel } from './shell-icons'\n\n/**\n * IconPicker.\n *\n * The control behind \"choose an icon\" for a workspace or a project: a grid of\n * curated glyphs, and optionally an uploaded picture in their place.\n *\n * It is a single-choice group. The glyph grid is a Kobalte radio group, so\n * arrow keys move the choice and Tab enters and leaves the grid as one stop,\n * which is the contract a 56-cell grid needs to stay usable from a keyboard. An\n * uploaded image is a separate state, not a 57th cell: while `image` is set no\n * glyph is checked, and choosing a glyph asks the caller to drop the image, so\n * the stored mark is never both.\n *\n * The picker does not persist anything. The caller owns `value` and `image`\n * and saves them with the rest of its form; the image arrives already resized\n * to the stored square (see `markImageFromFile`).\n */\nexport type IconPickerProps = {\n /** The group's accessible name, e.g. \"Workspace icon\". */\n label: string\n /** The checked icon key; ignored while `image` is set. */\n value: string | undefined\n onValueChange(key: string): void\n /** The key the surface treats as unset, labelled \"default\" in the grid. */\n defaultKey?: string\n /** An uploaded mark (a data URL) currently chosen in place of a glyph. */\n image?: string\n /**\n * Called with the resized upload, or `undefined` for Remove. Omit it for a\n * surface that offers glyphs only; the upload row then does not render.\n */\n onImageChange?(image: string | undefined): void\n disabled?: boolean\n class?: string\n}\n\nexport function IconPicker(props: IconPickerProps) {\n const inputId = createUniqueId()\n const [problem, setProblem] = createSignal<string>()\n const uploads = createLatestAction()\n const [fileInput, setFileInput] = createSignal<HTMLInputElement>()\n\n const upload = async (file: File | undefined) => {\n if (!file || !props.onImageChange) return\n setProblem(undefined)\n const outcome = await uploads.run(() => markImageFromFile(file))\n if (outcome.status === 'done') props.onImageChange?.(outcome.value)\n else if (outcome.status === 'failed')\n setProblem(\n markImageProblemCopy[\n outcome.error instanceof MarkImageError ? outcome.error.problem : 'unreadable'\n ]\n )\n }\n\n return (\n <div data-slot=\"icon-picker\" class={cn('flex flex-col gap-3', props.class)}>\n <Show when={props.onImageChange}>\n <div class=\"flex items-center gap-3\" data-slot=\"icon-picker-upload\">\n <span\n aria-hidden=\"true\"\n class=\"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-muted\"\n >\n <Show\n when={props.image}\n fallback={<ImageUp class=\"size-5 text-muted-foreground\" aria-hidden=\"true\" />}\n >\n {(src) => <img src={src()} alt=\"\" class=\"size-full object-cover\" />}\n </Show>\n </span>\n <div class=\"flex flex-wrap items-center gap-2\">\n <input\n ref={setFileInput}\n id={inputId}\n type=\"file\"\n class=\"sr-only\"\n tabIndex={-1}\n // The visible button drives this input; hide the duplicate from assistive\n // technology but keep a name so the form-label rule is satisfied.\n aria-hidden=\"true\"\n aria-label={props.image ? 'Replace image' : 'Upload image'}\n accept=\"image/png,image/jpeg,image/webp,image/gif\"\n disabled={props.disabled}\n onChange={(event) => {\n const input = event.currentTarget\n void upload(input.files?.[0])\n // Clearing the value lets the same file be chosen again after Remove.\n input.value = ''\n }}\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={props.disabled || uploads.pending()}\n onClick={() => fileInput()?.click()}\n >\n <ImageUp aria-hidden=\"true\" />\n {props.image ? 'Replace image' : 'Upload image'}\n </Button>\n <Show when={props.image}>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n disabled={props.disabled || uploads.pending()}\n onClick={() => {\n setProblem(undefined)\n props.onImageChange?.(undefined)\n }}\n >\n <Trash2 aria-hidden=\"true\" />\n Remove image\n </Button>\n </Show>\n </div>\n </div>\n <Show when={problem()}>\n {(message) => (\n <p role=\"alert\" class=\"text-sm text-destructive\">\n {message()}\n </p>\n )}\n </Show>\n <p class=\"text-xs text-muted-foreground\">\n PNG, JPEG, WebP or GIF up to {MARK_IMAGE_MAX_SOURCE_BYTES / 1024 / 1024} MB. It is cropped\n to a square.\n </p>\n </Show>\n <Radio\n aria-label={props.label}\n value={props.image ? '' : (props.value ?? '')}\n disabled={props.disabled}\n onChange={(key) => {\n if (key) props.onValueChange(key)\n }}\n class=\"grid grid-cols-[repeat(auto-fill,minmax(2.5rem,1fr))] gap-1.5\"\n >\n <For each={shellIconEntries}>\n {(entry) => {\n const Icon = resolveShellIcon(entry.key)\n return (\n <Radio.Item value={entry.key} class=\"contents\">\n <Radio.ItemInput class=\"peer\" />\n <Radio.ItemLabel\n title={entry.key === props.defaultKey ? `${entry.label} (default)` : entry.label}\n class={cn(\n 'flex size-10 cursor-pointer items-center justify-center rounded-lg border border-border bg-card text-muted-foreground',\n 'transition-colors ease-out',\n 'hover:bg-surface-hover hover:text-foreground',\n 'peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-primary-subtle',\n 'data-[checked]:border-primary data-[checked]:bg-primary-subtle data-[checked]:text-primary',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50'\n )}\n >\n <Icon class=\"size-5\" aria-hidden=\"true\" />\n <span class=\"sr-only\">\n {entry.label}\n {entry.key === props.defaultKey ? ' (default)' : ''}\n </span>\n </Radio.ItemLabel>\n </Radio.Item>\n )\n }}\n </For>\n </Radio>\n </div>\n )\n}\n\n/**\n * IconPickerDropdown.\n *\n * The compact form of the picker for a settings row: one button showing the\n * current mark, opening the full grid (and the upload row, when the host offers\n * it) in a popover. Choosing a glyph applies it and closes the popover; an\n * upload or Remove leaves it open so the result is visible. The host owns the\n * value exactly as it does for `IconPicker`.\n */\nexport type IconPickerDropdownProps = IconPickerProps & {\n /** The mark shown on the trigger; defaults to the checked glyph or the uploaded image. */\n trigger?: JSX.Element\n}\n\nexport function IconPickerDropdown(props: IconPickerDropdownProps) {\n const [open, setOpen] = createSignal(false)\n const [local, picker] = splitProps(props, ['trigger', 'class'])\n const Current = () => resolveShellIcon(props.value ?? props.defaultKey ?? '')\n return (\n <Popover open={open()} onOpenChange={setOpen} placement=\"bottom-start\">\n <PopoverTrigger\n as={Button}\n type=\"button\"\n variant=\"outline\"\n data-slot=\"icon-picker-trigger\"\n aria-label={`${props.label}: ${props.image ? 'uploaded image' : shellIconLabel(props.value ?? props.defaultKey ?? '')}`}\n disabled={props.disabled}\n class={cn('gap-2', local.class)}\n >\n <span aria-hidden=\"true\" class=\"flex size-5 items-center justify-center overflow-hidden\">\n <Show\n when={local.trigger}\n fallback={\n <Show\n when={props.image}\n fallback={<Dynamic component={Current()} class=\"size-4\" aria-hidden=\"true\" />}\n >\n {(src) => <img src={src()} alt=\"\" class=\"size-full rounded-sm object-cover\" />}\n </Show>\n }\n >\n {local.trigger}\n </Show>\n </span>\n <ChevronDown class=\"size-4 text-muted-foreground\" aria-hidden=\"true\" />\n </PopoverTrigger>\n <PopoverContent class=\"w-[min(22rem,var(--kb-popper-available-width))]\">\n <IconPicker\n {...picker}\n onValueChange={(key) => {\n picker.onValueChange(key)\n setOpen(false)\n }}\n />\n </PopoverContent>\n </Popover>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqDA,SAAgBmC,WAAWC,OAAwB;CACjD,MAAMC,UAAU5B,eAAe;CAC/B,MAAM,CAAC6B,SAASC,cAAc/B,aAAqB;CACnD,MAAMgC,UAAU5B,mBAAmB;CACnC,MAAM,CAAC6B,WAAWC,gBAAgBlC,aAA+B;CAEjE,MAAMoC,SAAS,OAAOC,SAA2B;EAC/C,IAAI,CAACA,QAAQ,CAACT,MAAMJ,eAAe;EACnCO,WAAWQ,KAAAA,CAAS;EACpB,MAAMC,UAAU,MAAMR,QAAQS,UAAU9B,kBAAkB0B,IAAI,CAAC;EAC/D,IAAIG,QAAQE,WAAW,QAAQd,MAAMJ,gBAAgBgB,QAAQrB,KAAK;OAC7D,IAAIqB,QAAQE,WAAW,UAC1BX,WACEnB,qBACE4B,QAAQG,iBAAiBjC,iBAAiB8B,QAAQG,MAAMb,UAAU,aAEtE;CACJ;CAEA,cAAA;EAAA,IAAAc,OAAAC,QAAA;EAAAC,OAAAF,MAAAG,gBAEKhD,MAAI;GAAA,IAACiD,OAAI;IAAA,OAAEpB,MAAMJ;GAAa;GAAA,IAAAyB,WAAA;IAAA,OAAA;YAAA;MAAA,IAAAC,QAAAC,OAAA,GAAAC,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AA,GAAAqD,gBAEbvC,gBAAc;IAAA,SAAA;IAAA,IAAAyC,WAAA;KAAA,OAAAF,gBACZpB,YAAU2F,WACLV,QAAM,EACVxF,gBAAgBC,QAAQ;MACtBuF,OAAOxF,cAAcC,GAAG;MACxBqF,QAAQ,KAAK;KACf,EAAC,CAAA,CAAA;IAAA;GAAA,CAAA,CAAA;EAAA;CAAA,CAAA;AAKX"}
@@ -1 +1 @@
1
- {"version":3,"file":"citation.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/inline-citation/citation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAKnF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAQ3F;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAa1F;AAED,yFAAyF;AACzF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAA;AACvD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;AAEtF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,GAAG,YAAY,CAavF"}
1
+ {"version":3,"file":"citation.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/inline-citation/citation.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAKxE;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAQ3F;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAa1F;AAED,yFAAyF;AACzF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAA;AACvD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;AAEtF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,GAAG,YAAY,CAavF"}
@@ -1,4 +1,5 @@
1
- import { boundText, sourceHost, sourceTitle } from "../sources/source.js";
1
+ import { boundText } from "../../../lib/text.js";
2
+ import { sourceHost, sourceTitle } from "../sources/source.js";
2
3
  // src/components/composites/inline-citation/citation.ts
3
4
  /** Characters of a host or title that fit in a badge before it is clipped. */
4
5
  var LABEL_LIMIT = 24;
@@ -1 +1 @@
1
- {"version":3,"file":"citation.js","names":[],"sources":["../../../../src/components/composites/inline-citation/citation.ts"],"sourcesContent":["import { boundText, sourceHost, sourceTitle, type Source } from '../sources/source'\n\n/** Characters of a host or title that fit in a badge before it is clipped. */\nconst LABEL_LIMIT = 24\n\n/**\n * The text on a citation badge.\n *\n * A 1-based `index` wins, because a number is what the sentence's own markers\n * and the Sources list use. Without one the badge shows the source's host (read\n * from the parsed URL, so it cannot be spoofed by a title), then a clipped title,\n * and only then a neutral word — never an invented number.\n */\nexport function citationLabel(index: number | undefined, source: Source | undefined): string {\n if (index !== undefined && Number.isInteger(index) && index >= 1 && index <= 9999) {\n return String(index)\n }\n if (source === undefined) return 'source'\n const host = sourceHost(source.url)\n if (host !== undefined) return boundText(host, LABEL_LIMIT)\n return boundText(source.title, LABEL_LIMIT) || 'source'\n}\n\n/**\n * The badge's accessible name. The visible label is a number or a host, which\n * says nothing on its own, so the name carries the title and host: a screen-reader\n * or voice-control user learns what is cited without opening the popover.\n */\nexport function citationName(sources: readonly Source[], index: number | undefined): string {\n const first = sources[0]\n if (first === undefined) return 'Citation'\n const label = citationLabel(index, first)\n if (sources.length > 1) {\n // Keep the visible badge text in the accessible name for label-content-name-mismatch checks.\n return `${label}+${sources.length - 1} — Sources ${label} and ${sources.length - 1} more`\n }\n const host = sourceHost(first.url)\n const title = sourceTitle(first)\n return host !== undefined && host !== title\n ? `Source ${label}: ${title}, ${host}`\n : `Source ${label}: ${title}`\n}\n\n/** Wrap a position into 0..count-1, so Previous on the first source goes to the last. */\nexport function wrapIndex(position: number, count: number): number {\n if (count <= 0) return 0\n return ((position % count) + count) % count\n}\n\n/**\n * How a citation's popover is open.\n *\n * - `peek` is a hover or keyboard-focus preview: it does not take focus, and it\n * goes away when the pointer or focus does.\n * - `pinned` is a deliberate open (click, tap, Enter, Space): focus moves into\n * the popover so its link and Previous/Next are reachable, and it stays until\n * Escape, an outside press, or the badge is pressed again.\n *\n * A popover that only opened on hover would exclude keyboard and touch readers;\n * one that only opened on press would make pointer users click to glance at a\n * source. This is the smallest model that serves both, and it is a pure function\n * so the awkward transitions (hover then click must pin, not toggle shut) are\n * tested rather than argued about.\n */\nexport type CitationMode = 'closed' | 'peek' | 'pinned'\nexport type CitationEvent = 'enter' | 'leave' | 'focus' | 'blur' | 'press' | 'dismiss'\n\nexport function nextCitationMode(mode: CitationMode, event: CitationEvent): CitationMode {\n switch (event) {\n case 'press':\n return mode === 'pinned' ? 'closed' : 'pinned'\n case 'dismiss':\n return 'closed'\n case 'enter':\n case 'focus':\n return mode === 'closed' ? 'peek' : mode\n case 'leave':\n case 'blur':\n return mode === 'peek' ? 'closed' : mode\n }\n}\n"],"mappings":";;;AAGA,IAAM,cAAc;;;;;;;;;AAUpB,SAAgB,cAAc,OAA2B,QAAoC;CAC3F,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,KAAK,KAAK,SAAS,KAAK,SAAS,MAC3E,OAAO,OAAO,KAAK;CAErB,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,OAAO,WAAW,OAAO,GAAG;CAClC,IAAI,SAAS,KAAA,GAAW,OAAO,UAAU,MAAM,WAAW;CAC1D,OAAO,UAAU,OAAO,OAAO,WAAW,KAAK;AACjD;;;;;;AAOA,SAAgB,aAAa,SAA4B,OAAmC;CAC1F,MAAM,QAAQ,QAAQ;CACtB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,QAAQ,cAAc,OAAO,KAAK;CACxC,IAAI,QAAQ,SAAS,GAEnB,OAAO,GAAG,MAAM,GAAG,QAAQ,SAAS,EAAE,aAAa,MAAM,OAAO,QAAQ,SAAS,EAAE;CAErF,MAAM,OAAO,WAAW,MAAM,GAAG;CACjC,MAAM,QAAQ,YAAY,KAAK;CAC/B,OAAO,SAAS,KAAA,KAAa,SAAS,QAClC,UAAU,MAAM,IAAI,MAAM,IAAI,SAC9B,UAAU,MAAM,IAAI;AAC1B;;AAGA,SAAgB,UAAU,UAAkB,OAAuB;CACjE,IAAI,SAAS,GAAG,OAAO;CACvB,QAAS,WAAW,QAAS,SAAS;AACxC;AAoBA,SAAgB,iBAAiB,MAAoB,OAAoC;CACvF,QAAQ,OAAR;EACE,KAAK,SACH,OAAO,SAAS,WAAW,WAAW;EACxC,KAAK,WACH,OAAO;EACT,KAAK;EACL,KAAK,SACH,OAAO,SAAS,WAAW,SAAS;EACtC,KAAK;EACL,KAAK,QACH,OAAO,SAAS,SAAS,WAAW;CACxC;AACF"}
1
+ {"version":3,"file":"citation.js","names":[],"sources":["../../../../src/components/composites/inline-citation/citation.ts"],"sourcesContent":["import { boundText } from '#lib/text'\nimport { sourceHost, sourceTitle, type Source } from '../sources/source'\n\n/** Characters of a host or title that fit in a badge before it is clipped. */\nconst LABEL_LIMIT = 24\n\n/**\n * The text on a citation badge.\n *\n * A 1-based `index` wins, because a number is what the sentence's own markers\n * and the Sources list use. Without one the badge shows the source's host (read\n * from the parsed URL, so it cannot be spoofed by a title), then a clipped title,\n * and only then a neutral word — never an invented number.\n */\nexport function citationLabel(index: number | undefined, source: Source | undefined): string {\n if (index !== undefined && Number.isInteger(index) && index >= 1 && index <= 9999) {\n return String(index)\n }\n if (source === undefined) return 'source'\n const host = sourceHost(source.url)\n if (host !== undefined) return boundText(host, LABEL_LIMIT)\n return boundText(source.title, LABEL_LIMIT) || 'source'\n}\n\n/**\n * The badge's accessible name. The visible label is a number or a host, which\n * says nothing on its own, so the name carries the title and host: a screen-reader\n * or voice-control user learns what is cited without opening the popover.\n */\nexport function citationName(sources: readonly Source[], index: number | undefined): string {\n const first = sources[0]\n if (first === undefined) return 'Citation'\n const label = citationLabel(index, first)\n if (sources.length > 1) {\n // Keep the visible badge text in the accessible name for label-content-name-mismatch checks.\n return `${label}+${sources.length - 1} — Sources ${label} and ${sources.length - 1} more`\n }\n const host = sourceHost(first.url)\n const title = sourceTitle(first)\n return host !== undefined && host !== title\n ? `Source ${label}: ${title}, ${host}`\n : `Source ${label}: ${title}`\n}\n\n/** Wrap a position into 0..count-1, so Previous on the first source goes to the last. */\nexport function wrapIndex(position: number, count: number): number {\n if (count <= 0) return 0\n return ((position % count) + count) % count\n}\n\n/**\n * How a citation's popover is open.\n *\n * - `peek` is a hover or keyboard-focus preview: it does not take focus, and it\n * goes away when the pointer or focus does.\n * - `pinned` is a deliberate open (click, tap, Enter, Space): focus moves into\n * the popover so its link and Previous/Next are reachable, and it stays until\n * Escape, an outside press, or the badge is pressed again.\n *\n * A popover that only opened on hover would exclude keyboard and touch readers;\n * one that only opened on press would make pointer users click to glance at a\n * source. This is the smallest model that serves both, and it is a pure function\n * so the awkward transitions (hover then click must pin, not toggle shut) are\n * tested rather than argued about.\n */\nexport type CitationMode = 'closed' | 'peek' | 'pinned'\nexport type CitationEvent = 'enter' | 'leave' | 'focus' | 'blur' | 'press' | 'dismiss'\n\nexport function nextCitationMode(mode: CitationMode, event: CitationEvent): CitationMode {\n switch (event) {\n case 'press':\n return mode === 'pinned' ? 'closed' : 'pinned'\n case 'dismiss':\n return 'closed'\n case 'enter':\n case 'focus':\n return mode === 'closed' ? 'peek' : mode\n case 'leave':\n case 'blur':\n return mode === 'peek' ? 'closed' : mode\n }\n}\n"],"mappings":";;;;AAIA,IAAM,cAAc;;;;;;;;;AAUpB,SAAgB,cAAc,OAA2B,QAAoC;CAC3F,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,KAAK,KAAK,SAAS,KAAK,SAAS,MAC3E,OAAO,OAAO,KAAK;CAErB,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,OAAO,WAAW,OAAO,GAAG;CAClC,IAAI,SAAS,KAAA,GAAW,OAAO,UAAU,MAAM,WAAW;CAC1D,OAAO,UAAU,OAAO,OAAO,WAAW,KAAK;AACjD;;;;;;AAOA,SAAgB,aAAa,SAA4B,OAAmC;CAC1F,MAAM,QAAQ,QAAQ;CACtB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,QAAQ,cAAc,OAAO,KAAK;CACxC,IAAI,QAAQ,SAAS,GAEnB,OAAO,GAAG,MAAM,GAAG,QAAQ,SAAS,EAAE,aAAa,MAAM,OAAO,QAAQ,SAAS,EAAE;CAErF,MAAM,OAAO,WAAW,MAAM,GAAG;CACjC,MAAM,QAAQ,YAAY,KAAK;CAC/B,OAAO,SAAS,KAAA,KAAa,SAAS,QAClC,UAAU,MAAM,IAAI,MAAM,IAAI,SAC9B,UAAU,MAAM,IAAI;AAC1B;;AAGA,SAAgB,UAAU,UAAkB,OAAuB;CACjE,IAAI,SAAS,GAAG,OAAO;CACvB,QAAS,WAAW,QAAS,SAAS;AACxC;AAoBA,SAAgB,iBAAiB,MAAoB,OAAoC;CACvF,QAAQ,OAAR;EACE,KAAK,SACH,OAAO,SAAS,WAAW,WAAW;EACxC,KAAK,WACH,OAAO;EACT,KAAK;EACL,KAAK,SACH,OAAO,SAAS,WAAW,SAAS;EACtC,KAAK;EACL,KAAK,QACH,OAAO,SAAS,SAAS,WAAW;CACxC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"inline-citation.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGxD,OAAO,EAML,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAA;AAU1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,0DAA0D;IAC1D,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAID,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,kCAwMxD;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,CAa7E"}
1
+ {"version":3,"file":"inline-citation.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGxD,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAA;AAW1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,0DAA0D;IAC1D,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAID,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,kCAyMxD;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,CAa7E"}
@@ -3,7 +3,8 @@ import { ActionButton } from "../action-button/action-button.js";
3
3
  import { Button } from "../../ui/button/button.js";
4
4
  import { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from "../../ui/popover/popover.js";
5
5
  import { TextLink } from "../../ui/text-link/text-link.js";
6
- import { boundText, safeSourceUrl, sourceHost, sourceTitle } from "../sources/source.js";
6
+ import { safeSourceUrl, sourceHost, sourceTitle } from "../sources/source.js";
7
+ import { boundText } from "../../../lib/text.js";
7
8
  import { citationLabel, citationName, nextCitationMode, wrapIndex } from "./citation.js";
8
9
  import { createComponent, insert, memo, template } from "solid-js/web";
9
10
  import { ChevronLeft, ChevronRight } from "lucide-solid";
@@ -1 +1 @@
1
- {"version":3,"file":"inline-citation.js","names":["ChevronLeft","ChevronRight","createEffect","createSignal","onCleanup","Show","splitProps","cn","ActionButton","Button","MessageCitations","Popover","PopoverContent","PopoverTitle","PopoverTrigger","TextLink","SOURCE_SNIPPET_LIMIT","boundText","safeSourceUrl","sourceHost","sourceTitle","Source","citationLabel","citationName","nextCitationMode","wrapIndex","CitationEvent","CitationMode","InlineCitationProps","sources","index","hoverDelay","class","LEAVE_DELAY","InlineCitation","props","local","mode","setMode","position","setPosition","timer","ReturnType","setTimeout","content","HTMLElement","pressing","restoringFocus","keyboardPeek","setKeyboardPeek","focusInCard","escapeClosedTooltip","onWindowKeyDown","event","KeyboardEvent","key","ownerDocument","querySelector","window","addEventListener","removeEventListener","count","length","active","clear","undefined","clearTimeout","dispatch","current","next","schedule","delay","onPointerEnter","PointerEvent","pointerType","onPointerLeave","onClick","wasPeeking","queueMicrotask","focus","_$createComponent","when","children","_el$","_tmpl$3","_$insert","open","onOpenChange","placement","gutter","as","variant","size","touchTarget","aria-label","onFocus","FocusEvent","currentTarget","matches","onBlur","_el$2","_tmpl$","_el$3","_tmpl$2","_el$4","firstChild","ref","element","inert","onOpenAutoFocus","Event","preventDefault","onFocusIn","onKeyDown","onCloseAutoFocus","returnFocus","source","_el$5","_tmpl$5","_el$6","_tmpl$4","_el$7","_el$8","_el$0","nextSibling","_el$9","_el$1","tooltip","value","CitationDetails","messageCitations","render","numbers","flatMap","number","href","url","host","snippet","withheld","_el$10","_tmpl$6","target","rel","_$memo","_tmpl$9","_tmpl$7","_el$12","_tmpl$8","_$createComponent","_$memo"],"sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from 'lucide-solid'\nimport { createEffect, createSignal, onCleanup, Show, splitProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { ActionButton } from '../action-button'\nimport { Button } from '../../ui/button'\nimport type { MessageCitations } from '../../ui/message'\nimport { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '../../ui/popover'\nimport { TextLink } from '../../ui/text-link'\nimport {\n SOURCE_SNIPPET_LIMIT,\n boundText,\n safeSourceUrl,\n sourceHost,\n sourceTitle,\n type Source,\n} from '../sources/source'\nimport {\n citationLabel,\n citationName,\n nextCitationMode,\n wrapIndex,\n type CitationEvent,\n type CitationMode,\n} from './citation'\n\n/**\n * InlineCitation.\n *\n * A small badge inside a sentence — \"1\", or a host — that opens the source(s)\n * behind the claim: title, host, address, snippet, and Previous/Next when several\n * sources share one marker. It is an inline element for prose such as\n * `MessageText`: it never breaks across lines, stays on the text baseline, and\n * adds no block of its own. For the list of everything a reply used, reach for\n * `Sources`; the two number sources the same way.\n *\n * ## One popover, two ways to open it\n *\n * A hover card would exclude everyone who is not holding a mouse, so this is a\n * `Popover` that a pointer can also *peek* at:\n *\n * - **Hover or keyboard focus peeks.** The popover opens without taking focus\n * and closes when the pointer or focus leaves. Touch has no hover, so a touch\n * never peeks. A keyboard peek's card is inert, so Tab moves on from the badge\n * to the next control on the page instead of into a card that is closing.\n * - **Click, tap, Enter or Space pins.** Focus moves into the popover so its\n * link and Previous/Next are reachable; it stays until Escape, an outside press,\n * or the badge is pressed again, and focus returns to the badge. Pressing a badge\n * that is only peeking pins it rather than toggling it shut — the transitions\n * are the pure `nextCitationMode`.\n *\n * Kobalte's trigger toggles on every press, so `open` is controlled and its own\n * close request is ignored for the press that we already decided (`pressing`).\n * Without that, hover-then-click, the commonest pointer path, would close the card.\n *\n * ## It makes no claim without sources\n *\n * No sources renders nothing: a marker that points nowhere is not a citation.\n * The address is a link only when `safeSourceUrl` allows it; the host comes from\n * the parsed URL; titles and snippets are clipped, cleaned of direction\n * overrides and rendered as text. The badge's accessible name carries the title\n * and host (the visible label is only a number or a host), so a reader hears\n * what is cited without opening anything.\n */\nexport type InlineCitationProps = {\n /** One source, or several that support the same claim. */\n sources: readonly Source[]\n /**\n * The 1-based number to show, matching the source's position in `Sources`.\n * Omit it to show the host instead; a number is never guessed.\n */\n index?: number\n /** Milliseconds a pointer rests before the peek opens. */\n hoverDelay?: number\n class?: string\n}\n\nconst LEAVE_DELAY = 200\n\nexport function InlineCitation(props: InlineCitationProps) {\n const [local] = splitProps(props, ['sources', 'index', 'hoverDelay', 'class'])\n const [mode, setMode] = createSignal<CitationMode>('closed')\n const [position, setPosition] = createSignal(0)\n let timer: ReturnType<typeof setTimeout> | undefined\n let content: HTMLElement | undefined\n let pressing = false\n // Focus handed back to the badge as the popover closes is not a request to\n // peek again; without this, Escape from a pinned card reopens it as a preview.\n let restoringFocus = false\n // A keyboard peek is a preview of the badge the reader is already on. Its card\n // sits in a portal at the end of the document, so if it stayed tabbable, Tab\n // from the badge would walk into the card, the card would close behind the\n // focus as the badge blurred, and focus would fall to <body> and be pulled\n // back to the badge: a keyboard trap. The card is inert until Enter or Space\n // pins it, and while it closes. A pointer peek stays interactive.\n const [keyboardPeek, setKeyboardPeek] = createSignal(false)\n // Focus goes back to the badge only when it was in the card. A peek never\n // held focus, and its close (finishing after its exit animation) must not\n // pull the reader back from wherever Tab has taken them since.\n let focusInCard = false\n // Escape closes the innermost layer first: an open Previous/Next tooltip, then\n // the card. Kobalte only lets the top-most layer take Escape, and a tooltip\n // that just closed stays the top layer while it animates out, so a second\n // Escape pressed during that exit used to vanish and leave the card open.\n // Whether a tooltip was open is read before any handler runs (window,\n // capture); an Escape that closed nothing else closes the card itself.\n let escapeClosedTooltip = false\n const onWindowKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n escapeClosedTooltip =\n content?.ownerDocument.querySelector('[data-slot=\"tooltip-content\"][data-expanded]') != null\n }\n createEffect(() => {\n if (mode() !== 'pinned' || typeof window === 'undefined') return\n window.addEventListener('keydown', onWindowKeyDown, true)\n onCleanup(() => window.removeEventListener('keydown', onWindowKeyDown, true))\n })\n\n const count = () => local.sources.length\n const active = () => local.sources[wrapIndex(position(), count())]\n const clear = () => {\n if (timer !== undefined) clearTimeout(timer)\n timer = undefined\n }\n onCleanup(clear)\n\n const dispatch = (event: CitationEvent) =>\n setMode((current) => {\n const next = nextCitationMode(current, event)\n if (next !== 'peek') setKeyboardPeek(false)\n else if (current === 'closed') setKeyboardPeek(event === 'focus')\n return next\n })\n const schedule = (event: CitationEvent, delay: number) => {\n clear()\n timer = setTimeout(() => dispatch(event), delay)\n }\n\n const onPointerEnter = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('enter', local.hoverDelay ?? 150)\n }\n const onPointerLeave = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('leave', LEAVE_DELAY)\n }\n\n const onClick = () => {\n clear()\n const wasPeeking = mode() === 'peek'\n dispatch('press')\n // Kobalte toggles right after this handler; its request is not a dismissal.\n pressing = true\n queueMicrotask(() => {\n pressing = false\n })\n // The peek never took focus; a deliberate press must hand it over.\n if (wasPeeking) queueMicrotask(() => content?.focus())\n }\n\n // The badge and the popover's portal marker share one wrapper. Without it they\n // are loose siblings in the host's node list, and when the portal marker comes\n // and goes as the card opens and closes, a host that renders its inline nodes\n // as one array (MessageText) reconciles that array and can move the badge,\n // which drops keyboard focus to <body> on the badge the reader just reached.\n return (\n <Show when={count() > 0}>\n <span data-slot=\"inline-citation-root\">\n <Popover\n open={mode() !== 'closed'}\n onOpenChange={(next) => {\n if (!next && !pressing) dispatch('dismiss')\n }}\n placement=\"bottom\"\n gutter={6}\n >\n <PopoverTrigger\n as={Button}\n variant=\"subtle\"\n size=\"2xs\"\n touchTarget=\"comfortable\"\n data-slot=\"inline-citation\"\n aria-label={citationName(local.sources, local.index)}\n class={cn('mx-0.5 align-baseline tabular-nums', local.class)}\n onClick={onClick}\n onPointerEnter={onPointerEnter}\n onPointerLeave={onPointerLeave}\n onFocus={(event: FocusEvent & { currentTarget: HTMLElement }) => {\n // Mouse focus follows the press; only keyboard focus peeks.\n if (restoringFocus) return\n if (event.currentTarget.matches(':focus-visible')) dispatch('focus')\n }}\n onBlur={() => dispatch('blur')}\n >\n <span aria-hidden=\"true\" class=\"max-w-32 truncate\">\n {citationLabel(local.index, local.sources[0])}\n </span>\n <Show when={count() > 1}>\n <span aria-hidden=\"true\">+{count() - 1}</span>\n </Show>\n </PopoverTrigger>\n <PopoverContent\n ref={(element: HTMLElement) => (content = element)}\n inert={keyboardPeek() || mode() === 'closed' || undefined}\n class=\"w-72 max-w-full\"\n onOpenAutoFocus={(event: Event) => {\n if (mode() === 'peek') event.preventDefault()\n }}\n onFocusIn={() => {\n focusInCard = true\n }}\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key !== 'Escape' || escapeClosedTooltip || mode() !== 'pinned') return\n dispatch('dismiss')\n }}\n onCloseAutoFocus={(event: Event) => {\n const returnFocus = focusInCard\n focusInCard = false\n if (!returnFocus) {\n event.preventDefault()\n return\n }\n // The focus move that follows is synchronous; the microtask ends the window.\n restoringFocus = true\n queueMicrotask(() => {\n restoringFocus = false\n })\n }}\n onPointerEnter={(event: PointerEvent) => {\n if (event.pointerType !== 'touch') clear()\n }}\n onPointerLeave={onPointerLeave}\n >\n <Show when={active()}>\n {(source) => (\n <div class=\"flex min-w-0 flex-col gap-1.5 px-2 py-1.5\">\n <Show when={count() > 1}>\n <div class=\"flex items-center justify-between gap-2\">\n <span\n role=\"status\"\n aria-live=\"polite\"\n class=\"text-xs text-muted-foreground tabular-nums\"\n >\n Source {wrapIndex(position(), count()) + 1} of {count()}\n </span>\n <span class=\"flex items-center gap-0.5\">\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Previous source\"\n tooltip=\"Previous source\"\n onClick={() => setPosition((value) => wrapIndex(value - 1, count()))}\n >\n <ChevronLeft />\n </ActionButton>\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Next source\"\n tooltip=\"Next source\"\n onClick={() => setPosition((value) => wrapIndex(value + 1, count()))}\n >\n <ChevronRight />\n </ActionButton>\n </span>\n </div>\n </Show>\n <PopoverTitle class=\"p-0 [overflow-wrap:anywhere]\">\n {sourceTitle(source())}\n </PopoverTitle>\n <CitationDetails source={source()} />\n </div>\n )}\n </Show>\n </PopoverContent>\n </Popover>\n </span>\n </Show>\n )\n}\n\n/**\n * Citation markers for `MessageText`, from the sources a reply really used.\n *\n * `[^2]` in the text becomes the second source's badge; `[^1,3]` one badge for\n * sources 1 and 3. A number beyond the list leaves the marker as written, and an\n * empty list makes every marker literal, so text can never cite a source the host\n * did not supply.\n *\n * <MessageText text={reply} citations={messageCitations(sources)} />\n */\nexport function messageCitations(sources: readonly Source[]): MessageCitations {\n return {\n count: sources.length,\n render: (numbers) => (\n <InlineCitation\n index={numbers[0]}\n sources={numbers.flatMap((number) => {\n const source = sources[number - 1]\n return source ? [source] : []\n })}\n />\n ),\n }\n}\n\nfunction CitationDetails(props: { source: Source }) {\n const href = () => safeSourceUrl(props.source.url)\n const host = () => sourceHost(props.source.url)\n const snippet = () =>\n props.source.snippet ? boundText(props.source.snippet, SOURCE_SNIPPET_LIMIT) : ''\n const withheld = () => props.source.url !== undefined && props.source.url !== '' && !href()\n\n return (\n <>\n <Show when={host()}>\n <p class=\"m-0 text-xs text-muted-foreground [overflow-wrap:anywhere]\">{host()}</p>\n </Show>\n <Show when={href()}>\n {(url) => (\n <TextLink\n href={url()}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n class=\"w-fit max-w-full text-xs [overflow-wrap:anywhere]\"\n >\n {boundText(url(), 96)}\n <span class=\"visually-hidden\"> (opens in a new tab)</span>\n </TextLink>\n )}\n </Show>\n <Show when={withheld()}>\n <p class=\"m-0 text-xs text-muted-foreground\">Address not linked</p>\n </Show>\n <Show when={snippet()}>\n <p class=\"m-0 line-clamp-6 text-xs text-muted-foreground [overflow-wrap:anywhere]\">\n {snippet()}\n </p>\n </Show>\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4EA,IAAMiC,cAAc;AAEpB,SAAgBC,eAAeC,OAA4B;CACzD,MAAM,CAACC,SAAS9B,WAAW6B,OAAO;EAAC;EAAW;EAAS;EAAc;CAAO,CAAC;CAC7E,MAAM,CAACE,MAAMC,WAAWnC,aAA2B,QAAQ;CAC3D,MAAM,CAACoC,UAAUC,eAAerC,aAAa,CAAC;CAC9C,IAAIsC;CACJ,IAAIG;CACJ,IAAIE,WAAW;CAGf,IAAIC,iBAAiB;CAOrB,MAAM,CAACC,cAAcC,mBAAmB9C,aAAa,KAAK;CAI1D,IAAI+C,cAAc;CAOlB,IAAIC,sBAAsB;CAC1B,MAAMC,mBAAmBC,UAAyB;EAChD,IAAIA,MAAME,QAAQ,UAAU;EAC5BJ,sBACEP,SAASY,cAAcC,cAAc,gDAA8C,KAAK;CAC5F;CACAvD,mBAAmB;EACjB,IAAImC,KAAK,MAAM,YAAY,OAAOqB,WAAW,aAAa;EAC1DA,OAAOC,i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OAAOoB,QAAQvE,KAAAA,KAAa9B,MAAMiF,OAAOoB,QAAQ,MAAM,CAACD,KAAK;CAE1F,OAAA;EAAAvD,gBAEK3E,MAAI;GAAA,IAAC4E,OAAI;IAAA,OAAEwD,KAAK;GAAC;GAAA,IAAAvD,WAAA;IAAA,IAAA0D,SAAAC,QAAA;IAAAxD,OAAAuD,QACuDH,IAAI;IAAA,OAAAG;GAAA;EAAA,CAAA;EAAA5D,gBAE5E3E,MAAI;GAAA,IAAC4E,OAAI;IAAA,OAAEsD,KAAK;GAAC;GAAArD,WACdsD,QAAGxD,gBACFjE,UAAQ;IAAA,IACPwH,OAAI;KAAA,OAAEC,IAAI;IAAC;IACXM,QAAM;IACNC,KAAG;IAAA,SAAA;IAAA,IAAA7D,WAAA;KAAA,OAAA,CAAA8D,WAGF/H,UAAUuH,IAAI,GAAG,EAAE,CAAC,GAAAS,QAAA,CAAA;IAAA;GAAA,CAAA;EAGxB,CAAA;EAAAjE,gBAEF3E,MAAI;GAAA,IAAC4E,OAAI;IAAA,OAAE0D,SAAS;GAAC;GAAA,IAAAzD,WAAA;IAAA,OAAAgE,QAAA;GAAA;EAAA,CAAA;EAAAlE,gBAGrB3E,MAAI;GAAA,IAAC4E,OAAI;IAAA,OAAEyD,QAAQ;GAAC;GAAA,IAAAxD,WAAA;IAAA,IAAAiE,SAAAC,QAAA;IAAA/D,OAAA8D,QAEhBT,OAAO;IAAA,OAAAS;GAAA;EAAA,CAAA;CAAA;AAKlB"}
1
+ {"version":3,"file":"inline-citation.js","names":["ChevronLeft","ChevronRight","createEffect","createSignal","onCleanup","Show","splitProps","cn","ActionButton","Button","MessageCitations","Popover","PopoverContent","PopoverTitle","PopoverTrigger","TextLink","SOURCE_SNIPPET_LIMIT","safeSourceUrl","sourceHost","sourceTitle","Source","boundText","citationLabel","citationName","nextCitationMode","wrapIndex","CitationEvent","CitationMode","InlineCitationProps","sources","index","hoverDelay","class","LEAVE_DELAY","InlineCitation","props","local","mode","setMode","position","setPosition","timer","ReturnType","setTimeout","content","HTMLElement","pressing","restoringFocus","keyboardPeek","setKeyboardPeek","focusInCard","escapeClosedTooltip","onWindowKeyDown","event","KeyboardEvent","key","ownerDocument","querySelector","window","addEventListener","removeEventListener","count","length","active","clear","undefined","clearTimeout","dispatch","current","next","schedule","delay","onPointerEnter","PointerEvent","pointerType","onPointerLeave","onClick","wasPeeking","queueMicrotask","focus","_$createComponent","when","children","_el$","_tmpl$3","_$insert","open","onOpenChange","placement","gutter","as","variant","size","touchTarget","aria-label","onFocus","FocusEvent","currentTarget","matches","onBlur","_el$2","_tmpl$","_el$3","_tmpl$2","_el$4","firstChild","ref","element","inert","onOpenAutoFocus","Event","preventDefault","onFocusIn","onKeyDown","onCloseAutoFocus","returnFocus","source","_el$5","_tmpl$5","_el$6","_tmpl$4","_el$7","_el$8","_el$0","nextSibling","_el$9","_el$1","tooltip","value","CitationDetails","messageCitations","render","numbers","flatMap","number","href","url","host","snippet","withheld","_el$10","_tmpl$6","target","rel","_$memo","_tmpl$9","_tmpl$7","_el$12","_tmpl$8","_$createComponent","_$memo"],"sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from 'lucide-solid'\nimport { createEffect, createSignal, onCleanup, Show, splitProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { ActionButton } from '../action-button'\nimport { Button } from '../../ui/button'\nimport type { MessageCitations } from '../../ui/message'\nimport { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '../../ui/popover'\nimport { TextLink } from '../../ui/text-link'\nimport {\n SOURCE_SNIPPET_LIMIT,\n safeSourceUrl,\n sourceHost,\n sourceTitle,\n type Source,\n} from '../sources/source'\nimport { boundText } from '#lib/text'\nimport {\n citationLabel,\n citationName,\n nextCitationMode,\n wrapIndex,\n type CitationEvent,\n type CitationMode,\n} from './citation'\n\n/**\n * InlineCitation.\n *\n * A small badge inside a sentence — \"1\", or a host — that opens the source(s)\n * behind the claim: title, host, address, snippet, and Previous/Next when several\n * sources share one marker. It is an inline element for prose such as\n * `MessageText`: it never breaks across lines, stays on the text baseline, and\n * adds no block of its own. For the list of everything a reply used, reach for\n * `Sources`; the two number sources the same way.\n *\n * ## One popover, two ways to open it\n *\n * A hover card would exclude everyone who is not holding a mouse, so this is a\n * `Popover` that a pointer can also *peek* at:\n *\n * - **Hover or keyboard focus peeks.** The popover opens without taking focus\n * and closes when the pointer or focus leaves. Touch has no hover, so a touch\n * never peeks. A keyboard peek's card is inert, so Tab moves on from the badge\n * to the next control on the page instead of into a card that is closing.\n * - **Click, tap, Enter or Space pins.** Focus moves into the popover so its\n * link and Previous/Next are reachable; it stays until Escape, an outside press,\n * or the badge is pressed again, and focus returns to the badge. Pressing a badge\n * that is only peeking pins it rather than toggling it shut — the transitions\n * are the pure `nextCitationMode`.\n *\n * Kobalte's trigger toggles on every press, so `open` is controlled and its own\n * close request is ignored for the press that we already decided (`pressing`).\n * Without that, hover-then-click, the commonest pointer path, would close the card.\n *\n * ## It makes no claim without sources\n *\n * No sources renders nothing: a marker that points nowhere is not a citation.\n * The address is a link only when `safeSourceUrl` allows it; the host comes from\n * the parsed URL; titles and snippets are clipped, cleaned of direction\n * overrides and rendered as text. The badge's accessible name carries the title\n * and host (the visible label is only a number or a host), so a reader hears\n * what is cited without opening anything.\n */\nexport type InlineCitationProps = {\n /** One source, or several that support the same claim. */\n sources: readonly Source[]\n /**\n * The 1-based number to show, matching the source's position in `Sources`.\n * Omit it to show the host instead; a number is never guessed.\n */\n index?: number\n /** Milliseconds a pointer rests before the peek opens. */\n hoverDelay?: number\n class?: string\n}\n\nconst LEAVE_DELAY = 200\n\nexport function InlineCitation(props: InlineCitationProps) {\n const [local] = splitProps(props, ['sources', 'index', 'hoverDelay', 'class'])\n const [mode, setMode] = createSignal<CitationMode>('closed')\n const [position, setPosition] = createSignal(0)\n let timer: ReturnType<typeof setTimeout> | undefined\n let content: HTMLElement | undefined\n let pressing = false\n // Focus handed back to the badge as the popover closes is not a request to\n // peek again; without this, Escape from a pinned card reopens it as a preview.\n let restoringFocus = false\n // A keyboard peek is a preview of the badge the reader is already on. Its card\n // sits in a portal at the end of the document, so if it stayed tabbable, Tab\n // from the badge would walk into the card, the card would close behind the\n // focus as the badge blurred, and focus would fall to <body> and be pulled\n // back to the badge: a keyboard trap. The card is inert until Enter or Space\n // pins it, and while it closes. A pointer peek stays interactive.\n const [keyboardPeek, setKeyboardPeek] = createSignal(false)\n // Focus goes back to the badge only when it was in the card. A peek never\n // held focus, and its close (finishing after its exit animation) must not\n // pull the reader back from wherever Tab has taken them since.\n let focusInCard = false\n // Escape closes the innermost layer first: an open Previous/Next tooltip, then\n // the card. Kobalte only lets the top-most layer take Escape, and a tooltip\n // that just closed stays the top layer while it animates out, so a second\n // Escape pressed during that exit used to vanish and leave the card open.\n // Whether a tooltip was open is read before any handler runs (window,\n // capture); an Escape that closed nothing else closes the card itself.\n let escapeClosedTooltip = false\n const onWindowKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n escapeClosedTooltip =\n content?.ownerDocument.querySelector('[data-slot=\"tooltip-content\"][data-expanded]') != null\n }\n createEffect(() => {\n if (mode() !== 'pinned' || typeof window === 'undefined') return\n window.addEventListener('keydown', onWindowKeyDown, true)\n onCleanup(() => window.removeEventListener('keydown', onWindowKeyDown, true))\n })\n\n const count = () => local.sources.length\n const active = () => local.sources[wrapIndex(position(), count())]\n const clear = () => {\n if (timer !== undefined) clearTimeout(timer)\n timer = undefined\n }\n onCleanup(clear)\n\n const dispatch = (event: CitationEvent) =>\n setMode((current) => {\n const next = nextCitationMode(current, event)\n if (next !== 'peek') setKeyboardPeek(false)\n else if (current === 'closed') setKeyboardPeek(event === 'focus')\n return next\n })\n const schedule = (event: CitationEvent, delay: number) => {\n clear()\n timer = setTimeout(() => dispatch(event), delay)\n }\n\n const onPointerEnter = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('enter', local.hoverDelay ?? 150)\n }\n const onPointerLeave = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('leave', LEAVE_DELAY)\n }\n\n const onClick = () => {\n clear()\n const wasPeeking = mode() === 'peek'\n dispatch('press')\n // Kobalte toggles right after this handler; its request is not a dismissal.\n pressing = true\n queueMicrotask(() => {\n pressing = false\n })\n // The peek never took focus; a deliberate press must hand it over, once\n // Kobalte's own toggle (which runs after this handler) has settled.\n if (wasPeeking) queueMicrotask(() => content?.focus())\n }\n\n // The badge and the popover's portal marker share one wrapper. Without it they\n // are loose siblings in the host's node list, and when the portal marker comes\n // and goes as the card opens and closes, a host that renders its inline nodes\n // as one array (MessageText) reconciles that array and can move the badge,\n // which drops keyboard focus to <body> on the badge the reader just reached.\n return (\n <Show when={count() > 0}>\n <span data-slot=\"inline-citation-root\">\n <Popover\n open={mode() !== 'closed'}\n onOpenChange={(next) => {\n if (!next && !pressing) dispatch('dismiss')\n }}\n placement=\"bottom\"\n gutter={6}\n >\n <PopoverTrigger\n as={Button}\n variant=\"subtle\"\n size=\"2xs\"\n touchTarget=\"comfortable\"\n data-slot=\"inline-citation\"\n aria-label={citationName(local.sources, local.index)}\n class={cn('mx-0.5 align-baseline tabular-nums', local.class)}\n onClick={onClick}\n onPointerEnter={onPointerEnter}\n onPointerLeave={onPointerLeave}\n onFocus={(event: FocusEvent & { currentTarget: HTMLElement }) => {\n // Mouse focus follows the press; only keyboard focus peeks.\n if (restoringFocus) return\n if (event.currentTarget.matches(':focus-visible')) dispatch('focus')\n }}\n onBlur={() => dispatch('blur')}\n >\n <span aria-hidden=\"true\" class=\"max-w-32 truncate\">\n {citationLabel(local.index, local.sources[0])}\n </span>\n <Show when={count() > 1}>\n <span aria-hidden=\"true\">+{count() - 1}</span>\n </Show>\n </PopoverTrigger>\n <PopoverContent\n ref={(element: HTMLElement) => (content = element)}\n inert={keyboardPeek() || mode() === 'closed' || undefined}\n class=\"w-72 max-w-full\"\n onOpenAutoFocus={(event: Event) => {\n if (mode() === 'peek') event.preventDefault()\n }}\n onFocusIn={() => {\n focusInCard = true\n }}\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key !== 'Escape' || escapeClosedTooltip || mode() !== 'pinned') return\n dispatch('dismiss')\n }}\n onCloseAutoFocus={(event: Event) => {\n const returnFocus = focusInCard\n focusInCard = false\n if (!returnFocus) {\n event.preventDefault()\n return\n }\n // The focus move that follows is synchronous; the microtask ends the window.\n restoringFocus = true\n queueMicrotask(() => {\n restoringFocus = false\n })\n }}\n onPointerEnter={(event: PointerEvent) => {\n if (event.pointerType !== 'touch') clear()\n }}\n onPointerLeave={onPointerLeave}\n >\n <Show when={active()}>\n {(source) => (\n <div class=\"flex min-w-0 flex-col gap-1.5 px-2 py-1.5\">\n <Show when={count() > 1}>\n <div class=\"flex items-center justify-between gap-2\">\n <span\n role=\"status\"\n aria-live=\"polite\"\n class=\"text-xs text-muted-foreground tabular-nums\"\n >\n Source {wrapIndex(position(), count()) + 1} of {count()}\n </span>\n <span class=\"flex items-center gap-0.5\">\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Previous source\"\n tooltip=\"Previous source\"\n onClick={() => setPosition((value) => wrapIndex(value - 1, count()))}\n >\n <ChevronLeft />\n </ActionButton>\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Next source\"\n tooltip=\"Next source\"\n onClick={() => setPosition((value) => wrapIndex(value + 1, count()))}\n >\n <ChevronRight />\n </ActionButton>\n </span>\n </div>\n </Show>\n <PopoverTitle class=\"p-0 [overflow-wrap:anywhere]\">\n {sourceTitle(source())}\n </PopoverTitle>\n <CitationDetails source={source()} />\n </div>\n )}\n </Show>\n </PopoverContent>\n </Popover>\n </span>\n </Show>\n )\n}\n\n/**\n * Citation markers for `MessageText`, from the sources a reply really used.\n *\n * `[^2]` in the text becomes the second source's badge; `[^1,3]` one badge for\n * sources 1 and 3. A number beyond the list leaves the marker as written, and an\n * empty list makes every marker literal, so text can never cite a source the host\n * did not supply.\n *\n * <MessageText text={reply} citations={messageCitations(sources)} />\n */\nexport function messageCitations(sources: readonly Source[]): MessageCitations {\n return {\n count: sources.length,\n render: (numbers) => (\n <InlineCitation\n index={numbers[0]}\n sources={numbers.flatMap((number) => {\n const source = sources[number - 1]\n return source ? [source] : []\n })}\n />\n ),\n }\n}\n\nfunction CitationDetails(props: { source: Source }) {\n const href = () => safeSourceUrl(props.source.url)\n const host = () => sourceHost(props.source.url)\n const snippet = () =>\n props.source.snippet ? boundText(props.source.snippet, SOURCE_SNIPPET_LIMIT) : ''\n const withheld = () => props.source.url !== undefined && props.source.url !== '' && !href()\n\n return (\n <>\n <Show when={host()}>\n <p class=\"m-0 text-xs text-muted-foreground [overflow-wrap:anywhere]\">{host()}</p>\n </Show>\n <Show when={href()}>\n {(url) => (\n <TextLink\n href={url()}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n class=\"w-fit max-w-full text-xs [overflow-wrap:anywhere]\"\n >\n {boundText(url(), 96)}\n <span class=\"visually-hidden\"> (opens in a new tab)</span>\n </TextLink>\n )}\n </Show>\n <Show when={withheld()}>\n <p class=\"m-0 text-xs text-muted-foreground\">Address not linked</p>\n </Show>\n <Show when={snippet()}>\n <p class=\"m-0 line-clamp-6 text-xs text-muted-foreground [overflow-wrap:anywhere]\">\n {snippet()}\n </p>\n </Show>\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4EA,IAAMiC,cAAc;AAEpB,SAAgBC,eAAeC,OAA4B;CACzD,MAAM,CAACC,SAAS9B,WAAW6B,OAAO;EAAC;EAAW;EAAS;EAAc;CAAO,CAAC;CAC7E,MAAM,CAACE,MAAMC,WAAWnC,aAA2B,QAAQ;CAC3D,MAAM,CAACoC,UAAUC,eAAerC,aAAa,CAAC;CAC9C,IAAIsC;CACJ,IAAIG;CACJ,IAAIE,WAAW;CAGf,IAAIC,iBAAiB;CAOrB,MAAM,CAACC,cAAcC,mBAAmB9C,aAAa,KAAK;CAI1D,IAAI+C,cAAc;CAOlB,IA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{ type ConversationSurfaceProps } from '../../conversation';
3
3
  /**
4
4
  * MessageScroller.
5
5
  *
@@ -32,13 +32,13 @@ import { type ConversationSurfaceProps } from '../../conversation/conversation-s
32
32
  * `resetKey`, which re-arms follow and discards any in-flight anchor.
33
33
  */
34
34
  export type MessageScrollerProps = Omit<ConversationSurfaceProps, 'header' | 'empty'> & {
35
- /** There are earlier turns the host can load. */
36
35
  hasOlder?: boolean;
37
- /** The host is loading earlier turns right now. */
36
+ /** The host is loading earlier turns right now, whether or not this scroller asked. */
38
37
  loadingOlder?: boolean;
39
38
  /**
40
39
  * Load earlier turns. The scroller preserves the reader's position across the
41
- * resulting insert whether the host resolves before or after rendering them.
40
+ * resulting insert whether the host resolves before or after rendering them. A
41
+ * rejection is the host's to report: the control stays so the reader can retry.
42
42
  */
43
43
  onLoadOlder?: () => void | Promise<void>;
44
44
  /** Words for the loader row; override for another language. */
@@ -46,7 +46,6 @@ export type MessageScrollerProps = Omit<ConversationSurfaceProps, 'header' | 'em
46
46
  loadingOlderLabel?: string;
47
47
  /** Rendered above the first turn, below the history control. */
48
48
  header?: JSX.Element;
49
- /** Rendered when there are no turns. */
50
49
  empty?: JSX.Element;
51
50
  /** A short sentence for the live status region ("Assistant is responding"). */
52
51
  announcement?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"message-scroller.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/message-scroller/message-scroller.tsx"],"names":[],"mappings":"AACA,OAAO,EAA2D,KAAK,GAAG,EAAE,MAAM,UAAU,CAAA;AAG5F,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,yCAAyC,CAAA;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG;IACtF,iDAAiD;IACjD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,mDAAmD;IACnD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,gEAAgE;IAChE,MAAM,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACpB,wCAAwC;IACxC,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACnB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAQD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAwO1D"}
1
+ {"version":3,"file":"message-scroller.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/message-scroller/message-scroller.tsx"],"names":[],"mappings":"AACA,OAAO,EAA2D,KAAK,GAAG,EAAE,MAAM,UAAU,CAAA;AAG5F,OAAO,EAAuB,KAAK,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAGvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG;IACtF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,uFAAuF;IACvF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,gEAAgE;IAChE,MAAM,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACnB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAKD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eA+O1D"}
@@ -11,8 +11,6 @@ var _tmpl$2 = /*#__PURE__*/ template(`<p role=status class="flex h-control-sm it
11
11
  var _tmpl$3 = /*#__PURE__*/ template(`<div data-slot=message-scroller-older class="flex justify-center py-2">`);
12
12
  /** How far from the top counts as "reached the top", in px. */
13
13
  var TOP_MARGIN = 160;
14
- /** How long a host that still reports `loadingOlder` is waited for, in frames (~10 s). */
15
- var MAX_HOST_WAIT_FRAMES = 600;
16
14
  function MessageScroller(props) {
17
15
  const [local, rest] = splitProps(props, [
18
16
  "class",
@@ -29,6 +27,14 @@ function MessageScroller(props) {
29
27
  "children"
30
28
  ]);
31
29
  let scroller;
30
+ let content;
31
+ let afterHostLoad;
32
+ createEffect(() => {
33
+ if (local.loadingOlder || !afterHostLoad) return;
34
+ const resume = afterHostLoad;
35
+ afterHostLoad = void 0;
36
+ resume();
37
+ });
32
38
  let holdFollow;
33
39
  let epoch = 0;
34
40
  const [inFlight, setInFlight] = createSignal(false);
@@ -45,6 +51,7 @@ function MessageScroller(props) {
45
51
  createEffect(() => {
46
52
  local.resetKey;
47
53
  epoch += 1;
54
+ afterHostLoad = void 0;
48
55
  setInFlight(false);
49
56
  stopWatching();
50
57
  releaseNativeAnchoring();
@@ -60,12 +67,12 @@ function MessageScroller(props) {
60
67
  if (scroller && local.hasOlder && scroller.scrollTop < TOP_MARGIN && scroller.scrollHeight > heightBefore) load();
61
68
  releaseHold?.();
62
69
  };
63
- const wait = (waited) => requestAnimationFrame(() => {
70
+ const afterInsert = () => requestAnimationFrame(() => requestAnimationFrame(() => {
64
71
  if (run !== epoch) return releaseHold?.();
65
- if (local.loadingOlder && waited < MAX_HOST_WAIT_FRAMES) return void wait(waited + 1);
66
- finish();
67
- });
68
- requestAnimationFrame(() => wait(0));
72
+ if (local.loadingOlder) afterHostLoad = afterInsert;
73
+ else finish();
74
+ }));
75
+ afterInsert();
69
76
  };
70
77
  let observer;
71
78
  let resizer;
@@ -79,8 +86,7 @@ function MessageScroller(props) {
79
86
  const load = async (fromControl = false) => {
80
87
  if (!scroller || !local.onLoadOlder || !local.hasOlder || local.loadingOlder || inFlight()) return;
81
88
  const run = epoch;
82
- const anchor = captureAnchor(scroller);
83
- anchor.known = anchorIds(scroller);
89
+ const anchor = captureAnchor(scroller, anchorIds(scroller));
84
90
  const heightBefore = scroller.scrollHeight;
85
91
  const restoreFocus = fromControl && document.activeElement?.closest("[data-slot=\"message-scroller-older\"]") != null;
86
92
  setInFlight(true);
@@ -93,7 +99,6 @@ function MessageScroller(props) {
93
99
  childList: true,
94
100
  subtree: true
95
101
  });
96
- const content = scroller.querySelector("[data-slot=\"conversation-content\"]");
97
102
  if (content && typeof ResizeObserver !== "undefined") {
98
103
  resizer = new ResizeObserver(() => {
99
104
  if (run === epoch && scroller) restoreAnchor(scroller, anchor);
@@ -106,9 +111,7 @@ function MessageScroller(props) {
106
111
  scroller.addEventListener("scroll", follow, { passive: true });
107
112
  const watched = scroller;
108
113
  unfollow = () => watched.removeEventListener("scroll", follow);
109
- try {
110
- await local.onLoadOlder();
111
- } catch {}
114
+ await Promise.resolve(local.onLoadOlder()).catch(() => void 0);
112
115
  settle(anchor, run, heightBefore, restoreFocus, run !== epoch ? holdFollow?.() : void 0);
113
116
  };
114
117
  onCleanup(() => {
@@ -136,6 +139,9 @@ function MessageScroller(props) {
136
139
  get resetKey() {
137
140
  return local.resetKey;
138
141
  },
142
+ contentRef: (element) => {
143
+ content = element;
144
+ },
139
145
  onFollowHold: (hold) => {
140
146
  holdFollow = hold;
141
147
  }
@@ -1 +1 @@
1
- {"version":3,"file":"message-scroller.js","names":["History","LoaderCircle","createEffect","onCleanup","Show","splitProps","createSignal","JSX","cn","Button","ConversationSurface","ConversationSurfaceProps","anchorIds","captureAnchor","restoreAnchor","ScrollAnchor","MessageScrollerProps","Omit","hasOlder","loadingOlder","onLoadOlder","Promise","olderLabel","loadingOlderLabel","header","Element","empty","announcement","TOP_MARGIN","MAX_HOST_WAIT_FRAMES","MessageScroller","props","local","rest","scroller","HTMLDivElement","holdFollow","epoch","inFlight","setInFlight","nativeAnchoring","holdNativeAnchoring","undefined","style","overflowAnchor","releaseNativeAnchoring","resetKey","stopWatching","settle","anchor","run","heightBefore","restoreFocus","releaseHold","finish","document","activeElement","body","again","querySelector","HTMLElement","focus","preventScroll","scrollTop","scrollHeight","load","wait","waited","requestAnimationFrame","observer","MutationObserver","resizer","ResizeObserver","unfollow","disconnect","fromControl","known","closest","observe","childList","subtree","content","follow","addEventListener","passive","watched","removeEventListener","watchTop","element","IntersectionObserver","io","entries","some","entry","isIntersecting","root","rootMargin","_el$","_tmpl$","_el$2","firstChild","_$insert","_$createComponent","_$mergeProps","role","onFollowHold","hold","ref","when","children","_el$3","_tmpl$3","_$use","fallback","type","variant","size","onClick","_$memo","_el$4","_tmpl$2","_$effect","_$className","class","_$createComponent","_$mergeProps","_$memo","_$className"],"sources":["../../../../src/components/composites/message-scroller/message-scroller.tsx"],"sourcesContent":["import { History, LoaderCircle } from 'lucide-solid'\nimport { createEffect, onCleanup, Show, splitProps, createSignal, type JSX } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport {\n ConversationSurface,\n type ConversationSurfaceProps,\n} from '../../conversation/conversation-surface'\nimport { anchorIds, captureAnchor, restoreAnchor, type ScrollAnchor } from './scroll-anchor'\n\n/**\n * MessageScroller.\n *\n * The thread. It owns the three scroll behaviours a chat gets wrong when each\n * is bolted on separately, and keeps them from fighting:\n *\n * 1. **Follow the reply only while the reader is at the bottom.** New and\n * streaming content scrolls into view when the reader is already at the end,\n * and never otherwise. Scrolling up parks the view; the \"Jump to latest\"\n * control brings it back. (This is `ConversationSurface`'s follow contract,\n * which this component wraps rather than reimplements.)\n * 2. **Load history without moving what the reader is looking at.** When the\n * reader reaches the top, `onLoadOlder` is asked for earlier turns. Turns\n * inserted *above* the viewport would normally push the visible content down\n * by exactly their height; here the first visible turn (found by\n * `data-anchor-id`, which `Message` sets from `anchorId`) is measured before\n * the load and put back to the same offset after it, on every layout change\n * until the load settles — so images and code blocks that size themselves\n * late do not jolt the view either. A \"Load earlier\" button is always present\n * while there is more, because the scroll trigger alone is unreachable to a\n * keyboard or switch user and fires nothing in a short pane.\n * 3. **Announce without flooding.** The scroller is a polite log, and a turn that\n * is still arriving marks itself `aria-busy`, so a screen reader waits for the\n * settled turn instead of reading every token. `announcement` is a separate\n * status region for the two moments that matter: a response starting and a\n * response finishing.\n *\n * What it does not own: which turns exist, their identity, or what \"older\"\n * means. The host passes children and a loader; a session switch is\n * `resetKey`, which re-arms follow and discards any in-flight anchor.\n */\nexport type MessageScrollerProps = Omit<ConversationSurfaceProps, 'header' | 'empty'> & {\n /** There are earlier turns the host can load. */\n hasOlder?: boolean\n /** The host is loading earlier turns right now. */\n loadingOlder?: boolean\n /**\n * Load earlier turns. The scroller preserves the reader's position across the\n * resulting insert whether the host resolves before or after rendering them.\n */\n onLoadOlder?: () => void | Promise<void>\n /** Words for the loader row; override for another language. */\n olderLabel?: string\n loadingOlderLabel?: string\n /** Rendered above the first turn, below the history control. */\n header?: JSX.Element\n /** Rendered when there are no turns. */\n empty?: JSX.Element\n /** A short sentence for the live status region (\"Assistant is responding\"). */\n announcement?: string\n}\n\n/** How far from the top counts as \"reached the top\", in px. */\nconst TOP_MARGIN = 160\n\n/** How long a host that still reports `loadingOlder` is waited for, in frames (~10 s). */\nconst MAX_HOST_WAIT_FRAMES = 600\n\nexport function MessageScroller(props: MessageScrollerProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'hasOlder',\n 'loadingOlder',\n 'onLoadOlder',\n 'olderLabel',\n 'loadingOlderLabel',\n 'header',\n 'empty',\n 'announcement',\n 'ref',\n 'resetKey',\n 'children',\n ])\n let scroller: HTMLDivElement | undefined\n let holdFollow: (() => () => void) | undefined\n let epoch = 0\n const [inFlight, setInFlight] = createSignal(false)\n\n // While a load holds the reader's place, the browser's own scroll anchoring is\n // switched off: it moves the offset by the same insert, and the two corrections\n // would be added together.\n let nativeAnchoring: string | undefined\n const holdNativeAnchoring = () => {\n if (!scroller || nativeAnchoring !== undefined) return\n nativeAnchoring = scroller.style.overflowAnchor\n scroller.style.overflowAnchor = 'none'\n }\n const releaseNativeAnchoring = () => {\n if (scroller && nativeAnchoring !== undefined) scroller.style.overflowAnchor = nativeAnchoring\n nativeAnchoring = undefined\n }\n\n // A session switch invalidates a load that was started for the previous one.\n createEffect(() => {\n void local.resetKey\n epoch += 1\n setInFlight(false)\n stopWatching()\n releaseNativeAnchoring()\n })\n\n const settle = (\n anchor: ScrollAnchor | undefined,\n run: number,\n heightBefore: number,\n restoreFocus: boolean,\n releaseHold?: () => void\n ) => {\n const finish = () => {\n if (run !== epoch) return releaseHold?.()\n if (scroller) restoreAnchor(scroller, anchor)\n stopWatching()\n releaseNativeAnchoring()\n setInFlight(false)\n // The control that started the load was replaced by the loading line, which\n // takes focus with it. Put it back on the control (or the thread), so a\n // keyboard user is not dropped onto the page.\n if (restoreFocus && scroller && document.activeElement === document.body) {\n const again = scroller.querySelector<HTMLElement>(\n '[data-slot=\"message-scroller-older\"] button'\n )\n ;(again ?? scroller).focus({ preventScroll: true })\n }\n // Still at the top after a load that added content: keep going, so a\n // pane taller than one page of history fills without a second scroll.\n if (\n scroller &&\n local.hasOlder &&\n scroller.scrollTop < TOP_MARGIN &&\n scroller.scrollHeight > heightBefore\n )\n void load()\n releaseHold?.()\n }\n // Two frames: the first lets the host's insert commit, the second lets\n // late-sizing content (images, highlighted code) report its height. A host\n // that says it is still loading (`loadingOlder`) after its promise resolved\n // is not finished either: its turns will land later, and the anchor must\n // still be held when they do.\n const wait = (waited: number) =>\n requestAnimationFrame(() => {\n if (run !== epoch) return releaseHold?.()\n if (local.loadingOlder && waited < MAX_HOST_WAIT_FRAMES) return void wait(waited + 1)\n finish()\n })\n requestAnimationFrame(() => wait(0))\n }\n\n let observer: MutationObserver | undefined\n let resizer: ResizeObserver | undefined\n let unfollow: (() => void) | undefined\n const stopWatching = () => {\n observer?.disconnect()\n resizer?.disconnect()\n unfollow?.()\n unfollow = undefined\n }\n const load = async (fromControl = false) => {\n if (!scroller || !local.onLoadOlder || !local.hasOlder || local.loadingOlder || inFlight())\n return\n const run = epoch\n const anchor = captureAnchor(scroller)\n anchor.known = anchorIds(scroller)\n const heightBefore = scroller.scrollHeight\n const restoreFocus =\n fromControl && document.activeElement?.closest('[data-slot=\"message-scroller-older\"]') != null\n setInFlight(true)\n holdNativeAnchoring()\n // Every layout change while the load is open re-pins the anchor *before\n // paint*, which is what makes the insert invisible.\n stopWatching()\n observer = new MutationObserver(() => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n })\n observer.observe(scroller, { childList: true, subtree: true })\n // Turns that size themselves late (`content-visibility`, images, highlighted code)\n // move the anchor without adding or removing a node, and with the browser's own\n // anchoring held off nothing else would carry the reader through that.\n const content = scroller.querySelector('[data-slot=\"conversation-content\"]')\n if (content && typeof ResizeObserver !== 'undefined') {\n resizer = new ResizeObserver(() => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n })\n resizer.observe(content)\n }\n // The reader may carry on scrolling while the host answers. A restore re-takes the\n // anchor on the turn they have come to, whichever of the observers or this event\n // reaches it first.\n const follow = () => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n }\n scroller.addEventListener('scroll', follow, { passive: true })\n const watched = scroller\n unfollow = () => watched.removeEventListener('scroll', follow)\n try {\n await local.onLoadOlder()\n } catch {\n // The host reports its own failure; the control stays so the reader can retry.\n }\n // A load that outlived its conversation inserts into a thread whose reader it knows\n // nothing about, and the anchor it held is gone. What it does to the layout (rows\n // taking their height, a clamp, the insert itself) is not the reader scrolling, so the\n // follow position is held until the two frames the insert needs have passed.\n settle(anchor, run, heightBefore, restoreFocus, run !== epoch ? holdFollow?.() : undefined)\n }\n\n onCleanup(() => {\n epoch += 1\n stopWatching()\n releaseNativeAnchoring()\n })\n\n const watchTop = (element: HTMLDivElement) => {\n if (typeof IntersectionObserver === 'undefined') return\n const io = new IntersectionObserver(\n (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) void load()\n },\n { root: scroller ?? null, rootMargin: `${TOP_MARGIN}px 0px 0px 0px` }\n )\n io.observe(element)\n onCleanup(() => io.disconnect())\n }\n\n return (\n <div\n class={cn('relative flex min-h-0 flex-1 flex-col', local.class)}\n data-slot=\"message-scroller\"\n >\n <ConversationSurface\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n resetKey={local.resetKey}\n onFollowHold={(hold) => {\n holdFollow = hold\n }}\n {...rest}\n ref={(element) => {\n scroller = element\n if (typeof local.ref === 'function') local.ref(element)\n }}\n class=\"flex-1\"\n header={\n <>\n <Show when={local.hasOlder || local.loadingOlder}>\n <div\n ref={watchTop}\n data-slot=\"message-scroller-older\"\n class=\"flex justify-center py-2\"\n >\n <Show\n when={local.loadingOlder || inFlight()}\n fallback={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n class=\"gap-1.5 text-muted-foreground\"\n onClick={() => void load(true)}\n >\n <History aria-hidden=\"true\" />\n {local.olderLabel ?? 'Load earlier messages'}\n </Button>\n }\n >\n <p\n role=\"status\"\n // The button's own height: swapping one for the other must not move\n // the turns below it by even a pixel while the anchor is being held.\n class=\"flex h-control-sm items-center gap-1.5 text-xs text-muted-foreground\"\n >\n <LoaderCircle aria-hidden=\"true\" class=\"size-3.5 motion-safe:animate-spin\" />\n {local.loadingOlderLabel ?? 'Loading earlier messages…'}\n </p>\n </Show>\n </div>\n </Show>\n {local.header}\n </>\n }\n empty={local.empty}\n >\n {local.children}\n </ConversationSurface>\n <p role=\"status\" class=\"sr-only\">\n {local.announcement}\n </p>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;AA+DA,IAAM4B,aAAa;;AAGnB,IAAMC,uBAAuB;AAE7B,SAAgBC,gBAAgBC,OAA6B;CAC3D,MAAM,CAACC,OAAOC,QAAQ5B,WAAW0B,OAAO;EACtC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AA,OAAA,CAAAP,gBAE7BtG,SAAO,EAAA,eAAA,OAAA,CAAA,GAAAsH,WACPtF,MAAMV,cAAc,uBAAuB,CAAA;SAAA;QAAA,CAAA;OAAA;OAAA,IAAAuF,WAAA;QAAA,IAAAU,QAAAC,QAAA;QAAAnB,OAAAkB,OAAAjB,gBAU7CrG,cAAY;SAAA,eAAA;SAAA,SAAA;QAAA,CAAA,GAAA,IAAA;QAAAoG,OAAAkB,aACZvF,MAAMT,qBAAqB,6BAA2B,IAAA;QAAA,OAAAgG;OAAA;MAAA,CAAA,CAAA;MAAA,OAAAT;KAAA;IAAA,CAAA,GAAAQ,WAK9DtF,MAAMR,MAAM,CAAA;GAAA;GAAA,IAGjBE,QAAK;IAAA,OAAEM,MAAMN;GAAK;GAAA,IAAAmF,WAAA;IAAA,OAEjB7E,MAAM6E;GAAQ;EAAA,CAAA,CAAA,GAAAV,KAAA;EAAAE,OAAAF,aAGdnE,MAAML,YAAY;EAAA8F,aAAAC,UAAAzB,MA5DdzF,GAAG,yCAAyCwB,MAAM2F,KAAK,CAAC,CAAA;EAAA,OAAA1B;CAAA,EAAA,CAAA;AAgErE"}
1
+ {"version":3,"file":"message-scroller.js","names":["History","LoaderCircle","createEffect","onCleanup","Show","splitProps","createSignal","JSX","cn","Button","ConversationSurface","ConversationSurfaceProps","anchorIds","captureAnchor","restoreAnchor","ScrollAnchor","MessageScrollerProps","Omit","hasOlder","loadingOlder","onLoadOlder","Promise","olderLabel","loadingOlderLabel","header","Element","empty","announcement","TOP_MARGIN","MessageScroller","props","local","rest","scroller","HTMLDivElement","content","afterHostLoad","resume","undefined","holdFollow","epoch","inFlight","setInFlight","nativeAnchoring","holdNativeAnchoring","style","overflowAnchor","releaseNativeAnchoring","resetKey","stopWatching","settle","anchor","run","heightBefore","restoreFocus","releaseHold","finish","document","activeElement","body","again","querySelector","HTMLElement","focus","preventScroll","scrollTop","scrollHeight","load","afterInsert","requestAnimationFrame","observer","MutationObserver","resizer","ResizeObserver","unfollow","disconnect","fromControl","closest","observe","childList","subtree","follow","addEventListener","passive","watched","removeEventListener","resolve","catch","watchTop","element","IntersectionObserver","io","entries","some","entry","isIntersecting","root","rootMargin","_el$","_tmpl$","_el$2","firstChild","_$insert","_$createComponent","_$mergeProps","role","contentRef","onFollowHold","hold","ref","when","children","_el$3","_tmpl$3","_$use","fallback","type","variant","size","onClick","_$memo","_el$4","_tmpl$2","_$effect","_$className","class","_$createComponent","_$mergeProps","_$memo","_$className"],"sources":["../../../../src/components/composites/message-scroller/message-scroller.tsx"],"sourcesContent":["import { History, LoaderCircle } from 'lucide-solid'\nimport { createEffect, onCleanup, Show, splitProps, createSignal, type JSX } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { ConversationSurface, type ConversationSurfaceProps } from '../../conversation'\nimport { anchorIds, captureAnchor, restoreAnchor, type ScrollAnchor } from './scroll-anchor'\n\n/**\n * MessageScroller.\n *\n * The thread. It owns the three scroll behaviours a chat gets wrong when each\n * is bolted on separately, and keeps them from fighting:\n *\n * 1. **Follow the reply only while the reader is at the bottom.** New and\n * streaming content scrolls into view when the reader is already at the end,\n * and never otherwise. Scrolling up parks the view; the \"Jump to latest\"\n * control brings it back. (This is `ConversationSurface`'s follow contract,\n * which this component wraps rather than reimplements.)\n * 2. **Load history without moving what the reader is looking at.** When the\n * reader reaches the top, `onLoadOlder` is asked for earlier turns. Turns\n * inserted *above* the viewport would normally push the visible content down\n * by exactly their height; here the first visible turn (found by\n * `data-anchor-id`, which `Message` sets from `anchorId`) is measured before\n * the load and put back to the same offset after it, on every layout change\n * until the load settles — so images and code blocks that size themselves\n * late do not jolt the view either. A \"Load earlier\" button is always present\n * while there is more, because the scroll trigger alone is unreachable to a\n * keyboard or switch user and fires nothing in a short pane.\n * 3. **Announce without flooding.** The scroller is a polite log, and a turn that\n * is still arriving marks itself `aria-busy`, so a screen reader waits for the\n * settled turn instead of reading every token. `announcement` is a separate\n * status region for the two moments that matter: a response starting and a\n * response finishing.\n *\n * What it does not own: which turns exist, their identity, or what \"older\"\n * means. The host passes children and a loader; a session switch is\n * `resetKey`, which re-arms follow and discards any in-flight anchor.\n */\nexport type MessageScrollerProps = Omit<ConversationSurfaceProps, 'header' | 'empty'> & {\n hasOlder?: boolean\n /** The host is loading earlier turns right now, whether or not this scroller asked. */\n loadingOlder?: boolean\n /**\n * Load earlier turns. The scroller preserves the reader's position across the\n * resulting insert whether the host resolves before or after rendering them. A\n * rejection is the host's to report: the control stays so the reader can retry.\n */\n onLoadOlder?: () => void | Promise<void>\n /** Words for the loader row; override for another language. */\n olderLabel?: string\n loadingOlderLabel?: string\n /** Rendered above the first turn, below the history control. */\n header?: JSX.Element\n empty?: JSX.Element\n /** A short sentence for the live status region (\"Assistant is responding\"). */\n announcement?: string\n}\n\n/** How far from the top counts as \"reached the top\", in px. */\nconst TOP_MARGIN = 160\n\nexport function MessageScroller(props: MessageScrollerProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'hasOlder',\n 'loadingOlder',\n 'onLoadOlder',\n 'olderLabel',\n 'loadingOlderLabel',\n 'header',\n 'empty',\n 'announcement',\n 'ref',\n 'resetKey',\n 'children',\n ])\n let scroller: HTMLDivElement | undefined\n let content: HTMLDivElement | undefined\n // A load whose promise resolved while the host still reports `loadingOlder`: its\n // turns land when the host clears it, and the anchor is held until then.\n let afterHostLoad: (() => void) | undefined\n createEffect(() => {\n if (local.loadingOlder || !afterHostLoad) return\n const resume = afterHostLoad\n afterHostLoad = undefined\n resume()\n })\n let holdFollow: (() => () => void) | undefined\n let epoch = 0\n const [inFlight, setInFlight] = createSignal(false)\n\n // While a load holds the reader's place, the browser's own scroll anchoring is\n // switched off: it moves the offset by the same insert, and the two corrections\n // would be added together.\n let nativeAnchoring: string | undefined\n const holdNativeAnchoring = () => {\n if (!scroller || nativeAnchoring !== undefined) return\n nativeAnchoring = scroller.style.overflowAnchor\n scroller.style.overflowAnchor = 'none'\n }\n const releaseNativeAnchoring = () => {\n if (scroller && nativeAnchoring !== undefined) scroller.style.overflowAnchor = nativeAnchoring\n nativeAnchoring = undefined\n }\n\n // A session switch invalidates a load that was started for the previous one.\n createEffect(() => {\n void local.resetKey\n epoch += 1\n afterHostLoad = undefined\n setInFlight(false)\n stopWatching()\n releaseNativeAnchoring()\n })\n\n const settle = (\n anchor: ScrollAnchor | undefined,\n run: number,\n heightBefore: number,\n restoreFocus: boolean,\n releaseHold?: () => void\n ) => {\n const finish = () => {\n if (run !== epoch) return releaseHold?.()\n if (scroller) restoreAnchor(scroller, anchor)\n stopWatching()\n releaseNativeAnchoring()\n setInFlight(false)\n // The control that started the load was replaced by the loading line, which\n // takes focus with it. Put it back on the control (or the thread), so a\n // keyboard user is not dropped onto the page.\n if (restoreFocus && scroller && document.activeElement === document.body) {\n const again = scroller.querySelector<HTMLElement>(\n '[data-slot=\"message-scroller-older\"] button'\n )\n ;(again ?? scroller).focus({ preventScroll: true })\n }\n // Still at the top after a load that added content: keep going, so a\n // pane taller than one page of history fills without a second scroll.\n if (\n scroller &&\n local.hasOlder &&\n scroller.scrollTop < TOP_MARGIN &&\n scroller.scrollHeight > heightBefore\n )\n void load()\n releaseHold?.()\n }\n // Two frames: the first lets the host's insert commit, the second lets\n // late-sizing content (images, highlighted code) report its height.\n const afterInsert = () =>\n requestAnimationFrame(() =>\n requestAnimationFrame(() => {\n if (run !== epoch) return releaseHold?.()\n if (local.loadingOlder) afterHostLoad = afterInsert\n else finish()\n })\n )\n afterInsert()\n }\n\n let observer: MutationObserver | undefined\n let resizer: ResizeObserver | undefined\n let unfollow: (() => void) | undefined\n const stopWatching = () => {\n observer?.disconnect()\n resizer?.disconnect()\n unfollow?.()\n unfollow = undefined\n }\n const load = async (fromControl = false) => {\n if (!scroller || !local.onLoadOlder || !local.hasOlder || local.loadingOlder || inFlight())\n return\n const run = epoch\n const anchor = captureAnchor(scroller, anchorIds(scroller))\n const heightBefore = scroller.scrollHeight\n const restoreFocus =\n fromControl && document.activeElement?.closest('[data-slot=\"message-scroller-older\"]') != null\n setInFlight(true)\n holdNativeAnchoring()\n // Every layout change while the load is open re-pins the anchor *before\n // paint*, which is what makes the insert invisible.\n stopWatching()\n observer = new MutationObserver(() => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n })\n observer.observe(scroller, { childList: true, subtree: true })\n // Turns that size themselves late (`content-visibility`, images, highlighted code)\n // move the anchor without adding or removing a node, and with the browser's own\n // anchoring held off nothing else would carry the reader through that.\n if (content && typeof ResizeObserver !== 'undefined') {\n resizer = new ResizeObserver(() => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n })\n resizer.observe(content)\n }\n // The reader may carry on scrolling while the host answers. A restore re-takes the\n // anchor on the turn they have come to, whichever of the observers or this event\n // reaches it first.\n const follow = () => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n }\n scroller.addEventListener('scroll', follow, { passive: true })\n const watched = scroller\n unfollow = () => watched.removeEventListener('scroll', follow)\n await Promise.resolve(local.onLoadOlder()).catch(() => undefined)\n // A load that outlived its conversation inserts into a thread whose reader it knows\n // nothing about, and the anchor it held is gone. What it does to the layout (rows\n // taking their height, a clamp, the insert itself) is not the reader scrolling, so the\n // follow position is held until the two frames the insert needs have passed.\n settle(anchor, run, heightBefore, restoreFocus, run !== epoch ? holdFollow?.() : undefined)\n }\n\n onCleanup(() => {\n epoch += 1\n stopWatching()\n releaseNativeAnchoring()\n })\n\n const watchTop = (element: HTMLDivElement) => {\n if (typeof IntersectionObserver === 'undefined') return\n const io = new IntersectionObserver(\n (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) void load()\n },\n { root: scroller ?? null, rootMargin: `${TOP_MARGIN}px 0px 0px 0px` }\n )\n io.observe(element)\n onCleanup(() => io.disconnect())\n }\n\n return (\n <div\n class={cn('relative flex min-h-0 flex-1 flex-col', local.class)}\n data-slot=\"message-scroller\"\n >\n <ConversationSurface\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n resetKey={local.resetKey}\n contentRef={(element) => {\n content = element\n }}\n onFollowHold={(hold) => {\n holdFollow = hold\n }}\n {...rest}\n ref={(element) => {\n scroller = element\n if (typeof local.ref === 'function') local.ref(element)\n }}\n class=\"flex-1\"\n header={\n <>\n <Show when={local.hasOlder || local.loadingOlder}>\n <div\n ref={watchTop}\n data-slot=\"message-scroller-older\"\n class=\"flex justify-center py-2\"\n >\n <Show\n when={local.loadingOlder || inFlight()}\n fallback={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n class=\"gap-1.5 text-muted-foreground\"\n onClick={() => void load(true)}\n >\n <History aria-hidden=\"true\" />\n {local.olderLabel ?? 'Load earlier messages'}\n </Button>\n }\n >\n <p\n role=\"status\"\n // The button's own height: swapping one for the other must not move\n // the turns below it by even a pixel while the anchor is being held.\n class=\"flex h-control-sm items-center gap-1.5 text-xs text-muted-foreground\"\n >\n <LoaderCircle aria-hidden=\"true\" class=\"size-3.5 motion-safe:animate-spin\" />\n {local.loadingOlderLabel ?? 'Loading earlier messages…'}\n </p>\n </Show>\n </div>\n </Show>\n {local.header}\n </>\n }\n empty={local.empty}\n >\n {local.children}\n </ConversationSurface>\n <p role=\"status\" class=\"sr-only\">\n {local.announcement}\n </p>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;AA2DA,IAAM4B,aAAa;AAEnB,SAAgBC,gBAAgBC,OAA6B;CAC3D,MAAM,CAACC,OAAOC,QAAQ3B,WAAWyB,OAAO;EACtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAAU,CACX;CACD,IAAIG;CACJ,IAAIE;CAGJ,IAAIC;CACJlC,mBAAmB;EACjB,IAAI6B,MAAMZ,gBAAgB,CAACiB,eAAe;EAC1C,MAAMC,SAASD;EACfA,gBAAgBE,KAAAA;EAChBD,OAAO;CACT,CAAC;CACD,IAAIE;CACJ,IAAIC,QAAQ;CACZ,MAAM,CAACC,UAAUC,eAAepC,aAAa,KAAK;CAKlD,IAAIqC;C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B,OAAAmB,OAAAlB,gBAU7CtG,cAAY;SAAA,eAAA;SAAA,SAAA;QAAA,CAAA,GAAA,IAAA;QAAAqG,OAAAmB,aACZ1F,MAAMR,qBAAqB,6BAA2B,IAAA;QAAA,OAAAkG;OAAA;MAAA,CAAA,CAAA;MAAA,OAAAT;KAAA;IAAA,CAAA,GAAAQ,WAK9DzF,MAAMP,MAAM,CAAA;GAAA;GAAA,IAGjBE,QAAK;IAAA,OAAEK,MAAML;GAAK;GAAA,IAAAqF,WAAA;IAAA,OAEjBhF,MAAMgF;GAAQ;EAAA,CAAA,CAAA,GAAAX,KAAA;EAAAE,OAAAF,aAGdrE,MAAMJ,YAAY;EAAAgG,aAAAC,UAAA1B,MA/Dd1F,GAAG,yCAAyCuB,MAAM8F,KAAK,CAAC,CAAA;EAAA,OAAA3B;CAAA,EAAA,CAAA;AAmErE"}
@@ -36,8 +36,6 @@ export type ScrollAnchor = {
36
36
  ends: Map<string, number>;
37
37
  /** Fallback when no turn carries an id: the scroll height at the last restore. */
38
38
  scrollHeight: number;
39
- /** The scroll offset at the last restore. */
40
- scrollTop: number;
41
39
  /**
42
40
  * When set, only these turns are marked: the ones that were there when the load began.
43
41
  * A turn that has just landed is still at its estimated height, so a correction taken
@@ -47,7 +45,10 @@ export type ScrollAnchor = {
47
45
  };
48
46
  /** The ids of the turns in the scroller now. */
49
47
  export declare function anchorIds(scroller: HTMLElement): Set<string>;
50
- /** Mark the turns around the viewport: where each sits in the document now. */
48
+ /**
49
+ * Mark the turns around the viewport: where each sits in the document now. With
50
+ * `known`, only those turns are marked, now and on every later restore.
51
+ */
51
52
  export declare function captureAnchor(scroller: HTMLElement, known?: ReadonlySet<string>): ScrollAnchor;
52
53
  /**
53
54
  * Put the reader back where the content's movement left them. Returns the correction
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-anchor.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/message-scroller/scroll-anchor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,iGAAiG;IACjG,EAAE,EAAE,MAAM,GAAG,SAAS,CAAA;IACtB;;;;OAIG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC1B,+FAA+F;IAC/F,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAA;IACpB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAC5B,CAAA;AAQD,gDAAgD;AAChD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAK5D;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,YAAY,CAmC9F;AA8BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CA4B7F"}
1
+ {"version":3,"file":"scroll-anchor.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/message-scroller/scroll-anchor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,iGAAiG;IACjG,EAAE,EAAE,MAAM,GAAG,SAAS,CAAA;IACtB;;;;OAIG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC1B,+FAA+F;IAC/F,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAC5B,CAAA;AAQD,gDAAgD;AAChD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAK5D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,YAAY,CAmC9F;AA8BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CA2B7F"}
@@ -9,7 +9,10 @@ function anchorIds(scroller) {
9
9
  for (const element of scroller.querySelectorAll(`[${ANCHOR_ATTRIBUTE}]`)) ids.add(element.getAttribute(ANCHOR_ATTRIBUTE));
10
10
  return ids;
11
11
  }
12
- /** Mark the turns around the viewport: where each sits in the document now. */
12
+ /**
13
+ * Mark the turns around the viewport: where each sits in the document now. With
14
+ * `known`, only those turns are marked, now and on every later restore.
15
+ */
13
16
  function captureAnchor(scroller, known) {
14
17
  const box = scroller.getBoundingClientRect();
15
18
  const scrollTop = scroller.scrollTop;
@@ -53,7 +56,7 @@ function captureAnchor(scroller, known) {
53
56
  marks,
54
57
  ends,
55
58
  scrollHeight: scroller.scrollHeight,
56
- scrollTop
59
+ known
57
60
  };
58
61
  }
59
62
  /**
@@ -112,7 +115,6 @@ function restoreAnchor(scroller, anchor) {
112
115
  for (const [id, position] of anchor.marks) anchor.marks.set(id, position + correction);
113
116
  for (const [id, end] of anchor.ends) anchor.ends.set(id, end + correction);
114
117
  }
115
- anchor.scrollTop = scroller.scrollTop;
116
118
  anchor.scrollHeight = scroller.scrollHeight;
117
119
  return correction;
118
120
  }