@opengeni/react 4.0.2 → 4.0.5-canary.39120434730001

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 (916) hide show
  1. package/README.md +787 -26
  2. package/dist/accounts.js +2 -0
  3. package/dist/accounts.js.map +1 -1
  4. package/dist/approvals.d.ts +2 -1
  5. package/dist/artifacts-document.js +6 -3
  6. package/dist/artifacts-presentation.js +6 -3
  7. package/dist/artifacts-spreadsheet.d.ts +1 -1
  8. package/dist/artifacts-spreadsheet.js +6 -3
  9. package/dist/artifacts.d.ts +5 -1
  10. package/dist/artifacts.js +542 -278
  11. package/dist/artifacts.js.map +1 -1
  12. package/dist/browser-viewer-GEHX3KYE.js +20 -0
  13. package/dist/capability-catalog-row.d.ts +20 -0
  14. package/dist/capability-logo-fallback.d.ts +3 -0
  15. package/dist/chat-interactive-block-5V3BGLXT.js +15 -0
  16. package/dist/chunk-2DDJ6YH6.js +41 -0
  17. package/dist/chunk-2DDJ6YH6.js.map +1 -0
  18. package/dist/chunk-2EGXXUG4.js +1161 -0
  19. package/dist/chunk-2EGXXUG4.js.map +1 -0
  20. package/dist/chunk-2XKRY4GF.js +302 -0
  21. package/dist/chunk-2XKRY4GF.js.map +1 -0
  22. package/dist/chunk-2ZUUIMBY.js +343 -0
  23. package/dist/chunk-2ZUUIMBY.js.map +1 -0
  24. package/dist/chunk-4F4FGCH2.js +34 -0
  25. package/dist/chunk-4F4FGCH2.js.map +1 -0
  26. package/dist/{chunk-Z7WBDB4E.js → chunk-4M2MJLY3.js} +848 -867
  27. package/dist/chunk-4M2MJLY3.js.map +1 -0
  28. package/dist/chunk-4U7SHFQ2.js +193 -0
  29. package/dist/chunk-4U7SHFQ2.js.map +1 -0
  30. package/dist/chunk-5I4VRWBB.js +56 -0
  31. package/dist/chunk-5I4VRWBB.js.map +1 -0
  32. package/dist/{chunk-24M4YBCL.js → chunk-62XZ3IX3.js} +1751 -845
  33. package/dist/chunk-62XZ3IX3.js.map +1 -0
  34. package/dist/chunk-77THWHSU.js +308 -0
  35. package/dist/chunk-77THWHSU.js.map +1 -0
  36. package/dist/chunk-7CZLTFXF.js +466 -0
  37. package/dist/chunk-7CZLTFXF.js.map +1 -0
  38. package/dist/chunk-7N5AD2TC.js +327 -0
  39. package/dist/chunk-7N5AD2TC.js.map +1 -0
  40. package/dist/chunk-7SZ7MMCY.js +325 -0
  41. package/dist/chunk-7SZ7MMCY.js.map +1 -0
  42. package/dist/chunk-7TG6KTR2.js +3153 -0
  43. package/dist/chunk-7TG6KTR2.js.map +1 -0
  44. package/dist/chunk-AIX25FIQ.js +409 -0
  45. package/dist/chunk-AIX25FIQ.js.map +1 -0
  46. package/dist/chunk-AT2HD6RQ.js +1936 -0
  47. package/dist/chunk-AT2HD6RQ.js.map +1 -0
  48. package/dist/chunk-B27E3V37.js +29 -0
  49. package/dist/chunk-B27E3V37.js.map +1 -0
  50. package/dist/{chunk-5M6VTFJ5.js → chunk-B4EDAXMC.js} +37 -13
  51. package/dist/chunk-B4EDAXMC.js.map +1 -0
  52. package/dist/chunk-BOG2FED3.js +35 -0
  53. package/dist/chunk-BOG2FED3.js.map +1 -0
  54. package/dist/chunk-BQYQU5QW.js +109 -0
  55. package/dist/chunk-BQYQU5QW.js.map +1 -0
  56. package/dist/{chunk-PAJU5KKL.js → chunk-BRIOXCLH.js} +68 -25
  57. package/dist/chunk-BRIOXCLH.js.map +1 -0
  58. package/dist/chunk-CM7LVUKC.js +35 -0
  59. package/dist/chunk-CM7LVUKC.js.map +1 -0
  60. package/dist/{chunk-KCGXPP5V.js → chunk-CXIGFHVL.js} +35 -23
  61. package/dist/chunk-CXIGFHVL.js.map +1 -0
  62. package/dist/chunk-DHXKEJBH.js +71 -0
  63. package/dist/chunk-DHXKEJBH.js.map +1 -0
  64. package/dist/{chunk-NOSYBS2D.js → chunk-DN3TKURW.js} +12 -9
  65. package/dist/chunk-DN3TKURW.js.map +1 -0
  66. package/dist/chunk-DNJ23AWQ.js +35 -0
  67. package/dist/chunk-DNJ23AWQ.js.map +1 -0
  68. package/dist/chunk-ESAMXNBZ.js +3237 -0
  69. package/dist/chunk-ESAMXNBZ.js.map +1 -0
  70. package/dist/{chunk-4MDLEHXL.js → chunk-EWATYP5L.js} +64 -44
  71. package/dist/chunk-EWATYP5L.js.map +1 -0
  72. package/dist/{chunk-YBM6CQRU.js → chunk-FQ5CXNUG.js} +65 -42
  73. package/dist/chunk-FQ5CXNUG.js.map +1 -0
  74. package/dist/chunk-FVROZ7HR.js +14396 -0
  75. package/dist/chunk-FVROZ7HR.js.map +1 -0
  76. package/dist/chunk-HEVQKE27.js +150 -0
  77. package/dist/chunk-HEVQKE27.js.map +1 -0
  78. package/dist/chunk-HZ47S3DP.js +1086 -0
  79. package/dist/chunk-HZ47S3DP.js.map +1 -0
  80. package/dist/chunk-I5BJ7ENY.js +174 -0
  81. package/dist/chunk-I5BJ7ENY.js.map +1 -0
  82. package/dist/chunk-IGFZFLI2.js +1390 -0
  83. package/dist/chunk-IGFZFLI2.js.map +1 -0
  84. package/dist/chunk-IGVL3ELX.js +46 -0
  85. package/dist/chunk-IGVL3ELX.js.map +1 -0
  86. package/dist/chunk-IOD24LGR.js +384 -0
  87. package/dist/chunk-IOD24LGR.js.map +1 -0
  88. package/dist/chunk-IOYHDEP3.js +38 -0
  89. package/dist/chunk-IOYHDEP3.js.map +1 -0
  90. package/dist/chunk-IQL77TMM.js +803 -0
  91. package/dist/chunk-IQL77TMM.js.map +1 -0
  92. package/dist/chunk-IZV5FTJC.js +55 -0
  93. package/dist/chunk-IZV5FTJC.js.map +1 -0
  94. package/dist/{chunk-H5YGYNXS.js → chunk-JAYYFOOB.js} +75 -28
  95. package/dist/chunk-JAYYFOOB.js.map +1 -0
  96. package/dist/chunk-KN2MYSCC.js +409 -0
  97. package/dist/chunk-KN2MYSCC.js.map +1 -0
  98. package/dist/{chunk-PEI6RANI.js → chunk-KYVJMTXL.js} +434 -145
  99. package/dist/chunk-KYVJMTXL.js.map +1 -0
  100. package/dist/{chunk-ZYRGEKWS.js → chunk-LJUMYUBO.js} +3 -1
  101. package/dist/{chunk-ZYRGEKWS.js.map → chunk-LJUMYUBO.js.map} +1 -1
  102. package/dist/{chunk-ICA6R6TW.js → chunk-LNUD3JNI.js} +1532 -395
  103. package/dist/chunk-LNUD3JNI.js.map +1 -0
  104. package/dist/chunk-M357MHH3.js +2 -0
  105. package/dist/{chunk-BV5A4OTE.js → chunk-MEL6PH2I.js} +1218 -537
  106. package/dist/chunk-MEL6PH2I.js.map +1 -0
  107. package/dist/chunk-MF6WS2XF.js +386 -0
  108. package/dist/chunk-MF6WS2XF.js.map +1 -0
  109. package/dist/chunk-MK2TQO4Y.js +24 -0
  110. package/dist/chunk-MK2TQO4Y.js.map +1 -0
  111. package/dist/chunk-N7S72EXK.js +25 -0
  112. package/dist/chunk-N7S72EXK.js.map +1 -0
  113. package/dist/{chunk-KZ73RL76.js → chunk-NAWXARTY.js} +58 -9
  114. package/dist/chunk-NAWXARTY.js.map +1 -0
  115. package/dist/chunk-NX4ADH73.js +14 -0
  116. package/dist/chunk-NX4ADH73.js.map +1 -0
  117. package/dist/chunk-OYQQJL3J.js +16 -0
  118. package/dist/chunk-OYQQJL3J.js.map +1 -0
  119. package/dist/chunk-P4MKPCTC.js +51 -0
  120. package/dist/chunk-P4MKPCTC.js.map +1 -0
  121. package/dist/{chunk-JVYQRRC4.js → chunk-PEHTX3V7.js} +21 -1
  122. package/dist/chunk-PEHTX3V7.js.map +1 -0
  123. package/dist/chunk-PMV53IMM.js +26 -0
  124. package/dist/chunk-PMV53IMM.js.map +1 -0
  125. package/dist/{chunk-HUIKIDM5.js → chunk-QOEWDOFW.js} +295 -156
  126. package/dist/chunk-QOEWDOFW.js.map +1 -0
  127. package/dist/chunk-QV3DJVRZ.js +11 -0
  128. package/dist/chunk-QV3DJVRZ.js.map +1 -0
  129. package/dist/{chunk-HUMIRRYI.js → chunk-QYUYVSNG.js} +1103 -1699
  130. package/dist/chunk-QYUYVSNG.js.map +1 -0
  131. package/dist/{chunk-6J56T3MG.js → chunk-RRAQ5FV5.js} +186 -60
  132. package/dist/chunk-RRAQ5FV5.js.map +1 -0
  133. package/dist/{chunk-5YK2ZDIG.js → chunk-TNEZNMSN.js} +4 -10
  134. package/dist/chunk-TNEZNMSN.js.map +1 -0
  135. package/dist/{chunk-22KP6LR5.js → chunk-TXS65BB2.js} +3 -1
  136. package/dist/{chunk-22KP6LR5.js.map → chunk-TXS65BB2.js.map} +1 -1
  137. package/dist/chunk-UIWIOB4U.js +2215 -0
  138. package/dist/chunk-UIWIOB4U.js.map +1 -0
  139. package/dist/chunk-UNJPZGNK.js +63 -0
  140. package/dist/chunk-UNJPZGNK.js.map +1 -0
  141. package/dist/chunk-V7UGCQHQ.js +86 -0
  142. package/dist/chunk-V7UGCQHQ.js.map +1 -0
  143. package/dist/chunk-VU4QUISJ.js +3405 -0
  144. package/dist/chunk-VU4QUISJ.js.map +1 -0
  145. package/dist/chunk-WEY5J52U.js +467 -0
  146. package/dist/chunk-WEY5J52U.js.map +1 -0
  147. package/dist/chunk-WH2CBESG.js +409 -0
  148. package/dist/chunk-WH2CBESG.js.map +1 -0
  149. package/dist/{chunk-VZTQ73XT.js → chunk-XEA5BCMA.js} +3 -1
  150. package/dist/{chunk-VZTQ73XT.js.map → chunk-XEA5BCMA.js.map} +1 -1
  151. package/dist/{chunk-NLTS7JHI.js → chunk-XEIHS3RN.js} +834 -403
  152. package/dist/chunk-XEIHS3RN.js.map +1 -0
  153. package/dist/chunk-YNXZRE3F.js +408 -0
  154. package/dist/chunk-YNXZRE3F.js.map +1 -0
  155. package/dist/chunk-YSRBFJMQ.js +43 -0
  156. package/dist/chunk-YSRBFJMQ.js.map +1 -0
  157. package/dist/{chunk-NEXLLTP4.js → chunk-ZGFU4LVW.js} +6 -5
  158. package/dist/chunk-ZGFU4LVW.js.map +1 -0
  159. package/dist/chunk-ZO35BAMO.js +172 -0
  160. package/dist/chunk-ZO35BAMO.js.map +1 -0
  161. package/dist/chunk-ZUWF4NF7.js +13 -0
  162. package/dist/chunk-ZUWF4NF7.js.map +1 -0
  163. package/dist/client.d.ts +15 -6
  164. package/dist/clipboard.js +3 -1
  165. package/dist/commands/registry.d.ts +2 -1
  166. package/dist/commands/types.d.ts +2 -0
  167. package/dist/components/anthropic-mark.d.ts +3 -0
  168. package/dist/components/approval-surface.d.ts +21 -7
  169. package/dist/components/artifacts/artifact-chrome.d.ts +121 -0
  170. package/dist/components/artifacts/artifact-sandbox.d.ts +30 -0
  171. package/dist/components/artifacts/artifact-surface.d.ts +4 -2
  172. package/dist/components/artifacts/chat-interactive-block.d.ts +29 -0
  173. package/dist/components/artifacts/deferred-chat-media.d.ts +15 -0
  174. package/dist/components/artifacts/document-editor.d.ts +4 -2
  175. package/dist/components/artifacts/editable-artifact-ui.d.ts +4 -2
  176. package/dist/components/artifacts/editable-artifact-view.d.ts +48 -0
  177. package/dist/components/artifacts/editable-document.d.ts +3 -2
  178. package/dist/components/artifacts/editable-presentation.d.ts +4 -3
  179. package/dist/components/artifacts/editable-spreadsheet.d.ts +8 -3
  180. package/dist/components/artifacts/index.d.ts +8 -1
  181. package/dist/components/artifacts/inline-html-document.d.ts +2 -0
  182. package/dist/components/artifacts/latest-task-runner.d.ts +15 -0
  183. package/dist/components/artifacts/presentation-editor.d.ts +6 -2
  184. package/dist/components/artifacts/published-html-artifact-frame.d.ts +17 -40
  185. package/dist/components/artifacts/session-artifact-viewer.d.ts +39 -0
  186. package/dist/components/artifacts/site-view.d.ts +26 -0
  187. package/dist/components/artifacts/spreadsheet-command-queue.d.ts +20 -0
  188. package/dist/components/artifacts/spreadsheet-download.d.ts +7 -0
  189. package/dist/components/artifacts/spreadsheet-general-display.d.ts +24 -0
  190. package/dist/components/artifacts/spreadsheet-grid.d.ts +11 -4
  191. package/dist/components/artifacts/spreadsheet-resize.d.ts +50 -0
  192. package/dist/components/artifacts/spreadsheet-submissions.d.ts +9 -0
  193. package/dist/components/artifacts/visualization-assets.gen.d.ts +2 -0
  194. package/dist/components/browser-select-control.d.ts +16 -0
  195. package/dist/components/browser-viewer.d.ts +11 -2
  196. package/dist/components/chat-composer.d.ts +21 -3
  197. package/dist/components/child-session-link.d.ts +5 -1
  198. package/dist/components/claude-mark.d.ts +3 -0
  199. package/dist/components/code-editor.d.ts +1 -4
  200. package/dist/components/command-palette.d.ts +1 -1
  201. package/dist/components/composer-transcription-control.d.ts +7 -0
  202. package/dist/components/composer.d.ts +30 -67
  203. package/dist/components/computer-viewer.d.ts +1 -1
  204. package/dist/components/copy-button.d.ts +3 -1
  205. package/dist/components/desktop-viewer.d.ts +1 -1
  206. package/dist/components/generated-video-player.d.ts +1 -1
  207. package/dist/components/grok-mark.d.ts +26 -0
  208. package/dist/components/human-input-form.d.ts +26 -32
  209. package/dist/components/human-input-surface.d.ts +5 -1
  210. package/dist/components/linkified-text.d.ts +18 -0
  211. package/dist/components/machine-input-display.d.ts +25 -3
  212. package/dist/components/machine-status-pill.d.ts +3 -2
  213. package/dist/components/machines/agent-status-icon.d.ts +6 -0
  214. package/dist/components/machines/health.d.ts +2 -1
  215. package/dist/components/machines/machine-detail.d.ts +7 -1
  216. package/dist/components/machines/machine-status.d.ts +49 -0
  217. package/dist/components/machines/metric-history-chart.d.ts +1 -1
  218. package/dist/components/machines/series.d.ts +3 -2
  219. package/dist/components/markdown-table-layout.d.ts +11 -2
  220. package/dist/components/markdown.d.ts +37 -4
  221. package/dist/components/message-timeline.d.ts +79 -7
  222. package/dist/components/model-mark.d.ts +29 -0
  223. package/dist/components/model-picker.d.ts +1 -1
  224. package/dist/components/model-policy-picker.d.ts +31 -22
  225. package/dist/components/new-conversation.d.ts +32 -0
  226. package/dist/components/open-geni-chat.d.ts +73 -0
  227. package/dist/components/open-geni-links.d.ts +69 -0
  228. package/dist/components/openrouter-mark.d.ts +6 -0
  229. package/dist/components/opper-mark.d.ts +7 -0
  230. package/dist/components/preview-loading.d.ts +2 -0
  231. package/dist/components/provider-recovery-notice.d.ts +17 -0
  232. package/dist/components/queue-item-content.d.ts +10 -0
  233. package/dist/components/rehype-secret-refs.d.ts +23 -0
  234. package/dist/components/remark-soft-line-breaks.d.ts +38 -0
  235. package/dist/components/sandbox-workspace.d.ts +18 -0
  236. package/dist/components/secret-question-field.d.ts +31 -0
  237. package/dist/components/secret-ref-chip.d.ts +35 -0
  238. package/dist/components/session-capability-frame.d.ts +37 -0
  239. package/dist/components/session-chrome.d.ts +20 -7
  240. package/dist/components/session-commands.d.ts +6 -0
  241. package/dist/components/session-connection-request.d.ts +8 -0
  242. package/dist/components/session-conversation.d.ts +147 -6
  243. package/dist/components/session-list.d.ts +39 -0
  244. package/dist/components/session-mcp-capability-card.d.ts +41 -0
  245. package/dist/components/session-proxy-scope.d.ts +35 -0
  246. package/dist/components/session-status.d.ts +6 -2
  247. package/dist/components/session-usage-limit-notice.d.ts +39 -0
  248. package/dist/components/this-computer/illustrations.d.ts +38 -0
  249. package/dist/components/this-computer/labels.d.ts +111 -0
  250. package/dist/components/this-computer/this-computer-card.d.ts +40 -0
  251. package/dist/components/this-computer/this-computer-setup.d.ts +35 -0
  252. package/dist/components/this-computer/this-computer-status.d.ts +42 -0
  253. package/dist/components/this-computer/use-this-computer.d.ts +29 -0
  254. package/dist/components/timeline-anchor.d.ts +3 -0
  255. package/dist/components/timeline-annotation-shared.d.ts +3 -2
  256. package/dist/components/timeline-annotations-dialog.d.ts +2 -1
  257. package/dist/components/timeline-annotations.d.ts +5 -1
  258. package/dist/components/timeline-reading-progress.d.ts +11 -0
  259. package/dist/components/timeline-search.d.ts +34 -0
  260. package/dist/components/timeline-settlement.d.ts +16 -0
  261. package/dist/components/tool-action-review.d.ts +48 -0
  262. package/dist/components/tool-review-history.d.ts +25 -0
  263. package/dist/components/usage-limit-notice.d.ts +50 -0
  264. package/dist/components/usage-member-list.d.ts +92 -0
  265. package/dist/components/usage-meter.d.ts +74 -0
  266. package/dist/components/use-viewer-menu-dismiss.d.ts +2 -0
  267. package/dist/components/user-message-body.d.ts +10 -1
  268. package/dist/components/workbench-changes.d.ts +2 -1
  269. package/dist/composer-messages.d.ts +75 -0
  270. package/dist/composer-messages.js +9 -0
  271. package/dist/composer-messages.js.map +1 -0
  272. package/dist/composer-voice-events.d.ts +8 -0
  273. package/dist/composer.d.ts +3 -3
  274. package/dist/composer.js +25 -12
  275. package/dist/computer-viewer-VOIOZGVZ.js +21 -0
  276. package/dist/computer-viewer-VOIOZGVZ.js.map +1 -0
  277. package/dist/connect-account-identity.d.ts +8 -0
  278. package/dist/connect-accounts.d.ts +15 -0
  279. package/dist/connect-chooser.d.ts +18 -0
  280. package/dist/connect-panel.d.ts +18 -0
  281. package/dist/connect-setup.d.ts +18 -0
  282. package/dist/connect.d.ts +21 -0
  283. package/dist/connect.js +2216 -0
  284. package/dist/connect.js.map +1 -0
  285. package/dist/connection-catalog.d.ts +38 -0
  286. package/dist/connection-discovery.d.ts +12 -0
  287. package/dist/connection-installed.d.ts +17 -0
  288. package/dist/connection-logo.d.ts +9 -0
  289. package/dist/connection-service-logo.d.ts +8 -0
  290. package/dist/connection-service-presentation.d.ts +13 -0
  291. package/dist/connection-skeleton.d.ts +5 -0
  292. package/dist/connection-type-picker.d.ts +6 -0
  293. package/dist/conversation-timeline.d.ts +1 -1
  294. package/dist/desktop.d.ts +7 -0
  295. package/dist/desktop.js +28 -0
  296. package/dist/desktop.js.map +1 -0
  297. package/dist/device-authorization.d.ts +23 -0
  298. package/dist/diffs.d.ts +8 -0
  299. package/dist/diffs.js +15 -0
  300. package/dist/diffs.js.map +1 -0
  301. package/dist/discovery-cache.d.ts +5 -0
  302. package/dist/editor.d.ts +7 -0
  303. package/dist/editor.js +23 -0
  304. package/dist/editor.js.map +1 -0
  305. package/dist/embedded-new-voice-KPLC5UJZ.js +19 -0
  306. package/dist/embedded-new-voice-KPLC5UJZ.js.map +1 -0
  307. package/dist/embedded-voice-V2RFSLIU.js +19 -0
  308. package/dist/embedded-voice-V2RFSLIU.js.map +1 -0
  309. package/dist/fleet-decision-row-FE73NSQ6.js +361 -0
  310. package/dist/fleet-decision-row-FE73NSQ6.js.map +1 -0
  311. package/dist/hooks/internal.d.ts +27 -2
  312. package/dist/hooks/latest-question.d.ts +26 -0
  313. package/dist/hooks/session-view-cache.d.ts +38 -0
  314. package/dist/hooks/shared-machines-list.d.ts +4 -0
  315. package/dist/hooks/shared-query.d.ts +123 -0
  316. package/dist/hooks/use-attached-browsers.d.ts +1 -1
  317. package/dist/hooks/use-auth-runs.d.ts +1 -4
  318. package/dist/hooks/use-available-models.d.ts +8 -3
  319. package/dist/hooks/use-browser-frame-stream.d.ts +1 -1
  320. package/dist/hooks/use-browser-session.d.ts +12 -1
  321. package/dist/hooks/use-client-config-flags.d.ts +49 -0
  322. package/dist/hooks/use-codex-accounts.d.ts +48 -9
  323. package/dist/hooks/use-composer.d.ts +24 -3
  324. package/dist/hooks/use-computer-frame-stream.d.ts +1 -1
  325. package/dist/hooks/use-computer-input-posture.d.ts +13 -0
  326. package/dist/hooks/use-computer-session.d.ts +5 -0
  327. package/dist/hooks/use-connect.d.ts +23 -0
  328. package/dist/hooks/use-desktop-stream.d.ts +1 -1
  329. package/dist/hooks/use-file-attachments.d.ts +4 -0
  330. package/dist/hooks/use-goal.d.ts +2 -1
  331. package/dist/hooks/use-last-started-turn-policy.d.ts +5 -1
  332. package/dist/hooks/use-machine-chip.d.ts +3 -2
  333. package/dist/hooks/use-new-conversation.d.ts +56 -0
  334. package/dist/hooks/use-new-session-draft.d.ts +74 -0
  335. package/dist/hooks/use-realtime-voice-models.d.ts +7 -0
  336. package/dist/hooks/use-sandbox-files.d.ts +3 -2
  337. package/dist/hooks/use-session-conversation.d.ts +49 -0
  338. package/dist/hooks/use-session-events.d.ts +21 -2
  339. package/dist/hooks/use-session-mcp-approval-policy.d.ts +2 -2
  340. package/dist/hooks/use-session-model-account.d.ts +48 -0
  341. package/dist/hooks/use-supergrok-accounts.d.ts +7 -1
  342. package/dist/hooks/use-terminal-stream.d.ts +11 -5
  343. package/dist/hooks/use-transcription.d.ts +2 -1
  344. package/dist/hooks/use-usage.d.ts +40 -0
  345. package/dist/hooks/use-vaults.d.ts +53 -0
  346. package/dist/hooks/use-voice-input.d.ts +8 -1
  347. package/dist/hooks/use-workspace-sessions.d.ts +24 -5
  348. package/dist/human-input-model.d.ts +123 -0
  349. package/dist/identity-link-accounts.d.ts +11 -0
  350. package/dist/identity-link-consent.d.ts +18 -0
  351. package/dist/index.d.ts +83 -18
  352. package/dist/index.js +2317 -6453
  353. package/dist/index.js.map +1 -1
  354. package/dist/interaction.d.ts +1 -1
  355. package/dist/interaction.js +20 -29
  356. package/dist/interaction.js.map +1 -1
  357. package/dist/latest-question-SXBXROBT.js +118 -0
  358. package/dist/latest-question-SXBXROBT.js.map +1 -0
  359. package/dist/lib/client-config-read.d.ts +31 -0
  360. package/dist/lib/clipboard.d.ts +7 -0
  361. package/dist/lib/error-message.d.ts +7 -0
  362. package/dist/lib/format.d.ts +59 -9
  363. package/dist/lib/host-theme.d.ts +77 -0
  364. package/dist/lib/interaction-errors.d.ts +3 -0
  365. package/dist/lib/menu-styles.d.ts +22 -0
  366. package/dist/lib/notify-observer.d.ts +2 -0
  367. package/dist/lib/pierre-diffs-loader.d.ts +20 -0
  368. package/dist/lib/provider-recovery.d.ts +56 -0
  369. package/dist/lib/scrollbars.d.ts +11 -0
  370. package/dist/lib/terminal-input-readiness.d.ts +11 -0
  371. package/dist/lib/transient-retry.d.ts +26 -0
  372. package/dist/lib/workbench-peers.d.ts +36 -0
  373. package/dist/lib/xterm-theme.d.ts +7 -5
  374. package/dist/machines.js +12 -6
  375. package/dist/{markdown-table-layout-3Z3AWBY7.js → markdown-table-layout-3PV2UAAH.js} +51 -9
  376. package/dist/markdown-table-layout-3PV2UAAH.js.map +1 -0
  377. package/dist/mcp-connection-status.d.ts +15 -0
  378. package/dist/messages/en.d.ts +3328 -0
  379. package/dist/messages/runtime.d.ts +69 -0
  380. package/dist/messages.d.ts +3 -0
  381. package/dist/messages.js +16 -0
  382. package/dist/messages.js.map +1 -0
  383. package/dist/model-mark-paths.d.ts +34 -0
  384. package/dist/model-mark-paths.js +16 -0
  385. package/dist/model-mark-paths.js.map +1 -0
  386. package/dist/model-picker-model.d.ts +112 -0
  387. package/dist/model-picker-model.js +25 -0
  388. package/dist/model-picker-model.js.map +1 -0
  389. package/dist/model-policy-picker-menu-NWIETWSR.js +18 -0
  390. package/dist/model-policy-picker-menu-NWIETWSR.js.map +1 -0
  391. package/dist/model-policy.d.ts +35 -10
  392. package/dist/model-policy.js +12 -1
  393. package/dist/native-previews.d.ts +29 -0
  394. package/dist/native-previews.js +82 -0
  395. package/dist/native-previews.js.map +1 -0
  396. package/dist/new-session-draft.d.ts +7 -0
  397. package/dist/new-session-draft.js +639 -0
  398. package/dist/new-session-draft.js.map +1 -0
  399. package/dist/notification-text.d.ts +27 -0
  400. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js → noto-sans-arabic-loader-XSH2KYWJ.js} +3 -1
  401. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js.map → noto-sans-arabic-loader-XSH2KYWJ.js.map} +1 -1
  402. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js → noto-sans-jp-loader.generated-MR5L6V7K.js} +3 -1
  403. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js.map → noto-sans-jp-loader.generated-MR5L6V7K.js.map} +1 -1
  404. package/dist/organization-model.d.ts +33 -0
  405. package/dist/organization-model.js +65 -0
  406. package/dist/organization-model.js.map +1 -0
  407. package/dist/platform-activity-row-VSQ2FZ5T.js +119 -0
  408. package/dist/platform-activity-row-VSQ2FZ5T.js.map +1 -0
  409. package/dist/plugin-details.d.ts +14 -0
  410. package/dist/plugin-discovery.d.ts +25 -0
  411. package/dist/preview-loading-paint.d.ts +20 -0
  412. package/dist/provider.d.ts +37 -2
  413. package/dist/queue-presentation-model.d.ts +73 -0
  414. package/dist/queue-presentation-model.js +38 -0
  415. package/dist/queue-presentation-model.js.map +1 -0
  416. package/dist/{queue-surface-implementation-LK3S4BIW.js → queue-surface-implementation-MEKXXWGR.js} +189 -343
  417. package/dist/queue-surface-implementation-MEKXXWGR.js.map +1 -0
  418. package/dist/realtime/embedded-new-voice.d.ts +1 -0
  419. package/dist/realtime/embedded-voice.d.ts +1 -0
  420. package/dist/realtime/realtime-control.d.ts +4 -65
  421. package/dist/realtime/session-realtime.d.ts +79 -0
  422. package/dist/realtime.js +26 -1333
  423. package/dist/realtime.js.map +1 -1
  424. package/dist/sandbox-files-5NRC2QUT.js +24 -0
  425. package/dist/sandbox-files-5NRC2QUT.js.map +1 -0
  426. package/dist/sandbox-label-model.d.ts +31 -0
  427. package/dist/sandbox-label-model.js +20 -0
  428. package/dist/sandbox-label-model.js.map +1 -0
  429. package/dist/scrollbars.d.ts +1 -0
  430. package/dist/scrollbars.js +10 -0
  431. package/dist/scrollbars.js.map +1 -0
  432. package/dist/secret-reference-label.d.ts +15 -0
  433. package/dist/secrets-ui.d.ts +57 -0
  434. package/dist/session-agents-model.d.ts +11 -0
  435. package/dist/session-agents-model.js +25 -0
  436. package/dist/session-agents-model.js.map +1 -0
  437. package/dist/session-attention-model.d.ts +8 -0
  438. package/dist/session-attention-model.js +47 -0
  439. package/dist/session-attention-model.js.map +1 -0
  440. package/dist/session-auth-recommendation.d.ts +6 -0
  441. package/dist/session-capability-policy.d.ts +32 -0
  442. package/dist/session-context.d.ts +9 -1
  443. package/dist/session-feedback-model.d.ts +21 -0
  444. package/dist/session-feedback-model.js +56 -0
  445. package/dist/session-feedback-model.js.map +1 -0
  446. package/dist/session-list-model.d.ts +139 -0
  447. package/dist/session-list-model.js +274 -0
  448. package/dist/session-list-model.js.map +1 -0
  449. package/dist/session-realtime-OZCE6IKP.js +22 -0
  450. package/dist/session-realtime-OZCE6IKP.js.map +1 -0
  451. package/dist/session-realtime.d.ts +7 -0
  452. package/dist/session-realtime.js +20 -0
  453. package/dist/session-realtime.js.map +1 -0
  454. package/dist/session-status-model.d.ts +37 -0
  455. package/dist/session-ui.d.ts +40 -3
  456. package/dist/session-ui.js +127 -21
  457. package/dist/session-ui.js.map +1 -1
  458. package/dist/session.d.ts +10 -2
  459. package/dist/session.js +44 -20
  460. package/dist/site-snapshot.d.ts +14 -0
  461. package/dist/sites-ui.d.ts +24 -0
  462. package/dist/sites.d.ts +3 -0
  463. package/dist/sites.js +15 -0
  464. package/dist/sites.js.map +1 -0
  465. package/dist/skill-discovery.d.ts +47 -0
  466. package/dist/terminal.d.ts +8 -0
  467. package/dist/terminal.js +33 -0
  468. package/dist/terminal.js.map +1 -0
  469. package/dist/testing/session-scenarios.d.ts +10 -0
  470. package/dist/testing/session-scenarios.js +367 -0
  471. package/dist/testing/session-scenarios.js.map +1 -0
  472. package/dist/this-computer.d.ts +8 -0
  473. package/dist/this-computer.js +1042 -0
  474. package/dist/this-computer.js.map +1 -0
  475. package/dist/timeline/activity-rail.d.ts +12 -2
  476. package/dist/timeline/agent-identity.d.ts +30 -0
  477. package/dist/timeline/agent-row.d.ts +31 -0
  478. package/dist/timeline/allowance-exhausted-row.d.ts +24 -0
  479. package/dist/timeline/compaction-copy.d.ts +47 -0
  480. package/dist/timeline/focus-sequence.d.ts +9 -0
  481. package/dist/timeline/genie-copy.d.ts +4 -0
  482. package/dist/timeline/genie-loading.d.ts +48 -0
  483. package/dist/timeline/index.d.ts +12 -5
  484. package/dist/timeline/invoked-tool.d.ts +6 -0
  485. package/dist/timeline/knowledge-receipt.d.ts +17 -0
  486. package/dist/timeline/learning-refusal-copy.d.ts +23 -0
  487. package/dist/timeline/learning-refusal-row.d.ts +19 -0
  488. package/dist/timeline/message-sender.d.ts +19 -0
  489. package/dist/timeline/notice-presentation.d.ts +14 -0
  490. package/dist/timeline/parsers.d.ts +11 -0
  491. package/dist/timeline/patch-apply-command.d.ts +19 -0
  492. package/dist/timeline/platform-activity-presentation.d.ts +26 -0
  493. package/dist/timeline/platform-activity-row.d.ts +1 -2
  494. package/dist/timeline/presented-image.d.ts +11 -0
  495. package/dist/timeline/projection.d.ts +32 -2
  496. package/dist/timeline/provider-logo.d.ts +15 -0
  497. package/dist/timeline/question-nav-model.d.ts +23 -0
  498. package/dist/timeline/registry.d.ts +10 -1
  499. package/dist/timeline/retained-image.d.ts +18 -0
  500. package/dist/timeline/retained-loaders.d.ts +27 -0
  501. package/dist/timeline/rolling-activity.d.ts +11 -0
  502. package/dist/timeline/screenshot-lightbox.d.ts +23 -1
  503. package/dist/timeline/session-usage-limit-row.d.ts +11 -0
  504. package/dist/timeline/shared.d.ts +8 -3
  505. package/dist/timeline/startup-dispatch-details.d.ts +5 -0
  506. package/dist/timeline/startup-preference.d.ts +3 -0
  507. package/dist/timeline/startup-timings.d.ts +4 -0
  508. package/dist/timeline/tool-display-name.d.ts +6 -2
  509. package/dist/timeline/tool-presentation.d.ts +185 -0
  510. package/dist/timeline/turn-summary-model.d.ts +102 -0
  511. package/dist/timeline/turn-summary.d.ts +20 -54
  512. package/dist/timeline/types.d.ts +184 -7
  513. package/dist/timeline/work-presentation.d.ts +61 -0
  514. package/dist/{timeline-annotation-markers-DRSTLEM6.js → timeline-annotation-markers-HYLRTT6S.js} +11 -6
  515. package/dist/timeline-annotation-markers-HYLRTT6S.js.map +1 -0
  516. package/dist/{timeline-annotation-selection-IHLUGVND.js → timeline-annotation-selection-LBKW5GHA.js} +15 -5
  517. package/dist/timeline-annotation-selection-LBKW5GHA.js.map +1 -0
  518. package/dist/{timeline-annotations-dialog-6Q53N5FG.js → timeline-annotations-dialog-JKVINC42.js} +34 -19
  519. package/dist/timeline-annotations-dialog-JKVINC42.js.map +1 -0
  520. package/dist/timeline-model.d.ts +29 -0
  521. package/dist/timeline-model.js +254 -0
  522. package/dist/timeline-model.js.map +1 -0
  523. package/dist/usage/allowance-copy.d.ts +26 -0
  524. package/dist/usage/session-usage-limit.d.ts +89 -0
  525. package/dist/usage/summary.d.ts +35 -0
  526. package/dist/usage.d.ts +17 -0
  527. package/dist/usage.js +1201 -0
  528. package/dist/usage.js.map +1 -0
  529. package/dist/voice-recording-owner.d.ts +7 -0
  530. package/package.json +119 -7
  531. package/src/approvals.ts +8 -1
  532. package/src/artifacts-spreadsheet.ts +1 -0
  533. package/src/artifacts.ts +41 -0
  534. package/src/assets/README.md +8 -0
  535. package/src/assets/gmail.ico +0 -0
  536. package/src/assets/outlook.ico +0 -0
  537. package/src/capability-catalog-row.tsx +96 -0
  538. package/src/capability-logo-fallback.ts +22 -0
  539. package/src/client.ts +18 -30
  540. package/src/commands/registry.ts +46 -36
  541. package/src/commands/types.ts +2 -0
  542. package/src/components/anthropic-mark.tsx +10 -0
  543. package/src/components/approval-surface.tsx +407 -142
  544. package/src/components/artifacts/artifact-chrome.tsx +425 -0
  545. package/src/components/artifacts/artifact-sandbox.tsx +193 -0
  546. package/src/components/artifacts/artifact-surface.tsx +48 -26
  547. package/src/components/artifacts/chat-interactive-block.tsx +260 -0
  548. package/src/components/artifacts/deferred-chat-media.tsx +72 -0
  549. package/src/components/artifacts/document-editor.tsx +193 -45
  550. package/src/components/artifacts/editable-artifact-ui.tsx +23 -11
  551. package/src/components/artifacts/editable-artifact-view.tsx +199 -0
  552. package/src/components/artifacts/editable-artifact-workbench.tsx +8 -3
  553. package/src/components/artifacts/editable-document.tsx +76 -54
  554. package/src/components/artifacts/editable-presentation.tsx +86 -40
  555. package/src/components/artifacts/editable-spreadsheet.tsx +581 -121
  556. package/src/components/artifacts/index.ts +42 -0
  557. package/src/components/artifacts/inline-html-document.ts +24 -0
  558. package/src/components/artifacts/latest-task-runner.ts +49 -0
  559. package/src/components/artifacts/presentation-editor.tsx +422 -122
  560. package/src/components/artifacts/published-html-artifact-frame.tsx +79 -265
  561. package/src/components/artifacts/session-artifact-viewer.tsx +381 -0
  562. package/src/components/artifacts/site-view.tsx +129 -0
  563. package/src/components/artifacts/spreadsheet-canvas.ts +5 -10
  564. package/src/components/artifacts/spreadsheet-command-queue.ts +190 -0
  565. package/src/components/artifacts/spreadsheet-download.tsx +117 -0
  566. package/src/components/artifacts/spreadsheet-general-display.ts +43 -0
  567. package/src/components/artifacts/spreadsheet-grid.tsx +390 -172
  568. package/src/components/artifacts/spreadsheet-resize.tsx +432 -0
  569. package/src/components/artifacts/spreadsheet-submissions.tsx +46 -0
  570. package/src/components/artifacts/visualization-assets/base.css +1015 -0
  571. package/src/components/artifacts/visualization-assets/helpers.html +349 -0
  572. package/src/components/artifacts/visualization-assets.gen.ts +3 -0
  573. package/src/components/browser-select-control.tsx +320 -0
  574. package/src/components/browser-viewer.tsx +1102 -505
  575. package/src/components/chat-composer.tsx +42 -3
  576. package/src/components/child-session-link.tsx +16 -5
  577. package/src/components/claude-mark.tsx +11 -0
  578. package/src/components/code-editor.tsx +38 -27
  579. package/src/components/command-palette.tsx +4 -1
  580. package/src/components/composer-transcription-control.tsx +151 -50
  581. package/src/components/composer.tsx +281 -176
  582. package/src/components/computer-viewer.tsx +1013 -341
  583. package/src/components/copy-button.tsx +17 -7
  584. package/src/components/desktop-viewer.tsx +42 -33
  585. package/src/components/diff-view.tsx +3 -1
  586. package/src/components/enrollment-consent.tsx +39 -34
  587. package/src/components/enrollment-device-flow.tsx +31 -19
  588. package/src/components/file-browser.tsx +47 -35
  589. package/src/components/fleet-tile.tsx +8 -4
  590. package/src/components/generated-video-player.tsx +10 -5
  591. package/src/components/grok-mark.tsx +34 -0
  592. package/src/components/human-input-form.tsx +438 -251
  593. package/src/components/human-input-surface.tsx +8 -0
  594. package/src/components/interaction-intervention-banner.tsx +15 -13
  595. package/src/components/linkified-text.tsx +79 -0
  596. package/src/components/machine-card.tsx +56 -89
  597. package/src/components/machine-dock-bar.tsx +10 -4
  598. package/src/components/machine-health-pill.tsx +4 -2
  599. package/src/components/machine-input-display.ts +309 -34
  600. package/src/components/machine-metrics.tsx +10 -7
  601. package/src/components/machine-status-pill.tsx +23 -15
  602. package/src/components/machines/agent-status-icon.tsx +31 -0
  603. package/src/components/machines/health.ts +53 -10
  604. package/src/components/machines/machine-detail.tsx +230 -42
  605. package/src/components/machines/machine-operation-policy.tsx +36 -29
  606. package/src/components/machines/machine-status.ts +264 -0
  607. package/src/components/machines/metric-history-chart.tsx +8 -2
  608. package/src/components/machines/series.ts +12 -11
  609. package/src/components/machines-dashboard.tsx +16 -9
  610. package/src/components/markdown-table-layout.ts +67 -9
  611. package/src/components/markdown.tsx +470 -133
  612. package/src/components/message-timeline.tsx +2290 -752
  613. package/src/components/model-mark.tsx +102 -0
  614. package/src/components/model-picker.tsx +27 -9
  615. package/src/components/model-policy-picker-menu.tsx +204 -100
  616. package/src/components/model-policy-picker.tsx +215 -152
  617. package/src/components/new-conversation.tsx +223 -0
  618. package/src/components/open-geni-chat.tsx +311 -0
  619. package/src/components/open-geni-links.tsx +183 -0
  620. package/src/components/openrouter-mark.tsx +13 -0
  621. package/src/components/opper-mark.tsx +18 -0
  622. package/src/components/pierre-diff.tsx +47 -19
  623. package/src/components/pierre-file.tsx +38 -11
  624. package/src/components/preview-loading.tsx +111 -0
  625. package/src/components/provider-recovery-notice.tsx +51 -0
  626. package/src/components/queue-item-content.ts +16 -0
  627. package/src/components/queue-surface-implementation.tsx +185 -420
  628. package/src/components/queue-surface-state.tsx +13 -8
  629. package/src/components/queue-surface.tsx +3 -1
  630. package/src/components/rehype-secret-refs.ts +98 -0
  631. package/src/components/remark-soft-line-breaks.ts +166 -0
  632. package/src/components/sandbox-files.tsx +75 -44
  633. package/src/components/sandbox-terminal.tsx +103 -22
  634. package/src/components/sandbox-workspace.tsx +168 -78
  635. package/src/components/secret-question-field.tsx +326 -0
  636. package/src/components/secret-ref-chip.tsx +187 -0
  637. package/src/components/session-capability-frame.tsx +203 -0
  638. package/src/components/session-chrome.tsx +559 -328
  639. package/src/components/session-commands-panel.tsx +34 -17
  640. package/src/components/session-commands.tsx +18 -0
  641. package/src/components/session-connection-request.tsx +99 -0
  642. package/src/components/session-conversation.tsx +853 -118
  643. package/src/components/session-list.tsx +259 -0
  644. package/src/components/session-mcp-capability-card.tsx +681 -0
  645. package/src/components/session-proxy-scope.tsx +160 -0
  646. package/src/components/session-status.tsx +35 -21
  647. package/src/components/session-usage-limit-notice.tsx +176 -0
  648. package/src/components/this-computer/illustrations.tsx +164 -0
  649. package/src/components/this-computer/labels.ts +234 -0
  650. package/src/components/this-computer/this-computer-card.tsx +203 -0
  651. package/src/components/this-computer/this-computer-setup.tsx +433 -0
  652. package/src/components/this-computer/this-computer-status.tsx +329 -0
  653. package/src/components/this-computer/use-this-computer.ts +183 -0
  654. package/src/components/timeline-anchor.tsx +43 -15
  655. package/src/components/timeline-annotation-chrome.tsx +33 -9
  656. package/src/components/timeline-annotation-markers.tsx +4 -2
  657. package/src/components/timeline-annotation-selection.tsx +11 -2
  658. package/src/components/timeline-annotation-shared.ts +9 -8
  659. package/src/components/timeline-annotations-dialog.tsx +30 -9
  660. package/src/components/timeline-annotations.tsx +24 -7
  661. package/src/components/timeline-reading-progress.ts +80 -0
  662. package/src/components/timeline-search.tsx +168 -0
  663. package/src/components/timeline-settlement.ts +60 -0
  664. package/src/components/tool-action-review.tsx +670 -0
  665. package/src/components/tool-review-history.tsx +88 -0
  666. package/src/components/usage-limit-notice.tsx +183 -0
  667. package/src/components/usage-member-list.tsx +797 -0
  668. package/src/components/usage-meter.tsx +386 -0
  669. package/src/components/use-viewer-menu-dismiss.ts +33 -0
  670. package/src/components/user-message-body.tsx +33 -2
  671. package/src/components/workbench-changes.tsx +28 -16
  672. package/src/components/workspace-dock.tsx +45 -13
  673. package/src/composer-messages.ts +153 -0
  674. package/src/composer-voice-events.ts +12 -0
  675. package/src/composer.ts +4 -0
  676. package/src/connect-account-identity.tsx +38 -0
  677. package/src/connect-accounts.tsx +233 -0
  678. package/src/connect-chooser.tsx +339 -0
  679. package/src/connect-panel.tsx +104 -0
  680. package/src/connect-setup.tsx +354 -0
  681. package/src/connect.ts +60 -0
  682. package/src/connection-assets.d.ts +4 -0
  683. package/src/connection-catalog.tsx +175 -0
  684. package/src/connection-discovery.tsx +251 -0
  685. package/src/connection-installed.tsx +56 -0
  686. package/src/connection-logo.tsx +37 -0
  687. package/src/connection-service-logo.tsx +55 -0
  688. package/src/connection-service-presentation.ts +46 -0
  689. package/src/connection-skeleton.tsx +16 -0
  690. package/src/connection-type-picker.tsx +38 -0
  691. package/src/conversation-timeline.ts +11 -2
  692. package/src/desktop.ts +24 -0
  693. package/src/device-authorization.tsx +111 -0
  694. package/src/diffs.ts +16 -0
  695. package/src/discovery-cache.ts +42 -0
  696. package/src/editor.ts +13 -0
  697. package/src/hooks/internal.ts +93 -10
  698. package/src/hooks/latest-question.ts +168 -0
  699. package/src/hooks/session-view-cache.ts +167 -0
  700. package/src/hooks/shared-machines-list.ts +34 -1
  701. package/src/hooks/shared-query.ts +744 -0
  702. package/src/hooks/use-attached-browsers.ts +1 -1
  703. package/src/hooks/use-auth-runs.ts +0 -27
  704. package/src/hooks/use-available-models.ts +20 -10
  705. package/src/hooks/use-browser-frame-stream.ts +23 -4
  706. package/src/hooks/use-browser-session.ts +684 -206
  707. package/src/hooks/use-browser-sessions.ts +32 -1
  708. package/src/hooks/use-client-config-flags.ts +102 -0
  709. package/src/hooks/use-codex-accounts.ts +216 -43
  710. package/src/hooks/use-composer.ts +240 -59
  711. package/src/hooks/use-computer-frame-stream.ts +29 -9
  712. package/src/hooks/use-computer-input-posture.ts +96 -0
  713. package/src/hooks/use-computer-session.ts +419 -100
  714. package/src/hooks/use-connect.ts +23 -0
  715. package/src/hooks/use-desktop-stream.ts +19 -28
  716. package/src/hooks/use-file-attachments.ts +19 -3
  717. package/src/hooks/use-goal.ts +172 -21
  718. package/src/hooks/use-human-input.ts +16 -2
  719. package/src/hooks/use-last-started-turn-policy.ts +37 -11
  720. package/src/hooks/use-machine-chip.ts +13 -8
  721. package/src/hooks/use-machines.ts +24 -10
  722. package/src/hooks/use-new-conversation.ts +377 -0
  723. package/src/hooks/use-new-session-draft.ts +813 -0
  724. package/src/hooks/use-realtime-voice-models.ts +46 -0
  725. package/src/hooks/use-sandbox-files.ts +22 -16
  726. package/src/hooks/use-session-background-commands.ts +2 -2
  727. package/src/hooks/use-session-capabilities.ts +3 -2
  728. package/src/hooks/use-session-conversation.ts +150 -0
  729. package/src/hooks/use-session-events.ts +403 -64
  730. package/src/hooks/use-session-lineage.ts +47 -9
  731. package/src/hooks/use-session-mcp-approval-policy.ts +13 -5
  732. package/src/hooks/use-session-model-account.ts +174 -0
  733. package/src/hooks/use-session.ts +19 -3
  734. package/src/hooks/use-slash-commands.ts +6 -11
  735. package/src/hooks/use-supergrok-accounts.ts +22 -8
  736. package/src/hooks/use-terminal-stream.ts +153 -27
  737. package/src/hooks/use-transcription.ts +45 -19
  738. package/src/hooks/use-turn-queue.ts +25 -5
  739. package/src/hooks/use-usage.ts +100 -0
  740. package/src/hooks/use-vaults.ts +153 -0
  741. package/src/hooks/use-video-artifact-playback.ts +1 -1
  742. package/src/hooks/use-voice-input.ts +127 -19
  743. package/src/hooks/use-workspace-capture.ts +3 -2
  744. package/src/hooks/use-workspace-sessions.ts +74 -7
  745. package/src/human-input-model.ts +374 -0
  746. package/src/identity-link-accounts.tsx +149 -0
  747. package/src/identity-link-consent.tsx +193 -0
  748. package/src/index.ts +282 -16
  749. package/src/interaction.ts +1 -0
  750. package/src/lib/client-config-read.ts +76 -0
  751. package/src/lib/clipboard.ts +29 -0
  752. package/src/lib/error-message.ts +37 -0
  753. package/src/lib/format.ts +231 -36
  754. package/src/lib/host-theme.ts +529 -0
  755. package/src/lib/interaction-errors.ts +15 -0
  756. package/src/lib/menu-styles.ts +44 -0
  757. package/src/lib/notify-observer.ts +15 -0
  758. package/src/lib/pierre-diffs-loader.ts +53 -0
  759. package/src/lib/provider-recovery.ts +255 -0
  760. package/src/lib/scrollbars.ts +30 -0
  761. package/src/lib/terminal-input-readiness.ts +51 -0
  762. package/src/lib/transient-retry.ts +101 -0
  763. package/src/lib/workbench-peers.ts +62 -0
  764. package/src/lib/xterm-theme.ts +23 -21
  765. package/src/mcp-connection-status.ts +39 -0
  766. package/src/messages/en.ts +3810 -0
  767. package/src/messages/runtime.tsx +175 -0
  768. package/src/messages.ts +19 -0
  769. package/src/model-mark-paths.ts +53 -0
  770. package/src/model-picker-model.ts +343 -0
  771. package/src/model-policy.ts +301 -79
  772. package/src/native-previews.ts +104 -0
  773. package/src/new-session-draft.ts +22 -0
  774. package/src/notification-text.ts +81 -0
  775. package/src/organization-model.ts +123 -0
  776. package/src/plugin-details.tsx +192 -0
  777. package/src/plugin-discovery.tsx +209 -0
  778. package/src/preview-loading-paint.ts +68 -0
  779. package/src/provider.tsx +105 -21
  780. package/src/queue-presentation-model.ts +475 -0
  781. package/src/realtime/dropdown-menu.tsx +19 -12
  782. package/src/realtime/embedded-new-voice.tsx +1 -0
  783. package/src/realtime/embedded-voice.tsx +3 -0
  784. package/src/realtime/realtime-control.tsx +240 -609
  785. package/src/realtime/session-realtime.ts +582 -0
  786. package/src/sandbox-label-model.ts +56 -0
  787. package/src/scrollbars.ts +3 -0
  788. package/src/secret-reference-label.ts +47 -0
  789. package/src/secrets-ui.tsx +59 -0
  790. package/src/session-agents-model.ts +40 -0
  791. package/src/session-attention-model.ts +62 -0
  792. package/src/session-auth-recommendation.ts +50 -0
  793. package/src/session-capability-policy.ts +200 -0
  794. package/src/session-context.ts +13 -5
  795. package/src/session-feedback-model.ts +101 -0
  796. package/src/session-list-model.ts +437 -0
  797. package/src/session-realtime.ts +18 -0
  798. package/src/session-status-model.ts +99 -0
  799. package/src/session-ui.ts +102 -3
  800. package/src/session.ts +19 -1
  801. package/src/site-snapshot.ts +74 -0
  802. package/src/sites-ui.tsx +350 -0
  803. package/src/sites.ts +3 -0
  804. package/src/skill-discovery.tsx +221 -0
  805. package/src/terminal.ts +26 -0
  806. package/src/testing/session-scenarios.ts +404 -0
  807. package/src/this-computer.ts +62 -0
  808. package/src/timeline/activity-rail.tsx +289 -119
  809. package/src/timeline/agent-identity.tsx +84 -0
  810. package/src/timeline/agent-row.tsx +235 -0
  811. package/src/timeline/allowance-exhausted-row.tsx +90 -0
  812. package/src/timeline/compaction-copy.ts +125 -0
  813. package/src/timeline/fleet-decision-row.tsx +120 -101
  814. package/src/timeline/focus-sequence.ts +44 -0
  815. package/src/timeline/genie-copy.ts +22 -0
  816. package/src/timeline/genie-loading.tsx +158 -0
  817. package/src/timeline/index.ts +37 -2
  818. package/src/timeline/invoked-tool.ts +15 -0
  819. package/src/timeline/knowledge-receipt.tsx +104 -0
  820. package/src/timeline/learning-refusal-copy.ts +67 -0
  821. package/src/timeline/learning-refusal-row.tsx +70 -0
  822. package/src/timeline/message-sender.tsx +71 -0
  823. package/src/timeline/notice-presentation.ts +67 -0
  824. package/src/timeline/parsers.ts +42 -2
  825. package/src/timeline/patch-apply-command.tsx +139 -0
  826. package/src/timeline/platform-activity-presentation.ts +219 -0
  827. package/src/timeline/platform-activity-row.tsx +34 -98
  828. package/src/timeline/presented-image.ts +63 -0
  829. package/src/timeline/projection.ts +1556 -71
  830. package/src/timeline/provider-logo.tsx +53 -0
  831. package/src/timeline/question-nav-model.ts +28 -0
  832. package/src/timeline/registry.ts +11 -1
  833. package/src/timeline/retained-image.ts +102 -0
  834. package/src/timeline/retained-loaders.ts +91 -0
  835. package/src/timeline/rolling-activity.tsx +84 -0
  836. package/src/timeline/screenshot-lightbox.tsx +250 -10
  837. package/src/timeline/session-usage-limit-row.tsx +44 -0
  838. package/src/timeline/shared.tsx +76 -29
  839. package/src/timeline/startup-dispatch-details.tsx +43 -0
  840. package/src/timeline/startup-preference.ts +33 -0
  841. package/src/timeline/startup-timings.tsx +164 -0
  842. package/src/timeline/tool-diff.tsx +3 -1
  843. package/src/timeline/tool-display-name.ts +38 -6
  844. package/src/timeline/tool-presentation.ts +1552 -0
  845. package/src/timeline/tool-renderers.tsx +1019 -1265
  846. package/src/timeline/turn-summary-model.ts +363 -0
  847. package/src/timeline/turn-summary.tsx +288 -367
  848. package/src/timeline/types.ts +191 -7
  849. package/src/timeline/work-presentation.ts +196 -0
  850. package/src/timeline-model.ts +143 -0
  851. package/src/usage/allowance-copy.ts +70 -0
  852. package/src/usage/session-usage-limit.ts +270 -0
  853. package/src/usage/summary.ts +93 -0
  854. package/src/usage.ts +70 -0
  855. package/src/voice-recording-owner.ts +22 -0
  856. package/styles/compiled.css +2010 -651
  857. package/styles/connect.css +290 -0
  858. package/styles/connect.d.ts +1 -0
  859. package/styles/effective-tokens.css +1 -0
  860. package/styles/index.css +286 -9
  861. package/styles/responsive.css +98 -6
  862. package/styles/session-capability.css +44 -0
  863. package/styles/this-computer.css +1042 -0
  864. package/styles/this-computer.d.ts +1 -0
  865. package/styles/tokens.css +132 -64
  866. package/dist/browser-viewer-NTD6UIPR.js +0 -14
  867. package/dist/chunk-24M4YBCL.js.map +0 -1
  868. package/dist/chunk-4MDLEHXL.js.map +0 -1
  869. package/dist/chunk-5M6VTFJ5.js.map +0 -1
  870. package/dist/chunk-5PQJOCX5.js +0 -902
  871. package/dist/chunk-5PQJOCX5.js.map +0 -1
  872. package/dist/chunk-5YK2ZDIG.js.map +0 -1
  873. package/dist/chunk-6J56T3MG.js.map +0 -1
  874. package/dist/chunk-BV5A4OTE.js.map +0 -1
  875. package/dist/chunk-CQG7YUJB.js +0 -10883
  876. package/dist/chunk-CQG7YUJB.js.map +0 -1
  877. package/dist/chunk-H5YGYNXS.js.map +0 -1
  878. package/dist/chunk-HUIKIDM5.js.map +0 -1
  879. package/dist/chunk-HUMIRRYI.js.map +0 -1
  880. package/dist/chunk-ICA6R6TW.js.map +0 -1
  881. package/dist/chunk-JVYQRRC4.js.map +0 -1
  882. package/dist/chunk-KCGXPP5V.js.map +0 -1
  883. package/dist/chunk-KZ73RL76.js.map +0 -1
  884. package/dist/chunk-NEXLLTP4.js.map +0 -1
  885. package/dist/chunk-NLTS7JHI.js.map +0 -1
  886. package/dist/chunk-NOSYBS2D.js.map +0 -1
  887. package/dist/chunk-PAJU5KKL.js.map +0 -1
  888. package/dist/chunk-PEI6RANI.js.map +0 -1
  889. package/dist/chunk-PLYRL5ER.js +0 -164
  890. package/dist/chunk-PLYRL5ER.js.map +0 -1
  891. package/dist/chunk-R4KRSFGA.js +0 -290
  892. package/dist/chunk-R4KRSFGA.js.map +0 -1
  893. package/dist/chunk-UMECRJRV.js +0 -223
  894. package/dist/chunk-UMECRJRV.js.map +0 -1
  895. package/dist/chunk-VRBL3F5E.js +0 -241
  896. package/dist/chunk-VRBL3F5E.js.map +0 -1
  897. package/dist/chunk-YBM6CQRU.js.map +0 -1
  898. package/dist/chunk-Z7WBDB4E.js.map +0 -1
  899. package/dist/computer-viewer-7TEZC6Y2.js +0 -16
  900. package/dist/fleet-decision-row-YZ3ZKWMM.js +0 -352
  901. package/dist/fleet-decision-row-YZ3ZKWMM.js.map +0 -1
  902. package/dist/hooks/use-environments.d.ts +0 -41
  903. package/dist/hooks/use-packs.d.ts +0 -32
  904. package/dist/markdown-table-layout-3Z3AWBY7.js.map +0 -1
  905. package/dist/model-policy-picker-menu-3R336DP2.js +0 -13
  906. package/dist/platform-activity-row-27LKAWZD.js +0 -169
  907. package/dist/platform-activity-row-27LKAWZD.js.map +0 -1
  908. package/dist/queue-surface-implementation-LK3S4BIW.js.map +0 -1
  909. package/dist/timeline-annotation-markers-DRSTLEM6.js.map +0 -1
  910. package/dist/timeline-annotation-selection-IHLUGVND.js.map +0 -1
  911. package/dist/timeline-annotations-dialog-6Q53N5FG.js.map +0 -1
  912. package/src/hooks/use-environments.ts +0 -182
  913. package/src/hooks/use-packs.ts +0 -157
  914. /package/dist/{browser-viewer-NTD6UIPR.js.map → browser-viewer-GEHX3KYE.js.map} +0 -0
  915. /package/dist/{computer-viewer-7TEZC6Y2.js.map → chat-interactive-block-5V3BGLXT.js.map} +0 -0
  916. /package/dist/{model-policy-picker-menu-3R336DP2.js.map → chunk-M357MHH3.js.map} +0 -0
