@arbidocs/blocks 0.5.115 → 0.5.117

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 (147) hide show
  1. package/dist/{ConnectedCallDock-WER7R222.cjs → ConnectedCallDock-OZBTU3IT.cjs} +20 -20
  2. package/dist/{ConnectedCallDock-WER7R222.cjs.map → ConnectedCallDock-OZBTU3IT.cjs.map} +1 -1
  3. package/dist/{ConnectedCallRoom-T7OBQTYP.cjs → ConnectedCallRoom-VMZE2NFP.cjs} +13 -13
  4. package/dist/{ConnectedCallRoom-T7OBQTYP.cjs.map → ConnectedCallRoom-VMZE2NFP.cjs.map} +1 -1
  5. package/dist/{ConnectedNativeDocxComparison-YXMYJWXY.cjs → ConnectedNativeDocxComparison-7OUKTKYP.cjs} +20 -20
  6. package/dist/{ConnectedNativeDocxComparison-YXMYJWXY.cjs.map → ConnectedNativeDocxComparison-7OUKTKYP.cjs.map} +1 -1
  7. package/dist/{ConnectedProductionSetDialog-LHB4VQWC.cjs → ConnectedProductionSetDialog-4EAY6KAZ.cjs} +3 -3
  8. package/dist/{ConnectedProductionSetDialog-LHB4VQWC.cjs.map → ConnectedProductionSetDialog-4EAY6KAZ.cjs.map} +1 -1
  9. package/dist/{ConnectedStreamedWordArtifact-2RTCHVPI.cjs → ConnectedStreamedWordArtifact-7V24ZDAC.cjs} +20 -20
  10. package/dist/{ConnectedStreamedWordArtifact-2RTCHVPI.cjs.map → ConnectedStreamedWordArtifact-7V24ZDAC.cjs.map} +1 -1
  11. package/dist/{DocumentReviewCard-ZSBZBGFK.cjs → DocumentReviewCard-OCPFVMLD.cjs} +15 -15
  12. package/dist/{DocumentReviewCard-ZSBZBGFK.cjs.map → DocumentReviewCard-OCPFVMLD.cjs.map} +1 -1
  13. package/dist/{FilesViewerDialog-I5QIHQZT.cjs → FilesViewerDialog-KLRDIYEH.cjs} +45 -45
  14. package/dist/{FilesViewerDialog-I5QIHQZT.cjs.map → FilesViewerDialog-KLRDIYEH.cjs.map} +1 -1
  15. package/dist/{NativeDocxEditor-H6TAEVGY.cjs → NativeDocxEditor-2LQY2CTV.cjs} +6 -6
  16. package/dist/{NativeDocxEditor-H6TAEVGY.cjs.map → NativeDocxEditor-2LQY2CTV.cjs.map} +1 -1
  17. package/dist/{WorkspaceTableView-J3C6VH4T.cjs → WorkspaceTableView-IMAZICIZ.cjs} +8 -8
  18. package/dist/{WorkspaceTableView-J3C6VH4T.cjs.map → WorkspaceTableView-IMAZICIZ.cjs.map} +1 -1
  19. package/dist/agents/index.cjs +297 -297
  20. package/dist/{ai-IM4A23YT.cjs → ai-7U4B4CVF.cjs} +24 -24
  21. package/dist/ai-7U4B4CVF.cjs.map +1 -0
  22. package/dist/calls/index.cjs +121 -121
  23. package/dist/chat/index.cjs +1 -1
  24. package/dist/{chunk-M6IKVKU5.cjs → chunk-2CSLFAGF.cjs} +392 -149
  25. package/dist/chunk-2CSLFAGF.cjs.map +1 -0
  26. package/dist/{chunk-SGYSDABK.cjs → chunk-2W5E62EY.cjs} +6 -6
  27. package/dist/{chunk-SGYSDABK.cjs.map → chunk-2W5E62EY.cjs.map} +1 -1
  28. package/dist/{chunk-P77YTTJ3.cjs → chunk-3ODEWSRO.cjs} +4 -4
  29. package/dist/{chunk-P77YTTJ3.cjs.map → chunk-3ODEWSRO.cjs.map} +1 -1
  30. package/dist/{chunk-DDIW4HLU.cjs → chunk-3U36VYMD.cjs} +27 -27
  31. package/dist/{chunk-DDIW4HLU.cjs.map → chunk-3U36VYMD.cjs.map} +1 -1
  32. package/dist/{chunk-TP5PGWIO.cjs → chunk-4IOYQLKG.cjs} +3 -3
  33. package/dist/{chunk-TP5PGWIO.cjs.map → chunk-4IOYQLKG.cjs.map} +1 -1
  34. package/dist/{chunk-NY3YUCOW.cjs → chunk-4NPCDS2X.cjs} +3 -3
  35. package/dist/{chunk-NY3YUCOW.cjs.map → chunk-4NPCDS2X.cjs.map} +1 -1
  36. package/dist/{chunk-BQ5RIWWT.cjs → chunk-4VZZWYEC.cjs} +3 -3
  37. package/dist/{chunk-BQ5RIWWT.cjs.map → chunk-4VZZWYEC.cjs.map} +1 -1
  38. package/dist/{chunk-Y24V6HPR.cjs → chunk-57EE6CMW.cjs} +15 -15
  39. package/dist/{chunk-Y24V6HPR.cjs.map → chunk-57EE6CMW.cjs.map} +1 -1
  40. package/dist/{chunk-NNUK5ZM7.cjs → chunk-5QUL5BZO.cjs} +4 -4
  41. package/dist/{chunk-NNUK5ZM7.cjs.map → chunk-5QUL5BZO.cjs.map} +1 -1
  42. package/dist/{chunk-OEREKAAP.cjs → chunk-6DCIZA3X.cjs} +75 -75
  43. package/dist/{chunk-OEREKAAP.cjs.map → chunk-6DCIZA3X.cjs.map} +1 -1
  44. package/dist/{chunk-YGXOKB5Z.cjs → chunk-7TEUGFIL.cjs} +4 -4
  45. package/dist/{chunk-YGXOKB5Z.cjs.map → chunk-7TEUGFIL.cjs.map} +1 -1
  46. package/dist/{chunk-TT4IF52H.cjs → chunk-7X3FS5HQ.cjs} +35 -35
  47. package/dist/{chunk-TT4IF52H.cjs.map → chunk-7X3FS5HQ.cjs.map} +1 -1
  48. package/dist/{chunk-CPR6EHG7.cjs → chunk-7XT5B2DZ.cjs} +47 -47
  49. package/dist/{chunk-CPR6EHG7.cjs.map → chunk-7XT5B2DZ.cjs.map} +1 -1
  50. package/dist/chunk-BKY2LAV2.cjs +18 -0
  51. package/dist/{chunk-CIHERNDO.cjs.map → chunk-BKY2LAV2.cjs.map} +1 -1
  52. package/dist/{chunk-XKVPSOKP.cjs → chunk-BW5MF464.cjs} +4 -4
  53. package/dist/{chunk-XKVPSOKP.cjs.map → chunk-BW5MF464.cjs.map} +1 -1
  54. package/dist/{chunk-IW7CDJTA.cjs → chunk-COD5ENHK.cjs} +4 -4
  55. package/dist/{chunk-IW7CDJTA.cjs.map → chunk-COD5ENHK.cjs.map} +1 -1
  56. package/dist/{chunk-A3T3IC3K.cjs → chunk-D7ICHGWM.cjs} +239 -85
  57. package/dist/chunk-D7ICHGWM.cjs.map +1 -0
  58. package/dist/{chunk-TDO5UWXF.cjs → chunk-E4BLRF2L.cjs} +5 -5
  59. package/dist/{chunk-TDO5UWXF.cjs.map → chunk-E4BLRF2L.cjs.map} +1 -1
  60. package/dist/{chunk-WR2SF44W.cjs → chunk-E4DUXU5K.cjs} +9 -9
  61. package/dist/{chunk-WR2SF44W.cjs.map → chunk-E4DUXU5K.cjs.map} +1 -1
  62. package/dist/{chunk-WAV762GP.cjs → chunk-GQXPNIRE.cjs} +6 -6
  63. package/dist/{chunk-WAV762GP.cjs.map → chunk-GQXPNIRE.cjs.map} +1 -1
  64. package/dist/{chunk-7OPOPYV6.cjs → chunk-H5OLHP2U.cjs} +3 -3
  65. package/dist/{chunk-7OPOPYV6.cjs.map → chunk-H5OLHP2U.cjs.map} +1 -1
  66. package/dist/{chunk-6UTKM5AB.cjs → chunk-JSQQV23D.cjs} +3 -3
  67. package/dist/{chunk-6UTKM5AB.cjs.map → chunk-JSQQV23D.cjs.map} +1 -1
  68. package/dist/{chunk-557MJ4IH.cjs → chunk-LFRNBT2I.cjs} +20 -20
  69. package/dist/{chunk-557MJ4IH.cjs.map → chunk-LFRNBT2I.cjs.map} +1 -1
  70. package/dist/{chunk-R7CJEIA5.cjs → chunk-LYTIQQQ2.cjs} +3 -3
  71. package/dist/{chunk-R7CJEIA5.cjs.map → chunk-LYTIQQQ2.cjs.map} +1 -1
  72. package/dist/{chunk-CPG7II4E.cjs → chunk-MC4F2URI.cjs} +28 -28
  73. package/dist/{chunk-CPG7II4E.cjs.map → chunk-MC4F2URI.cjs.map} +1 -1
  74. package/dist/{chunk-WXUU3COI.cjs → chunk-MZ2KZXNU.cjs} +3 -3
  75. package/dist/{chunk-WXUU3COI.cjs.map → chunk-MZ2KZXNU.cjs.map} +1 -1
  76. package/dist/{chunk-ZTXQIIFV.cjs → chunk-OZVDOAXG.cjs} +6 -6
  77. package/dist/{chunk-ZTXQIIFV.cjs.map → chunk-OZVDOAXG.cjs.map} +1 -1
  78. package/dist/{chunk-325GVZE6.cjs → chunk-Q6DQGGP4.cjs} +3 -3
  79. package/dist/{chunk-325GVZE6.cjs.map → chunk-Q6DQGGP4.cjs.map} +1 -1
  80. package/dist/{chunk-KTQOGT2L.cjs → chunk-TDN33HSK.cjs} +6 -6
  81. package/dist/{chunk-KTQOGT2L.cjs.map → chunk-TDN33HSK.cjs.map} +1 -1
  82. package/dist/{chunk-T23UTIRI.cjs → chunk-UNDQYTRF.cjs} +6 -6
  83. package/dist/{chunk-T23UTIRI.cjs.map → chunk-UNDQYTRF.cjs.map} +1 -1
  84. package/dist/{chunk-KXIRVKCJ.cjs → chunk-UUENH4BJ.cjs} +3 -3
  85. package/dist/{chunk-KXIRVKCJ.cjs.map → chunk-UUENH4BJ.cjs.map} +1 -1
  86. package/dist/{chunk-24EDG4PC.cjs → chunk-VBL3SHWX.cjs} +50 -50
  87. package/dist/{chunk-24EDG4PC.cjs.map → chunk-VBL3SHWX.cjs.map} +1 -1
  88. package/dist/{chunk-3A7QWUAW.cjs → chunk-VKH3BEZE.cjs} +3 -3
  89. package/dist/{chunk-3A7QWUAW.cjs.map → chunk-VKH3BEZE.cjs.map} +1 -1
  90. package/dist/{chunk-X5LANJDZ.cjs → chunk-VTYJAZDU.cjs} +23 -15
  91. package/dist/chunk-VTYJAZDU.cjs.map +1 -0
  92. package/dist/{chunk-B3LZITVF.cjs → chunk-WW6LXQY6.cjs} +12 -12
  93. package/dist/{chunk-B3LZITVF.cjs.map → chunk-WW6LXQY6.cjs.map} +1 -1
  94. package/dist/{chunk-NJCK6V6U.cjs → chunk-XKDUPU7B.cjs} +4 -4
  95. package/dist/{chunk-NJCK6V6U.cjs.map → chunk-XKDUPU7B.cjs.map} +1 -1
  96. package/dist/{chunk-42TURFHF.cjs → chunk-YGBHY67W.cjs} +5 -5
  97. package/dist/{chunk-42TURFHF.cjs.map → chunk-YGBHY67W.cjs.map} +1 -1
  98. package/dist/connect/docx.cjs +24 -24
  99. package/dist/connect/index.cjs +983 -983
  100. package/dist/connect/viewer.cjs +34 -34
  101. package/dist/connection/docx/ConnectedNativeDocxEditor.js +10 -2
  102. package/dist/connection/docx/ConnectedNativeDocxEditor.js.map +2 -2
  103. package/dist/connection/viewer/ConnectedDocumentViewer.js +124 -21
  104. package/dist/connection/viewer/ConnectedDocumentViewer.js.map +2 -2
  105. package/dist/connection/viewer/VersionDropdown.d.ts +9 -0
  106. package/dist/connection/viewer/VersionDropdown.js +39 -0
  107. package/dist/connection/viewer/VersionDropdown.js.map +7 -0
  108. package/dist/connection/viewer/ViewerPdfPane.js +4 -1
  109. package/dist/connection/viewer/ViewerPdfPane.js.map +2 -2
  110. package/dist/connection/viewer/useViewerBlobs.d.ts +3 -1
  111. package/dist/connection/viewer/useViewerBlobs.js +14 -8
  112. package/dist/connection/viewer/useViewerBlobs.js.map +2 -2
  113. package/dist/connection/viewer/useViewerTabs.js +10 -0
  114. package/dist/connection/viewer/useViewerTabs.js.map +2 -2
  115. package/dist/dashboards/index.cjs +1 -1
  116. package/dist/docx/DocxCommandMenu.d.ts +8 -0
  117. package/dist/docx/DocxCommandMenu.js +202 -0
  118. package/dist/docx/DocxCommandMenu.js.map +7 -0
  119. package/dist/docx/NativeDocxEditor.d.ts +4 -2
  120. package/dist/docx/NativeDocxEditor.js +51 -12
  121. package/dist/docx/NativeDocxEditor.js.map +2 -2
  122. package/dist/docx/RibbonMenu.d.ts +3 -1
  123. package/dist/docx/RibbonMenu.js +10 -3
  124. package/dist/docx/RibbonMenu.js.map +2 -2
  125. package/dist/docx/RibbonOverflow.d.ts +3 -0
  126. package/dist/docx/RibbonOverflow.js +24 -1
  127. package/dist/docx/RibbonOverflow.js.map +2 -2
  128. package/dist/docx/index.cjs +38 -38
  129. package/dist/docx/signatures/SignatureFields.d.ts +3 -1
  130. package/dist/docx/signatures/SignatureFields.js +17 -8
  131. package/dist/docx/signatures/SignatureFields.js.map +2 -2
  132. package/dist/embed/index.cjs +38 -38
  133. package/dist/files/index.cjs +224 -224
  134. package/dist/index.cjs +1590 -1590
  135. package/dist/settings/index.cjs +147 -147
  136. package/dist/shell/index.cjs +90 -90
  137. package/dist/studio/index.cjs +26 -26
  138. package/dist/styles.css +1 -1
  139. package/dist/workflow-canvas/index.cjs +55 -55
  140. package/node_modules/@arbidocs/coedit/package.json +1 -1
  141. package/package.json +5 -5
  142. package/src/docx/styles.css +94 -0
  143. package/dist/ai-IM4A23YT.cjs.map +0 -1
  144. package/dist/chunk-A3T3IC3K.cjs.map +0 -1
  145. package/dist/chunk-CIHERNDO.cjs +0 -18
  146. package/dist/chunk-M6IKVKU5.cjs.map +0 -1
  147. package/dist/chunk-X5LANJDZ.cjs.map +0 -1
