@arbidocs/blocks 0.5.59 → 0.5.60

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 (214) hide show
  1. package/README.md +40 -0
  2. package/dist/{ConnectedCallDock-IGIDX5LT.cjs → ConnectedCallDock-NEXHEXVL.cjs} +14 -14
  3. package/dist/{ConnectedCallDock-IGIDX5LT.cjs.map → ConnectedCallDock-NEXHEXVL.cjs.map} +1 -1
  4. package/dist/{ConnectedCallDock-KCINYWGF.js → ConnectedCallDock-PMCWZXCO.js} +13 -13
  5. package/dist/{ConnectedCallDock-KCINYWGF.js.map → ConnectedCallDock-PMCWZXCO.js.map} +1 -1
  6. package/dist/{ConnectedCallRoom-V3UUSCMA.cjs → ConnectedCallRoom-GE2TMDIL.cjs} +14 -14
  7. package/dist/{ConnectedCallRoom-V3UUSCMA.cjs.map → ConnectedCallRoom-GE2TMDIL.cjs.map} +1 -1
  8. package/dist/{ConnectedCallRoom-W3IDBOFA.js → ConnectedCallRoom-RJZT5ZUA.js} +13 -13
  9. package/dist/{ConnectedCallRoom-W3IDBOFA.js.map → ConnectedCallRoom-RJZT5ZUA.js.map} +1 -1
  10. package/dist/{ConnectedDocumentViewer-DXBTO2K6.cjs → ConnectedDocumentViewer-2KDPYQDT.cjs} +22 -21
  11. package/dist/{ConnectedDocumentViewer-DXBTO2K6.cjs.map → ConnectedDocumentViewer-2KDPYQDT.cjs.map} +1 -1
  12. package/dist/{ConnectedDocumentViewer-S4TWI5ML.js → ConnectedDocumentViewer-GYLXZV72.js} +21 -20
  13. package/dist/{ConnectedDocumentViewer-S4TWI5ML.js.map → ConnectedDocumentViewer-GYLXZV72.js.map} +1 -1
  14. package/dist/{ConnectedNativeDocxComparison-XOUU4XE4.cjs → ConnectedNativeDocxComparison-2OC37MR5.cjs} +15 -15
  15. package/dist/ConnectedNativeDocxComparison-2OC37MR5.cjs.map +1 -0
  16. package/dist/{ConnectedNativeDocxComparison-4Q57CKP4.js → ConnectedNativeDocxComparison-7PD2LD7L.js} +14 -14
  17. package/dist/ConnectedNativeDocxComparison-7PD2LD7L.js.map +1 -0
  18. package/dist/{ConnectedNativeDocxEditor-EFEAU6CF.cjs → ConnectedNativeDocxEditor-FPIX7SWU.cjs} +15 -15
  19. package/dist/ConnectedNativeDocxEditor-FPIX7SWU.cjs.map +1 -0
  20. package/dist/{ConnectedNativeDocxEditor-4KXAQEBW.js → ConnectedNativeDocxEditor-UMENIC3E.js} +13 -13
  21. package/dist/ConnectedNativeDocxEditor-UMENIC3E.js.map +1 -0
  22. package/dist/{ConnectedStreamedWordArtifact-MWVDNPYF.cjs → ConnectedStreamedWordArtifact-3UZN4UHY.cjs} +15 -15
  23. package/dist/ConnectedStreamedWordArtifact-3UZN4UHY.cjs.map +1 -0
  24. package/dist/{ConnectedStreamedWordArtifact-MKEN2R7Y.js → ConnectedStreamedWordArtifact-K7HVTZIG.js} +14 -14
  25. package/dist/ConnectedStreamedWordArtifact-K7HVTZIG.js.map +1 -0
  26. package/dist/{DocumentReviewCard-RURBAILX.cjs → DocumentReviewCard-B3RRCJBD.cjs} +8 -8
  27. package/dist/{DocumentReviewCard-RURBAILX.cjs.map → DocumentReviewCard-B3RRCJBD.cjs.map} +1 -1
  28. package/dist/{DocumentReviewCard-FHRCV7IB.js → DocumentReviewCard-RPETGTSK.js} +8 -8
  29. package/dist/{DocumentReviewCard-FHRCV7IB.js.map → DocumentReviewCard-RPETGTSK.js.map} +1 -1
  30. package/dist/{WorkspaceTableView-2AZRQUTW.cjs → WorkspaceTableView-2XRSJECY.cjs} +10 -10
  31. package/dist/{WorkspaceTableView-2AZRQUTW.cjs.map → WorkspaceTableView-2XRSJECY.cjs.map} +1 -1
  32. package/dist/{WorkspaceTableView-7D6CO2NO.js → WorkspaceTableView-F4QG4226.js} +8 -8
  33. package/dist/{WorkspaceTableView-7D6CO2NO.js.map → WorkspaceTableView-F4QG4226.js.map} +1 -1
  34. package/dist/agents/index.cjs +344 -344
  35. package/dist/agents/index.js +8 -8
  36. package/dist/calls/index.cjs +2 -2
  37. package/dist/calls/index.js +2 -2
  38. package/dist/chat/index.cjs +167 -167
  39. package/dist/chat/index.js +10 -10
  40. package/dist/{chunk-MSY4JQPU.js → chunk-2N5G5WZ7.js} +3 -3
  41. package/dist/{chunk-MSY4JQPU.js.map → chunk-2N5G5WZ7.js.map} +1 -1
  42. package/dist/chunk-34HQO4ZQ.cjs +72 -0
  43. package/dist/chunk-34HQO4ZQ.cjs.map +1 -0
  44. package/dist/{chunk-EQ3WRY2N.js → chunk-3EWS6ECM.js} +9 -6
  45. package/dist/chunk-3EWS6ECM.js.map +1 -0
  46. package/dist/{chunk-Y564AOO6.js → chunk-6HMWZY3U.js} +3 -3
  47. package/dist/{chunk-Y564AOO6.js.map → chunk-6HMWZY3U.js.map} +1 -1
  48. package/dist/{chunk-FB6DTNMF.cjs → chunk-6TMA6MPT.cjs} +8 -8
  49. package/dist/{chunk-FB6DTNMF.cjs.map → chunk-6TMA6MPT.cjs.map} +1 -1
  50. package/dist/{chunk-JS7KJRKG.js → chunk-75Z5AUMM.js} +3 -3
  51. package/dist/{chunk-JS7KJRKG.js.map → chunk-75Z5AUMM.js.map} +1 -1
  52. package/dist/{chunk-4TCJDGIM.js → chunk-7EOO6ZCK.js} +3 -3
  53. package/dist/{chunk-4TCJDGIM.js.map → chunk-7EOO6ZCK.js.map} +1 -1
  54. package/dist/{chunk-AJCMN23Q.js → chunk-AGDOBXHY.js} +3 -3
  55. package/dist/{chunk-AJCMN23Q.js.map → chunk-AGDOBXHY.js.map} +1 -1
  56. package/dist/{chunk-W7B6VO7E.js → chunk-B63TSC3W.js} +97 -6
  57. package/dist/chunk-B63TSC3W.js.map +1 -0
  58. package/dist/{chunk-HC4GCNCQ.js → chunk-B7XMGAWP.js} +3 -32
  59. package/dist/chunk-B7XMGAWP.js.map +1 -0
  60. package/dist/{chunk-EQRSQZS5.cjs → chunk-BSITLJMQ.cjs} +4 -4
  61. package/dist/{chunk-EQRSQZS5.cjs.map → chunk-BSITLJMQ.cjs.map} +1 -1
  62. package/dist/{chunk-UJN3MBVO.js → chunk-CYECDWVY.js} +3 -3
  63. package/dist/{chunk-UJN3MBVO.js.map → chunk-CYECDWVY.js.map} +1 -1
  64. package/dist/{chunk-NTXOETH6.js → chunk-DP7XGB2D.js} +3 -3
  65. package/dist/{chunk-NTXOETH6.js.map → chunk-DP7XGB2D.js.map} +1 -1
  66. package/dist/{chunk-PFCTYQJH.cjs → chunk-DQ6PNJ6J.cjs} +3 -3
  67. package/dist/{chunk-PFCTYQJH.cjs.map → chunk-DQ6PNJ6J.cjs.map} +1 -1
  68. package/dist/{chunk-XNOQVBU3.cjs → chunk-ECJOIWF4.cjs} +66 -28
  69. package/dist/chunk-ECJOIWF4.cjs.map +1 -0
  70. package/dist/{chunk-AMZNWDTN.cjs → chunk-GCMNPIKB.cjs} +6 -6
  71. package/dist/{chunk-AMZNWDTN.cjs.map → chunk-GCMNPIKB.cjs.map} +1 -1
  72. package/dist/{chunk-QV3YRFQS.js → chunk-GYONAUKV.js} +11 -11
  73. package/dist/{chunk-QV3YRFQS.js.map → chunk-GYONAUKV.js.map} +1 -1
  74. package/dist/chunk-IRPDQJNT.js +70 -0
  75. package/dist/chunk-IRPDQJNT.js.map +1 -0
  76. package/dist/{chunk-62DTFNIS.cjs → chunk-IZXJTVOS.cjs} +44 -7
  77. package/dist/chunk-IZXJTVOS.cjs.map +1 -0
  78. package/dist/{chunk-IHEXSVAI.cjs → chunk-J2A7LVTM.cjs} +70 -70
  79. package/dist/{chunk-IHEXSVAI.cjs.map → chunk-J2A7LVTM.cjs.map} +1 -1
  80. package/dist/{chunk-PFEXFTJ6.js → chunk-JLR67BW2.js} +47 -11
  81. package/dist/chunk-JLR67BW2.js.map +1 -0
  82. package/dist/{chunk-OMWOPRQR.cjs → chunk-JZ4LN4Q6.cjs} +3 -3
  83. package/dist/{chunk-OMWOPRQR.cjs.map → chunk-JZ4LN4Q6.cjs.map} +1 -1
  84. package/dist/{chunk-DDHEN3TC.cjs → chunk-K2UPRNQB.cjs} +3 -3
  85. package/dist/{chunk-DDHEN3TC.cjs.map → chunk-K2UPRNQB.cjs.map} +1 -1
  86. package/dist/{chunk-BFWAIOZK.js → chunk-L4JJKGUD.js} +3 -3
  87. package/dist/{chunk-BFWAIOZK.js.map → chunk-L4JJKGUD.js.map} +1 -1
  88. package/dist/{chunk-6YJLVAR6.cjs → chunk-LVC4ZGYW.cjs} +19 -19
  89. package/dist/{chunk-6YJLVAR6.cjs.map → chunk-LVC4ZGYW.cjs.map} +1 -1
  90. package/dist/{chunk-72VTGWZ5.cjs → chunk-LXKALYOS.cjs} +5 -5
  91. package/dist/{chunk-72VTGWZ5.cjs.map → chunk-LXKALYOS.cjs.map} +1 -1
  92. package/dist/{chunk-TM2D4XT4.cjs → chunk-MZZ3SBQL.cjs} +9 -6
  93. package/dist/chunk-MZZ3SBQL.cjs.map +1 -0
  94. package/dist/{chunk-RJ7753W5.js → chunk-NMU723IY.js} +5 -5
  95. package/dist/{chunk-RJ7753W5.js.map → chunk-NMU723IY.js.map} +1 -1
  96. package/dist/{chunk-BL6KFCZK.cjs → chunk-NUAG57PG.cjs} +18 -18
  97. package/dist/{chunk-BL6KFCZK.cjs.map → chunk-NUAG57PG.cjs.map} +1 -1
  98. package/dist/{chunk-FAYWEPDL.js → chunk-NXSPX7AP.js} +5 -5
  99. package/dist/{chunk-FAYWEPDL.js.map → chunk-NXSPX7AP.js.map} +1 -1
  100. package/dist/{chunk-N27CI32R.cjs → chunk-OM5IVNEW.cjs} +7 -7
  101. package/dist/{chunk-N27CI32R.cjs.map → chunk-OM5IVNEW.cjs.map} +1 -1
  102. package/dist/{chunk-I3BF67WQ.cjs → chunk-Q5GFVDFM.cjs} +9 -9
  103. package/dist/{chunk-I3BF67WQ.cjs.map → chunk-Q5GFVDFM.cjs.map} +1 -1
  104. package/dist/{chunk-PPOL2RVQ.js → chunk-QCDS3ZCF.js} +3 -3
  105. package/dist/{chunk-PPOL2RVQ.js.map → chunk-QCDS3ZCF.js.map} +1 -1
  106. package/dist/{chunk-VEMJON3H.cjs → chunk-QUTIWGWO.cjs} +3 -3
  107. package/dist/{chunk-VEMJON3H.cjs.map → chunk-QUTIWGWO.cjs.map} +1 -1
  108. package/dist/{chunk-TUXGAGPX.js → chunk-R6UKY6NA.js} +7 -7
  109. package/dist/{chunk-TUXGAGPX.js.map → chunk-R6UKY6NA.js.map} +1 -1
  110. package/dist/{chunk-EANS63YE.js → chunk-RGRQWMTF.js} +43 -6
  111. package/dist/chunk-RGRQWMTF.js.map +1 -0
  112. package/dist/{chunk-HWT2IHT4.js → chunk-S45JNJK7.js} +3 -3
  113. package/dist/{chunk-HWT2IHT4.js.map → chunk-S45JNJK7.js.map} +1 -1
  114. package/dist/{chunk-WH2BIMAZ.js → chunk-SBVOYSOO.js} +3 -3
  115. package/dist/{chunk-WH2BIMAZ.js.map → chunk-SBVOYSOO.js.map} +1 -1
  116. package/dist/chunk-SUVMOGTC.js +132 -0
  117. package/dist/chunk-SUVMOGTC.js.map +1 -0
  118. package/dist/chunk-TAVQOU3M.cjs +137 -0
  119. package/dist/chunk-TAVQOU3M.cjs.map +1 -0
  120. package/dist/{chunk-VO3VUC44.cjs → chunk-TFTGDUE4.cjs} +27 -27
  121. package/dist/{chunk-VO3VUC44.cjs.map → chunk-TFTGDUE4.cjs.map} +1 -1
  122. package/dist/{chunk-OXDKLA47.cjs → chunk-TX4CIWH5.cjs} +97 -4
  123. package/dist/chunk-TX4CIWH5.cjs.map +1 -0
  124. package/dist/{chunk-Q3SG3BWO.js → chunk-UIUWCTIZ.js} +3 -3
  125. package/dist/{chunk-Q3SG3BWO.js.map → chunk-UIUWCTIZ.js.map} +1 -1
  126. package/dist/{chunk-HPA4XNIC.js → chunk-UM543YBU.js} +3 -3
  127. package/dist/{chunk-HPA4XNIC.js.map → chunk-UM543YBU.js.map} +1 -1
  128. package/dist/{chunk-T6C5Z4CS.cjs → chunk-UR3MPRJA.cjs} +4 -4
  129. package/dist/{chunk-T6C5Z4CS.cjs.map → chunk-UR3MPRJA.cjs.map} +1 -1
  130. package/dist/{chunk-MQBEX5KB.js → chunk-VB7VPTMB.js} +13 -13
  131. package/dist/{chunk-MQBEX5KB.js.map → chunk-VB7VPTMB.js.map} +1 -1
  132. package/dist/{chunk-HA27GUIF.cjs → chunk-VTY44LKS.cjs} +12 -12
  133. package/dist/{chunk-HA27GUIF.cjs.map → chunk-VTY44LKS.cjs.map} +1 -1
  134. package/dist/{chunk-Z2KOIA5D.cjs → chunk-W427WPYF.cjs} +2 -32
  135. package/dist/chunk-W427WPYF.cjs.map +1 -0
  136. package/dist/{chunk-UPWVMG2X.cjs → chunk-XNZSVCNR.cjs} +4 -4
  137. package/dist/{chunk-UPWVMG2X.cjs.map → chunk-XNZSVCNR.cjs.map} +1 -1
  138. package/dist/{chunk-S65CHL3M.js → chunk-YA2H33OW.js} +5 -5
  139. package/dist/{chunk-S65CHL3M.js.map → chunk-YA2H33OW.js.map} +1 -1
  140. package/dist/{chunk-F72ZD5Q2.cjs → chunk-YD3RN2FY.cjs} +3 -3
  141. package/dist/{chunk-F72ZD5Q2.cjs.map → chunk-YD3RN2FY.cjs.map} +1 -1
  142. package/dist/{chunk-22UJW54C.js → chunk-YXX63XJD.js} +3 -3
  143. package/dist/{chunk-22UJW54C.js.map → chunk-YXX63XJD.js.map} +1 -1
  144. package/dist/{chunk-OS27G5ZI.js → chunk-Z3MWFHZC.js} +3 -3
  145. package/dist/{chunk-OS27G5ZI.js.map → chunk-Z3MWFHZC.js.map} +1 -1
  146. package/dist/{chunk-XUEJYHEP.cjs → chunk-ZDZY6OPL.cjs} +3 -3
  147. package/dist/{chunk-XUEJYHEP.cjs.map → chunk-ZDZY6OPL.cjs.map} +1 -1
  148. package/dist/{chunk-YWBIOI6M.cjs → chunk-ZQDJRROK.cjs} +26 -26
  149. package/dist/{chunk-YWBIOI6M.cjs.map → chunk-ZQDJRROK.cjs.map} +1 -1
  150. package/dist/{chunk-4QDJQC5I.cjs → chunk-ZTTR5MMZ.cjs} +10 -10
  151. package/dist/{chunk-4QDJQC5I.cjs.map → chunk-ZTTR5MMZ.cjs.map} +1 -1
  152. package/dist/collaboration/index.cjs +9 -9
  153. package/dist/collaboration/index.js +1 -1
  154. package/dist/components/Banner.d.ts +9 -3
  155. package/dist/components/ErrorBoundary.d.ts +16 -1
  156. package/dist/components/LoadingIndicator.d.ts +14 -1
  157. package/dist/connect/docx.cjs +17 -17
  158. package/dist/connect/docx.js +13 -13
  159. package/dist/connect/index.cjs +843 -843
  160. package/dist/connect/index.js +45 -45
  161. package/dist/connect/viewer.cjs +21 -20
  162. package/dist/connect/viewer.js +19 -18
  163. package/dist/facts/index.cjs +57 -57
  164. package/dist/facts/index.js +5 -5
  165. package/dist/files/index.cjs +2 -2
  166. package/dist/files/index.js +2 -2
  167. package/dist/home/index.cjs +29 -29
  168. package/dist/home/index.js +4 -4
  169. package/dist/index.cjs +806 -789
  170. package/dist/index.cjs.map +1 -1
  171. package/dist/index.d.ts +1 -1
  172. package/dist/index.js +28 -27
  173. package/dist/index.js.map +1 -1
  174. package/dist/settings/ErrorDialog.d.ts +21 -1
  175. package/dist/settings/error-report.d.ts +26 -0
  176. package/dist/settings/index.cjs +163 -155
  177. package/dist/settings/index.d.ts +2 -1
  178. package/dist/settings/index.js +3 -3
  179. package/dist/shell/AccountBanners.d.ts +22 -0
  180. package/dist/shell/Toaster.d.ts +24 -2
  181. package/dist/shell/index.cjs +91 -74
  182. package/dist/shell/index.d.ts +2 -1
  183. package/dist/shell/index.js +7 -6
  184. package/dist/site/index.cjs +55 -54
  185. package/dist/site/index.js +3 -2
  186. package/dist/studio/index.cjs +56 -55
  187. package/dist/studio/index.cjs.map +1 -1
  188. package/dist/studio/index.js +9 -8
  189. package/dist/studio/index.js.map +1 -1
  190. package/dist/workflow-canvas/index.cjs +44 -44
  191. package/dist/workflow-canvas/index.js +19 -19
  192. package/node_modules/@arbidocs/coedit/package.json +1 -1
  193. package/package.json +5 -5
  194. package/src/blocks.css +83 -2
  195. package/dist/ConnectedNativeDocxComparison-4Q57CKP4.js.map +0 -1
  196. package/dist/ConnectedNativeDocxComparison-XOUU4XE4.cjs.map +0 -1
  197. package/dist/ConnectedNativeDocxEditor-4KXAQEBW.js.map +0 -1
  198. package/dist/ConnectedNativeDocxEditor-EFEAU6CF.cjs.map +0 -1
  199. package/dist/ConnectedStreamedWordArtifact-MKEN2R7Y.js.map +0 -1
  200. package/dist/ConnectedStreamedWordArtifact-MWVDNPYF.cjs.map +0 -1
  201. package/dist/chunk-62DTFNIS.cjs.map +0 -1
  202. package/dist/chunk-EANS63YE.js.map +0 -1
  203. package/dist/chunk-EQ3WRY2N.js.map +0 -1
  204. package/dist/chunk-HC4GCNCQ.js.map +0 -1
  205. package/dist/chunk-OXDKLA47.cjs.map +0 -1
  206. package/dist/chunk-PFEXFTJ6.js.map +0 -1
  207. package/dist/chunk-SOZQJTHB.js +0 -34
  208. package/dist/chunk-SOZQJTHB.js.map +0 -1
  209. package/dist/chunk-TM2D4XT4.cjs.map +0 -1
  210. package/dist/chunk-VTQOMJW7.cjs +0 -37
  211. package/dist/chunk-VTQOMJW7.cjs.map +0 -1
  212. package/dist/chunk-W7B6VO7E.js.map +0 -1
  213. package/dist/chunk-XNOQVBU3.cjs.map +0 -1
  214. package/dist/chunk-Z2KOIA5D.cjs.map +0 -1