@@ -1,26 +1,193 @@
1
+ "use client";
1
2
  import {
2
3
  ArtifactSurface,
3
4
  EditableArtifactMessage,
4
5
  editableArtifactAccessRevoked,
5
6
  editableArtifactStatusLabel,
6
7
  useEditableArtifactView
7
- } from "./chunk-KCGXPP5V.js";
8
+ } from "./chunk-CXIGFHVL.js";
9
+ import {
10
+ ArtifactButton
11
+ } from "./chunk-2XKRY4GF.js";
8
12
  import {
9
13
  cn
10
- } from "./chunk-22KP6LR5.js";
14
+ } from "./chunk-TXS65BB2.js";
15
+ import {
16
+ useOpenGeniText
17
+ } from "./chunk-VU4QUISJ.js";
11
18
 
12
19
  // src/components/artifacts/spreadsheet-grid.tsx
13
20
  import { PlusIcon } from "lucide-react";
14
21
  import {
15
- useCallback,
16
- useEffect,
22
+ useCallback as useCallback3,
23
+ useEffect as useEffect3,
17
24
  useId,
18
25
  useLayoutEffect,
19
- useMemo,
20
- useRef,
21
- useState
26
+ useMemo as useMemo2,
27
+ useRef as useRef3,
28
+ useState as useState3
22
29
  } from "react";