@@ -3,27 +3,27 @@
3
3
 
4
4
  var chunk4CIVQWAX_cjs = require('./chunk-4CIVQWAX.cjs');
5
5
  var chunkPL7HUTM3_cjs = require('./chunk-PL7HUTM3.cjs');
6
- var chunkYGXOKB5Z_cjs = require('./chunk-YGXOKB5Z.cjs');
7
- var chunkKXIRVKCJ_cjs = require('./chunk-KXIRVKCJ.cjs');
8
- var chunkTT4IF52H_cjs = require('./chunk-TT4IF52H.cjs');
9
- var chunkNNUK5ZM7_cjs = require('./chunk-NNUK5ZM7.cjs');
10
- var chunkX5LANJDZ_cjs = require('./chunk-X5LANJDZ.cjs');
6
+ var chunk7TEUGFIL_cjs = require('./chunk-7TEUGFIL.cjs');
7
+ var chunkUUENH4BJ_cjs = require('./chunk-UUENH4BJ.cjs');
8
+ var chunk7X3FS5HQ_cjs = require('./chunk-7X3FS5HQ.cjs');
9
+ var chunk5QUL5BZO_cjs = require('./chunk-5QUL5BZO.cjs');
10
+ var chunkVTYJAZDU_cjs = require('./chunk-VTYJAZDU.cjs');
11
11
  var chunkYYPZOEED_cjs = require('./chunk-YYPZOEED.cjs');
