@arbidocs/blocks 0.5.6 → 0.5.7

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 (134) hide show
  1. package/dist/{ConnectedCallDock-WSYIEIYQ.cjs → ConnectedCallDock-R3SJLBDY.cjs} +10 -10
  2. package/dist/{ConnectedCallDock-WSYIEIYQ.cjs.map → ConnectedCallDock-R3SJLBDY.cjs.map} +1 -1
  3. package/dist/{ConnectedCallDock-XUDNF7WJ.js → ConnectedCallDock-W6MVKME2.js} +9 -9
  4. package/dist/{ConnectedCallDock-XUDNF7WJ.js.map → ConnectedCallDock-W6MVKME2.js.map} +1 -1
  5. package/dist/{ConnectedCallRoom-LKXXPK6N.js → ConnectedCallRoom-C6PP45LE.js} +9 -9
  6. package/dist/{ConnectedCallRoom-LKXXPK6N.js.map → ConnectedCallRoom-C6PP45LE.js.map} +1 -1
  7. package/dist/{ConnectedCallRoom-ATSCANHS.cjs → ConnectedCallRoom-EKC7RFYF.cjs} +10 -10
  8. package/dist/{ConnectedCallRoom-ATSCANHS.cjs.map → ConnectedCallRoom-EKC7RFYF.cjs.map} +1 -1
  9. package/dist/{ConnectedNativeDocxComparison-F47WEZVU.js → ConnectedNativeDocxComparison-4MI22H2R.js} +10 -10
  10. package/dist/{ConnectedNativeDocxComparison-F47WEZVU.js.map → ConnectedNativeDocxComparison-4MI22H2R.js.map} +1 -1
  11. package/dist/{ConnectedNativeDocxComparison-WEFO2EPP.cjs → ConnectedNativeDocxComparison-VZLB7WWW.cjs} +11 -11
  12. package/dist/{ConnectedNativeDocxComparison-WEFO2EPP.cjs.map → ConnectedNativeDocxComparison-VZLB7WWW.cjs.map} +1 -1
  13. package/dist/{ConnectedNativeDocxEditor-RUABE4VP.cjs → ConnectedNativeDocxEditor-74PFGTMR.cjs} +11 -11
  14. package/dist/{ConnectedNativeDocxEditor-RUABE4VP.cjs.map → ConnectedNativeDocxEditor-74PFGTMR.cjs.map} +1 -1
  15. package/dist/{ConnectedNativeDocxEditor-BLMQUKP7.js → ConnectedNativeDocxEditor-YBHAQQSY.js} +9 -9
  16. package/dist/{ConnectedNativeDocxEditor-BLMQUKP7.js.map → ConnectedNativeDocxEditor-YBHAQQSY.js.map} +1 -1
  17. package/dist/{ConnectedStreamedWordArtifact-I2XIXZFY.cjs → ConnectedStreamedWordArtifact-63ME4QD5.cjs} +11 -11
  18. package/dist/ConnectedStreamedWordArtifact-63ME4QD5.cjs.map +1 -0
  19. package/dist/{ConnectedStreamedWordArtifact-F66VKPLJ.js → ConnectedStreamedWordArtifact-ELHQ2VYL.js} +10 -10
  20. package/dist/ConnectedStreamedWordArtifact-ELHQ2VYL.js.map +1 -0
  21. package/dist/NativeDocxEditor-ATPL3Q3O.js +1 -1
  22. package/dist/NativeDocxEditor-R4EIHWNL.cjs +1 -1
  23. package/dist/{WorkspaceTableView-YOZPUVBW.js → WorkspaceTableView-3TIMUU2J.js} +6 -6
  24. package/dist/{WorkspaceTableView-YOZPUVBW.js.map → WorkspaceTableView-3TIMUU2J.js.map} +1 -1
  25. package/dist/{WorkspaceTableView-56W7D7UC.cjs → WorkspaceTableView-FROHEPCT.cjs} +8 -8
  26. package/dist/{WorkspaceTableView-56W7D7UC.cjs.map → WorkspaceTableView-FROHEPCT.cjs.map} +1 -1
  27. package/dist/agents/index.cjs +330 -330
  28. package/dist/agents/index.js +8 -8
  29. package/dist/calls/index.cjs +2 -2
  30. package/dist/calls/index.js +2 -2
  31. package/dist/chat/DraftingDocChip.d.ts +7 -2
  32. package/dist/chat/index.cjs +63 -63
  33. package/dist/chat/index.js +1 -1
  34. package/dist/{chunk-I23WVKEX.js → chunk-2A2QX3MS.js} +5 -5
  35. package/dist/{chunk-I23WVKEX.js.map → chunk-2A2QX3MS.js.map} +1 -1
  36. package/dist/{chunk-7F6P3GYU.cjs → chunk-2CTG4DHL.cjs} +5 -5
  37. package/dist/{chunk-7F6P3GYU.cjs.map → chunk-2CTG4DHL.cjs.map} +1 -1
  38. package/dist/{chunk-PGZJ7JPX.cjs → chunk-32W6STZ2.cjs} +5 -5
  39. package/dist/{chunk-PGZJ7JPX.cjs.map → chunk-32W6STZ2.cjs.map} +1 -1
  40. package/dist/{chunk-AOXEVFKP.js → chunk-3IQUMSJI.js} +3 -3
  41. package/dist/{chunk-AOXEVFKP.js.map → chunk-3IQUMSJI.js.map} +1 -1
  42. package/dist/{chunk-3XM3IS26.js → chunk-4MQKXHMC.js} +3 -3
  43. package/dist/{chunk-3XM3IS26.js.map → chunk-4MQKXHMC.js.map} +1 -1
  44. package/dist/{chunk-6RNNLWCU.cjs → chunk-54RSCDE6.cjs} +3 -3
  45. package/dist/{chunk-6RNNLWCU.cjs.map → chunk-54RSCDE6.cjs.map} +1 -1
  46. package/dist/{chunk-US43A35W.cjs → chunk-6HPBSKXG.cjs} +4 -4
  47. package/dist/{chunk-US43A35W.cjs.map → chunk-6HPBSKXG.cjs.map} +1 -1
  48. package/dist/{chunk-OBOWJBHS.js → chunk-AQ2XKOQ7.js} +3 -3
  49. package/dist/{chunk-OBOWJBHS.js.map → chunk-AQ2XKOQ7.js.map} +1 -1
  50. package/dist/{chunk-I7N5PRTQ.cjs → chunk-AY66THUZ.cjs} +12 -12
  51. package/dist/{chunk-I7N5PRTQ.cjs.map → chunk-AY66THUZ.cjs.map} +1 -1
  52. package/dist/{chunk-GWA4N43X.cjs → chunk-DAEDRTIN.cjs} +3 -3
  53. package/dist/{chunk-GWA4N43X.cjs.map → chunk-DAEDRTIN.cjs.map} +1 -1
  54. package/dist/{chunk-AP5WW4XJ.js → chunk-FEYRHZYB.js} +6 -6
  55. package/dist/{chunk-AP5WW4XJ.js.map → chunk-FEYRHZYB.js.map} +1 -1
  56. package/dist/{chunk-OWRQLGRM.js → chunk-IK4AWPDW.js} +3 -3
  57. package/dist/{chunk-OWRQLGRM.js.map → chunk-IK4AWPDW.js.map} +1 -1
  58. package/dist/{chunk-JVPFKYXE.cjs → chunk-L22BJYHL.cjs} +3 -3
  59. package/dist/{chunk-JVPFKYXE.cjs.map → chunk-L22BJYHL.cjs.map} +1 -1
  60. package/dist/{chunk-SGDM6ZVT.cjs → chunk-LPUQHIVP.cjs} +3 -3
  61. package/dist/{chunk-SGDM6ZVT.cjs.map → chunk-LPUQHIVP.cjs.map} +1 -1
  62. package/dist/{chunk-I4BGKX2H.js → chunk-LSKTOCKN.js} +4 -4
  63. package/dist/{chunk-I4BGKX2H.js.map → chunk-LSKTOCKN.js.map} +1 -1
  64. package/dist/{chunk-ZNFTHDL2.cjs → chunk-M6Z7HTJ2.cjs} +5 -5
  65. package/dist/{chunk-ZNFTHDL2.cjs.map → chunk-M6Z7HTJ2.cjs.map} +1 -1
  66. package/dist/{chunk-4VAPCCUZ.cjs → chunk-M7LMEVXY.cjs} +50 -50
  67. package/dist/{chunk-4VAPCCUZ.cjs.map → chunk-M7LMEVXY.cjs.map} +1 -1
  68. package/dist/{chunk-6LPLKK32.js → chunk-NHY4AKA4.js} +3 -3
  69. package/dist/{chunk-6LPLKK32.js.map → chunk-NHY4AKA4.js.map} +1 -1
  70. package/dist/{chunk-PU7CEHTL.cjs → chunk-OBAVNGTL.cjs} +16 -7
  71. package/dist/chunk-OBAVNGTL.cjs.map +1 -0
  72. package/dist/{chunk-NKBVMHE3.cjs → chunk-PSTA227J.cjs} +8 -8
  73. package/dist/{chunk-NKBVMHE3.cjs.map → chunk-PSTA227J.cjs.map} +1 -1
  74. package/dist/{chunk-W76ZUOZO.js → chunk-QH4OY5GP.js} +3 -3
  75. package/dist/{chunk-W76ZUOZO.js.map → chunk-QH4OY5GP.js.map} +1 -1
  76. package/dist/{chunk-AJXGZV5G.cjs → chunk-QIY3ZHD2.cjs} +3 -3
  77. package/dist/{chunk-AJXGZV5G.cjs.map → chunk-QIY3ZHD2.cjs.map} +1 -1
  78. package/dist/{chunk-MWQFMVX7.js → chunk-RC2REIM4.js} +3 -3
  79. package/dist/{chunk-MWQFMVX7.js.map → chunk-RC2REIM4.js.map} +1 -1
  80. package/dist/{chunk-2UAHEONJ.js → chunk-S4KPVLHO.js} +3 -3
  81. package/dist/{chunk-2UAHEONJ.js.map → chunk-S4KPVLHO.js.map} +1 -1
  82. package/dist/{chunk-AXVVXAOY.cjs → chunk-TUODUKDK.cjs} +4 -4
  83. package/dist/{chunk-AXVVXAOY.cjs.map → chunk-TUODUKDK.cjs.map} +1 -1
  84. package/dist/{chunk-3FKM4G2T.js → chunk-VDXVTQOF.js} +16 -7
  85. package/dist/chunk-VDXVTQOF.js.map +1 -0
  86. package/dist/{chunk-6H2V4A33.cjs → chunk-WB4B6TSW.cjs} +4 -4
  87. package/dist/{chunk-6H2V4A33.cjs.map → chunk-WB4B6TSW.cjs.map} +1 -1
  88. package/dist/{chunk-BFKHJZ3P.js → chunk-X5FS27BM.js} +3 -3
  89. package/dist/{chunk-BFKHJZ3P.js.map → chunk-X5FS27BM.js.map} +1 -1
  90. package/dist/{chunk-V2NEQGHA.js → chunk-XHJAYCPQ.js} +3 -3
  91. package/dist/{chunk-V2NEQGHA.js.map → chunk-XHJAYCPQ.js.map} +1 -1
  92. package/dist/{chunk-LBJYN5TJ.js → chunk-Z7KGBVKI.js} +6 -6
  93. package/dist/{chunk-LBJYN5TJ.js.map → chunk-Z7KGBVKI.js.map} +1 -1
  94. package/dist/collaboration/index.cjs +1 -1
  95. package/dist/collaboration/index.js +1 -1
  96. package/dist/connect/docx.cjs +13 -13
  97. package/dist/connect/docx.js +9 -9
  98. package/dist/connect/index.cjs +820 -813
  99. package/dist/connect/index.cjs.map +1 -1
  100. package/dist/connect/index.js +36 -29
  101. package/dist/connect/index.js.map +1 -1
  102. package/dist/connect/viewer.cjs +78 -78
  103. package/dist/connect/viewer.cjs.map +1 -1
  104. package/dist/connect/viewer.js +17 -17
  105. package/dist/connect/viewer.js.map +1 -1
  106. package/dist/connection/config/useDeveloperConfig.d.ts +3 -3
  107. package/dist/connection/config/useModelPicker.d.ts +12 -12
  108. package/dist/document-tools/index.cjs +19 -19
  109. package/dist/document-tools/index.js +2 -2
  110. package/dist/docx/index.cjs +1 -1
  111. package/dist/docx/index.js +1 -1
  112. package/dist/facts/index.cjs +1 -1
  113. package/dist/facts/index.js +1 -1
  114. package/dist/files/index.cjs +224 -224
  115. package/dist/files/index.js +4 -4
  116. package/dist/index.cjs +521 -521
  117. package/dist/index.js +15 -15
  118. package/dist/settings/index.cjs +155 -155
  119. package/dist/settings/index.js +2 -2
  120. package/dist/shell/index.cjs +11 -11
  121. package/dist/shell/index.js +3 -3
  122. package/dist/site/index.cjs +22 -22
  123. package/dist/site/index.js +2 -2
  124. package/dist/studio/index.cjs +9 -9
  125. package/dist/studio/index.js +8 -8
  126. package/dist/workflow-canvas/index.cjs +22 -22
  127. package/dist/workflow-canvas/index.js +9 -9
  128. package/node_modules/@arbidocs/coedit/package.json +1 -1
  129. package/package.json +5 -5
  130. package/src/docx/README.md +4 -1
  131. package/dist/ConnectedStreamedWordArtifact-F66VKPLJ.js.map +0 -1
  132. package/dist/ConnectedStreamedWordArtifact-I2XIXZFY.cjs.map +0 -1
  133. package/dist/chunk-3FKM4G2T.js.map +0 -1
  134. package/dist/chunk-PU7CEHTL.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkNMZI3K6R_cjs = require('./chunk-NMZI3K6R.cjs');
5
4
  var chunkUWIILWDI_cjs = require('./chunk-UWIILWDI.cjs');
5
+ var chunkNMZI3K6R_cjs = require('./chunk-NMZI3K6R.cjs');
6
6
  var chunkJPWPR6QU_cjs = require('./chunk-JPWPR6QU.cjs');
7
7
  var chunkZAVEMQ37_cjs = require('./chunk-ZAVEMQ37.cjs');
8
8
  var lucideReact = require('lucide-react');
@@ -861,5 +861,5 @@ exports.SignatureStatus = SignatureStatus;
861
861
  exports.SignedEditNote = SignedEditNote;
862
862
  exports.VersionSnapshotBar = VersionSnapshotBar;
863
863
  exports.formatSignedAt = formatSignedAt;
