@arbidocs/blocks 0.4.147 → 0.4.150

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 (337) hide show
  1. package/dist/ConnectedNativeDocxComparison-3XQSINPQ.cjs +44 -0
  2. package/dist/ConnectedNativeDocxComparison-3XQSINPQ.cjs.map +1 -0
  3. package/dist/ConnectedNativeDocxComparison-XQSXVGHR.js +35 -0
  4. package/dist/ConnectedNativeDocxComparison-XQSXVGHR.js.map +1 -0
  5. package/dist/ConnectedNativeDocxEditor-IPEZDERL.js +33 -0
  6. package/dist/ConnectedNativeDocxEditor-IPEZDERL.js.map +1 -0
  7. package/dist/ConnectedNativeDocxEditor-OUWFMIPH.cjs +46 -0
  8. package/dist/ConnectedNativeDocxEditor-OUWFMIPH.cjs.map +1 -0
  9. package/dist/ConnectedStreamedWordArtifact-D5LSMDO4.cjs +44 -0
  10. package/dist/ConnectedStreamedWordArtifact-D5LSMDO4.cjs.map +1 -0
  11. package/dist/ConnectedStreamedWordArtifact-UZVNBKQB.js +35 -0
  12. package/dist/ConnectedStreamedWordArtifact-UZVNBKQB.js.map +1 -0
  13. package/dist/FactTextEditor-YESAU2IJ.js +25 -0
  14. package/dist/FactTextEditor-YESAU2IJ.js.map +1 -0
  15. package/dist/FactTextEditor-YUPBCTXK.cjs +27 -0
  16. package/dist/FactTextEditor-YUPBCTXK.cjs.map +1 -0
  17. package/dist/{NativeDocxEditor-BE2OEOTJ.cjs → NativeDocxEditor-5VBNM5I7.cjs} +8 -8
  18. package/dist/{NativeDocxEditor-BE2OEOTJ.cjs.map → NativeDocxEditor-5VBNM5I7.cjs.map} +1 -1
  19. package/dist/{NativeDocxEditor-KOPFMRYW.js → NativeDocxEditor-XT5ZLFGU.js} +4 -4
  20. package/dist/{NativeDocxEditor-KOPFMRYW.js.map → NativeDocxEditor-XT5ZLFGU.js.map} +1 -1
  21. package/dist/agents/index.cjs +265 -266
  22. package/dist/agents/index.js +8 -9
  23. package/dist/calendar/index.cjs +117 -125
  24. package/dist/calendar/index.d.ts +0 -1
  25. package/dist/calendar/index.js +1 -1
  26. package/dist/calls/index.cjs +3 -3
  27. package/dist/calls/index.js +2 -2
  28. package/dist/chat/index.cjs +78 -78
  29. package/dist/chat/index.js +3 -3
  30. package/dist/{chunk-2FL7QJKJ.js → chunk-265GOG4W.js} +3 -3
  31. package/dist/{chunk-2FL7QJKJ.js.map → chunk-265GOG4W.js.map} +1 -1
  32. package/dist/{chunk-VUR63NMQ.js → chunk-3E2F4AHD.js} +8 -8
  33. package/dist/{chunk-VUR63NMQ.js.map → chunk-3E2F4AHD.js.map} +1 -1
  34. package/dist/{chunk-U37AYUPI.cjs → chunk-3FSXWVHW.cjs} +47 -234
  35. package/dist/chunk-3FSXWVHW.cjs.map +1 -0
  36. package/dist/{chunk-IL3WB3YX.cjs → chunk-4JNKXOFZ.cjs} +3 -3
  37. package/dist/{chunk-IL3WB3YX.cjs.map → chunk-4JNKXOFZ.cjs.map} +1 -1
  38. package/dist/{chunk-ODRHHWHY.cjs → chunk-4KMLM3GY.cjs} +4 -4
  39. package/dist/chunk-4KMLM3GY.cjs.map +1 -0
  40. package/dist/{chunk-MHFF5N65.cjs → chunk-757OYF6G.cjs} +4 -38
  41. package/dist/chunk-757OYF6G.cjs.map +1 -0
  42. package/dist/chunk-AXTDDWMR.js +16 -0
  43. package/dist/chunk-AXTDDWMR.js.map +1 -0
  44. package/dist/{chunk-B3AHCIV5.js → chunk-BJ24VPOA.js} +4 -55
  45. package/dist/chunk-BJ24VPOA.js.map +1 -0
  46. package/dist/chunk-C7PTF6BQ.cjs +172 -0
  47. package/dist/chunk-C7PTF6BQ.cjs.map +1 -0
  48. package/dist/{chunk-LZRMXJIE.js → chunk-COA3S3CZ.js} +3 -3
  49. package/dist/{chunk-LZRMXJIE.js.map → chunk-COA3S3CZ.js.map} +1 -1
  50. package/dist/{chunk-SUUPR735.js → chunk-CQPFW64W.js} +5 -5
  51. package/dist/{chunk-SUUPR735.js.map → chunk-CQPFW64W.js.map} +1 -1
  52. package/dist/chunk-D3WFIFRY.cjs +659 -0
  53. package/dist/chunk-D3WFIFRY.cjs.map +1 -0
  54. package/dist/{chunk-QXMR5YHC.js → chunk-DIB4JYUY.js} +19 -3
  55. package/dist/chunk-DIB4JYUY.js.map +1 -0
  56. package/dist/chunk-DVB5ZKOF.js +22 -0
  57. package/dist/chunk-DVB5ZKOF.js.map +1 -0
  58. package/dist/{chunk-VHJHY7TT.js → chunk-ECERC6TI.js} +3 -3
  59. package/dist/{chunk-VHJHY7TT.js.map → chunk-ECERC6TI.js.map} +1 -1
  60. package/dist/chunk-EDV7CYG6.cjs +18 -0
  61. package/dist/chunk-EDV7CYG6.cjs.map +1 -0
  62. package/dist/chunk-FAXXN7KI.cjs +213 -0
  63. package/dist/chunk-FAXXN7KI.cjs.map +1 -0
  64. package/dist/{chunk-2MJWWPHY.js → chunk-G4IYES7G.js} +140 -15
  65. package/dist/chunk-G4IYES7G.js.map +1 -0
  66. package/dist/{chunk-AINU3EJ6.cjs → chunk-GGTUMLCT.cjs} +93 -91
  67. package/dist/chunk-GGTUMLCT.cjs.map +1 -0
  68. package/dist/{chunk-QI6AIHWP.cjs → chunk-GOWXP5KT.cjs} +145 -14
  69. package/dist/chunk-GOWXP5KT.cjs.map +1 -0
  70. package/dist/{chunk-H74HEPKT.js → chunk-HGLC566X.js} +598 -13
  71. package/dist/chunk-HGLC566X.js.map +1 -0
  72. package/dist/{chunk-AO7SK6WP.cjs → chunk-ILM42LE6.cjs} +33 -33
  73. package/dist/{chunk-AO7SK6WP.cjs.map → chunk-ILM42LE6.cjs.map} +1 -1
  74. package/dist/{chunk-LTU35TQN.cjs → chunk-IPQ5MJ4Z.cjs} +636 -31
  75. package/dist/chunk-IPQ5MJ4Z.cjs.map +1 -0
  76. package/dist/{chunk-NRFAWUVD.js → chunk-JAANWQGB.js} +157 -157
  77. package/dist/chunk-JAANWQGB.js.map +1 -0
  78. package/dist/{chunk-7RJTEWYM.js → chunk-JGOST4IL.js} +350 -64
  79. package/dist/chunk-JGOST4IL.js.map +1 -0
  80. package/dist/chunk-KHXEIEXN.js +41 -0
  81. package/dist/chunk-KHXEIEXN.js.map +1 -0
  82. package/dist/chunk-KLPRAQCE.cjs +22 -0
  83. package/dist/chunk-KLPRAQCE.cjs.map +1 -0
  84. package/dist/chunk-KQYPP72K.js +644 -0
  85. package/dist/chunk-KQYPP72K.js.map +1 -0
  86. package/dist/chunk-KUT2Y7JF.cjs +43 -0
  87. package/dist/chunk-KUT2Y7JF.cjs.map +1 -0
  88. package/dist/{chunk-6YTHQ73P.cjs → chunk-LLYZGH3L.cjs} +3 -56
  89. package/dist/chunk-LLYZGH3L.cjs.map +1 -0
  90. package/dist/{chunk-YSHIC4NJ.cjs → chunk-LXTOOUEN.cjs} +159 -154
  91. package/dist/chunk-LXTOOUEN.cjs.map +1 -0
  92. package/dist/{chunk-EVUEIBNU.js → chunk-M4S75AEJ.js} +44 -5
  93. package/dist/chunk-M4S75AEJ.js.map +1 -0
  94. package/dist/{chunk-V5OAXIBN.cjs → chunk-NPR5BGFF.cjs} +11 -11
  95. package/dist/{chunk-V5OAXIBN.cjs.map → chunk-NPR5BGFF.cjs.map} +1 -1
  96. package/dist/{chunk-PLJ7PHWU.cjs → chunk-NS7NVX4E.cjs} +3 -3
  97. package/dist/{chunk-PLJ7PHWU.cjs.map → chunk-NS7NVX4E.cjs.map} +1 -1
  98. package/dist/{chunk-T5I4NRFP.cjs → chunk-NWNAYXC7.cjs} +9 -9
  99. package/dist/{chunk-T5I4NRFP.cjs.map → chunk-NWNAYXC7.cjs.map} +1 -1
  100. package/dist/{chunk-WIZ7Z7FN.js → chunk-Q6N6MZKO.js} +47 -222
  101. package/dist/chunk-Q6N6MZKO.js.map +1 -0
  102. package/dist/{chunk-I2QSDQQV.cjs → chunk-QT3A4PFC.cjs} +21 -2
  103. package/dist/chunk-QT3A4PFC.cjs.map +1 -0
  104. package/dist/{chunk-ZM26YEOT.js → chunk-RY2SODRN.js} +3 -3
  105. package/dist/{chunk-ZM26YEOT.js.map → chunk-RY2SODRN.js.map} +1 -1
  106. package/dist/chunk-SDOEHEJP.js +208 -0
  107. package/dist/chunk-SDOEHEJP.js.map +1 -0
  108. package/dist/{chunk-DETZZBG2.cjs → chunk-SIB6C7P7.cjs} +43 -2
  109. package/dist/chunk-SIB6C7P7.cjs.map +1 -0
  110. package/dist/{chunk-MFY2ZNP6.cjs → chunk-SMN32BQ3.cjs} +4 -4
  111. package/dist/chunk-SMN32BQ3.cjs.map +1 -0
  112. package/dist/chunk-TAWPVD6C.cjs +1956 -0
  113. package/dist/chunk-TAWPVD6C.cjs.map +1 -0
  114. package/dist/chunk-TC25LGIM.js +6584 -0
  115. package/dist/chunk-TC25LGIM.js.map +1 -0
  116. package/dist/{chunk-DAHCRVPM.js → chunk-TL45OJQE.js} +85 -83
  117. package/dist/chunk-TL45OJQE.js.map +1 -0
  118. package/dist/{chunk-AOSUHWIL.js → chunk-TZOQKV64.js} +4 -37
  119. package/dist/chunk-TZOQKV64.js.map +1 -0
  120. package/dist/chunk-UTVY63DG.js +16 -0
  121. package/dist/chunk-UTVY63DG.js.map +1 -0
  122. package/dist/chunk-V4YZXGXR.cjs +6751 -0
  123. package/dist/chunk-V4YZXGXR.cjs.map +1 -0
  124. package/dist/chunk-XRWHFMHK.js +19 -0
  125. package/dist/chunk-XRWHFMHK.js.map +1 -0
  126. package/dist/{chunk-O4YPVYPO.cjs → chunk-YAEXSCUW.cjs} +364 -60
  127. package/dist/chunk-YAEXSCUW.cjs.map +1 -0
  128. package/dist/chunk-YIFCLNII.cjs +18 -0
  129. package/dist/chunk-YIFCLNII.cjs.map +1 -0
  130. package/dist/chunk-Z27QMJ6S.cjs +25 -0
  131. package/dist/chunk-Z27QMJ6S.cjs.map +1 -0
  132. package/dist/{chunk-CSI2B2H5.js → chunk-Z4NQ3TED.js} +4 -4
  133. package/dist/chunk-Z4NQ3TED.js.map +1 -0
  134. package/dist/{chunk-DWZXSPMB.cjs → chunk-ZAVEMQ37.cjs} +3 -3
  135. package/dist/{chunk-DWZXSPMB.cjs.map → chunk-ZAVEMQ37.cjs.map} +1 -1
  136. package/dist/{chunk-DGV7HQA7.js → chunk-ZLEYLCE4.js} +4 -4
  137. package/dist/chunk-ZLEYLCE4.js.map +1 -0
  138. package/dist/chunk-ZNLTEZEF.js +170 -0
  139. package/dist/chunk-ZNLTEZEF.js.map +1 -0
  140. package/dist/chunk-ZO7PJMCO.js +1907 -0
  141. package/dist/chunk-ZO7PJMCO.js.map +1 -0
  142. package/dist/citations/index.cjs +14 -14
  143. package/dist/citations/index.js +2 -2
  144. package/dist/collaboration/index.cjs +36 -36
  145. package/dist/collaboration/index.js +2 -2
  146. package/dist/connect/docx.cjs +23 -28
  147. package/dist/connect/docx.cjs.map +1 -1
  148. package/dist/connect/docx.js +12 -28
  149. package/dist/connect/docx.js.map +1 -1
  150. package/dist/connect/index.cjs +8661 -2823
  151. package/dist/connect/index.cjs.map +1 -1
  152. package/dist/connect/index.d.ts +10 -2
  153. package/dist/connect/index.js +8468 -2671
  154. package/dist/connect/index.js.map +1 -1
  155. package/dist/connect/viewer.cjs +1229 -0
  156. package/dist/connect/viewer.cjs.map +1 -0
  157. package/dist/connect/viewer.d.ts +8 -0
  158. package/dist/connect/viewer.js +1226 -0
  159. package/dist/connect/viewer.js.map +1 -0
  160. package/dist/connection/ConnectedWorkflowsTable.d.ts +2 -12
  161. package/dist/connection/ai.d.ts +2 -9
  162. package/dist/connection/billing/AddAddonDialog.d.ts +24 -0
  163. package/dist/connection/billing/BillingCard.d.ts +18 -0
  164. package/dist/connection/billing/BillingProjectEntity.d.ts +9 -0
  165. package/dist/connection/billing/ChangePlanDialog.d.ts +20 -0
  166. package/dist/connection/billing/ChangeProPlan.d.ts +20 -0
  167. package/dist/connection/billing/CheckoutTotal.d.ts +12 -0
  168. package/dist/connection/billing/DailyCapEditor.d.ts +4 -0
  169. package/dist/connection/billing/InvoicesModal.d.ts +6 -0
  170. package/dist/connection/billing/NewProjectFlow.d.ts +14 -0
  171. package/dist/connection/billing/PlanChangeLines.d.ts +13 -0
  172. package/dist/connection/billing/PlanSelector.d.ts +50 -0
  173. package/dist/connection/billing/ProjectBilling.d.ts +24 -0
  174. package/dist/connection/billing/ProjectDetail.d.ts +16 -0
  175. package/dist/connection/billing/ProjectUsageCard.d.ts +21 -0
  176. package/dist/connection/billing/ProjectUsageContent.d.ts +18 -0
  177. package/dist/connection/billing/ProjectsTable.d.ts +13 -0
  178. package/dist/connection/billing/ReduceAddonDialog.d.ts +18 -0
  179. package/dist/connection/billing/ReferralReward.d.ts +32 -0
  180. package/dist/connection/billing/SharedProjects.d.ts +13 -0
  181. package/dist/connection/billing/StripeCheckoutModal.d.ts +32 -0
  182. package/dist/connection/billing/SubscriptionPlans.d.ts +15 -0
  183. package/dist/connection/billing/SubscriptionStatus.d.ts +10 -0
  184. package/dist/connection/billing/addon-pricing.d.ts +97 -0
  185. package/dist/connection/billing/api-error.d.ts +6 -0
  186. package/dist/connection/billing/billing-country.d.ts +14 -0
  187. package/dist/connection/billing/billing-focus.d.ts +11 -0
  188. package/dist/connection/billing/index.d.ts +22 -0
  189. package/dist/connection/billing/plan-badge.d.ts +15 -0
  190. package/dist/connection/billing/plan-change-outcome.d.ts +15 -0
  191. package/dist/connection/billing/plan-constants.d.ts +29 -0
  192. package/dist/connection/billing/plan-pricing.d.ts +67 -0
  193. package/dist/connection/billing/quota-items.d.ts +33 -0
  194. package/dist/connection/billing/referral-reward.d.ts +28 -0
  195. package/dist/connection/billing/refusal-copy.d.ts +5 -0
  196. package/dist/connection/billing/reward-balance.d.ts +19 -0
  197. package/dist/connection/billing/support.d.ts +35 -0
  198. package/dist/connection/billing/tax-quote.d.ts +36 -0
  199. package/dist/connection/billing/useAddonPurchase.d.ts +32 -0
  200. package/dist/connection/billing/useAutoRefreshPendingProjects.d.ts +11 -0
  201. package/dist/connection/billing/useCheckoutQuote.d.ts +30 -0
  202. package/dist/connection/billing/useOpenBillingPortal.d.ts +12 -0
  203. package/dist/connection/calendar/CalendarSettingsDialog.d.ts +1 -1
  204. package/dist/connection/facts/ConnectedFactsPage.d.ts +50 -0
  205. package/dist/connection/facts/FactMarkdownEditor.d.ts +57 -0
  206. package/dist/connection/facts/FactSourcesPopover.d.ts +38 -0
  207. package/dist/connection/facts/FactTextEditor.d.ts +2 -0
  208. package/dist/connection/facts/factNouns.d.ts +4 -0
  209. package/dist/connection/facts/factPageColumns.d.ts +37 -0
  210. package/dist/connection/facts/types.d.ts +127 -0
  211. package/dist/connection/facts/useFactActions.d.ts +10 -0
  212. package/dist/connection/facts/useFactComposer.d.ts +54 -0
  213. package/dist/connection/facts/useFactFilters.d.ts +101 -0
  214. package/dist/connection/facts/useFactSelection.d.ts +82 -0
  215. package/dist/connection/facts/useFactsGrid.d.ts +87 -0
  216. package/dist/connection/facts/useFactsPageView.d.ts +4 -0
  217. package/dist/connection/mail/ConnectedMailComposer.d.ts +3 -1
  218. package/dist/connection/mail/ConnectedMailbox.d.ts +4 -2
  219. package/dist/connection/mail/MailComposerForm.d.ts +4 -2
  220. package/dist/connection/mail/MailRecipientInput.d.ts +14 -0
  221. package/dist/connection/mail/index.d.ts +1 -1
  222. package/dist/connection/mail/types.d.ts +10 -0
  223. package/dist/connection/search/ConnectedSearchPage.d.ts +64 -0
  224. package/dist/connection/search/SearchResultRows.d.ts +38 -0
  225. package/dist/connection/search/index.d.ts +2 -0
  226. package/dist/connection/tags/ConnectedTagTable.d.ts +108 -0
  227. package/dist/connection/tags/ConnectedTagsPage.d.ts +55 -0
  228. package/dist/connection/tags/DocTagPassages.d.ts +25 -0
  229. package/dist/connection/tags/GlossaryExport.d.ts +7 -0
  230. package/dist/connection/tags/TagCombineFilter.d.ts +14 -0
  231. package/dist/connection/tags/TagPlacement.d.ts +16 -0
  232. package/dist/connection/tags/TagsPageSections.d.ts +36 -0
  233. package/dist/connection/tags/tagCombine.d.ts +55 -0
  234. package/dist/connection/useConnectedWorkNotifications.d.ts +7 -24
  235. package/dist/connection/viewer/ConnectedDocumentToolsProvider.d.ts +11 -0
  236. package/dist/connection/viewer/ConnectedDocumentViewer.d.ts +21 -0
  237. package/dist/connection/viewer/FinaliseTranslationButton.d.ts +15 -0
  238. package/dist/connection/viewer/ViewerPdfPane.d.ts +46 -0
  239. package/dist/connection/viewer/support.d.ts +79 -0
  240. package/dist/connection/viewer/useImageCrop.d.ts +13 -0
  241. package/dist/connection/viewer/useViewedDocument.d.ts +70 -0
  242. package/dist/connection/viewer/useViewerBlobs.d.ts +15 -0
  243. package/dist/connection/viewer/useViewerTabs.d.ts +18 -0
  244. package/dist/connection/viewer/useViewerVersions.d.ts +11 -0
  245. package/dist/connection/workspace-settings/useConnectedWorkspaceSettings.d.ts +6 -0
  246. package/dist/document-tools/index.cjs +59 -652
  247. package/dist/document-tools/index.cjs.map +1 -1
  248. package/dist/document-tools/index.js +2 -641
  249. package/dist/document-tools/index.js.map +1 -1
  250. package/dist/docx/index.cjs +48 -47
  251. package/dist/docx/index.js +4 -3
  252. package/dist/facts/FactsBulkBar.d.ts +6 -3
  253. package/dist/facts/cited-version-ref.d.ts +1 -0
  254. package/dist/facts/index.cjs +206 -1942
  255. package/dist/facts/index.cjs.map +1 -1
  256. package/dist/facts/index.d.ts +1 -0
  257. package/dist/facts/index.js +15 -1897
  258. package/dist/facts/index.js.map +1 -1
  259. package/dist/files/ViewerChrome.d.ts +5 -4
  260. package/dist/files/ViewerControlBar.d.ts +12 -0
  261. package/dist/files/doc-labels.d.ts +35 -0
  262. package/dist/files/grid/FilterButton.d.ts +12 -0
  263. package/dist/files/grid/RowDensityControl.d.ts +18 -0
  264. package/dist/files/grid/row-density.d.ts +27 -0
  265. package/dist/files/index.cjs +779 -7100
  266. package/dist/files/index.cjs.map +1 -1
  267. package/dist/files/index.d.ts +5 -0
  268. package/dist/files/index.js +14 -6919
  269. package/dist/files/index.js.map +1 -1
  270. package/dist/home/index.cjs +2 -2
  271. package/dist/home/index.js +2 -2
  272. package/dist/index.cjs +1041 -1257
  273. package/dist/index.cjs.map +1 -1
  274. package/dist/index.js +24 -357
  275. package/dist/index.js.map +1 -1
  276. package/dist/retrieval/SearchSnippet.d.ts +6 -0
  277. package/dist/retrieval/index.cjs +75 -42
  278. package/dist/retrieval/index.d.ts +2 -0
  279. package/dist/retrieval/index.js +3 -2
  280. package/dist/retrieval/search-results.d.ts +46 -0
  281. package/dist/settings/Billing.d.ts +0 -66
  282. package/dist/settings/SubscriptionParts.d.ts +1 -50
  283. package/dist/settings/index.cjs +170 -218
  284. package/dist/settings/index.d.ts +3 -2
  285. package/dist/settings/index.js +3 -3
  286. package/dist/settings/inverted-index-filter.d.ts +26 -0
  287. package/dist/shell/index.cjs +2 -2
  288. package/dist/shell/index.js +2 -2
  289. package/dist/studio/index.cjs +5 -5
  290. package/dist/studio/index.js +4 -4
  291. package/dist/tags/definitions.d.ts +10 -0
  292. package/dist/tags/index.d.ts +4 -1
  293. package/dist/tags/page/ExtractEntitiesDialog.d.ts +24 -0
  294. package/dist/tags/page/TagPicker.d.ts +16 -0
  295. package/dist/tags/page/tagsPageLabels.d.ts +36 -0
  296. package/dist/workflow-canvas/index.cjs +21 -22
  297. package/dist/workflow-canvas/index.cjs.map +1 -1
  298. package/dist/workflow-canvas/index.js +8 -9
  299. package/dist/workflow-canvas/index.js.map +1 -1
  300. package/node_modules/@arbidocs/coedit/package.json +1 -1
  301. package/package.json +13 -4
  302. package/dist/calendar/access-setup.d.ts +0 -8
  303. package/dist/chunk-2MJWWPHY.js.map +0 -1
  304. package/dist/chunk-3AFWGEDJ.cjs +0 -53
  305. package/dist/chunk-3AFWGEDJ.cjs.map +0 -1
  306. package/dist/chunk-6YTHQ73P.cjs.map +0 -1
  307. package/dist/chunk-7RJTEWYM.js.map +0 -1
  308. package/dist/chunk-AINU3EJ6.cjs.map +0 -1
  309. package/dist/chunk-AOSUHWIL.js.map +0 -1
  310. package/dist/chunk-B3AHCIV5.js.map +0 -1
  311. package/dist/chunk-CSI2B2H5.js.map +0 -1
  312. package/dist/chunk-DAHCRVPM.js.map +0 -1
  313. package/dist/chunk-DETZZBG2.cjs.map +0 -1
  314. package/dist/chunk-DGV7HQA7.js.map +0 -1
  315. package/dist/chunk-EVUEIBNU.js.map +0 -1
  316. package/dist/chunk-H74HEPKT.js.map +0 -1
  317. package/dist/chunk-I2QSDQQV.cjs.map +0 -1
  318. package/dist/chunk-J5CWKFSC.js +0 -170
  319. package/dist/chunk-J5CWKFSC.js.map +0 -1
  320. package/dist/chunk-LTU35TQN.cjs.map +0 -1
  321. package/dist/chunk-MFY2ZNP6.cjs.map +0 -1
  322. package/dist/chunk-MHFF5N65.cjs.map +0 -1
  323. package/dist/chunk-NRFAWUVD.js.map +0 -1
  324. package/dist/chunk-O4YPVYPO.cjs.map +0 -1
  325. package/dist/chunk-ODRHHWHY.cjs.map +0 -1
  326. package/dist/chunk-QI6AIHWP.cjs.map +0 -1
  327. package/dist/chunk-QXMR5YHC.js.map +0 -1
  328. package/dist/chunk-RFXJYIDV.js +0 -50
  329. package/dist/chunk-RFXJYIDV.js.map +0 -1
  330. package/dist/chunk-U37AYUPI.cjs.map +0 -1
  331. package/dist/chunk-WIZ7Z7FN.js.map +0 -1
  332. package/dist/chunk-XVUOMWMD.cjs +0 -177
  333. package/dist/chunk-XVUOMWMD.cjs.map +0 -1
  334. package/dist/chunk-YSHIC4NJ.cjs.map +0 -1
  335. package/dist/connection/ConnectedTagTable.d.ts +0 -32
  336. package/dist/connection/calendar/CopyField.d.ts +0 -9
  337. package/dist/connection/calendar/OpenAccessPanel.d.ts +0 -7