12
12
  var chunkGNZAH6UI_cjs = require('./chunk-GNZAH6UI.cjs');
13
13
  var chunkJH6JTI76_cjs = require('./chunk-JH6JTI76.cjs');
14
14
  var chunkDTMBAFIL_cjs = require('./chunk-DTMBAFIL.cjs');
15
15
  var chunkMZZ3SBQL_cjs = require('./chunk-MZZ3SBQL.cjs');
16
- var chunkMNIQDXM6_cjs = require('./chunk-MNIQDXM6.cjs');
17
- var chunkE3Y7RI3J_cjs = require('./chunk-E3Y7RI3J.cjs');
18
16
  var chunkVLCY46K6_cjs = require('./chunk-VLCY46K6.cjs');
17
+ var chunkFX3K6LNZ_cjs = require('./chunk-FX3K6LNZ.cjs');
18
+ var chunkIPSHAMO2_cjs = require('./chunk-IPSHAMO2.cjs');
19
19
  var chunkEG7EJFUE_cjs = require('./chunk-EG7EJFUE.cjs');
20
20
  var chunkHQDR43JC_cjs = require('./chunk-HQDR43JC.cjs');
21
21
  var chunkJR2YSBD5_cjs = require('./chunk-JR2YSBD5.cjs');
22
22
  var chunkSJSGSHIT_cjs = require('./chunk-SJSGSHIT.cjs');
23
- var chunkFX3K6LNZ_cjs = require('./chunk-FX3K6LNZ.cjs');
24
- var chunkIPSHAMO2_cjs = require('./chunk-IPSHAMO2.cjs');
25
- var chunkTKHCIHE2_cjs = require('./chunk-TKHCIHE2.cjs');
26
23
  var chunkLJJJ6CYH_cjs = require('./chunk-LJJJ6CYH.cjs');
24
+ var chunkMNIQDXM6_cjs = require('./chunk-MNIQDXM6.cjs');
25
+ var chunkE3Y7RI3J_cjs = require('./chunk-E3Y7RI3J.cjs');
26
+ var chunkTKHCIHE2_cjs = require('./chunk-TKHCIHE2.cjs');
27
27
  var React = require('react');
28
28
  var lucideReact = require('lucide-react');
29
29
  var react = require('@arbidocs/react');
@@ -194,13 +194,13 @@ function ViewerRelatedDocuments({ document: document2 }) {
194
194
  );
195
195
  if (!related) return null;
196
196
  return /* @__PURE__ */ jsxRuntime.jsx(
197
- chunkTT4IF52H_cjs.RelatedDocumentsCell,
197
+ chunk7X3FS5HQ_cjs.RelatedDocumentsCell,
198
198
  {
199
199
  currentDoc: document2,
200
200
  related,
201
201
  viewingDocumentId: viewerOpen ? viewingId : null,
202
202
  onDocumentClick: (id) => session.setViewingDocument({ id, page: null }),
203
- onDelete: (doc) => chunkYGXOKB5Z_cjs.useFilesDialogs.getState().requestDelete(doc),
203
+ onDelete: (doc) => chunk7TEUGFIL_cjs.useFilesDialogs.getState().requestDelete(doc),
204
204
  onCompare
205
205
  }
206
206
  );
@@ -327,7 +327,7 @@ function useViewedDocument(documentId) {
327
327
  const documentData = record?.external_id === documentId ? record : void 0;
328
328
  const { data: tags } = chunkHQDR43JC_cjs.useConnectedTags();
329
329
  const labelSummaries = React.useMemo(
330
- () => chunkNNUK5ZM7_cjs.summariseDocTags(documentData?.doctags ?? [], tags.filter(chunkNNUK5ZM7_cjs.isDocumentLabel)),
330
+ () => chunk5QUL5BZO_cjs.summariseDocTags(documentData?.doctags ?? [], tags.filter(chunk5QUL5BZO_cjs.isDocumentLabel)),
331
331
  [documentData, tags]
332
332
  );
333
333
  const fileName = documentData?.file_name;
@@ -389,26 +389,30 @@ function useViewedDocument(documentId) {
389
389
  hasParsedContent
390
390
  };
391
391
  }