864
- //# sourceMappingURL=chunk-SGDM6ZVT.cjs.map
865
- //# sourceMappingURL=chunk-SGDM6ZVT.cjs.map
864
+ //# sourceMappingURL=chunk-LPUQHIVP.cjs.map
865
+ //# sourceMappingURL=chunk-LPUQHIVP.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/document-tools/DocumentToolButtons.tsx","../src/document-tools/MarkupNotices.tsx","../src/document-tools/MarkupViewNote.tsx","../src/document-tools/SignatureStatus.tsx","../src/document-tools/SignatureCertificate.tsx","../src/document-tools/VersionSnapshotBar.tsx","../src/document-tools/PlaceMySignatureButton.tsx","../src/document-tools/SavedSignatureSettings.tsx","../src/document-tools/SignatureRequestBanner.tsx"],"names":["jsxs","Button","jsx","PencilLine","FileText","Download","PenLine","Users","Fragment","ViewerStatusNote","useOptionalDocumentTools","Popover","PopoverTrigger","PopoverContent","certificateLink","useState","useRef","matchSignedCopy","cn","LINK","useDocumentTools","fetchSavedSignature","DropdownMenu","DropdownMenuTrigger","Signature","DropdownMenuContent","DropdownMenuItem","DropdownMenuSeparator","DropdownMenuLabel","INFORMAL_SIGNATURE_NOTE","AdoptSignatureDialog","storeSavedSignature","useSavedSignature","useStoreSavedSignature","useDeleteSavedSignature","SettingsCard","Trash2","ConfirmDialog","SIGNER_PROGRESS_LABELS","useDocumentSignatureRequests","useVoidSignatureRequest","useInviteSigners","useSignerCandidates","Send","FilePenLine"],"mappings":";;;;;;;;;;;;AAUA,IAAM,KAAA,GAAQ,yBAAA;AAUP,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,OAAA,EAAS,SAAQ,EAA8B;AACtF,EAAA,uBACEA,eAAA;AAAA,IAACC,SAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,QAAA;AAAA,MACL,OAAA,EAAS,SAAS,SAAA,GAAY,SAAA;AAAA,MAC9B,IAAA,EAAM,UAAU,MAAA,GAAS,IAAA;AAAA,MACzB,cAAA,EAAc,MAAA;AAAA,MACd,KAAA,EAAM,6CAAA;AAAA,MACN,YAAA,EAAW,UAAA;AAAA,M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A,EAAU,SAAA,EAAU,QAAA,EAAA;AAAA,gBAAA,2BAAA;AAAA,gBACE,EAAE,MAAA,CAAO,MAAA;AAAA,gBAAO,QAAA;AAAA,gBAAO,CAAA,CAAE,MAAA,CAAO,MAAA,KAAW,CAAA,GAAI,EAAA,GAAK,GAAA;AAAA,gBAAI;AAAA,eAAA,EAEpF,CAAA;AAAA,8BACAE,cAAAA,CAACD,SAAAA,EAAA,EAAO,MAAK,QAAA,EAAS,IAAA,EAAK,IAAA,EAAK,OAAA,EAAQ,WAAU,OAAA,EAAS,MAAM,WAAA,CAAY,CAAC,GAAG,QAAA,EAAA,UAAA,EAEjF,CAAA;AAAA,8BACAC,cAAAA;AAAA,gBAACD,SAAAA;AAAA,gBAAA;AAAA,kBACC,IAAA,EAAK,QAAA;AAAA,kBACL,IAAA,EAAK,IAAA;AAAA,kBACL,OAAA,EAAQ,OAAA;AAAA,kBACR,OAAA,EAAS,MAAM,MAAA,CAAO,CAAC,CAAA;AAAA,kBACvB,UAAU,WAAA,CAAY,SAAA;AAAA,kBACvB,QAAA,EAAA;AAAA;AAAA;AAED;AAAA,WAAA;AAAA,UApBK,CAAA,CAAE;AAAA,SAsBV;AAAA;AAAA;AAAA,GACH;AAEJ","file":"chunk-SGDM6ZVT.cjs","sourcesContent":["/**\n * The viewer-header buttons of the PDF document tools: Annotate, Show original, Download with\n * markup and Sign. Separate parts so a host can place them among its own header actions. On a\n * narrow (`compact`) header each is icon-only; its accessible name stays.\n */\n\nimport type { ReactElement } from 'react'\nimport { Download, FileText, PenLine, PencilLine, Users } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\n\nconst TOUCH = 'pointer-coarse:min-h-11'\n\ninterface ToggleProps {\n /** On (pressed). */\n active: boolean\n onClick: () => void\n compact?: boolean\n}\n\n/** Annotate mode: highlight, comment, stamp, redact. */\nexport function AnnotateButton({ active, onClick, compact }: ToggleProps): ReactElement {\n return (\n <Button\n type=\"button\"\n variant={active ? 'default' : 'outline'}\n size={compact ? 'icon' : 'sm'}\n aria-pressed={active}\n title=\"Annotate: highlight, comment, stamp, redact\"\n aria-label=\"Annotate\"\n data-testid=\"annotate-toggle\"\n className={TOUCH}\n onClick={onClick}\n >\n <PencilLine className=\"size-4\" />\n {!compact && <span className=\"ml-1\">Annotate</span>}\n </Button>\n )\n}\n\n/** The markup is the default view of a marked-up PDF; this shows the untouched file. */\nexport function ShowOriginalButton({ active, onClick, compact }: ToggleProps): ReactElement {\n return (\n <Button\n type=\"button\"\n variant={active ? 'default' : 'outline'}\n size={compact ? 'icon' : 'sm'}\n aria-pressed={active}\n title={active ? 'Show the markup again' : 'Show the original, without markup'}\n aria-label=\"Show original\"\n data-testid=\"markup-show-original\"\n className={TOUCH}\n onClick={onClick}\n >\n <FileText className=\"size-4\" />\n {!compact && <span className=\"ml-1\">Show original</span>}\n </Button>\n )\n}\n\n/**\n * \"Download with markup\": the PDF with its annotations, which Acrobat and Preview show. With a\n * `disabledReason` (a signed, locked version) it is off and says why.\n */\nexport function DownloadMarkupButton({\n onClick,\n disabledReason,\n}: {\n onClick: () => void\n disabledReason?: string\n}): ReactElement {\n const button = (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"icon\"\n title={\n disabledReason ??\n 'Download with markup: the PDF with its annotations (opens in Acrobat or Preview)'\n }\n aria-label=\"Download with markup\"\n aria-description={disabledReason}\n disabled={!!disabledReason}\n data-testid=\"markup-download\"\n className={TOUCH}\n onClick={onClick}\n >\n <Download className=\"size-4\" />\n </Button>\n )\n // A disabled button gets no pointer events, so the reason sits on a wrapper too.\n return disabledReason ? (\n <span title={disabledReason} className=\"inline-flex\" data-testid=\"markup-download-locked\">\n {button}\n </span>\n ) : (\n button\n )\n}\n\n/** One line where a signed version's content can be edited: an edit is a new, unsigned version. */\nexport function SignedEditNote(): ReactElement {\n return (\n <p\n className=\"border-b px-3 py-1.5 text-xs text-muted-foreground\"\n data-testid=\"signed-edit-note\"\n >\n Editing creates a new unsigned version\n </p>\n )\n}\n\n/** Sign: choose where the signature goes, then sign. */\nexport function SignButton({ active, onClick, compact }: ToggleProps): ReactElement {\n return (\n <Button\n type=\"button\"\n variant={active ? 'default' : 'outline'}\n size={compact ? 'icon' : 'sm'}\n aria-pressed={active}\n title=\"Sign document\"\n aria-label=\"Sign\"\n data-testid=\"sign-document-button\"\n className={TOUCH}\n onClick={onClick}\n >\n <PenLine className=\"size-4\" />\n {!compact && <span className=\"ml-1\">Sign</span>}\n </Button>\n )\n}\n\n/** Prepare the document for others to sign: place their fields and send it. */\nexport function RequestSignaturesButton({ active, onClick, compact }: ToggleProps): ReactElement {\n return (\n <Button\n type=\"button\"\n variant={active ? 'default' : 'outline'}\n size={compact ? 'icon' : 'sm'}\n aria-pressed={active}\n title=\"Request signatures\"\n aria-label=\"Request signatures\"\n data-testid=\"request-signatures-button\"\n className={TOUCH}\n onClick={onClick}\n >\n <Users className=\"size-4\" />\n {!compact && <span className=\"ml-1\">Request signatures</span>}\n </Button>\n )\n}\n","/**\n * The one-line notices above the PDF about its markup: annotations found in this browser from\n * before markup was saved on the server (for a shared document: add them to the shared markup, or\n * discard), and markup that sits on an older version (open it, or copy its open comments here).\n */\n\nimport type { LegacyPrompt, OlderMarkupNote } from '@arbidocs/react/document-tools'\n\nconst BAR = 'flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2 text-xs'\nconst LINK =\n 'font-medium text-primary hover:underline disabled:opacity-50 disabled:no-underline pointer-coarse:min-h-11'\n\nexport interface MarkupNoticesProps {\n legacyPrompt: LegacyPrompt | null\n olderNote: OlderMarkupNote | null\n onOpenVersion: (version: number) => void\n}\n\nexport function MarkupNotices({ legacyPrompt, olderNote, onOpenVersion }: MarkupNoticesProps) {\n return (\n <>\n {legacyPrompt && (\n <div className={BAR} role=\"status\" data-testid=\"markup-migration-prompt\">\n <span>\n {legacyPrompt.count} annotation{legacyPrompt.count === 1 ? '' : 's'} on this document\n {legacyPrompt.count === 1 ? ' is' : ' are'} saved only in this browser. Add{' '}\n {legacyPrompt.count === 1 ? 'it' : 'them'} to the shared markup, where everyone with\n access sees {legacyPrompt.count === 1 ? 'it' : 'them'}?\n </span>\n <span className=\"flex items-center gap-3\">\n <button\n type=\"button\"\n className={LINK}\n disabled={legacyPrompt.busy}\n data-testid=\"markup-migration-add\"\n onClick={legacyPrompt.add}\n >\n {legacyPrompt.busy ? 'Adding…' : 'Add to shared markup'}\n </button>\n <button\n type=\"button\"\n className={LINK}\n disabled={legacyPrompt.busy}\n data-testid=\"markup-migration-discard\"\n onClick={legacyPrompt.discard}\n >\n Discard\n </button>\n </span>\n </div>\n )}\n {olderNote && (\n <div className={BAR} data-testid=\"markup-older-version-note\">\n <span>\n The markup is on version {olderNote.version}. This version started without it.\n {olderNote.signed && (\n <span data-testid=\"markup-older-version-signed\">\n {' '}\n It is signed: comments copied here are kept beside it, and the signed PDF does not\n change.\n </span>\n )}\n </span>\n <span className=\"flex items-center gap-3\">\n <button\n type=\"button\"\n className={LINK}\n data-testid=\"markup-open-older-version\"\n onClick={() => onOpenVersion(olderNote.version)}\n >\n Open version {olderNote.version}\n </button>\n <button\n type=\"button\"\n className={LINK}\n disabled={olderNote.busy}\n data-testid=\"markup-copy-open-threads\"\n title=\"Copy the unresolved comment threads onto this version (redactions never carry over)\"\n onClick={olderNote.copy}\n >\n {olderNote.busy ? 'Copying…' : 'Copy open comments here'}\n </button>\n </span>\n </div>\n )}\n </>\n )\n}\n","/**\n * Which view of a marked-up PDF is on screen, spelled out beside the title, with the switch to the\n * other one. The narrow header's \"Show original\" is an unlabelled page icon, so on its own it read\n * as no control at all, and nothing said whether the page showed the markup or the original.\n */\n\nimport type { ReactElement } from 'react'\nimport { ViewerStatusNote } from '../files/ViewerLayout'\n\nexport interface MarkupViewNoteProps {\n showOriginal: boolean\n onToggle: () => void\n}\n\nexport function MarkupViewNote({ showOriginal, onToggle }: MarkupViewNoteProps): ReactElement {\n return (\n <ViewerStatusNote testId=\"markup-view-note\">\n {showOriginal ? 'Original, without markup' : 'With markup'}\n {' · '}\n <button\n type=\"button\"\n className=\"font-medium text-primary hover:underline pointer-coarse:min-h-11\"\n data-testid=\"markup-view-note-toggle\"\n onClick={onToggle}\n >\n {showOriginal ? 'Show markup' : 'Show original'}\n </button>\n </ViewerStatusNote>\n )\n}\n","/**\n * The \"Signed — locked\" note in the viewer header (a signed version changes only by a further\n * signature), which opens the signature details: who signed and when,\n * whether the document is unchanged since, and \"View certificate\", the public page anyone can\n * check the signature on (the same page the signature on the PDF links to). Read from the PDF\n * itself (GET .../signatures). A counter-signed copy lists every signature, oldest first.\n */\n\nimport type { ReactElement, ReactNode } from 'react'\nimport {\n certificateLink,\n useOptionalDocumentTools,\n type SignatureStatusResponse,\n} from '@arbidocs/react/document-tools'\nimport { Popover, PopoverContent, PopoverTrigger } from '@arbidocs/react/ui'\n\n/** \"14 Oct 2026, 12:00\" in the reader's locale and time zone. */\nexport function formatSignedAt(iso: string): string {\n const date = new Date(iso)\n if (Number.isNaN(date.getTime())) return iso\n return date.toLocaleString([], { dateStyle: 'medium', timeStyle: 'short' })\n}\n\nexport interface SignatureStatusProps {\n status: SignatureStatusResponse\n /** How the signing time is shown. Default: {@link formatSignedAt}. */\n formatDate?: (iso: string) => string\n /**\n * The certificate page of a signature in this app. Preferred over the `certificate_url` the API\n * returns (which is on the deployment domain). Default: the enclosing `<DocumentToolsProvider>`'s\n * `certificateUrl`, if any; without either, the API's `certificate_url`, else\n * `/verify/{reference}` on this origin.\n */\n certificateUrl?: (reference: string) => string\n}\n\nfunction Row({ label, field, children }: { label: string; field: string; children: ReactNode }) {\n return (\n <div className=\"grid grid-cols-[5.5rem_1fr] gap-2\">\n <dt className=\"text-muted-foreground\">{label}</dt>\n <dd className=\"min-w-0 break-words\" data-testid={`signature-detail-${field}`}>\n {children}\n </dd>\n </div>\n )\n}\n\nexport function SignatureStatus({\n status,\n formatDate = formatSignedAt,\n certificateUrl,\n}: SignatureStatusProps): ReactElement {\n const tools = useOptionalDocumentTools()\n const hostCertificateUrl = certificateUrl ?? tools?.certificateUrl\n const signatures = status.signatures ?? []\n // A signed copy can be counter-signed: each signature is listed, oldest first.\n const isCounterSigned = signatures.length > 1\n return (\n <Popover>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n className=\"flex-shrink-0 text-sm text-muted-foreground underline decoration-dotted underline-offset-4 hover:text-foreground pointer-coarse:min-h-11\"\n data-testid=\"document-signature-status\"\n aria-label={`${status.intact ? 'Signed, locked' : 'Modified after signing'}: show signature details`}\n >\n {status.intact ? 'Signed — locked' : 'Modified after signing'}\n </button>\n </PopoverTrigger>\n <PopoverContent\n className=\"max-h-[70vh] w-80 overflow-y-auto p-3 text-sm\"\n align=\"start\"\n data-testid=\"signature-details\"\n >\n <p className=\"mb-2 font-medium\" data-testid=\"signature-details-title\">\n {isCounterSigned\n ? `Electronic signatures (${signatures.length})`\n : 'Electronic signature'}\n </p>\n {signatures.map((signature, index) => (\n <dl\n key={signature.reference}\n className={`mb-3 space-y-1 ${index > 0 ? 'border-t border-border pt-2' : ''}`}\n data-testid={`signature-item-${index}`}\n >\n <Row label=\"Signed by\" field=\"signer\">\n {signature.signer_name || signature.signer_email}\n </Row>\n <Row label=\"On\" field=\"time\">\n {formatDate(signature.signed_at)}\n </Row>\n <dd>\n <a\n href={certificateLink(signature, hostCertificateUrl)}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center font-medium text-primary hover:underline pointer-coarse:min-h-11\"\n data-testid={`signature-certificate-link-${index}`}\n >\n View certificate\n </a>\n </dd>\n </dl>\n ))}\n <p\n className={`border-t border-border pt-2 ${status.intact ? '' : 'text-red-text'}`}\n data-testid=\"signature-detail-intact\"\n >\n {status.intact\n ? isCounterSigned\n ? '✓ Unchanged since the last signature'\n : '✓ Unchanged since signing'\n : '✗ Changed after it was signed'}\n </p>\n <p className=\"mt-1 text-xs text-muted-foreground\" data-testid=\"signature-detail-locked\">\n Locked: only further signatures can be added.\n </p>\n </PopoverContent>\n </Popover>\n )\n}\n","/**\n * The certificate of an ARBI signature: the page the link on a signed PDF's signature opens, for\n * anyone, signed in or not. Plain English and short: who signed and when, what ARBI checks, the\n * result, any counter-signatures, and \"Check your copy\", which hashes a PDF in the browser and\n * compares it with the signed document and each signed revision (the file never leaves the\n * device). No email addresses and no\n * document content. Presentational: `verification` comes from `useSignatureVerification` in\n * `@arbidocs/react/document-tools`.\n */\n\nimport { useRef, useState, type DragEvent, type ReactElement, type ReactNode } from 'react'\nimport {\n matchSignedCopy,\n type CopyMatch,\n type SignatureVerification,\n} from '@arbidocs/react/document-tools'\nimport { cn } from '@arbidocs/react/ui'\nimport { formatSignedAt } from './SignatureStatus'\n\nexport interface SignatureCertificateProps {\n /** The signature reference (`sig-…`), shown at the foot of the page. */\n reference?: string\n verification?: SignatureVerification\n isLoading?: boolean\n /** Why the signature could not be checked. */\n error?: string | null\n /** The error is a passing one (too many checks): say it calmly, not as a failure. */\n isErrorTransient?: boolean\n /** How signing times are shown. Default: {@link formatSignedAt}. */\n formatDate?: (iso: string) => string\n /** Offer \"Check your copy\". Default on. */\n allowCopyCheck?: boolean\n}\n\ntype CopyCheck =\n | { state: 'idle' }\n | { state: 'checking'; name: string }\n | { state: 'done'; name: string; match: CopyMatch }\n | { state: 'failed'; name: string }\n\nfunction Frame({ children }: { children: ReactNode }) {\n return (\n <main\n className=\"mx-auto w-full max-w-xl px-4 py-10 text-foreground\"\n data-testid=\"signature-certificate\"\n >\n <h1 className=\"mb-6 text-xl font-semibold\">Signature certificate</h1>\n {children}\n </main>\n )\n}\n\nfunction copyResult(name: string, match: CopyMatch): string {\n if (match.kind === 'current') return `✓ ${name} is the signed document, unchanged.`\n if (match.kind === 'earlier') {\n // A counter-signed PDF: the copy is an earlier signed revision, which is still genuine.\n return `✓ ${name}: this is the version signed by ${match.signature.signer_name || 'an ARBI user'}.`\n }\n return `✗ ${name} is not the signed document: it differs from what was signed.`\n}\n\nexport function SignatureCertificate({\n reference,\n verification,\n isLoading = false,\n error,\n isErrorTransient = false,\n formatDate = formatSignedAt,\n allowCopyCheck = true,\n}: SignatureCertificateProps): ReactElement {\n const [copy, setCopy] = useState<CopyCheck>({ state: 'idle' })\n const [dragging, setDragging] = useState(false)\n const input = useRef<HTMLInputElement>(null)\n\n if (isLoading) {\n return (\n <Frame>\n <p className=\"text-muted-foreground\" data-testid=\"signature-certificate-loading\">\n Checking the signature…\n </p>\n </Frame>\n )\n }\n if (error || !verification) {\n return (\n <Frame>\n <p\n className={isErrorTransient ? 'text-muted-foreground' : 'text-red-text'}\n role={isErrorTransient ? 'status' : 'alert'}\n data-testid=\"signature-certificate-error\"\n >\n {error || 'The signature could not be checked.'}\n </p>\n </Frame>\n )\n }\n\n const [first, ...counter] = verification.signatures\n const check = async (file: File | undefined) => {\n if (!file) return\n setCopy({ state: 'checking', name: file.name })\n try {\n setCopy({ state: 'done', name: file.name, match: await matchSignedCopy(file, verification) })\n } catch {\n setCopy({ state: 'failed', name: file.name })\n }\n }\n const onDrop = (e: DragEvent) => {\n e.preventDefault()\n setDragging(false)\n void check(e.dataTransfer.files[0])\n }\n\n return (\n <Frame>\n <section className=\"space-y-3\">\n {first && (\n <p className=\"text-base\" data-testid=\"signature-certificate-signer\">\n Signed by <strong>{first.signer_name || 'an ARBI user'}</strong> on{' '}\n {formatDate(first.signed_at)}\n </p>\n )}\n {counter.length > 0 && (\n <ul className=\"space-y-1 text-sm\" data-testid=\"signature-certificate-counter\">\n {counter.map((s, i) => (\n <li key={`${s.sha256}-${i}`}>\n Also signed by <strong>{s.signer_name || 'an ARBI user'}</strong> on{' '}\n {formatDate(s.signed_at)}\n </li>\n ))}\n </ul>\n )}\n <p className=\"text-sm text-muted-foreground\">\n ARBI checks that this document hasn’t changed since it was signed. If anything changed,\n this check fails.\n </p>\n <p\n className={cn(\n 'rounded-md border px-3 py-2 font-medium',\n verification.intact\n ? 'border-green-border bg-green-bg text-green-text'\n : 'border-red-text text-red-text'\n )}\n role=\"status\"\n data-testid=\"signature-certificate-result\"\n data-intact={verification.intact}\n >\n {verification.intact\n ? '✓ Unchanged since signing'\n : '✗ Changed since signing: this is not the document that was signed'}\n </p>\n </section>\n\n {allowCopyCheck && (\n <section className=\"mt-8 space-y-2\">\n <h2 className=\"text-sm font-medium\">Check your copy</h2>\n <div\n role=\"button\"\n tabIndex={0}\n className={cn(\n 'flex min-h-24 cursor-pointer flex-col items-center justify-center rounded-md border border-dashed px-4 py-6 text-center text-sm text-muted-foreground pointer-coarse:min-h-32',\n dragging && 'border-primary bg-muted'\n )}\n data-testid=\"signature-certificate-dropzone\"\n onClick={() => input.current?.click()}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n input.current?.click()\n }\n }}\n onDragOver={(e) => {\n e.preventDefault()\n setDragging(true)\n }}\n onDragLeave={() => setDragging(false)}\n onDrop={onDrop}\n >\n Drop the PDF you were sent here, or choose it\n <span className=\"mt-1 text-xs\">It is checked in this browser and never uploaded.</span>\n <input\n ref={input}\n type=\"file\"\n accept=\"application/pdf,.pdf\"\n className=\"sr-only\"\n data-testid=\"signature-certificate-file-input\"\n onChange={(e) => void check(e.target.files?.[0])}\n />\n </div>\n {copy.state !== 'idle' && (\n <p\n className={cn(\n 'text-sm',\n copy.state === 'done' && copy.match.kind !== 'none' && 'text-green-text',\n ((copy.state === 'done' && copy.match.kind === 'none') ||\n copy.state === 'failed') &&\n 'text-red-text'\n )}\n role=\"status\"\n data-testid=\"signature-certificate-copy-result\"\n >\n {copy.state === 'checking'\n ? `Checking ${copy.name}…`\n : copy.state === 'failed'\n ? `${copy.name} could not be read.`\n : copyResult(copy.name, copy.match)}\n </p>\n )}\n </section>\n )}\n\n {reference && (\n <p\n className=\"mt-8 text-xs text-muted-foreground\"\n data-testid=\"signature-certificate-reference\"\n >\n Reference {reference}\n </p>\n )}\n </Frame>\n )\n}\n","/**\n * The bar above an older version opened read-only: which version it is, \"Ask about this version\"\n * (when the host has an assistant) and the way back to the current version. Put it in the viewer's\n * sticky header, not the content area: a PDF view scrolls its first page into view, which would\n * scroll a bar above it out of sight.\n */\n\nimport type { ReactElement } from 'react'\n\nconst LINK = 'font-medium text-primary hover:underline pointer-coarse:min-h-11'\n\nexport interface VersionSnapshotBarLabels {\n /** `Version 2 · read only`; `number` is undefined when the version is not known. */\n title: (number: number | undefined) => string\n ask: string\n returnToCurrent: string\n /** For documents edited live (Word, artifacts), where \"current\" is the live document. */\n returnToLive: string\n}\n\nexport const DEFAULT_VERSION_SNAPSHOT_BAR_LABELS: VersionSnapshotBarLabels = {\n title: (number) => `${number ? `Version ${number}` : 'Saved version'} · read only`,\n ask: 'Ask about this version',\n returnToCurrent: 'Return to current version',\n returnToLive: 'Return to live document',\n}\n\nexport interface VersionSnapshotBarProps {\n /** The version's number, when known. */\n versionNumber?: number\n /** The document is edited live: the way back says \"live document\". */\n live?: boolean\n /** Ask the assistant about this version. Omitted: no ask action. */\n onAsk?: () => void\n onReturn: () => void\n labels?: Partial<VersionSnapshotBarLabels>\n}\n\nexport function VersionSnapshotBar({\n versionNumber,\n live = false,\n onAsk,\n onReturn,\n labels: overrides,\n}: VersionSnapshotBarProps): ReactElement {\n const labels = { ...DEFAULT_VERSION_SNAPSHOT_BAR_LABELS, ...overrides }\n return (\n <div\n className=\"flex items-center justify-between border-b px-3 py-2 text-xs\"\n data-testid=\"version-snapshot-bar\"\n >\n <span>{labels.title(versionNumber)}</span>\n <span className=\"flex items-center gap-3\">\n {onAsk && (\n <button type=\"button\" className={LINK} data-testid=\"version-snapshot-ask\" onClick={onAsk}>\n {labels.ask}\n </button>\n )}\n <button\n type=\"button\"\n className={LINK}\n data-testid=\"version-snapshot-return\"\n onClick={onReturn}\n >\n {live ? labels.returnToLive : labels.returnToCurrent}\n </button>\n </span>\n </div>\n )\n}\n","/**\n * PDF tab › My signature: place one's own saved signature or initials on the page as a picture stamp\n * in the markup layer (then drag and resize it like any stamp). Nothing saved yet: the adopt dialog\n * opens first and saves it. An informal signature; verified signing is Request signatures. Needs a\n * `<DocumentToolsProvider>` inside a React Query `QueryClientProvider`.\n */\n\nimport { useState, type ReactElement } from 'react'\nimport { Signature } from 'lucide-react'\nimport {\n INFORMAL_SIGNATURE_NOTE,\n fetchSavedSignature,\n storeSavedSignature,\n useDocumentTools,\n type SavedSignature,\n} from '@arbidocs/react/document-tools'\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '@arbidocs/react/ui'\nimport { AdoptSignatureDialog } from './AdoptSignatureDialog'\n\nexport type PlacedMark = { image: string; label: string }\n\ntype Mark = 'signature' | 'initials'\n\nconst picked = (saved: SavedSignature, mark: Mark): PlacedMark =>\n mark === 'signature'\n ? { image: saved.signature_png, label: 'Signature' }\n : { image: saved.initials_png, label: 'Initials' }\n\nexport function PlaceMySignatureButton({\n onPlace,\n compact = false,\n}: {\n /** Arm the stamp tool with this picture: the next click on a page places it. */\n onPlace: (mark: PlacedMark) => void\n compact?: boolean\n}): ReactElement {\n const { client, user, notify } = useDocumentTools()\n const [adoptFor, setAdoptFor] = useState<Mark | null>(null)\n\n // Read when asked for (sealed with one's own key: opened here, in the browser).\n const place = async (mark: Mark) => {\n try {\n const saved = await fetchSavedSignature(client)\n if (saved) return onPlace(picked(saved, mark))\n setAdoptFor(mark)\n } catch (err) {\n notify(err instanceof Error ? err.message : 'Your saved signature could not be read', 'error')\n }\n }\n\n return (\n <>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size={compact ? 'icon' : 'sm'}\n title=\"Place my signature\"\n aria-label=\"Place my signature\"\n className=\"pointer-coarse:min-h-11\"\n data-testid=\"place-my-signature-button\"\n >\n <Signature className=\"size-4\" />\n {!compact && <span className=\"ml-1\">My signature</span>}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"max-w-72\">\n <DropdownMenuItem\n onSelect={() => void place('signature')}\n data-testid=\"place-my-signature\"\n >\n Place my signature\n </DropdownMenuItem>\n <DropdownMenuItem onSelect={() => void place('initials')} data-testid=\"place-my-initials\">\n Place my initials\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuLabel className=\"text-xs font-normal text-muted-foreground\">\n {INFORMAL_SIGNATURE_NOTE}\n </DropdownMenuLabel>\n </DropdownMenuContent>\n </DropdownMenu>\n <AdoptSignatureDialog\n open={!!adoptFor}\n onOpenChange={(open) => !open && setAdoptFor(null)}\n mode=\"save\"\n defaultName={user?.name ?? ''}\n onSave={async (signature) => {\n await storeSavedSignature(client, signature)\n const mark = adoptFor\n setAdoptFor(null)\n if (mark) onPlace(picked(signature, mark))\n }}\n onAdopt={() => notify('Your signature is saved. Click where it goes.', 'success')}\n />\n </>\n )\n}\n","/**\n * Account settings › Your signature: the signature and initials saved to the account (sealed with\n * the user's own key), with Replace (the adopt dialog, saving over it) and Delete (removed from the\n * account completely; what was already placed in documents or sealed in signed PDFs stays as it\n * is). Needs a `<DocumentToolsProvider>` inside a React Query `QueryClientProvider`.\n */\n\nimport { useState, type ReactElement } from 'react'\nimport { PenLine, Trash2 } from 'lucide-react'\nimport {\n INFORMAL_SIGNATURE_NOTE,\n useDeleteSavedSignature,\n useDocumentTools,\n useSavedSignature,\n useStoreSavedSignature,\n} from '@arbidocs/react/document-tools'\nimport { Button } from '@arbidocs/react/ui'\nimport { ConfirmDialog } from '../settings/ConfirmDialog'\nimport { SettingsCard } from '../settings/SettingsPanel'\nimport { AdoptSignatureDialog } from './AdoptSignatureDialog'\n\nexport const DELETE_SAVED_SIGNATURE_TEXT =\n 'Your saved signature and initials are removed from your account completely. Signatures you ' +\n 'already inserted into documents, and those sealed in signed PDFs, are not affected.'\n\nexport function SavedSignatureSettings(): ReactElement {\n const { user, notify } = useDocumentTools()\n const saved = useSavedSignature()\n const store = useStoreSavedSignature()\n const remove = useDeleteSavedSignature()\n const [editing, setEditing] = useState(false)\n const [confirming, setConfirming] = useState(false)\n const signature = saved.data\n\n return (\n <SettingsCard data-testid=\"saved-signature-settings\">\n <div className=\"space-y-1\">\n <h3 className=\"text-sm font-medium\">Your signature</h3>\n <p className=\"text-sm text-muted-foreground\">\n Saved to your account, sealed with your own key, to insert into Word documents and place\n on PDFs. {INFORMAL_SIGNATURE_NOTE}\n </p>\n </div>\n {signature ? (\n <div className=\"flex flex-wrap items-center gap-4\" data-testid=\"saved-signature-preview\">\n <img\n src={`data:image/png;base64,${signature.signature_png}`}\n alt=\"Your saved signature\"\n className=\"h-16 max-w-xs rounded-md border bg-white object-contain p-1\"\n />\n <img\n src={`data:image/png;base64,${signature.initials_png}`}\n alt=\"Your saved initials\"\n className=\"h-16 max-w-[8rem] rounded-md border bg-white object-contain p-1\"\n />\n </div>\n ) : (\n <p className=\"text-sm text-muted-foreground\" data-testid=\"saved-signature-none\">\n {saved.isLoading ? 'Loading…' : 'No signature saved.'}\n </p>\n )}\n <div className=\"flex gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => setEditing(true)}\n data-testid=\"saved-signature-replace\"\n >\n <PenLine className=\"mr-1 size-4\" aria-hidden />\n {signature ? 'Replace' : 'Add a signature'}\n </Button>\n {signature && (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => setConfirming(true)}\n data-testid=\"saved-signature-delete\"\n >\n <Trash2 className=\"mr-1 size-4\" aria-hidden />\n Delete\n </Button>\n )}\n </div>\n <AdoptSignatureDialog\n open={editing}\n onOpenChange={setEditing}\n mode=\"save\"\n defaultName={user?.name ?? ''}\n saved={signature ?? null}\n onSave={async (next) => void (await store.mutateAsync(next))}\n onAdopt={() => {\n setEditing(false)\n notify('Your signature is saved.', 'success')\n }}\n />\n <ConfirmDialog\n isOpen={confirming}\n onClose={() => setConfirming(false)}\n onConfirm={async () => {\n try {\n await remove.mutateAsync()\n notify('Your saved signature is deleted.', 'success')\n } catch (err) {\n notify(err instanceof Error ? err.message : 'Could not delete it', 'error')\n } finally {\n setConfirming(false)\n }\n }}\n title=\"Delete your saved signature?\"\n description={DELETE_SAVED_SIGNATURE_TEXT}\n confirmText=\"Delete\"\n variant=\"destructive\"\n isLoading={remove.isPending}\n testId=\"saved-signature-delete-confirm\"\n />\n </SettingsCard>\n )\n}\n\nexport default SavedSignatureSettings\n","/**\n * Where a document's signature requests stand, above the document: a request waiting for the\n * viewer's signature (with \"Review and sign\"), one the viewer sent and is waiting on others (who\n * has signed; void it), and the viewer's own draft (go on editing it). Nothing when there is none.\n * Needs a `<DocumentToolsProvider>` whose `user` has an `externalId`.\n */\n\nimport type { ReactElement } from 'react'\nimport { FilePenLine, PenLine, Send } from 'lucide-react'\nimport {\n SIGNER_PROGRESS_LABELS,\n useDocumentSignatureRequests,\n useDocumentTools,\n useInviteSigners,\n useSignerCandidates,\n useVoidSignatureRequest,\n type SignatureRequest,\n} from '@arbidocs/react/document-tools'\nimport { Button } from '@arbidocs/react/ui'\n\nexport interface SignatureRequestBannerProps {\n documentId: string\n /** Open the guided signing of a request waiting for the viewer. */\n onSign: (request: SignatureRequest) => void\n /** Go on editing the viewer's draft. */\n onEditDraft: (request: SignatureRequest) => void\n /** Hide it (e.g. while the editor or the guided signing is open). */\n hidden?: boolean\n}\n\n/** Who is still to sign, and how far each has got (\"Dana Day (invited)\"). */\nfunction waitingFor(request: SignatureRequest): string[] {\n return request.signers\n .filter((s) => s.status === 'pending')\n .map((s) => `${s.name || s.email || ''} (${SIGNER_PROGRESS_LABELS[s.progress].toLowerCase()})`)\n}\n\nexport function SignatureRequestBanner({\n documentId,\n onSign,\n onEditDraft,\n hidden = false,\n}: SignatureRequestBannerProps): ReactElement | null {\n const { user, notify } = useDocumentTools()\n const requests = useDocumentSignatureRequests(documentId, !hidden)\n const voidRequest = useVoidSignatureRequest()\n const invite = useInviteSigners()\n const me = user?.externalId ?? null\n const candidates = useSignerCandidates(!hidden && !!me)\n const isOwner = candidates.data?.some((c) => c.externalId === me && c.role === 'owner') ?? false\n if (hidden || !me || !requests.data) return null\n const open = requests.data.filter((r) => r.status === 'sent' || r.status === 'draft')\n const awaitingMe = open.filter(\n (r) =>\n r.status === 'sent' && r.signers.some((s) => s.user_ext_id === me && s.status === 'pending')\n )\n const sentByMe = open.filter(\n (r) => r.status === 'sent' && r.created_by === me && !awaitingMe.includes(r)\n )\n const drafts = open.filter((r) => r.status === 'draft' && r.created_by === me)\n if (awaitingMe.length + sentByMe.length + drafts.length === 0) return null\n\n const doVoid = async (request: SignatureRequest) => {\n try {\n await voidRequest.mutateAsync(request.external_id)\n notify(request.status === 'draft' ? 'Draft discarded.' : 'Signature request voided.', 'info')\n } catch (err) {\n notify(err instanceof Error ? err.message : 'Could not void it', 'error')\n }\n }\n\n return (\n <div\n className=\"space-y-1.5 border-b border-border px-3 py-2 text-sm\"\n data-testid=\"signature-request-banner\"\n >\n {awaitingMe.map((r) => {\n const count = r.fields.filter((f) => f.signer === me).length\n const author = r.signers.find((s) => s.user_ext_id === r.created_by)?.name\n return (\n <div\n key={r.external_id}\n className=\"flex flex-wrap items-center gap-2 rounded-md bg-blue-50 px-2 py-1.5 text-blue-950 dark:bg-blue-950/40 dark:text-blue-100\"\n data-testid=\"signature-request-awaiting-me\"\n >\n <PenLine className=\"size-4 shrink-0\" aria-hidden />\n <span className=\"mr-auto\">\n {author && r.created_by !== me\n ? `${author} asked you to sign`\n : 'You are asked to sign'}{' '}\n {count} field{count === 1 ? '' : 's'} in this document.\n {r.stale && ' It has changed since it was sent: ask for it again.'}\n </span>\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={() => onSign(r)}\n disabled={r.stale}\n data-testid=\"signature-request-start\"\n >\n Review and sign\n </Button>\n </div>\n )\n })}\n {sentByMe.map((r) => {\n const pending = waitingFor(r)\n const signed = r.signers.length - pending.length\n const invited = r.signers.filter((s) => s.progress === 'invited' && s.email)\n return (\n <div\n key={r.external_id}\n className=\"flex flex-wrap items-center gap-2\"\n data-testid=\"signature-request-sent\"\n >\n <Send className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden />\n <span className=\"mr-auto\">\n Out for signature: {signed} of {r.signers.length} signed\n {pending.length > 0 && (\n <span className=\"text-muted-foreground\"> · waiting for {pending.join(', ')}</span>\n )}\n {r.stale && (\n <span className=\"text-red-text\"> · the document has changed since it was sent</span>\n )}\n </span>\n {isOwner && invited.length > 0 && (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n disabled={invite.isPending}\n onClick={async () => {\n try {\n await invite.mutateAsync({\n documentId,\n emails: invited.map((s) => s.email!),\n })\n notify(\n 'Invited again: anyone already registered is added now and asked to sign.',\n 'success'\n )\n } catch (err) {\n notify(err instanceof Error ? err.message : 'Could not invite', 'error')\n }\n }}\n data-testid=\"signature-request-reinvite\"\n >\n Invite again\n </Button>\n )}\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => doVoid(r)}\n disabled={voidRequest.isPending}\n >\n Void\n </Button>\n </div>\n )\n })}\n {drafts.map((r) => (\n <div\n key={r.external_id}\n className=\"flex flex-wrap items-center gap-2\"\n data-testid=\"signature-request-draft\"\n >\n <FilePenLine className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden />\n <span className=\"mr-auto\">\n Draft signature request: {r.fields.length} field{r.fields.length === 1 ? '' : 's'}, not\n sent yet.\n </span>\n <Button type=\"button\" size=\"sm\" variant=\"outline\" onClick={() => onEditDraft(r)}>\n Continue\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => doVoid(r)}\n disabled={voidRequest.isPending}\n >\n Discard\n </Button>\n </div>\n ))}\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/document-tools/DocumentToolButtons.tsx","../src/document-tools/MarkupNotices.tsx","../src/document-tools/MarkupViewNote.tsx","../src/document-tools/SignatureStatus.tsx","../src/document-tools/SignatureCertificate.tsx","../src/document-tools/VersionSnapshotBar.tsx","../src/document-tools/PlaceMySignatureButton.tsx","../src/document-tools/SavedSignatureSettings.tsx","../src/document-tools/SignatureRequestBanner.tsx"],"names":["jsxs","Button","jsx","PencilLine","FileText","Download","PenLine","Users","Fragment","ViewerStatusNote","useOptionalDocumentTools","Popover","PopoverTrigger","PopoverContent","certificateLink","useState","useRef","matchSignedCopy","cn","LINK","useDocumentTools","fetchSavedSignature","DropdownMenu","DropdownMenuTrigger","Signature","DropdownMenuContent","DropdownMenuItem","DropdownMenuSeparator","DropdownMenuLabel","INFORMAL_SIGNATURE_NOTE","AdoptSignatureDialog","storeSavedSignature","useSavedSignature","useStoreSavedSignature","useDeleteSavedSignature","SettingsCard","Trash2","ConfirmDialog","SIGNER_PROGRESS_LABELS","useDocumentSignatureRequests","useVoidSignatureRequest","useInviteSigners","useSignerCandidates","Send","FilePenLine"],"mappings":";;;;;;;;;;;;AAUA,IAAM,KAAA,GAAQ,yBAAA;AAUP,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,OAAA,EAAS,SAAQ,EAA8B;AACtF,EAAA,uBACEA,eAAA;AAAA,IAACC,SAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,QAAA;AAAA,MACL,OAAA,EAAS,SAAS,SAAA,GAAY,SAAA;AAAA,MAC9B,IAAA,EAAM,UAAU,MAAA,GAAS,IAAA;AAAA,MACzB,cAAA,EAAc,MAAA;AAAA,MACd,KAAA,EAAM,6CAAA;AAAA,MACN,YAAA,EAAW,UAAA;AAAA,MACX,aAAA,EAAY,iBAAA;AAAA,MACZ,SAAA,EAAW,KAAA;AAAA,MACX,OAAA;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAAC,cAAA,CAACC,sBAAA,EAAA,EAAW,WAAU,QAAA,EAAS,CAAA;AAAA,QAC9B,CAAC,OAAA,oBAAWD,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,QAAO,QAAA,EAAA,UAAA,EAAQ;AAAA;AAAA;AAAA,GAC9C;AAEJ;AAGO,SAAS,kBAAA,CAAmB,EAAE,MAAA,EAAQ,OAAA,EAAS,S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,CAAC,GAAG,QAAA,EAAA,UAAA,EAEjF,CAAA;AAAA,8BACAC,cAAAA;AAAA,gBAACD,SAAAA;AAAA,gBAAA;AAAA,kBACC,IAAA,EAAK,QAAA;AAAA,kBACL,IAAA,EAAK,IAAA;AAAA,kBACL,OAAA,EAAQ,OAAA;AAAA,kBACR,OAAA,EAAS,MAAM,MAAA,CAAO,CAAC,CAAA;AAAA,kBACvB,UAAU,WAAA,CAAY,SAAA;AAAA,kBACvB,QAAA,EAAA;AAAA;AAAA;AAED;AAAA,WAAA;AAAA,UApBK,CAAA,CAAE;AAAA,SAsBV;AAAA;AAAA;AAAA,GACH;AAEJ","file":"chunk-LPUQHIVP.cjs","sourcesContent":["/**\n * The viewer-header buttons of the PDF document tools: Annotate, Show original, Download with\n * markup and Sign. Separate parts so a host can place them among its own header actions. On a\n * narrow (`compact`) header each is icon-only; its accessible name stays.\n */\n\nimport type { ReactElement } from 'react'\nimport { Download, FileText, PenLine, PencilLine, Users } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\n\nconst TOUCH = 'pointer-coarse:min-h-11'\n\ninterface ToggleProps {\n /** On (pressed). */\n active: boolean\n onClick: () => void\n compact?: boolean\n}\n\n/** Annotate mode: highlight, comment, stamp, redact. */\nexport function AnnotateButton({ active, onClick, compact }: ToggleProps): ReactElement {\n return (\n <Button\n type=\"button\"\n variant={active ? 'default' : 'outline'}\n size={compact ? 'icon' : 'sm'}\n aria-pressed={active}\n title=\"Annotate: highlight, comment, stamp, redact\"\n aria-label=\"Annotate\"\n data-testid=\"annotate-toggle\"\n className={TOUCH}\n onClick={onClick}\n >\n <PencilLine className=\"size-4\" />\n {!compact && <span className=\"ml-1\">Annotate</span>}\n </Button>\n )\n}\n\n/** The markup is the default view of a marked-up PDF; this shows the untouched file. */\nexport function ShowOriginalButton({ active, onClick, compact }: ToggleProps): ReactElement {\n return (\n <Button\n type=\"button\"\n variant={active ? 'default' : 'outline'}\n size={compact ? 'icon' : 'sm'}\n aria-pressed={active}\n title={active ? 'Show the markup again' : 'Show the original, without markup'}\n aria-label=\"Show original\"\n data-testid=\"markup-show-original\"\n className={TOUCH}\n onClick={onClick}\n >\n <FileText className=\"size-4\" />\n {!compact && <span className=\"ml-1\">Show original</span>}\n </Button>\n )\n}\n\n/**\n * \"Download with markup\": the PDF with its annotations, which Acrobat and Preview show. With a\n * `disabledReason` (a signed, locked version) it is off and says why.\n */\nexport function DownloadMarkupButton({\n onClick,\n disabledReason,\n}: {\n onClick: () => void\n disabledReason?: string\n}): ReactElement {\n const button = (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"icon\"\n title={\n disabledReason ??\n 'Download with markup: the PDF with its annotations (opens in Acrobat or Preview)'\n }\n aria-label=\"Download with markup\"\n aria-description={disabledReason}\n disabled={!!disabledReason}\n data-testid=\"markup-download\"\n className={TOUCH}\n onClick={onClick}\n >\n <Download className=\"size-4\" />\n </Button>\n )\n // A disabled button gets no pointer events, so the reason sits on a wrapper too.\n return disabledReason ? (\n <span title={disabledReason} className=\"inline-flex\" data-testid=\"markup-download-locked\">\n {button}\n </span>\n ) : (\n button\n )\n}\n\n/** One line where a signed version's content can be edited: an edit is a new, unsigned version. */\nexport function SignedEditNote(): ReactElement {\n return (\n <p\n className=\"border-b px-3 py-1.5 text-xs text-muted-foreground\"\n data-testid=\"signed-edit-note\"\n >\n Editing creates a new unsigned version\n </p>\n )\n}\n\n/** Sign: choose where the signature goes, then sign. */\nexport function SignButton({ active, onClick, compact }: ToggleProps): ReactElement {\n return (\n <Button\n type=\"button\"\n variant={active ? 'default' : 'outline'}\n size={compact ? 'icon' : 'sm'}\n aria-pressed={active}\n title=\"Sign document\"\n aria-label=\"Sign\"\n data-testid=\"sign-document-button\"\n className={TOUCH}\n onClick={onClick}\n >\n <PenLine className=\"size-4\" />\n {!compact && <span className=\"ml-1\">Sign</span>}\n </Button>\n )\n}\n\n/** Prepare the document for others to sign: place their fields and send it. */\nexport function RequestSignaturesButton({ active, onClick, compact }: ToggleProps): ReactElement {\n return (\n <Button\n type=\"button\"\n variant={active ? 'default' : 'outline'}\n size={compact ? 'icon' : 'sm'}\n aria-pressed={active}\n title=\"Request signatures\"\n aria-label=\"Request signatures\"\n data-testid=\"request-signatures-button\"\n className={TOUCH}\n onClick={onClick}\n >\n <Users className=\"size-4\" />\n {!compact && <span className=\"ml-1\">Request signatures</span>}\n </Button>\n )\n}\n","/**\n * The one-line notices above the PDF about its markup: annotations found in this browser from\n * before markup was saved on the server (for a shared document: add them to the shared markup, or\n * discard), and markup that sits on an older version (open it, or copy its open comments here).\n */\n\nimport type { LegacyPrompt, OlderMarkupNote } from '@arbidocs/react/document-tools'\n\nconst BAR = 'flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2 text-xs'\nconst LINK =\n 'font-medium text-primary hover:underline disabled:opacity-50 disabled:no-underline pointer-coarse:min-h-11'\n\nexport interface MarkupNoticesProps {\n legacyPrompt: LegacyPrompt | null\n olderNote: OlderMarkupNote | null\n onOpenVersion: (version: number) => void\n}\n\nexport function MarkupNotices({ legacyPrompt, olderNote, onOpenVersion }: MarkupNoticesProps) {\n return (\n <>\n {legacyPrompt && (\n <div className={BAR} role=\"status\" data-testid=\"markup-migration-prompt\">\n <span>\n {legacyPrompt.count} annotation{legacyPrompt.count === 1 ? '' : 's'} on this document\n {legacyPrompt.count === 1 ? ' is' : ' are'} saved only in this browser. Add{' '}\n {legacyPrompt.count === 1 ? 'it' : 'them'} to the shared markup, where everyone with\n access sees {legacyPrompt.count === 1 ? 'it' : 'them'}?\n </span>\n <span className=\"flex items-center gap-3\">\n <button\n type=\"button\"\n className={LINK}\n disabled={legacyPrompt.busy}\n data-testid=\"markup-migration-add\"\n onClick={legacyPrompt.add}\n >\n {legacyPrompt.busy ? 'Adding…' : 'Add to shared markup'}\n </button>\n <button\n type=\"button\"\n className={LINK}\n disabled={legacyPrompt.busy}\n data-testid=\"markup-migration-discard\"\n onClick={legacyPrompt.discard}\n >\n Discard\n </button>\n </span>\n </div>\n )}\n {olderNote && (\n <div className={BAR} data-testid=\"markup-older-version-note\">\n <span>\n The markup is on version {olderNote.version}. This version started without it.\n {olderNote.signed && (\n <span data-testid=\"markup-older-version-signed\">\n {' '}\n It is signed: comments copied here are kept beside it, and the signed PDF does not\n change.\n </span>\n )}\n </span>\n <span className=\"flex items-center gap-3\">\n <button\n type=\"button\"\n className={LINK}\n data-testid=\"markup-open-older-version\"\n onClick={() => onOpenVersion(olderNote.version)}\n >\n Open version {olderNote.version}\n </button>\n <button\n type=\"button\"\n className={LINK}\n disabled={olderNote.busy}\n data-testid=\"markup-copy-open-threads\"\n title=\"Copy the unresolved comment threads onto this version (redactions never carry over)\"\n onClick={olderNote.copy}\n >\n {olderNote.busy ? 'Copying…' : 'Copy open comments here'}\n </button>\n </span>\n </div>\n )}\n </>\n )\n}\n","/**\n * Which view of a marked-up PDF is on screen, spelled out beside the title, with the switch to the\n * other one. The narrow header's \"Show original\" is an unlabelled page icon, so on its own it read\n * as no control at all, and nothing said whether the page showed the markup or the original.\n */\n\nimport type { ReactElement } from 'react'\nimport { ViewerStatusNote } from '../files/ViewerLayout'\n\nexport interface MarkupViewNoteProps {\n showOriginal: boolean\n onToggle: () => void\n}\n\nexport function MarkupViewNote({ showOriginal, onToggle }: MarkupViewNoteProps): ReactElement {\n return (\n <ViewerStatusNote testId=\"markup-view-note\">\n {showOriginal ? 'Original, without markup' : 'With markup'}\n {' · '}\n <button\n type=\"button\"\n className=\"font-medium text-primary hover:underline pointer-coarse:min-h-11\"\n data-testid=\"markup-view-note-toggle\"\n onClick={onToggle}\n >\n {showOriginal ? 'Show markup' : 'Show original'}\n </button>\n </ViewerStatusNote>\n )\n}\n","/**\n * The \"Signed — locked\" note in the viewer header (a signed version changes only by a further\n * signature), which opens the signature details: who signed and when,\n * whether the document is unchanged since, and \"View certificate\", the public page anyone can\n * check the signature on (the same page the signature on the PDF links to). Read from the PDF\n * itself (GET .../signatures). A counter-signed copy lists every signature, oldest first.\n */\n\nimport type { ReactElement, ReactNode } from 'react'\nimport {\n certificateLink,\n useOptionalDocumentTools,\n type SignatureStatusResponse,\n} from '@arbidocs/react/document-tools'\nimport { Popover, PopoverContent, PopoverTrigger } from '@arbidocs/react/ui'\n\n/** \"14 Oct 2026, 12:00\" in the reader's locale and time zone. */\nexport function formatSignedAt(iso: string): string {\n const date = new Date(iso)\n if (Number.isNaN(date.getTime())) return iso\n return date.toLocaleString([], { dateStyle: 'medium', timeStyle: 'short' })\n}\n\nexport interface SignatureStatusProps {\n status: SignatureStatusResponse\n /** How the signing time is shown. Default: {@link formatSignedAt}. */\n formatDate?: (iso: string) => string\n /**\n * The certificate page of a signature in this app. Preferred over the `certificate_url` the API\n * returns (which is on the deployment domain). Default: the enclosing `<DocumentToolsProvider>`'s\n * `certificateUrl`, if any; without either, the API's `certificate_url`, else\n * `/verify/{reference}` on this origin.\n */\n certificateUrl?: (reference: string) => string\n}\n\nfunction Row({ label, field, children }: { label: string; field: string; children: ReactNode }) {\n return (\n <div className=\"grid grid-cols-[5.5rem_1fr] gap-2\">\n <dt className=\"text-muted-foreground\">{label}</dt>\n <dd className=\"min-w-0 break-words\" data-testid={`signature-detail-${field}`}>\n {children}\n </dd>\n </div>\n )\n}\n\nexport function SignatureStatus({\n status,\n formatDate = formatSignedAt,\n certificateUrl,\n}: SignatureStatusProps): ReactElement {\n const tools = useOptionalDocumentTools()\n const hostCertificateUrl = certificateUrl ?? tools?.certificateUrl\n const signatures = status.signatures ?? []\n // A signed copy can be counter-signed: each signature is listed, oldest first.\n const isCounterSigned = signatures.length > 1\n return (\n <Popover>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n className=\"flex-shrink-0 text-sm text-muted-foreground underline decoration-dotted underline-offset-4 hover:text-foreground pointer-coarse:min-h-11\"\n data-testid=\"document-signature-status\"\n aria-label={`${status.intact ? 'Signed, locked' : 'Modified after signing'}: show signature details`}\n >\n {status.intact ? 'Signed — locked' : 'Modified after signing'}\n </button>\n </PopoverTrigger>\n <PopoverContent\n className=\"max-h-[70vh] w-80 overflow-y-auto p-3 text-sm\"\n align=\"start\"\n data-testid=\"signature-details\"\n >\n <p className=\"mb-2 font-medium\" data-testid=\"signature-details-title\">\n {isCounterSigned\n ? `Electronic signatures (${signatures.length})`\n : 'Electronic signature'}\n </p>\n {signatures.map((signature, index) => (\n <dl\n key={signature.reference}\n className={`mb-3 space-y-1 ${index > 0 ? 'border-t border-border pt-2' : ''}`}\n data-testid={`signature-item-${index}`}\n >\n <Row label=\"Signed by\" field=\"signer\">\n {signature.signer_name || signature.signer_email}\n </Row>\n <Row label=\"On\" field=\"time\">\n {formatDate(signature.signed_at)}\n </Row>\n <dd>\n <a\n href={certificateLink(signature, hostCertificateUrl)}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center font-medium text-primary hover:underline pointer-coarse:min-h-11\"\n data-testid={`signature-certificate-link-${index}`}\n >\n View certificate\n </a>\n </dd>\n </dl>\n ))}\n <p\n className={`border-t border-border pt-2 ${status.intact ? '' : 'text-red-text'}`}\n data-testid=\"signature-detail-intact\"\n >\n {status.intact\n ? isCounterSigned\n ? '✓ Unchanged since the last signature'\n : '✓ Unchanged since signing'\n : '✗ Changed after it was signed'}\n </p>\n <p className=\"mt-1 text-xs text-muted-foreground\" data-testid=\"signature-detail-locked\">\n Locked: only further signatures can be added.\n </p>\n </PopoverContent>\n </Popover>\n )\n}\n","/**\n * The certificate of an ARBI signature: the page the link on a signed PDF's signature opens, for\n * anyone, signed in or not. Plain English and short: who signed and when, what ARBI checks, the\n * result, any counter-signatures, and \"Check your copy\", which hashes a PDF in the browser and\n * compares it with the signed document and each signed revision (the file never leaves the\n * device). No email addresses and no\n * document content. Presentational: `verification` comes from `useSignatureVerification` in\n * `@arbidocs/react/document-tools`.\n */\n\nimport { useRef, useState, type DragEvent, type ReactElement, type ReactNode } from 'react'\nimport {\n matchSignedCopy,\n type CopyMatch,\n type SignatureVerification,\n} from '@arbidocs/react/document-tools'\nimport { cn } from '@arbidocs/react/ui'\nimport { formatSignedAt } from './SignatureStatus'\n\nexport interface SignatureCertificateProps {\n /** The signature reference (`sig-…`), shown at the foot of the page. */\n reference?: string\n verification?: SignatureVerification\n isLoading?: boolean\n /** Why the signature could not be checked. */\n error?: string | null\n /** The error is a passing one (too many checks): say it calmly, not as a failure. */\n isErrorTransient?: boolean\n /** How signing times are shown. Default: {@link formatSignedAt}. */\n formatDate?: (iso: string) => string\n /** Offer \"Check your copy\". Default on. */\n allowCopyCheck?: boolean\n}\n\ntype CopyCheck =\n | { state: 'idle' }\n | { state: 'checking'; name: string }\n | { state: 'done'; name: string; match: CopyMatch }\n | { state: 'failed'; name: string }\n\nfunction Frame({ children }: { children: ReactNode }) {\n return (\n <main\n className=\"mx-auto w-full max-w-xl px-4 py-10 text-foreground\"\n data-testid=\"signature-certificate\"\n >\n <h1 className=\"mb-6 text-xl font-semibold\">Signature certificate</h1>\n {children}\n </main>\n )\n}\n\nfunction copyResult(name: string, match: CopyMatch): string {\n if (match.kind === 'current') return `✓ ${name} is the signed document, unchanged.`\n if (match.kind === 'earlier') {\n // A counter-signed PDF: the copy is an earlier signed revision, which is still genuine.\n return `✓ ${name}: this is the version signed by ${match.signature.signer_name || 'an ARBI user'}.`\n }\n return `✗ ${name} is not the signed document: it differs from what was signed.`\n}\n\nexport function SignatureCertificate({\n reference,\n verification,\n isLoading = false,\n error,\n isErrorTransient = false,\n formatDate = formatSignedAt,\n allowCopyCheck = true,\n}: SignatureCertificateProps): ReactElement {\n const [copy, setCopy] = useState<CopyCheck>({ state: 'idle' })\n const [dragging, setDragging] = useState(false)\n const input = useRef<HTMLInputElement>(null)\n\n if (isLoading) {\n return (\n <Frame>\n <p className=\"text-muted-foreground\" data-testid=\"signature-certificate-loading\">\n Checking the signature…\n </p>\n </Frame>\n )\n }\n if (error || !verification) {\n return (\n <Frame>\n <p\n className={isErrorTransient ? 'text-muted-foreground' : 'text-red-text'}\n role={isErrorTransient ? 'status' : 'alert'}\n data-testid=\"signature-certificate-error\"\n >\n {error || 'The signature could not be checked.'}\n </p>\n </Frame>\n )\n }\n\n const [first, ...counter] = verification.signatures\n const check = async (file: File | undefined) => {\n if (!file) return\n setCopy({ state: 'checking', name: file.name })\n try {\n setCopy({ state: 'done', name: file.name, match: await matchSignedCopy(file, verification) })\n } catch {\n setCopy({ state: 'failed', name: file.name })\n }\n }\n const onDrop = (e: DragEvent) => {\n e.preventDefault()\n setDragging(false)\n void check(e.dataTransfer.files[0])\n }\n\n return (\n <Frame>\n <section className=\"space-y-3\">\n {first && (\n <p className=\"text-base\" data-testid=\"signature-certificate-signer\">\n Signed by <strong>{first.signer_name || 'an ARBI user'}</strong> on{' '}\n {formatDate(first.signed_at)}\n </p>\n )}\n {counter.length > 0 && (\n <ul className=\"space-y-1 text-sm\" data-testid=\"signature-certificate-counter\">\n {counter.map((s, i) => (\n <li key={`${s.sha256}-${i}`}>\n Also signed by <strong>{s.signer_name || 'an ARBI user'}</strong> on{' '}\n {formatDate(s.signed_at)}\n </li>\n ))}\n </ul>\n )}\n <p className=\"text-sm text-muted-foreground\">\n ARBI checks that this document hasn’t changed since it was signed. If anything changed,\n this check fails.\n </p>\n <p\n className={cn(\n 'rounded-md border px-3 py-2 font-medium',\n verification.intact\n ? 'border-green-border bg-green-bg text-green-text'\n : 'border-red-text text-red-text'\n )}\n role=\"status\"\n data-testid=\"signature-certificate-result\"\n data-intact={verification.intact}\n >\n {verification.intact\n ? '✓ Unchanged since signing'\n : '✗ Changed since signing: this is not the document that was signed'}\n </p>\n </section>\n\n {allowCopyCheck && (\n <section className=\"mt-8 space-y-2\">\n <h2 className=\"text-sm font-medium\">Check your copy</h2>\n <div\n role=\"button\"\n tabIndex={0}\n className={cn(\n 'flex min-h-24 cursor-pointer flex-col items-center justify-center rounded-md border border-dashed px-4 py-6 text-center text-sm text-muted-foreground pointer-coarse:min-h-32',\n dragging && 'border-primary bg-muted'\n )}\n data-testid=\"signature-certificate-dropzone\"\n onClick={() => input.current?.click()}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n input.current?.click()\n }\n }}\n onDragOver={(e) => {\n e.preventDefault()\n setDragging(true)\n }}\n onDragLeave={() => setDragging(false)}\n onDrop={onDrop}\n >\n Drop the PDF you were sent here, or choose it\n <span className=\"mt-1 text-xs\">It is checked in this browser and never uploaded.</span>\n <input\n ref={input}\n type=\"file\"\n accept=\"application/pdf,.pdf\"\n className=\"sr-only\"\n data-testid=\"signature-certificate-file-input\"\n onChange={(e) => void check(e.target.files?.[0])}\n />\n </div>\n {copy.state !== 'idle' && (\n <p\n className={cn(\n 'text-sm',\n copy.state === 'done' && copy.match.kind !== 'none' && 'text-green-text',\n ((copy.state === 'done' && copy.match.kind === 'none') ||\n copy.state === 'failed') &&\n 'text-red-text'\n )}\n role=\"status\"\n data-testid=\"signature-certificate-copy-result\"\n >\n {copy.state === 'checking'\n ? `Checking ${copy.name}…`\n : copy.state === 'failed'\n ? `${copy.name} could not be read.`\n : copyResult(copy.name, copy.match)}\n </p>\n )}\n </section>\n )}\n\n {reference && (\n <p\n className=\"mt-8 text-xs text-muted-foreground\"\n data-testid=\"signature-certificate-reference\"\n >\n Reference {reference}\n </p>\n )}\n </Frame>\n )\n}\n","/**\n * The bar above an older version opened read-only: which version it is, \"Ask about this version\"\n * (when the host has an assistant) and the way back to the current version. Put it in the viewer's\n * sticky header, not the content area: a PDF view scrolls its first page into view, which would\n * scroll a bar above it out of sight.\n */\n\nimport type { ReactElement } from 'react'\n\nconst LINK = 'font-medium text-primary hover:underline pointer-coarse:min-h-11'\n\nexport interface VersionSnapshotBarLabels {\n /** `Version 2 · read only`; `number` is undefined when the version is not known. */\n title: (number: number | undefined) => string\n ask: string\n returnToCurrent: string\n /** For documents edited live (Word, artifacts), where \"current\" is the live document. */\n returnToLive: string\n}\n\nexport const DEFAULT_VERSION_SNAPSHOT_BAR_LABELS: VersionSnapshotBarLabels = {\n title: (number) => `${number ? `Version ${number}` : 'Saved version'} · read only`,\n ask: 'Ask about this version',\n returnToCurrent: 'Return to current version',\n returnToLive: 'Return to live document',\n}\n\nexport interface VersionSnapshotBarProps {\n /** The version's number, when known. */\n versionNumber?: number\n /** The document is edited live: the way back says \"live document\". */\n live?: boolean\n /** Ask the assistant about this version. Omitted: no ask action. */\n onAsk?: () => void\n onReturn: () => void\n labels?: Partial<VersionSnapshotBarLabels>\n}\n\nexport function VersionSnapshotBar({\n versionNumber,\n live = false,\n onAsk,\n onReturn,\n labels: overrides,\n}: VersionSnapshotBarProps): ReactElement {\n const labels = { ...DEFAULT_VERSION_SNAPSHOT_BAR_LABELS, ...overrides }\n return (\n <div\n className=\"flex items-center justify-between border-b px-3 py-2 text-xs\"\n data-testid=\"version-snapshot-bar\"\n >\n <span>{labels.title(versionNumber)}</span>\n <span className=\"flex items-center gap-3\">\n {onAsk && (\n <button type=\"button\" className={LINK} data-testid=\"version-snapshot-ask\" onClick={onAsk}>\n {labels.ask}\n </button>\n )}\n <button\n type=\"button\"\n className={LINK}\n data-testid=\"version-snapshot-return\"\n onClick={onReturn}\n >\n {live ? labels.returnToLive : labels.returnToCurrent}\n </button>\n </span>\n </div>\n )\n}\n","/**\n * PDF tab › My signature: place one's own saved signature or initials on the page as a picture stamp\n * in the markup layer (then drag and resize it like any stamp). Nothing saved yet: the adopt dialog\n * opens first and saves it. An informal signature; verified signing is Request signatures. Needs a\n * `<DocumentToolsProvider>` inside a React Query `QueryClientProvider`.\n */\n\nimport { useState, type ReactElement } from 'react'\nimport { Signature } from 'lucide-react'\nimport {\n INFORMAL_SIGNATURE_NOTE,\n fetchSavedSignature,\n storeSavedSignature,\n useDocumentTools,\n type SavedSignature,\n} from '@arbidocs/react/document-tools'\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '@arbidocs/react/ui'\nimport { AdoptSignatureDialog } from './AdoptSignatureDialog'\n\nexport type PlacedMark = { image: string; label: string }\n\ntype Mark = 'signature' | 'initials'\n\nconst picked = (saved: SavedSignature, mark: Mark): PlacedMark =>\n mark === 'signature'\n ? { image: saved.signature_png, label: 'Signature' }\n : { image: saved.initials_png, label: 'Initials' }\n\nexport function PlaceMySignatureButton({\n onPlace,\n compact = false,\n}: {\n /** Arm the stamp tool with this picture: the next click on a page places it. */\n onPlace: (mark: PlacedMark) => void\n compact?: boolean\n}): ReactElement {\n const { client, user, notify } = useDocumentTools()\n const [adoptFor, setAdoptFor] = useState<Mark | null>(null)\n\n // Read when asked for (sealed with one's own key: opened here, in the browser).\n const place = async (mark: Mark) => {\n try {\n const saved = await fetchSavedSignature(client)\n if (saved) return onPlace(picked(saved, mark))\n setAdoptFor(mark)\n } catch (err) {\n notify(err instanceof Error ? err.message : 'Your saved signature could not be read', 'error')\n }\n }\n\n return (\n <>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size={compact ? 'icon' : 'sm'}\n title=\"Place my signature\"\n aria-label=\"Place my signature\"\n className=\"pointer-coarse:min-h-11\"\n data-testid=\"place-my-signature-button\"\n >\n <Signature className=\"size-4\" />\n {!compact && <span className=\"ml-1\">My signature</span>}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"max-w-72\">\n <DropdownMenuItem\n onSelect={() => void place('signature')}\n data-testid=\"place-my-signature\"\n >\n Place my signature\n </DropdownMenuItem>\n <DropdownMenuItem onSelect={() => void place('initials')} data-testid=\"place-my-initials\">\n Place my initials\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuLabel className=\"text-xs font-normal text-muted-foreground\">\n {INFORMAL_SIGNATURE_NOTE}\n </DropdownMenuLabel>\n </DropdownMenuContent>\n </DropdownMenu>\n <AdoptSignatureDialog\n open={!!adoptFor}\n onOpenChange={(open) => !open && setAdoptFor(null)}\n mode=\"save\"\n defaultName={user?.name ?? ''}\n onSave={async (signature) => {\n await storeSavedSignature(client, signature)\n const mark = adoptFor\n setAdoptFor(null)\n if (mark) onPlace(picked(signature, mark))\n }}\n onAdopt={() => notify('Your signature is saved. Click where it goes.', 'success')}\n />\n </>\n )\n}\n","/**\n * Account settings › Your signature: the signature and initials saved to the account (sealed with\n * the user's own key), with Replace (the adopt dialog, saving over it) and Delete (removed from the\n * account completely; what was already placed in documents or sealed in signed PDFs stays as it\n * is). Needs a `<DocumentToolsProvider>` inside a React Query `QueryClientProvider`.\n */\n\nimport { useState, type ReactElement } from 'react'\nimport { PenLine, Trash2 } from 'lucide-react'\nimport {\n INFORMAL_SIGNATURE_NOTE,\n useDeleteSavedSignature,\n useDocumentTools,\n useSavedSignature,\n useStoreSavedSignature,\n} from '@arbidocs/react/document-tools'\nimport { Button } from '@arbidocs/react/ui'\nimport { ConfirmDialog } from '../settings/ConfirmDialog'\nimport { SettingsCard } from '../settings/SettingsPanel'\nimport { AdoptSignatureDialog } from './AdoptSignatureDialog'\n\nexport const DELETE_SAVED_SIGNATURE_TEXT =\n 'Your saved signature and initials are removed from your account completely. Signatures you ' +\n 'already inserted into documents, and those sealed in signed PDFs, are not affected.'\n\nexport function SavedSignatureSettings(): ReactElement {\n const { user, notify } = useDocumentTools()\n const saved = useSavedSignature()\n const store = useStoreSavedSignature()\n const remove = useDeleteSavedSignature()\n const [editing, setEditing] = useState(false)\n const [confirming, setConfirming] = useState(false)\n const signature = saved.data\n\n return (\n <SettingsCard data-testid=\"saved-signature-settings\">\n <div className=\"space-y-1\">\n <h3 className=\"text-sm font-medium\">Your signature</h3>\n <p className=\"text-sm text-muted-foreground\">\n Saved to your account, sealed with your own key, to insert into Word documents and place\n on PDFs. {INFORMAL_SIGNATURE_NOTE}\n </p>\n </div>\n {signature ? (\n <div className=\"flex flex-wrap items-center gap-4\" data-testid=\"saved-signature-preview\">\n <img\n src={`data:image/png;base64,${signature.signature_png}`}\n alt=\"Your saved signature\"\n className=\"h-16 max-w-xs rounded-md border bg-white object-contain p-1\"\n />\n <img\n src={`data:image/png;base64,${signature.initials_png}`}\n alt=\"Your saved initials\"\n className=\"h-16 max-w-[8rem] rounded-md border bg-white object-contain p-1\"\n />\n </div>\n ) : (\n <p className=\"text-sm text-muted-foreground\" data-testid=\"saved-signature-none\">\n {saved.isLoading ? 'Loading…' : 'No signature saved.'}\n </p>\n )}\n <div className=\"flex gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => setEditing(true)}\n data-testid=\"saved-signature-replace\"\n >\n <PenLine className=\"mr-1 size-4\" aria-hidden />\n {signature ? 'Replace' : 'Add a signature'}\n </Button>\n {signature && (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => setConfirming(true)}\n data-testid=\"saved-signature-delete\"\n >\n <Trash2 className=\"mr-1 size-4\" aria-hidden />\n Delete\n </Button>\n )}\n </div>\n <AdoptSignatureDialog\n open={editing}\n onOpenChange={setEditing}\n mode=\"save\"\n defaultName={user?.name ?? ''}\n saved={signature ?? null}\n onSave={async (next) => void (await store.mutateAsync(next))}\n onAdopt={() => {\n setEditing(false)\n notify('Your signature is saved.', 'success')\n }}\n />\n <ConfirmDialog\n isOpen={confirming}\n onClose={() => setConfirming(false)}\n onConfirm={async () => {\n try {\n await remove.mutateAsync()\n notify('Your saved signature is deleted.', 'success')\n } catch (err) {\n notify(err instanceof Error ? err.message : 'Could not delete it', 'error')\n } finally {\n setConfirming(false)\n }\n }}\n title=\"Delete your saved signature?\"\n description={DELETE_SAVED_SIGNATURE_TEXT}\n confirmText=\"Delete\"\n variant=\"destructive\"\n isLoading={remove.isPending}\n testId=\"saved-signature-delete-confirm\"\n />\n </SettingsCard>\n )\n}\n\nexport default SavedSignatureSettings\n","/**\n * Where a document's signature requests stand, above the document: a request waiting for the\n * viewer's signature (with \"Review and sign\"), one the viewer sent and is waiting on others (who\n * has signed; void it), and the viewer's own draft (go on editing it). Nothing when there is none.\n * Needs a `<DocumentToolsProvider>` whose `user` has an `externalId`.\n */\n\nimport type { ReactElement } from 'react'\nimport { FilePenLine, PenLine, Send } from 'lucide-react'\nimport {\n SIGNER_PROGRESS_LABELS,\n useDocumentSignatureRequests,\n useDocumentTools,\n useInviteSigners,\n useSignerCandidates,\n useVoidSignatureRequest,\n type SignatureRequest,\n} from '@arbidocs/react/document-tools'\nimport { Button } from '@arbidocs/react/ui'\n\nexport interface SignatureRequestBannerProps {\n documentId: string\n /** Open the guided signing of a request waiting for the viewer. */\n onSign: (request: SignatureRequest) => void\n /** Go on editing the viewer's draft. */\n onEditDraft: (request: SignatureRequest) => void\n /** Hide it (e.g. while the editor or the guided signing is open). */\n hidden?: boolean\n}\n\n/** Who is still to sign, and how far each has got (\"Dana Day (invited)\"). */\nfunction waitingFor(request: SignatureRequest): string[] {\n return request.signers\n .filter((s) => s.status === 'pending')\n .map((s) => `${s.name || s.email || ''} (${SIGNER_PROGRESS_LABELS[s.progress].toLowerCase()})`)\n}\n\nexport function SignatureRequestBanner({\n documentId,\n onSign,\n onEditDraft,\n hidden = false,\n}: SignatureRequestBannerProps): ReactElement | null {\n const { user, notify } = useDocumentTools()\n const requests = useDocumentSignatureRequests(documentId, !hidden)\n const voidRequest = useVoidSignatureRequest()\n const invite = useInviteSigners()\n const me = user?.externalId ?? null\n const candidates = useSignerCandidates(!hidden && !!me)\n const isOwner = candidates.data?.some((c) => c.externalId === me && c.role === 'owner') ?? false\n if (hidden || !me || !requests.data) return null\n const open = requests.data.filter((r) => r.status === 'sent' || r.status === 'draft')\n const awaitingMe = open.filter(\n (r) =>\n r.status === 'sent' && r.signers.some((s) => s.user_ext_id === me && s.status === 'pending')\n )\n const sentByMe = open.filter(\n (r) => r.status === 'sent' && r.created_by === me && !awaitingMe.includes(r)\n )\n const drafts = open.filter((r) => r.status === 'draft' && r.created_by === me)\n if (awaitingMe.length + sentByMe.length + drafts.length === 0) return null\n\n const doVoid = async (request: SignatureRequest) => {\n try {\n await voidRequest.mutateAsync(request.external_id)\n notify(request.status === 'draft' ? 'Draft discarded.' : 'Signature request voided.', 'info')\n } catch (err) {\n notify(err instanceof Error ? err.message : 'Could not void it', 'error')\n }\n }\n\n return (\n <div\n className=\"space-y-1.5 border-b border-border px-3 py-2 text-sm\"\n data-testid=\"signature-request-banner\"\n >\n {awaitingMe.map((r) => {\n const count = r.fields.filter((f) => f.signer === me).length\n const author = r.signers.find((s) => s.user_ext_id === r.created_by)?.name\n return (\n <div\n key={r.external_id}\n className=\"flex flex-wrap items-center gap-2 rounded-md bg-blue-50 px-2 py-1.5 text-blue-950 dark:bg-blue-950/40 dark:text-blue-100\"\n data-testid=\"signature-request-awaiting-me\"\n >\n <PenLine className=\"size-4 shrink-0\" aria-hidden />\n <span className=\"mr-auto\">\n {author && r.created_by !== me\n ? `${author} asked you to sign`\n : 'You are asked to sign'}{' '}\n {count} field{count === 1 ? '' : 's'} in this document.\n {r.stale && ' It has changed since it was sent: ask for it again.'}\n </span>\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={() => onSign(r)}\n disabled={r.stale}\n data-testid=\"signature-request-start\"\n >\n Review and sign\n </Button>\n </div>\n )\n })}\n {sentByMe.map((r) => {\n const pending = waitingFor(r)\n const signed = r.signers.length - pending.length\n const invited = r.signers.filter((s) => s.progress === 'invited' && s.email)\n return (\n <div\n key={r.external_id}\n className=\"flex flex-wrap items-center gap-2\"\n data-testid=\"signature-request-sent\"\n >\n <Send className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden />\n <span className=\"mr-auto\">\n Out for signature: {signed} of {r.signers.length} signed\n {pending.length > 0 && (\n <span className=\"text-muted-foreground\"> · waiting for {pending.join(', ')}</span>\n )}\n {r.stale && (\n <span className=\"text-red-text\"> · the document has changed since it was sent</span>\n )}\n </span>\n {isOwner && invited.length > 0 && (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n disabled={invite.isPending}\n onClick={async () => {\n try {\n await invite.mutateAsync({\n documentId,\n emails: invited.map((s) => s.email!),\n })\n notify(\n 'Invited again: anyone already registered is added now and asked to sign.',\n 'success'\n )\n } catch (err) {\n notify(err instanceof Error ? err.message : 'Could not invite', 'error')\n }\n }}\n data-testid=\"signature-request-reinvite\"\n >\n Invite again\n </Button>\n )}\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => doVoid(r)}\n disabled={voidRequest.isPending}\n >\n Void\n </Button>\n </div>\n )\n })}\n {drafts.map((r) => (\n <div\n key={r.external_id}\n className=\"flex flex-wrap items-center gap-2\"\n data-testid=\"signature-request-draft\"\n >\n <FilePenLine className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden />\n <span className=\"mr-auto\">\n Draft signature request: {r.fields.length} field{r.fields.length === 1 ? '' : 's'}, not\n sent yet.\n </span>\n <Button type=\"button\" size=\"sm\" variant=\"outline\" onClick={() => onEditDraft(r)}>\n Continue\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => doVoid(r)}\n disabled={voidRequest.isPending}\n >\n Discard\n </Button>\n </div>\n ))}\n </div>\n )\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import { QuietLink } from './chunk-M7EI5V6H.js';
3
- import { rehypeDocEntityPills, workspaceDocIdFromHref } from './chunk-DDCMLHXF.js';
4
- import { MentionChip } from './chunk-7CPOQPWR.js';
5
3
  import { useConnectedWorkspace } from './chunk-Z7PVDIUN.js';