23
30
 
31
+ // src/components/artifacts/spreadsheet-command-queue.ts
32
+ import { useCallback, useEffect, useRef, useState } from "react";
33
+ function overlaps(a, b) {
34
+ return a.top <= b.bottom && a.bottom >= b.top && a.left <= b.right && a.right >= b.left;
35
+ }
36
+ function contains(a, b) {
37
+ return a.top <= b.top && a.bottom >= b.bottom && a.left <= b.left && a.right >= b.right;
38
+ }
39
+ function useSpreadsheetCommandQueue({
40
+ scopeKey,
41
+ enabled,
42
+ onCommandError
43
+ }) {
44
+ const t = useOpenGeniText();
45
+ const [pendingCount, setPendingCount] = useState(0);
46
+ const [failures, setFailures] = useState([]);
47
+ const commandsRef = useRef(/* @__PURE__ */ new Map());
48
+ const nextIdRef = useRef(0);
49
+ const mountedRef = useRef(true);
50
+ const optionsRef = useRef({ scopeKey, enabled, onCommandError });
51
+ optionsRef.current = { scopeKey, enabled, onCommandError };
52
+ const scopeRef = useRef({ key: scopeKey, epoch: 0 });
53
+ if (scopeRef.current.key !== scopeKey) {
54
+ scopeRef.current = { key: scopeKey, epoch: scopeRef.current.epoch + 1 };
55
+ }
56
+ useEffect(() => {
57
+ mountedRef.current = true;
58
+ return () => {
59
+ mountedRef.current = false;
60
+ };
61
+ }, []);
62
+ useEffect(() => {
63
+ commandsRef.current.clear();
64
+ setPendingCount(0);
65
+ setFailures([]);
66
+ }, [scopeKey]);
67
+ const refreshFailures = useCallback(() => {
68
+ setFailures(
69
+ [...commandsRef.current.values()].filter(
70
+ (command) => command.message !== void 0 && !command.covered
71
+ )
72
+ );
73
+ }, []);
74
+ const clearPreflightFailure = useCallback(() => {
75
+ let changed = false;
76
+ for (const previous of commandsRef.current.values()) {
77
+ if (previous.target === null && previous.message !== void 0) {
78
+ commandsRef.current.delete(previous.id);
79
+ changed = true;
80
+ }
81
+ }
82
+ if (changed) refreshFailures();
83
+ }, [refreshFailures]);
84
+ const run = useCallback(
85
+ (invoke, retry, rollback, target, accepted) => {
86
+ if (!optionsRef.current.enabled) return;
87
+ const scope = optionsRef.current.scopeKey;
88
+ const epoch = scopeRef.current.epoch;
89
+ const id = ++nextIdRef.current;
90
+ clearPreflightFailure();
91
+ const command = { id, target: null, overlapped: false, covered: false };
92
+ commandsRef.current.set(id, command);
93
+ const current = () => mountedRef.current && optionsRef.current.scopeKey === scope && scopeRef.current.epoch === epoch;
94
+ const fail = (cause) => {
95
+ if (!current()) return;
96
+ rollback(id);
97
+ if (command.covered) {
98
+ commandsRef.current.delete(id);
99
+ return;
100
+ }
101
+ const error = cause instanceof Error ? cause : new Error(String(cause));
102
+ command.message = error.message || t("artifacts.spreadsheetCommandQueue.spreadsheetChangeFailed");
103
+ command.retry = () => {
104
+ if (!current() || !optionsRef.current.enabled || command.overlapped) return;
105
+ commandsRef.current.delete(id);
106
+ refreshFailures();
107
+ retry();
108
+ };
109
+ refreshFailures();
110
+ optionsRef.current.onCommandError?.(error);
111
+ };
112
+ let result;
113
+ try {
114
+ command.target = typeof target === "function" ? target() : target ?? null;
115
+ if (command.target) {
116
+ for (const previous of commandsRef.current.values()) {
117
+ if (previous.id === id || !previous.target || !overlaps(command.target, previous.target))
118
+ continue;
119
+ previous.overlapped = true;
120
+ previous.covered ||= contains(command.target, previous.target);
121
+ if (previous.covered && previous.message !== void 0)
122
+ commandsRef.current.delete(previous.id);
123
+ }
124
+ refreshFailures();
125
+ }
126
+ result = invoke(id);
127
+ } catch (cause) {
128
+ fail(cause);
129
+ return;
130
+ }
131
+ const succeed = () => {
132
+ if (!current()) return;
133
+ commandsRef.current.delete(id);
134
+ accepted?.(id);
135
+ };
136
+ if (!result || typeof result.then !== "function") {
137
+ succeed();
138
+ return;
139
+ }
140
+ setPendingCount((count) => count + 1);
141
+ void Promise.resolve(result).then(
142
+ () => {
143
+ if (!current()) return;
144
+ setPendingCount((count) => Math.max(0, count - 1));
145
+ succeed();
146
+ },
147
+ (cause) => {
148
+ if (!current()) return;
149
+ setPendingCount((count) => Math.max(0, count - 1));
150
+ fail(cause);
151
+ }
152
+ );
153
+ },
154
+ [clearPreflightFailure, refreshFailures, t]
155
+ );
156
+ const first = failures[0];
157
+ return {
158
+ run,
159
+ clearPreflightFailure,
160
+ pendingCount,
161
+ error: first ? {
162
+ message: failures.length > 1 ? t("artifacts.spreadsheetCommandQueue.messageLengthChangesNotSaved", {
163
+ message: first.message,
164
+ length: failures.length
165
+ }) : first.message,
166
+ retry: enabled && !first.overlapped ? first.retry : void 0
167
+ } : null
168
+ };
169
+ }
170
+
171
+ // src/components/artifacts/spreadsheet-general-display.ts
172
+ function formatSpreadsheetGeneralDisplay(value) {
173
+ if (value === null || value === void 0) return "";
174
+ if (value instanceof Date) return Number.isNaN(value.getTime()) ? "" : value.toLocaleDateString();
175
+ if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
176
+ if (typeof value === "number") {
177
+ if (Object.is(value, -0) || value === 0) return "0";
178
+ if (!Number.isFinite(value)) return String(value);
179
+ const rounded = Number(value.toPrecision(15));
180
+ return String(Number.isFinite(rounded) ? rounded : value);
181
+ }
182
+ return String(value);
183
+ }
184
+ function spreadsheetCellEditSource(value) {
185
+ if (value === null || value === void 0) return "";
186
+ if (value instanceof Date) return Number.isNaN(value.getTime()) ? "" : value.toLocaleDateString();
187
+ if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
188
+ return String(value);
189
+ }
190
+
24
191
  // src/components/artifacts/spreadsheet-canvas.ts
25
192
  var TILE_SIZE = 256;
26
193
  var MAX_CACHE_PHYSICAL_PIXELS = 32e6;