@@ -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/documentViewerTabs.ts","../src/connection/viewer/ConnectedDocumentToolsProvider.tsx","../src/connection/viewer/support.ts"],"names":["useState","useId","useEffect","jsxs","jsx","createContext","useContext","useBlocksEnvironment","React","useArbiSession","MentionChip","QuietLink","useArbiHost","Fragment","useDocument","EntityPill","FileText","DocumentEntity","Mail","mentionFromHref","MarkdownLink","workspaceDocIdFromHref","MarkdownStreamingContext","MarkdownCode","rehypeDocEntityPills","useMemo","KitMarkdownRenderer","useOptionalDocumentTools","useArbi","useQueryClient","useHost","useConnectedWorkspace","useCallback","refreshDocuments","arbiQueryKeys","documentBytesKey","clientUpload","DocumentToolsProvider"],"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,kBAAA,EAAoB;AACvB,IAAA,kBAAA,GAAqB,OAAO,SAAS,CAAA,CAAE,IAAA,CAAK,CAAC,GAAA,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YAAA,IAAgB,eAAA;AAAA,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;;;ACvBA,IAAM,aAAoC,EAAC;AAEpC,SAAS,wBAAA,GAAkD;AAChE,EAAA,OAAOP,yBAAA,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-OMWOPRQR.cjs","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","/** The views of the document dialog (`ConnectedDocumentViewer layout=\"dialog\"`). */\n\n/**\n * - `review`: the parsed document with its AI findings, a cited passage marked;\n * - `document`: the whole viewer (PDF and text, markup, signing, versions, sharing);\n * - `ask`: a question about the document, which starts a thread about it.\n */\nexport type DocumentViewerTab = 'review' | 'document' | 'ask'\n\nexport const DEFAULT_DOCUMENT_VIEWER_TABS: readonly DocumentViewerTab[] = [\n 'review',\n 'document',\n 'ask',\n]\n\n/** The dialog's words; each has a neutral default. */\nexport interface DocumentViewerDialogLabels {\n review?: string\n document?: string\n ask?: string\n /** Above the ask bar. */\n askIntro?: string\n /** The ask bar's placeholder; `{title}` is the document's title. */\n askPlaceholder?: string\n}\n\nexport const DEFAULT_DOCUMENT_VIEWER_LABELS: Required<DocumentViewerDialogLabels> = {\n review: 'Review',\n document: 'Document',\n ask: 'Ask AI',\n askIntro:\n 'Your question starts a new thread about this document. The answer cites its passages and takes follow-ups.',\n askPlaceholder: 'Ask about {title}…',\n}\n\nexport const DEFAULT_ASK_SUGGESTIONS: readonly string[] = [\n 'Summarise the key points',\n 'List the dates and deadlines it mentions',\n 'Who are the people and organisations named, and what are their roles?',\n]\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 /** 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/documentViewerTabs.ts","../src/connection/viewer/ConnectedDocumentToolsProvider.tsx","../src/connection/viewer/support.ts"],"names":["useState","useId","useEffect","jsxs","jsx","createContext","useContext","useBlocksEnvironment","React","useArbiSession","MentionChip","QuietLink","useArbiHost","Fragment","useDocument","EntityPill","FileText","DocumentEntity","Mail","mentionFromHref","MarkdownLink","workspaceDocIdFromHref","MarkdownStreamingContext","MarkdownCode","rehypeDocEntityPills","useMemo","KitMarkdownRenderer","useOptionalDocumentTools","useArbi","useQueryClient","useHost","useConnectedWorkspace","useCallback","refreshDocuments","arbiQue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BAAgB,IAAA,EAAM,cAAA;AAAA,MAErB;AAAA;AAAA,GACH;AAEJ;;;ACvBA,IAAM,aAAoC,EAAC;AAEpC,SAAS,wBAAA,GAAkD;AAChE,EAAA,OAAOP,yBAAA,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-JZ4LN4Q6.cjs","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","/** The views of the document dialog (`ConnectedDocumentViewer layout=\"dialog\"`). */\n\n/**\n * - `review`: the parsed document with its AI findings, a cited passage marked;\n * - `document`: the whole viewer (PDF and text, markup, signing, versions, sharing);\n * - `ask`: a question about the document, which starts a thread about it.\n */\nexport type DocumentViewerTab = 'review' | 'document' | 'ask'\n\nexport const DEFAULT_DOCUMENT_VIEWER_TABS: readonly DocumentViewerTab[] = [\n 'review',\n 'document',\n 'ask',\n]\n\n/** The dialog's words; each has a neutral default. */\nexport interface DocumentViewerDialogLabels {\n review?: string\n document?: string\n ask?: string\n /** Above the ask bar. */\n askIntro?: string\n /** The ask bar's placeholder; `{title}` is the document's title. */\n askPlaceholder?: string\n}\n\nexport const DEFAULT_DOCUMENT_VIEWER_LABELS: Required<DocumentViewerDialogLabels> = {\n review: 'Review',\n document: 'Document',\n ask: 'Ask AI',\n askIntro:\n 'Your question starts a new thread about this document. The answer cites its passages and takes follow-ups.',\n askPlaceholder: 'Ask about {title}…',\n}\n\nexport const DEFAULT_ASK_SUGGESTIONS: readonly string[] = [\n 'Summarise the key points',\n 'List the dates and deadlines it mentions',\n 'Who are the people and organisations named, and what are their roles?',\n]\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 /** 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,8 +1,8 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkLUO46ELJ_cjs = require('./chunk-LUO46ELJ.cjs');
5
4
  var chunkAHDJXIUB_cjs = require('./chunk-AHDJXIUB.cjs');
5
+ var chunkLUO46ELJ_cjs = require('./chunk-LUO46ELJ.cjs');
6
6
  var chunkITRI47DF_cjs = require('./chunk-ITRI47DF.cjs');
7
7
  var chunkFX3K6LNZ_cjs = require('./chunk-FX3K6LNZ.cjs');
8
8
  var chunkMHVNT4J3_cjs = require('./chunk-MHVNT4J3.cjs');
@@ -1317,5 +1317,5 @@ exports.useSidebarController = useSidebarController;
1317
1317
  exports.useSidebarSettle = useSidebarSettle;
1318
1318
  exports.workspaceKindColor = workspaceKindColor;
1319
1319
  exports.workspaceKindMeta = workspaceKindMeta;
1320
- //# sourceMappingURL=chunk-DDHEN3TC.cjs.map
1321
- //# sourceMappingURL=chunk-DDHEN3TC.cjs.map
1320
+ //# sourceMappingURL=chunk-K2UPRNQB.cjs.map
1321
+ //# sourceMappingURL=chunk-K2UPRNQB.cjs.map