392
+ var offlineCopies = /* @__PURE__ */ new WeakSet();
392
393
  function useViewerBlobs(documentId, doc) {
393
394
  const { documentData, isArtifact, isDocx, isXlsx, isDownloadOnly, isWebmFile } = doc;
394
395
  const { setWebmHasVideoTrack } = doc;
395
396
  const { client, saveFile } = documentTools.useDocumentTools();
396
397
  const { notify } = chunkTKHCIHE2_cjs.useBlocksEnvironment();
397
398
  const currentVersion = documentData?.current_version ?? 1;
399
+ const snapshot = !!artifacts.parseVersionRef(documentId).version;
398
400
  const name = documentData?.file_name;
399
401
  const original = ui.isImageFile(name) || ui.isVideoFile(name) || ui.isAudioFile(name);
400
- const fallback = documentData && !artifacts.parseVersionRef(documentId).version ? () => react.loadOfflineDocument(documentData.external_id) : void 0;
402
+ const fallback = documentData && !snapshot ? async () => {
403
+ const blob = await react.loadOfflineDocument(documentData.external_id);
404
+ if (blob) offlineCopies.add(blob);
405
+ return blob;
406
+ } : void 0;
401
407
  const pdf = documentTools.useDocumentBytes(documentId, {
402
408
  version: currentVersion,
403
409
  kind: original ? "original" : "pdf",
404
- enabled: !isArtifact && !!documentData && !isDownloadOnly && (!isDocx || documentData.status === "completed" || documentData.status === "low-content"),
410
+ enabled: (!isArtifact || isDocx && !doc.isDraft && !doc.isStreaming && !doc.liveKind) && !!documentData && !isDownloadOnly && (!isDocx || snapshot || documentData.status === "completed" || documentData.status === "low-content"),
405
411
  fallback
406
412
  });
407
- const [pdfBlob, setPdfBlob] = React.useState(null);
408
- React.useEffect(() => setPdfBlob(null), [documentId]);
409
- React.useEffect(() => {
410
- if (pdf.data) setPdfBlob(pdf.data);
411
- }, [pdf.data]);
413
+ const pdfReady = !isDocx || snapshot || ["completed", "low-content"].includes(documentData?.status || "");
414
+ const pdfBlob = pdfReady && !pdf.isPlaceholderData ? pdf.data ?? null : null;
415
+ const pdfVerified = !!pdfBlob && !offlineCopies.has(pdfBlob);
412
416
  React.useEffect(() => {
413
417
  if (!isWebmFile || !pdfBlob) return;
414
418
  let cancelled = false;
@@ -433,6 +437,8 @@ function useViewerBlobs(documentId, doc) {
433
437
  }, [client, saveFile, notify, documentId, documentData?.file_name]);
434
438
  return {
435
439
  pdfBlob,
440
+ pdfVerified,
441
+ retryPdf: pdf.refetch,
436
442
  isPdfLoading: pdf.isLoading,
437
443
  pdfError: pdf.error,
438
444
  xlsxBlob: xlsx.data ?? null,
@@ -444,6 +450,8 @@ function useViewerTabs(doc, isCompact, hasHistory = false) {
444
450
  const {
445
451
  documentData,
446
452
  isArtifact,
453
+ isDraft,
454
+ isStreaming,
447
455
  isDocx,
448
456
  isXlsx,
449
457
  isEmail,
@@ -548,6 +556,14 @@ function useViewerTabs(doc, isCompact, hasHistory = false) {
548
556
  tooltip: liveKind ? "Code" : "Editor",
549
557
  label: tabLabel("edit", liveKind ? "Code" : "Document")
550
558
  },
559
+ ...!liveKind && !isDraft && !isStreaming && isDocx ? [
560
+ {
561
+ id: "pdf",
562
+ icon: /* @__PURE__ */ jsxRuntime.jsx(react.PdfIcon, { size: 20 }),
563
+ tooltip: "PDF",
564
+ label: tabLabel("pdf", "PDF")
565
+ }
566
+ ] : [],
551
567
  versionsTab
552
568
  ] : [
553
569
  ...isDocx ? [
@@ -611,6 +627,39 @@ function useViewerVersions(docId) {
611
627
  }, [documents, plainId]);
612
628
  return { versions, translations };
613
629
  }
630
+ function VersionDropdown({
631
+ versions,
632
+ activeId,
633
+ isSnapshot,
634
+ onOpen,
635
+ onHistory
636
+ }) {
637
+ const active = versions.find((version) => version.id === activeId);
638
+ const pendingVersion = activeId?.match(/@v([1-9]\d*)$/)?.[1];
639
+ return /* @__PURE__ */ jsxRuntime.jsxs(
640
+ "select",
641
+ {
642
+ "aria-label": "Active document version",
643
+ "data-testid": "document-version-dropdown",
644
+ className: "max-w-44 rounded border border-input bg-background px-2 py-1 text-sm",
645
+ value: active?.id ?? "",
646
+ onChange: (event) => {
647
+ const id = event.currentTarget.value;
648
+ if (id === "__history") onHistory();
649
+ else if (versions.some((version) => version.id === id)) onOpen(id);
650
+ },
651
+ children: [
652
+ !active && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: pendingVersion ? `v${pendingVersion} \xB7 ${isSnapshot ? "Read only" : "Current"}` : "Version unavailable" }),
653
+ [...versions].sort((a, b) => b.number - a.number).map((version) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: version.id, children: [
654
+ "v",
655
+ version.number,
656
+ version.isCurrent ? " \xB7 Current" : " \xB7 Read only"
657
+ ] }, version.id)),
658
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "__history", children: "Version history\u2026" })
659
+ ]
660
+ }
661
+ );
662
+ }
614
663
 
615
664
  // src/connection/viewer/parsed/document-tags.ts
616
665
  function isDocumentTag(tag) {
@@ -832,7 +881,7 @@ function PassageTagPanel({
832
881
  [workspaceTags]
833
882
  );
834
883
  return /* @__PURE__ */ jsxRuntime.jsx(
835
- chunkNNUK5ZM7_cjs.TagPassagePanel,
884
+ chunk5QUL5BZO_cjs.TagPassagePanel,
836
885
  {
837
886
  pageNumber,
838
887
  preview,
@@ -957,7 +1006,7 @@ var ParsedPassage = React.memo(function ParsedPassage2({
957
1006
  ];
958
1007
  }) : [];
959
1008
  return /* @__PURE__ */ jsxRuntime.jsx(
960
- chunkNNUK5ZM7_cjs.HtmlPassage,
1009
+ chunk5QUL5BZO_cjs.HtmlPassage,
961
1010
  {
962
1011
  chunkId,
963
1012
  highlight: isStrong ? "strong" : isLight ? "light" : void 0,
@@ -997,7 +1046,7 @@ var ParsedPassage = React.memo(function ParsedPassage2({
997
1046
  items: passageItems
998
1047
  }
999
1048
  ) : void 0,
1000
- children: /* @__PURE__ */ jsxRuntime.jsx(chunkKXIRVKCJ_cjs.ConnectedMarkdown, { children: chunk.content })
1049
+ children: /* @__PURE__ */ jsxRuntime.jsx(chunkUUENH4BJ_cjs.ConnectedMarkdown, { children: chunk.content })
1001
1050
  }
1002
1051
  );
1003
1052
  });
@@ -1133,11 +1182,11 @@ function useDocumentLabels(documentId, doctags, orderedChunkIds) {
1133
1182
  const workspaceTags = React.useMemo(() => allTags.filter(isDocumentTag), [allTags]);
1134
1183
  const documentDoctags = React.useMemo(() => doctags ?? [], [doctags]);
1135
1184
  const tagSummaries = React.useMemo(
1136
- () => chunkNNUK5ZM7_cjs.summariseDocTags(documentDoctags, workspaceTags),
1185
+ () => chunk5QUL5BZO_cjs.summariseDocTags(documentDoctags, workspaceTags),
1137
1186
  [documentDoctags, workspaceTags]
1138
1187
  );
1139
1188
  const labelSummaries = React.useMemo(
1140
- () => chunkNNUK5ZM7_cjs.summariseDocTags(documentDoctags, workspaceTags.filter(chunkNNUK5ZM7_cjs.isDocumentLabel)),
1189
+ () => chunk5QUL5BZO_cjs.summariseDocTags(documentDoctags, workspaceTags.filter(chunk5QUL5BZO_cjs.isDocumentLabel)),
1141
1190
  [documentDoctags, workspaceTags]
1142
1191
  );
1143
1192
  const labelsByChunk = React.useMemo(() => {
@@ -1645,14 +1694,14 @@ function ParsedTextView({
1645
1694
  }
1646
1695
  }
1647
1696
  }, [maxPageNumber, onLoadSuccess]);
1648
- if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: "Loading parsed document..." });
1697
+ if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "Loading parsed document..." });
1649
1698
  if (error) {
1650
- return /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-text", children: "Failed to load parsed document" }) });
1699
+ return /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-text", children: "Failed to load parsed document" }) });
1651
1700
  }
1652
1701
  const taggingChunk = labels.taggingChunkId ? processedChunks.flatMap((page) => page.chunks).find((c) => c.chunkExtId === labels.taggingChunkId) : void 0;