@@ -266,7 +433,7 @@ var SpreadsheetCanvasRenderer = class {
266
433
  paintTileGrid(context, input, tileLeft, tileTop, tileRight, tileBottom);
267
434
  for (const cell of cells) {
268
435
  const value = input.projection.valueAt(cell);
269
- const text = displayValue(value);
436
+ const text = formatSpreadsheetGeneralDisplay(value);
270
437
  if (!text) continue;
271
438
  paintCellText(context, input, cell, text, tileLeft, tileTop);
272
439
  }
@@ -351,7 +518,7 @@ function paintSelection(context, input) {
351
518
  const top = input.columnHeaderHeight + input.rows.offsetAt(selection.top) - input.logicalScrollTop;
352
519
  const bottom = input.columnHeaderHeight + input.rows.offsetAt(selection.bottom + 1) - input.logicalScrollTop;
353
520
  context.save();
354
- setFill(context, input.theme.accent, "#3b82f6");
521
+ setFill(context, input.theme.accent, "#545454");
355
522
  context.globalAlpha = 0.1;
356
523
  context.fillRect(left, top, right - left, bottom - top);
357
524
  context.restore();
@@ -360,7 +527,7 @@ function paintSelection(context, input) {
360
527
  const activeWidth = input.columns.sizeAt(selection.focusColumn);
361
528
  const activeHeight = input.rows.sizeAt(selection.focusRow);
362
529
  context.save();
363
- setStroke(context, input.theme.accent, "#3b82f6");
530
+ setStroke(context, input.theme.accent, "#545454");
364
531
  context.lineWidth = 2;
365
532
  context.strokeRect(
366
533
  activeLeft + 1,
@@ -522,12 +689,6 @@ function ellipsize(context, input, maximumWidth) {
522
689
  function finitePositive(value, fallback) {
523
690
  return value !== void 0 && Number.isFinite(value) && value > 0 ? value : fallback;
524
691
  }
525
- function displayValue(value) {
526
- if (value === null || value === void 0) return "";
527
- if (value instanceof Date) return Number.isNaN(value.getTime()) ? "" : value.toLocaleDateString();
528
- if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
529
- return String(value);
530
- }
531
692
  function columnName(index) {
532
693
  let value = index + 1;
533
694
  let result = "";
@@ -542,8 +703,340 @@ function clamp(value, minimum, maximum) {
542
703
  return Math.max(minimum, Math.min(maximum, value));
543
704
  }
544
705
 
706
+ // src/components/artifacts/spreadsheet-resize.tsx
707
+ import {
708
+ useCallback as useCallback2,
709
+ useEffect as useEffect2,
710
+ useMemo,
711
+ useRef as useRef2,
712
+ useState as useState2
713
+ } from "react";
714
+ import { jsx } from "react/jsx-runtime";
715
+ var MIN_SIZE = 8;
716
+ var MAX_SIZE = 4096;
717
+ function keyOf(change) {
718
+ return `${change.axis}:${change.index}`;
719
+ }
720
+ function boundedSize(size) {
721
+ return Math.max(MIN_SIZE, Math.min(MAX_SIZE, Math.round(size)));
722
+ }
723
+ function useSpreadsheetResizing(options) {
724
+ const t = useOpenGeniText();
725
+ const optionsRef = useRef2(options);
726
+ optionsRef.current = options;
727
+ const [gesture, setGesture] = useState2(null);
728
+ const [pending, setPending] = useState2([]);
729
+ const [inFlightCount, setInFlightCount] = useState2(0);
730
+ const [errors, setErrors] = useState2([]);
731
+ const errorsRef = useRef2(/* @__PURE__ */ new Map());
732
+ const activeRef = useRef2(null);
733
+ const pendingRef = useRef2(/* @__PURE__ */ new Map());
734
+ const frameRef = useRef2(null);
735
+ const nextIdRef = useRef2(0);
736
+ const scopeRef = useRef2(0);
737
+ const mountedRef = useRef2(true);
738
+ const clearError = useCallback2(() => {
739
+ errorsRef.current.clear();
740
+ setErrors([]);
741
+ }, []);
742
+ const cancelFrame = useCallback2(() => {
743
+ if (frameRef.current !== null) globalThis.cancelAnimationFrame?.(frameRef.current);
744
+ frameRef.current = null;
745
+ }, []);
746
+ const cancel = useCallback2(() => {
747
+ cancelFrame();
748
+ activeRef.current = null;
749
+ setGesture(null);
750
+ }, [cancelFrame]);
751
+ useEffect2(() => {
752
+ mountedRef.current = true;
753
+ return () => {
754
+ mountedRef.current = false;
755
+ scopeRef.current += 1;
756
+ cancelFrame();
757
+ };
758
+ }, [cancelFrame]);
759
+ useEffect2(() => {
760
+ scopeRef.current += 1;
761
+ cancel();
762
+ pendingRef.current.clear();
763
+ setPending([]);
764
+ setInFlightCount(0);
765
+ clearError();
766
+ }, [cancel, clearError, options.enabled, options.generationId, options.sheetId]);
767
+ const authoritativeSize = useCallback2((axis, index) => {
768
+ const current = optionsRef.current;
769
+ const entries = axis === "row" ? current.rowHeights : current.columnWidths;
770
+ return entries.find(([at]) => at === index)?.[1] ?? (axis === "row" ? current.defaultRowHeight : current.defaultColumnWidth);
771
+ }, []);
772
+ useEffect2(() => {
773
+ let changed = false;
774
+ for (const [key, entry] of pendingRef.current) {
775
+ if (entry.settled && (authoritativeSize(entry.axis, entry.index) === entry.size || options.revision !== entry.baseRevision)) {
776
+ pendingRef.current.delete(key);
777
+ changed = true;
778
+ }
779
+ }
780
+ if (changed) setPending([...pendingRef.current.values()]);
781
+ }, [authoritativeSize, options.columnWidths, options.revision, options.rowHeights, pending]);
782
+ const submit = useCallback2(
783
+ (change) => {
784
+ const current = optionsRef.current;
785
+ if (!current.enabled || !current.commit || change.sheetId !== current.sheetId) return;
786
+ const scope = scopeRef.current;
787
+ const id = ++nextIdRef.current;
788
+ const key = keyOf(change);
789
+ const entry = {
790
+ ...change,
791
+ id,
792
+ baseRevision: current.revision,
793
+ settled: false
794
+ };
795
+ pendingRef.current.set(key, entry);
796
+ setPending([...pendingRef.current.values()]);
797
+ errorsRef.current.delete(key);
798
+ setErrors([...errorsRef.current.values()]);
799
+ current.onStart?.();
800
+ let asynchronous = false;
801
+ const settle = (failed, cause) => {
802
+ if (!mountedRef.current || scopeRef.current !== scope) return;
803
+ if (asynchronous) setInFlightCount((count) => Math.max(0, count - 1));
804
+ const latest = pendingRef.current.get(key);
805
+ if (latest?.id !== id) return;
806
+ if (failed) {
807
+ pendingRef.current.delete(key);
808
+ const failure = cause instanceof Error ? cause : new Error(String(cause));
809
+ errorsRef.current.set(key, {
810
+ key,
811
+ message: failure.message || t("artifacts.spreadsheetResize.spreadsheetResizeFailed"),
812
+ retry: () => {
813
+ if (!mountedRef.current || scopeRef.current !== scope) return;
814
+ submit(change);
815
+ }
816
+ });
817
+ setErrors([...errorsRef.current.values()]);
818
+ optionsRef.current.onCommandError?.(failure);
819
+ } else {
820
+ pendingRef.current.set(key, {
821
+ ...entry,
822
+ baseRevision: optionsRef.current.revision,
823
+ settled: true
824
+ });
825
+ }
826
+ setPending([...pendingRef.current.values()]);
827
+ };
828
+ try {
829
+ const result = current.commit(change);
830
+ if (result && typeof result.then === "function") {
831
+ asynchronous = true;
832
+ setInFlightCount((count) => count + 1);
833
+ void Promise.resolve(result).then(
834
+ () => settle(false),
835
+ (cause) => settle(true, cause)
836
+ );
837
+ } else {
838
+ settle(false);
839
+ }
840
+ } catch (cause) {
841
+ settle(true, cause);
842
+ }
843
+ },
844
+ [t]
845
+ );
846
+ const update = useCallback2((next) => {
847
+ activeRef.current = next;
848
+ if (frameRef.current !== null) return;
849
+ if (typeof globalThis.requestAnimationFrame !== "function") {
850
+ setGesture(next);
851
+ return;
852
+ }
853
+ frameRef.current = globalThis.requestAnimationFrame(() => {
854
+ frameRef.current = null;
855
+ if (mountedRef.current) setGesture(activeRef.current);
856
+ });
857
+ }, []);
858
+ const finish = useCallback2(() => {
859
+ const active = activeRef.current;
860
+ cancel();
861
+ if (!active || active.size === active.startSize) return;
862
+ submit({ sheetId: active.sheetId, axis: active.axis, index: active.index, size: active.size });
863
+ }, [cancel, submit]);
864
+ const begin = useCallback2(
865
+ (axis, index, pointerId, position) => {
866
+ const current = optionsRef.current;
867
+ if (!current.enabled || !current.commit) return;
868
+ const existing = pendingRef.current.get(keyOf({ axis, index }));
869
+ const size = existing?.size ?? authoritativeSize(axis, index);
870
+ cancel();
871
+ const next = {
872
+ sheetId: current.sheetId,
873
+ axis,
874
+ index,
875
+ size,
876
+ startSize: size,
877
+ startPosition: position,
878
+ pointerId
879
+ };
880
+ activeRef.current = next;
881
+ setGesture(next);
882
+ current.onStart?.();
883
+ },
884
+ [authoritativeSize, cancel]
885
+ );
886
+ const handleProps = useCallback2(
887
+ (axis, index) => ({
888
+ onPointerDown(event) {
889
+ if (event.button !== 0 || event.isPrimary === false) return;
890
+ event.preventDefault();
891
+ event.stopPropagation();
892
+ event.currentTarget.focus({ preventScroll: true });
893
+ begin(axis, index, event.pointerId, axis === "column" ? event.clientX : event.clientY);
894
+ event.currentTarget.setPointerCapture?.(event.pointerId);
895
+ },
896
+ onPointerMove(event) {
897
+ const active = activeRef.current;
898
+ if (!active || active.pointerId !== event.pointerId || active.axis !== axis || active.index !== index)
899
+ return;
900
+ event.preventDefault();
901
+ event.stopPropagation();
902
+ const position = axis === "column" ? event.clientX : event.clientY;
903
+ update({
904
+ ...active,
905
+ size: boundedSize(active.startSize + position - active.startPosition)
906
+ });
907
+ },
908
+ onPointerUp(event) {
909
+ const active = activeRef.current;
910
+ if (!active || active.pointerId !== event.pointerId || active.axis !== axis || active.index !== index)
911
+ return;
912
+ event.preventDefault();
913
+ event.stopPropagation();
914
+ const position = axis === "column" ? event.clientX : event.clientY;
915
+ activeRef.current = {
916
+ ...active,
917
+ size: boundedSize(active.startSize + position - active.startPosition)
918
+ };
919
+ finish();
920
+ if (event.currentTarget.hasPointerCapture?.(event.pointerId)) {
921
+ event.currentTarget.releasePointerCapture?.(event.pointerId);
922
+ }
923
+ },
924
+ onPointerCancel(event) {
925
+ const active = activeRef.current;
926
+ if (active?.pointerId === event.pointerId && active.axis === axis && active.index === index)
927
+ cancel();
928
+ event.stopPropagation();
929
+ },
930
+ onLostPointerCapture(event) {
931
+ const active = activeRef.current;
932
+ if (active?.pointerId === event.pointerId && active.axis === axis && active.index === index)
933
+ cancel();
934
+ },
935
+ onKeyDown(event) {
936
+ event.stopPropagation();
937
+ if (event.key === "Escape") {
938
+ event.preventDefault();
939
+ cancel();
940
+ return;
941
+ }
942
+ if (event.key === "Enter") {
943
+ event.preventDefault();
944
+ finish();
945
+ return;
946
+ }
947
+ const negative = axis === "column" ? "ArrowLeft" : "ArrowUp";
948
+ const positive = axis === "column" ? "ArrowRight" : "ArrowDown";
949
+ if (event.key !== negative && event.key !== positive && event.key !== "Home") return;
950
+ event.preventDefault();
951
+ if (activeRef.current?.pointerId !== null || activeRef.current.axis !== axis || activeRef.current.index !== index) {
952
+ begin(axis, index, null, 0);
953
+ }
954
+ const active = activeRef.current;
955
+ if (!active) return;
956
+ const current = optionsRef.current;
957
+ const size = event.key === "Home" ? axis === "row" ? current.defaultRowHeight : current.defaultColumnWidth : active.size + (event.key === negative ? -1 : 1) * (event.shiftKey ? 1 : 8);
958
+ update({ ...active, size: boundedSize(size) });
959
+ },
960
+ onKeyUp(event) {
961
+ event.stopPropagation();
962
+ const active = activeRef.current;
963
+ if (active?.axis === axis && active.index === index && (event.key === "Home" || event.key.startsWith("Arrow")))
964
+ finish();
965
+ },
966
+ onBlur() {
967
+ const active = activeRef.current;
968
+ if (active?.pointerId === null && active.axis === axis && active.index === index) finish();
969
+ }
970
+ }),
971
+ [begin, cancel, finish, update]
972
+ );
973
+ const pendingRows = useMemo(() => pending.filter((entry) => entry.axis === "row"), [pending]);
974
+ const pendingColumns = useMemo(
975
+ () => pending.filter((entry) => entry.axis === "column"),
976
+ [pending]
977
+ );
978
+ const rowGesture = gesture?.axis === "row" ? gesture : null;
979
+ const columnGesture = gesture?.axis === "column" ? gesture : null;
980
+ const rowHeights = useMemo(
981
+ () => previewDimensions(options.rowHeights, pendingRows, rowGesture),
982
+ [options.rowHeights, pendingRows, rowGesture]
983
+ );
984
+ const columnWidths = useMemo(
985
+ () => previewDimensions(options.columnWidths, pendingColumns, columnGesture),
986
+ [options.columnWidths, pendingColumns, columnGesture]
987
+ );
988
+ const previewKey = [
989
+ ...pending.map((entry) => `${entry.axis}:${entry.index}:${entry.size}`),
990
+ ...gesture ? [`${gesture.axis}:${gesture.index}:${gesture.size}`] : []
991
+ ].join(";");
992
+ return {
993
+ rowHeights,
994
+ columnWidths,
995
+ previewKey,
996
+ handleProps,
997
+ pendingCount: inFlightCount,
998
+ error: errors[0] ? { message: errors[0].message, retry: options.enabled ? errors[0].retry : void 0 } : null,
999
+ clearError
1000
+ };
1001
+ }
1002
+ function previewDimensions(entries, pending, gesture) {
1003
+ if (!pending.length && !gesture) return entries;
1004
+ const projected = new Map(entries);
1005
+ for (const entry of pending) projected.set(entry.index, entry.size);
1006
+ if (gesture) projected.set(gesture.index, gesture.size);
1007
+ return [...projected.entries()];
1008
+ }
1009
+ function SpreadsheetResizeHandle({
1010
+ axis,
1011
+ label,
1012
+ size,
1013
+ ...handlers
1014
+ }) {
1015
+ const t = useOpenGeniText();
1016
+ return /* @__PURE__ */ jsx(
1017
+ "div",
1018
+ {
1019
+ ...handlers,
1020
+ role: "separator",
1021
+ tabIndex: 0,
1022
+ "aria-label": label,
1023
+ "aria-orientation": axis === "column" ? "vertical" : "horizontal",
1024
+ "aria-valuemin": MIN_SIZE,
1025
+ "aria-valuemax": MAX_SIZE,
1026
+ "aria-valuenow": size,
1027
+ "aria-valuetext": t("artifacts.spreadsheetResize.sizePixels", { size }),
1028
+ "data-og-resize-axis": axis,
1029
+ style: { [axis === "column" ? "right" : "bottom"]: "calc(var(--spacing) * -1)" },
1030
+ className: cn(
1031
+ "pointer-events-auto absolute z-40 touch-none outline-hidden hover:bg-og-accent/20 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-og-accent",
1032
+ axis === "column" ? "top-0 h-full w-2 cursor-col-resize" : "left-0 h-2 w-full cursor-row-resize"
1033
+ )
1034
+ }
1035
+ );
1036
+ }
1037
+
545
1038
  // src/components/artifacts/spreadsheet-grid.tsx
546
- import { jsx, jsxs } from "react/jsx-runtime";
1039
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
547
1040
  var MAX_ROWS = 1048576;
548
1041
  var MAX_COLUMNS = 16384;
549
1042
  var ROW_HEADER_WIDTH = 48;
@@ -556,7 +1049,8 @@ var MAX_MOUNTED_AXIS_ITEMS = 512;
556
1049
  var MAX_MOUNTED_GRID_CELLS = 2048;
557
1050
  var MAX_CLIPBOARD_INPUT_BYTES = 4 * 1024 * 1024;
558
1051
  var MAX_CLIPBOARD_CELLS = 65536;
559
- var useClientLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
1052
+ var EMPTY_DIMENSIONS = [];
1053
+ var useClientLayoutEffect = typeof window === "undefined" ? useEffect3 : useLayoutEffect;
560
1054
  function boundedInteger(value, fallback, max) {
561
1055
  if (value === void 0) return fallback;
562
1056
  if (!Number.isFinite(value)) return fallback;
@@ -795,12 +1289,6 @@ function isCellSelected(selection, row, col) {
795
1289
  const normalized = normalizeSelection(selection);
796
1290
  return row >= normalized.top && row <= normalized.bottom && col >= normalized.left && col <= normalized.right;
797
1291
  }
798
- function displayValue2(value) {
799
- if (value === null || value === void 0) return "";
800
- if (value instanceof Date) return Number.isNaN(value.getTime()) ? "" : value.toLocaleDateString();
801
- if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
802
- return String(value);
803
- }
804
1292
  function parseCellInput(input) {
805
1293
  if (input === "") return null;
806
1294
  const normalized = input.trim();
@@ -811,9 +1299,9 @@ function parseCellInput(input) {
811
1299
  }
812
1300
  return input;
813
1301
  }
814
- function parseSpreadsheetClipboard(input) {
1302
+ function parseSpreadsheetClipboard(t, input) {
815
1303
  if (new TextEncoder().encode(input).byteLength > MAX_CLIPBOARD_INPUT_BYTES) {
816
- throw new Error("Clipboard data is too large to paste");
1304
+ throw new Error(t("artifacts.spreadsheetGrid.clipboardDataIsTooLarge"));
817
1305
  }
818
1306
  const records = [[]];
819
1307
  let field = "";
@@ -853,14 +1341,14 @@ function parseSpreadsheetClipboard(input) {
853
1341
  endedWithRecordSeparator = false;
854
1342
  }
855
1343
  }
856
- if (quoted) throw new Error("Clipboard data contains an unterminated quoted cell");
1344
+ if (quoted) throw new Error(t("artifacts.spreadsheetGrid.clipboardDataContainsAnUnterminated"));
857
1345
  if (endedWithRecordSeparator) records.pop();
858
1346
  else records.at(-1).push(field);
859
1347
  if (records.length === 0) records.push([""]);
860
1348
  const columns = Math.max(1, ...records.map((record) => record.length));
861
1349
  const cellCount = records.length * columns;
862
1350
  if (cellCount > MAX_CLIPBOARD_CELLS) {
863
- throw new Error("Clipboard range is too large to paste");
1351
+ throw new Error(t("artifacts.spreadsheetGrid.clipboardRangeIsTooLarge"));
864
1352
  }
865
1353
  const inputs = records.flatMap((record) => [
866
1354
  ...record,
@@ -909,7 +1397,7 @@ function spreadsheetCanvasTheme(element) {
909
1397
  const border = computedToken(style, "--og-color-border", "#d1d5db");
910
1398
  const foreground = style.color || computedToken(style, "--og-color-fg", "#111827");
911
1399
  const mutedForeground = computedToken(style, "--og-color-fg-muted", "#6b7280");
912
- const accent = computedToken(style, "--og-color-accent", "#3b82f6");
1400
+ const accent = computedToken(style, "--og-color-accent", "#545454");
913
1401
  const error = computedToken(style, "--og-color-status-failed", "#dc2626");
914
1402
  const fontFamily = style.fontFamily || computedToken(
915
1403
  style,
@@ -944,11 +1432,11 @@ function spreadsheetCanvasTheme(element) {
944
1432
  };
945
1433
  }
946
1434
  function useWorkbookViewState(workbook) {
947
- const [view, setView] = useState(() => ({
1435
+ const [view, setView] = useState3(() => ({
948
1436
  revision: workbook.revision,
949
1437
  dimensionRevision: 0
950
1438
  }));
951
- useEffect(() => {
1439
+ useEffect3(() => {
952
1440
  setView(
953
1441
  (current) => current.revision === workbook.revision ? current : { revision: workbook.revision, dimensionRevision: current.dimensionRevision + 1 }
954
1442
  );
@@ -961,14 +1449,14 @@ function useWorkbookViewState(workbook) {
961
1449
  }, [workbook]);
962
1450
  return view;
963
1451
  }
964
- function nextAvailableSheetName(workbook) {
1452
+ function nextAvailableSheetName(t, workbook) {
965
1453
  let index = workbook.worksheets.items.length + 1;
966
1454
  while (workbook.worksheets.items.some((sheet) => sheet.name === `Sheet${index}`)) index += 1;
967
- return `Sheet${index}`;
1455
+ return t("artifacts.spreadsheetGrid.sheetIndex", { index });
968
1456
  }
969
1457
  function SpreadsheetArtifactSurface({
970
1458
  workbook,
971
- title = "Workbook",
1459
+ title: titleProp,
972
1460
  subtitle,
973
1461
  actions,
974
1462
  initialSheetId,
@@ -976,6 +1464,8 @@ function SpreadsheetArtifactSurface({
976
1464
  readOnly = false,
977
1465
  ...gridProps
978
1466
  }) {
1467
+ const t = useOpenGeniText();
1468
+ const title = titleProp === void 0 ? t("artifacts.spreadsheetGrid.workbook") : titleProp;
979
1469
  const { revision } = useWorkbookViewState(workbook);
980
1470
  const availableSheets = workbook.worksheets.items;
981
1471
  const initial = (initialSheetId ? availableSheets.find((sheet) => sheet.id === initialSheetId) : void 0) ?? (() => {
@@ -985,31 +1475,31 @@ function SpreadsheetArtifactSurface({
985
1475
  return availableSheets[0];
986
1476
  }
987
1477
  })();
988
- const [activeSheetId, setActiveSheetId] = useState(initial?.id ?? null);
1478
+ const [activeSheetId, setActiveSheetId] = useState3(initial?.id ?? null);
989
1479
  const activeSheet = availableSheets.find((sheet) => sheet.id === activeSheetId) ?? availableSheets[0] ?? null;
990
- useEffect(() => {
1480
+ useEffect3(() => {
991
1481
  if (!activeSheet && activeSheetId !== null) setActiveSheetId(null);
992
1482
  else if (activeSheet && activeSheet.id !== activeSheetId) setActiveSheetId(activeSheet.id);
993
1483
  }, [activeSheet, activeSheetId, revision]);
994
- const selectSheet = useCallback(
1484
+ const selectSheet = useCallback3(
995
1485
  (sheet) => {
996
1486
  workbook.worksheets.setActiveWorksheet(sheet);
997
1487
  setActiveSheetId(sheet.id);
998
1488
  },
999
1489
  [workbook]
1000
1490
  );
1001
- const addSheet = useCallback(() => {
1002
- const sheet = workbook.worksheets.add(nextAvailableSheetName(workbook));
1491
+ const addSheet = useCallback3(() => {
1492
+ const sheet = workbook.worksheets.add(nextAvailableSheetName(t, workbook));
1003
1493
  selectSheet(sheet);
1004
- }, [selectSheet, workbook]);
1494
+ }, [selectSheet, workbook, t]);
1005
1495
  const footer = /* @__PURE__ */ jsxs(
1006
1496
  "div",
1007
1497
  {
1008
1498
  className: "flex min-h-9 items-center gap-1 overflow-x-auto px-2",
1009
1499
  role: "tablist",
1010
- "aria-label": "Worksheets",
1500
+ "aria-label": t("artifacts.spreadsheetGrid.worksheets"),
1011
1501
  children: [
1012
- availableSheets.map((sheet) => /* @__PURE__ */ jsx(
1502
+ availableSheets.map((sheet) => /* @__PURE__ */ jsx2(
1013
1503
  "button",
1014
1504
  {
1015
1505
  type: "button",
@@ -1024,28 +1514,28 @@ function SpreadsheetArtifactSurface({
1024
1514
  },
1025
1515
  sheet.id
1026
1516
  )),
1027
- !readOnly && allowAddSheet ? /* @__PURE__ */ jsx(
1517
+ !readOnly && allowAddSheet ? /* @__PURE__ */ jsx2(
1028
1518
  "button",
1029
1519
  {
1030
1520
  type: "button",
1031
1521
  onClick: addSheet,
1032
- "aria-label": "Add worksheet",
1522
+ "aria-label": t("artifacts.spreadsheetGrid.addWorksheet"),
1033
1523
  className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted hover:bg-og-surface-3 hover:text-og-fg [&>svg]:size-3.5",
1034
- children: /* @__PURE__ */ jsx(PlusIcon, {})
1524
+ children: /* @__PURE__ */ jsx2(PlusIcon, {})
1035
1525
  }
1036
1526
  ) : null
1037
1527
  ]
1038
1528
  }
1039
1529
  );
1040
- return /* @__PURE__ */ jsx(
1530
+ return /* @__PURE__ */ jsx2(
1041
1531
  ArtifactSurface,
1042
1532
  {
1043
1533
  modality: "spreadsheet",
1044
1534
  title,
1045
- subtitle: subtitle ?? (activeSheet ? `${availableSheets.length} sheet${availableSheets.length === 1 ? "" : "s"}` : "Empty workbook"),
1535
+ subtitle: subtitle ?? (activeSheet ? t("counts.sheets", { count: availableSheets.length }) : t("artifacts.spreadsheetGrid.emptyWorkbook")),
1046
1536
  actions,
1047
1537
  footer,
1048
- children: activeSheet ? /* @__PURE__ */ jsx(
1538
+ children: activeSheet ? /* @__PURE__ */ jsx2(
1049
1539
  SpreadsheetGrid,
1050
1540
  {
1051
1541
  ...gridProps,
@@ -1054,20 +1544,20 @@ function SpreadsheetArtifactSurface({
1054
1544
  readOnly
1055
1545
  },
1056
1546
  activeSheet.id
1057
- ) : /* @__PURE__ */ jsx(
1547
+ ) : /* @__PURE__ */ jsx2(
1058
1548
  "div",
1059
1549
  {
1060
1550
  className: "grid h-full place-items-center bg-og-bg p-6 text-center",
1061
1551
  style: { minHeight: 224 },
1062
1552
  children: /* @__PURE__ */ jsxs("div", { children: [
1063
- /* @__PURE__ */ jsx("p", { className: "text-og-base font-medium text-og-fg", children: "This workbook has no worksheets." }),
1064
- !readOnly && allowAddSheet ? /* @__PURE__ */ jsx(
1553
+ /* @__PURE__ */ jsx2("p", { className: "text-og-base font-medium text-og-fg", children: t("artifacts.spreadsheetGrid.thisWorkbookHasNoWorksheets") }),
1554
+ !readOnly && allowAddSheet ? /* @__PURE__ */ jsx2(
1065
1555
  "button",
1066
1556
  {
1067
1557
  type: "button",
1068
1558
  onClick: addSheet,
1069
- className: "mt-3 rounded-og-sm bg-og-accent-deep px-3 py-1.5 text-og-sm font-medium text-og-accent-fg",
1070
- children: "Add worksheet"
1559
+ className: "mt-3 rounded-og-sm border border-og-primary-border bg-og-primary text-og-primary-fg px-3 py-1.5 text-og-sm font-medium hover:bg-og-primary-hover",
1560
+ children: t("artifacts.spreadsheetGrid.addWorksheet")
1071
1561
  }
1072
1562
  ) : null
1073
1563
  ] })
@@ -1086,12 +1576,13 @@ function SpreadsheetGrid({
1086
1576
  overscanColumns = 2,
1087
1577
  onSelectionChange,
1088
1578
  onCommit,
1579
+ onResize,
1089
1580
  onViewportChange,
1090
1581
  className
1091
1582
  }) {
1092
1583
  const { revision, dimensionRevision } = useWorkbookViewState(workbook);
1093
1584
  const boundedProjection = requestedRowCount !== void 0 || requestedColumnCount !== void 0;
1094
- const usedRange = useMemo(() => {
1585
+ const usedRange = useMemo2(() => {
1095
1586
  void revision;
1096
1587
  return boundedProjection ? worksheet.usedRangeAddress() : null;
1097
1588
  }, [boundedProjection, revision, worksheet]);
@@ -1111,15 +1602,15 @@ function SpreadsheetGrid({
1111
1602
  MAX_COLUMNS,
1112
1603
  MAX_COLUMNS
1113
1604
  );
1114
- const rowHeights = useMemo(() => {
1605
+ const rowHeights = useMemo2(() => {
1115
1606
  void dimensionRevision;
1116
1607
  return [...worksheet.rowHeightEntries()];
1117
1608
  }, [dimensionRevision, worksheet]);
1118
- const columnWidths = useMemo(() => {
1609
+ const columnWidths = useMemo2(() => {
1119
1610
  void dimensionRevision;
1120
1611
  return [...worksheet.columnWidthEntries()];
1121
1612
  }, [dimensionRevision, worksheet]);
1122
- const projection = useMemo(() => {
1613
+ const projection = useMemo2(() => {
1123
1614
  void dimensionRevision;
1124
1615
  const cells = new SparseSpreadsheetCellIndex(
1125
1616
  function* projectedCells() {
@@ -1153,7 +1644,7 @@ function SpreadsheetGrid({
1153
1644
  const data = worksheet.cellData(row, col);
1154
1645
  return {
1155
1646
  value: data.formula ? workbook.valueAt(worksheet, { row, col }) : data.value,
1156
- input: data.formula ?? displayValue2(data.value),
1647
+ input: data.formula ?? spreadsheetCellEditSource(data.value),
1157
1648
  format: data.format
1158
1649
  };
1159
1650
  }
@@ -1169,7 +1660,7 @@ function SpreadsheetGrid({
1169
1660
  workbook,
1170
1661
  worksheet
1171
1662
  ]);
1172
- const commit = useCallback(
1663
+ const commit = useCallback3(
1173
1664
  (next) => {
1174
1665
  const target = worksheet.getCell(next.cell.row, next.cell.col);
1175
1666
  if (next.kind === "formula") target.formulas = [[next.input]];
@@ -1178,7 +1669,7 @@ function SpreadsheetGrid({
1178
1669
  },
1179
1670
  [onCommit, worksheet]
1180
1671
  );
1181
- const commitRange = useCallback(
1672
+ const commitRange = useCallback3(
1182
1673
  (next) => {
1183
1674
  if (next.rows * next.columns !== next.inputs.length) {
1184
1675
  throw new Error("Spreadsheet paste shape is invalid");
@@ -1199,7 +1690,7 @@ function SpreadsheetGrid({
1199
1690
  },
1200
1691
  [workbook, worksheet]
1201
1692
  );
1202
- const clear = useCallback(
1693
+ const clear = useCallback3(
1203
1694
  (next) => {
1204
1695
  const normalized = normalizeSelection(next);
1205
1696
  worksheet.getRangeByIndexes(
@@ -1211,7 +1702,15 @@ function SpreadsheetGrid({
1211
1702
  },
1212
1703
  [worksheet]
1213
1704
  );
1214
- return /* @__PURE__ */ jsx(
1705
+ const resize = useCallback3(
1706
+ (change) => {
1707
+ if (change.axis === "column") worksheet.setColumnWidth(change.index, change.size);
1708
+ else worksheet.setRowHeight(change.index, change.size);
1709
+ onResize?.(change);
1710
+ },
1711
+ [onResize, worksheet]
1712
+ );
1713
+ return /* @__PURE__ */ jsx2(
1215
1714
  SpreadsheetProjectionGrid,
1216
1715
  {
1217
1716
  projection,
@@ -1222,6 +1721,7 @@ function SpreadsheetGrid({
1222
1721
  commit,
1223
1722
  commitRange,
1224
1723
  clear,
1724
+ resize,
1225
1725
  onViewportChange,
1226
1726
  className
1227
1727
  }
@@ -1236,65 +1736,118 @@ function SpreadsheetProjectionGrid({
1236
1736
  commit,
1237
1737
  commitRange,
1238
1738
  clear,
1739
+ resize,
1740
+ pendingTransactions = 0,
1741
+ syncStatus,
1742
+ syncError,
1239
1743
  onCommandError,
1240
1744
  onViewportChange,
1241
1745
  className
1242
1746
  }) {
1747
+ const t = useOpenGeniText();
1243
1748
  const { revision, rowCount, columnCount } = projection;
1244
- const dimensionRevision = projection.dimensionRevision ?? 0;
1245
1749
  const editable = !readOnly && commit !== void 0;
1246
- const rows = useMemo(() => {
1247
- void dimensionRevision;
1248
- return buildAxis(rowCount, projection.defaultRowHeight ?? 24, projection.rowHeights ?? []);
1249
- }, [dimensionRevision, projection.defaultRowHeight, projection.rowHeights, rowCount]);
1250
- const columns = useMemo(() => {
1251
- void dimensionRevision;
1252
- return buildAxis(
1253
- columnCount,
1254
- projection.defaultColumnWidth ?? 96,
1255
- projection.columnWidths ?? []
1256
- );
1257
- }, [columnCount, dimensionRevision, projection.columnWidths, projection.defaultColumnWidth]);
1258
- const canvasRows = useMemo(() => canvasAxis(rows), [rows]);
1259
- const canvasColumns = useMemo(() => canvasAxis(columns), [columns]);
1260
- const [selection, setSelection] = useState(() => ({
1750
+ const commandQueue = useSpreadsheetCommandQueue({
1751
+ scopeKey: `${projection.sheetId}:${projection.generationId ?? "none"}`,
1752
+ enabled: editable,
1753
+ onCommandError
1754
+ });
1755
+ const [commandFailure, setCommandFailure] = useState3(null);
1756
+ const clearPreflightFailure = commandQueue.clearPreflightFailure;
1757
+ const clearCommandFailure = useCallback3(() => {
1758
+ setCommandFailure(null);
1759
+ clearPreflightFailure();
1760
+ }, [clearPreflightFailure]);
1761
+ const resizing = useSpreadsheetResizing({
1762
+ sheetId: projection.sheetId,
1763
+ generationId: projection.generationId,
1764
+ revision: projection.dimensionRevision ?? revision,
1765
+ rowHeights: projection.rowHeights ?? EMPTY_DIMENSIONS,
1766
+ columnWidths: projection.columnWidths ?? EMPTY_DIMENSIONS,
1767
+ defaultRowHeight: projection.defaultRowHeight ?? 24,
1768
+ defaultColumnWidth: projection.defaultColumnWidth ?? 96,
1769
+ enabled: !readOnly && resize !== void 0,
1770
+ commit: resize,
1771
+ onCommandError,
1772
+ onStart: clearCommandFailure
1773
+ });
1774
+ const dimensionRevision = `${projection.dimensionRevision ?? 0}:${resizing.previewKey}`;
1775
+ const rows = useMemo2(() => {
1776
+ return buildAxis(rowCount, projection.defaultRowHeight ?? 24, resizing.rowHeights);
1777
+ }, [projection.defaultRowHeight, resizing.rowHeights, rowCount]);
1778
+ const columns = useMemo2(() => {
1779
+ return buildAxis(columnCount, projection.defaultColumnWidth ?? 96, resizing.columnWidths);
1780
+ }, [columnCount, resizing.columnWidths, projection.defaultColumnWidth]);
1781
+ const canvasRows = useMemo2(() => canvasAxis(rows), [rows]);
1782
+ const canvasColumns = useMemo2(() => canvasAxis(columns), [columns]);
1783
+ const [selection, setSelection] = useState3(() => ({
1261
1784
  sheetId: projection.sheetId,
1262
1785
  anchor: { row: 0, col: 0 },
1263
1786
  focus: { row: 0, col: 0 }
1264
1787
  }));
1265
- const [editMode, setEditMode] = useState(null);
1266
- const [draft, setDraft] = useState(
1788
+ const [editMode, setEditMode] = useState3(null);
1789
+ const [draft, setDraft] = useState3(
1267
1790
  () => projection.readCell(selection.focus.row, selection.focus.col)?.input ?? ""
1268
1791
  );
1269
- const [pendingCommands, setPendingCommands] = useState(0);
1270
- const [commandFailure, setCommandFailure] = useState(null);
1271
- const [viewport, setViewport] = useState({
1792
+ const visibleCommandFailure = resizing.error ?? commandQueue.error ?? commandFailure ?? (syncError ? { message: syncError, retry: void 0 } : null);
1793
+ const pendingCommandCount = commandQueue.pendingCount + resizing.pendingCount + pendingTransactions;
1794
+ const visibleSyncStatus = pendingCommandCount > 0 && (!syncStatus || syncStatus === t("artifacts.editableSpreadsheet.saved") || syncStatus === t("artifacts.editableSpreadsheet.readOnly")) ? t("artifacts.spreadsheetGrid.saving") : syncStatus;
1795
+ const runQueuedCommand = commandQueue.run;
1796
+ const [viewport, setViewport] = useState3({
1272
1797
  width: FALLBACK_VIEWPORT_WIDTH,
1273
1798
  height: FALLBACK_VIEWPORT_HEIGHT,
1274
1799
  scrollLeft: 0,
1275
1800
  scrollTop: 0,
1276
1801
  devicePixelRatio: 1
1277
1802
  });
1278
- const [canvasReady, setCanvasReady] = useState(false);
1279
- const [canvasEpoch, setCanvasEpoch] = useState(0);
1280
- const viewportRef = useRef(null);
1281
- const canvasRef = useRef(null);
1282
- const editorRef = useRef(null);
1283
- const selectionRef = useRef(selection);
1284
- const selectingRef = useRef(null);
1285
- const committingRef = useRef(false);
1286
- const composingRef = useRef(false);
1287
- const commitAfterCompositionRef = useRef(false);
1288
- const selectDraftOnFocusRef = useRef(true);
1289
- const initialDraftRef = useRef(draft);
1290
- const optimisticInputRef = useRef(null);
1291
- const mountedRef = useRef(true);
1292
- const commandScopeRef = useRef(0);
1293
- const latestCommandRef = useRef(0);
1294
- const canvasRendererRef = useRef(null);
1803
+ const [canvasReady, setCanvasReady] = useState3(false);
1804
+ const [canvasEpoch, setCanvasEpoch] = useState3(0);
1805
+ const viewportRef = useRef3(null);
1806
+ const canvasRef = useRef3(null);
1807
+ const editorRef = useRef3(null);
1808
+ const selectionRef = useRef3(selection);
1809
+ const selectingRef = useRef3(null);
1810
+ const committingRef = useRef3(false);
1811
+ const composingRef = useRef3(false);
1812
+ const commitAfterCompositionRef = useRef3(false);
1813
+ const selectDraftOnFocusRef = useRef3(true);
1814
+ const initialDraftRef = useRef3(draft);
1815
+ const optimisticInputsRef = useRef3(
1816
+ /* @__PURE__ */ new Map()
1817
+ );
1818
+ const [optimisticEpoch, setOptimisticEpoch] = useState3(0);
1819
+ const refreshOptimisticInputs = useCallback3(() => setOptimisticEpoch((value) => value + 1), []);
1820
+ const optimisticScope = `${projection.sheetId}:${projection.generationId ?? "none"}`;
1821
+ const optimisticScopeRef = useRef3(optimisticScope);
1822
+ if (optimisticScopeRef.current !== optimisticScope) {
1823
+ optimisticScopeRef.current = optimisticScope;
1824
+ optimisticInputsRef.current.clear();
1825
+ }
1826
+ const projectionRef = useRef3(projection);
1827
+ projectionRef.current = projection;
1828
+ const editModeRef = useRef3(editMode);
1829
+ editModeRef.current = editMode;
1830
+ const canvasRendererRef = useRef3(null);
1295
1831
  if (!canvasRendererRef.current) canvasRendererRef.current = new SpreadsheetCanvasRenderer();
1296
1832
  const reactId = useId().replaceAll(":", "");
1297
- const updateSelection = useCallback(
1833
+ const readEditInput = useCallback3(
1834
+ (cell) => optimisticInputsRef.current.get(`${cell.row}:${cell.col}`)?.input ?? projectionRef.current.readCell(cell.row, cell.col)?.input ?? "",
1835
+ []
1836
+ );
1837
+ const forgetOptimisticInputs = useCallback3(
1838
+ (target) => {
1839
+ let changed = false;
1840
+ for (const [key, entry] of optimisticInputsRef.current) {
1841
+ if (entry.row >= target.top && entry.row <= target.bottom && entry.col >= target.left && entry.col <= target.right) {
1842
+ optimisticInputsRef.current.delete(key);
1843
+ changed = true;
1844
+ }
1845
+ }
1846
+ if (changed) refreshOptimisticInputs();
1847
+ },
1848
+ [refreshOptimisticInputs]
1849
+ );
1850
+ const updateSelection = useCallback3(
1298
1851
  (next) => {
1299
1852
  selectionRef.current = next;
1300
1853
  setSelection(next);
@@ -1302,39 +1855,44 @@ function SpreadsheetProjectionGrid({
1302
1855
  },
1303
1856
  [onSelectionChange]
1304
1857
  );
1305
- useEffect(() => {
1858
+ useEffect3(() => {
1306
1859
  if (selection.sheetId === projection.sheetId) return;
1307
- commandScopeRef.current += 1;
1308
- latestCommandRef.current += 1;
1309
1860
  const next = {
1310
1861
  sheetId: projection.sheetId,
1311
1862
  anchor: { row: 0, col: 0 },
1312
1863
  focus: { row: 0, col: 0 }
1313
1864
  };
1314
- optimisticInputRef.current = null;
1315
- setPendingCommands(0);
1865
+ optimisticInputsRef.current.clear();
1316
1866
  setCommandFailure(null);
1317
1867
  setEditMode(null);
1318
1868
  updateSelection(next);
1319
1869
  }, [projection.sheetId, selection.sheetId, updateSelection]);
1320
- useEffect(() => {
1321
- mountedRef.current = true;
1322
- return () => {
1323
- mountedRef.current = false;
1324
- commandScopeRef.current += 1;
1325
- latestCommandRef.current += 1;
1326
- };
1327
- }, []);
1328
- useEffect(() => {
1329
- if (editMode !== null) return;
1330
- const optimistic = optimisticInputRef.current;
1331
- if (optimistic?.sheetId === projection.sheetId && optimistic.row === selection.focus.row && optimistic.col === selection.focus.col && optimistic.baseRevision === revision) {
1332
- setDraft(optimistic.input);
1333
- return;
1870
+ useEffect3(() => {
1871
+ optimisticInputsRef.current.clear();
1872
+ refreshOptimisticInputs();
1873
+ }, [projection.generationId, projection.sheetId, refreshOptimisticInputs]);
1874
+ useClientLayoutEffect(() => {
1875
+ let changed = false;
1876
+ for (const [key, optimistic] of optimisticInputsRef.current) {
1877
+ const coverage = projection.coverage;
1878
+ const covered = !coverage || optimistic.row >= coverage.rowStart && optimistic.row < coverage.rowEnd && optimistic.col >= coverage.columnStart && optimistic.col < coverage.columnEnd;
1879
+ if (!optimistic.pending && covered && (projection.readCell(optimistic.row, optimistic.col)?.input === optimistic.input || revision !== optimistic.baseRevision)) {
1880
+ optimisticInputsRef.current.delete(key);
1881
+ changed = true;
1882
+ }
1334
1883
  }
1335
- if (optimistic && optimistic.baseRevision !== revision) optimisticInputRef.current = null;
1336
- setDraft(projection.readCell(selection.focus.row, selection.focus.col)?.input ?? "");
1337
- }, [editMode, projection, revision, selection.focus.col, selection.focus.row]);
1884
+ if (changed) refreshOptimisticInputs();
1885
+ if (editMode === null) setDraft(readEditInput(selection.focus));
1886
+ }, [
1887
+ commandQueue.pendingCount,
1888
+ editMode,
1889
+ projection,
1890
+ readEditInput,
1891
+ revision,
1892
+ selection.focus,
1893
+ refreshOptimisticInputs,
1894
+ optimisticEpoch
1895
+ ]);
1338
1896
  useClientLayoutEffect(() => {
1339
1897
  const element = viewportRef.current;
1340
1898
  if (!element) return;
@@ -1355,10 +1913,10 @@ function SpreadsheetProjectionGrid({
1355
1913
  globalThis.removeEventListener?.("resize", measure);
1356
1914
  };
1357
1915
  }, []);
1358
- useEffect(() => {
1916
+ useEffect3(() => {
1359
1917
  return () => canvasRendererRef.current?.dispose();
1360
1918
  }, []);
1361
- useEffect(() => {
1919
+ useEffect3(() => {
1362
1920
  if (typeof document === "undefined") return;
1363
1921
  let active = true;
1364
1922
  void document.fonts?.ready.then(() => {
@@ -1383,7 +1941,7 @@ function SpreadsheetProjectionGrid({
1383
1941
  observer.disconnect();
1384
1942
  };
1385
1943
  }, []);
1386
- useEffect(() => {
1944
+ useEffect3(() => {
1387
1945
  if (editMode !== "cell") return;
1388
1946
  const editor = editorRef.current;
1389
1947
  editor?.focus();
@@ -1391,7 +1949,7 @@ function SpreadsheetProjectionGrid({
1391
1949
  if (selectDraftOnFocusRef.current) editor.select();
1392
1950
  else editor.setSelectionRange(editor.value.length, editor.value.length);
1393
1951
  }, [editMode]);
1394
- const ensureVisible = useCallback(
1952
+ const ensureVisible = useCallback3(
1395
1953
  (cell) => {
1396
1954
  const element = viewportRef.current;
1397
1955
  if (!element) return;
@@ -1428,7 +1986,7 @@ function SpreadsheetProjectionGrid({
1428
1986
  },
1429
1987
  [columns, rows]
1430
1988
  );
1431
- const moveSelection = useCallback(
1989
+ const moveSelection = useCallback3(
1432
1990
  (rowDelta, colDelta, extend) => {
1433
1991
  const focus = {
1434
1992
  row: Math.max(0, Math.min(rowCount - 1, selection.focus.row + rowDelta)),
@@ -1444,53 +2002,24 @@ function SpreadsheetProjectionGrid({
1444
2002
  },
1445
2003
  [columnCount, ensureVisible, projection.sheetId, rowCount, selection, updateSelection]
1446
2004
  );
1447
- const runCommand = useCallback(
1448
- (invoke, retry, rollback) => {
1449
- const commandId = latestCommandRef.current + 1;
1450
- latestCommandRef.current = commandId;
1451
- const scope = commandScopeRef.current;
2005
+ const runCommand = useCallback3(
2006
+ (invoke, retry, rollback, target, accepted) => {
1452
2007
  setCommandFailure(null);
1453
- const fail = (cause) => {
1454
- if (!mountedRef.current || commandScopeRef.current !== scope || latestCommandRef.current !== commandId) {
1455
- return;
1456
- }
1457
- const error = cause instanceof Error ? cause : new Error(String(cause));
1458
- rollback();
1459
- setCommandFailure({ message: error.message || "Spreadsheet change failed", retry });
1460
- onCommandError?.(error);
1461
- };
1462
- let result;
1463
- try {
1464
- result = invoke();
1465
- } catch (cause) {
1466
- fail(cause);
1467
- return;
1468
- }
1469
- if (!result || typeof result.then !== "function") return;
1470
- setPendingCommands((current) => current + 1);
1471
- void Promise.resolve(result).then(
1472
- () => {
1473
- if (!mountedRef.current || commandScopeRef.current !== scope) return;
1474
- setPendingCommands((current) => Math.max(0, current - 1));
1475
- },
1476
- (cause) => {
1477
- if (!mountedRef.current || commandScopeRef.current !== scope) return;
1478
- setPendingCommands((current) => Math.max(0, current - 1));
1479
- fail(cause);
1480
- }
1481
- );
2008
+ runQueuedCommand(invoke, retry, rollback, target, accepted);
1482
2009
  },
1483
- [onCommandError]
2010
+ [runQueuedCommand]
1484
2011
  );
1485
- const reportCommandFailure = useCallback(
2012
+ const reportCommandFailure = useCallback3(
1486
2013
  (cause) => {
1487
2014
  const error = cause instanceof Error ? cause : new Error(String(cause));
1488
- setCommandFailure({ message: error.message || "Spreadsheet action failed" });
2015
+ setCommandFailure({
2016
+ message: error.message || t("artifacts.spreadsheetGrid.spreadsheetActionFailed")
2017
+ });
1489
2018
  onCommandError?.(error);
1490
2019
  },
1491
- [onCommandError]
2020
+ [onCommandError, t]
1492
2021
  );
1493
- const commitDraft = useCallback(
2022
+ const commitDraft = useCallback3(
1494
2023
  (input = draft) => {
1495
2024
  if (committingRef.current) return;
1496
2025
  committingRef.current = true;
@@ -1516,21 +2045,41 @@ function SpreadsheetProjectionGrid({
1516
2045
  kind: input.startsWith("=") ? "formula" : "value"
1517
2046
  };
1518
2047
  const execute = () => {
1519
- optimisticInputRef.current = {
1520
- sheetId: projection.sheetId,
1521
- row: selection.focus.row,
1522
- col: selection.focus.col,
1523
- input,
1524
- baseRevision: revision
1525
- };
1526
- setDraft(input);
2048
+ const retryFocus = selectionRef.current.focus;
2049
+ if (editModeRef.current === null && retryFocus.row === next.cell.row && retryFocus.col === next.cell.col) {
2050
+ setDraft(input);
2051
+ }
2052
+ const key = `${next.cell.row}:${next.cell.col}`;
1527
2053
  runCommand(
1528
- () => commit(next),
2054
+ (commandId) => {
2055
+ optimisticInputsRef.current.set(key, {
2056
+ ...next.cell,
2057
+ input,
2058
+ baseRevision: revision,
2059
+ commandId,
2060
+ pending: true
2061
+ });
2062
+ refreshOptimisticInputs();
2063
+ return commit(next);
2064
+ },
1529
2065
  execute,
1530
- () => {
1531
- optimisticInputRef.current = null;
2066
+ (commandId) => {
2067
+ if (optimisticInputsRef.current.get(key)?.commandId !== commandId) return;
2068
+ optimisticInputsRef.current.delete(key);
2069
+ refreshOptimisticInputs();
1532
2070
  const current = selectionRef.current.focus;
1533
- setDraft(projection.readCell(current.row, current.col)?.input ?? "");
2071
+ if (editModeRef.current === null && current.row === next.cell.row && current.col === next.cell.col) {
2072
+ setDraft(readEditInput(current));
2073
+ }
2074
+ },
2075
+ { top: next.cell.row, bottom: next.cell.row, left: next.cell.col, right: next.cell.col },
2076
+ (commandId) => {
2077
+ const optimistic = optimisticInputsRef.current.get(key);
2078
+ if (optimistic?.commandId === commandId) {
2079
+ optimistic.pending = false;
2080
+ optimistic.baseRevision = projectionRef.current.revision;
2081
+ refreshOptimisticInputs();
2082
+ }
1534
2083
  }
1535
2084
  );
1536
2085
  };
@@ -1542,36 +2091,64 @@ function SpreadsheetProjectionGrid({
1542
2091
  committingRef.current = false;
1543
2092
  });
1544
2093
  },
1545
- [commit, draft, editable, projection, revision, runCommand, selection.focus]
2094
+ [
2095
+ commit,
2096
+ draft,
2097
+ editable,
2098
+ projection,
2099
+ readEditInput,
2100
+ revision,
2101
+ runCommand,
2102
+ selection.focus,
2103
+ refreshOptimisticInputs
2104
+ ]
1546
2105
  );
1547
- const clearSelection = useCallback(() => {
2106
+ const clearSelection = useCallback3(() => {
1548
2107
  if (!editable || !clear) return;
1549
2108
  const current = selection;
2109
+ const target = normalizeSelection(current);
1550
2110
  const execute = () => runCommand(
1551
- () => clear(current),
2111
+ () => {
2112
+ forgetOptimisticInputs(target);
2113
+ return clear(current);
2114
+ },
1552
2115
  execute,
1553
2116
  () => {
1554
- }
2117
+ },
2118
+ target
1555
2119
  );
1556
2120
  execute();
1557
- }, [clear, editable, runCommand, selection]);
1558
- const pasteClipboard = useCallback(
2121
+ }, [clear, editable, forgetOptimisticInputs, runCommand, selection]);
2122
+ const pasteClipboard = useCallback3(
1559
2123
  (event) => {
1560
2124
  if (!editable || editMode !== null) return;
1561
2125
  const clipboardText = event.clipboardData.getData("text/plain");
1562
2126
  if (!clipboardText && !event.clipboardData.types.includes("text/plain")) return;
1563
2127
  event.preventDefault();
2128
+ const previousSelection = selectionRef.current;
2129
+ const anchor = previousSelection.focus;
1564
2130
  const execute = () => {
1565
- const previousSelection = selectionRef.current;
1566
- const invoke = () => {
1567
- const parsed = parseSpreadsheetClipboard(clipboardText);
1568
- const anchor = previousSelection.focus;
1569
- if (anchor.row + parsed.rows > rowCount || anchor.col + parsed.columns > columnCount) {
1570
- throw new Error("Clipboard range does not fit in this worksheet");
2131
+ let prepared;
2132
+ let target;
2133
+ const prepare = () => {
2134
+ prepared = parseSpreadsheetClipboard(t, clipboardText);
2135
+ if (anchor.row + prepared.rows > rowCount || anchor.col + prepared.columns > columnCount) {
2136
+ throw new Error(t("artifacts.spreadsheetGrid.clipboardRangeDoesNotFit"));
1571
2137
  }
1572
- if (!commitRange && parsed.inputs.length !== 1) {
1573
- throw new Error("This spreadsheet adapter does not support rectangular paste");
2138
+ if (!commitRange && prepared.inputs.length !== 1) {
2139
+ throw new Error(t("artifacts.spreadsheetGrid.thisSpreadsheetAdapterDoesNot"));
1574
2140
  }
2141
+ target = {
2142
+ top: anchor.row,
2143
+ left: anchor.col,
2144
+ bottom: anchor.row + prepared.rows - 1,
2145
+ right: anchor.col + prepared.columns - 1
2146
+ };
2147
+ return target;
2148
+ };
2149
+ const invoke = () => {
2150
+ const parsed = prepared;
2151
+ forgetOptimisticInputs(target);
1575
2152
  const bottomRight = {
1576
2153
  row: anchor.row + parsed.rows - 1,
1577
2154
  col: anchor.col + parsed.columns - 1
@@ -1599,7 +2176,17 @@ function SpreadsheetProjectionGrid({
1599
2176
  kind: input.startsWith("=") ? "formula" : "value"
1600
2177
  });
1601
2178
  };
1602
- runCommand(invoke, execute, () => updateSelection(previousSelection));
2179
+ runCommand(
2180
+ invoke,
2181
+ execute,
2182
+ () => {
2183
+ const current = selectionRef.current;
2184
+ if (target && current.anchor.row === anchor.row && current.anchor.col === anchor.col && current.focus.row === target.bottom && current.focus.col === target.right) {
2185
+ updateSelection(previousSelection);
2186
+ }
2187
+ },
2188
+ prepare
2189
+ );
1603
2190
  };
1604
2191
  execute();
1605
2192
  },
@@ -1610,13 +2197,15 @@ function SpreadsheetProjectionGrid({
1610
2197
  editMode,
1611
2198
  editable,
1612
2199
  ensureVisible,
2200
+ forgetOptimisticInputs,
1613
2201
  projection.sheetId,
1614
2202
  rowCount,
1615
2203
  runCommand,
1616
- updateSelection
2204
+ updateSelection,
2205
+ t
1617
2206
  ]
1618
2207
  );
1619
- const copySelection = useCallback(
2208
+ const copySelection = useCallback3(
1620
2209
  (event) => {
1621
2210
  if (editMode !== null) return;
1622
2211
  const selected = normalizeSelection(selectionRef.current);
@@ -1624,13 +2213,15 @@ function SpreadsheetProjectionGrid({
1624
2213
  const columnsToCopy = selected.right - selected.left + 1;
1625
2214
  if (rowsToCopy * columnsToCopy > MAX_CLIPBOARD_CELLS) {
1626
2215
  event.preventDefault();
1627
- reportCommandFailure(new Error("Selected range is too large to copy"));
2216
+ reportCommandFailure(new Error(t("artifacts.spreadsheetGrid.selectedRangeIsTooLarge")));
1628
2217
  return;
1629
2218
  }
1630
2219
  const coverage = projection.coverage;
1631
2220
  if (coverage && (selected.top < coverage.rowStart || selected.bottom >= coverage.rowEnd || selected.left < coverage.columnStart || selected.right >= coverage.columnEnd)) {
1632
2221
  event.preventDefault();
1633
- reportCommandFailure(new Error("Selected cells are still loading; copy again when ready"));
2222
+ reportCommandFailure(
2223
+ new Error(t("artifacts.spreadsheetGrid.selectedCellsAreStillLoading"))
2224
+ );
1634
2225
  return;
1635
2226
  }
1636
2227
  const output = [];
@@ -1645,21 +2236,21 @@ function SpreadsheetProjectionGrid({
1645
2236
  event.preventDefault();
1646
2237
  setCommandFailure(null);
1647
2238
  },
1648
- [editMode, projection, reportCommandFailure]
2239
+ [editMode, projection, reportCommandFailure, t]
1649
2240
  );
1650
- const beginEditing = useCallback(
2241
+ const beginEditing = useCallback3(
1651
2242
  (initial, cell = selectionRef.current.focus) => {
1652
2243
  if (!editable) return;
1653
2244
  ensureVisible(cell);
1654
- const current = projection.readCell(cell.row, cell.col)?.input ?? "";
2245
+ const current = readEditInput(cell);
1655
2246
  initialDraftRef.current = current;
1656
2247
  selectDraftOnFocusRef.current = initial === void 0;
1657
2248
  setDraft(initial ?? current);
1658
2249
  setEditMode("cell");
1659
2250
  },
1660
- [editable, ensureVisible, projection]
2251
+ [editable, ensureVisible, readEditInput]
1661
2252
  );
1662
- const onGridKeyDown = useCallback(
2253
+ const onGridKeyDown = useCallback3(
1663
2254
  (event) => {
1664
2255
  if (editMode !== null) return;
1665
2256
  if (event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) return;
@@ -1733,7 +2324,7 @@ function SpreadsheetProjectionGrid({
1733
2324
  projection.usedRange
1734
2325
  ]
1735
2326
  );
1736
- const onEditorKeyDown = useCallback(
2327
+ const onEditorKeyDown = useCallback3(
1737
2328
  (event) => {
1738
2329
  if (composingRef.current || event.nativeEvent.isComposing) return;
1739
2330
  if (event.key === "Enter") {
@@ -1742,7 +2333,7 @@ function SpreadsheetProjectionGrid({
1742
2333
  } else if (event.key === "Escape") {
1743
2334
  event.preventDefault();
1744
2335
  committingRef.current = true;
1745
- setDraft(projection.readCell(selection.focus.row, selection.focus.col)?.input ?? "");
2336
+ setDraft(readEditInput(selection.focus));
1746
2337
  setEditMode(null);
1747
2338
  viewportRef.current?.focus();
1748
2339
  queueMicrotask(() => {
@@ -1750,12 +2341,12 @@ function SpreadsheetProjectionGrid({
1750
2341
  });
1751
2342
  }
1752
2343
  },
1753
- [commitDraft, projection, selection.focus.col, selection.focus.row]
2344
+ [commitDraft, readEditInput, selection.focus]
1754
2345
  );
1755
- const onEditorCompositionStart = useCallback(() => {
2346
+ const onEditorCompositionStart = useCallback3(() => {
1756
2347
  composingRef.current = true;
1757
2348
  }, []);
1758
- const onEditorCompositionEnd = useCallback(
2349
+ const onEditorCompositionEnd = useCallback3(
1759
2350
  (input) => {
1760
2351
  composingRef.current = false;
1761
2352
  if (!commitAfterCompositionRef.current) return;
@@ -1764,7 +2355,7 @@ function SpreadsheetProjectionGrid({
1764
2355
  },
1765
2356
  [commitDraft]
1766
2357
  );
1767
- const commitEditorOnBlur = useCallback(
2358
+ const commitEditorOnBlur = useCallback3(
1768
2359
  (mode, input) => {
1769
2360
  if (editMode !== mode) return;
1770
2361
  if (composingRef.current) {
@@ -1775,7 +2366,7 @@ function SpreadsheetProjectionGrid({
1775
2366
  },
1776
2367
  [commitDraft, editMode]
1777
2368
  );
1778
- const selectCell = useCallback(
2369
+ const selectCell = useCallback3(
1779
2370
  (cell, extend) => {
1780
2371
  const current = selectionRef.current;
1781
2372
  const next = {
@@ -1789,7 +2380,7 @@ function SpreadsheetProjectionGrid({
1789
2380
  },
1790
2381
  [projection.sheetId, updateSelection]
1791
2382
  );
1792
- const hitTestCell = useCallback(
2383
+ const hitTestCell = useCallback3(
1793
2384
  (clientX, clientY) => {
1794
2385
  const element = viewportRef.current;
1795
2386
  if (!element) return null;
@@ -1815,7 +2406,7 @@ function SpreadsheetProjectionGrid({
1815
2406
  },
1816
2407
  [columnCount, columns, rowCount, rows]
1817
2408
  );
1818
- const onGridPointerDown = useCallback(
2409
+ const onGridPointerDown = useCallback3(
1819
2410
  (event) => {
1820
2411
  if (event.button !== 0) return;
1821
2412
  const cell = hitTestCell(event.clientX, event.clientY);
@@ -1834,7 +2425,7 @@ function SpreadsheetProjectionGrid({
1834
2425
  },
1835
2426
  [hitTestCell, projection.sheetId, updateSelection]
1836
2427
  );
1837
- const onGridPointerMove = useCallback(
2428
+ const onGridPointerMove = useCallback3(
1838
2429
  (event) => {
1839
2430
  const selecting = selectingRef.current;
1840
2431
  if (!selecting || selecting.pointerId !== event.pointerId) return;
@@ -1846,11 +2437,11 @@ function SpreadsheetProjectionGrid({
1846
2437
  },
1847
2438
  [hitTestCell, projection.sheetId, updateSelection]
1848
2439
  );
1849
- const stopPointerSelection = useCallback((pointerId) => {
2440
+ const stopPointerSelection = useCallback3((pointerId) => {
1850
2441
  if (pointerId !== void 0 && selectingRef.current?.pointerId !== pointerId) return;
1851
2442
  selectingRef.current = null;
1852
2443
  }, []);
1853
- useEffect(() => {
2444
+ useEffect3(() => {
1854
2445
  if (typeof window === "undefined") return;
1855
2446
  const stopSelecting = () => stopPointerSelection();
1856
2447
  window.addEventListener("pointerup", stopSelecting);
@@ -1906,7 +2497,7 @@ function SpreadsheetProjectionGrid({
1906
2497
  const activeCellVisible = selection.focus.row >= rowWindow.start && selection.focus.row < rowWindow.end && selection.focus.col >= columnWindow.start && selection.focus.col < columnWindow.end;
1907
2498
  const activeCellId = `${reactId}-cell-${selection.focus.row}-${selection.focus.col}`;
1908
2499
  const hiddenActiveValue = activeCellVisible ? null : projection.readCell(selection.focus.row, selection.focus.col)?.value;
1909
- useEffect(() => {
2500
+ useEffect3(() => {
1910
2501
  if (!onViewportChange) return;
1911
2502
  const next = {
1912
2503
  sheetId: projection.sheetId,
@@ -2016,30 +2607,30 @@ function SpreadsheetProjectionGrid({
2016
2607
  "div",
2017
2608
  {
2018
2609
  className: cn("relative flex h-full min-w-0 flex-col bg-og-bg", className),
2019
- "data-og-command-state": commandFailure ? "error" : pendingCommands > 0 ? "pending" : "idle",
2610
+ "data-og-command-state": visibleCommandFailure ? "error" : pendingCommandCount > 0 ? "pending" : "idle",
2020
2611
  style: { minHeight: 256 },
2021
2612
  children: [
2022
2613
  /* @__PURE__ */ jsxs("div", { className: "flex min-h-9 shrink-0 items-center border-b border-og-border bg-og-surface-1", children: [
2023
- /* @__PURE__ */ jsx(
2614
+ /* @__PURE__ */ jsx2(
2024
2615
  "output",
2025
2616
  {
2026
- "aria-label": "Selected range",
2617
+ "aria-label": t("artifacts.spreadsheetGrid.selectedRange"),
2027
2618
  className: "shrink-0 border-r border-og-border px-2 font-mono text-og-xs text-og-fg-muted",
2028
2619
  style: { width: 96 },
2029
2620
  children: selectionName(selection)
2030
2621
  }
2031
2622
  ),
2032
- /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "px-2 font-og-mono text-og-sm italic text-og-fg-subtle", children: "fx" }),
2033
- /* @__PURE__ */ jsx(
2623
+ /* @__PURE__ */ jsx2("span", { "aria-hidden": true, className: "px-2 font-og-mono text-og-sm italic text-og-fg-subtle", children: t("artifacts.spreadsheetGrid.fx") }),
2624
+ /* @__PURE__ */ jsx2(
2034
2625
  "input",
2035
2626
  {
2036
- "aria-label": "Formula or value",
2627
+ "aria-label": t("artifacts.spreadsheetGrid.formulaOrValue"),
2037
2628
  readOnly: !editable,
2038
- "aria-invalid": commandFailure ? "true" : void 0,
2629
+ "aria-invalid": visibleCommandFailure ? "true" : void 0,
2039
2630
  value: draft,
2040
2631
  onFocus: () => {
2041
2632
  if (editable) {
2042
- const current = projection.readCell(selection.focus.row, selection.focus.col)?.input ?? "";
2633
+ const current = readEditInput(selection.focus);
2043
2634
  initialDraftRef.current = current;
2044
2635
  setDraft(current);
2045
2636
  setEditMode("formula");
@@ -2052,41 +2643,51 @@ function SpreadsheetProjectionGrid({
2052
2643
  onBlur: (event) => commitEditorOnBlur("formula", event.currentTarget.value),
2053
2644
  className: "h-8 min-w-0 flex-1 bg-transparent px-1 font-mono text-og-sm text-og-fg outline-hidden placeholder:text-og-fg-subtle"
2054
2645
  }
2055
- )
2646
+ ),
2647
+ visibleSyncStatus ? /* @__PURE__ */ jsx2(
2648
+ "output",
2649
+ {
2650
+ "aria-label": t("artifacts.spreadsheetGrid.spreadsheetSyncStatus"),
2651
+ className: "shrink-0 px-2 text-og-xs text-og-fg-muted",
2652
+ children: visibleCommandFailure ? t("artifacts.spreadsheetGrid.notSaved") : visibleSyncStatus
2653
+ }
2654
+ ) : null
2056
2655
  ] }),
2057
- /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: commandFailure?.message ?? (pendingCommands > 0 ? "Saving spreadsheet changes" : "") }),
2058
- commandFailure ? /* @__PURE__ */ jsxs(
2656
+ /* @__PURE__ */ jsx2("div", { role: "status", "aria-live": "polite", className: "sr-only", children: visibleCommandFailure?.message ?? (pendingCommandCount > 0 ? t("artifacts.spreadsheetGrid.savingSpreadsheetChanges") : "") }),
2657
+ visibleCommandFailure ? /* @__PURE__ */ jsxs(
2059
2658
  "div",
2060
2659
  {
2061
2660
  role: "alert",
2062
2661
  className: "absolute bottom-2 left-2 z-50 flex items-center gap-2 rounded-og-sm border border-og-status-failed/30 bg-og-surface-1/95 px-2 py-1 text-og-xs text-og-status-failed shadow-og-sm",
2063
2662
  style: { maxWidth: "calc(100% - 1rem)" },
2064
2663
  children: [
2065
- /* @__PURE__ */ jsx("span", { className: "truncate", children: commandFailure.message }),
2066
- commandFailure.retry ? /* @__PURE__ */ jsx(
2664
+ /* @__PURE__ */ jsx2("span", { className: "truncate", children: visibleCommandFailure.message }),
2665
+ visibleCommandFailure.retry ? /* @__PURE__ */ jsx2(
2067
2666
  "button",
2068
2667
  {
2069
2668
  type: "button",
2070
- onClick: commandFailure.retry,
2669
+ onClick: visibleCommandFailure.retry,
2071
2670
  className: "shrink-0 rounded-og-xs px-1.5 py-0.5 font-medium outline-hidden hover:bg-og-surface-3 focus-visible:ring-2 focus-visible:ring-og-accent",
2072
- children: "Retry"
2671
+ children: t("artifacts.spreadsheetGrid.retry")
2073
2672
  }
2074
2673
  ) : null
2075
2674
  ]
2076
2675
  }
2077
2676
  ) : null,
2078
- /* @__PURE__ */ jsx(
2677
+ /* @__PURE__ */ jsx2(
2079
2678
  "div",
2080
2679
  {
2081
2680
  ref: viewportRef,
2082
2681
  role: "grid",
2083
2682
  tabIndex: 0,
2084
- "aria-label": `${projection.sheetName} spreadsheet`,
2683
+ "aria-label": t("artifacts.spreadsheetGrid.sheetnameSpreadsheet", {
2684
+ sheetName: projection.sheetName
2685
+ }),
2085
2686
  "aria-rowcount": rowCount,
2086
2687
  "aria-colcount": columnCount,
2087
2688
  "aria-multiselectable": "true",
2088
2689
  "aria-readonly": !editable,
2089
- "aria-busy": pendingCommands > 0 ? "true" : void 0,
2690
+ "aria-busy": pendingCommandCount > 0 ? "true" : void 0,
2090
2691
  "aria-activedescendant": activeCellId,
2091
2692
  onKeyDown: onGridKeyDown,
2092
2693
  onCopy: copySelection,
@@ -2120,10 +2721,14 @@ function SpreadsheetProjectionGrid({
2120
2721
  className: "relative",
2121
2722
  style: {
2122
2723
  width: horizontalProjection.physicalTotal,
2123
- height: verticalProjection.physicalTotal
2724
+ height: verticalProjection.physicalTotal,
2725
+ // Centered boundary handles must not enlarge the bounded scroll
2726
+ // extent at the final row/column. Unlike hidden, clip does not
2727
+ // create another scroll container for the sticky headers.
2728
+ overflow: "clip"
2124
2729
  },
2125
2730
  children: [
2126
- /* @__PURE__ */ jsx(
2731
+ /* @__PURE__ */ jsx2(
2127
2732
  "canvas",
2128
2733
  {
2129
2734
  ref: canvasRef,
@@ -2138,7 +2743,7 @@ function SpreadsheetProjectionGrid({
2138
2743
  }
2139
2744
  }
2140
2745
  ),
2141
- /* @__PURE__ */ jsx(
2746
+ /* @__PURE__ */ jsx2(
2142
2747
  "div",
2143
2748
  {
2144
2749
  "aria-hidden": true,
@@ -2150,12 +2755,12 @@ function SpreadsheetProjectionGrid({
2150
2755
  }
2151
2756
  }
2152
2757
  ),
2153
- /* @__PURE__ */ jsx("div", { role: "row", className: "contents", children: columnLayout.map(({ col, left, width }) => /* @__PURE__ */ jsx(
2758
+ /* @__PURE__ */ jsx2("div", { role: "row", className: "contents", children: columnLayout.map(({ col, left, width }) => /* @__PURE__ */ jsxs(
2154
2759
  "div",
2155
2760
  {
2156
2761
  role: "columnheader",
2157
2762
  "aria-colindex": col + 1,
2158
- className: "sticky top-0 z-30 grid select-none place-items-center overflow-hidden border-b border-r border-og-border bg-og-surface-2 text-og-xs font-medium text-og-fg-muted",
2763
+ className: "pointer-events-none sticky top-0 z-30 grid select-none place-items-center border-b border-r border-og-border bg-og-surface-2 text-og-xs font-medium text-og-fg-muted",
2159
2764
  style: {
2160
2765
  position: "absolute",
2161
2766
  left,
@@ -2168,7 +2773,20 @@ function SpreadsheetProjectionGrid({
2168
2773
  color: "transparent"
2169
2774
  } : void 0
2170
2775
  },
2171
- children: columnName2(col)
2776
+ children: [
2777
+ /* @__PURE__ */ jsx2("span", { className: "max-w-full overflow-hidden", children: columnName2(col) }),
2778
+ !readOnly && resize ? /* @__PURE__ */ jsx2(
2779
+ SpreadsheetResizeHandle,
2780
+ {
2781
+ axis: "column",
2782
+ label: t("artifacts.spreadsheetGrid.resizeColumnColumnname", {
2783
+ columnName: columnName2(col)
2784
+ }),
2785
+ size: width,
2786
+ ...resizing.handleProps("column", col)
2787
+ }
2788
+ ) : null
2789
+ ]
2172
2790
  },
2173
2791
  `header-${col}`
2174
2792
  )) }),
@@ -2185,11 +2803,11 @@ function SpreadsheetProjectionGrid({
2185
2803
  height
2186
2804
  },
2187
2805
  children: [
2188
- /* @__PURE__ */ jsx(
2806
+ /* @__PURE__ */ jsxs(
2189
2807
  "div",
2190
2808
  {
2191
2809
  role: "rowheader",
2192
- className: "sticky left-0 z-20 grid h-full select-none place-items-center border-b border-r border-og-border bg-og-surface-2 text-og-xs text-og-fg-muted",
2810
+ className: "pointer-events-none sticky left-0 z-20 grid h-full select-none place-items-center border-b border-r border-og-border bg-og-surface-2 text-og-xs text-og-fg-muted",
2193
2811
  style: {
2194
2812
  width: ROW_HEADER_WIDTH,
2195
2813
  ...canvasReady ? {
@@ -2198,7 +2816,18 @@ function SpreadsheetProjectionGrid({
2198
2816
  color: "transparent"
2199
2817
  } : void 0
2200
2818
  },
2201
- children: row + 1
2819
+ children: [
2820
+ row + 1,
2821
+ !readOnly && resize ? /* @__PURE__ */ jsx2(
2822
+ SpreadsheetResizeHandle,
2823
+ {
2824
+ axis: "row",
2825
+ label: t("artifacts.spreadsheetGrid.resizeRowRow", { row: row + 1 }),
2826
+ size: height,
2827
+ ...resizing.handleProps("row", row)
2828
+ }
2829
+ ) : null
2830
+ ]
2202
2831
  }
2203
2832
  ),
2204
2833
  columnLayout.map(({ col, left, width }) => {
@@ -2210,38 +2839,45 @@ function SpreadsheetProjectionGrid({
2210
2839
  format: {}
2211
2840
  };
2212
2841
  const value = data.value;
2842
+ const optimistic = editable ? optimisticInputsRef.current.get(`${row}:${col}`) : void 0;
2843
+ const display = optimistic ? optimistic.input : formatSpreadsheetGeneralDisplay(value);
2213
2844
  const address = cellName({ row, col });
2214
2845
  const error = typeof value === "string" && value.startsWith("#");
2215
- return /* @__PURE__ */ jsx(
2846
+ return /* @__PURE__ */ jsx2(
2216
2847
  "div",
2217
2848
  {
2218
2849
  id: `${reactId}-cell-${row}-${col}`,
2219
2850
  role: "gridcell",
2220
2851
  "aria-colindex": col + 1,
2221
2852
  "aria-selected": selected,
2222
- "aria-label": `${address}${value === null ? "" : `, ${displayValue2(value)}`}`,
2853
+ "aria-label": `${address}${display ? `, ${display}` : ""}${optimistic ? optimistic.input.startsWith("=") ? ", pending formula, awaiting calculation" : ", pending edit" : ""}`,
2854
+ "data-og-pending-input": optimistic ? "true" : void 0,
2223
2855
  "data-og-cell": address,
2224
2856
  className: cn(
2225
2857
  "pointer-events-none absolute top-0 flex h-full min-w-0 overflow-hidden border-b border-r border-og-border px-1.5 text-og-fg",
2226
- !canvasReady && selected && !active && "bg-og-accent/10",
2227
- !canvasReady && active && "z-10 bg-og-accent/10 ring-2 ring-inset ring-og-accent",
2858
+ (!canvasReady || optimistic) && selected && !active && "bg-og-accent/10",
2859
+ (!canvasReady || optimistic) && active && "z-10 bg-og-accent/10 ring-2 ring-inset ring-og-accent",
2228
2860
  !canvasReady && error && "text-og-status-failed"
2229
2861
  ),
2230
2862
  style: {
2231
2863
  left,
2232
2864
  width,
2233
2865
  ...cellStyle(data.format),
2234
- ...canvasReady ? {
2866
+ ...canvasReady && !optimistic ? {
2235
2867
  background: "transparent",
2236
2868
  borderColor: "transparent",
2237
2869
  color: "transparent"
2870
+ } : void 0,
2871
+ ...optimistic ? {
2872
+ background: data.format.fill ?? "var(--og-color-surface-1)",
2873
+ zIndex: 10
2238
2874
  } : void 0
2239
2875
  },
2240
- children: active && editMode === "cell" ? /* @__PURE__ */ jsx(
2876
+ children: active && editMode === "cell" ? /* @__PURE__ */ jsx2(
2241
2877
  "input",
2242
2878
  {
2243
2879
  ref: editorRef,
2244
- "aria-label": `Edit ${address}`,
2880
+ "aria-label": t("artifacts.spreadsheetGrid.editAddress", { address }),
2245
2881
  value: draft,
2246
2882
  onInput: (event) => setDraft(event.currentTarget.value),
2247
2883
  onKeyDown: onEditorKeyDown,
@@ -2251,7 +2887,7 @@ function SpreadsheetProjectionGrid({
2251
2887
  onPointerDown: (event) => event.stopPropagation(),
2252
2888
  className: "pointer-events-auto absolute inset-0 size-full bg-og-surface-1 px-1.5 font-mono text-og-sm text-og-fg outline-hidden ring-2 ring-inset ring-og-accent"
2253
2889
  }
2254
- ) : /* @__PURE__ */ jsx("span", { className: "block min-w-0 overflow-hidden text-ellipsis", children: displayValue2(value) })
2890
+ ) : /* @__PURE__ */ jsx2("span", { className: "block min-w-0 overflow-hidden text-ellipsis", children: display })
2255
2891
  },
2256
2892
  col
2257
2893
  );
@@ -2261,14 +2897,14 @@ function SpreadsheetProjectionGrid({
2261
2897
  `row-${row}`
2262
2898
  );
2263
2899
  }),
2264
- !activeCellVisible ? /* @__PURE__ */ jsx("div", { role: "row", "aria-rowindex": selection.focus.row + 1, className: "sr-only", children: /* @__PURE__ */ jsx(
2900
+ !activeCellVisible ? /* @__PURE__ */ jsx2("div", { role: "row", "aria-rowindex": selection.focus.row + 1, className: "sr-only", children: /* @__PURE__ */ jsx2(
2265
2901
  "div",
2266
2902
  {
2267
2903
  id: activeCellId,
2268
2904
  role: "gridcell",
2269
2905
  "aria-colindex": selection.focus.col + 1,
2270
2906
  "aria-selected": "true",
2271
- "aria-label": `${cellName(selection.focus)}${hiddenActiveValue == null ? "" : `, ${displayValue2(hiddenActiveValue)}`}`
2907
+ "aria-label": `${cellName(selection.focus)}${hiddenActiveValue == null ? "" : `, ${formatSpreadsheetGeneralDisplay(hiddenActiveValue)}`}`
2272
2908
  }
2273
2909
  ) }) : null
2274
2910
  ]
@@ -2288,8 +2924,141 @@ import {
2288
2924
  spreadsheetSheetId
2289
2925
  } from "@opengeni/sdk/editable-artifacts";
2290
2926
  import { PlusIcon as PlusIcon2 } from "lucide-react";
2291
- import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
2292
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
2927
+ import {
2928
+ useCallback as useCallback4,
2929
+ useEffect as useEffect5,
2930
+ useId as useId2,
2931
+ useLayoutEffect as useLayoutEffect2,
2932
+ useMemo as useMemo3,
2933
+ useRef as useRef5,
2934
+ useState as useState6
2935
+ } from "react";
2936
+
2937
+ // src/components/artifacts/spreadsheet-download.tsx
2938
+ import { DownloadIcon, LoaderCircleIcon } from "lucide-react";
2939
+ import { useEffect as useEffect4, useRef as useRef4, useState as useState5, useSyncExternalStore } from "react";
2940
+
2941
+ // src/components/artifacts/spreadsheet-submissions.tsx
2942
+ import { createContext, useContext, useState as useState4 } from "react";
2943
+ import { jsx as jsx3 } from "react/jsx-runtime";
2944
+ function createSubmissionQueue() {
2945
+ let pending = 0;
2946
+ const listeners = /* @__PURE__ */ new Set();
2947
+ const emit = () => {
2948
+ for (const listener of listeners) listener();
2949
+ };
2950
+ return {
2951
+ getPending: () => pending,
2952
+ subscribe: (listener) => {
2953
+ listeners.add(listener);
2954
+ return () => {
2955
+ listeners.delete(listener);
2956
+ };
2957
+ },
2958
+ async run(invoke) {
2959
+ pending++;
2960
+ emit();
2961
+ try {
2962
+ return await invoke();
2963
+ } finally {
2964
+ pending--;
2965
+ emit();
2966
+ }
2967
+ }
2968
+ };
2969
+ }
2970
+ var standaloneQueue = {
2971
+ getPending: () => 0,
2972
+ subscribe: (_listener) => () => {
2973
+ },
2974
+ run: (invoke) => invoke()
2975
+ };
2976
+ var SubmissionContext = createContext(null);
2977
+ function SpreadsheetSubmissionProvider({ children }) {
2978
+ const [queue] = useState4(createSubmissionQueue);
2979
+ return /* @__PURE__ */ jsx3(SubmissionContext.Provider, { value: queue, children });
2980
+ }
2981
+ function useSpreadsheetSubmissions() {
2982
+ return useContext(SubmissionContext) ?? standaloneQueue;
2983
+ }
2984
+
2985
+ // src/components/artifacts/spreadsheet-download.tsx
2986
+ import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
2987
+ function SpreadsheetDownloadButton({
2988
+ session,
2989
+ title,
2990
+ download
2991
+ }) {
2992
+ const t = useOpenGeniText();
2993
+ const view = useEditableArtifactView(session);
2994
+ const submissions = useSpreadsheetSubmissions();
2995
+ const submitting = useSyncExternalStore(
2996
+ submissions.subscribe,
2997
+ submissions.getPending,
2998
+ submissions.getPending
2999
+ );
3000
+ const active = useRef4(null);
3001
+ const [busy, setBusy] = useState5(false);
3002
+ const [error, setError] = useState5(false);
3003
+ const ready = view.state === "live" && submitting === 0 && view.pendingTransactions === 0 && view.blockedPending.length === 0 && !view.authoringBlockedReason;
3004
+ useEffect4(() => () => active.current?.abort(), [session]);
3005
+ useEffect4(() => {
3006
+ if (view.state === "failed" || view.state === "closed") {
3007
+ active.current?.abort();
3008
+ active.current = null;
3009
+ setBusy(false);
3010
+ }
3011
+ }, [view.state]);
3012
+ const start = async () => {
3013
+ if (active.current || !ready || submissions.getPending()) return;
3014
+ const current = session.getView();
3015
+ if (current.state !== "live" || current.pendingTransactions || current.blockedPending.length || current.authoringBlockedReason)
3016
+ return;
3017
+ const controller = new AbortController();
3018
+ active.current = controller;
3019
+ setBusy(true);
3020
+ setError(false);
3021
+ try {
3022
+ const blob = await download(controller.signal);
3023
+ if (controller.signal.aborted) return;
3024
+ const url = URL.createObjectURL(blob);
3025
+ try {
3026
+ const anchor = document.createElement("a");
3027
+ anchor.href = url;
3028
+ anchor.download = `${title.replace(/[\\/:*?"<>|\u0000-\u001f]/g, "_").replace(/\.xlsx$/i, "").trim() || t("artifacts.spreadsheetDownload.workbook")}.xlsx`;
3029
+ anchor.rel = "noopener";
3030
+ anchor.click();
3031
+ } finally {
3032
+ setTimeout(() => URL.revokeObjectURL(url), 0);
3033
+ }
3034
+ } catch {
3035
+ if (!controller.signal.aborted) setError(true);
3036
+ } finally {
3037
+ if (!controller.signal.aborted) {
3038
+ active.current = null;
3039
+ setBusy(false);
3040
+ }
3041
+ }
3042
+ };
3043
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
3044
+ error ? /* @__PURE__ */ jsx4("span", { role: "alert", className: "text-og-xs text-og-fg-muted", children: t("artifacts.spreadsheetDownload.downloadFailedTryAgain") }) : null,
3045
+ /* @__PURE__ */ jsxs2(
3046
+ ArtifactButton,
3047
+ {
3048
+ onClick: () => void start(),
3049
+ disabled: busy || !ready,
3050
+ title: ready ? t("artifacts.spreadsheetDownload.downloadWorkbookAsXlsx") : t("artifacts.spreadsheetDownload.waitForWorkbookChangesTo"),
3051
+ children: [
3052
+ busy ? /* @__PURE__ */ jsx4(LoaderCircleIcon, { className: "animate-spin", "aria-hidden": true }) : /* @__PURE__ */ jsx4(DownloadIcon, { "aria-hidden": true }),
3053
+ busy ? t("artifacts.spreadsheetDownload.preparing") : t("artifacts.spreadsheetDownload.download")
3054
+ ]
3055
+ }
3056
+ )
3057
+ ] });
3058
+ }
3059
+
3060
+ // src/components/artifacts/editable-spreadsheet.tsx
3061
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
2293
3062
  var EXCEL_MAX_ROWS = 1048576;
2294
3063
  var EXCEL_MAX_COLUMNS = 16384;
2295
3064
  var INITIAL_VIEWPORT_ROWS = 64;
@@ -2298,7 +3067,19 @@ var MAX_INTERACTIVE_QUERY_CELLS = 65536;
2298
3067
  var MAX_INTERACTIVE_QUERY_BYTES = 8 * 1024 * 1024;
2299
3068
  var EMPTY_FORMAT = Object.freeze({});
2300
3069
  var EMPTY_SHEETS = [];
2301
- function EditableSpreadsheetGrid({
3070
+ var useClientLayoutEffect2 = typeof window === "undefined" ? useEffect5 : useLayoutEffect2;
3071
+ var SESSION_KEYS = /* @__PURE__ */ new WeakMap();
3072
+ var nextSessionKey = 0;
3073
+ function EditableSpreadsheetGrid(props) {
3074
+ return /* @__PURE__ */ jsx5(
3075
+ EditableSpreadsheetGridSession,
3076
+ {
3077
+ ...props
3078
+ },
3079
+ `${spreadsheetSessionKey(props.session)}:${props.sheet.sheetId}:${props.sheet.generationId ?? "pending"}`
3080
+ );
3081
+ }
3082
+ function EditableSpreadsheetGridSession({
2302
3083
  session,
2303
3084
  sheet,
2304
3085
  metadataRevision,
@@ -2309,39 +3090,52 @@ function EditableSpreadsheetGrid({
2309
3090
  overscanColumns = 2,
2310
3091
  onSelectionChange,
2311
3092
  onCommit,
3093
+ onResize,
2312
3094
  onCommandError,
2313
3095
  onViewportChange,
2314
3096
  className
2315
3097
  }) {
3098
+ const t = useOpenGeniText();
3099
+ const authoringLifetime = useSpreadsheetAuthoringLifetime();
3100
+ const submissions = useSpreadsheetSubmissions();
3101
+ const view = useEditableArtifactView(session);
2316
3102
  const rowCount = boundedSheetCount(requestedRowCount, EXCEL_MAX_ROWS, sheet.usedBounds?.endRow);
2317
3103
  const columnCount = boundedSheetCount(
2318
3104
  requestedColumnCount,
2319
3105
  EXCEL_MAX_COLUMNS,
2320
3106
  sheet.usedBounds?.endColumn
2321
3107
  );
2322
- const [state, setState] = useState2(() => ({
3108
+ const [state, setState] = useState6(() => ({
3109
+ session,
3110
+ generationId: sheet.generationId,
2323
3111
  query: initialViewportQuery(sheet.sheetId, rowCount, columnCount),
2324
3112
  projection: null,
2325
3113
  error: null
2326
3114
  }));
2327
- const activeCellRef = useRef2({ row: 0, column: 0 });
2328
- useEffect2(() => {
2329
- setState({
2330
- query: initialViewportQuery(sheet.sheetId, rowCount, columnCount),
2331
- projection: null,
2332
- error: null
2333
- });
3115
+ const activeCellRef = useRef5({ row: 0, column: 0 });
3116
+ useEffect5(() => {
3117
+ setState(
3118
+ (current) => current.session === session && current.generationId === sheet.generationId && current.query.sheetId === sheet.sheetId ? current : {
3119
+ session,
3120
+ generationId: sheet.generationId,
3121
+ query: initialViewportQuery(sheet.sheetId, rowCount, columnCount),
3122
+ projection: null,
3123
+ error: null
3124
+ }
3125
+ );
2334
3126
  activeCellRef.current = { row: 0, column: 0 };
2335
- }, [columnCount, rowCount, session, sheet.sheetId]);
2336
- useEffect2(() => {
3127
+ }, [columnCount, rowCount, session, sheet.generationId, sheet.sheetId]);
3128
+ useEffect5(() => {
2337
3129
  const query = state.query;
2338
- return session.subscribeSpreadsheetViewport(
3130
+ const matchesScope = (current) => current.session === session && current.generationId === sheet.generationId && sameViewportQuery(current.query, query);
3131
+ let active = true;
3132
+ const unsubscribe = session.subscribeSpreadsheetViewport(
2339
3133
  query,
2340
3134
  (projection2) => {
2341
- if (!sameViewport(projection2, query)) return;
3135
+ if (!active || !sameViewport(projection2, query)) return;
2342
3136
  if (sheet.generationId !== null && projection2.generationId !== sheet.generationId) {
2343
3137
  setState(
2344
- (current) => sameViewportQuery(current.query, query) ? {
3138
+ (current) => matchesScope(current) ? {
2345
3139
  ...current,
2346
3140
  projection: null,
2347
3141
  error: new Error("Spreadsheet generation changed; refreshing metadata")
@@ -2350,97 +3144,147 @@ function EditableSpreadsheetGrid({
2350
3144
  return;
2351
3145
  }
2352
3146
  setState(
2353
- (current) => sameViewportQuery(current.query, query) ? { query, projection: projection2, error: null } : current
3147
+ (current) => matchesScope(current) ? { ...current, projection: projection2, error: null } : current
2354
3148
  );
2355
3149
  },
2356
3150
  {
2357
3151
  onError(error) {
2358
- setState(
2359
- (current) => sameViewportQuery(current.query, query) ? { ...current, error } : current
2360
- );
3152
+ if (!active) return;
3153
+ setState((current) => matchesScope(current) ? { ...current, error } : current);
2361
3154
  }
2362
3155
  }
2363
3156
  );
3157
+ return () => {
3158
+ active = false;
3159
+ unsubscribe();
3160
+ };
2364
3161
  }, [session, sheet.generationId, state.query]);
2365
- const projection = useMemo2(
3162
+ const projection = useMemo3(
2366
3163
  () => projectSdkViewport(
2367
3164
  sheet,
2368
3165
  metadataRevision,
2369
3166
  state.query,
2370
- state.projection,
3167
+ state.session === session && state.generationId === sheet.generationId ? state.projection : null,
2371
3168
  rowCount,
2372
3169
  columnCount
2373
3170
  ),
2374
- [columnCount, metadataRevision, rowCount, sheet, state.projection, state.query]
3171
+ [columnCount, metadataRevision, rowCount, session, sheet, state]
2375
3172
  );
2376
- const generation = useMemo2(() => sheetGeneration(sheet), [sheet]);
2377
- const editable = !readOnly && generation !== null;
2378
- const handleCommit = useCallback2(
3173
+ const generation = useMemo3(() => sheetGeneration(sheet), [sheet]);
3174
+ const editable = !readOnly && view.writable && !view.authoringBlockedReason && generation !== null;
3175
+ const syncStatus = view.authoringBlockedReason ? t("artifacts.editableSpreadsheet.waitingForEarlierEdits") : view.state === "live" ? editable ? t("artifacts.editableSpreadsheet.saved") : t("artifacts.editableSpreadsheet.readOnly") : editableArtifactStatusLabel(t, view);
3176
+ const syncError = view.blockedPending.length > 0 ? t("artifacts.editableSpreadsheet.someEarlierChangesCouldNot") : view.lastError?.message;
3177
+ const resizable = editable && sheet.defaultRowHeight !== void 0 && sheet.defaultColumnWidth !== void 0;
3178
+ const handleCommit = useCallback4(
2379
3179
  async (commit) => {
2380
- if (!generation) throw new Error("This sheet generation is not writable yet");
3180
+ const lifetime = requireSpreadsheetAuthoringLifetime(authoringLifetime);
3181
+ if (!generation) throw new Error(t("artifacts.editableSpreadsheet.thisSheetGenerationIsNot"));
2381
3182
  const input = spreadsheetCellInput(commit.input, commit.kind);
2382
- await session.applySpreadsheetCommands({
2383
- version: SPREADSHEET_ARTIFACT_COMMAND_VERSION,
2384
- commands: [
2385
- {
2386
- kind: "cells.set",
2387
- sheet: generation,
2388
- anchor: { row: commit.cell.row, column: commit.cell.col },
2389
- rows: 1,
2390
- columns: 1,
2391
- cells: [input]
2392
- }
2393
- ]
2394
- });
2395
- onCommit?.(commit);
3183
+ await submissions.run(
3184
+ () => session.applySpreadsheetCommands({
3185
+ version: SPREADSHEET_ARTIFACT_COMMAND_VERSION,
3186
+ commands: [
3187
+ {
3188
+ kind: "cells.set",
3189
+ sheet: generation,
3190
+ anchor: { row: commit.cell.row, column: commit.cell.col },
3191
+ rows: 1,
3192
+ columns: 1,
3193
+ cells: [input]
3194
+ }
3195
+ ]
3196
+ })
3197
+ );
3198
+ if (authoringLifetime.current === lifetime) onCommit?.(commit);
2396
3199
  },
2397
- [generation, onCommit, session]
3200
+ [authoringLifetime, generation, onCommit, session, submissions, t]
2398
3201
  );
2399
- const handleClear = useCallback2(
3202
+ const handleClear = useCallback4(
2400
3203
  async (selection) => {
2401
- if (!generation) throw new Error("This sheet generation is not writable yet");
3204
+ requireSpreadsheetAuthoringLifetime(authoringLifetime);
3205
+ if (!generation) throw new Error(t("artifacts.editableSpreadsheet.thisSheetGenerationIsNot"));
2402
3206
  const top = Math.min(selection.anchor.row, selection.focus.row);
2403
3207
  const bottom = Math.max(selection.anchor.row, selection.focus.row);
2404
3208
  const left = Math.min(selection.anchor.col, selection.focus.col);
2405
3209
  const right = Math.max(selection.anchor.col, selection.focus.col);
2406
- await session.applySpreadsheetCommands({
2407
- version: SPREADSHEET_ARTIFACT_COMMAND_VERSION,
2408
- commands: [
2409
- {
2410
- kind: "range.clear",
2411
- sheet: generation,
2412
- range: {
2413
- start: { row: top, column: left },
2414
- end: { row: bottom, column: right }
3210
+ await submissions.run(
3211
+ () => session.applySpreadsheetCommands({
3212
+ version: SPREADSHEET_ARTIFACT_COMMAND_VERSION,
3213
+ commands: [
3214
+ {
3215
+ kind: "range.clear",
3216
+ sheet: generation,
3217
+ range: {
3218
+ start: { row: top, column: left },
3219
+ end: { row: bottom, column: right }
3220
+ }
2415
3221
  }
2416
- }
2417
- ]
2418
- });
3222
+ ]
3223
+ })
3224
+ );
2419
3225
  },
2420
- [generation, session]
3226
+ [authoringLifetime, generation, session, submissions, t]
2421
3227
  );
2422
- const handleCommitRange = useCallback2(
3228
+ const handleCommitRange = useCallback4(
2423
3229
  async (commit) => {
2424
- if (!generation) throw new Error("This sheet generation is not writable yet");
2425
- await session.applySpreadsheetCommands({
2426
- version: SPREADSHEET_ARTIFACT_COMMAND_VERSION,
2427
- commands: [
2428
- {
2429
- kind: "cells.set",
2430
- sheet: generation,
2431
- anchor: { row: commit.anchor.row, column: commit.anchor.col },
2432
- rows: commit.rows,
2433
- columns: commit.columns,
2434
- cells: commit.inputs.map(
2435
- (input) => spreadsheetCellInput(input, input.startsWith("=") ? "formula" : "value")
2436
- )
2437
- }
2438
- ]
2439
- });
3230
+ requireSpreadsheetAuthoringLifetime(authoringLifetime);
3231
+ if (!generation) throw new Error(t("artifacts.editableSpreadsheet.thisSheetGenerationIsNot"));
3232
+ await submissions.run(
3233
+ () => session.applySpreadsheetCommands({
3234
+ version: SPREADSHEET_ARTIFACT_COMMAND_VERSION,
3235
+ commands: [
3236
+ {
3237
+ kind: "cells.set",
3238
+ sheet: generation,
3239
+ anchor: { row: commit.anchor.row, column: commit.anchor.col },
3240
+ rows: commit.rows,
3241
+ columns: commit.columns,
3242
+ cells: commit.inputs.map(
3243
+ (input) => spreadsheetCellInput(input, input.startsWith("=") ? "formula" : "value")
3244
+ )
3245
+ }
3246
+ ]
3247
+ })
3248
+ );
2440
3249
  },
2441
- [generation, session]
3250
+ [authoringLifetime, generation, session, submissions, t]
2442
3251
  );
2443
- const handleSelection = useCallback2(
3252
+ const handleResize = useCallback4(
3253
+ async (change) => {
3254
+ const lifetime = requireSpreadsheetAuthoringLifetime(authoringLifetime);
3255
+ if (!generation) throw new Error(t("artifacts.editableSpreadsheet.thisSheetGenerationIsNot"));
3256
+ await submissions.run(
3257
+ () => session.applySpreadsheetCommands({
3258
+ version: SPREADSHEET_ARTIFACT_COMMAND_VERSION,
3259
+ commands: [
3260
+ change.axis === "column" ? {
3261
+ kind: "column.width.set",
3262
+ sheet: generation,
3263
+ column: change.index,
3264
+ width: change.size === sheet.defaultColumnWidth ? null : change.size
3265
+ } : {
3266
+ kind: "row.height.set",
3267
+ sheet: generation,
3268
+ row: change.index,
3269
+ height: change.size === sheet.defaultRowHeight ? null : change.size
3270
+ }
3271
+ ]
3272
+ })
3273
+ );
3274
+ if (authoringLifetime.current === lifetime) onResize?.(change);
3275
+ },
3276
+ [
3277
+ authoringLifetime,
3278
+ generation,
3279
+ onResize,
3280
+ session,
3281
+ sheet.defaultColumnWidth,
3282
+ sheet.defaultRowHeight,
3283
+ submissions,
3284
+ t
3285
+ ]
3286
+ );
3287
+ const handleSelection = useCallback4(
2444
3288
  (selection) => {
2445
3289
  activeCellRef.current = {
2446
3290
  row: selection.focus.row,
@@ -2449,6 +3293,7 @@ function EditableSpreadsheetGrid({
2449
3293
  setState((current) => {
2450
3294
  if (queryContains(current.query, selection.focus.row, selection.focus.col)) return current;
2451
3295
  return {
3296
+ ...current,
2452
3297
  query: boundedViewportQuery(
2453
3298
  sheet.sheetId,
2454
3299
  selection.focus.row,
@@ -2467,7 +3312,7 @@ function EditableSpreadsheetGrid({
2467
3312
  },
2468
3313
  [columnCount, onSelectionChange, rowCount, sheet.sheetId]
2469
3314
  );
2470
- const handleViewport = useCallback2(
3315
+ const handleViewport = useCallback4(
2471
3316
  (viewport) => {
2472
3317
  const next = boundedViewportQuery(
2473
3318
  sheet.sheetId,
@@ -2480,14 +3325,23 @@ function EditableSpreadsheetGrid({
2480
3325
  activeCellRef.current
2481
3326
  );
2482
3327
  setState(
2483
- (current) => sameViewportQuery(current.query, next) ? current : { query: next, projection: current.projection, error: null }
3328
+ (current) => sameViewportQuery(current.query, next) ? current : { ...current, query: next, error: null }
2484
3329
  );
2485
3330
  onViewportChange?.(viewport);
2486
3331
  },
2487
3332
  [columnCount, onViewportChange, rowCount, sheet.sheetId]
2488
3333
  );
2489
- return /* @__PURE__ */ jsxs2("div", { className: cn("relative h-full min-h-0", className), children: [
2490
- /* @__PURE__ */ jsx2(
3334
+ if (editableArtifactAccessRevoked(view)) {
3335
+ return /* @__PURE__ */ jsx5(
3336
+ EditableArtifactMessage,
3337
+ {
3338
+ title: t("artifacts.editableSpreadsheet.spreadsheetUnavailable"),
3339
+ detail: t("artifacts.editableSpreadsheet.youNoLongerHaveAccess")
3340
+ }
3341
+ );
3342
+ }
3343
+ return /* @__PURE__ */ jsxs3("div", { className: cn("relative h-full min-h-0", className), children: [
3344
+ /* @__PURE__ */ jsx5(
2491
3345
  SpreadsheetProjectionGrid,
2492
3346
  {
2493
3347
  projection,
@@ -2498,11 +3352,15 @@ function EditableSpreadsheetGrid({
2498
3352
  commit: editable ? handleCommit : void 0,
2499
3353
  commitRange: editable ? handleCommitRange : void 0,
2500
3354
  clear: editable ? handleClear : void 0,
3355
+ resize: resizable ? handleResize : void 0,
3356
+ pendingTransactions: view.pendingTransactions,
3357
+ syncStatus,
3358
+ syncError,
2501
3359
  onCommandError,
2502
3360
  onViewportChange: handleViewport
2503
3361
  }
2504
3362
  ),
2505
- state.error ? /* @__PURE__ */ jsx2(
3363
+ state.error && state.session === session && state.generationId === sheet.generationId ? /* @__PURE__ */ jsx5(
2506
3364
  "output",
2507
3365
  {
2508
3366
  role: "status",
@@ -2513,95 +3371,109 @@ function EditableSpreadsheetGrid({
2513
3371
  ) : null
2514
3372
  ] });
2515
3373
  }
2516
- function EditableSpreadsheetArtifactSurface({
3374
+ function EditableSpreadsheetArtifactSurface(props) {
3375
+ return /* @__PURE__ */ jsx5(SpreadsheetSubmissionProvider, { children: /* @__PURE__ */ jsx5(EditableSpreadsheetArtifactSurfaceSession, { ...props }) }, spreadsheetSessionKey(props.session));
3376
+ }
3377
+ function EditableSpreadsheetArtifactSurfaceSession({
2517
3378
  session,
2518
- title = "Workbook",
3379
+ title: titleProp,
3380
+ showHeader,
2519
3381
  subtitle,
2520
3382
  actions,
3383
+ download,
2521
3384
  initialSheetId,
2522
3385
  allowAddSheet = true,
2523
3386
  readOnly = false,
2524
3387
  ...gridProps
2525
3388
  }) {
3389
+ const t = useOpenGeniText();
3390
+ const title = titleProp === void 0 ? t("artifacts.editableSpreadsheet.workbook") : titleProp;
3391
+ const authoringLifetime = useSpreadsheetAuthoringLifetime();
3392
+ const submissions = useSpreadsheetSubmissions();
2526
3393
  const { metadata, error: metadataError } = useSpreadsheetMetadata(session);
2527
3394
  const view = useEditableArtifactView(session);
2528
- const [activeSheetId, setActiveSheetId] = useState2(initialSheetId ?? null);
2529
- const [creatingSheet, setCreatingSheet] = useState2(false);
2530
- const [surfaceError, setSurfaceError] = useState2(null);
3395
+ const [activeSheetId, setActiveSheetId] = useState6(initialSheetId ?? null);
3396
+ const [creatingSheet, setCreatingSheet] = useState6(false);
3397
+ const [surfaceError, setSurfaceError] = useState6(null);
2531
3398
  const sheets = metadata?.sheets ?? EMPTY_SHEETS;
2532
3399
  const activeSheet = sheets.find((sheet) => sheet.sheetId === activeSheetId) ?? (initialSheetId ? sheets.find((sheet) => sheet.sheetId === initialSheetId) : void 0) ?? sheets[0] ?? null;
2533
- const writable = !readOnly && view.writable;
3400
+ const writable = !readOnly && view.writable && !view.authoringBlockedReason;
2534
3401
  const accessRevoked = editableArtifactAccessRevoked(view);
2535
- const addSheet = useCallback2(async () => {
3402
+ const addSheet = useCallback4(async () => {
2536
3403
  if (!writable || creatingSheet) return;
3404
+ const lifetime = requireSpreadsheetAuthoringLifetime(authoringLifetime);
2537
3405
  setCreatingSheet(true);
2538
3406
  setSurfaceError(null);
2539
3407
  try {
2540
3408
  const after = activeSheet ? sheetGeneration(activeSheet) : null;
2541
- const created = await session.createSpreadsheetSheet({
2542
- name: nextAvailableSheetName2(sheets),
2543
- after
2544
- });
2545
- setActiveSheetId(created.sheetId);
3409
+ const created = await submissions.run(
3410
+ () => session.createSpreadsheetSheet({
3411
+ name: nextAvailableSheetName2(t, sheets),
3412
+ after
3413
+ })
3414
+ );
3415
+ if (authoringLifetime.current === lifetime) setActiveSheetId(created.sheetId);
2546
3416
  } catch (cause) {
2547
- setSurfaceError(asError(cause));
3417
+ if (authoringLifetime.current === lifetime) setSurfaceError(asError(cause));
2548
3418
  } finally {
2549
- setCreatingSheet(false);
3419
+ if (authoringLifetime.current === lifetime) setCreatingSheet(false);
2550
3420
  }
2551
- }, [activeSheet, creatingSheet, session, sheets, writable]);
2552
- const footer = /* @__PURE__ */ jsxs2(
3421
+ }, [activeSheet, authoringLifetime, creatingSheet, session, sheets, submissions, writable, t]);
3422
+ const footer = /* @__PURE__ */ jsxs3(
2553
3423
  "div",
2554
3424
  {
2555
3425
  className: "flex min-h-9 items-center gap-1 overflow-x-auto px-2",
2556
3426
  role: "tablist",
2557
- "aria-label": "Worksheets",
3427
+ "aria-label": t("artifacts.editableSpreadsheet.worksheets"),
2558
3428
  children: [
2559
- sheets.map((sheet) => /* @__PURE__ */ jsx2(
2560
- "button",
3429
+ sheets.map((sheet) => /* @__PURE__ */ jsx5(
3430
+ EditableWorksheetTab,
2561
3431
  {
2562
- type: "button",
2563
- role: "tab",
2564
- "aria-selected": sheet.sheetId === activeSheet?.sheetId,
2565
- onClick: () => setActiveSheetId(sheet.sheetId),
2566
- className: cn(
2567
- "h-7 shrink-0 rounded-og-sm px-2.5 text-og-sm outline-hidden transition-colors focus-visible:ring-2 focus-visible:ring-og-accent",
2568
- sheet.sheetId === activeSheet?.sheetId ? "bg-og-surface-3 font-medium text-og-fg" : "text-og-fg-muted hover:bg-og-surface-3 hover:text-og-fg"
2569
- ),
2570
- children: sheet.name
3432
+ session,
3433
+ sheet,
3434
+ sheets,
3435
+ selected: sheet.sheetId === activeSheet?.sheetId,
3436
+ writable,
3437
+ onSelect: () => setActiveSheetId(sheet.sheetId),
3438
+ onCommandError: gridProps.onCommandError
2571
3439
  },
2572
3440
  `${sheet.sheetId}:${sheet.generationId ?? "pending"}`
2573
3441
  )),
2574
- writable && allowAddSheet ? /* @__PURE__ */ jsx2(
3442
+ writable && allowAddSheet ? /* @__PURE__ */ jsx5(
2575
3443
  "button",
2576
3444
  {
2577
3445
  type: "button",
2578
3446
  onClick: () => void addSheet(),
2579
3447
  disabled: creatingSheet,
2580
- "aria-label": creatingSheet ? "Adding worksheet" : "Add worksheet",
3448
+ "aria-label": creatingSheet ? t("artifacts.editableSpreadsheet.addingWorksheet") : t("artifacts.editableSpreadsheet.addWorksheet"),
2581
3449
  className: "grid size-7 shrink-0 place-items-center rounded-og-sm text-og-fg-muted outline-hidden hover:bg-og-surface-3 hover:text-og-fg focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-50 [&>svg]:size-3.5",
2582
- children: /* @__PURE__ */ jsx2(PlusIcon2, {})
3450
+ children: /* @__PURE__ */ jsx5(PlusIcon2, {})
2583
3451
  }
2584
3452
  ) : null
2585
3453
  ]
2586
3454
  }
2587
3455
  );
2588
3456
  const error = surfaceError ?? metadataError;
2589
- return /* @__PURE__ */ jsx2(
3457
+ return /* @__PURE__ */ jsx5(
2590
3458
  ArtifactSurface,
2591
3459
  {
2592
3460
  modality: "spreadsheet",
2593
3461
  title,
2594
- subtitle: subtitle ?? (accessRevoked ? editableArtifactStatusLabel(view) : metadata ? `${sheets.length} sheet${sheets.length === 1 ? "" : "s"}` : editableArtifactStatusLabel(view)),
2595
- actions,
3462
+ showHeader,
3463
+ subtitle: subtitle ?? (accessRevoked ? editableArtifactStatusLabel(t, view) : metadata ? t("counts.sheets", { count: sheets.length }) : editableArtifactStatusLabel(t, view)),
3464
+ actions: download ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
3465
+ actions,
3466
+ /* @__PURE__ */ jsx5(SpreadsheetDownloadButton, { session, title, download })
3467
+ ] }) : actions,
2596
3468
  footer: accessRevoked ? void 0 : footer,
2597
3469
  busy: !accessRevoked && !metadata && !error,
2598
- children: accessRevoked ? /* @__PURE__ */ jsx2(
3470
+ children: accessRevoked ? /* @__PURE__ */ jsx5(
2599
3471
  EditableArtifactMessage,
2600
3472
  {
2601
- title: "Access changed",
2602
- detail: editableArtifactStatusLabel(view)
3473
+ title: t("artifacts.editableSpreadsheet.accessChanged"),
3474
+ detail: editableArtifactStatusLabel(t, view)
2603
3475
  }
2604
- ) : activeSheet && metadata ? /* @__PURE__ */ jsx2(
3476
+ ) : activeSheet && metadata ? /* @__PURE__ */ jsx5(
2605
3477
  EditableSpreadsheetGrid,
2606
3478
  {
2607
3479
  ...gridProps,
@@ -2611,40 +3483,301 @@ function EditableSpreadsheetArtifactSurface({
2611
3483
  readOnly: !writable
2612
3484
  },
2613
3485
  `${activeSheet.sheetId}:${activeSheet.generationId ?? "pending"}`
2614
- ) : error ? /* @__PURE__ */ jsx2(EditableArtifactMessage, { title: "Could not open this workbook", detail: error.message }) : metadata ? /* @__PURE__ */ jsx2("div", { className: "grid h-full place-items-center bg-og-bg p-6 text-center", children: /* @__PURE__ */ jsxs2("div", { children: [
2615
- /* @__PURE__ */ jsx2("p", { className: "text-og-base font-medium text-og-fg", children: "This workbook has no worksheets." }),
2616
- writable && allowAddSheet ? /* @__PURE__ */ jsx2(
3486
+ ) : error ? /* @__PURE__ */ jsx5(
3487
+ EditableArtifactMessage,
3488
+ {
3489
+ title: t("artifacts.editableSpreadsheet.couldNotOpenThisWorkbook"),
3490
+ detail: error.message
3491
+ }
3492
+ ) : metadata ? /* @__PURE__ */ jsx5("div", { className: "grid h-full place-items-center bg-og-bg p-6 text-center", children: /* @__PURE__ */ jsxs3("div", { children: [
3493
+ /* @__PURE__ */ jsx5("p", { className: "text-og-base font-medium text-og-fg", children: t("artifacts.editableSpreadsheet.thisWorkbookHasNoWorksheets") }),
3494
+ writable && allowAddSheet ? /* @__PURE__ */ jsx5(
2617
3495
  "button",
2618
3496
  {
2619
3497
  type: "button",
2620
3498
  onClick: () => void addSheet(),
2621
3499
  disabled: creatingSheet,
2622
- className: "mt-3 rounded-og-sm bg-og-accent-deep px-3 py-1.5 text-og-sm font-medium text-og-accent-fg outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-50",
2623
- children: creatingSheet ? "Adding\u2026" : "Add worksheet"
3500
+ className: "mt-3 rounded-og-sm border border-og-primary-border bg-og-primary text-og-primary-fg px-3 py-1.5 text-og-sm font-medium hover:bg-og-primary-hover outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-50",
3501
+ children: creatingSheet ? t("artifacts.editableSpreadsheet.adding") : t("artifacts.editableSpreadsheet.addWorksheet")
2624
3502
  }
2625
3503
  ) : null
2626
- ] }) }) : /* @__PURE__ */ jsx2(
3504
+ ] }) }) : /* @__PURE__ */ jsx5(
2627
3505
  EditableArtifactMessage,
2628
3506
  {
2629
- title: "Opening workbook",
2630
- detail: editableArtifactStatusLabel(view)
3507
+ title: t("artifacts.editableSpreadsheet.openingWorkbook"),
3508
+ detail: editableArtifactStatusLabel(t, view)
2631
3509
  }
2632
3510
  )
2633
3511
  }
2634
3512
  );
2635
3513
  }
2636
- function useSpreadsheetMetadata(session) {
2637
- const [state, setState] = useState2({ metadata: null, error: null });
2638
- useEffect2(
2639
- () => session.subscribeSpreadsheetMetadata({}, (metadata) => setState({ metadata, error: null }), {
2640
- onError: (error) => setState((current) => ({ ...current, error }))
2641
- }),
2642
- [session]
3514
+ function EditableWorksheetTab({
3515
+ session,
3516
+ sheet,
3517
+ sheets,
3518
+ selected,
3519
+ writable,
3520
+ onSelect,
3521
+ onCommandError
3522
+ }) {
3523
+ const t = useOpenGeniText();
3524
+ const submissions = useSpreadsheetSubmissions();
3525
+ const [editing, setEditing] = useState6(false);
3526
+ const [name, setName] = useState6(sheet.name);
3527
+ const [saving, setSaving] = useState6(false);
3528
+ const [accepted, setAccepted] = useState6(false);
3529
+ const [error, setError] = useState6(null);
3530
+ const inputRef = useRef5(null);
3531
+ const tabRef = useRef5(null);
3532
+ const busyRef = useRef5(false);
3533
+ const mountedRef = useRef5(true);
3534
+ const latestRef = useRef5({ session, sheet, writable });
3535
+ latestRef.current = { session, sheet, writable };
3536
+ const errorId = useId2();
3537
+ const canRename = writable && sheet.generationId !== null;
3538
+ const scopeRef = useRef5({
3539
+ session,
3540
+ sheetId: sheet.sheetId,
3541
+ generationId: sheet.generationId,
3542
+ canRename
3543
+ });
3544
+ if (scopeRef.current.session !== session || scopeRef.current.sheetId !== sheet.sheetId || scopeRef.current.generationId !== sheet.generationId || scopeRef.current.canRename !== canRename) {
3545
+ scopeRef.current = {
3546
+ session,
3547
+ sheetId: sheet.sheetId,
3548
+ generationId: sheet.generationId,
3549
+ canRename
3550
+ };
3551
+ }
3552
+ useEffect5(() => {
3553
+ mountedRef.current = true;
3554
+ return () => {
3555
+ mountedRef.current = false;
3556
+ };
3557
+ }, []);
3558
+ useEffect5(() => {
3559
+ setEditing(false);
3560
+ setSaving(false);
3561
+ setAccepted(false);
3562
+ setError(null);
3563
+ busyRef.current = false;
3564
+ }, [session, sheet.generationId, sheet.sheetId, canRename]);
3565
+ useEffect5(() => {
3566
+ if (!editing) return;
3567
+ inputRef.current?.focus();
3568
+ inputRef.current?.select();
3569
+ }, [editing]);
3570
+ useEffect5(() => {
3571
+ if (!accepted || !editing || sheet.name !== name) return;
3572
+ const restoreFocus = document.activeElement === document.body || document.activeElement === inputRef.current;
3573
+ setEditing(false);
3574
+ setSaving(false);
3575
+ setAccepted(false);
3576
+ busyRef.current = false;
3577
+ if (restoreFocus) queueMicrotask(() => tabRef.current?.focus({ preventScroll: true }));
3578
+ }, [accepted, editing, name, sheet.name]);
3579
+ const start = () => {
3580
+ if (!canRename || busyRef.current) return;
3581
+ onSelect();
3582
+ setName(sheet.name);
3583
+ setError(null);
3584
+ setAccepted(false);
3585
+ setEditing(true);
3586
+ };
3587
+ const cancel = () => {
3588
+ if (busyRef.current) return;
3589
+ setEditing(false);
3590
+ setError(null);
3591
+ queueMicrotask(() => tabRef.current?.focus({ preventScroll: true }));
3592
+ };
3593
+ const rename = async () => {
3594
+ if (!canRename || busyRef.current) return;
3595
+ const generation = sheetGeneration(sheet);
3596
+ if (!generation) return;
3597
+ const next = name.trim();
3598
+ if (!next || next.length > 31 || /[\\/?*[\]:\0]/u.test(next)) {
3599
+ setError(t("artifacts.editableSpreadsheet.use131CharactersWithout"));
3600
+ return;
3601
+ }
3602
+ if (sheets.some((other) => other.sheetId !== sheet.sheetId && other.name === next)) {
3603
+ setError(t("artifacts.editableSpreadsheet.aWorksheetAlreadyHasThis"));
3604
+ return;
3605
+ }
3606
+ if (next === sheet.name) {
3607
+ cancel();
3608
+ return;
3609
+ }
3610
+ setName(next);
3611
+ setError(null);
3612
+ setSaving(true);
3613
+ busyRef.current = true;
3614
+ const scope = scopeRef.current;
3615
+ const current = () => mountedRef.current && scopeRef.current === scope && latestRef.current.writable;
3616
+ try {
3617
+ await submissions.run(
3618
+ () => session.applySpreadsheetCommands({
3619
+ version: SPREADSHEET_ARTIFACT_COMMAND_VERSION,
3620
+ commands: [{ kind: "sheet.rename", sheet: generation, name: next }]
3621
+ })
3622
+ );
3623
+ if (current()) setAccepted(true);
3624
+ } catch (cause) {
3625
+ if (!current()) return;
3626
+ const failure = asError(cause);
3627
+ busyRef.current = false;
3628
+ setSaving(false);
3629
+ setError(failure.message || t("artifacts.editableSpreadsheet.couldNotRenameWorksheetTry"));
3630
+ onCommandError?.(failure);
3631
+ queueMicrotask(() => inputRef.current?.focus());
3632
+ }
3633
+ };
3634
+ const tab = /* @__PURE__ */ jsx5(
3635
+ "button",
3636
+ {
3637
+ ref: tabRef,
3638
+ type: "button",
3639
+ role: "tab",
3640
+ tabIndex: editing && canRename ? -1 : void 0,
3641
+ "aria-selected": selected,
3642
+ "aria-keyshortcuts": canRename ? "F2" : void 0,
3643
+ title: canRename ? t("artifacts.editableSpreadsheet.doubleClickOrPressF2") : void 0,
3644
+ onClick: onSelect,
3645
+ onDoubleClick: start,
3646
+ onKeyDown: (event) => {
3647
+ if (event.key === "F2") {
3648
+ event.preventDefault();
3649
+ start();
3650
+ }
3651
+ },
3652
+ className: cn(
3653
+ "h-7 shrink-0 rounded-og-sm px-2.5 text-og-sm outline-hidden transition-colors focus-visible:ring-2 focus-visible:ring-og-accent",
3654
+ selected ? "bg-og-surface-3 font-medium text-og-fg" : "text-og-fg-muted hover:bg-og-surface-3 hover:text-og-fg"
3655
+ ),
3656
+ children: sheet.name
3657
+ }
2643
3658
  );
2644
- return state;
3659
+ return editing && canRename ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
3660
+ /* @__PURE__ */ jsx5("span", { className: "sr-only", children: tab }),
3661
+ /* @__PURE__ */ jsxs3(
3662
+ "form",
3663
+ {
3664
+ className: "flex min-w-0 flex-wrap items-center gap-1 py-1",
3665
+ style: { width: "min(18rem, 100%)" },
3666
+ onSubmit: (event) => {
3667
+ event.preventDefault();
3668
+ void rename();
3669
+ },
3670
+ children: [
3671
+ /* @__PURE__ */ jsx5(
3672
+ "input",
3673
+ {
3674
+ ref: inputRef,
3675
+ "aria-label": t("artifacts.editableSpreadsheet.worksheetName"),
3676
+ "aria-invalid": error ? "true" : void 0,
3677
+ "aria-describedby": error ? errorId : void 0,
3678
+ disabled: saving,
3679
+ value: name,
3680
+ onInput: (event) => {
3681
+ setName(event.currentTarget.value);
3682
+ setError(null);
3683
+ },
3684
+ onKeyDown: (event) => {
3685
+ if (event.nativeEvent.isComposing || event.keyCode === 229) return;
3686
+ if (event.key === "Escape") {
3687
+ event.preventDefault();
3688
+ cancel();
3689
+ }
3690
+ if (event.key === "Enter") {
3691
+ event.preventDefault();
3692
+ void rename();
3693
+ }
3694
+ },
3695
+ className: "h-7 w-40 rounded-og-sm border border-og-border bg-og-surface-1 px-2 text-og-sm text-og-fg outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent disabled:opacity-50"
3696
+ }
3697
+ ),
3698
+ saving ? /* @__PURE__ */ jsx5("span", { role: "status", className: "text-og-xs text-og-fg-muted", children: t("artifacts.editableSpreadsheet.renaming") }) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
3699
+ /* @__PURE__ */ jsx5(
3700
+ "button",
3701
+ {
3702
+ type: "submit",
3703
+ className: "rounded-og-sm px-2 py-1 text-og-xs text-og-fg outline-hidden hover:bg-og-surface-3 focus-visible:ring-2 focus-visible:ring-og-accent",
3704
+ children: t("artifacts.editableSpreadsheet.save")
3705
+ }
3706
+ ),
3707
+ /* @__PURE__ */ jsx5(
3708
+ "button",
3709
+ {
3710
+ type: "button",
3711
+ onClick: cancel,
3712
+ className: "rounded-og-sm px-2 py-1 text-og-xs text-og-fg-muted outline-hidden hover:bg-og-surface-3 focus-visible:ring-2 focus-visible:ring-og-accent",
3713
+ children: t("artifacts.editableSpreadsheet.cancel")
3714
+ }
3715
+ )
3716
+ ] }),
3717
+ error ? /* @__PURE__ */ jsx5(
3718
+ "span",
3719
+ {
3720
+ id: errorId,
3721
+ role: "alert",
3722
+ className: "text-og-xs text-og-status-failed",
3723
+ style: { flexBasis: "100%", overflowWrap: "anywhere" },
3724
+ children: error
3725
+ }
3726
+ ) : null
3727
+ ]
3728
+ }
3729
+ )
3730
+ ] }) : tab;
3731
+ }
3732
+ function spreadsheetSessionKey(session) {
3733
+ let key = SESSION_KEYS.get(session);
3734
+ if (key === void 0) {
3735
+ key = ++nextSessionKey;
3736
+ SESSION_KEYS.set(session, key);
3737
+ }
3738
+ return key;
3739
+ }
3740
+ function useSpreadsheetAuthoringLifetime() {
3741
+ const lifetime = useRef5({});
3742
+ useClientLayoutEffect2(() => {
3743
+ lifetime.current = {};
3744
+ return () => {
3745
+ lifetime.current = null;
3746
+ };
3747
+ }, []);
3748
+ return lifetime;
3749
+ }
3750
+ function requireSpreadsheetAuthoringLifetime(lifetime) {
3751
+ if (!lifetime.current) throw new Error("Spreadsheet authoring session changed");
3752
+ return lifetime.current;
3753
+ }
3754
+ function useSpreadsheetMetadata(session) {
3755
+ const [state, setState] = useState6({ session, metadata: null, error: null });
3756
+ useEffect5(() => {
3757
+ let active = true;
3758
+ const unsubscribe = session.subscribeSpreadsheetMetadata(
3759
+ {},
3760
+ (metadata) => {
3761
+ if (active) setState({ session, metadata, error: null });
3762
+ },
3763
+ {
3764
+ onError: (error) => {
3765
+ if (active)
3766
+ setState(
3767
+ (current) => current.session === session ? { ...current, error } : { session, metadata: null, error }
3768
+ );
3769
+ }
3770
+ }
3771
+ );
3772
+ return () => {
3773
+ active = false;
3774
+ unsubscribe();
3775
+ };
3776
+ }, [session]);
3777
+ return state.session === session ? state : { metadata: null, error: null };
2645
3778
  }
2646
3779
  function projectSdkViewport(sheet, metadataRevision, query, viewport, rowCount, columnCount) {
2647
- const current = viewport && sameViewport(viewport, query) ? viewport : null;
3780
+ const current = viewport && viewport.sheetId === sheet.sheetId && viewport.generationId === sheet.generationId ? viewport : null;
2648
3781
  const projectedCells = (current?.cells ?? []).map((cell) => ({
2649
3782
  row: cell.row,
2650
3783
  col: cell.column,
@@ -2661,8 +3794,12 @@ function projectSdkViewport(sheet, metadataRevision, query, viewport, rowCount,
2661
3794
  sheetId: sheet.sheetId,
2662
3795
  sheetName: sheet.name,
2663
3796
  generationId: current?.generationId ?? sheet.generationId,
2664
- revision: `${metadataRevision}:${current?.revision ?? "loading"}`,
3797
+ revision: current?.revision.toString() ?? "loading",
2665
3798
  dimensionRevision: metadataRevision.toString(),
3799
+ defaultRowHeight: sheet.defaultRowHeight,
3800
+ defaultColumnWidth: sheet.defaultColumnWidth,
3801
+ rowHeights: sheet.rowHeights,
3802
+ columnWidths: sheet.columnWidths,
2666
3803
  rowCount,
2667
3804
  columnCount,
2668
3805
  usedRange: used ? {
@@ -2688,7 +3825,7 @@ function projectSdkViewport(sheet, metadataRevision, query, viewport, rowCount,
2688
3825
  const cell = byCoordinate.get(`${row}:${column}`);
2689
3826
  return cell ? {
2690
3827
  value: cell.value,
2691
- input: cell.formula ?? displayValue3(cell.value),
3828
+ input: cell.formula ?? displayValue(cell.value),
2692
3829
  format: cell.format
2693
3830
  } : null;
2694
3831
  }
@@ -2799,16 +3936,16 @@ function boundedSheetCount(requested, maximum, usedEnd) {
2799
3936
  const usedCount = usedEnd === void 0 || !Number.isSafeInteger(usedEnd) ? 1 : Math.max(1, Math.min(maximum, usedEnd + 1));
2800
3937
  return Math.max(requestedCount, usedCount);
2801
3938
  }
2802
- function displayValue3(value) {
3939
+ function displayValue(value) {
2803
3940
  if (value === null || value === void 0) return "";
2804
3941
  if (value instanceof Date) return Number.isNaN(value.getTime()) ? "" : value.toISOString();
2805
3942
  if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
2806
3943
  return String(value);
2807
3944
  }
2808
- function nextAvailableSheetName2(sheets) {
3945
+ function nextAvailableSheetName2(t, sheets) {
2809
3946
  let index = sheets.length + 1;
2810
3947
  while (sheets.some((sheet) => sheet.name === `Sheet${index}`)) index += 1;
2811
- return `Sheet${index}`;
3948
+ return t("artifacts.editableSpreadsheet.sheetIndex", { index });
2812
3949
  }
2813
3950
  function clampInteger(value, minimum, maximum) {
2814
3951
  if (!Number.isFinite(value)) return minimum;
@@ -2825,4 +3962,4 @@ export {
2825
3962
  EditableSpreadsheetGrid,
2826
3963
  EditableSpreadsheetArtifactSurface
2827
3964
  };
2828
- //# sourceMappingURL=chunk-ICA6R6TW.js.map
3965
+ //# sourceMappingURL=chunk-LNUD3JNI.js.map