@@ -0,0 +1,1226 @@
1
+ "use client";
2
+ import { ViewerTitle, ViewerTabBar, ViewerImageActions, ViewerFrame, ViewerMessage, DocumentLabelBar, ViewerControlBar, ViewerZoomControl, PdfPageNav, ViewerPageCounter, summariseDocTags, isDocumentLabel, ViewerPreviewUnavailable, ViewerLoadError } from '../chunk-TC25LGIM.js';
3
+ import { useDocumentViewerSupport } from '../chunk-XRWHFMHK.js';
4
+ import '../chunk-JGOST4IL.js';
5
+ import '../chunk-RC6VTY2H.js';
6
+ import { useConnectedConversations, useConnectedDocuments, useConnectedTags } from '../chunk-DN2KI4BU.js';
7
+ import { useConnectedWorkspace } from '../chunk-US3S4DCB.js';
8
+ import { MarkupViewNote, SignatureStatus, AnnotateButton, ShowOriginalButton, DownloadMarkupButton, SignButton, RequestSignaturesButton, MarkupNotices, SignedEditNote, VersionSnapshotBar, SignatureRequestBanner } from '../chunk-KQYPP72K.js';
9
+ import '../chunk-EQB3WELX.js';
10
+ import { ViewerStatusNote, ViewerHeaderStart, ViewerHeaderEnd, ViewerPane } from '../chunk-6HKLTYNN.js';
11
+ import { SignDocumentDialog } from '../chunk-2YOVK524.js';
12
+ import '../chunk-JJA6GQKH.js';
13
+ import '../chunk-H4D7WKDY.js';
14
+ import { ShareControl } from '../chunk-K4BGOPGG.js';
15
+ import '../chunk-SDOEHEJP.js';
16
+ import '../chunk-A3XPS2EU.js';
17
+ import '../chunk-M4S75AEJ.js';
18
+ import '../chunk-5LXQPP2K.js';
19
+ import '../chunk-RLWIUUQ5.js';
20
+ import '../chunk-YKQ2DPIP.js';
21
+ import '../chunk-NUNKSZKU.js';
22
+ import '../chunk-YU2KUMGE.js';
23
+ import '../chunk-N5YEF3LC.js';
24
+ import { ArtifactCompareBar, ArtifactPreview, ArtifactCodeView, VersionTimeline } from '../chunk-65S53MZK.js';
25
+ import '../chunk-NS4JD2VR.js';
26
+ import '../chunk-LOJVUGBJ.js';
27
+ import { TabHeader } from '../chunk-4WWM3GQ5.js';
28
+ import { useBlocksEnvironment } from '../chunk-TBEVGWY3.js';
29
+ import '../chunk-TX2ZICS7.js';
30
+ import '../chunk-OKERRHLH.js';
31
+ import '../chunk-7XF5SFJ2.js';
32
+ import { useRegisterOpenDocument, savedDocumentIdFor } from '../chunk-YBLIKTJK.js';
33
+ import '../chunk-AUS3KBHJ.js';
34
+ import { useIsPhone } from '../chunk-SLSBJRWW.js';
35
+ import '../chunk-NPLYHR2E.js';
36
+ import '../chunk-7F6CBP3Z.js';
37
+ import { fmtDate } from '../chunk-OXF2IFXG.js';
38
+ import '../chunk-VUNV25KB.js';
39
+ import { lazy, useMemo, useCallback, useState, useRef, useEffect, Suspense } from 'react';
40
+ import { MessageSquare, Mail, Languages, FileCheck2, MonitorPlay, Code, FileText, History } from 'lucide-react';
41
+ import { useArbi, refreshDocuments, arbiQueryKeys, useArbiSessionState, useArbiSessionStore, ImageCropModal, DEFAULT_ASPECT_OPTIONS, useDocumentVersionList, useDocument, useParsedDocument, hasVideoTrack, useFinaliseTranslation, DocIcon, XlsIcon, HtmlIcon, VidIcon, AudIcon, ImgIcon, EmlIcon, PdfIcon } from '@arbidocs/react';
42
+ import { parseVersionRef, versionLabel, findVersion, documentVersions, toArtifactVersions, artifactKindFromMode, artifactKindFromFileName, useArtifactSource } from '@arbidocs/react/artifacts';
43
+ import { useOptionalDocumentTools, documentBytesKey, clientUpload, DocumentToolsProvider, useDocumentTools, useDocumentSignatures, useDocumentMarkup, canAnnotate, SIGNED_LOCKED_REASON, useDocumentBytes, fetchDocumentFile } from '@arbidocs/react/document-tools';
44
+ import { XlsxViewer, cycleZoom, VideoViewer, AudioViewer, ImageViewer, PdfViewer } from '@arbidocs/react/viewers';
45
+ import { Button, getEntityLabel, isImageFile, isVideoFile, isAudioFile, isDownloadOnlyFile, friendlyFileType } from '@arbidocs/react/ui';
46
+ import { useQueryClient } from '@tanstack/react-query';
47
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
48
+
49
+ function ConnectedDocumentToolsProvider({ children }) {
50
+ const enclosing = useOptionalDocumentTools();
51
+ return enclosing ? /* @__PURE__ */ jsx(Fragment, { children }) : /* @__PURE__ */ jsx(OwnDocumentTools, { children });
52
+ }
53
+ function OwnDocumentTools({ children }) {
54
+ const arbi = useArbi();
55
+ const queryClient = useQueryClient();
56
+ const { user, ensureWorkspaceOpen } = useConnectedWorkspace();
57
+ const { notify: environmentNotify, openDocument: openInHost } = useBlocksEnvironment();
58
+ const client = arbi.isLoggedIn ? arbi.getClient().fetch : null;
59
+ const signer = useMemo(
60
+ () => user ? { name: user.name, email: user.email, externalId: user.externalId } : null,
61
+ [user]
62
+ );
63
+ const notify = useCallback(
64
+ (message, kind, options) => environmentNotify(message, kind, {
65
+ description: options?.description,
66
+ action: options?.action
67
+ }),
68
+ [environmentNotify]
69
+ );
70
+ const onDocumentsChanged = useCallback(
71
+ async (ids, change) => {
72
+ const refresh = [refreshDocuments(queryClient, arbi, ids)];
73
+ if (change === "signed" || change === "version")
74
+ for (const id of ids)
75
+ refresh.push(
76
+ queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documentVersions(id) }),
77
+ queryClient.invalidateQueries({ queryKey: documentBytesKey(id) })
78
+ );
79
+ await Promise.all(refresh);
80
+ },
81
+ [queryClient, arbi]
82
+ );
83
+ const uploadDocument = useCallback(
84
+ async (request) => {
85
+ if (!client) throw new Error("Sign in to save a copy.");
86
+ await ensureWorkspaceOpen();
87
+ return clientUpload(client)(request);
88
+ },
89
+ [client, ensureWorkspaceOpen]
90
+ );
91
+ const openDocument = useCallback((ref) => openInHost(ref), [openInHost]);
92
+ if (!client) return /* @__PURE__ */ jsx(Fragment, { children });
93
+ return /* @__PURE__ */ jsx(
94
+ DocumentToolsProvider,
95
+ {
96
+ client,
97
+ user: signer,
98
+ notify,
99
+ openDocument,
100
+ onDocumentsChanged,
101
+ uploadDocument,
102
+ children
103
+ }
104
+ );
105
+ }
106
+ var isTranslationDraft = (doc) => !!doc?.derived_from?.some((d) => d.role === "translation") && !doc.derived_from.some((d) => d.role === "final");
107
+ function FinaliseTranslationButton({
108
+ document,
109
+ isCompact
110
+ }) {
111
+ const finalise = useFinaliseTranslation();
112
+ const { openDocument } = useDocumentTools();
113
+ const { notify } = useBlocksEnvironment();
114
+ if (!document || !isTranslationDraft(document)) return null;
115
+ const pending = finalise.isPending;
116
+ const onClick = async () => {
117
+ try {
118
+ const { document_ext_id: finalId } = await finalise.mutateAsync(document.external_id);
119
+ notify("Saved the final PDF of this translation", "success");
120
+ openDocument?.(finalId);
121
+ } catch (error) {
122
+ const detail = error?.detail;
123
+ notify(
124
+ typeof detail === "string" ? detail : "The final PDF could not be saved. Try again.",
125
+ "error"
126
+ );
127
+ }
128
+ };
129
+ return /* @__PURE__ */ jsxs(
130
+ Button,
131
+ {
132
+ type: "button",
133
+ variant: "outline",
134
+ size: isCompact ? "icon" : "sm",
135
+ title: "Finalise: save this translation as a new PDF, labelled Translation and linked to the original",
136
+ "aria-label": "Finalise",
137
+ "data-testid": "finalise-translation-button",
138
+ className: "pointer-coarse:min-h-11",
139
+ disabled: pending,
140
+ onClick: () => void onClick(),
141
+ children: [
142
+ /* @__PURE__ */ jsx(FileCheck2, { className: "size-4" }),
143
+ !isCompact && /* @__PURE__ */ jsx("span", { className: "ml-1", children: pending ? "Finalising\u2026" : "Finalise" })
144
+ ]
145
+ }
146
+ );
147
+ }
148
+ function useImageCrop(documentId, fileName, imageBlob) {
149
+ const { uploadDocument, onDocumentsChanged, openDocument } = useDocumentTools();
150
+ const { notify } = useBlocksEnvironment();
151
+ const [cropImageUrl, setCropImageUrl] = useState(null);
152
+ const handleOpenCrop = useCallback(() => {
153
+ if (!imageBlob) return;
154
+ setCropImageUrl(URL.createObjectURL(imageBlob));
155
+ }, [imageBlob]);
156
+ const closeCrop = useCallback(() => {
157
+ setCropImageUrl((url) => {
158
+ if (url) URL.revokeObjectURL(url);
159
+ return null;
160
+ });
161
+ }, []);
162
+ const handleCropComplete = useCallback(
163
+ async (result) => {
164
+ const baseName = (fileName || "image").replace(/\.[^.]+$/, "");
165
+ const file = new File([result.blob], `${baseName} (cropped).png`, { type: "image/png" });
166
+ try {
167
+ const response = await uploadDocument({
168
+ file,
169
+ query: { derived_from: [documentId], derived_role: "crop" }
170
+ });
171
+ const newDocId = response?.doc_ext_ids?.[0];
172
+ if (newDocId) {
173
+ await onDocumentsChanged?.([newDocId], "copy");
174
+ openDocument?.(newDocId);
175
+ }
176
+ notify("Cropped image saved", "success");
177
+ } catch {
178
+ notify("Failed to save the cropped image", "error");
179
+ } finally {
180
+ closeCrop();
181
+ }
182
+ },
183
+ [fileName, documentId, uploadDocument, onDocumentsChanged, openDocument, notify, closeCrop]
184
+ );
185
+ return { cropImageUrl, handleOpenCrop, closeCrop, handleCropComplete };
186
+ }
187
+ var DOCX_EXTENSIONS = /* @__PURE__ */ new Set([".docx", ".doc"]);
188
+ var XLSX_EXTENSIONS = /* @__PURE__ */ new Set([".xlsx", ".xls"]);
189
+ var EMAIL_EXTENSIONS = /* @__PURE__ */ new Set([".eml", ".msg"]);
190
+ function fileExtension(fileName) {
191
+ if (!fileName) return "";
192
+ return fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
193
+ }
194
+ function useViewedDocument(documentId) {
195
+ const support = useDocumentViewerSupport();
196
+ const [webmHasVideoTrack, setWebmHasVideoTrack] = useState(null);
197
+ useEffect(() => setWebmHasVideoTrack(null), [documentId]);
198
+ const streamingDoc = support.streamingDocuments?.[documentId];
199
+ const isStreaming = !!streamingDoc && !streamingDoc.isComplete;
200
+ const draftDoc = support.draftDocuments?.[documentId];
201
+ const isDraft = !!draftDoc;
202
+ const isCaptureDraft = draftDoc?.kind === "audio" || draftDoc?.kind === "photo" || draftDoc?.kind === "video";
203
+ const isTextDraft = draftDoc?.kind === "text";
204
+ const { workspaceId, live } = useConnectedWorkspace();
205
+ const { data: record } = useDocument(documentId, {
206
+ enabled: live && !!workspaceId && !isStreaming && !isDraft,
207
+ // A new version (Save version, a signed copy) is processed before its PDF exists: keep
208
+ // re-reading until it is done, so the PDF tab and the signing tools come back on their own.
209
+ pollWhileProcessing: true
210
+ });
211
+ const documentData = record?.external_id === documentId ? record : void 0;
212
+ const { data: tags } = useConnectedTags();
213
+ const labelSummaries = useMemo(
214
+ () => summariseDocTags(documentData?.doctags ?? [], tags.filter(isDocumentLabel)),
215
+ [documentData, tags]
216
+ );
217
+ const fileName = documentData?.file_name;
218
+ const isMarkdown = fileExtension(fileName) === ".md";
219
+ const isImage = isImageFile(fileName);
220
+ const isWebmFile = fileExtension(fileName) === ".webm";
221
+ const isVideo = isWebmFile && webmHasVideoTrack === false ? false : isVideoFile(fileName);
222
+ const isAudio = isWebmFile && webmHasVideoTrack === false ? true : isAudioFile(fileName);
223
+ const isBlobArtifact = streamingDoc?.mode === "image" || documentData?.wp_type === "artifact" && (isImage || isVideo || isAudio);
224
+ const isArtifact = (!!streamingDoc || isTextDraft || documentData?.wp_type === "artifact" || isMarkdown) && !isBlobArtifact;
225
+ const liveKind = isArtifact ? artifactKindFromMode(streamingDoc?.mode ?? void 0) ?? artifactKindFromFileName(fileName) : null;
226
+ const savedDocumentId = savedDocumentIdFor({
227
+ documentId,
228
+ isDraft,
229
+ isStreaming,
230
+ isBlobArtifact,
231
+ documentData
232
+ });
233
+ const { data: liveSourceFetched } = useArtifactSource(
234
+ documentId,
235
+ !!liveKind && !streamingDoc && !!documentData && !isDraft
236
+ );
237
+ const liveSource = streamingDoc ? streamingDoc.content : liveSourceFetched ?? "";
238
+ const hasParsedDocStatus = documentData?.status === "completed" || documentData?.status === "low-content";
239
+ const { data: parsedDoc, isLoading: isParsedDocLoading } = useParsedDocument(
240
+ documentId,
241
+ "final",
242
+ {
243
+ enabled: !!documentId && live && !isStreaming && !isDraft && !isBlobArtifact && hasParsedDocStatus
244
+ }
245
+ );
246
+ const hasParsedContent = (parsedDoc?.chunks?.length ?? 0) > 0;
247
+ return {
248
+ workspaceId,
249
+ documentData,
250
+ streamingDoc,
251
+ isStreaming,
252
+ draftDoc,
253
+ isDraft,
254
+ isCaptureDraft,
255
+ isTextDraft,
256
+ labelSummaries,
257
+ isImage,
258
+ isWebmFile,
259
+ setWebmHasVideoTrack,
260
+ isVideo,
261
+ isAudio,
262
+ isMedia: isVideo || isAudio,
263
+ isBlobArtifact,
264
+ savedDocumentId,
265
+ isArtifact,
266
+ liveKind,
267
+ liveSource,
268
+ isDocx: DOCX_EXTENSIONS.has(fileExtension(fileName)),
269
+ isXlsx: XLSX_EXTENSIONS.has(fileExtension(fileName)),
270
+ isEmail: EMAIL_EXTENSIONS.has(fileExtension(fileName)),
271
+ isDownloadOnly: isDownloadOnlyFile(fileName),
272
+ isParsedDocLoading,
273
+ hasParsedContent
274
+ };
275
+ }
276
+ function useViewerBlobs(documentId, doc) {
277
+ const { documentData, isArtifact, isDocx, isXlsx, isDownloadOnly, isWebmFile } = doc;
278
+ const { setWebmHasVideoTrack } = doc;
279
+ const { client, saveFile } = useDocumentTools();
280
+ const { notify } = useBlocksEnvironment();
281
+ const { loadOfflineCopy } = useDocumentViewerSupport();
282
+ const currentVersion = documentData?.current_version ?? 1;
283
+ const name = documentData?.file_name;
284
+ const original = isImageFile(name) || isVideoFile(name) || isAudioFile(name);
285
+ const fallback = loadOfflineCopy && documentData && !parseVersionRef(documentId).version ? () => loadOfflineCopy(documentData) : void 0;
286
+ const pdf = useDocumentBytes(documentId, {
287
+ version: currentVersion,
288
+ kind: original ? "original" : "pdf",
289
+ enabled: !isArtifact && !!documentData && !isDownloadOnly && (!isDocx || documentData.status === "completed" || documentData.status === "low-content"),
290
+ fallback
291
+ });
292
+ const [pdfBlob, setPdfBlob] = useState(null);
293
+ useEffect(() => setPdfBlob(null), [documentId]);
294
+ useEffect(() => {
295
+ if (pdf.data) setPdfBlob(pdf.data);
296
+ }, [pdf.data]);
297
+ useEffect(() => {
298
+ if (!isWebmFile || !pdfBlob) return;
299
+ let cancelled = false;
300
+ void hasVideoTrack(pdfBlob).then((result) => {
301
+ if (!cancelled) setWebmHasVideoTrack(result);
302
+ });
303
+ return () => {
304
+ cancelled = true;
305
+ };
306
+ }, [isWebmFile, pdfBlob, setWebmHasVideoTrack]);
307
+ const xlsx = useDocumentBytes(documentId, {
308
+ version: currentVersion,
309
+ kind: "original",
310
+ enabled: !isArtifact && !!documentData && isXlsx
311
+ });
312
+ const handleDirectDownload = useCallback(async () => {
313
+ try {
314
+ saveFile(await fetchDocumentFile(client, documentId), documentData?.file_name || "download");
315
+ } catch {
316
+ notify("Failed to download file", "error");
317
+ }
318
+ }, [client, saveFile, notify, documentId, documentData?.file_name]);
319
+ return {
320
+ pdfBlob,
321
+ isPdfLoading: pdf.isLoading,
322
+ pdfError: pdf.error,
323
+ xlsxBlob: xlsx.data ?? null,
324
+ xlsxError: xlsx.error,
325
+ handleDirectDownload
326
+ };
327
+ }
328
+ function useViewerTabs(doc, isCompact, hasHistory = false) {
329
+ const {
330
+ documentData,
331
+ isArtifact,
332
+ isDocx,
333
+ isXlsx,
334
+ isEmail,
335
+ isVideo,
336
+ isAudio,
337
+ isImage,
338
+ liveKind,
339
+ hasParsedContent,
340
+ isParsedDocLoading
341
+ } = doc;
342
+ const session = useArbiSessionStore();
343
+ const {
344
+ tab: activeTab,
345
+ compareId,
346
+ tabRequest,
347
+ phonePdfChosen
348
+ } = useArbiSessionState((s) => s.documentViewer);
349
+ const setActiveTab = (tab) => session.setDocumentViewer({ tab });
350
+ const isTextFile = friendlyFileType(documentData?.file_type, documentData?.file_name) === "Text";
351
+ const isPhone = useIsPhone();
352
+ const phoneDefaultDecidedFor = useRef(null);
353
+ const hasDocumentData = !!documentData;
354
+ const documentKey = documentData?.external_id;
355
+ useEffect(() => {
356
+ if (isArtifact && (activeTab === "pdf" || !liveKind && activeTab === "docx")) {
357
+ setActiveTab(liveKind ? "preview" : "edit");
358
+ } else if (isDocx && activeTab === "pdf") {
359
+ setActiveTab("docx");
360
+ } else if (!liveKind && activeTab === "preview") {
361
+ setActiveTab(isArtifact ? "edit" : "pdf");
362
+ } else if (!isArtifact && documentData && activeTab === "edit") {
363
+ setActiveTab(isDocx ? "docx" : isXlsx ? "xlsx" : "pdf");
364
+ } else if (!isArtifact && !isDocx && !isXlsx && documentData && (activeTab === "docx" || activeTab === "xlsx")) {
365
+ setActiveTab("pdf");
366
+ }
367
+ }, [hasDocumentData, documentKey, isArtifact, isDocx, isXlsx, liveKind]);
368
+ useEffect(() => {
369
+ if (!tabRequest || !documentKey || tabRequest.documentId !== documentKey) return;
370
+ phoneDefaultDecidedFor.current = documentKey;
371
+ session.setDocumentViewer({ tabRequest: null, tab: tabRequest.tab });
372
+ }, [documentKey, tabRequest]);
373
+ const hasVersionsTab = isArtifact || isDocx || hasHistory;
374
+ useEffect(() => {
375
+ if (activeTab === "versions" && documentData && !hasVersionsTab) {
376
+ setActiveTab(isXlsx ? "xlsx" : "pdf");
377
+ }
378
+ }, [activeTab, documentData, hasVersionsTab]);
379
+ useEffect(() => {
380
+ if (activeTab === "html" && documentData !== void 0 && !isParsedDocLoading && !hasParsedContent && !compareId) {
381
+ setActiveTab(isArtifact ? "edit" : isDocx ? "docx" : isXlsx ? "xlsx" : "pdf");
382
+ }
383
+ }, [
384
+ activeTab,
385
+ documentData,
386
+ isParsedDocLoading,
387
+ hasParsedContent,
388
+ compareId,
389
+ isArtifact,
390
+ isDocx,
391
+ isXlsx
392
+ ]);
393
+ useEffect(() => {
394
+ if (!isPhone || !documentKey || isParsedDocLoading) return;
395
+ if (phoneDefaultDecidedFor.current === documentKey) return;
396
+ phoneDefaultDecidedFor.current = documentKey;
397
+ const opensOnPdf = !isArtifact && !isDocx && !isXlsx && !isVideo && !isAudio && !isImage && !isEmail;
398
+ if (opensOnPdf && hasParsedContent && !compareId && !phonePdfChosen && activeTab === "pdf") {
399
+ setActiveTab("html");
400
+ }
401
+ }, [isPhone, documentKey, isParsedDocLoading, hasParsedContent]);
402
+ const handleTabChange = (tabId) => {
403
+ const change = { tab: tabId };
404
+ if (tabId !== "html" && compareId) change.compareId = null;
405
+ if (isPhone && (tabId === "pdf" || tabId === "html")) change.phonePdfChosen = tabId === "pdf";
406
+ session.setDocumentViewer(change);
407
+ };
408
+ const mediaTab = isVideo ? { icon: /* @__PURE__ */ jsx(VidIcon, { size: 20 }), tooltip: "Video" } : isAudio ? { icon: /* @__PURE__ */ jsx(AudIcon, { size: 20 }), tooltip: "Audio" } : isImage ? { icon: /* @__PURE__ */ jsx(ImgIcon, { size: 20 }), tooltip: "Image" } : isEmail ? { icon: /* @__PURE__ */ jsx(EmlIcon, { size: 20 }), tooltip: "Email" } : isTextFile ? { icon: /* @__PURE__ */ jsx(FileText, { className: "size-5" }), tooltip: "Text" } : documentData ? { icon: /* @__PURE__ */ jsx(PdfIcon, { size: 20 }), tooltip: "PDF" } : (
409
+ // The file type is unknown until the record loads: name no guess (a text file
410
+ // would flip from PDF to Text once it arrives).
411
+ { icon: /* @__PURE__ */ jsx(FileText, { className: "size-5" }), tooltip: "Document" }
412
+ );
413
+ const tabLabel = (id, label) => !isCompact || activeTab === id || id === "html" ? label : void 0;
414
+ const versionsTab = {
415
+ id: "versions",
416
+ icon: /* @__PURE__ */ jsx(History, { className: "size-5" }),
417
+ tooltip: "Versions",
418
+ label: tabLabel("versions", "Versions")
419
+ };
420
+ const viewerTabs = [
421
+ ...isArtifact ? [
422
+ ...liveKind ? [
423
+ {
424
+ id: "preview",
425
+ icon: /* @__PURE__ */ jsx(MonitorPlay, { className: "size-5" }),
426
+ tooltip: "Preview",
427
+ label: tabLabel("preview", "Preview")
428
+ }
429
+ ] : [],
430
+ {
431
+ id: "edit",
432
+ icon: liveKind ? /* @__PURE__ */ jsx(Code, { className: "size-5" }) : /* @__PURE__ */ jsx(FileText, { className: "size-5" }),
433
+ tooltip: liveKind ? "Code" : "Editor",
434
+ label: tabLabel("edit", liveKind ? "Code" : "Document")
435
+ },
436
+ versionsTab
437
+ ] : [
438
+ ...isDocx ? [
439
+ {
440
+ id: "docx",
441
+ icon: /* @__PURE__ */ jsx(DocIcon, { size: 20 }),
442
+ tooltip: "DOCX (with track changes & comments)",
443
+ label: tabLabel("docx", "DOCX")
444
+ }
445
+ ] : [],
446
+ ...isXlsx ? [
447
+ {
448
+ id: "xlsx",
449
+ icon: /* @__PURE__ */ jsx(XlsIcon, { size: 20 }),
450
+ tooltip: "Spreadsheet",
451
+ label: tabLabel("xlsx", "Sheet")
452
+ }
453
+ ] : [],
454
+ { id: "pdf", ...mediaTab, label: tabLabel("pdf", mediaTab.tooltip) },
455
+ ...hasVersionsTab ? [versionsTab] : []
456
+ ],
457
+ ...(hasParsedContent || compareId) && !liveKind ? [
458
+ {
459
+ id: "html",
460
+ icon: compareId ? /* @__PURE__ */ jsx(FileText, { className: "size-5" }) : /* @__PURE__ */ jsx(HtmlIcon, { size: 20 }),
461
+ tooltip: compareId ? "Word redline" : "HTML",
462
+ label: tabLabel("html", compareId ? "Compare" : "HTML")
463
+ }
464
+ ] : []
465
+ ];
466
+ return { activeTab, handleTabChange, viewerTabs };
467
+ }
468
+ function useViewerVersions(docId) {
469
+ const plainId = docId ? parseVersionRef(docId).docId : "";
470
+ const { data: documents } = useConnectedDocuments();
471
+ const listed = useMemo(
472
+ () => plainId ? documents.find((d) => d.external_id === plainId) : void 0,
473
+ [documents, plainId]
474
+ );
475
+ const { data: history } = useDocumentVersionList(plainId, { enabled: !!plainId && !listed });
476
+ const versions = useMemo(
477
+ () => listed ? documentVersions(listed) : toArtifactVersions(plainId || null, history),
478
+ [listed, history, plainId]
479
+ );
480
+ const translations = useMemo(() => {
481
+ if (!plainId) return [];
482
+ return documents.flatMap((doc) => {
483
+ const link = doc.derived_from?.find(
484
+ (d) => d.role === "translation" && d.doc_ext_id === plainId
485
+ );
486
+ return link ? [
487
+ {
488
+ id: doc.external_id,
489
+ name: doc.doc_metadata?.title || doc.file_name || doc.external_id,
490
+ createdAt: doc.created_at,
491
+ sourceVersion: link.version ?? null,
492
+ final: !!doc.derived_from?.some((d) => d.role === "final")
493
+ }
494
+ ] : [];
495
+ }).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
496
+ }, [documents, plainId]);
497
+ return { versions, translations };
498
+ }
499
+ var AnnotatedPdfViewer = lazy(
500
+ () => import('../document-tools/viewer/index.js').then((m) => ({ default: m.AnnotatedPdfViewer }))
501
+ );
502
+ var SignaturePlacementViewer = lazy(
503
+ () => import('../document-tools/viewer/index.js').then((m) => ({ default: m.SignaturePlacementViewer }))
504
+ );
505
+ var SignatureRequestEditor = lazy(
506
+ () => import('../document-tools/viewer/index.js').then((m) => ({ default: m.SignatureRequestEditor }))
507
+ );
508
+ var GuidedSigningViewer = lazy(
509
+ () => import('../document-tools/viewer/index.js').then((m) => ({ default: m.GuidedSigningViewer }))
510
+ );
511
+ function SessionPdfViewer(props) {
512
+ const session = useArbiSessionStore();
513
+ const viewingId = useArbiSessionState((s) => s.viewingDocument?.id);
514
+ const { isDetached } = useDocumentViewerSupport();
515
+ const onPageChange = useCallback(
516
+ (page) => {
517
+ if (viewingId) session.setViewingDocument({ id: viewingId, page });
518
+ },
519
+ [session, viewingId]
520
+ );
521
+ return /* @__PURE__ */ jsx(PdfViewer, { ...props, onPageChange, disableFontFace: !!isDetached });
522
+ }
523
+ function ViewerPdfPane({
524
+ documentId,
525
+ doc,
526
+ pdfBlob,
527
+ isPdfLoading,
528
+ pdfError,
529
+ onDownload,
530
+ viewerProps,
531
+ signatureFlow,
532
+ onSignatureFlow,
533
+ currentUserId,
534
+ placingSignature,
535
+ onPlacingDone,
536
+ annotating,
537
+ markup,
538
+ pdfSnapshotNumber,
539
+ isSigned
540
+ }) {
541
+ const { documentData, isDownloadOnly, isVideo, isAudio, isImage, isDocx } = doc;
542
+ const showMarkup = markup.hasMarkup && !markup.showOriginal;
543
+ if (isDownloadOnly) {
544
+ return /* @__PURE__ */ jsx(
545
+ ViewerPreviewUnavailable,
546
+ {
547
+ extension: fileExtension(documentData?.file_name),
548
+ onDownload
549
+ }
550
+ );
551
+ }
552
+ const loadingLabel = isVideo ? "Loading video..." : isAudio ? "Loading audio..." : isImage ? "Loading image..." : !documentData ? "Loading document..." : friendlyFileType(documentData.file_type, documentData.file_name) === "Text" ? "Loading text..." : "Loading PDF...";
553
+ const errorLabel = isVideo ? "Failed to load video" : isAudio ? "Failed to load audio" : isImage ? "Failed to load image" : "Failed to load PDF";
554
+ if (isDocx && documentData && !["completed", "low-content", "failed"].includes(documentData.status || "")) {
555
+ return /* @__PURE__ */ jsx(ViewerMessage, { children: "PDF and search indexing are processing. Open the DOCX tab to edit now." });
556
+ }
557
+ if (isPdfLoading) return /* @__PURE__ */ jsx(ViewerMessage, { children: loadingLabel });
558
+ if (pdfError) {
559
+ return /* @__PURE__ */ jsx(
560
+ ViewerLoadError,
561
+ {
562
+ message: isVideo || isAudio || isImage ? `${errorLabel} \u2014 download it instead.` : "Couldn't display the PDF \u2014 download it instead.",
563
+ onDownload
564
+ }
565
+ );
566
+ }
567
+ if (!pdfBlob) return /* @__PURE__ */ jsx(ViewerMessage, { children: loadingLabel });
568
+ if (isVideo) return /* @__PURE__ */ jsx(VideoViewer, { blob: pdfBlob, title: documentData?.file_name || "Video" });
569
+ if (isAudio) return /* @__PURE__ */ jsx(AudioViewer, { blob: pdfBlob, title: documentData?.file_name || "Audio" });
570
+ if (isImage) {
571
+ return /* @__PURE__ */ jsx(ImageViewer, { blob: pdfBlob, alt: documentData?.file_name || "Document image" });
572
+ }
573
+ if (signatureFlow?.kind === "prepare") {
574
+ return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: "Loading\u2026" }), children: /* @__PURE__ */ jsx(
575
+ SignatureRequestEditor,
576
+ {
577
+ ...viewerProps,
578
+ file: pdfBlob,
579
+ documentId,
580
+ version: documentData?.current_version ?? void 0,
581
+ draft: signatureFlow.draft,
582
+ viewer: SessionPdfViewer,
583
+ onCancel: () => onSignatureFlow(null),
584
+ onSaved: () => onSignatureFlow(null)
585
+ }
586
+ ) });
587
+ }
588
+ if (signatureFlow?.kind === "sign" && currentUserId) {
589
+ const { currentPage: _page, scrollTrigger: _trigger, ...guidedProps } = viewerProps;
590
+ return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: "Loading\u2026" }), children: /* @__PURE__ */ jsx(
591
+ GuidedSigningViewer,
592
+ {
593
+ ...guidedProps,
594
+ file: pdfBlob,
595
+ request: signatureFlow.request,
596
+ signer: currentUserId,
597
+ viewer: SessionPdfViewer,
598
+ onClose: () => onSignatureFlow(null),
599
+ onSigned: () => onSignatureFlow(null)
600
+ }
601
+ ) });
602
+ }
603
+ if (placingSignature) {
604
+ return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: "Loading\u2026" }), children: /* @__PURE__ */ jsx(
605
+ SignaturePlacementViewer,
606
+ {
607
+ ...viewerProps,
608
+ file: pdfBlob,
609
+ documentId,
610
+ viewer: SessionPdfViewer,
611
+ onCancel: () => onPlacingDone(),
612
+ onContinue: (appearance) => onPlacingDone(appearance)
613
+ }
614
+ ) });
615
+ }
616
+ if (annotating || showMarkup) {
617
+ return /* @__PURE__ */ jsx(
618
+ Suspense,
619
+ {
620
+ fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: annotating ? "Loading annotation tools\u2026" : "Loading markup\u2026" }),
621
+ children: /* @__PURE__ */ jsx(
622
+ AnnotatedPdfViewer,
623
+ {
624
+ ...viewerProps,
625
+ file: pdfBlob,
626
+ documentId,
627
+ version: pdfSnapshotNumber,
628
+ editing: annotating,
629
+ onMarkupChange: markup.onMarkupChange,
630
+ fileName: documentData?.file_name,
631
+ shared: documentData?.shared ?? false,
632
+ folder: documentData?.folder,
633
+ viewer: SessionPdfViewer,
634
+ signed: isSigned
635
+ },
636
+ `${documentId}@${pdfSnapshotNumber ?? "current"}`
637
+ )
638
+ }
639
+ );
640
+ }
641
+ return /* @__PURE__ */ jsx(SessionPdfViewer, { ...viewerProps, file: pdfBlob });
642
+ }
643
+ var NativeDocxEditor = lazy(
644
+ () => import('../ConnectedNativeDocxEditor-IPEZDERL.js').then((m) => ({
645
+ default: m.ConnectedNativeDocxEditor
646
+ }))
647
+ );
648
+ var StreamedWordArtifact = lazy(
649
+ () => import('../ConnectedStreamedWordArtifact-UZVNBKQB.js').then((m) => ({
650
+ default: m.ConnectedStreamedWordArtifact
651
+ }))
652
+ );
653
+ var NativeDocxComparison = lazy(
654
+ () => import('../ConnectedNativeDocxComparison-XQSXVGHR.js').then((m) => ({
655
+ default: m.ConnectedNativeDocxComparison
656
+ }))
657
+ );
658
+ var UPLOADED_NO_VERSIONS = "No earlier versions yet. Replacing, editing or signing this file adds a new version here.";
659
+ function canChangeVisibility(doc, userId) {
660
+ if (!doc || !userId) return false;
661
+ return userId.startsWith("agt-") || (doc.created_by_ext_id?.startsWith("agt-") ?? false) || doc.created_by_ext_id === userId;
662
+ }
663
+ function ConnectedDocumentViewer(props) {
664
+ const viewing = useArbiSessionState((s) => s.viewingDocument?.id);
665
+ const openedId = props.documentId ?? viewing;
666
+ if (!openedId) return null;
667
+ return /* @__PURE__ */ jsx(ConnectedDocumentToolsProvider, { children: /* @__PURE__ */ jsx(DocumentViewerContent, { ...props, openedId }) });
668
+ }
669
+ function DocumentViewerContent({
670
+ openedId,
671
+ headerActions,
672
+ artifactRuntimeUrl = "/artifact-runtime/"
673
+ }) {
674
+ const arbi = useArbi();
675
+ const session = useArbiSessionStore();
676
+ const support = useDocumentViewerSupport();
677
+ const formatDate = support.formatDate ?? fmtDate;
678
+ const tools = useDocumentTools();
679
+ const { openConversation, notify } = useBlocksEnvironment();
680
+ const { userId: currentUserId } = useConnectedWorkspace();
681
+ const documentId = parseVersionRef(openedId).docId;
682
+ const [totalPages, setTotalPages] = useState(0);
683
+ const [isCompact, setIsCompact] = useState(false);
684
+ const [pdfZoom, setPdfZoom] = useState(1);
685
+ const {
686
+ tab: zoomTab,
687
+ textScale,
688
+ compareId: compareDocumentId
689
+ } = useArbiSessionState((s) => s.documentViewer);
690
+ const zoom = zoomTab === "html" ? textScale : pdfZoom;
691
+ const setZoom = useCallback(
692
+ (next) => {
693
+ const value = typeof next === "function" ? next(zoom) : next;
694
+ if (zoomTab === "html") session.setDocumentViewer({ textScale: value });
695
+ else setPdfZoom(value);
696
+ },
697
+ [zoomTab, session, zoom]
698
+ );
699
+ const [scrollTrigger, setScrollTrigger] = useState(0);
700
+ const containerRef = useRef(null);
701
+ const viewingDocumentPage = useArbiSessionState((s) => s.viewingDocument?.page ?? null);
702
+ const setViewingDocumentPage = (page) => session.setViewingDocument({ id: openedId, page });
703
+ const setViewingDocumentId = (id) => session.setViewingDocument({ id });
704
+ const setActiveTab = (tab) => session.setDocumentViewer({ tab });
705
+ const setCompareDocumentId = (id) => session.setDocumentViewer({ compareId: id });
706
+ const { data: conversations } = useConnectedConversations();
707
+ const snapshotRef = parseVersionRef(openedId).version ? openedId : null;
708
+ const { versions, translations } = useViewerVersions(documentId);
709
+ const currentVersionId = versions.find((v) => v.isCurrent)?.id ?? documentId;
710
+ const snapshotDocumentId = snapshotRef && snapshotRef !== currentVersionId ? snapshotRef : null;
711
+ const doc = useViewedDocument(documentId);
712
+ const setSnapshotDocumentId = (ref) => setViewingDocumentId(ref ?? documentId);
713
+ useRegisterOpenDocument({
714
+ documentId: doc.savedDocumentId,
715
+ shownId: openedId,
716
+ showLive: () => setViewingDocumentId(documentId),
717
+ workspaceId: doc.workspaceId
718
+ });
719
+ const {
720
+ documentData,
721
+ streamingDoc,
722
+ isStreaming,
723
+ draftDoc,
724
+ isDraft,
725
+ isCaptureDraft,
726
+ labelSummaries,
727
+ isImage,
728
+ isVideo,
729
+ isAudio,
730
+ isMedia,
731
+ isArtifact,
732
+ liveKind,
733
+ liveSource,
734
+ isDocx,
735
+ isXlsx,
736
+ isDownloadOnly
737
+ } = doc;
738
+ const threadTitle = (id) => conversations.find((c) => c.external_id === id)?.title?.trim() || "Its thread";
739
+ const madeInId = documentData?.conversation_ext_id ?? null;
740
+ const madeIn = madeInId ? { id: madeInId, title: threadTitle(madeInId) } : null;
741
+ const pdfSnapshotId = snapshotDocumentId && !isDocx && !isArtifact ? snapshotDocumentId : null;
742
+ const shownDocumentId = pdfSnapshotId || documentId;
743
+ const blobs = useViewerBlobs(shownDocumentId, doc);
744
+ const { pdfBlob, xlsxBlob, xlsxError, handleDirectDownload } = blobs;
745
+ const [annotating, setAnnotating] = useState(false);
746
+ useEffect(() => setAnnotating(false), [documentId]);
747
+ const hasHistory = versions.length > 1 || (documentData?.current_version ?? 1) > 1 || translations.length > 0;
748
+ const { activeTab, handleTabChange, viewerTabs } = useViewerTabs(doc, isCompact, hasHistory);
749
+ const crop = useImageCrop(documentId, documentData?.file_name, pdfBlob);
750
+ const [placingSignature, setPlacingSignature] = useState(false);
751
+ const [signAppearance, setSignAppearance] = useState();
752
+ const [isSignOpen, setIsSignOpen] = useState(false);
753
+ useEffect(() => setPlacingSignature(false), [documentId, snapshotDocumentId]);
754
+ const [signatureFlow, setSignatureFlow] = useState(null);
755
+ useEffect(() => setSignatureFlow(null), [documentId, snapshotDocumentId]);
756
+ const { data: signatureStatus } = useDocumentSignatures(shownDocumentId, !isDraft && !liveKind);
757
+ const isCoEditing = !snapshotDocumentId && !compareDocumentId && !isDraft && (activeTab === "docx" && isDocx || activeTab === "edit" && isArtifact && !liveKind && !isStreaming);
758
+ const currentVersionLabel = isCoEditing ? void 0 : !snapshotDocumentId && !compareDocumentId && (isDocx || isArtifact && !liveKind) ? "Live" : versionLabel(versions, snapshotDocumentId || documentId);
759
+ const compareVersionLabel = versionLabel(versions, compareDocumentId);
760
+ const snapshotNumber = findVersion(versions, snapshotDocumentId)?.number;
761
+ const pdfSnapshotNumber = pdfSnapshotId ? snapshotNumber : void 0;
762
+ const isSigned = !!signatureStatus?.signed;
763
+ const markup = useDocumentMarkup(documentData, pdfSnapshotNumber, isSigned);
764
+ useEffect(() => {
765
+ const container = containerRef.current;
766
+ if (!container) return;
767
+ const resizeObserver = new ResizeObserver((entries) => {
768
+ for (const entry of entries) setIsCompact(entry.contentRect.width < 640);
769
+ });
770
+ resizeObserver.observe(container);
771
+ return () => resizeObserver.disconnect();
772
+ }, []);
773
+ const handleLoadSuccess = useCallback((numPages) => setTotalPages(numPages), []);
774
+ const goToPage = (page) => {
775
+ setViewingDocumentPage(page);
776
+ setScrollTrigger((prev) => prev + 1);
777
+ };
778
+ const stepPage = (delta) => {
779
+ const next = (viewingDocumentPage || 1) + delta;
780
+ if (next >= 1 && next <= totalPages) goToPage(next);
781
+ };
782
+ const documentTitle = streamingDoc?.title || draftDoc?.title || documentData?.doc_metadata?.title || documentData?.file_name || "Document";
783
+ const pageNav = totalPages > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
784
+ /* @__PURE__ */ jsx(ViewerZoomControl, { zoom, onCycle: () => setZoom(cycleZoom(zoom)) }),
785
+ /* @__PURE__ */ jsx(
786
+ PdfPageNav,
787
+ {
788
+ canPrev: (viewingDocumentPage || 1) > 1,
789
+ canNext: (viewingDocumentPage || 1) < totalPages,
790
+ onPrev: () => stepPage(-1),
791
+ onNext: () => stepPage(1),
792
+ counter: /* @__PURE__ */ jsx(ViewerPageCounter, { page: viewingDocumentPage || 1, total: totalPages, onGoTo: goToPage })
793
+ }
794
+ )
795
+ ] });
796
+ const isComparing = !!compareDocumentId;
797
+ const compareTarget = compareDocumentId ? parseVersionRef(compareDocumentId).docId : null;
798
+ const compareIndicator = isComparing && compareTarget && /* @__PURE__ */ jsx(
799
+ ArtifactCompareBar,
800
+ {
801
+ compareTarget: support.renderDocumentPill?.(compareTarget) ?? compareTarget,
802
+ versionLabel: compareVersionLabel,
803
+ mode: "flip",
804
+ showTrackChanges: false,
805
+ onToggleTrackChanges: () => {
806
+ },
807
+ onFlip: () => {
808
+ setViewingDocumentId(compareDocumentId);
809
+ setCompareDocumentId(documentId);
810
+ },
811
+ onStop: () => setCompareDocumentId(null)
812
+ }
813
+ );
814
+ const titleBlock = /* @__PURE__ */ jsxs(Fragment, { children: [
815
+ isDraft ? support.renderDraftTitle?.(documentId) : /* @__PURE__ */ jsx(
816
+ ViewerTitle,
817
+ {
818
+ title: documentTitle,
819
+ versionLabel: currentVersionLabel,
820
+ shrink: !!liveKind || isCompact
821
+ }
822
+ ),
823
+ isCompact && !isDraft && documentData?.shared && /* @__PURE__ */ jsx(ViewerStatusNote, { testId: "document-shared-status", children: "Shared with the workspace" }),
824
+ isCompact && activeTab === "pdf" && pdfBlob && markup.hasMarkup && !annotating && !placingSignature && /* @__PURE__ */ jsx(
825
+ MarkupViewNote,
826
+ {
827
+ showOriginal: markup.showOriginal,
828
+ onToggle: () => markup.setShowOriginal((on) => !on)
829
+ }
830
+ ),
831
+ !isComparing && !liveKind && documentData && support.renderRelated?.(documentData),
832
+ isStreaming && /* @__PURE__ */ jsx(ViewerStatusNote, { pulse: true, children: "streaming..." }),
833
+ isDraft && /* @__PURE__ */ jsx(ViewerStatusNote, { testId: "draft-unsaved-indicator", children: "Draft \u2014 not saved" }),
834
+ signatureStatus?.signed && /* @__PURE__ */ jsx(SignatureStatus, { status: signatureStatus, formatDate })
835
+ ] });
836
+ const leftContent = /* @__PURE__ */ jsxs(ViewerHeaderStart, { children: [
837
+ isDraft ? (
838
+ // A draft's kind replaces the tabs: neither Versions nor the text view means anything
839
+ // before the first save.
840
+ support.renderDraftKind?.(documentId)
841
+ ) : /* @__PURE__ */ jsx(ViewerTabBar, { tabs: viewerTabs, activeId: activeTab, onChange: handleTabChange }),
842
+ !isCompact && titleBlock
843
+ ] });
844
+ const annotatable = canAnnotate({
845
+ activeTab,
846
+ hasPdf: !!pdfBlob,
847
+ isImage,
848
+ isVideo,
849
+ isAudio,
850
+ isDownloadOnly,
851
+ isDraft,
852
+ isStreaming,
853
+ isSnapshot: !!snapshotDocumentId,
854
+ isComparing
855
+ });
856
+ const signatureBanner = !isDraft && !liveKind && !snapshotDocumentId && /* @__PURE__ */ jsx(
857
+ SignatureRequestBanner,
858
+ {
859
+ documentId,
860
+ hidden: !!signatureFlow,
861
+ onSign: (request) => {
862
+ setAnnotating(false);
863
+ setPlacingSignature(false);
864
+ if (activeTab !== "pdf") handleTabChange("pdf");
865
+ setSignatureFlow({ kind: "sign", request });
866
+ },
867
+ onEditDraft: (draft) => {
868
+ if (activeTab !== "pdf") handleTabChange("pdf");
869
+ setSignatureFlow({ kind: "prepare", draft });
870
+ }
871
+ }
872
+ );
873
+ const share = () => {
874
+ const name = (liveKind ? documentTitle : documentData?.file_name) || void 0;
875
+ if (support.share) {
876
+ support.share({ id: documentId, name, isPrivate: !documentData?.shared });
877
+ return;
878
+ }
879
+ void arbi.documents.update([{ external_id: documentId, shared: !documentData?.shared }]).then(() => tools.onDocumentsChanged?.([documentId], "markup")).catch(() => notify("Couldn't change who can see this document", "error"));
880
+ };
881
+ const shownRef = snapshotDocumentId || documentId;
882
+ const rightContent = /* @__PURE__ */ jsxs(ViewerHeaderEnd, { isCompact, children: [
883
+ annotatable && /* @__PURE__ */ jsx(
884
+ AnnotateButton,
885
+ {
886
+ active: annotating,
887
+ compact: isCompact,
888
+ onClick: () => {
889
+ setPlacingSignature(false);
890
+ markup.setShowOriginal(false);
891
+ setAnnotating((on) => !on);
892
+ }
893
+ }
894
+ ),
895
+ activeTab === "pdf" && pdfBlob && !placingSignature && (markup.hasMarkup || annotating) && /* @__PURE__ */ jsx(
896
+ ShowOriginalButton,
897
+ {
898
+ active: markup.showOriginal,
899
+ compact: isCompact,
900
+ onClick: () => {
901
+ setAnnotating(false);
902
+ markup.setShowOriginal((on) => !on);
903
+ }
904
+ }
905
+ ),
906
+ activeTab === "pdf" && markup.hasMarkup && !annotating && /* @__PURE__ */ jsx(
907
+ DownloadMarkupButton,
908
+ {
909
+ onClick: () => void markup.downloadMarkup(),
910
+ disabledReason: isSigned ? SIGNED_LOCKED_REASON : void 0
911
+ }
912
+ ),
913
+ activeTab === "pdf" && isImage && pdfBlob && /* @__PURE__ */ jsx(
914
+ ViewerImageActions,
915
+ {
916
+ compact: isCompact,
917
+ onUseAsReference: support.useImageAsReference ? () => support.useImageAsReference(documentId) : void 0,
918
+ onCrop: crop.handleOpenCrop
919
+ }
920
+ ),
921
+ madeIn && /* @__PURE__ */ jsxs(
922
+ Button,
923
+ {
924
+ type: "button",
925
+ variant: "outline",
926
+ size: isCompact ? "icon" : "sm",
927
+ onClick: () => openConversation(madeIn.id, {
928
+ messageId: documentData?.source_message_ext_id ?? void 0
929
+ }),
930
+ title: `Open the thread it was made in: ${madeIn.title}`,
931
+ "aria-label": `Open the thread it was made in: ${madeIn.title}`,
932
+ "data-testid": "document-open-thread",
933
+ children: [
934
+ /* @__PURE__ */ jsx(MessageSquare, { className: "size-4" }),
935
+ !isCompact && /* @__PURE__ */ jsx("span", { className: "max-w-[10rem] truncate", children: madeIn.title })
936
+ ]
937
+ }
938
+ ),
939
+ documentId && doc.workspaceId && /* @__PURE__ */ jsx(
940
+ ShareControl,
941
+ {
942
+ state: documentData?.shared ? "shared" : "private",
943
+ onToggle: share,
944
+ disabled: !canChangeVisibility(documentData, currentUserId),
945
+ disabledTooltip: "Only the owner can change visibility",
946
+ tooltip: documentData?.shared ? "Shared with the workspace \u2014 click to share with specific people" : "Share with the workspace, then optionally notify specific people by email",
947
+ variant: "outline",
948
+ compact: isCompact,
949
+ showState: !isCompact,
950
+ labels: {
951
+ shared: getEntityLabel("WORKSPACE"),
952
+ private: "Only you",
953
+ mixed: "Partly shared"
954
+ },
955
+ testId: "share-document-button",
956
+ stateTestId: "document-title-shared-indicator"
957
+ }
958
+ ),
959
+ tools.emailDocument && !isDraft && !isStreaming && documentData?.file_name && /* @__PURE__ */ jsxs(Fragment, { children: [
960
+ /* @__PURE__ */ jsx("span", { className: "mx-1 h-5 w-px bg-border", "aria-hidden": "true" }),
961
+ /* @__PURE__ */ jsxs(
962
+ Button,
963
+ {
964
+ type: "button",
965
+ variant: "outline",
966
+ size: isCompact ? "icon" : "sm",
967
+ title: "Email this document",
968
+ "aria-label": "Email",
969
+ "data-testid": "email-document-button",
970
+ className: "pointer-coarse:min-h-11",
971
+ onClick: () => tools.emailDocument?.(shownRef),
972
+ children: [
973
+ /* @__PURE__ */ jsx(Mail, { className: "size-4" }),
974
+ !isCompact && /* @__PURE__ */ jsx("span", { className: "ml-1", children: "Email" })
975
+ ]
976
+ }
977
+ )
978
+ ] }),
979
+ support.translate && !isDraft && !isStreaming && !liveKind && !isImage && documentData?.file_name && /* @__PURE__ */ jsxs(
980
+ Button,
981
+ {
982
+ type: "button",
983
+ variant: "outline",
984
+ size: isCompact ? "icon" : "sm",
985
+ title: "Translate into another language: a new editable document, original and translation side by side",
986
+ "aria-label": "Translate",
987
+ "data-testid": "translate-document-button",
988
+ className: "pointer-coarse:min-h-11",
989
+ onClick: () => support.translate(shownRef),
990
+ children: [
991
+ /* @__PURE__ */ jsx(Languages, { className: "size-4" }),
992
+ !isCompact && /* @__PURE__ */ jsx("span", { className: "ml-1", children: "Translate" })
993
+ ]
994
+ }
995
+ ),
996
+ !isStreaming && !snapshotDocumentId && /* @__PURE__ */ jsx(FinaliseTranslationButton, { document: documentData ?? void 0, isCompact }),
997
+ annotatable && /* @__PURE__ */ jsx(
998
+ SignButton,
999
+ {
1000
+ active: placingSignature,
1001
+ compact: isCompact,
1002
+ onClick: () => {
1003
+ setAnnotating(false);
1004
+ setSignatureFlow(null);
1005
+ setPlacingSignature((on) => !on);
1006
+ }
1007
+ }
1008
+ ),
1009
+ annotatable && !isSigned && /* @__PURE__ */ jsx(
1010
+ RequestSignaturesButton,
1011
+ {
1012
+ active: signatureFlow?.kind === "prepare",
1013
+ compact: isCompact,
1014
+ onClick: () => {
1015
+ setAnnotating(false);
1016
+ setPlacingSignature(false);
1017
+ setSignatureFlow(signatureFlow?.kind === "prepare" ? null : { kind: "prepare" });
1018
+ }
1019
+ }
1020
+ ),
1021
+ isSignOpen && pdfBlob && /* @__PURE__ */ jsx(
1022
+ SignDocumentDialog,
1023
+ {
1024
+ open: isSignOpen,
1025
+ onOpenChange: setIsSignOpen,
1026
+ documentId,
1027
+ pdfBlob,
1028
+ version: documentData?.current_version ?? void 0,
1029
+ appearance: signAppearance
1030
+ }
1031
+ ),
1032
+ headerActions
1033
+ ] });
1034
+ const viewerProps = {
1035
+ currentPage: viewingDocumentPage || void 0,
1036
+ onLoadSuccess: handleLoadSuccess,
1037
+ scrollTrigger,
1038
+ zoom,
1039
+ onZoomChange: setZoom
1040
+ };
1041
+ return /* @__PURE__ */ jsxs(
1042
+ ViewerFrame,
1043
+ {
1044
+ frameRef: containerRef,
1045
+ contentId: documentId,
1046
+ header: /* @__PURE__ */ jsxs(Fragment, { children: [
1047
+ /* @__PURE__ */ jsx(
1048
+ TabHeader,
1049
+ {
1050
+ tabs: [],
1051
+ activeTabId: activeTab,
1052
+ onTabChange: handleTabChange,
1053
+ leftContent,
1054
+ rightContent,
1055
+ variant: "underline"
1056
+ }
1057
+ ),
1058
+ isCompact && !isCoEditing && /* @__PURE__ */ jsx("div", { "data-slot": "viewer-title-row", className: "flex min-w-0 items-center gap-2 px-3 pb-2", children: titleBlock }),
1059
+ snapshotDocumentId && /* @__PURE__ */ jsx(
1060
+ VersionSnapshotBar,
1061
+ {
1062
+ versionNumber: snapshotNumber,
1063
+ live: isDocx || isArtifact,
1064
+ onAsk: support.askAboutVersion ? () => support.askAboutVersion(snapshotDocumentId) : void 0,
1065
+ onReturn: () => setSnapshotDocumentId(null)
1066
+ }
1067
+ )
1068
+ ] }),
1069
+ compareRow: isComparing ? compareIndicator || void 0 : void 0,
1070
+ footer: (
1071
+ // Crop to a new document. Full resolution (no maxSize): a crop frames, it never downscales.
1072
+ /* @__PURE__ */ jsx(
1073
+ ImageCropModal,
1074
+ {
1075
+ open: crop.cropImageUrl !== null,
1076
+ image: crop.cropImageUrl,
1077
+ title: "Crop image",
1078
+ saveLabel: "Save as a copy",
1079
+ aspectOptions: DEFAULT_ASPECT_OPTIONS,
1080
+ output: { mimeType: "image/png" },
1081
+ onComplete: crop.handleCropComplete,
1082
+ onCancel: crop.closeCrop
1083
+ }
1084
+ )
1085
+ ),
1086
+ children: [
1087
+ isComparing && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: "Loading comparison\u2026" }), children: /* @__PURE__ */ jsx(
1088
+ NativeDocxComparison,
1089
+ {
1090
+ baseId: compareDocumentId,
1091
+ revisedId: documentId,
1092
+ title: documentTitle
1093
+ }
1094
+ ) }),
1095
+ isCaptureDraft && support.renderCaptureDraft?.(documentId),
1096
+ !isCaptureDraft && (activeTab === "pdf" || isMedia && activeTab === "html") && !isArtifact && !isComparing && /* @__PURE__ */ jsxs(ViewerPane, { hidden: activeTab !== "pdf", children: [
1097
+ /* @__PURE__ */ jsx(DocumentLabelBar, { summaries: labelSummaries }),
1098
+ !isMedia && !isImage && signatureBanner,
1099
+ activeTab === "pdf" && !isMedia && !isImage && /* @__PURE__ */ jsx(
1100
+ MarkupNotices,
1101
+ {
1102
+ legacyPrompt: markup.legacyPrompt,
1103
+ olderNote: markup.olderNote,
1104
+ onOpenVersion: (n) => setSnapshotDocumentId(`${documentId}@v${n}`)
1105
+ }
1106
+ ),
1107
+ /* @__PURE__ */ jsx(ViewerControlBar, { controls: activeTab === "pdf" && pageNav, children: /* @__PURE__ */ jsx(
1108
+ ViewerPdfPane,
1109
+ {
1110
+ documentId,
1111
+ doc,
1112
+ pdfBlob,
1113
+ isPdfLoading: blobs.isPdfLoading,
1114
+ pdfError: blobs.pdfError,
1115
+ onDownload: () => void handleDirectDownload(),
1116
+ viewerProps,
1117
+ signatureFlow,
1118
+ onSignatureFlow: setSignatureFlow,
1119
+ currentUserId,
1120
+ placingSignature,
1121
+ onPlacingDone: (appearance) => {
1122
+ setPlacingSignature(false);
1123
+ if (!appearance) return;
1124
+ setSignAppearance(appearance);
1125
+ setIsSignOpen(true);
1126
+ },
1127
+ annotating,
1128
+ markup,
1129
+ pdfSnapshotNumber,
1130
+ isSigned
1131
+ }
1132
+ ) })
1133
+ ] }),
1134
+ activeTab === "preview" && isArtifact && liveKind && // The preview loads its JSX compiler on first use, so it stays out of the main bundle.
1135
+ /* @__PURE__ */ jsx(
1136
+ ArtifactPreview,
1137
+ {
1138
+ kind: liveKind,
1139
+ source: liveSource,
1140
+ isStreaming,
1141
+ runtimeUrl: artifactRuntimeUrl
1142
+ }
1143
+ ),
1144
+ activeTab === "edit" && isArtifact && liveKind && /* @__PURE__ */ jsx(ArtifactCodeView, { source: liveSource, fileName: documentData?.file_name ?? void 0 }),
1145
+ activeTab === "edit" && isArtifact && !liveKind && !isStreaming && !isComparing && /* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: "Loading editor\u2026" }), children: [
1146
+ isSigned && !snapshotDocumentId && /* @__PURE__ */ jsx(SignedEditNote, {}),
1147
+ /* @__PURE__ */ jsx(
1148
+ NativeDocxEditor,
1149
+ {
1150
+ documentId: snapshotDocumentId || documentId,
1151
+ title: documentTitle,
1152
+ draftContent: isDraft ? draftDoc?.content || "" : void 0,
1153
+ snapshot: !!snapshotDocumentId,
1154
+ onSaved: (id) => {
1155
+ if (!isDraft) return;
1156
+ support.onDraftSaved?.(documentId, id);
1157
+ setViewingDocumentId(id);
1158
+ }
1159
+ },
1160
+ `${snapshotDocumentId || documentId}-${snapshotDocumentId ? "snapshot" : "live"}`
1161
+ )
1162
+ ] }),
1163
+ activeTab === "versions" && (isArtifact || isDocx || hasHistory) && !isComparing && /* @__PURE__ */ jsx(
1164
+ VersionTimeline,
1165
+ {
1166
+ versions: versions.map((v) => ({
1167
+ ...v,
1168
+ madeIn: v.thread ? {
1169
+ label: threadTitle(v.thread.conversationId),
1170
+ onOpen: () => openConversation(v.thread.conversationId, {
1171
+ messageId: v.thread.messageId ?? void 0
1172
+ })
1173
+ } : null
1174
+ })),
1175
+ currentId: currentVersionId,
1176
+ live: !!liveKind,
1177
+ labels: isArtifact ? void 0 : { emptyDocument: UPLOADED_NO_VERSIONS },
1178
+ formatDate,
1179
+ onOpen: (id) => {
1180
+ setSnapshotDocumentId(id === currentVersionId ? null : id);
1181
+ setActiveTab(isArtifact ? "edit" : isDocx ? "docx" : "pdf");
1182
+ },
1183
+ onCompare: (id) => session.setDocumentViewer({ compareId: id, tab: "html" }),
1184
+ translations,
1185
+ onOpenTranslation: (id) => setViewingDocumentId(id)
1186
+ }
1187
+ ),
1188
+ activeTab === "xlsx" && isXlsx && (xlsxBlob ? /* @__PURE__ */ jsx(XlsxViewer, { blob: xlsxBlob }) : /* @__PURE__ */ jsx(ViewerMessage, { children: xlsxError ? "Failed to load spreadsheet" : "Loading spreadsheet..." })),
1189
+ activeTab === "docx" && isDocx && !isComparing && /* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: "Loading editor\u2026" }), children: [
1190
+ signatureBanner,
1191
+ isSigned && !snapshotDocumentId && /* @__PURE__ */ jsx(SignedEditNote, {}),
1192
+ /* @__PURE__ */ jsx(
1193
+ NativeDocxEditor,
1194
+ {
1195
+ documentId: snapshotDocumentId || documentId,
1196
+ title: documentTitle,
1197
+ snapshot: !!snapshotDocumentId
1198
+ },
1199
+ `${snapshotDocumentId || documentId}-${snapshotDocumentId ? "snapshot" : "live"}`
1200
+ )
1201
+ ] }),
1202
+ streamingDoc && isStreaming && isArtifact && !liveKind && !isComparing && (activeTab === "html" || activeTab === "edit") && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: "Opening draft\u2026" }), children: /* @__PURE__ */ jsx(
1203
+ StreamedWordArtifact,
1204
+ {
1205
+ documentId: documentId.startsWith("doc-") ? documentId : void 0,
1206
+ title: documentTitle,
1207
+ content: streamingDoc.content,
1208
+ busy: isStreaming
1209
+ },
1210
+ documentId
1211
+ ) }),
1212
+ !isCaptureDraft && !isComparing && activeTab === "html" && !(isStreaming && isArtifact && !liveKind) && support.renderParsedView && /* @__PURE__ */ jsx(ViewerPane, { children: /* @__PURE__ */ jsx(ViewerControlBar, { controls: pageNav, children: support.renderParsedView({
1213
+ documentId: pdfSnapshotId || documentId,
1214
+ onLoadSuccess: handleLoadSuccess,
1215
+ scrollTrigger,
1216
+ zoom,
1217
+ onZoomChange: setZoom
1218
+ }) }) })
1219
+ ]
1220
+ }
1221
+ );
1222
+ }
1223
+
1224
+ export { ConnectedDocumentToolsProvider, ConnectedDocumentViewer };
1225
+ //# sourceMappingURL=viewer.js.map
1226
+ //# sourceMappingURL=viewer.js.map