1653
- return /* @__PURE__ */ jsxRuntime.jsxs(chunkNNUK5ZM7_cjs.HtmlViewerRoot, { children: [
1702
+ return /* @__PURE__ */ jsxRuntime.jsxs(chunk5QUL5BZO_cjs.HtmlViewerRoot, { children: [
1654
1703
  /* @__PURE__ */ jsxRuntime.jsx(
1655
- chunkNNUK5ZM7_cjs.DocumentLabelBar,
1704
+ chunk5QUL5BZO_cjs.DocumentLabelBar,
1656
1705
  {
1657
1706
  summaries: labels.labelSummaries,
1658
1707
  activeTagExtId: labels.activeTagExtId,
@@ -1677,15 +1726,15 @@ function ParsedTextView({
1677
1726
  }
1678
1727
  ),
1679
1728
  !citation.factCitationActive && citation.runStartIds.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1680
- chunkNNUK5ZM7_cjs.CitedRunNav,
1729
+ chunk5QUL5BZO_cjs.CitedRunNav,
1681
1730
  {
1682
1731
  position: citation.runCursor + 1,
1683
1732
  total: citation.runStartIds.length,
1684
1733
  onStep: citation.gotoRun
1685
1734
  }
1686
1735
  ),
1687
- /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.HtmlViewerSurface, { surfaceRef: containerRef, onMouseUp: citation.handleSelectionEnd, children: processedChunks.length > 0 ? processedChunks.map((page, pageIndex) => /* @__PURE__ */ jsxRuntime.jsx(
1688
- chunkNNUK5ZM7_cjs.HtmlPage,
1736
+ /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.HtmlViewerSurface, { surfaceRef: containerRef, onMouseUp: citation.handleSelectionEnd, children: processedChunks.length > 0 ? processedChunks.map((page, pageIndex) => /* @__PURE__ */ jsxRuntime.jsx(
1737
+ chunk5QUL5BZO_cjs.HtmlPage,
1689
1738
  {
1690
1739
  pageNumber: page.pageNumber,
1691
1740
  totalPages,
@@ -1726,7 +1775,7 @@ function ParsedTextView({
1726
1775
  })
1727
1776
  },
1728
1777
  pageIndex
1729
- )) : /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.HtmlViewerEmpty, {}) })
1778
+ )) : /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.HtmlViewerEmpty, {}) })
1730
1779
  ] });
1731
1780
  }
1732
1781
  var AnnotatedPdfViewer = React.lazy(
@@ -1776,7 +1825,7 @@ function ViewerPdfPane({
1776
1825
  const showMarkup = markup.hasMarkup && !markup.showOriginal;
1777
1826
  if (isDownloadOnly) {
1778
1827
  return /* @__PURE__ */ jsxRuntime.jsx(
1779
- chunkNNUK5ZM7_cjs.ViewerPreviewUnavailable,
1828
+ chunk5QUL5BZO_cjs.ViewerPreviewUnavailable,
1780
1829
  {
1781
1830
  extension: fileExtension(documentData?.file_name),
1782
1831
  onDownload
@@ -1785,27 +1834,30 @@ function ViewerPdfPane({
1785
1834
  }
1786
1835
  const loadingLabel = isVideo ? "Loading video..." : isAudio ? "Loading audio..." : isImage ? "Loading image..." : !documentData ? "Loading document..." : ui.friendlyFileType(documentData.file_type, documentData.file_name) === "Text" ? "Loading text..." : "Loading PDF...";
1787
1836
  const errorLabel = isVideo ? "Failed to load video" : isAudio ? "Failed to load audio" : isImage ? "Failed to load image" : "Failed to load PDF";
1788
- if (isDocx && documentData && !["completed", "low-content", "failed"].includes(documentData.status || "")) {
1789
- return /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: "PDF and search indexing are processing. Open the DOCX tab to edit now." });
1837
+ if (isDocx && !pdfSnapshotNumber && documentData && !["completed", "low-content", "failed"].includes(documentData.status || "")) {
1838
+ return /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "PDF and search indexing are processing. Open the DOCX tab to edit now." });
1790
1839
  }
1791
- if (isPdfLoading) return /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: loadingLabel });
1840
+ if (isDocx && !pdfSnapshotNumber && documentData?.status === "failed") {
1841
+ return /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "PDF conversion failed. Open the Word editor or download the document." });
1842
+ }
1843
+ if (isPdfLoading) return /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: loadingLabel });
1792
1844
  if (pdfError) {
1793
1845
  return /* @__PURE__ */ jsxRuntime.jsx(
1794
- chunkNNUK5ZM7_cjs.ViewerLoadError,
1846
+ chunk5QUL5BZO_cjs.ViewerLoadError,
1795
1847
  {
1796
1848
  message: isVideo || isAudio || isImage ? `${errorLabel} \u2014 download it instead.` : "Couldn't display the PDF \u2014 download it instead.",
1797
1849
  onDownload
1798
1850
  }
1799
1851
  );
1800
1852
  }
1801
- if (!pdfBlob) return /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: loadingLabel });
1853
+ if (!pdfBlob) return /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: loadingLabel });
1802
1854
  if (isVideo) return /* @__PURE__ */ jsxRuntime.jsx(viewers.VideoViewer, { blob: pdfBlob, title: documentData?.file_name || "Video" });
1803
1855
  if (isAudio) return /* @__PURE__ */ jsxRuntime.jsx(viewers.AudioViewer, { blob: pdfBlob, title: documentData?.file_name || "Audio" });
1804
1856
  if (isImage) {
1805
1857
  return /* @__PURE__ */ jsxRuntime.jsx(viewers.ImageViewer, { blob: pdfBlob, alt: documentData?.file_name || "Document image" });
1806
1858
  }