6
4
  import { useHost } from './chunk-T4P237N6.js';
7
5
  import { useBlocksEnvironment } from './chunk-PKB4LBPC.js';
6
+ import { rehypeDocEntityPills, workspaceDocIdFromHref } from './chunk-DDCMLHXF.js';
7
+ import { MentionChip } from './chunk-7CPOQPWR.js';
8
8
  import React, { createContext, useMemo, useContext, useState, useId, useEffect, useCallback } from 'react';
9
9
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
10
10
  import { useArbiHost, useArbiSession, useDocument, useArbi, refreshDocuments, arbiQueryKeys } from '@arbidocs/react';
@@ -352,5 +352,5 @@ function useViewerIsDetached() {
352
352
  }
353
353
 
354
354
  export { ConnectedDocumentToolsProvider, ConnectedMarkdown, DocumentChip, DocumentWorkspaceContext, ExternalLink, InternalDocLink, MailChip, MermaidDiagram, WorkspaceDocumentReference, useDocumentViewerSupport, useDocumentWorkspace, useViewerDraftDocument, useViewerIsDetached, useViewerPassageCitation, useViewerStreamingDocument };
355
- //# sourceMappingURL=chunk-I4BGKX2H.js.map
356
- //# sourceMappingURL=chunk-I4BGKX2H.js.map
355
+ //# sourceMappingURL=chunk-LSKTOCKN.js.map
356
+ //# sourceMappingURL=chunk-LSKTOCKN.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/chat/mermaid-normalize.ts","../src/connection/conversation/MermaidDiagram.tsx","../src/connection/conversation/DocumentWorkspaceContext.tsx","../src/connection/conversation/ConnectedMarkdown.tsx","../src/connection/viewer/ConnectedDocumentToolsProvider.tsx","../src/connection/viewer/support.ts"],"names":["jsx","useContext","KitMarkdownRenderer","Fragment","useMemo"],"mappings":";;;;;;;;;;;;;;;;AAsBO,SAAS,sBAAsB,MAAA,EAAwB;AAE5D,EAAA,IAAI,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA,EAAG,OAAO,MAAA;AAE9B,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,KAAA,CAAM,gCAAgC,CAAA;AACjE,EAAA,IAAI,CAAC,aAAa,OAAO,MAAA;AAEzB,EAAA,MAAM,MAAA,GAAS,WAAA,CAAY,CAAC,CAAA,CAAE,OAAA,EAAQ;AACtC,EAAA,IAAI,OAAO,MAAA,CAAO,KAAA,CAAM,WAAA,CAAY,CAAC,EAAE,MAAM,CAAA;AAG7C,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,uDAAA,EAAyD,OAAO,CAAA;AAIpF,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,cAAA,EAAgB,SAAS,CAAA;AAI7C,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,wCAAA,EAA0C,KAAK,CAA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MACpC,kBAAA,EAAoB,MAAM,kBAAA,IAAsB,mBAAA;AAAA,MAChD,cAAA,EAAgB,MAAM,cAAA,IAAkB,SAAA;AAAA,MACxC,aAAA;AAAA,MACA,gBAAgB,IAAA,EAAM,cAAA;AAAA,MAErB;AAAA;AAAA,GACH;AAEJ;;;ACrBA,IAAM,aAAoC,EAAC;AAEpC,SAAS,wBAAA,GAAkD;AAChE,EAAA,OAAO,OAAA,GAAU,MAAA,IAAU,UAAA;AAC7B;AAEA,IAAM,OAAO,MAAM,MAAA;AACnB,IAAM,WAAW,MAAM,KAAA;AAGhB,SAAS,2BACd,UAAA,EACqC;AACrC,EAAA,MAAM,YAAA,GAAe,wBAAA,EAAyB,CAAE,oBAAA,IAAwB,IAAA;AACxE,EAAA,OAAO,aAAa,UAAU,CAAA;AAChC;AAGO,SAAS,uBAAuB,OAAA,EAAkD;AACvF,EAAA,MAAM,QAAA,GAAW,wBAAA,EAAyB,CAAE,gBAAA,IAAoB,IAAA;AAChE,EAAA,OAAO,SAAS,OAAO,CAAA;AACzB;AAGO,SAAS,wBAAA,GAAwD;AACtE,EAAA,MAAM,WAAA,GAAc,wBAAA,EAAyB,CAAE,kBAAA,IAAsB,IAAA;AACrE,EAAA,OAAO,WAAA,EAAY;AACrB;AAGO,SAAS,mBAAA,GAA+B;AAC7C,EAAA,MAAM,WAAA,GAAc,wBAAA,EAAyB,CAAE,aAAA,IAAiB,QAAA;AAChE,EAAA,OAAO,WAAA,EAAY;AACrB","file":"chunk-I4BGKX2H.js","sourcesContent":["/**\n * Defensive normalizer for single-line `graph` / `flowchart` Mermaid source.\n *\n * Some LLMs emit the entire diagram on one line. Mermaid's parser splits\n * statements on newlines, so a single-line graph fails outright. This helper\n * inserts newlines on safe statement boundaries so the diagram has a chance\n * of parsing. Only attempts normalization when:\n * 1. The source has no embedded newlines (i.e. is genuinely single-line), and\n * 2. The first directive is `graph` or `flowchart`.\n *\n * Other diagram types (sequenceDiagram, classDiagram, gantt, …) have very\n * different syntaxes — applying these heuristics to them would corrupt valid\n * input, so they're left untouched.\n *\n * Boundaries we split on:\n * - After the diagram-type header (`graph TD`, `flowchart LR`, …).\n * - Before each `style` / `classDef` / `class` / `linkStyle` / `click`\n * / `subgraph` keyword.\n * - Before/after `end` (closes a subgraph block).\n * - After a `]` (label close) that's followed by another node identifier\n * starting a new edge or node declaration.\n */\nexport function normalizeMermaidGraph(source: string): string {\n // Already multi-line — assume it's well-formed; don't touch it.\n if (/\\n/.test(source)) return source\n\n const headerMatch = source.match(/^\\s*(graph|flowchart)\\s+\\w+\\s+/)\n if (!headerMatch) return source\n\n const header = headerMatch[0].trimEnd()\n let body = source.slice(headerMatch[0].length)\n\n // Insert newline before keywords that always start a new statement.\n body = body.replace(/\\s+(style|classDef|class|linkStyle|click|subgraph)\\s/g, '\\n$1 ')\n\n // `end` closes a subgraph: put it on its own line, with a break after it\n // too so any trailing statements don't stay attached.\n body = body.replace(/\\s+end\\b\\s*/g, '\\nend\\n')\n\n // After a label close (`]`), if the next token looks like a Mermaid node id\n // followed by another `[` or `-->`, that's a new statement starting.\n body = body.replace(/\\]\\s+(?=[A-Za-z_][\\w-]*\\s*(?:\\[|-->))/g, ']\\n')\n\n // Collapse any accidental runs of blank lines we may have produced.\n body = body.replace(/\\n{2,}/g, '\\n')\n\n return `${header}\\n${body.trimStart()}`\n}\n","/**\n * MermaidDiagram Component\n *\n * Renders a Mermaid diagram from source code.\n * Used inside MarkdownRenderer to handle ```mermaid code blocks.\n * Lazy-loads the mermaid library to avoid bloating the initial bundle.\n */\n\nimport { useState, useEffect, useId } from 'react'\nimport { normalizeMermaidGraph } from '../../chat/mermaid-normalize'\n\ninterface MermaidDiagramProps {\n /** Mermaid diagram source code */\n chart: string\n}\n\n// Lazy-load and initialize mermaid once\nlet mermaidInstance: typeof import('mermaid').default | null = null\nlet mermaidLoadPromise: Promise<typeof import('mermaid').default> | null = null\n\nasync function getMermaid() {\n if (mermaidInstance) return mermaidInstance\n if (!mermaidLoadPromise) {\n mermaidLoadPromise = import('mermaid').then((mod) => {\n const m = mod.default\n m.initialize({\n startOnLoad: false,\n theme: 'default',\n securityLevel: 'strict',\n flowchart: { useMaxWidth: true, curve: 'basis' },\n })\n mermaidInstance = m\n return m\n })\n }\n return mermaidLoadPromise\n}\n\nexport function MermaidDiagram({ chart }: MermaidDiagramProps) {\n const [svg, setSvg] = useState<string | null>(null)\n const [error, setError] = useState<string | null>(null)\n const uniqueId = useId().replace(/:/g, '-')\n\n useEffect(() => {\n let cancelled = false\n\n async function render() {\n const mermaid = await getMermaid()\n const diagramId = `mermaid${uniqueId}`\n\n // Validate with parse() before render(). In Mermaid v11 a render() with\n // bad source can return a \"Syntax error in text\" bomb SVG instead of\n // throwing — and it appends DOM side-effects of its own — so a try/catch\n // around render() doesn't reliably catch failures and the bomb leaks\n // into the page (especially under React StrictMode where effects run\n // twice). parse() throws cleanly with no DOM side-effects.\n //\n // Defensive rescue: some LLMs emit single-line `graph`/`flowchart`\n // source. If the original parse fails, try a normalized variant. The\n // normalizer is a no-op on already-multi-line source and on non-graph\n // diagram types, so this only helps the bad-source case and never\n // corrupts valid input.\n let validSource: string | null = null\n let firstErr: unknown\n try {\n await mermaid.parse(chart)\n validSource = chart\n } catch (err) {\n firstErr = err\n const normalized = normalizeMermaidGraph(chart)\n if (normalized !== chart) {\n try {\n await mermaid.parse(normalized)\n validSource = normalized\n } catch (retryErr) {\n console.warn('Mermaid normalized parse also failed', retryErr)\n }\n }\n }\n\n if (cancelled) return\n\n if (!validSource) {\n console.warn('Mermaid parse failed, showing source', firstErr)\n setError('Failed to render diagram')\n setSvg(null)\n return\n }\n\n try {\n const { svg: renderedSvg } = await mermaid.render(diagramId, validSource)\n if (!cancelled) {\n setSvg(renderedSvg)\n setError(null)\n }\n } catch (renderErr) {\n if (!cancelled) {\n console.warn('Mermaid render failed despite parse success', renderErr)\n setError('Failed to render diagram')\n setSvg(null)\n }\n }\n }\n\n render()\n return () => {\n cancelled = true\n }\n }, [chart, uniqueId])\n\n if (error) {\n // Fall back to showing the raw source in a code block\n return (\n <div className=\"code-block\" data-testid=\"mermaid-error\">\n <div className=\"text-sm text-muted-foreground mb-1\">{error}</div>\n <code className=\"language-mermaid\">{chart}</code>\n </div>\n )\n }\n\n if (!svg) {\n return (\n <div\n className=\"flex items-center justify-center py-8 text-muted-foreground text-sm\"\n data-testid=\"mermaid-loading\"\n >\n Rendering diagram...\n </div>\n )\n }\n\n return (\n <div\n className=\"mermaid-diagram my-4 overflow-x-auto rounded-md border border-border bg-background p-4\"\n data-testid=\"mermaid-diagram\"\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n )\n}\n","/**\n * The workspace a conversation's document references belong to, when it is not the open one: an\n * agent's direct-message thread runs in the agent's workspace, so the documents it names are there.\n * A reference then opens that workspace first (`openDocument(id, { workspaceId })`).\n */\n\nimport { createContext, useContext, type ReactNode } from 'react'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\n/** The workspace of the documents referenced inside it (null: the open workspace). */\nexport const DocumentWorkspaceContext = createContext<string | null>(null)\nexport const useDocumentWorkspace = () => useContext(DocumentWorkspaceContext)\n\n/** A reference to a document of another workspace: opening it opens that workspace first. */\nexport function WorkspaceDocumentReference({\n workspaceId,\n docId,\n children,\n className = 'inline-flex rounded-full border px-2 py-0.5 text-xs hover:bg-muted',\n}: {\n workspaceId: string\n docId: string\n children?: ReactNode\n className?: string\n}) {\n const { openDocument } = useBlocksEnvironment()\n return (\n <button\n type=\"button\"\n className={className}\n onClick={() => openDocument(docId, { workspaceId })}\n >\n {children ?? docId}\n </button>\n )\n}\n","/**\n * The conversation's markdown: the kit's `MarkdownRenderer` (`@arbidocs/react`: sanitised HTML,\n * slugs, lazy KaTeX, streaming blocks, tables, code) with what a conversation adds: @mention chips,\n * workspace documents opening in the viewer, quiet external links, document and email pills (the\n * host's chips, `ArbiChatHost.renderDocumentChip` / `renderMailChip`) and Mermaid diagrams.\n */\nimport { useArbiHost, useArbiSession, useDocument } from '@arbidocs/react'\nimport { mentionFromHref, type MentionKind } from '@arbidocs/react/shell'\nimport {\n EntityPill,\n MarkdownCode,\n MarkdownLink,\n MarkdownRenderer as KitMarkdownRenderer,\n MarkdownStreamingContext,\n type MarkdownRendererProps as KitMarkdownRendererProps,\n DocumentEntity,\n} from '@arbidocs/react/ui'\nimport React, { useContext, useMemo } from 'react'\nimport { FileText, Mail } from 'lucide-react'\n\n/** The markdown element overrides, as the kit's renderer takes them. */\ntype Components = NonNullable<KitMarkdownRendererProps['components']>\nimport { MentionChip } from '../../chat/MentionMenu'\nimport { QuietLink } from '../../citations/QuietMarks'\nimport { rehypeDocEntityPills } from '../../chat/rehype-doc-entity-pills'\nimport { workspaceDocIdFromHref } from '../../chat/doc-links'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { MermaidDiagram } from './MermaidDiagram'\nimport { useDocumentWorkspace, WorkspaceDocumentReference } from './DocumentWorkspaceContext'\n\n/** Plain text of a link's children (the `@Label` of a mention link). */\nfunction childrenText(children: React.ReactNode): string {\n return React.Children.toArray(children)\n .map((child) => (typeof child === 'string' || typeof child === 'number' ? String(child) : ''))\n .join('')\n}\n\n/** A mention chip; a mention of the reader stands out. */\nfunction MentionLink({ kind, id, text }: { kind: MentionKind; id: string; text: string }) {\n const currentUserId = useArbiSession().user?.external_id\n return (\n <MentionChip\n kind={kind}\n id={id}\n label={text.replace(/^@/, '')}\n isSelf={kind === 'user' && id === currentUserId}\n />\n )\n}\n\n/**\n * A link to elsewhere, as quiet text. Its menu (Open link / Copy link) is the deliberate step\n * the old confirmation dialog used to be; nothing opens until the menu's primary row is chosen.\n */\nexport function ExternalLink({ href, children }: React.ComponentPropsWithoutRef<'a'>) {\n return (\n <QuietLink href={href} kind=\"external\">\n {children}\n </QuietLink>\n )\n}\n\n/**\n * A workspace document referenced by a link's href rather than by its text.\n *\n * `rehypeDocEntityPills` turns a bare `doc-…` id into a pill, but it only walks\n * TEXT nodes — so `[NVDA DCF Valuation Report](…doc-abc12345…)`, which is how an\n * answer links an artifact it just saved, keeps the id in the href where the\n * plugin never looks. The link then fell through to `ExternalLink`, and opening\n * your own workspace document asked you to confirm an \"external link\" and\n * launched a new tab. It opens in the document viewer, like the pill and the\n * artifact card already do.\n */\nexport function InternalDocLink({\n docId,\n href,\n children,\n}: React.ComponentPropsWithoutRef<'a'> & { docId: string }) {\n const { openDocument } = useBlocksEnvironment()\n const workspaceId = useDocumentWorkspace()\n if (workspaceId) {\n return (\n <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId}>\n {children}\n </WorkspaceDocumentReference>\n )\n }\n\n return (\n <QuietLink href={href} kind=\"document\" onOpen={() => openDocument(docId)}>\n {children}\n </QuietLink>\n )\n}\n\n/** A document of the workspace, as a pill: the host's chip, else the document entity. */\nexport function DocumentChip({ docId }: { docId: string }) {\n const render = useArbiHost().chat?.renderDocumentChip\n const workspaceId = useDocumentWorkspace()\n if (workspaceId) return <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId} />\n return render ? <>{render(docId)}</> : <DefaultDocumentChip docId={docId} />\n}\n\nfunction DefaultDocumentChip({ docId }: { docId: string }) {\n const { data: doc } = useDocument(docId)\n const { openDocument } = useBlocksEnvironment()\n if (!doc)\n return (\n <EntityPill\n icon={<FileText className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label={docId}\n size=\"sm\"\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <DocumentEntity doc={doc} onClick={() => openDocument(docId)} data-testid=\"doc-entity-pill\" />\n )\n}\n\n/** An email of the person's mailbox, as a pill: the host's chip, else a plain \"Email\". */\nexport function MailChip({ mailId }: { mailId: string }) {\n const render = useArbiHost().chat?.renderMailChip\n if (render) return <>{render(mailId)}</>\n return (\n <EntityPill\n icon={<Mail className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label=\"Email\"\n size=\"sm\"\n data-testid=\"mail-entity-pill\"\n />\n )\n}\n\n/**\n * The conversation's overrides, layered on the kit's defaults. Module scope, so the reference is stable\n * and memoised markdown blocks do not re-parse.\n */\nconst conversationMarkdownComponents: Partial<Components> = {\n a: function ConversationMarkdownLink({\n href,\n children,\n ...props\n }: React.ComponentPropsWithoutRef<'a'>) {\n const deploymentDomain = useBlocksEnvironment().runtimeConfig.deploymentDomain\n // @mentions: `linkMentions` turned them into `#mention-<id>` links; draw them as chips.\n const mention = mentionFromHref(href)\n if (mention) {\n return <MentionLink kind={mention.kind} id={mention.id} text={childrenText(children)} />\n }\n // Bookmarks: in-page anchors are near-invisible text; the menu jumps or copies the place.\n if (href?.startsWith('#') && !href.startsWith('#cite-')) {\n return (\n <QuietLink href={href} kind=\"anchor\">\n {children}\n </QuietLink>\n )\n }\n // Citations, `cite:` references and bare links: the kit's link.\n if (!href || href.startsWith('#') || href.startsWith('cite:')) {\n return (\n <MarkdownLink href={href} {...props}>\n {children}\n </MarkdownLink>\n )\n }\n // A workspace document is not an external link, wherever it is hosted: it opens in the viewer.\n const docId = workspaceDocIdFromHref(href, deploymentDomain)\n if (docId) {\n return (\n <InternalDocLink docId={docId} href={href} {...props}>\n {children}\n </InternalDocLink>\n )\n }\n return (\n <ExternalLink href={href} {...props}>\n {children}\n </ExternalLink>\n )\n },\n code: function ConversationMarkdownCode(\n props: React.ComponentPropsWithoutRef<'code'> & { inline?: boolean }\n ) {\n const isStreaming = useContext(MarkdownStreamingContext)\n const { className, children } = props\n const language = /language-(\\w+)/.exec(className || '')?.[1]\n if (!language) {\n // Answers often backtick a bare doc id (`doc-f7b3eeb5`). The text-node pass skips code, so\n // the id would stay monospace text; show it as the document pill. Only a whole id (eight\n // alphanumerics): while streaming, a partial one (\"doc-e\") would be looked up and 404.\n const codeText = typeof children === 'string' ? children.trim() : ''\n if (/^doc-[a-zA-Z0-9]{8}$/.test(codeText)) return <DocumentChip docId={codeText} />\n if (/^eml-[a-zA-Z0-9]{8}$/.test(codeText)) return <MailChip mailId={codeText} />\n }\n // Mermaid lazy-loads its own bundle and re-renders SVG on every change. While streaming the\n // fence is almost always partial, so it stays a code block until generation completes.\n if (language === 'mermaid' && !isStreaming) {\n return <MermaidDiagram chart={String(children).replace(/\\n$/, '')} />\n }\n return <MarkdownCode {...props} />\n },\n span: ({ children, className, ...props }: React.ComponentPropsWithoutRef<'span'>) => {\n const docId = (props as Record<string, unknown>)['data-doc-id'] as string | undefined\n if (docId) return <DocumentChip docId={docId} />\n const mailId = (props as Record<string, unknown>)['data-mail-id'] as string | undefined\n if (mailId) return <MailChip mailId={mailId} />\n return (\n <span className={className} {...props}>\n {children}\n </span>\n )\n },\n}\n\n/** Bare `doc-…` / `eml-…` ids in text become `<span data-doc-id>` / `<span data-mail-id>` pills. */\nconst conversationRehypePlugins = [rehypeDocEntityPills]\n\nexport type ConnectedMarkdownProps = Omit<KitMarkdownRendererProps, 'rehypePlugins'>\n\n/**\n * The kit's renderer with the conversation's overrides; a caller's `components` (e.g. the citation\n * core's) still win over both.\n */\nfunction ConnectedMarkdownComponent({ components, ...props }: ConnectedMarkdownProps) {\n const merged = useMemo(\n () =>\n components\n ? { ...conversationMarkdownComponents, ...components }\n : conversationMarkdownComponents,\n [components]\n )\n return (\n <KitMarkdownRenderer {...props} components={merged} rehypePlugins={conversationRehypePlugins} />\n )\n}\n\nexport const ConnectedMarkdown = React.memo(ConnectedMarkdownComponent)\n","/**\n * The PDF document tools (markup, Freeze, signing, signature requests, productions) on the\n * signed-in session, for any host: the API client, the signed-in user, the host's notices and\n * document opening (`BlocksEnvironment`), and the shared caches a change refreshes. A host with its\n * own binding (its own lists to refresh, an XHR upload with progress, Mail) gives it as the host\n * configuration's `documentTools`, field by field. An enclosing `DocumentToolsProvider` (a dialog\n * with its own client) wins.\n */\n\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { arbiQueryKeys, refreshDocuments, useArbi } from '@arbidocs/react'\nimport {\n DocumentToolsProvider,\n clientUpload,\n documentBytesKey,\n useOptionalDocumentTools,\n type DocumentChange,\n type DocumentToolsClient,\n type DocumentToolsEnvironment,\n type DocumentToolsNotify,\n type DocumentUploadRequest,\n} from '@arbidocs/react/document-tools'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { useConnectedWorkspace } from '../ConnectionProvider'\n\n/** What a host binds of the document tools itself; each absent field is the kit's own. */\nexport interface DocumentToolsHost {\n /** The API client the tools call. Default: the host `arbi`'s. */\n client?: DocumentToolsClient\n /** The deployment domain keys are derived for (signing). Default: the host `arbi`'s. */\n deploymentDomain?: string\n /** Open a document or a version the tools made. Default: the environment's `openDocument`. */\n openDocument?: (documentRef: string) => void\n /** Refresh the host's lists after a change. Default: the shared document caches. */\n onDocumentsChanged?: DocumentToolsEnvironment['onDocumentsChanged']\n /** Upload a derived copy. Default: through the API client, into the open workspace. */\n uploadDocument?: DocumentToolsEnvironment['uploadDocument']\n /**\n * Where \"View certificate\" goes for a signature `reference` (e.g. the site's own verify page).\n * Default: the certificate link the API returns (on the deployment domain).\n */\n certificateUrl?: (reference: string) => string\n /** Email a document (a hook): absent, or returning nothing, when mail is not offered. */\n useEmailDocument?: () => ((documentRef: string) => void) | undefined\n}\n\nconst NO_EMAIL = () => undefined\n\nexport function ConnectedDocumentToolsProvider({ children }: { children: ReactNode }) {\n const enclosing = useOptionalDocumentTools()\n return enclosing ? <>{children}</> : <OwnDocumentTools>{children}</OwnDocumentTools>\n}\n\nfunction OwnDocumentTools({ children }: { children: ReactNode }) {\n const arbi = useArbi()\n const queryClient = useQueryClient()\n const host = useHost().documentTools\n const { user, ensureWorkspaceOpen } = useConnectedWorkspace()\n const { notify: environmentNotify, openDocument: openInHost } = useBlocksEnvironment()\n const useEmailDocument = host?.useEmailDocument ?? NO_EMAIL\n const emailDocument = useEmailDocument()\n const client = host?.client ?? (arbi.isLoggedIn ? arbi.getClient().fetch : null)\n const signer = useMemo(\n () => (user ? { name: user.name, email: user.email, externalId: user.externalId } : null),\n [user]\n )\n const notify = useCallback<DocumentToolsNotify>(\n (message, kind, options) =>\n environmentNotify(message, kind, {\n description: options?.description,\n action: options?.action,\n }),\n [environmentNotify]\n )\n const ownDocumentsChanged = useCallback(\n async (ids: string[], change: DocumentChange) => {\n // The list carries each version's markup count and the copies; a signature or a saved\n // version is a new current version, with new versions and a new rendered PDF.\n const refresh: Promise<unknown>[] = [refreshDocuments(queryClient, arbi, ids)]\n if (change === 'signed' || change === 'version')\n for (const id of ids)\n refresh.push(\n queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documentVersions(id) }),\n queryClient.invalidateQueries({ queryKey: documentBytesKey(id) })\n )\n await Promise.all(refresh)\n },\n [queryClient, arbi]\n )\n // The server files an upload in the session's open workspace: re-assert it first.\n const ownUpload = useCallback(\n async (request: DocumentUploadRequest) => {\n if (!client) throw new Error('Sign in to save a copy.')\n await ensureWorkspaceOpen()\n return clientUpload(client)(request)\n },\n [client, ensureWorkspaceOpen]\n )\n const ownOpenDocument = useCallback((ref: string) => openInHost(ref), [openInHost])\n if (!client) return <>{children}</>\n return (\n <DocumentToolsProvider\n client={client}\n deploymentDomain={host?.deploymentDomain}\n user={signer}\n notify={notify}\n openDocument={host?.openDocument ?? ownOpenDocument}\n onDocumentsChanged={host?.onDocumentsChanged ?? ownDocumentsChanged}\n uploadDocument={host?.uploadDocument ?? ownUpload}\n emailDocument={emailDocument}\n certificateUrl={host?.certificateUrl}\n >\n {children}\n </DocumentToolsProvider>\n )\n}\n","/**\n * What a host adds to the connected document viewer. The viewer reads documents, versions, PDFs,\n * markup and signatures on the signed-in session by itself; these are the host's own things it\n * cannot know: documents the host makes on the client (an artifact streaming in from a chat, an\n * unsaved draft), the host's dialogs and workflows a document action opens, and how the host lays\n * the viewer out. It is the host configuration's `viewer`. Every field is optional: without one the\n * viewer offers less (no Translate button, no draft controls), never something that does nothing.\n * What changes while the viewer is open is read through hooks (`use…`).\n */\n\nimport type { ReactNode } from 'react'\nimport type { components } from '@arbidocs/client'\nimport { useHost } from '../../provider/host'\n\n/** A document's record, as the viewer reads it. */\nexport type ViewerDocumentRecord = components['schemas']['DocResponse']\n\n/** An artifact being generated in a chat, shown in the viewer as it streams. */\nexport interface ViewerStreamingDocument {\n title?: string | null\n /** The content so far (Markdown, or the html/react source of a live artifact). */\n content: string\n /** How it is carried: a document draft, a live `html` / `react` artifact, an `image`. */\n mode?: string | null\n isComplete: boolean\n}\n\n/** A document the user started on the client, with no backend record until it is saved. */\nexport interface ViewerDraftDocument {\n kind: 'text' | 'audio' | 'photo' | 'video'\n title?: string | null\n /** A text draft's starting content. */\n content?: string | null\n}\n\nexport interface DocumentViewerSupport {\n /** The artifact streaming in as this document, if one is (a hook). */\n useStreamingDocument?: (documentId: string) => ViewerStreamingDocument | undefined\n /** The unsaved draft with this client id, if there is one (a hook). */\n useDraftDocument?: (draftId: string) => ViewerDraftDocument | undefined\n /** A draft's kind (text, photo, audio, video), in place of the tabs. */\n renderDraftKind?: (draftId: string) => ReactNode\n /** A draft's name (editable), in place of the title. */\n renderDraftTitle?: (draftId: string) => ReactNode\n /** The recorder of a photo, audio or video draft: the whole body of the viewer. */\n renderCaptureDraft?: (draftId: string) => ReactNode\n /** A text draft was saved as `documentId`; the viewer shows it next. */\n onDraftSaved?: (draftId: string, documentId: string) => void\n /** The copy of a document kept on this device, for when the network is down. */\n loadOfflineCopy?: (document: ViewerDocumentRecord) => Promise<Blob | undefined>\n /** Documents related to the one open (near duplicates), beside its name. */\n renderRelated?: (document: ViewerDocumentRecord) => ReactNode\n /** A document as a pill (the comparison's other side). Default: its name. */\n renderDocumentPill?: (documentId: string) => ReactNode\n /** Open the host's share dialog for the document. Default: share it with the workspace. */\n share?: (document: { id: string; name: string | undefined; isPrivate: boolean }) => void\n /** Ask the assistant about a version (`doc-…@v2`) open read-only. Absent: not offered. */\n askAboutVersion?: (versionRef: string) => void\n /** Translate the document (or the version) on screen. Absent: not offered. */\n translate?: (documentRef: string) => void\n /** Start an image generation from the image on screen. Absent: not offered. */\n useImageAsReference?: (documentId: string) => void\n /**\n * A citation being edited elsewhere (a fact's sources, a field's) picks its passages in the text\n * view: clicks and selections there are handed to it (a hook). Absent: passages are not pickable.\n */\n usePassageCitation?: () => PassageCitation | undefined\n /** Open the document's passages in the host's navigator (a passage's menu). Absent: not offered. */\n openInNavigator?: (documentId: string) => void\n /** Start a new label or field in the host's editor (the passage tagging panel). Absent: not offered. */\n createTag?: () => void\n /** How dates read (versions, signatures). Default: `fmtDate`. */\n formatDate?: (iso: string) => string\n /** Whether the viewer is shown in another window, where PDF pages render without the page's web\n * fonts (a hook). */\n useIsDetached?: () => boolean\n}\n\n/** A passage picked for a citation: its chunk and, when known, its page. */\nexport interface PickedPassage {\n chunk_id: string\n page?: number\n}\n\n/** The citation a host is editing, as the text view sees it. */\nexport interface PassageCitation {\n /** The citation picking passages now, and the document it picks in; null when none is. */\n active: { documentId: string; key: string | null } | null\n /** Passages to light (a fact's cited passages while its sources are open). */\n highlighted: readonly string[]\n /** Passages added to the citation. */\n pick: (passages: PickedPassage[]) => void\n /** Passages taken off it. */\n unpick: (chunkIds: string[]) => void\n}\n\nconst NO_SUPPORT: DocumentViewerSupport = {}\n\nexport function useDocumentViewerSupport(): DocumentViewerSupport {\n return useHost().viewer ?? NO_SUPPORT\n}\n\nconst NONE = () => undefined\nconst ATTACHED = () => false\n\n/** The artifact streaming in as this document (none without the host's). */\nexport function useViewerStreamingDocument(\n documentId: string\n): ViewerStreamingDocument | undefined {\n const useStreaming = useDocumentViewerSupport().useStreamingDocument ?? NONE\n return useStreaming(documentId)\n}\n\n/** The unsaved draft with this id (none without the host's). */\nexport function useViewerDraftDocument(draftId: string): ViewerDraftDocument | undefined {\n const useDraft = useDocumentViewerSupport().useDraftDocument ?? NONE\n return useDraft(draftId)\n}\n\n/** The citation picking passages (none without the host's). */\nexport function useViewerPassageCitation(): PassageCitation | undefined {\n const useCitation = useDocumentViewerSupport().usePassageCitation ?? NONE\n return useCitation()\n}\n\n/** Whether the viewer is in another window (never without the host's). */\nexport function useViewerIsDetached(): boolean {\n const useDetached = useDocumentViewerSupport().useIsDetached ?? ATTACHED\n return useDetached()\n}\n"]}
1
+ {"version":3,"sources":["../src/chat/mermaid-normalize.ts","../src/connection/conversation/MermaidDiagram.tsx","../src/connection/conversation/DocumentWorkspaceContext.tsx","../src/connection/conversation/ConnectedMarkdown.tsx","../src/connection/viewer/ConnectedDocumentToolsProvider.tsx","../src/connection/viewer/support.ts"],"names":["jsx","useContext","KitMarkdownRenderer","Fragment","useMemo"],"mappings":";;;;;;;;;;;;;;;;AAsBO,SAAS,sBAAsB,MAAA,EAAwB;AAE5D,EAAA,IAAI,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA,EAAG,OAAO,MAAA;AAE9B,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,KAAA,CAAM,gCAAgC,CAAA;AACjE,EAAA,IAAI,CAAC,aAAa,OAAO,MAAA;AAEzB,EAAA,MAAM,MAAA,GAAS,WAAA,CAAY,CAAC,CAAA,CAAE,OAAA,EAAQ;AACtC,EAAA,IAAI,OAAO,MAAA,CAAO,KAAA,CAAM,WAAA,CAAY,CAAC,EAAE,MAAM,CAAA;AAG7C,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,uDAAA,EAAyD,OAAO,CAAA;AAIpF,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,cAAA,EAAgB,SAAS,CAAA;AAI7C,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,wCAAA,EAA0C,KAAK,CAAA;AAGnE,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,SAAA,EAAW,IAAI,CAAA;AAEnC,EAAA,OAAO,GAAG,MAAM;AAAA,EAAK,IAAA,CAAK,WAAW,CAAA,CAAA;AACvC;AC9BA,IAAI,eAAA,GAA2D,IAAA;AAC/D,IAAI,kBAAA,GAAuE,IAAA;AAE3E,eAAe,UAAA,GAAa;AAC1B,EAAA,IAAI,iBAAiB,OAAO,eAAA;AAC5B,EAAA,IAAI,CAAC,k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OAAO,MAAM,MAAA;AACnB,IAAM,WAAW,MAAM,KAAA;AAGhB,SAAS,2BACd,UAAA,EACqC;AACrC,EAAA,MAAM,YAAA,GAAe,wBAAA,EAAyB,CAAE,oBAAA,IAAwB,IAAA;AACxE,EAAA,OAAO,aAAa,UAAU,CAAA;AAChC;AAGO,SAAS,uBAAuB,OAAA,EAAkD;AACvF,EAAA,MAAM,QAAA,GAAW,wBAAA,EAAyB,CAAE,gBAAA,IAAoB,IAAA;AAChE,EAAA,OAAO,SAAS,OAAO,CAAA;AACzB;AAGO,SAAS,wBAAA,GAAwD;AACtE,EAAA,MAAM,WAAA,GAAc,wBAAA,EAAyB,CAAE,kBAAA,IAAsB,IAAA;AACrE,EAAA,OAAO,WAAA,EAAY;AACrB;AAGO,SAAS,mBAAA,GAA+B;AAC7C,EAAA,MAAM,WAAA,GAAc,wBAAA,EAAyB,CAAE,aAAA,IAAiB,QAAA;AAChE,EAAA,OAAO,WAAA,EAAY;AACrB","file":"chunk-LSKTOCKN.js","sourcesContent":["/**\n * Defensive normalizer for single-line `graph` / `flowchart` Mermaid source.\n *\n * Some LLMs emit the entire diagram on one line. Mermaid's parser splits\n * statements on newlines, so a single-line graph fails outright. This helper\n * inserts newlines on safe statement boundaries so the diagram has a chance\n * of parsing. Only attempts normalization when:\n * 1. The source has no embedded newlines (i.e. is genuinely single-line), and\n * 2. The first directive is `graph` or `flowchart`.\n *\n * Other diagram types (sequenceDiagram, classDiagram, gantt, …) have very\n * different syntaxes — applying these heuristics to them would corrupt valid\n * input, so they're left untouched.\n *\n * Boundaries we split on:\n * - After the diagram-type header (`graph TD`, `flowchart LR`, …).\n * - Before each `style` / `classDef` / `class` / `linkStyle` / `click`\n * / `subgraph` keyword.\n * - Before/after `end` (closes a subgraph block).\n * - After a `]` (label close) that's followed by another node identifier\n * starting a new edge or node declaration.\n */\nexport function normalizeMermaidGraph(source: string): string {\n // Already multi-line — assume it's well-formed; don't touch it.\n if (/\\n/.test(source)) return source\n\n const headerMatch = source.match(/^\\s*(graph|flowchart)\\s+\\w+\\s+/)\n if (!headerMatch) return source\n\n const header = headerMatch[0].trimEnd()\n let body = source.slice(headerMatch[0].length)\n\n // Insert newline before keywords that always start a new statement.\n body = body.replace(/\\s+(style|classDef|class|linkStyle|click|subgraph)\\s/g, '\\n$1 ')\n\n // `end` closes a subgraph: put it on its own line, with a break after it\n // too so any trailing statements don't stay attached.\n body = body.replace(/\\s+end\\b\\s*/g, '\\nend\\n')\n\n // After a label close (`]`), if the next token looks like a Mermaid node id\n // followed by another `[` or `-->`, that's a new statement starting.\n body = body.replace(/\\]\\s+(?=[A-Za-z_][\\w-]*\\s*(?:\\[|-->))/g, ']\\n')\n\n // Collapse any accidental runs of blank lines we may have produced.\n body = body.replace(/\\n{2,}/g, '\\n')\n\n return `${header}\\n${body.trimStart()}`\n}\n","/**\n * MermaidDiagram Component\n *\n * Renders a Mermaid diagram from source code.\n * Used inside MarkdownRenderer to handle ```mermaid code blocks.\n * Lazy-loads the mermaid library to avoid bloating the initial bundle.\n */\n\nimport { useState, useEffect, useId } from 'react'\nimport { normalizeMermaidGraph } from '../../chat/mermaid-normalize'\n\ninterface MermaidDiagramProps {\n /** Mermaid diagram source code */\n chart: string\n}\n\n// Lazy-load and initialize mermaid once\nlet mermaidInstance: typeof import('mermaid').default | null = null\nlet mermaidLoadPromise: Promise<typeof import('mermaid').default> | null = null\n\nasync function getMermaid() {\n if (mermaidInstance) return mermaidInstance\n if (!mermaidLoadPromise) {\n mermaidLoadPromise = import('mermaid').then((mod) => {\n const m = mod.default\n m.initialize({\n startOnLoad: false,\n theme: 'default',\n securityLevel: 'strict',\n flowchart: { useMaxWidth: true, curve: 'basis' },\n })\n mermaidInstance = m\n return m\n })\n }\n return mermaidLoadPromise\n}\n\nexport function MermaidDiagram({ chart }: MermaidDiagramProps) {\n const [svg, setSvg] = useState<string | null>(null)\n const [error, setError] = useState<string | null>(null)\n const uniqueId = useId().replace(/:/g, '-')\n\n useEffect(() => {\n let cancelled = false\n\n async function render() {\n const mermaid = await getMermaid()\n const diagramId = `mermaid${uniqueId}`\n\n // Validate with parse() before render(). In Mermaid v11 a render() with\n // bad source can return a \"Syntax error in text\" bomb SVG instead of\n // throwing — and it appends DOM side-effects of its own — so a try/catch\n // around render() doesn't reliably catch failures and the bomb leaks\n // into the page (especially under React StrictMode where effects run\n // twice). parse() throws cleanly with no DOM side-effects.\n //\n // Defensive rescue: some LLMs emit single-line `graph`/`flowchart`\n // source. If the original parse fails, try a normalized variant. The\n // normalizer is a no-op on already-multi-line source and on non-graph\n // diagram types, so this only helps the bad-source case and never\n // corrupts valid input.\n let validSource: string | null = null\n let firstErr: unknown\n try {\n await mermaid.parse(chart)\n validSource = chart\n } catch (err) {\n firstErr = err\n const normalized = normalizeMermaidGraph(chart)\n if (normalized !== chart) {\n try {\n await mermaid.parse(normalized)\n validSource = normalized\n } catch (retryErr) {\n console.warn('Mermaid normalized parse also failed', retryErr)\n }\n }\n }\n\n if (cancelled) return\n\n if (!validSource) {\n console.warn('Mermaid parse failed, showing source', firstErr)\n setError('Failed to render diagram')\n setSvg(null)\n return\n }\n\n try {\n const { svg: renderedSvg } = await mermaid.render(diagramId, validSource)\n if (!cancelled) {\n setSvg(renderedSvg)\n setError(null)\n }\n } catch (renderErr) {\n if (!cancelled) {\n console.warn('Mermaid render failed despite parse success', renderErr)\n setError('Failed to render diagram')\n setSvg(null)\n }\n }\n }\n\n render()\n return () => {\n cancelled = true\n }\n }, [chart, uniqueId])\n\n if (error) {\n // Fall back to showing the raw source in a code block\n return (\n <div className=\"code-block\" data-testid=\"mermaid-error\">\n <div className=\"text-sm text-muted-foreground mb-1\">{error}</div>\n <code className=\"language-mermaid\">{chart}</code>\n </div>\n )\n }\n\n if (!svg) {\n return (\n <div\n className=\"flex items-center justify-center py-8 text-muted-foreground text-sm\"\n data-testid=\"mermaid-loading\"\n >\n Rendering diagram...\n </div>\n )\n }\n\n return (\n <div\n className=\"mermaid-diagram my-4 overflow-x-auto rounded-md border border-border bg-background p-4\"\n data-testid=\"mermaid-diagram\"\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n )\n}\n","/**\n * The workspace a conversation's document references belong to, when it is not the open one: an\n * agent's direct-message thread runs in the agent's workspace, so the documents it names are there.\n * A reference then opens that workspace first (`openDocument(id, { workspaceId })`).\n */\n\nimport { createContext, useContext, type ReactNode } from 'react'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\n/** The workspace of the documents referenced inside it (null: the open workspace). */\nexport const DocumentWorkspaceContext = createContext<string | null>(null)\nexport const useDocumentWorkspace = () => useContext(DocumentWorkspaceContext)\n\n/** A reference to a document of another workspace: opening it opens that workspace first. */\nexport function WorkspaceDocumentReference({\n workspaceId,\n docId,\n children,\n className = 'inline-flex rounded-full border px-2 py-0.5 text-xs hover:bg-muted',\n}: {\n workspaceId: string\n docId: string\n children?: ReactNode\n className?: string\n}) {\n const { openDocument } = useBlocksEnvironment()\n return (\n <button\n type=\"button\"\n className={className}\n onClick={() => openDocument(docId, { workspaceId })}\n >\n {children ?? docId}\n </button>\n )\n}\n","/**\n * The conversation's markdown: the kit's `MarkdownRenderer` (`@arbidocs/react`: sanitised HTML,\n * slugs, lazy KaTeX, streaming blocks, tables, code) with what a conversation adds: @mention chips,\n * workspace documents opening in the viewer, quiet external links, document and email pills (the\n * host's chips, `ArbiChatHost.renderDocumentChip` / `renderMailChip`) and Mermaid diagrams.\n */\nimport { useArbiHost, useArbiSession, useDocument } from '@arbidocs/react'\nimport { mentionFromHref, type MentionKind } from '@arbidocs/react/shell'\nimport {\n EntityPill,\n MarkdownCode,\n MarkdownLink,\n MarkdownRenderer as KitMarkdownRenderer,\n MarkdownStreamingContext,\n type MarkdownRendererProps as KitMarkdownRendererProps,\n DocumentEntity,\n} from '@arbidocs/react/ui'\nimport React, { useContext, useMemo } from 'react'\nimport { FileText, Mail } from 'lucide-react'\n\n/** The markdown element overrides, as the kit's renderer takes them. */\ntype Components = NonNullable<KitMarkdownRendererProps['components']>\nimport { MentionChip } from '../../chat/MentionMenu'\nimport { QuietLink } from '../../citations/QuietMarks'\nimport { rehypeDocEntityPills } from '../../chat/rehype-doc-entity-pills'\nimport { workspaceDocIdFromHref } from '../../chat/doc-links'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { MermaidDiagram } from './MermaidDiagram'\nimport { useDocumentWorkspace, WorkspaceDocumentReference } from './DocumentWorkspaceContext'\n\n/** Plain text of a link's children (the `@Label` of a mention link). */\nfunction childrenText(children: React.ReactNode): string {\n return React.Children.toArray(children)\n .map((child) => (typeof child === 'string' || typeof child === 'number' ? String(child) : ''))\n .join('')\n}\n\n/** A mention chip; a mention of the reader stands out. */\nfunction MentionLink({ kind, id, text }: { kind: MentionKind; id: string; text: string }) {\n const currentUserId = useArbiSession().user?.external_id\n return (\n <MentionChip\n kind={kind}\n id={id}\n label={text.replace(/^@/, '')}\n isSelf={kind === 'user' && id === currentUserId}\n />\n )\n}\n\n/**\n * A link to elsewhere, as quiet text. Its menu (Open link / Copy link) is the deliberate step\n * the old confirmation dialog used to be; nothing opens until the menu's primary row is chosen.\n */\nexport function ExternalLink({ href, children }: React.ComponentPropsWithoutRef<'a'>) {\n return (\n <QuietLink href={href} kind=\"external\">\n {children}\n </QuietLink>\n )\n}\n\n/**\n * A workspace document referenced by a link's href rather than by its text.\n *\n * `rehypeDocEntityPills` turns a bare `doc-…` id into a pill, but it only walks\n * TEXT nodes — so `[NVDA DCF Valuation Report](…doc-abc12345…)`, which is how an\n * answer links an artifact it just saved, keeps the id in the href where the\n * plugin never looks. The link then fell through to `ExternalLink`, and opening\n * your own workspace document asked you to confirm an \"external link\" and\n * launched a new tab. It opens in the document viewer, like the pill and the\n * artifact card already do.\n */\nexport function InternalDocLink({\n docId,\n href,\n children,\n}: React.ComponentPropsWithoutRef<'a'> & { docId: string }) {\n const { openDocument } = useBlocksEnvironment()\n const workspaceId = useDocumentWorkspace()\n if (workspaceId) {\n return (\n <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId}>\n {children}\n </WorkspaceDocumentReference>\n )\n }\n\n return (\n <QuietLink href={href} kind=\"document\" onOpen={() => openDocument(docId)}>\n {children}\n </QuietLink>\n )\n}\n\n/** A document of the workspace, as a pill: the host's chip, else the document entity. */\nexport function DocumentChip({ docId }: { docId: string }) {\n const render = useArbiHost().chat?.renderDocumentChip\n const workspaceId = useDocumentWorkspace()\n if (workspaceId) return <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId} />\n return render ? <>{render(docId)}</> : <DefaultDocumentChip docId={docId} />\n}\n\nfunction DefaultDocumentChip({ docId }: { docId: string }) {\n const { data: doc } = useDocument(docId)\n const { openDocument } = useBlocksEnvironment()\n if (!doc)\n return (\n <EntityPill\n icon={<FileText className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label={docId}\n size=\"sm\"\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <DocumentEntity doc={doc} onClick={() => openDocument(docId)} data-testid=\"doc-entity-pill\" />\n )\n}\n\n/** An email of the person's mailbox, as a pill: the host's chip, else a plain \"Email\". */\nexport function MailChip({ mailId }: { mailId: string }) {\n const render = useArbiHost().chat?.renderMailChip\n if (render) return <>{render(mailId)}</>\n return (\n <EntityPill\n icon={<Mail className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label=\"Email\"\n size=\"sm\"\n data-testid=\"mail-entity-pill\"\n />\n )\n}\n\n/**\n * The conversation's overrides, layered on the kit's defaults. Module scope, so the reference is stable\n * and memoised markdown blocks do not re-parse.\n */\nconst conversationMarkdownComponents: Partial<Components> = {\n a: function ConversationMarkdownLink({\n href,\n children,\n ...props\n }: React.ComponentPropsWithoutRef<'a'>) {\n const deploymentDomain = useBlocksEnvironment().runtimeConfig.deploymentDomain\n // @mentions: `linkMentions` turned them into `#mention-<id>` links; draw them as chips.\n const mention = mentionFromHref(href)\n if (mention) {\n return <MentionLink kind={mention.kind} id={mention.id} text={childrenText(children)} />\n }\n // Bookmarks: in-page anchors are near-invisible text; the menu jumps or copies the place.\n if (href?.startsWith('#') && !href.startsWith('#cite-')) {\n return (\n <QuietLink href={href} kind=\"anchor\">\n {children}\n </QuietLink>\n )\n }\n // Citations, `cite:` references and bare links: the kit's link.\n if (!href || href.startsWith('#') || href.startsWith('cite:')) {\n return (\n <MarkdownLink href={href} {...props}>\n {children}\n </MarkdownLink>\n )\n }\n // A workspace document is not an external link, wherever it is hosted: it opens in the viewer.\n const docId = workspaceDocIdFromHref(href, deploymentDomain)\n if (docId) {\n return (\n <InternalDocLink docId={docId} href={href} {...props}>\n {children}\n </InternalDocLink>\n )\n }\n return (\n <ExternalLink href={href} {...props}>\n {children}\n </ExternalLink>\n )\n },\n code: function ConversationMarkdownCode(\n props: React.ComponentPropsWithoutRef<'code'> & { inline?: boolean }\n ) {\n const isStreaming = useContext(MarkdownStreamingContext)\n const { className, children } = props\n const language = /language-(\\w+)/.exec(className || '')?.[1]\n if (!language) {\n // Answers often backtick a bare doc id (`doc-f7b3eeb5`). The text-node pass skips code, so\n // the id would stay monospace text; show it as the document pill. Only a whole id (eight\n // alphanumerics): while streaming, a partial one (\"doc-e\") would be looked up and 404.\n const codeText = typeof children === 'string' ? children.trim() : ''\n if (/^doc-[a-zA-Z0-9]{8}$/.test(codeText)) return <DocumentChip docId={codeText} />\n if (/^eml-[a-zA-Z0-9]{8}$/.test(codeText)) return <MailChip mailId={codeText} />\n }\n // Mermaid lazy-loads its own bundle and re-renders SVG on every change. While streaming the\n // fence is almost always partial, so it stays a code block until generation completes.\n if (language === 'mermaid' && !isStreaming) {\n return <MermaidDiagram chart={String(children).replace(/\\n$/, '')} />\n }\n return <MarkdownCode {...props} />\n },\n span: ({ children, className, ...props }: React.ComponentPropsWithoutRef<'span'>) => {\n const docId = (props as Record<string, unknown>)['data-doc-id'] as string | undefined\n if (docId) return <DocumentChip docId={docId} />\n const mailId = (props as Record<string, unknown>)['data-mail-id'] as string | undefined\n if (mailId) return <MailChip mailId={mailId} />\n return (\n <span className={className} {...props}>\n {children}\n </span>\n )\n },\n}\n\n/** Bare `doc-…` / `eml-…` ids in text become `<span data-doc-id>` / `<span data-mail-id>` pills. */\nconst conversationRehypePlugins = [rehypeDocEntityPills]\n\nexport type ConnectedMarkdownProps = Omit<KitMarkdownRendererProps, 'rehypePlugins'>\n\n/**\n * The kit's renderer with the conversation's overrides; a caller's `components` (e.g. the citation\n * core's) still win over both.\n */\nfunction ConnectedMarkdownComponent({ components, ...props }: ConnectedMarkdownProps) {\n const merged = useMemo(\n () =>\n components\n ? { ...conversationMarkdownComponents, ...components }\n : conversationMarkdownComponents,\n [components]\n )\n return (\n <KitMarkdownRenderer {...props} components={merged} rehypePlugins={conversationRehypePlugins} />\n )\n}\n\nexport const ConnectedMarkdown = React.memo(ConnectedMarkdownComponent)\n","/**\n * The PDF document tools (markup, Freeze, signing, signature requests, productions) on the\n * signed-in session, for any host: the API client, the signed-in user, the host's notices and\n * document opening (`BlocksEnvironment`), and the shared caches a change refreshes. A host with its\n * own binding (its own lists to refresh, an XHR upload with progress, Mail) gives it as the host\n * configuration's `documentTools`, field by field. An enclosing `DocumentToolsProvider` (a dialog\n * with its own client) wins.\n */\n\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { arbiQueryKeys, refreshDocuments, useArbi } from '@arbidocs/react'\nimport {\n DocumentToolsProvider,\n clientUpload,\n documentBytesKey,\n useOptionalDocumentTools,\n type DocumentChange,\n type DocumentToolsClient,\n type DocumentToolsEnvironment,\n type DocumentToolsNotify,\n type DocumentUploadRequest,\n} from '@arbidocs/react/document-tools'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { useConnectedWorkspace } from '../ConnectionProvider'\n\n/** What a host binds of the document tools itself; each absent field is the kit's own. */\nexport interface DocumentToolsHost {\n /** The API client the tools call. Default: the host `arbi`'s. */\n client?: DocumentToolsClient\n /** The deployment domain keys are derived for (signing). Default: the host `arbi`'s. */\n deploymentDomain?: string\n /** Open a document or a version the tools made. Default: the environment's `openDocument`. */\n openDocument?: (documentRef: string) => void\n /** Refresh the host's lists after a change. Default: the shared document caches. */\n onDocumentsChanged?: DocumentToolsEnvironment['onDocumentsChanged']\n /** Upload a derived copy. Default: through the API client, into the open workspace. */\n uploadDocument?: DocumentToolsEnvironment['uploadDocument']\n /**\n * Where \"View certificate\" goes for a signature `reference` (e.g. the site's own verify page).\n * Default: the certificate link the API returns (on the deployment domain).\n */\n certificateUrl?: (reference: string) => string\n /** Email a document (a hook): absent, or returning nothing, when mail is not offered. */\n useEmailDocument?: () => ((documentRef: string) => void) | undefined\n}\n\nconst NO_EMAIL = () => undefined\n\nexport function ConnectedDocumentToolsProvider({ children }: { children: ReactNode }) {\n const enclosing = useOptionalDocumentTools()\n return enclosing ? <>{children}</> : <OwnDocumentTools>{children}</OwnDocumentTools>\n}\n\nfunction OwnDocumentTools({ children }: { children: ReactNode }) {\n const arbi = useArbi()\n const queryClient = useQueryClient()\n const host = useHost().documentTools\n const { user, ensureWorkspaceOpen } = useConnectedWorkspace()\n const { notify: environmentNotify, openDocument: openInHost } = useBlocksEnvironment()\n const useEmailDocument = host?.useEmailDocument ?? NO_EMAIL\n const emailDocument = useEmailDocument()\n const client = host?.client ?? (arbi.isLoggedIn ? arbi.getClient().fetch : null)\n const signer = useMemo(\n () => (user ? { name: user.name, email: user.email, externalId: user.externalId } : null),\n [user]\n )\n const notify = useCallback<DocumentToolsNotify>(\n (message, kind, options) =>\n environmentNotify(message, kind, {\n description: options?.description,\n action: options?.action,\n }),\n [environmentNotify]\n )\n const ownDocumentsChanged = useCallback(\n async (ids: string[], change: DocumentChange) => {\n // The list carries each version's markup count and the copies; a signature or a saved\n // version is a new current version, with new versions and a new rendered PDF.\n const refresh: Promise<unknown>[] = [refreshDocuments(queryClient, arbi, ids)]\n if (change === 'signed' || change === 'version')\n for (const id of ids)\n refresh.push(\n queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documentVersions(id) }),\n queryClient.invalidateQueries({ queryKey: documentBytesKey(id) })\n )\n await Promise.all(refresh)\n },\n [queryClient, arbi]\n )\n // The server files an upload in the session's open workspace: re-assert it first.\n const ownUpload = useCallback(\n async (request: DocumentUploadRequest) => {\n if (!client) throw new Error('Sign in to save a copy.')\n await ensureWorkspaceOpen()\n return clientUpload(client)(request)\n },\n [client, ensureWorkspaceOpen]\n )\n const ownOpenDocument = useCallback((ref: string) => openInHost(ref), [openInHost])\n if (!client) return <>{children}</>\n return (\n <DocumentToolsProvider\n client={client}\n deploymentDomain={host?.deploymentDomain}\n user={signer}\n notify={notify}\n openDocument={host?.openDocument ?? ownOpenDocument}\n onDocumentsChanged={host?.onDocumentsChanged ?? ownDocumentsChanged}\n uploadDocument={host?.uploadDocument ?? ownUpload}\n emailDocument={emailDocument}\n certificateUrl={host?.certificateUrl}\n >\n {children}\n </DocumentToolsProvider>\n )\n}\n","/**\n * What a host adds to the connected document viewer. The viewer reads documents, versions, PDFs,\n * markup and signatures on the signed-in session by itself; these are the host's own things it\n * cannot know: documents the host makes on the client (an artifact streaming in from a chat, an\n * unsaved draft), the host's dialogs and workflows a document action opens, and how the host lays\n * the viewer out. It is the host configuration's `viewer`. Every field is optional: without one the\n * viewer offers less (no Translate button, no draft controls), never something that does nothing.\n * What changes while the viewer is open is read through hooks (`use…`).\n */\n\nimport type { ReactNode } from 'react'\nimport type { components } from '@arbidocs/client'\nimport { useHost } from '../../provider/host'\n\n/** A document's record, as the viewer reads it. */\nexport type ViewerDocumentRecord = components['schemas']['DocResponse']\n\n/** An artifact being generated in a chat, shown in the viewer as it streams. */\nexport interface ViewerStreamingDocument {\n title?: string | null\n /** The content so far (Markdown, or the html/react source of a live artifact). */\n content: string\n /** How it is carried: a document draft, a live `html` / `react` artifact, an `image`. */\n mode?: string | null\n isComplete: boolean\n}\n\n/** A document the user started on the client, with no backend record until it is saved. */\nexport interface ViewerDraftDocument {\n kind: 'text' | 'audio' | 'photo' | 'video'\n title?: string | null\n /** A text draft's starting content. */\n content?: string | null\n}\n\nexport interface DocumentViewerSupport {\n /** The artifact streaming in as this document, if one is (a hook). */\n useStreamingDocument?: (documentId: string) => ViewerStreamingDocument | undefined\n /** The unsaved draft with this client id, if there is one (a hook). */\n useDraftDocument?: (draftId: string) => ViewerDraftDocument | undefined\n /** A draft's kind (text, photo, audio, video), in place of the tabs. */\n renderDraftKind?: (draftId: string) => ReactNode\n /** A draft's name (editable), in place of the title. */\n renderDraftTitle?: (draftId: string) => ReactNode\n /** The recorder of a photo, audio or video draft: the whole body of the viewer. */\n renderCaptureDraft?: (draftId: string) => ReactNode\n /** A text draft was saved as `documentId`; the viewer shows it next. */\n onDraftSaved?: (draftId: string, documentId: string) => void\n /** The copy of a document kept on this device, for when the network is down. */\n loadOfflineCopy?: (document: ViewerDocumentRecord) => Promise<Blob | undefined>\n /** Documents related to the one open (near duplicates), beside its name. */\n renderRelated?: (document: ViewerDocumentRecord) => ReactNode\n /** A document as a pill (the comparison's other side). Default: its name. */\n renderDocumentPill?: (documentId: string) => ReactNode\n /** Open the host's share dialog for the document. Default: share it with the workspace. */\n share?: (document: { id: string; name: string | undefined; isPrivate: boolean }) => void\n /** Ask the assistant about a version (`doc-…@v2`) open read-only. Absent: not offered. */\n askAboutVersion?: (versionRef: string) => void\n /** Translate the document (or the version) on screen. Absent: not offered. */\n translate?: (documentRef: string) => void\n /** Start an image generation from the image on screen. Absent: not offered. */\n useImageAsReference?: (documentId: string) => void\n /**\n * A citation being edited elsewhere (a fact's sources, a field's) picks its passages in the text\n * view: clicks and selections there are handed to it (a hook). Absent: passages are not pickable.\n */\n usePassageCitation?: () => PassageCitation | undefined\n /** Open the document's passages in the host's navigator (a passage's menu). Absent: not offered. */\n openInNavigator?: (documentId: string) => void\n /** Start a new label or field in the host's editor (the passage tagging panel). Absent: not offered. */\n createTag?: () => void\n /** How dates read (versions, signatures). Default: `fmtDate`. */\n formatDate?: (iso: string) => string\n /** Whether the viewer is shown in another window, where PDF pages render without the page's web\n * fonts (a hook). */\n useIsDetached?: () => boolean\n}\n\n/** A passage picked for a citation: its chunk and, when known, its page. */\nexport interface PickedPassage {\n chunk_id: string\n page?: number\n}\n\n/** The citation a host is editing, as the text view sees it. */\nexport interface PassageCitation {\n /** The citation picking passages now, and the document it picks in; null when none is. */\n active: { documentId: string; key: string | null } | null\n /** Passages to light (a fact's cited passages while its sources are open). */\n highlighted: readonly string[]\n /** Passages added to the citation. */\n pick: (passages: PickedPassage[]) => void\n /** Passages taken off it. */\n unpick: (chunkIds: string[]) => void\n}\n\nconst NO_SUPPORT: DocumentViewerSupport = {}\n\nexport function useDocumentViewerSupport(): DocumentViewerSupport {\n return useHost().viewer ?? NO_SUPPORT\n}\n\nconst NONE = () => undefined\nconst ATTACHED = () => false\n\n/** The artifact streaming in as this document (none without the host's). */\nexport function useViewerStreamingDocument(\n documentId: string\n): ViewerStreamingDocument | undefined {\n const useStreaming = useDocumentViewerSupport().useStreamingDocument ?? NONE\n return useStreaming(documentId)\n}\n\n/** The unsaved draft with this id (none without the host's). */\nexport function useViewerDraftDocument(draftId: string): ViewerDraftDocument | undefined {\n const useDraft = useDocumentViewerSupport().useDraftDocument ?? NONE\n return useDraft(draftId)\n}\n\n/** The citation picking passages (none without the host's). */\nexport function useViewerPassageCitation(): PassageCitation | undefined {\n const useCitation = useDocumentViewerSupport().usePassageCitation ?? NONE\n return useCitation()\n}\n\n/** Whether the viewer is in another window (never without the host's). */\nexport function useViewerIsDetached(): boolean {\n const useDetached = useDocumentViewerSupport().useIsDetached ?? ATTACHED\n return useDetached()\n}\n"]}