1807
1859
  if (signatureFlow?.kind === "prepare") {
1808
- return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: "Loading\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
1860
+ return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "Loading\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
1809
1861
  SignatureRequestEditor,
1810
1862
  {
1811
1863
  ...viewerProps,
@@ -1823,7 +1875,7 @@ function ViewerPdfPane({
1823
1875
  }
1824
1876
  if (signatureFlow?.kind === "sign" && currentUserId) {
1825
1877
  const { currentPage: _page, scrollTrigger: _trigger, ...guidedProps } = viewerProps;
1826
- return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: "Loading\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
1878
+ return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "Loading\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
1827
1879
  GuidedSigningViewer,
1828
1880
  {
1829
1881
  ...guidedProps,
@@ -1837,7 +1889,7 @@ function ViewerPdfPane({
1837
1889
  ) });
1838
1890
  }
1839
1891
  if (placingSignature) {
1840
- return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: "Loading\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
1892
+ return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "Loading\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
1841
1893
  SignaturePlacementViewer,
1842
1894
  {
1843
1895
  ...viewerProps,
@@ -1853,7 +1905,7 @@ function ViewerPdfPane({
1853
1905
  return /* @__PURE__ */ jsxRuntime.jsx(
1854
1906
  React.Suspense,
1855
1907
  {
1856
- fallback: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: annotating ? "Loading annotation tools\u2026" : "Loading markup\u2026" }),
1908
+ fallback: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: annotating ? "Loading annotation tools\u2026" : "Loading markup\u2026" }),
1857
1909
  children: /* @__PURE__ */ jsxRuntime.jsx(
1858
1910
  AnnotatedPdfViewer,
1859
1911
  {
@@ -1879,12 +1931,12 @@ function ViewerPdfPane({
1879
1931
  return /* @__PURE__ */ jsxRuntime.jsx(SessionPdfViewer, { ...viewerProps, file: pdfBlob });
1880
1932
  }
1881
1933
  var StreamedWordArtifact = React.lazy(
1882
- () => import('./ConnectedStreamedWordArtifact-2RTCHVPI.cjs').then((m) => ({
1934
+ () => import('./ConnectedStreamedWordArtifact-7V24ZDAC.cjs').then((m) => ({
1883
1935
  default: m.ConnectedStreamedWordArtifact
1884
1936
  }))
1885
1937
  );
1886
1938
  var NativeDocxComparison = React.lazy(
1887
- () => import('./ConnectedNativeDocxComparison-YXMYJWXY.cjs').then((m) => ({
1939
+ () => import('./ConnectedNativeDocxComparison-7OUKTKYP.cjs').then((m) => ({
1888
1940
  default: m.ConnectedNativeDocxComparison
1889
1941
  }))
1890
1942
  );
@@ -1987,10 +2039,15 @@ function DocumentViewerContent({
1987
2039
  const threadTitle = (id) => conversations.find((c) => c.external_id === id)?.title?.trim() || "Its thread";
1988
2040
  const madeInId = documentData?.conversation_ext_id ?? null;
1989
2041
  const madeIn = madeInId ? { id: madeInId, title: threadTitle(madeInId) } : null;
1990
- const pdfSnapshotId = snapshotDocumentId && !isDocx && !isArtifact ? snapshotDocumentId : null;
2042
+ const pdfSnapshotId = snapshotDocumentId && (!isArtifact || isDocx) ? snapshotDocumentId : null;
1991
2043
  const shownDocumentId = pdfSnapshotId || documentId;
1992
2044
  const blobs = useViewerBlobs(shownDocumentId, doc);
1993
- const { pdfBlob, xlsxBlob, xlsxError, handleDirectDownload } = blobs;
2045
+ const [minimumPdfVersion, setMinimumPdfVersion] = React.useState(null);
2046
+ React.useEffect(() => setMinimumPdfVersion(null), [documentId]);
2047
+ const versionReady = !!pdfSnapshotId || minimumPdfVersion === null || (documentData?.current_version ?? 0) >= minimumPdfVersion;
2048
+ const { xlsxBlob, xlsxError, handleDirectDownload } = blobs;
2049
+ const pdfBlob = versionReady ? blobs.pdfBlob : null;
2050
+ const pdfVerified = !!pdfBlob && blobs.pdfVerified !== false;
1994
2051
  const [annotating, setAnnotating] = React.useState(false);
1995
2052
  const [sharingFile, setSharingFile] = React.useState(false);
1996
2053
  React.useEffect(() => setAnnotating(false), [documentId]);
@@ -1998,7 +2055,52 @@ function DocumentViewerContent({
1998
2055
  null
1999
2056
  );
2000
2057
  const hasHistory = versions.length > 1 || (documentData?.current_version ?? 1) > 1 || translations.length > 0;
2001
- const { activeTab, handleTabChange, viewerTabs } = useViewerTabs(doc, isCompact, hasHistory);
2058
+ const {
2059
+ activeTab,
2060
+ handleTabChange: changeTab,
2061
+ viewerTabs
2062
+ } = useViewerTabs(doc, isCompact, hasHistory);
2063
+ const saveWordRef = React.useRef(null);
2064
+ const transitionPending = React.useRef(false);
2065
+ const transitionKey = JSON.stringify([openedId, doc.workspaceId]);
2066
+ const transitionScope = React.useRef({ key: transitionKey, generation: 0 });
2067
+ if (transitionScope.current.key !== transitionKey) {
2068
+ transitionScope.current = {
2069
+ key: transitionKey,
2070
+ generation: transitionScope.current.generation + 1
2071
+ };
2072
+ }
2073
+ React.useEffect(
2074
+ () => () => {
2075
+ transitionScope.current.generation += 1;
2076
+ },
2077
+ []
2078
+ );
2079
+ const requestViewerTransition = async (transition) => {
2080
+ if (transitionPending.current) return false;
2081
+ const leavingWord = isDocx && !isDraft && !isStreaming && !snapshotDocumentId && (activeTab === "docx" || isArtifact && !liveKind && activeTab === "edit");
2082
+ if (leavingWord) {
2083
+ transitionPending.current = true;
2084
+ const generation = transitionScope.current.generation;
2085
+ try {
2086
+ const saved = saveWordRef.current && await saveWordRef.current();
2087
+ if (!saved) {
2088
+ notify("Could not save the current document. Stay in the editor and try again.", "error");
2089
+ return false;
2090
+ }
2091
+ if (generation !== transitionScope.current.generation) return false;
2092
+ if (typeof saved === "number") setMinimumPdfVersion(saved);
2093
+ } finally {
2094
+ transitionPending.current = false;
2095
+ }
2096
+ }
2097
+ transition();
2098
+ return true;
2099
+ };
2100
+ const handleTabChange = (tab) => {
2101
+ if (tab === activeTab) return;
2102
+ void requestViewerTransition(() => changeTab(tab));
2103
+ };
2002
2104
  const crop = useImageCrop(
2003
2105
  documentId,
2004
2106
  documentData?.file_name,
@@ -2008,15 +2110,31 @@ function DocumentViewerContent({
2008
2110
  const [placingSignature, setPlacingSignature] = React.useState(false);
2009
2111
  const [signAppearance, setSignAppearance] = React.useState();
2010
2112
  const [isSignOpen, setIsSignOpen] = React.useState(false);
2011
- React.useEffect(() => setPlacingSignature(false), [documentId, snapshotDocumentId]);
2113
+ const signingScope = JSON.stringify([
2114
+ documentId,
2115
+ snapshotDocumentId,
2116
+ documentData?.current_version
2117
+ ]);
2118
+ const signingScopeRef = React.useRef(signingScope);
2119
+ const signingScopeMatches = signingScopeRef.current === signingScope;
2120
+ React.useEffect(() => {
2121
+ setPlacingSignature(false);
2122
+ setIsSignOpen(false);
2123
+ setSignAppearance(void 0);
2124
+ signingScopeRef.current = signingScope;
2125
+ }, [signingScope]);
2012
2126
  const [signatureFlow, setSignatureFlow] = React.useState(null);
2013
- React.useEffect(() => setSignatureFlow(null), [documentId, snapshotDocumentId]);
2014
- const { data: signatureStatus } = documentTools.useDocumentSignatures(shownDocumentId, !isDraft && !liveKind);
2127
+ React.useEffect(() => setSignatureFlow(null), [signingScope]);
2128
+ const signatureDocumentId = pdfSnapshotId || (documentData?.current_version ? `${documentId}@v${documentData.current_version}` : documentId);
2129
+ const { data: signatureStatus } = documentTools.useDocumentSignatures(
2130
+ signatureDocumentId,
2131
+ !isDraft && !liveKind
2132
+ );
2015
2133
  const isCoEditing = !snapshotDocumentId && !compareDocumentId && !isDraft && (activeTab === "docx" && isDocx || activeTab === "edit" && isArtifact && !liveKind && !isStreaming);
2016
2134
  const currentVersionLabel = isCoEditing ? void 0 : !snapshotDocumentId && !compareDocumentId && (isDocx || isArtifact && !liveKind) ? "Live" : artifacts.versionLabel(versions, snapshotDocumentId || documentId);
2017
2135
  const compareVersionLabel = artifacts.versionLabel(versions, compareDocumentId);
2018
2136
  const snapshotNumber = artifacts.findVersion(versions, snapshotDocumentId)?.number;
2019
- const pdfSnapshotNumber = pdfSnapshotId ? snapshotNumber : void 0;
2137
+ const pdfSnapshotNumber = pdfSnapshotId ? artifacts.parseVersionRef(pdfSnapshotId).version ?? void 0 : void 0;
2020
2138
  const isSigned = !!signatureStatus?.signed;
2021
2139
  const markup = documentTools.useDocumentMarkup(documentData, pdfSnapshotNumber, isSigned);
2022
2140
  React.useEffect(() => {
@@ -2039,15 +2157,15 @@ function DocumentViewerContent({
2039
2157
  };
2040
2158
  const documentTitle = streamingDoc?.title || draftDoc?.title || documentData?.doc_metadata?.title || documentData?.file_name || "Document";
2041
2159
  const pageNav = totalPages > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2042
- /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerZoomControl, { zoom, onCycle: () => setZoom(viewers.cycleZoom(zoom)) }),
2160
+ /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerZoomControl, { zoom, onCycle: () => setZoom(viewers.cycleZoom(zoom)) }),
2043
2161
  /* @__PURE__ */ jsxRuntime.jsx(
2044
- chunkNNUK5ZM7_cjs.PdfPageNav,
2162
+ chunk5QUL5BZO_cjs.PdfPageNav,
2045
2163
  {
2046
2164
  canPrev: (viewingDocumentPage || 1) > 1,
2047
2165
  canNext: (viewingDocumentPage || 1) < totalPages,
2048
2166
  onPrev: () => stepPage(-1),
2049
2167
  onNext: () => stepPage(1),
2050
- counter: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerPageCounter, { page: viewingDocumentPage || 1, total: totalPages, onGoTo: goToPage })
2168
+ counter: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerPageCounter, { page: viewingDocumentPage || 1, total: totalPages, onGoTo: goToPage })
2051
2169
  }
2052
2170
  )
2053
2171
  ] });
@@ -2071,7 +2189,7 @@ function DocumentViewerContent({
2071
2189
  );
2072
2190
  const titleBlock = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2073
2191
  isDraft ? /* @__PURE__ */ jsxRuntime.jsx(ViewerDraftTitle, { documentId }) : /* @__PURE__ */ jsxRuntime.jsx(
2074
- chunkNNUK5ZM7_cjs.ViewerTitle,
2192
+ chunk5QUL5BZO_cjs.ViewerTitle,
2075
2193
  {
2076
2194
  title: documentTitle,
2077
2195
  versionLabel: currentVersionLabel,
@@ -2096,12 +2214,37 @@ function DocumentViewerContent({
2096
2214
  // A draft's kind replaces the tabs: neither Versions nor the text view means anything
2097
2215
  // before the first save.
2098
2216
  /* @__PURE__ */ jsxRuntime.jsx(ViewerDraftKind, { documentId })
2099
- ) : /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerTabBar, { tabs: viewerTabs, activeId: activeTab, onChange: handleTabChange }),
2217
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2218
+ /* @__PURE__ */ jsxRuntime.jsx(
2219
+ chunk5QUL5BZO_cjs.ViewerTabBar,
2220
+ {
2221
+ tabs: viewerTabs.filter((tab) => tab.id !== "versions"),
2222
+ activeId: activeTab,
2223
+ onChange: handleTabChange
2224
+ }
2225
+ ),
2226
+ (isArtifact || isDocx || hasHistory) && !liveKind && !isComparing && /* @__PURE__ */ jsxRuntime.jsx(
2227
+ VersionDropdown,
2228
+ {
2229
+ versions,
2230
+ activeId: snapshotDocumentId ?? (currentVersionId === documentId && documentData?.current_version ? `${documentId}@v${documentData.current_version}` : currentVersionId),
2231
+ isSnapshot: !!snapshotDocumentId,
2232
+ onOpen: (id) => {
2233
+ void requestViewerTransition(() => {
2234
+ setSnapshotDocumentId(id === currentVersionId ? null : id);
2235
+ if (activeTab === "versions")
2236
+ setActiveTab(isArtifact ? "edit" : isDocx ? "docx" : "pdf");
2237
+ });
2238
+ },
2239
+ onHistory: () => handleTabChange("versions")
2240
+ }
2241
+ )
2242
+ ] }),
2100
2243
  !isCompact && titleBlock
2101
2244
  ] });
2102
2245
  const annotatable = documentTools.canAnnotate({
2103
2246
  activeTab,
2104
- hasPdf: !!pdfBlob,
2247
+ hasPdf: pdfVerified,
2105
2248
  isImage,
2106
2249
  isVideo,
2107
2250
  isAudio,
@@ -2117,14 +2260,18 @@ function DocumentViewerContent({
2117
2260
  documentId,
2118
2261
  hidden: !!signatureFlow,
2119
2262
  onSign: (request) => {
2120
- setAnnotating(false);
2121
- setPlacingSignature(false);
2122
- if (activeTab !== "pdf") handleTabChange("pdf");
2123
- setSignatureFlow({ kind: "sign", request });
2263
+ void requestViewerTransition(() => {
2264
+ setAnnotating(false);
2265
+ setPlacingSignature(false);
2266
+ if (activeTab !== "pdf") changeTab("pdf");
2267
+ setSignatureFlow({ kind: "sign", request });
2268
+ });
2124
2269
  },
2125
2270
  onEditDraft: (draft) => {
2126
- if (activeTab !== "pdf") handleTabChange("pdf");
2127
- setSignatureFlow({ kind: "prepare", draft });
2271
+ void requestViewerTransition(() => {
2272
+ if (activeTab !== "pdf") changeTab("pdf");
2273
+ setSignatureFlow({ kind: "prepare", draft });
2274
+ });
2128
2275
  }
2129
2276
  }
2130
2277
  );
@@ -2169,7 +2316,7 @@ function DocumentViewerContent({
2169
2316
  }
2170
2317
  ),
2171
2318
  activeTab === "pdf" && isImage && pdfBlob && /* @__PURE__ */ jsxRuntime.jsx(
2172
- chunkNNUK5ZM7_cjs.ViewerImageActions,
2319
+ chunk5QUL5BZO_cjs.ViewerImageActions,
2173
2320
  {
2174
2321
  compact: isCompact,
2175
2322
  onUseAsReference: support.useImageAsReference ? () => support.useImageAsReference(documentId) : void 0,
@@ -2238,7 +2385,7 @@ function DocumentViewerContent({
2238
2385
  {
2239
2386
  state: documentData?.shared ? "shared" : "private",
2240
2387
  onToggle: share,
2241
- disabled: !chunkNNUK5ZM7_cjs.canChangeVisibility(documentData, currentUserId),
2388
+ disabled: !chunk5QUL5BZO_cjs.canChangeVisibility(documentData, currentUserId),
2242
2389
  disabledTooltip: "Only the owner can change visibility",
2243
2390
  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",
2244
2391
  variant: "outline",
@@ -2361,7 +2508,7 @@ function DocumentViewerContent({
2361
2508
  ] })
2362
2509
  ] })
2363
2510
  ] }),
2364
- isSignOpen && pdfBlob && /* @__PURE__ */ jsxRuntime.jsx(
2511
+ isSignOpen && pdfBlob && pdfVerified && signingScopeMatches && /* @__PURE__ */ jsxRuntime.jsx(
2365
2512
  chunkJH6JTI76_cjs.SignDocumentDialog,
2366
2513
  {
2367
2514
  open: isSignOpen,
@@ -2382,7 +2529,7 @@ function DocumentViewerContent({
2382
2529
  onZoomChange: setZoom
2383
2530
  };
2384
2531
  return /* @__PURE__ */ jsxRuntime.jsxs(
2385
- chunkNNUK5ZM7_cjs.ViewerFrame,
2532
+ chunk5QUL5BZO_cjs.ViewerFrame,
2386
2533
  {
2387
2534
  frameRef: containerRef,
2388
2535
  contentId: documentId,
@@ -2427,7 +2574,7 @@ function DocumentViewerContent({
2427
2574
  )
2428
2575
  ),
2429
2576
  children: [
2430
- isComparing && /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: "Loading comparison\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
2577
+ isComparing && /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "Loading comparison\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
2431
2578
  NativeDocxComparison,
2432
2579
  {
2433
2580
  baseId: compareDocumentId,
@@ -2436,9 +2583,14 @@ function DocumentViewerContent({
2436
2583
  }
2437
2584
  ) }),
2438
2585
  isCaptureDraft && /* @__PURE__ */ jsxRuntime.jsx(ViewerCaptureDraft, { documentId }),
2439
- !isCaptureDraft && (activeTab === "pdf" || isMedia && activeTab === "html") && !isArtifact && !isComparing && /* @__PURE__ */ jsxRuntime.jsxs(chunkDTMBAFIL_cjs.ViewerPane, { hidden: activeTab !== "pdf", children: [
2440
- /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.DocumentLabelBar, { summaries: labelSummaries }),
2586
+ !isCaptureDraft && (activeTab === "pdf" || isMedia && activeTab === "html") && (!isArtifact || isDocx && !isDraft && !isStreaming && !liveKind) && !isComparing && /* @__PURE__ */ jsxRuntime.jsxs(chunkDTMBAFIL_cjs.ViewerPane, { hidden: activeTab !== "pdf", children: [
2587
+ /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.DocumentLabelBar, { summaries: labelSummaries }),
2441
2588
  !isMedia && !isImage && signatureBanner,
2589
+ activeTab === "pdf" && pdfBlob && !pdfVerified && /* @__PURE__ */ jsxRuntime.jsxs(chunk5QUL5BZO_cjs.ViewerMessage, { children: [
2590
+ "Offline copy: its version cannot be verified. Reconnect before signing.",
2591
+ " ",
2592
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => void blobs.retryPdf(), className: "underline", children: "Retry loading the current PDF" })
2593
+ ] }),
2442
2594
  activeTab === "pdf" && !isMedia && !isImage && /* @__PURE__ */ jsxRuntime.jsx(
2443
2595
  chunkYYPZOEED_cjs.MarkupNotices,
2444
2596
  {
@@ -2447,20 +2599,20 @@ function DocumentViewerContent({
2447
2599
  onOpenVersion: (n) => setSnapshotDocumentId(`${documentId}@v${n}`)
2448
2600
  }
2449
2601
  ),
2450
- /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerControlBar, { controls: activeTab === "pdf" && pageNav, children: /* @__PURE__ */ jsxRuntime.jsx(
2602
+ /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerControlBar, { controls: activeTab === "pdf" && pageNav, children: /* @__PURE__ */ jsxRuntime.jsx(
2451
2603
  ViewerPdfPane,
2452
2604
  {
2453
2605
  documentId,
2454
2606
  doc,
2455
2607
  pdfBlob,
2456
- isPdfLoading: blobs.isPdfLoading,
2608
+ isPdfLoading: !versionReady || blobs.isPdfLoading,
2457
2609
  pdfError: blobs.pdfError,
2458
2610
  onDownload: () => void handleDirectDownload(),
2459
2611
  viewerProps,
2460
- signatureFlow,
2612
+ signatureFlow: pdfVerified && signingScopeMatches ? signatureFlow : null,
2461
2613
  onSignatureFlow: setSignatureFlow,
2462
2614
  currentUserId,
2463
- placingSignature,
2615
+ placingSignature: pdfVerified && signingScopeMatches && placingSignature,
2464
2616
  onPlacingDone: (appearance) => {
2465
2617
  setPlacingSignature(false);
2466
2618
  if (!appearance) return;
@@ -2486,15 +2638,16 @@ function DocumentViewerContent({
2486
2638
  }
2487
2639
  ),
2488
2640
  activeTab === "edit" && isArtifact && liveKind && /* @__PURE__ */ jsxRuntime.jsx(chunkEG7EJFUE_cjs.ArtifactCodeView, { source: liveSource, fileName: documentData?.file_name ?? void 0 }),
2489
- activeTab === "edit" && isArtifact && !liveKind && !isStreaming && !isComparing && /* @__PURE__ */ jsxRuntime.jsxs(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: "Loading editor\u2026" }), children: [
2641
+ activeTab === "edit" && isArtifact && !liveKind && !isStreaming && !isComparing && /* @__PURE__ */ jsxRuntime.jsxs(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "Loading editor\u2026" }), children: [
2490
2642
  isSigned && !snapshotDocumentId && /* @__PURE__ */ jsxRuntime.jsx(chunkYYPZOEED_cjs.SignedEditNote, {}),
2491
2643
  /* @__PURE__ */ jsxRuntime.jsx(
2492
- chunkX5LANJDZ_cjs.ConnectedNativeDocxEditor,
2644
+ chunkVTYJAZDU_cjs.ConnectedNativeDocxEditor,
2493
2645
  {
2494
2646
  documentId: snapshotDocumentId || documentId,
2495
2647
  title: documentTitle,
2496
2648
  draftContent: isDraft ? draftDoc?.content || "" : void 0,
2497
2649
  snapshot: !!snapshotDocumentId,
2650
+ saveRef: saveWordRef,
2498
2651
  onSaved: (id) => {
2499
2652
  if (!isDraft) return;
2500
2653
  session.clearDraftDocument(documentId);
@@ -2529,21 +2682,22 @@ function DocumentViewerContent({
2529
2682
  onOpenTranslation: (id) => setViewingDocumentId(id)
2530
2683
  }
2531
2684
  ),
2532
- activeTab === "xlsx" && isXlsx && (xlsxBlob ? /* @__PURE__ */ jsxRuntime.jsx(viewers.XlsxViewer, { blob: xlsxBlob }) : /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: xlsxError ? "Failed to load spreadsheet" : "Loading spreadsheet..." })),
2533
- activeTab === "docx" && isDocx && !isComparing && /* @__PURE__ */ jsxRuntime.jsxs(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: "Loading editor\u2026" }), children: [
2685
+ activeTab === "xlsx" && isXlsx && (xlsxBlob ? /* @__PURE__ */ jsxRuntime.jsx(viewers.XlsxViewer, { blob: xlsxBlob }) : /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: xlsxError ? "Failed to load spreadsheet" : "Loading spreadsheet..." })),
2686
+ activeTab === "docx" && isDocx && !isComparing && /* @__PURE__ */ jsxRuntime.jsxs(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "Loading editor\u2026" }), children: [
2534
2687
  signatureBanner,
2535
2688
  isSigned && !snapshotDocumentId && /* @__PURE__ */ jsxRuntime.jsx(chunkYYPZOEED_cjs.SignedEditNote, {}),
2536
2689
  /* @__PURE__ */ jsxRuntime.jsx(
2537
- chunkX5LANJDZ_cjs.ConnectedNativeDocxEditor,
2690
+ chunkVTYJAZDU_cjs.ConnectedNativeDocxEditor,
2538
2691
  {
2539
2692
  documentId: snapshotDocumentId || documentId,
2540
2693
  title: documentTitle,
2541
- snapshot: !!snapshotDocumentId
2694
+ snapshot: !!snapshotDocumentId,
2695
+ saveRef: saveWordRef
2542
2696
  },
2543
2697
  `${snapshotDocumentId || documentId}-${snapshotDocumentId ? "snapshot" : "live"}`
2544
2698
  )
2545
2699
  ] }),
2546
- streamingDoc && isStreaming && isArtifact && !liveKind && !isComparing && (activeTab === "html" || activeTab === "edit") && /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerMessage, { children: "Opening draft\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
2700
+ streamingDoc && isStreaming && isArtifact && !liveKind && !isComparing && (activeTab === "html" || activeTab === "edit") && /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerMessage, { children: "Opening draft\u2026" }), children: /* @__PURE__ */ jsxRuntime.jsx(
2547
2701
  StreamedWordArtifact,
2548
2702
  {
2549
2703
  documentId: documentId.startsWith("doc-") ? documentId : void 0,
@@ -2553,7 +2707,7 @@ function DocumentViewerContent({
2553
2707
  },
2554
2708
  documentId
2555
2709
  ) }),
2556
- !isCaptureDraft && !isComparing && activeTab === "html" && !(isStreaming && isArtifact && !liveKind) && /* @__PURE__ */ jsxRuntime.jsx(chunkDTMBAFIL_cjs.ViewerPane, { children: /* @__PURE__ */ jsxRuntime.jsx(chunkNNUK5ZM7_cjs.ViewerControlBar, { controls: pageNav, children: /* @__PURE__ */ jsxRuntime.jsx(
2710
+ !isCaptureDraft && !isComparing && activeTab === "html" && !(isStreaming && isArtifact && !liveKind) && /* @__PURE__ */ jsxRuntime.jsx(chunkDTMBAFIL_cjs.ViewerPane, { children: /* @__PURE__ */ jsxRuntime.jsx(chunk5QUL5BZO_cjs.ViewerControlBar, { controls: pageNav, children: /* @__PURE__ */ jsxRuntime.jsx(
2557
2711
  ParsedTextView,
2558
2712
  {
2559
2713
  documentId: pdfSnapshotId || documentId,
@@ -2569,5 +2723,5 @@ function DocumentViewerContent({
2569
2723
  }
2570
2724
 
2571
2725
  exports.ConnectedDocumentViewer = ConnectedDocumentViewer;
2572
- //# sourceMappingURL=chunk-A3T3IC3K.cjs.map
2573
- //# sourceMappingURL=chunk-A3T3IC3K.cjs.map
2726
+ //# sourceMappingURL=chunk-D7ICHGWM.cjs.map
2727
+ //# sourceMappingURL=chunk-D7ICHGWM.cjs.map