@arbidocs/blocks 0.5.193 → 0.5.195

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 (192) hide show
  1. package/dist/{ConnectedCallDock-ILFVXVCB.cjs → ConnectedCallDock-L2ER6N2P.cjs} +12 -12
  2. package/dist/{ConnectedCallDock-ILFVXVCB.cjs.map → ConnectedCallDock-L2ER6N2P.cjs.map} +1 -1
  3. package/dist/{ConnectedCallRoom-XUMVIAWS.cjs → ConnectedCallRoom-R6SHBOKX.cjs} +12 -12
  4. package/dist/{ConnectedCallRoom-XUMVIAWS.cjs.map → ConnectedCallRoom-R6SHBOKX.cjs.map} +1 -1
  5. package/dist/{ConnectedNativeDocxComparison-3KBUDWLO.cjs → ConnectedNativeDocxComparison-JNOAKSPK.cjs} +16 -16
  6. package/dist/{ConnectedNativeDocxComparison-3KBUDWLO.cjs.map → ConnectedNativeDocxComparison-JNOAKSPK.cjs.map} +1 -1
  7. package/dist/{ConnectedPresentation-LNDESKYE.cjs → ConnectedPresentation-ZSB7454J.cjs} +13 -13
  8. package/dist/{ConnectedPresentation-LNDESKYE.cjs.map → ConnectedPresentation-ZSB7454J.cjs.map} +1 -1
  9. package/dist/{ConnectedSlidesTab-LEA5OW75.cjs → ConnectedSlidesTab-LCA3ZX5W.cjs} +13 -13
  10. package/dist/{ConnectedSlidesTab-LEA5OW75.cjs.map → ConnectedSlidesTab-LCA3ZX5W.cjs.map} +1 -1
  11. package/dist/{ConnectedStreamedWordArtifact-F4XIWVOG.cjs → ConnectedStreamedWordArtifact-J5HVQMUS.cjs} +16 -16
  12. package/dist/{ConnectedStreamedWordArtifact-F4XIWVOG.cjs.map → ConnectedStreamedWordArtifact-J5HVQMUS.cjs.map} +1 -1
  13. package/dist/{DocumentReviewCard-GWMZMXKZ.cjs → DocumentReviewCard-Q3NKJLSM.cjs} +17 -17
  14. package/dist/{DocumentReviewCard-GWMZMXKZ.cjs.map → DocumentReviewCard-Q3NKJLSM.cjs.map} +1 -1
  15. package/dist/{FilesViewerDialog-SEMFURAU.cjs → FilesViewerDialog-O3ZTKELI.cjs} +34 -34
  16. package/dist/{FilesViewerDialog-SEMFURAU.cjs.map → FilesViewerDialog-O3ZTKELI.cjs.map} +1 -1
  17. package/dist/{WorkspaceTableView-W6NGKKII.cjs → WorkspaceTableView-QT63XYII.cjs} +9 -9
  18. package/dist/{WorkspaceTableView-W6NGKKII.cjs.map → WorkspaceTableView-QT63XYII.cjs.map} +1 -1
  19. package/dist/agents/index.cjs +398 -382
  20. package/dist/agents/tasks/WorkflowThreadStrip.d.ts +3 -1
  21. package/dist/agents/tasks/WorkflowThreadStrip.js +29 -0
  22. package/dist/agents/tasks/WorkflowThreadStrip.js.map +2 -2
  23. package/dist/agents/workflows/StepBarFrame.d.ts +11 -1
  24. package/dist/agents/workflows/StepBarFrame.js +40 -2
  25. package/dist/agents/workflows/StepBarFrame.js.map +2 -2
  26. package/dist/agents/workflows/WorkflowOverview.d.ts +78 -0
  27. package/dist/agents/workflows/WorkflowOverview.js +150 -0
  28. package/dist/agents/workflows/WorkflowOverview.js.map +7 -0
  29. package/dist/agents/workflows/WorkflowRunner.d.ts +2 -0
  30. package/dist/agents/workflows/WorkflowRunner.js +22 -0
  31. package/dist/agents/workflows/WorkflowRunner.js.map +2 -2
  32. package/dist/agents/workflows/WorkflowStepBar.d.ts +5 -1
  33. package/dist/agents/workflows/WorkflowStepBar.js +33 -1
  34. package/dist/agents/workflows/WorkflowStepBar.js.map +2 -2
  35. package/dist/agents/workflows/index.d.ts +1 -0
  36. package/dist/agents/workflows/index.js +10 -0
  37. package/dist/agents/workflows/index.js.map +2 -2
  38. package/dist/agents/workflows/planSteps.js +21 -4
  39. package/dist/agents/workflows/planSteps.js.map +2 -2
  40. package/dist/agents/workflows/run.js +2 -1
  41. package/dist/agents/workflows/run.js.map +2 -2
  42. package/dist/agents/workflows/suggest.d.ts +15 -0
  43. package/dist/agents/workflows/suggest.js +51 -0
  44. package/dist/agents/workflows/suggest.js.map +7 -0
  45. package/dist/agents/workflows/types.d.ts +27 -2
  46. package/dist/agents/workflows/types.js.map +1 -1
  47. package/dist/{ai-C5THVAML.cjs → ai-I7QIW5OA.cjs} +24 -24
  48. package/dist/ai-I7QIW5OA.cjs.map +1 -0
  49. package/dist/calls/index.cjs +24 -24
  50. package/dist/chat/index.cjs +60 -60
  51. package/dist/{chunk-POTF3QQB.cjs → chunk-3GI3UM2T.cjs} +82 -82
  52. package/dist/{chunk-POTF3QQB.cjs.map → chunk-3GI3UM2T.cjs.map} +1 -1
  53. package/dist/{chunk-PIJPM5RA.cjs → chunk-3YGSCNXQ.cjs} +6 -6
  54. package/dist/{chunk-PIJPM5RA.cjs.map → chunk-3YGSCNXQ.cjs.map} +1 -1
  55. package/dist/{chunk-UYYN3T73.cjs → chunk-5WCQ5Y77.cjs} +9 -9
  56. package/dist/{chunk-UYYN3T73.cjs.map → chunk-5WCQ5Y77.cjs.map} +1 -1
  57. package/dist/{chunk-IOTSI4IZ.cjs → chunk-633ZCYVN.cjs} +37 -37
  58. package/dist/{chunk-IOTSI4IZ.cjs.map → chunk-633ZCYVN.cjs.map} +1 -1
  59. package/dist/{chunk-PMZHUK3O.cjs → chunk-6CXTLIGJ.cjs} +6 -6
  60. package/dist/{chunk-PMZHUK3O.cjs.map → chunk-6CXTLIGJ.cjs.map} +1 -1
  61. package/dist/{chunk-E56TJFIR.cjs → chunk-6EATJW7T.cjs} +8 -8
  62. package/dist/{chunk-E56TJFIR.cjs.map → chunk-6EATJW7T.cjs.map} +1 -1
  63. package/dist/{chunk-HS7TUDEM.cjs → chunk-6HP6SQWC.cjs} +7 -7
  64. package/dist/{chunk-HS7TUDEM.cjs.map → chunk-6HP6SQWC.cjs.map} +1 -1
  65. package/dist/{chunk-ER2MRSLT.cjs → chunk-6LNTU7DA.cjs} +16 -16
  66. package/dist/{chunk-ER2MRSLT.cjs.map → chunk-6LNTU7DA.cjs.map} +1 -1
  67. package/dist/{chunk-H4N6BZNU.cjs → chunk-A7MGQMOV.cjs} +3 -3
  68. package/dist/{chunk-H4N6BZNU.cjs.map → chunk-A7MGQMOV.cjs.map} +1 -1
  69. package/dist/{chunk-3P766LID.cjs → chunk-AZUPMHZI.cjs} +4 -4
  70. package/dist/{chunk-3P766LID.cjs.map → chunk-AZUPMHZI.cjs.map} +1 -1
  71. package/dist/{chunk-DRYJIRBS.cjs → chunk-EAH7LFJN.cjs} +5 -5
  72. package/dist/{chunk-DRYJIRBS.cjs.map → chunk-EAH7LFJN.cjs.map} +1 -1
  73. package/dist/{chunk-C4UNKFG6.cjs → chunk-EFV52SZ6.cjs} +4 -4
  74. package/dist/{chunk-C4UNKFG6.cjs.map → chunk-EFV52SZ6.cjs.map} +1 -1
  75. package/dist/{chunk-OO5GWDXK.cjs → chunk-ELN3YOXF.cjs} +28 -28
  76. package/dist/{chunk-OO5GWDXK.cjs.map → chunk-ELN3YOXF.cjs.map} +1 -1
  77. package/dist/{chunk-Y3GJBLAI.cjs → chunk-FSTIAEJW.cjs} +10 -9
  78. package/dist/chunk-FSTIAEJW.cjs.map +1 -0
  79. package/dist/{chunk-WBPP7IEW.cjs → chunk-H4ZKASMT.cjs} +6 -6
  80. package/dist/{chunk-WBPP7IEW.cjs.map → chunk-H4ZKASMT.cjs.map} +1 -1
  81. package/dist/{chunk-ZS74MKNV.cjs → chunk-HBY5PEMC.cjs} +4 -4
  82. package/dist/{chunk-ZS74MKNV.cjs.map → chunk-HBY5PEMC.cjs.map} +1 -1
  83. package/dist/{chunk-3EIO4ZH5.cjs → chunk-HGH5FLYS.cjs} +6 -6
  84. package/dist/{chunk-3EIO4ZH5.cjs.map → chunk-HGH5FLYS.cjs.map} +1 -1
  85. package/dist/{chunk-I6JXZ4FU.cjs → chunk-HJAI3QNK.cjs} +18 -18
  86. package/dist/{chunk-I6JXZ4FU.cjs.map → chunk-HJAI3QNK.cjs.map} +1 -1
  87. package/dist/{chunk-2K5DLB7B.cjs → chunk-IOGN5UAT.cjs} +35 -18
  88. package/dist/chunk-IOGN5UAT.cjs.map +1 -0
  89. package/dist/{chunk-5FSULBPE.cjs → chunk-KC3HRFSO.cjs} +11 -11
  90. package/dist/{chunk-5FSULBPE.cjs.map → chunk-KC3HRFSO.cjs.map} +1 -1
  91. package/dist/{chunk-6QFHYV2J.cjs → chunk-KD37PODE.cjs} +3 -3
  92. package/dist/{chunk-6QFHYV2J.cjs.map → chunk-KD37PODE.cjs.map} +1 -1
  93. package/dist/{chunk-KSBXPXWT.cjs → chunk-KHT2YJ5N.cjs} +5 -5
  94. package/dist/{chunk-KSBXPXWT.cjs.map → chunk-KHT2YJ5N.cjs.map} +1 -1
  95. package/dist/{chunk-6AFAYGJW.cjs → chunk-L3MYUPSH.cjs} +5 -5
  96. package/dist/{chunk-6AFAYGJW.cjs.map → chunk-L3MYUPSH.cjs.map} +1 -1
  97. package/dist/{chunk-JEHGTPS2.cjs → chunk-LYDSETR7.cjs} +3 -3
  98. package/dist/{chunk-JEHGTPS2.cjs.map → chunk-LYDSETR7.cjs.map} +1 -1
  99. package/dist/{chunk-XKXKEVHH.cjs → chunk-NSL5BCGH.cjs} +6 -6
  100. package/dist/{chunk-XKXKEVHH.cjs.map → chunk-NSL5BCGH.cjs.map} +1 -1
  101. package/dist/{chunk-M2KZ2GPP.cjs → chunk-NYNHFDVW.cjs} +19 -19
  102. package/dist/{chunk-M2KZ2GPP.cjs.map → chunk-NYNHFDVW.cjs.map} +1 -1
  103. package/dist/{chunk-S6SG5J4I.cjs → chunk-P5DNNAUY.cjs} +90 -90
  104. package/dist/{chunk-S6SG5J4I.cjs.map → chunk-P5DNNAUY.cjs.map} +1 -1
  105. package/dist/{chunk-M55XUF4L.cjs → chunk-QFSFTO7I.cjs} +7 -7
  106. package/dist/{chunk-M55XUF4L.cjs.map → chunk-QFSFTO7I.cjs.map} +1 -1
  107. package/dist/{chunk-RQN45P3L.cjs → chunk-QXIWLWR2.cjs} +4 -4
  108. package/dist/{chunk-RQN45P3L.cjs.map → chunk-QXIWLWR2.cjs.map} +1 -1
  109. package/dist/{chunk-IRDL2EC6.cjs → chunk-SDID4WK7.cjs} +9 -9
  110. package/dist/{chunk-IRDL2EC6.cjs.map → chunk-SDID4WK7.cjs.map} +1 -1
  111. package/dist/{chunk-VLB6ETIQ.cjs → chunk-SXC4ZIN4.cjs} +3 -3
  112. package/dist/{chunk-VLB6ETIQ.cjs.map → chunk-SXC4ZIN4.cjs.map} +1 -1
  113. package/dist/{chunk-WK4MI52B.cjs → chunk-SYUVP52B.cjs} +59 -59
  114. package/dist/{chunk-WK4MI52B.cjs.map → chunk-SYUVP52B.cjs.map} +1 -1
  115. package/dist/{chunk-7GVKG3G4.cjs → chunk-V4XARTJ4.cjs} +17 -17
  116. package/dist/{chunk-7GVKG3G4.cjs.map → chunk-V4XARTJ4.cjs.map} +1 -1
  117. package/dist/{chunk-5IRDGXB2.cjs → chunk-V5VFRRLL.cjs} +10 -10
  118. package/dist/{chunk-5IRDGXB2.cjs.map → chunk-V5VFRRLL.cjs.map} +1 -1
  119. package/dist/{chunk-SQCCQU3K.cjs → chunk-VOGIYFNN.cjs} +2 -2
  120. package/dist/chunk-VOGIYFNN.cjs.map +1 -0
  121. package/dist/{chunk-GLYPVBBI.cjs → chunk-X3SUQFY7.cjs} +444 -145
  122. package/dist/chunk-X3SUQFY7.cjs.map +1 -0
  123. package/dist/{chunk-XP7BO4JJ.cjs → chunk-YPSCG6ZW.cjs} +18 -18
  124. package/dist/{chunk-XP7BO4JJ.cjs.map → chunk-YPSCG6ZW.cjs.map} +1 -1
  125. package/dist/{chunk-HH5MKRBL.cjs → chunk-YYK2CCMC.cjs} +10 -10
  126. package/dist/{chunk-HH5MKRBL.cjs.map → chunk-YYK2CCMC.cjs.map} +1 -1
  127. package/dist/{chunk-BH322H5B.cjs → chunk-ZLMWMAID.cjs} +6 -6
  128. package/dist/{chunk-BH322H5B.cjs.map → chunk-ZLMWMAID.cjs.map} +1 -1
  129. package/dist/{chunk-OHWYQI3B.cjs → chunk-ZTR3SUN4.cjs} +27 -27
  130. package/dist/{chunk-OHWYQI3B.cjs.map → chunk-ZTR3SUN4.cjs.map} +1 -1
  131. package/dist/connect/docx.cjs +19 -19
  132. package/dist/connect/index.cjs +1168 -1080
  133. package/dist/connect/index.cjs.map +1 -1
  134. package/dist/connect/viewer.cjs +22 -22
  135. package/dist/connection/ConnectedWorkflowBuilder.d.ts +1 -1
  136. package/dist/connection/ConnectedWorkflowBuilder.js.map +2 -2
  137. package/dist/connection/report-problem/ConnectedReportProblem.js +3 -0
  138. package/dist/connection/report-problem/ConnectedReportProblem.js.map +2 -2
  139. package/dist/connection/report-problem/ReportProblemDialog.d.ts +4 -1
  140. package/dist/connection/report-problem/ReportProblemDialog.js +2 -0
  141. package/dist/connection/report-problem/ReportProblemDialog.js.map +2 -2
  142. package/dist/connection/report-problem/SupportVideoEvidence.d.ts +4 -1
  143. package/dist/connection/report-problem/SupportVideoEvidence.js +54 -0
  144. package/dist/connection/report-problem/SupportVideoEvidence.js.map +2 -2
  145. package/dist/connection/report-problem/useSaveRecordingToWorkspace.d.ts +16 -0
  146. package/dist/connection/report-problem/useSaveRecordingToWorkspace.js +39 -0
  147. package/dist/connection/report-problem/useSaveRecordingToWorkspace.js.map +7 -0
  148. package/dist/embed/index.cjs +31 -31
  149. package/dist/facts/index.cjs +1 -1
  150. package/dist/files/index.cjs +223 -223
  151. package/dist/home/index.cjs +1 -1
  152. package/dist/index.cjs +962 -946
  153. package/dist/office/index.cjs +5 -5
  154. package/dist/pages/index.cjs +35 -35
  155. package/dist/record/index.cjs +2 -2
  156. package/dist/record/index.cjs.map +1 -1
  157. package/dist/record/index.js +2 -2
  158. package/dist/record/index.js.map +1 -1
  159. package/dist/record/runs.d.ts +1 -1
  160. package/dist/settings/index.cjs +137 -137
  161. package/dist/shell/index.cjs +2 -2
  162. package/dist/site/index.cjs +9 -9
  163. package/dist/studio/index.cjs +16 -16
  164. package/dist/styles.css +1 -1
  165. package/dist/workflow-canvas/StepActionSettings.d.ts +3 -0
  166. package/dist/workflow-canvas/StepActionSettings.js +48 -2
  167. package/dist/workflow-canvas/StepActionSettings.js.map +2 -2
  168. package/dist/workflow-canvas/StepInspector.d.ts +9 -0
  169. package/dist/workflow-canvas/StepInspector.js +18 -1
  170. package/dist/workflow-canvas/StepInspector.js.map +2 -2
  171. package/dist/workflow-canvas/WorkflowBuilder.d.ts +11 -1
  172. package/dist/workflow-canvas/WorkflowBuilder.js +54 -3
  173. package/dist/workflow-canvas/WorkflowBuilder.js.map +2 -2
  174. package/dist/workflow-canvas/WorkflowOutline.d.ts +55 -0
  175. package/dist/workflow-canvas/WorkflowOutline.js +331 -0
  176. package/dist/workflow-canvas/WorkflowOutline.js.map +7 -0
  177. package/dist/workflow-canvas/edit.d.ts +7 -0
  178. package/dist/workflow-canvas/edit.js +22 -1
  179. package/dist/workflow-canvas/edit.js.map +2 -2
  180. package/dist/workflow-canvas/index.cjs +1339 -909
  181. package/dist/workflow-canvas/index.cjs.map +1 -1
  182. package/dist/workflow-canvas/index.d.ts +2 -1
  183. package/dist/workflow-canvas/index.js +10 -0
  184. package/dist/workflow-canvas/index.js.map +2 -2
  185. package/node_modules/@arbidocs/coedit/package.json +1 -1
  186. package/package.json +6 -5
  187. package/record/recording_clock.py +58 -0
  188. package/dist/ai-C5THVAML.cjs.map +0 -1
  189. package/dist/chunk-2K5DLB7B.cjs.map +0 -1
  190. package/dist/chunk-GLYPVBBI.cjs.map +0 -1
  191. package/dist/chunk-SQCCQU3K.cjs.map +0 -1
  192. package/dist/chunk-Y3GJBLAI.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkM55XUF4L_cjs = require('./chunk-M55XUF4L.cjs');
5
- var chunkSQCCQU3K_cjs = require('./chunk-SQCCQU3K.cjs');
4
+ var chunkQFSFTO7I_cjs = require('./chunk-QFSFTO7I.cjs');
5
+ var chunkVOGIYFNN_cjs = require('./chunk-VOGIYFNN.cjs');
6
6
  var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
7
7
  var chunkHN56WWBR_cjs = require('./chunk-HN56WWBR.cjs');
8
8
  var react = require('@arbidocs/react');
@@ -34,7 +34,7 @@ function useWorkflowTasks() {
34
34
  );
35
35
  const create = react$1.useCallback(
36
36
  async (ctx, forceWorkflow = false) => {
37
- const request = chunkM55XUF4L_cjs.taskComposerToCreateRequest(
37
+ const request = chunkQFSFTO7I_cjs.taskComposerToCreateRequest(
38
38
  { ...ctx, documentTitles, plan: ctx.plan ?? null },
39
39
  activeWorkspaceId ?? void 0,
40
40
  forceWorkflow
@@ -76,7 +76,7 @@ function useWorkflowTasks() {
76
76
  );
77
77
  const update = react$1.useCallback(
78
78
  async (task, ctx) => {
79
- const patch = chunkM55XUF4L_cjs.taskComposerToUpdateRequest({ ...ctx, plan: ctx.plan ?? null });
79
+ const patch = chunkQFSFTO7I_cjs.taskComposerToUpdateRequest({ ...ctx, plan: ctx.plan ?? null });
80
80
  if (task.is_owner === false) delete patch.shared;
81
81
  await updateConversation.mutateAsync({ conversationId: task.external_id, patch });
82
82
  },
@@ -84,7 +84,7 @@ function useWorkflowTasks() {
84
84
  );
85
85
  const updateWorkflow = react$1.useCallback(
86
86
  async (workflow, ctx) => {
87
- const patch = chunkM55XUF4L_cjs.composerToWorkflowUpdate({ ...ctx, documentTitles, plan: ctx.plan ?? null });
87
+ const patch = chunkQFSFTO7I_cjs.composerToWorkflowUpdate({ ...ctx, documentTitles, plan: ctx.plan ?? null });
88
88
  if (workflow.is_owner === false) delete patch.shared;
89
89
  const workspaceId = workflow.workspace_ext_id ?? activeWorkspaceId;
90
90
  const updated = await updateWorkflowMutation.mutateAsync({
@@ -123,7 +123,7 @@ var DEFAULT_PACK_LABEL = "Skills from this site";
123
123
  var NO_PACKS = [];
124
124
  function useHostSkills() {
125
125
  const packs = chunk3YZKDCWY_cjs.useHost().workflows?.skillPacks;
126
- return react$1.useMemo(() => packs?.length ? packs.flatMap(chunkM55XUF4L_cjs.skillPackWorkflows) : NO_PACKS, [packs]);
126
+ return react$1.useMemo(() => packs?.length ? packs.flatMap(chunkQFSFTO7I_cjs.skillPackWorkflows) : NO_PACKS, [packs]);
127
127
  }
128
128
  function hostSkillItem(workflow) {
129
129
  const label = workflow.category ?? workflow.pack.label ?? DEFAULT_PACK_LABEL;
@@ -136,7 +136,7 @@ function hostSkillItem(workflow) {
136
136
  }
137
137
  function useNamedWorkflows(workflows) {
138
138
  const copy = shell.useAssistantCopy();
139
- return react$1.useMemo(() => chunkM55XUF4L_cjs.nameBuiltinWorkflows(workflows, copy), [workflows, copy]);
139
+ return react$1.useMemo(() => chunkQFSFTO7I_cjs.nameBuiltinWorkflows(workflows, copy), [workflows, copy]);
140
140
  }
141
141
 
142
142
  // src/connection/workflows/useWorkflowDefinitions.ts
@@ -152,28 +152,28 @@ function useUsableSkillListings(hostSkills) {
152
152
  function useWorkflowDefinitions() {
153
153
  const hostSkills = useHostSkills();
154
154
  const listings = useUsableSkillListings(hostSkills);
155
- const usage = chunkM55XUF4L_cjs.useWorkflowUsage();
155
+ const usage = chunkQFSFTO7I_cjs.useWorkflowUsage();
156
156
  const skillsEnabled = useSkillsEnabled();
157
- const web = useNamedWorkflows(chunkM55XUF4L_cjs.WEB_WORKFLOWS);
158
- const operations = useNamedWorkflows(chunkM55XUF4L_cjs.DASHBOARD_OPERATIONS);
157
+ const web = useNamedWorkflows(chunkQFSFTO7I_cjs.WEB_WORKFLOWS);
158
+ const operations = useNamedWorkflows(chunkQFSFTO7I_cjs.DASHBOARD_OPERATIONS);
159
159
  return react$1.useMemo(() => {
160
160
  const packSlugs = new Set(hostSkills.map((w) => w.id));
161
- const { host: builtins, skills: fromServer } = chunkSQCCQU3K_cjs.mergeSkillWorkflows(
161
+ const { host: builtins, skills: fromServer } = chunkVOGIYFNN_cjs.mergeSkillWorkflows(
162
162
  web.filter((w) => !packSlugs.has(w.id)),
163
163
  listings
164
164
  );
165
165
  const all = [...builtins, ...hostSkills, ...fromServer];
166
166
  const byId = new Map(all.map((w) => [w.id, w]));
167
- const pinned = chunkM55XUF4L_cjs.DASHBOARD_PINNED.flatMap((id) => {
167
+ const pinned = chunkQFSFTO7I_cjs.DASHBOARD_PINNED.flatMap((id) => {
168
168
  const w = byId.get(id);
169
169
  return w ? [w] : [];
170
170
  });
171
171
  return {
172
172
  skills: all,
173
173
  skillsEnabled,
174
- start: skillsEnabled ? [...builtins, ...chunkM55XUF4L_cjs.sortByRecentUse(fromServer, usage)] : [],
174
+ start: skillsEnabled ? [...builtins, ...chunkQFSFTO7I_cjs.sortByRecentUse(fromServer, usage)] : [],
175
175
  dashboard: [...pinned, ...operations],
176
- forTasks: [chunkM55XUF4L_cjs.CUSTOM_TASK, ...all.filter((w) => w.schedulable), chunkM55XUF4L_cjs.REMIND_TASK]
176
+ forTasks: [chunkQFSFTO7I_cjs.CUSTOM_TASK, ...all.filter((w) => w.schedulable), chunkQFSFTO7I_cjs.REMIND_TASK]
177
177
  };
178
178
  }, [hostSkills, listings, usage, skillsEnabled, web, operations]);
179
179
  }
@@ -189,5 +189,5 @@ exports.useUsableSkillListings = useUsableSkillListings;
189
189
  exports.useWorkflowDefinitions = useWorkflowDefinitions;
190
190
  exports.useWorkflowTasks = useWorkflowTasks;
191
191
  exports.withoutMarketplace = withoutMarketplace;
192
- //# sourceMappingURL=chunk-ER2MRSLT.cjs.map
193
- //# sourceMappingURL=chunk-ER2MRSLT.cjs.map
192
+ //# sourceMappingURL=chunk-6LNTU7DA.cjs.map
193
+ //# sourceMappingURL=chunk-6LNTU7DA.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connection/workflows/useWorkflowTasks.ts","../src/connection/useIsExternalAccount.ts","../src/connection/workflows/useSkillsEnabled.ts","../src/connection/workflows/useHostSkills.ts","../src/connection/workflows/useNamedWorkflows.ts","../src/connection/workflows/useWorkflowDefinitions.ts"],"names":["useRunWorkflow","useStartTaskQuery","useCreateWorkflow","useUpdateConversation","useUpdateWorkflow","useArbiSessionState","useCreateWork","useBlocksEnvironment","useGrantAgentAccess","useCallback","useDocuments","useMemo","getDocumentTitle","taskComposerToCreateRequest","taskComposerToUpdateRequest","composerToWorkflowUpdate","useArbiSession","useUserSettings","useHost","skillPackWorkflows","useAssistantCopy","nameBuiltinWorkflows","useSkills","useWorkflowUsage","WEB_WORKFLOWS","DASHBOARD_OPERATIONS","mergeSkillWorkflows","DASHBOARD_PINNED","sortByRecentUse","CUSTOM_TASK","REMIND_TASK"],"mappings":";;;;;;;;;;;AAuDO,SAAS,gBAAA,GAAmB;AACjC,EAAA,MAAM,cAAcA,oBAAA,EAAe;AACnC,EAAA,MAAM,aAAaC,uBAAA,EAAkB;AACrC,EAAA,MAAM,iBAAiBC,uBAAA,EAAkB;AACzC,EAAA,MAAM,qBAAqBC,2BAAA,EAAsB;AACjD,EAAA,MAAM,yBAAyBC,uBAAA,EAAkB;AACjD,EAAA,MAAM,iBAAA,GAAoBC,yBAAA,CAAoB,CAAC,CAAA,KAAM,EAAE,WAAW,CAAA;AAClE,EAAA,MAAM,UAAA,GAAaC,mBAAA,CAAc,EAAE,WAAA,EAAa,mBAAmB,CAAA;AACnE,EAAA,MAAM,EAAE,SAAA,EAAU,GAAIC,sCAAA,EAAqB;AAI3C,EAAA,MAAM,EAAE,WAAA,EAAa,KAAA,EAAM,GAAIC,yBAAA,EAAoB;AACnD,EAAA,MAAM,gBAAA,GAAmBC,mBAAA;AAAA,IACvB,CAAC,YAAoB,WAAA,KACnB,KAAA,CAAM,EAAE,UAAA,EAAY,WAAA,EAAa,CAAA,CAAE,IAAA;AAAA,MACjC,MAAM,MAAA;AAAA,MACN,MAAM;AAAA,KACR;AAAA,IACF,CAAC,KAAK;AAAA,GACR;AAEA,EAAA,MAAM,EAAE,IAAA,EAAM,SAAA,GAAY,EAAC,KAAMC,kBAAA,EAAa;AAC9C,EAAA,MAAM,cAAA,GAAiBC,eAAA;AAAA,IACrB,MACE,MAAA,CAAO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,CAAC,CAAA;AAAA,MACtC;AAAA,KACF;AAEA,IAAA,MAAM,MAAM,CAAC,GAAG,UAAU,GAAG,UAAA,EAAY,GAAG,UAAU,CAAA;AACtD,IAAA,MAAM,IAAA,GAAO,IAAI,GAAA,CAAI,GAAA,CAAI,GAAA,CAAI,CAAC,CAAA,KAAM,CAAC,CAAA,CAAE,EAAA,EAAI,CAAC,CAAC,CAAC,CAAA;AAC9C,IAAA,MAAM,MAAA,GAASC,kCAAA,CAAiB,OAAA,CAAQ,CAAC,EAAA,KAAO;AAC9C,MAAA,MAAM,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,EAAE,CAAA;AACrB,MAAA,OAAO,CAAA,GAAI,CAAC,CAAC,CAAA,GAAI,EAAC;AAAA,IACpB,CAAC,CAAA;AACD,IAAA,OAAO;AAAA,MACL,MAAA,EAAQ,GAAA;AAAA,MACR,aAAA;AAAA,MACA,KAAA,EAAO,aAAA,GAAgB,CAAC,GAAG,QAAA,EAAU,GAAGC,iCAAA,CAAgB,UAAA,EAAY,KAAK,CAAC,CAAA,GAAI,EAAC;AAAA,MAC/E,SAAA,EAAW,CAAC,GAAG,MAAA,EAAQ,GAAG,UAAU,CAAA;AAAA,MACpC,QAAA,EAAU,CAACC,6BAAA,EAAa,GAAG,GAAA,CAAI,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,WAAW,CAAA,EAAGC,6BAAW;AAAA,KAC1E;AAAA,EACF,CAAA,EAAG,CAAC,UAAA,EAAY,QAAA,EAAU,OAAO,aAAA,EAAe,GAAA,EAAK,UAAU,CAAC,CAAA;AAClE","file":"chunk-ER2MRSLT.cjs","sourcesContent":["/**\n * Creating and updating work and workflows from the composer, in one place.\n *\n * \"Now\" is an assistant query with task options (the person's own run: the thread becomes a task); a plain\n * to-do creates work with no run. Any other start (a date, a repeat, an event, after another task) saves a workflow\n * that creates the work when it fires. The request mapping is shared with every host (and tested in\n * blocks): `taskComposerToCreateRequest` decides which.\n *\n * Workspace authorization is a per-run, least-privilege choice (`auth_mode`) composed over the shipped\n * workspace-access-request + grant machinery:\n * - Now -> no tier: the query runs as the person asking, with their own access.\n * - Workflow -> `scheduled_require_auth` by default (asks at run time), or `scheduled_permanent`\n * (\"keep access\"): standing membership so unattended runs can decrypt while the owner\n * is away. Only this tier grants membership.\n */\n\nimport {\n useCreateWorkflow,\n useGrantAgentAccess,\n useRunWorkflow,\n useUpdateWorkflow,\n useDocuments,\n useArbiSessionState,\n useCreateWork,\n useStartTaskQuery,\n useUpdateConversation,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport type { components } from '@arbidocs/client'\nimport { useCallback, useMemo } from 'react'\nimport {\n composerToWorkflowUpdate,\n taskComposerToCreateRequest,\n taskComposerToUpdateRequest,\n} from '../../agents/tasks/taskRequest'\nimport { type TaskComposerValues } from '../../agents/tasks/taskComposerTypes'\nimport { type WorkflowDefinition } from '../../agents/workflows/types'\nimport type { TaskPlan } from '../../agents/workflows/planSteps'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\ntype Task = components['schemas']['ConversationResponse']\ntype Workflow = components['schemas']['WorkflowResponse']\n\nexport interface TaskSubmitContext {\n workflow: WorkflowDefinition\n values: TaskComposerValues\n /** Goal checklist for agent work, if one was drafted. */\n plan?: TaskPlan | null\n}\n\n/** What a composer submission created. `ran` is null for work no agent runs. */\nexport type CreateOutcome =\n | { kind: 'work'; task: Pick<Task, 'title'> & { external_id?: string }; ran: boolean | null }\n | { kind: 'workflow'; workflow: Workflow }\n\nexport function useWorkflowTasks() {\n const runWorkflow = useRunWorkflow()\n const startQuery = useStartTaskQuery()\n const createWorkflow = useCreateWorkflow()\n const updateConversation = useUpdateConversation()\n const updateWorkflowMutation = useUpdateWorkflow()\n const activeWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const createWork = useCreateWork({ workspaceId: activeWorkspaceId })\n const { openFiles } = useBlocksEnvironment()\n\n // Standing access for a workflow's agent, so its unattended runs can read the workspace. An agent\n // that is already a member makes the server refuse the re-grant: that is no failure here.\n const { mutateAsync: grant } = useGrantAgentAccess()\n const grantAgentAccess = useCallback(\n (agentExtId: string, workspaceId: string) =>\n grant({ agentExtId, workspaceId }).then(\n () => undefined,\n () => undefined\n ),\n [grant]\n )\n // File names for the prompt's wording (\"the document <name>\"): the server is told the ids as well.\n const { data: documents = [] } = useDocuments()\n const documentTitles = useMemo(\n () =>\n Object.fromEntries(documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])),\n [documents]\n )\n\n /**\n * Create work or a workflow. `forceWorkflow` is for the workflow dialog, where even a reminder is\n * saved as a workflow.\n */\n const create = useCallback(\n async (ctx: TaskSubmitContext, forceWorkflow = false): Promise<CreateOutcome> => {\n const request = taskComposerToCreateRequest(\n { ...ctx, documentTitles, plan: ctx.plan ?? null },\n activeWorkspaceId ?? undefined,\n forceWorkflow\n )\n if (request.kind === 'workflow') {\n const workflow = await createWorkflow.mutateAsync(request.body)\n // Keep access: deposit the key for the agent the server assigned (the Assistant when none was\n // picked), while the owner is here, so unattended runs start on their own.\n const workspaceId = workflow.workspace_ext_id ?? request.body.workspace_ext_id\n if (\n workflow.auth_mode === 'scheduled_permanent' &&\n !workflow.on_demand &&\n workflow.agent_ext_id &&\n workspaceId\n ) {\n await grantAgentAccess(workflow.agent_ext_id, workspaceId)\n }\n if (ctx.workflow.documentAction && ctx.values.when === 'now' && !forceWorkflow) {\n const result = await runWorkflow.mutateAsync(workflow.external_id)\n if (result.error) throw new Error(result.error)\n openFiles()\n }\n return { kind: 'workflow', workflow }\n }\n if (request.kind === 'query') {\n // Run now is the person's own assistant query: it makes the thread a task and runs it.\n const { conversationId } = await startQuery.start(request.query)\n return {\n kind: 'work',\n task: { external_id: conversationId, title: request.query.task.title ?? null },\n ran: true,\n }\n }\n // A plain to-do (or reminder): a task with no run.\n const task = await createWork.mutateAsync(request.body)\n return { kind: 'work', task, ran: null }\n },\n [\n activeWorkspaceId,\n createWork,\n createWorkflow,\n documentTitles,\n grantAgentAccess,\n startQuery,\n runWorkflow,\n openFiles,\n ]\n )\n\n /** PATCH the editable fields of a task (the instruction, workspace and agent stay as created). */\n const update = useCallback(\n async (task: Pick<Task, 'external_id'> & { is_owner?: boolean }, ctx: TaskSubmitContext) => {\n const patch = taskComposerToUpdateRequest({ ...ctx, plan: ctx.plan ?? null })\n // Who can see a task is its owner's to change: an editor's save leaves it out.\n if (task.is_owner === false) delete patch.shared\n await updateConversation.mutateAsync({ conversationId: task.external_id, patch })\n },\n [updateConversation]\n )\n\n /** PATCH a workflow: its name, trigger and action. */\n const updateWorkflow = useCallback(\n async (\n workflow: Pick<Workflow, 'external_id' | 'agent_ext_id' | 'workspace_ext_id'> & {\n is_owner?: boolean\n },\n ctx: TaskSubmitContext\n ) => {\n const patch = composerToWorkflowUpdate({ ...ctx, documentTitles, plan: ctx.plan ?? null })\n // Sharing a workflow is its owner's: an editor's save leaves it out.\n if (workflow.is_owner === false) delete patch.shared\n const workspaceId = workflow.workspace_ext_id ?? activeWorkspaceId\n const updated = await updateWorkflowMutation.mutateAsync({\n workflowId: workflow.external_id,\n patch,\n })\n // The agent the server keeps (the Assistant when none was picked) gets the key for unattended runs.\n const agentId = updated.agent_ext_id ?? patch.agent_ext_id ?? workflow.agent_ext_id\n if (\n updated.auth_mode === 'scheduled_permanent' &&\n !updated.on_demand &&\n agentId &&\n workspaceId\n ) {\n await grantAgentAccess(agentId, workspaceId)\n }\n },\n [activeWorkspaceId, documentTitles, grantAgentAccess, updateWorkflowMutation]\n )\n\n return {\n create,\n update,\n updateWorkflow,\n isPending:\n createWork.isPending ||\n startQuery.isPending ||\n createWorkflow.isPending ||\n updateConversation.isPending ||\n updateWorkflowMutation.isPending,\n }\n}\n","import { useArbiSession } from '@arbidocs/react'\n\n/** The account fields that say it is an external one. */\ninterface AccountKind {\n temporary_access_only?: boolean | null\n user_type?: string | null\n}\n\n/** An external account: temporary access to shared workspaces only. */\nexport const isExternalAccount = (user: AccountKind | null | undefined): boolean =>\n !!user && (user.temporary_access_only === true || user.user_type === 'external')\n\n/**\n * Whether the signed-in person is an external guest. They get the built-in skills and the host's\n * skill packs, never the marketplace (the backend enforces it as well).\n */\nexport function useIsExternalAccount(): boolean {\n return isExternalAccount(useArbiSession().user)\n}\n\n/** Skill listings without the marketplace's (`visibility: global`): what an external guest gets. */\nexport const withoutMarketplace = <T extends { visibility?: string | null }>(listings: T[]): T[] =>\n listings.filter((s) => s.visibility !== 'global')\n","/**\n * The one gate for everything skill-shaped in the app: the empty chat's Start list, the skill\n * entries of the slash menu, the sidebar's Skills item, the Skills browser's entry points and the\n * typed `/skill` interception. It is the personal `show_skills` user setting, default off; the\n * switch lives in Settings, Experimental (developers only), so today only developers have it.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\nimport { useIsExternalAccount } from '../useIsExternalAccount'\n\nexport function useSkillsEnabled(): boolean {\n const { data: userSettings } = useUserSettings()\n return userSettings?.show_skills ?? false\n}\n\n/**\n * Whether the Skills browser (the marketplace: \"Browse skills\", the Skills menu entry) is offered:\n * to skills users, never to an external guest (the backend enforces it as well).\n */\nexport function useCanBrowseSkills(): boolean {\n const skillsEnabled = useSkillsEnabled()\n const isExternal = useIsExternalAccount()\n return skillsEnabled && !isExternal\n}\n","/**\n * The host's skill packs (`host.workflows.skillPacks`) as the kit's workflows, and the `/` menu's\n * rows for them: one section per heading (a category, else a pack's label).\n */\nimport { useMemo } from 'react'\nimport { skillPackWorkflows, type SkillPackWorkflow } from '../../agents/workflows/skillPack'\nimport type { SlashMenuItem } from '../../chat/SlashMenu'\nimport { useHost } from '../../provider/host'\n\n/** The section heading of a pack without a label or category. */\nconst DEFAULT_PACK_LABEL = 'Skills from this site'\n\nconst NO_PACKS: SkillPackWorkflow[] = []\n\nexport function useHostSkills(): SkillPackWorkflow[] {\n const packs = useHost().workflows?.skillPacks\n return useMemo(() => (packs?.length ? packs.flatMap(skillPackWorkflows) : NO_PACKS), [packs])\n}\n\n/**\n * A pack skill's `/` menu row. Its section is its heading (its category, else its pack's label), so\n * skills of several packs under one heading share one section.\n */\nexport function hostSkillItem(workflow: SkillPackWorkflow): SlashMenuItem {\n const label = workflow.category ?? workflow.pack.label ?? DEFAULT_PACK_LABEL\n return {\n name: workflow.id,\n description: workflow.description,\n kind: 'skill',\n group: { id: `pack-${label.toLowerCase().replace(/[^a-z0-9]+/g, '-')}`, label },\n }\n}\n","import { useMemo } from 'react'\nimport { useAssistantCopy } from '@arbidocs/react/shell'\nimport { nameBuiltinWorkflows } from '../../agents/workflows/catalogue/seed'\nimport type { WorkflowDefinition } from '../../agents/workflows/types'\n\n/** The seeded workflows in the host's assistant name (`nameBuiltinWorkflows`). */\nexport function useNamedWorkflows(\n workflows: ReadonlyArray<WorkflowDefinition>\n): WorkflowDefinition[] {\n const copy = useAssistantCopy()\n return useMemo(() => nameBuiltinWorkflows(workflows, copy), [workflows, copy])\n}\n","/**\n * The one list of workflows: the seeded ones plus every skill the user can invoke (each degraded\n * to a single-field form from its `arg_hint`). The dashboard tiles, the slash menu, tasks and\n * agents all read this.\n */\n\nimport { useMemo } from 'react'\nimport { useSkills } from '@arbidocs/react'\nimport { mergeSkillWorkflows } from '../../agents/workflows/workflow'\nimport { type WorkflowDefinition } from '../../agents/workflows/types'\nimport {\n CUSTOM_TASK,\n DASHBOARD_OPERATIONS,\n DASHBOARD_PINNED,\n REMIND_TASK,\n} from '../../agents/workflows/catalogue/seed'\nimport { useSkillsEnabled } from './useSkillsEnabled'\nimport { useHostSkills } from './useHostSkills'\nimport { useIsExternalAccount, withoutMarketplace } from '../useIsExternalAccount'\nimport { sortByRecentUse, useWorkflowUsage } from '../../agents/workflows/catalogue/workflow-usage'\nimport { WEB_WORKFLOWS } from '../../agents/workflows/catalogue/registry'\nimport { useNamedWorkflows } from './useNamedWorkflows'\n\nexport interface UseWorkflowDefinitionsResult {\n /**\n * Every skill workflow of this host: built-ins, the host's skill packs, then the user's and the\n * marketplace's (one list).\n */\n skills: WorkflowDefinition[]\n /** The user has skills switched on (`show_skills`): the gate of every skill-shaped surface. */\n skillsEnabled: boolean\n /**\n * The empty chat's Start section: built-ins first (their own order), then the user's own and\n * marketplace skills by recent use, then name. EMPTY for users without skills enabled.\n */\n start: WorkflowDefinition[]\n /** The dashboard Start band: pinned skills in order, then the operation launchers. */\n dashboard: WorkflowDefinition[]\n /** What a task can run: schedulable skills plus a free instruction and a reminder. */\n forTasks: WorkflowDefinition[]\n}\n\n/**\n * The skill listings a person may use from the menus: a host pack's slug is the pack's (an\n * installed copy is the same skill), and an external guest gets no marketplace skills.\n */\nexport function useUsableSkillListings(hostSkills: ReadonlyArray<WorkflowDefinition>) {\n const { data: listings } = useSkills()\n const isExternal = useIsExternalAccount()\n return useMemo(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n const usable = (listings ?? []).filter((s) => !packSlugs.has(s.slug))\n return isExternal ? withoutMarketplace(usable) : usable\n }, [listings, hostSkills, isExternal])\n}\n\nexport function useWorkflowDefinitions(): UseWorkflowDefinitionsResult {\n const hostSkills = useHostSkills()\n const listings = useUsableSkillListings(hostSkills)\n const usage = useWorkflowUsage()\n const skillsEnabled = useSkillsEnabled()\n const web = useNamedWorkflows(WEB_WORKFLOWS)\n const operations = useNamedWorkflows(DASHBOARD_OPERATIONS)\n return useMemo(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n // An uploaded skill of a built-in's slug is used instead of it.\n const { host: builtins, skills: fromServer } = mergeSkillWorkflows(\n web.filter((w) => !packSlugs.has(w.id)),\n listings\n )\n // The host's packs sit with the built-ins; they are listed in the menus, not in Start.\n const all = [...builtins, ...hostSkills, ...fromServer]\n const byId = new Map(all.map((w) => [w.id, w]))\n const pinned = DASHBOARD_PINNED.flatMap((id) => {\n const w = byId.get(id)\n return w ? [w] : []\n })\n return {\n skills: all,\n skillsEnabled,\n start: skillsEnabled ? [...builtins, ...sortByRecentUse(fromServer, usage)] : [],\n dashboard: [...pinned, ...operations],\n forTasks: [CUSTOM_TASK, ...all.filter((w) => w.schedulable), REMIND_TASK],\n }\n }, [hostSkills, listings, usage, skillsEnabled, web, operations])\n}\n"]}
1
+ {"version":3,"sources":["../src/connection/workflows/useWorkflowTasks.ts","../src/connection/useIsExternalAccount.ts","../src/connection/workflows/useSkillsEnabled.ts","../src/connection/workflows/useHostSkills.ts","../src/connection/workflows/useNamedWorkflows.ts","../src/connection/workflows/useWorkflowDefinitions.ts"],"names":["useRunWorkflow","useStartTaskQuery","useCreateWorkflow","useUpdateConversation","useUpdateWorkflow","useArbiSessionState","useCreateWork","useBlocksEnvironment","useGrantAgentAccess","useCallback","useDocuments","useMemo","getDocumentTitle","taskComposerToCreateRequest","taskComposerToUpdateRequest","composerToWorkflowUpdate","useArbiSession","useUserSettings","useHost","skillPackWorkflows","useAssistantCopy","nameBuiltinWorkflows","useSkills","useWorkflowUsage","WEB_WORKFLOWS","DASHBOARD_OPERATIONS","mergeSkillWorkflows","DASHBOARD_PINNED","sortByRecentUse","CUSTOM_TASK","REMIND_TASK"],"mappings":";;;;;;;;;;;AAuDO,SAAS,gBAAA,GAAmB;AACjC,EAAA,MAAM,cAAcA,oBAAA,EAAe;AACnC,EAAA,MAAM,aAAaC,uBAAA,EAAkB;AACrC,EAAA,MAAM,iBAAiBC,uBAAA,EAAkB;AACzC,EAAA,MAAM,qBAAqBC,2BAAA,EAAsB;AACjD,EAAA,MAAM,yBAAyBC,uBAAA,EAAkB;AACjD,EAAA,MAAM,iBAAA,GAAoBC,yBAAA,CAAoB,CAAC,CAAA,KAAM,EAAE,WAAW,CAAA;AAClE,EAAA,MAAM,UAAA,GAAaC,mBAAA,CAAc,EAAE,WAAA,EAAa,mBAAmB,CAAA;AACnE,EAAA,MAAM,EAAE,SAAA,EAAU,GAAIC,sCAAA,EAAqB;AAI3C,EAAA,MAAM,EAAE,WAAA,EAAa,KAAA,EAAM,GAAIC,yBAAA,EAAoB;AACnD,EAAA,MAAM,gBAAA,GAAmBC,mBAAA;AAAA,IACvB,CAAC,YAAoB,WAAA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U,OAAO,aAAA,EAAe,GAAA,EAAK,UAAU,CAAC,CAAA;AAClE","file":"chunk-6LNTU7DA.cjs","sourcesContent":["/**\n * Creating and updating work and workflows from the composer, in one place.\n *\n * \"Now\" is an assistant query with task options (the person's own run: the thread becomes a task); a plain\n * to-do creates work with no run. Any other start (a date, a repeat, an event, after another task) saves a workflow\n * that creates the work when it fires. The request mapping is shared with every host (and tested in\n * blocks): `taskComposerToCreateRequest` decides which.\n *\n * Workspace authorization is a per-run, least-privilege choice (`auth_mode`) composed over the shipped\n * workspace-access-request + grant machinery:\n * - Now -> no tier: the query runs as the person asking, with their own access.\n * - Workflow -> `scheduled_require_auth` by default (asks at run time), or `scheduled_permanent`\n * (\"keep access\"): standing membership so unattended runs can decrypt while the owner\n * is away. Only this tier grants membership.\n */\n\nimport {\n useCreateWorkflow,\n useGrantAgentAccess,\n useRunWorkflow,\n useUpdateWorkflow,\n useDocuments,\n useArbiSessionState,\n useCreateWork,\n useStartTaskQuery,\n useUpdateConversation,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport type { components } from '@arbidocs/client'\nimport { useCallback, useMemo } from 'react'\nimport {\n composerToWorkflowUpdate,\n taskComposerToCreateRequest,\n taskComposerToUpdateRequest,\n} from '../../agents/tasks/taskRequest'\nimport { type TaskComposerValues } from '../../agents/tasks/taskComposerTypes'\nimport { type WorkflowDefinition } from '../../agents/workflows/types'\nimport type { TaskPlan } from '../../agents/workflows/planSteps'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\ntype Task = components['schemas']['ConversationResponse']\ntype Workflow = components['schemas']['WorkflowResponse']\n\nexport interface TaskSubmitContext {\n workflow: WorkflowDefinition\n values: TaskComposerValues\n /** Goal checklist for agent work, if one was drafted. */\n plan?: TaskPlan | null\n}\n\n/** What a composer submission created. `ran` is null for work no agent runs. */\nexport type CreateOutcome =\n | { kind: 'work'; task: Pick<Task, 'title'> & { external_id?: string }; ran: boolean | null }\n | { kind: 'workflow'; workflow: Workflow }\n\nexport function useWorkflowTasks() {\n const runWorkflow = useRunWorkflow()\n const startQuery = useStartTaskQuery()\n const createWorkflow = useCreateWorkflow()\n const updateConversation = useUpdateConversation()\n const updateWorkflowMutation = useUpdateWorkflow()\n const activeWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const createWork = useCreateWork({ workspaceId: activeWorkspaceId })\n const { openFiles } = useBlocksEnvironment()\n\n // Standing access for a workflow's agent, so its unattended runs can read the workspace. An agent\n // that is already a member makes the server refuse the re-grant: that is no failure here.\n const { mutateAsync: grant } = useGrantAgentAccess()\n const grantAgentAccess = useCallback(\n (agentExtId: string, workspaceId: string) =>\n grant({ agentExtId, workspaceId }).then(\n () => undefined,\n () => undefined\n ),\n [grant]\n )\n // File names for the prompt's wording (\"the document <name>\"): the server is told the ids as well.\n const { data: documents = [] } = useDocuments()\n const documentTitles = useMemo(\n () =>\n Object.fromEntries(documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])),\n [documents]\n )\n\n /**\n * Create work or a workflow. `forceWorkflow` is for the workflow dialog, where even a reminder is\n * saved as a workflow.\n */\n const create = useCallback(\n async (ctx: TaskSubmitContext, forceWorkflow = false): Promise<CreateOutcome> => {\n const request = taskComposerToCreateRequest(\n { ...ctx, documentTitles, plan: ctx.plan ?? null },\n activeWorkspaceId ?? undefined,\n forceWorkflow\n )\n if (request.kind === 'workflow') {\n const workflow = await createWorkflow.mutateAsync(request.body)\n // Keep access: deposit the key for the agent the server assigned (the Assistant when none was\n // picked), while the owner is here, so unattended runs start on their own.\n const workspaceId = workflow.workspace_ext_id ?? request.body.workspace_ext_id\n if (\n workflow.auth_mode === 'scheduled_permanent' &&\n !workflow.on_demand &&\n workflow.agent_ext_id &&\n workspaceId\n ) {\n await grantAgentAccess(workflow.agent_ext_id, workspaceId)\n }\n if (ctx.workflow.documentAction && ctx.values.when === 'now' && !forceWorkflow) {\n const result = await runWorkflow.mutateAsync(workflow.external_id)\n if (result.error) throw new Error(result.error)\n openFiles()\n }\n return { kind: 'workflow', workflow }\n }\n if (request.kind === 'query') {\n // Run now is the person's own assistant query: it makes the thread a task and runs it.\n const { conversationId } = await startQuery.start(request.query)\n return {\n kind: 'work',\n task: { external_id: conversationId, title: request.query.task.title ?? null },\n ran: true,\n }\n }\n // A plain to-do (or reminder): a task with no run.\n const task = await createWork.mutateAsync(request.body)\n return { kind: 'work', task, ran: null }\n },\n [\n activeWorkspaceId,\n createWork,\n createWorkflow,\n documentTitles,\n grantAgentAccess,\n startQuery,\n runWorkflow,\n openFiles,\n ]\n )\n\n /** PATCH the editable fields of a task (the instruction, workspace and agent stay as created). */\n const update = useCallback(\n async (task: Pick<Task, 'external_id'> & { is_owner?: boolean }, ctx: TaskSubmitContext) => {\n const patch = taskComposerToUpdateRequest({ ...ctx, plan: ctx.plan ?? null })\n // Who can see a task is its owner's to change: an editor's save leaves it out.\n if (task.is_owner === false) delete patch.shared\n await updateConversation.mutateAsync({ conversationId: task.external_id, patch })\n },\n [updateConversation]\n )\n\n /** PATCH a workflow: its name, trigger and action. */\n const updateWorkflow = useCallback(\n async (\n workflow: Pick<Workflow, 'external_id' | 'agent_ext_id' | 'workspace_ext_id'> & {\n is_owner?: boolean\n },\n ctx: TaskSubmitContext\n ) => {\n const patch = composerToWorkflowUpdate({ ...ctx, documentTitles, plan: ctx.plan ?? null })\n // Sharing a workflow is its owner's: an editor's save leaves it out.\n if (workflow.is_owner === false) delete patch.shared\n const workspaceId = workflow.workspace_ext_id ?? activeWorkspaceId\n const updated = await updateWorkflowMutation.mutateAsync({\n workflowId: workflow.external_id,\n patch,\n })\n // The agent the server keeps (the Assistant when none was picked) gets the key for unattended runs.\n const agentId = updated.agent_ext_id ?? patch.agent_ext_id ?? workflow.agent_ext_id\n if (\n updated.auth_mode === 'scheduled_permanent' &&\n !updated.on_demand &&\n agentId &&\n workspaceId\n ) {\n await grantAgentAccess(agentId, workspaceId)\n }\n },\n [activeWorkspaceId, documentTitles, grantAgentAccess, updateWorkflowMutation]\n )\n\n return {\n create,\n update,\n updateWorkflow,\n isPending:\n createWork.isPending ||\n startQuery.isPending ||\n createWorkflow.isPending ||\n updateConversation.isPending ||\n updateWorkflowMutation.isPending,\n }\n}\n","import { useArbiSession } from '@arbidocs/react'\n\n/** The account fields that say it is an external one. */\ninterface AccountKind {\n temporary_access_only?: boolean | null\n user_type?: string | null\n}\n\n/** An external account: temporary access to shared workspaces only. */\nexport const isExternalAccount = (user: AccountKind | null | undefined): boolean =>\n !!user && (user.temporary_access_only === true || user.user_type === 'external')\n\n/**\n * Whether the signed-in person is an external guest. They get the built-in skills and the host's\n * skill packs, never the marketplace (the backend enforces it as well).\n */\nexport function useIsExternalAccount(): boolean {\n return isExternalAccount(useArbiSession().user)\n}\n\n/** Skill listings without the marketplace's (`visibility: global`): what an external guest gets. */\nexport const withoutMarketplace = <T extends { visibility?: string | null }>(listings: T[]): T[] =>\n listings.filter((s) => s.visibility !== 'global')\n","/**\n * The one gate for everything skill-shaped in the app: the empty chat's Start list, the skill\n * entries of the slash menu, the sidebar's Skills item, the Skills browser's entry points and the\n * typed `/skill` interception. It is the personal `show_skills` user setting, default off; the\n * switch lives in Settings, Experimental (developers only), so today only developers have it.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\nimport { useIsExternalAccount } from '../useIsExternalAccount'\n\nexport function useSkillsEnabled(): boolean {\n const { data: userSettings } = useUserSettings()\n return userSettings?.show_skills ?? false\n}\n\n/**\n * Whether the Skills browser (the marketplace: \"Browse skills\", the Skills menu entry) is offered:\n * to skills users, never to an external guest (the backend enforces it as well).\n */\nexport function useCanBrowseSkills(): boolean {\n const skillsEnabled = useSkillsEnabled()\n const isExternal = useIsExternalAccount()\n return skillsEnabled && !isExternal\n}\n","/**\n * The host's skill packs (`host.workflows.skillPacks`) as the kit's workflows, and the `/` menu's\n * rows for them: one section per heading (a category, else a pack's label).\n */\nimport { useMemo } from 'react'\nimport { skillPackWorkflows, type SkillPackWorkflow } from '../../agents/workflows/skillPack'\nimport type { SlashMenuItem } from '../../chat/SlashMenu'\nimport { useHost } from '../../provider/host'\n\n/** The section heading of a pack without a label or category. */\nconst DEFAULT_PACK_LABEL = 'Skills from this site'\n\nconst NO_PACKS: SkillPackWorkflow[] = []\n\nexport function useHostSkills(): SkillPackWorkflow[] {\n const packs = useHost().workflows?.skillPacks\n return useMemo(() => (packs?.length ? packs.flatMap(skillPackWorkflows) : NO_PACKS), [packs])\n}\n\n/**\n * A pack skill's `/` menu row. Its section is its heading (its category, else its pack's label), so\n * skills of several packs under one heading share one section.\n */\nexport function hostSkillItem(workflow: SkillPackWorkflow): SlashMenuItem {\n const label = workflow.category ?? workflow.pack.label ?? DEFAULT_PACK_LABEL\n return {\n name: workflow.id,\n description: workflow.description,\n kind: 'skill',\n group: { id: `pack-${label.toLowerCase().replace(/[^a-z0-9]+/g, '-')}`, label },\n }\n}\n","import { useMemo } from 'react'\nimport { useAssistantCopy } from '@arbidocs/react/shell'\nimport { nameBuiltinWorkflows } from '../../agents/workflows/catalogue/seed'\nimport type { WorkflowDefinition } from '../../agents/workflows/types'\n\n/** The seeded workflows in the host's assistant name (`nameBuiltinWorkflows`). */\nexport function useNamedWorkflows(\n workflows: ReadonlyArray<WorkflowDefinition>\n): WorkflowDefinition[] {\n const copy = useAssistantCopy()\n return useMemo(() => nameBuiltinWorkflows(workflows, copy), [workflows, copy])\n}\n","/**\n * The one list of workflows: the seeded ones plus every skill the user can invoke (each degraded\n * to a single-field form from its `arg_hint`). The dashboard tiles, the slash menu, tasks and\n * agents all read this.\n */\n\nimport { useMemo } from 'react'\nimport { useSkills } from '@arbidocs/react'\nimport { mergeSkillWorkflows } from '../../agents/workflows/workflow'\nimport { type WorkflowDefinition } from '../../agents/workflows/types'\nimport {\n CUSTOM_TASK,\n DASHBOARD_OPERATIONS,\n DASHBOARD_PINNED,\n REMIND_TASK,\n} from '../../agents/workflows/catalogue/seed'\nimport { useSkillsEnabled } from './useSkillsEnabled'\nimport { useHostSkills } from './useHostSkills'\nimport { useIsExternalAccount, withoutMarketplace } from '../useIsExternalAccount'\nimport { sortByRecentUse, useWorkflowUsage } from '../../agents/workflows/catalogue/workflow-usage'\nimport { WEB_WORKFLOWS } from '../../agents/workflows/catalogue/registry'\nimport { useNamedWorkflows } from './useNamedWorkflows'\n\nexport interface UseWorkflowDefinitionsResult {\n /**\n * Every skill workflow of this host: built-ins, the host's skill packs, then the user's and the\n * marketplace's (one list).\n */\n skills: WorkflowDefinition[]\n /** The user has skills switched on (`show_skills`): the gate of every skill-shaped surface. */\n skillsEnabled: boolean\n /**\n * The empty chat's Start section: built-ins first (their own order), then the user's own and\n * marketplace skills by recent use, then name. EMPTY for users without skills enabled.\n */\n start: WorkflowDefinition[]\n /** The dashboard Start band: pinned skills in order, then the operation launchers. */\n dashboard: WorkflowDefinition[]\n /** What a task can run: schedulable skills plus a free instruction and a reminder. */\n forTasks: WorkflowDefinition[]\n}\n\n/**\n * The skill listings a person may use from the menus: a host pack's slug is the pack's (an\n * installed copy is the same skill), and an external guest gets no marketplace skills.\n */\nexport function useUsableSkillListings(hostSkills: ReadonlyArray<WorkflowDefinition>) {\n const { data: listings } = useSkills()\n const isExternal = useIsExternalAccount()\n return useMemo(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n const usable = (listings ?? []).filter((s) => !packSlugs.has(s.slug))\n return isExternal ? withoutMarketplace(usable) : usable\n }, [listings, hostSkills, isExternal])\n}\n\nexport function useWorkflowDefinitions(): UseWorkflowDefinitionsResult {\n const hostSkills = useHostSkills()\n const listings = useUsableSkillListings(hostSkills)\n const usage = useWorkflowUsage()\n const skillsEnabled = useSkillsEnabled()\n const web = useNamedWorkflows(WEB_WORKFLOWS)\n const operations = useNamedWorkflows(DASHBOARD_OPERATIONS)\n return useMemo(() => {\n const packSlugs = new Set(hostSkills.map((w) => w.id))\n // An uploaded skill of a built-in's slug is used instead of it.\n const { host: builtins, skills: fromServer } = mergeSkillWorkflows(\n web.filter((w) => !packSlugs.has(w.id)),\n listings\n )\n // The host's packs sit with the built-ins; they are listed in the menus, not in Start.\n const all = [...builtins, ...hostSkills, ...fromServer]\n const byId = new Map(all.map((w) => [w.id, w]))\n const pinned = DASHBOARD_PINNED.flatMap((id) => {\n const w = byId.get(id)\n return w ? [w] : []\n })\n return {\n skills: all,\n skillsEnabled,\n start: skillsEnabled ? [...builtins, ...sortByRecentUse(fromServer, usage)] : [],\n dashboard: [...pinned, ...operations],\n forTasks: [CUSTOM_TASK, ...all.filter((w) => w.schedulable), REMIND_TASK],\n }\n }, [hostSkills, listings, usage, skillsEnabled, web, operations])\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkVJNJ4G6Y_cjs = require('./chunk-VJNJ4G6Y.cjs');
5
4
  var chunkE23H6FJR_cjs = require('./chunk-E23H6FJR.cjs');
5
+ var chunkVJNJ4G6Y_cjs = require('./chunk-VJNJ4G6Y.cjs');
6
6
  var chunk75BNMCUX_cjs = require('./chunk-75BNMCUX.cjs');
7
7
  var chunk5OD6DRG7_cjs = require('./chunk-5OD6DRG7.cjs');
8
8
  var chunkPIKTGP55_cjs = require('./chunk-PIKTGP55.cjs');
@@ -512,5 +512,5 @@ exports.MermaidDiagram = MermaidDiagram;
512
512
  exports.WorkspaceDocumentReference = WorkspaceDocumentReference;
513
513
  exports.openEntityReference = openEntityReference;
514
514
  exports.useDocumentWorkspace = useDocumentWorkspace;
515
- //# sourceMappingURL=chunk-H4N6BZNU.cjs.map
516
- //# sourceMappingURL=chunk-H4N6BZNU.cjs.map
515
+ //# sourceMappingURL=chunk-A7MGQMOV.cjs.map
516
+ //# sourceMappingURL=chunk-A7MGQMOV.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connection/conversation/DocumentWorkspaceContext.tsx","../src/chat/mermaid-normalize.ts","../src/connection/conversation/download-mermaid.ts","../src/connection/conversation/MermaidDiagram.tsx","../src/connection/conversation/open-entity-reference.ts","../src/connection/conversation/EntityReference.tsx","../src/connection/conversation/ConnectedMarkdown.tsx"],"names":["createContext","useContext","hrefFor","useBlocksEnvironment","jsx","EntityPill","FileText","useArbiHost","useReferencedDocuments","getDocumentTitle","useState","useId","useEffect","jsxs","Button","Download","DATABASES_OPEN_VIEW","CalendarDays","Phone","MessagesSquare","Folder","Workflow","LayoutDashboard","Database","Table2","StickyNote","Tags","User","useArbiSessionState","useEntityReferenceTitle","useArbiSessionStore","parseHref","parseCallFragment","openCall","EntityIcon","React","useArbiSession","MentionChip","QuietLink","workspaceDocIdFromHref","Fragment","useDocument","DocumentEntity","Mail","mentionFromHref","MarkdownLink","MarkdownStreamingContext","ENTITY_ID","MarkdownCode","rehypeDocEntityPills","useMemo","KitMarkdownRenderer"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcO,IAAM,wBAAA,GAA2BA,oBAA6B,IAAI;AAClE,IAAM,oBAAA,GAAuB,MAAMC,gBAAA,CAAW,wBAAwB;AAG7E,SAAS,qBAAA,CAAsB;AAAA,EAC7B,WAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA,GAAY;AACd,CAAA,EAOG;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,OAAA,EAAAC,QAAAA,KAAYC,sCAAA,EAAqB;AAEvD,EAAA,MAAM,OACJD,QAAAA,CAAQ,EAAE,MAAM,UAAA,EAAY,UAAA,EAAY,OAAO,WAAA,EAAa,CAAA,IAC5DA,yBAAA,CAAe,EAAE,IAAA,EAAM,UAAA,EAAY,YAAY,KAAA,EAAO,WAAA,EAAa,CAAA,IACnE,QAAA;AACF,EAAA,MAAM,IAAA,GAAO,MAAO,WAAA,GAAc,YAAA,CAAa,KAAA,EAAO,EAAE,WAAA,EAAa,CAAA,GAAI,YAAA,CAAa,KAAK,CAAA;AAC3F,EAAA,IAAI,CAAC,QAAA,IAAY,OAAO,QAAA,KAAa,QAAA;AACnC,IAAA,uBACEE,cAAA;AAAA,MAACC,a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AASC,aAAA;AAAA,IACb,MACE,UAAA,GACI,EAAE,GAAG,8BAAA,EAAgC,GAAG,YAAW,GACnD,8BAAA;AAAA,IACN,CAAC,UAAU;AAAA,GACb;AACA,EAAA,uBACE9C,eAAC+C,mBAAA,EAAA,EAAqB,GAAG,OAAO,UAAA,EAAY,MAAA,EAAQ,eAAe,yBAAA,EAA2B,CAAA;AAElG;AAEO,IAAM,iBAAA,GAAoBhB,sBAAA,CAAM,IAAA,CAAK,0BAA0B","file":"chunk-H4N6BZNU.cjs","sourcesContent":["/**\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 { useArbiHost, useReferencedDocuments } from '@arbidocs/react'\nimport { EntityPill, getDocumentTitle } from '@arbidocs/react/ui'\nimport { FileText } from 'lucide-react'\nimport { hrefFor as defaultHrefFor } from '../../lib/routes'\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. */\nfunction DocumentReferenceView({\n workspaceId,\n docId,\n children,\n label,\n copyHref,\n className = 'inline-flex rounded-full border px-2 py-0.5 text-xs hover:bg-muted',\n}: {\n workspaceId?: string | null\n docId: string\n children?: ReactNode\n label?: string\n copyHref?: string\n className?: string\n}) {\n const { openDocument, hrefFor } = useBlocksEnvironment()\n\n const link =\n hrefFor({ kind: 'document', documentId: docId, workspaceId }) ??\n defaultHrefFor({ kind: 'document', documentId: docId, workspaceId }) ??\n copyHref\n const open = () => (workspaceId ? openDocument(docId, { workspaceId }) : openDocument(docId))\n if (!children || typeof children === 'string')\n return (\n <EntityPill\n icon={<FileText className=\"h-3.5 w-3.5 shrink-0\" />}\n label={label || (typeof children === 'string' ? children : 'File')}\n copyHref={link}\n onClick={open}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <button type=\"button\" className={className} onClick={open}>\n {children ?? docId}\n </button>\n )\n}\n\ntype ReferenceProps = Parameters<typeof DocumentReferenceView>[0]\nexport function WorkspaceDocumentReference(props: ReferenceProps) {\n const arbi = useArbiHost().arbi\n return arbi && props.workspaceId && !props.children && !props.label ? (\n <ResolvedDocumentReference {...props} workspaceId={props.workspaceId} />\n ) : (\n <DocumentReferenceView {...props} />\n )\n}\nfunction ResolvedDocumentReference(props: ReferenceProps & { workspaceId: string }) {\n const { data } = useReferencedDocuments(props.workspaceId)\n const doc = data?.find((d) => d.external_id === props.docId)\n return <DocumentReferenceView {...props} label={getDocumentTitle(doc)} />\n}\n","/**\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","/** Save the rendered graphic, including Mermaid's styles, as a standalone image. */\nexport function downloadMermaidSvg(rendered: string): void {\n const doc = new DOMParser().parseFromString(rendered, 'image/svg+xml')\n const svg = doc.documentElement\n if (svg.localName !== 'svg' || doc.querySelector('parsererror'))\n throw new Error('The diagram did not produce a valid SVG image')\n svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n const box = svg\n .getAttribute('viewBox')\n ?.trim()\n .split(/[\\s,]+/)\n .map(Number)\n if (box?.length === 4 && box.every(Number.isFinite) && box[2] > 0 && box[3] > 0) {\n svg.setAttribute('width', String(Math.ceil(box[2])))\n svg.setAttribute('height', String(Math.ceil(box[3])))\n }\n const blob = new Blob([new XMLSerializer().serializeToString(svg)], { type: 'image/svg+xml' })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = 'diagram.svg'\n document.body.append(link)\n try {\n link.click()\n } finally {\n link.remove()\n // Let the browser consume the download before releasing the image URL.\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n }\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 { Download } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { normalizeMermaidGraph } from '../../chat/mermaid-normalize'\nimport { downloadMermaidSvg } from './download-mermaid'\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 >\n <div className=\"mb-2 flex justify-end\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => downloadMermaidSvg(svg)}>\n <Download className=\"mr-2 size-4\" aria-hidden=\"true\" />\n Download SVG\n </Button>\n </div>\n <div dangerouslySetInnerHTML={{ __html: svg }} />\n </div>\n )\n}\n","import { DATABASES_OPEN_VIEW, type ArbiSessionStore } from '@arbidocs/react'\nimport type { Arbi } from '@arbidocs/sdk/browser'\nimport type { BlocksEnvironment } from '../../provider/environment'\n\n/** Navigation intents shared by copied entity links and inline entity menus. */\nexport async function openEntityReference(\n id: string,\n session: ArbiSessionStore,\n env: BlocksEnvironment,\n arbi?: Arbi\n) {\n const prefix = id.split('-')[0]\n switch (prefix) {\n case 'pag':\n session.setViewValue('pages.open', id)\n session.setPage('pages')\n break\n case 'dbs':\n session.setTransientView(DATABASES_OPEN_VIEW, { databaseId: id })\n session.setPage('databases')\n break\n case 'fct':\n env.openFacts?.({ focusId: id })\n break\n case 'tag':\n session.setPage('tags')\n session.setTransientView('tags.focus', id)\n break\n case 'viw': {\n if (!arbi) return\n const workspace = session.getState().workspaceId\n if (!workspace) return\n const view = await arbi.readInWorkspace(workspace, () => arbi.views.get(id))\n if (session.getState().workspaceId !== workspace) return\n if (view.target === 'documents') {\n session.setTransientView('documents.openView', id)\n session.setPage('documents')\n } else {\n session.setTransientView(DATABASES_OPEN_VIEW, { databaseId: view.target, viewId: id })\n session.setPage('databases')\n }\n break\n }\n case 'wfl':\n env.openWorkflow?.(id)\n break\n case 'prj':\n env.openProject(id)\n break\n case 'usr':\n case 'agt':\n env.openDirectChat?.(id)\n break\n case 'cht':\n env.openChat?.(id)\n break\n case 'cal':\n env.openCalendar()\n break\n }\n}\n","import {\n useArbiHost,\n useArbiSessionState,\n useArbiSessionStore,\n openCall,\n useEntityReferenceTitle,\n} from '@arbidocs/react'\nimport { EntityPill, EntityIcon } from '@arbidocs/react/ui'\nimport {\n CalendarDays,\n Phone,\n Database,\n LayoutDashboard,\n Workflow,\n StickyNote,\n Table2,\n Tags,\n User,\n MessagesSquare,\n Folder,\n} from 'lucide-react'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useDocumentWorkspace } from './DocumentWorkspaceContext'\nimport { hrefFor, parseHref } from '../../lib/routes'\nimport { openEntityReference } from './open-entity-reference'\nimport { parseCallFragment } from '@arbidocs/client'\n\nconst kinds = {\n evt: ['Appointment', CalendarDays],\n call: ['Call', Phone],\n con: ['Thread', MessagesSquare],\n wrk: ['Workspace', Folder],\n prj: ['Project', Folder],\n wfl: ['Workflow', Workflow],\n pag: ['Page', LayoutDashboard],\n dbs: ['Database', Database],\n viw: ['Saved view', Table2],\n fct: ['Fact', StickyNote],\n tag: ['Tag', Tags],\n usr: ['Person', User],\n agt: ['Agent', User],\n cht: ['Chat', MessagesSquare],\n cal: ['Calendar', CalendarDays],\n} as const\n\n/** A permission-aware reference, shared by main conversations and encrypted DMs. */\nfunction ConnectedEntityReference({\n id,\n href,\n title,\n workspaceId: explicitWorkspace,\n}: {\n id: string\n href?: string\n title?: string\n workspaceId?: string | null\n}) {\n const contextWorkspace = useDocumentWorkspace()\n const selected = useArbiSessionState((s) => s.workspaceId)\n const workspaceId = explicitWorkspace ?? contextWorkspace ?? selected\n const prefix = id.split('-')[0] as keyof typeof kinds\n const global = ['evt', 'call', 'cal', 'usr', 'agt', 'prj', 'cht'].includes(prefix)\n const metadata = useEntityReferenceTitle(\n id,\n workspaceId,\n global || prefix === 'con' || workspaceId === selected\n )\n return (\n <EntityReferenceView id={id} href={href} title={metadata || title} workspaceId={workspaceId} />\n )\n}\n\ninterface ReferenceProps {\n id: string\n href?: string\n title?: string\n workspaceId?: string | null\n}\nexport function EntityReference(props: ReferenceProps) {\n const arbi = useArbiHost().arbi\n return arbi ? <ConnectedEntityReference {...props} /> : <EntityReferenceView {...props} />\n}\nfunction EntityReferenceView({ id, href, title, workspaceId: explicitWorkspace }: ReferenceProps) {\n const arbi = useArbiHost().arbi\n const env = useBlocksEnvironment()\n const session = useArbiSessionStore()\n const contextWorkspace = useDocumentWorkspace()\n const selected = useArbiSessionState((s) => s.workspaceId)\n const workspaceId = explicitWorkspace ?? contextWorkspace ?? selected\n const prefix = id.split('-')[0] as keyof typeof kinds\n const [kind, Icon] = kinds[prefix] ?? ['Entity', Folder]\n const global = ['evt', 'call', 'cal', 'usr', 'agt', 'prj', 'cht'].includes(prefix)\n const target =\n prefix === 'con'\n ? hrefFor({ kind: 'conversation', conversationId: id, workspaceId })\n : prefix === 'evt'\n ? hrefFor({ kind: 'calendar', eventId: id })\n : prefix === 'call'\n ? hrefFor({ kind: 'call', callId: id })\n : prefix === 'wrk'\n ? hrefFor({ kind: 'workspace', workspaceId: id })\n : hrefFor({\n kind: 'entity',\n entityId: id,\n workspaceId: global ? undefined : workspaceId,\n })\n const link = href ?? target\n const open = () => {\n if (prefix === 'con') {\n const route = href ? parseHref(href) : null\n env.openConversation(id, {\n workspaceId: workspaceId ?? undefined,\n messageId: route?.kind === 'conversation' ? route.messageId : undefined,\n })\n } else if (prefix === 'evt') env.openCalendar({ event: { id } })\n else if (prefix === 'call') {\n const fragment = href ? parseCallFragment(new URL(href, window.location.href).hash) : null\n if (arbi)\n void openCall(arbi, {\n callExtId: id,\n key: fragment?.key,\n linkVersion: fragment?.linkVersion,\n })\n else if (link) env.navigate(link)\n } else if (prefix === 'wrk') env.openWorkspace(id)\n else if (workspaceId && workspaceId !== selected && link) env.navigate(link)\n else\n void openEntityReference(id, session, env, arbi).catch(() =>\n env.notify('Unable to open content.', 'error')\n )\n }\n return (\n <EntityPill\n icon={\n prefix === 'con' ? (\n <EntityIcon entityType=\"CONVERSATION\" className=\"h-3.5 w-3.5 shrink-0\" />\n ) : (\n <Icon className=\"h-3.5 w-3.5 shrink-0\" />\n )\n }\n label={title || kind}\n copyHref={link}\n onClick={open}\n tooltipContent={`${kind}: ${title || id}`}\n labelMaxWidth=\"max-w-[min(20rem,65vw)]\"\n data-testid={`entity-reference-${id}`}\n />\n )\n}\n","import { EntityReference } from './EntityReference'\nimport { ENTITY_ID } from './entity-references'\nimport { parseHref } from '../../lib/routes'\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, useArbiSessionState, 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) =>\n typeof child === 'string' || typeof child === 'number'\n ? String(child)\n : React.isValidElement<{ children?: React.ReactNode }>(child)\n ? childrenText(child.props.children)\n : ''\n )\n .join('')\n}\n\n/** Text labels may be formatted; a non-text leaf (such as an image) needs the rich-child path. */\nfunction plainLinkText(children: React.ReactNode): string | null {\n const parts = React.Children.toArray(children).map((child): string | null => {\n if (typeof child === 'string' || typeof child === 'number') return String(child)\n if (\n React.isValidElement<{ children?: React.ReactNode }>(child) &&\n child.props.children != null\n ) {\n return plainLinkText(child.props.children)\n }\n return null\n })\n return parts.includes(null) ? null : parts.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 { runtimeConfig } = useBlocksEnvironment()\n const conversationWorkspace = useDocumentWorkspace()\n const selectedWorkspace = useArbiSessionState((s) => s.workspaceId)\n // A delegated reference can target a different workspace than its Home DM. Only trust the\n // route after the same origin/deployment check used by the markdown adapters.\n const route =\n href && workspaceDocIdFromHref(href, runtimeConfig.deploymentDomain) === docId\n ? parseHref(href)\n : null\n const workspaceId =\n (route?.kind === 'document' ? route.workspaceId : null) ??\n conversationWorkspace ??\n selectedWorkspace\n const text = plainLinkText(children)?.trim()\n const isAddress = !text || text === href || text === docId\n\n return (\n <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId} copyHref={href}>\n {text === undefined ? children : isAddress ? undefined : text}\n </WorkspaceDocumentReference>\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, hrefFor } = useBlocksEnvironment()\n const selectedWorkspace = useArbiSessionState((s) => s.workspaceId)\n const copyHref = hrefFor({ kind: 'document', documentId: docId, workspaceId: selectedWorkspace })\n if (!doc)\n return (\n <EntityPill\n icon={<FileText className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label=\"File\"\n copyHref={copyHref}\n size=\"sm\"\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <DocumentEntity\n doc={doc}\n copyHref={copyHref}\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n}\n\n/** An email of the person's mailbox, as a pill: the host's chip, else a plain \"Email\". */\nfunction 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 const route = parseHref(href)\n const reference =\n route?.kind === 'entity'\n ? route.entityId\n : route?.kind === 'conversation'\n ? route.conversationId\n : route?.kind === 'workspace'\n ? route.workspaceId\n : route?.kind === 'call'\n ? route.callId\n : route?.kind === 'calendar'\n ? route.eventId\n : undefined\n if (reference && !reference.startsWith('doc-')) {\n const url = new URL(href, window.location.href)\n const trusted =\n url.origin === window.location.origin ||\n (url.protocol === 'https:' && url.hostname === deploymentDomain)\n if (trusted)\n return (\n <EntityReference\n id={reference}\n href={href}\n title={childrenText(children) === href ? undefined : childrenText(children)}\n workspaceId={url.pathname.match(/\\b(wrk-[a-zA-Z0-9]{8})\\b/)?.[1]}\n />\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 if (ENTITY_ID.test(codeText)) return <EntityReference id={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 entityId = (props as Record<string, unknown>)['data-entity-id'] as string | undefined\n if (entityId) return <EntityReference id={entityId} />\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<\n KitMarkdownRendererProps,\n 'rehypePlugins' | 'allowHtml' | 'renderCitation'\n>\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"]}
1
+ {"version":3,"sources":["../src/connection/conversation/DocumentWorkspaceContext.tsx","../src/chat/mermaid-normalize.ts","../src/connection/conversation/download-mermaid.ts","../src/connection/conversation/MermaidDiagram.tsx","../src/connection/conversation/open-entity-reference.ts","../src/connection/conversation/EntityReference.tsx","../src/connection/conversation/ConnectedMarkdown.tsx"],"names":["createContext","useContext","hrefFor","useBlocksEnvironment","jsx","EntityPill","FileText","useArbiHost","useReferencedDocuments","getDocumentTitle","useState","useId","useEffect","jsxs","Button","Download","DATABASES_OPEN_VIEW","CalendarDays","Phone","MessagesSquare","Folder","Workflow","LayoutDashboard","Database","Table2","StickyNote","Tags","User","useArbiSessionState","useEntityReferenceTitle","useArbiSessionStore","parseHref","parseCallFragment","openCall","EntityIcon","React","useArbiSession","MentionChip","QuietLink","workspaceDocIdFromHref","Fragment","useDocument","DocumentEntity","Mail","mentionFromHref","MarkdownLink","MarkdownStreamingContext","ENTITY_ID","MarkdownCode","rehypeDocEntityPills","useMemo","KitMarkdownRenderer"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcO,IAAM,wBAAA,GAA2BA,oBAA6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A,EACA,MAAM,CAAC,EAAE,UAAU,SAAA,EAAW,GAAG,OAAM,KAA8C;AACnF,IAAA,MAAM,QAAA,GAAY,MAAkC,gBAAgB,CAAA;AACpE,IAAA,IAAI,UAAU,uBAAO5C,cAAAA,CAAC,eAAA,EAAA,EAAgB,IAAI,QAAA,EAAU,CAAA;AACpD,IAAA,MAAM,KAAA,GAAS,MAAkC,aAAa,CAAA;AAC9D,IAAA,IAAI,KAAA,EAAO,uBAAOA,cAAAA,CAAC,gBAAa,KAAA,EAAc,CAAA;AAC9C,IAAA,MAAM,MAAA,GAAU,MAAkC,cAAc,CAAA;AAChE,IAAA,IAAI,MAAA,EAAQ,uBAAOA,cAAAA,CAAC,YAAS,MAAA,EAAgB,CAAA;AAC7C,IAAA,uBACEA,cAAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAuB,GAAG,OAC7B,QAAA,EACH,CAAA;AAAA,EAEJ;AACF,CAAA;AAGA,IAAM,yBAAA,GAA4B,CAAC6C,sCAAoB,CAAA;AAWvD,SAAS,0BAAA,CAA2B,EAAE,UAAA,EAAY,GAAG,OAAM,EAA2B;AACpF,EAAA,MAAM,MAAA,GAASC,aAAA;AAAA,IACb,MACE,UAAA,GACI,EAAE,GAAG,8BAAA,EAAgC,GAAG,YAAW,GACnD,8BAAA;AAAA,IACN,CAAC,UAAU;AAAA,GACb;AACA,EAAA,uBACE9C,eAAC+C,mBAAA,EAAA,EAAqB,GAAG,OAAO,UAAA,EAAY,MAAA,EAAQ,eAAe,yBAAA,EAA2B,CAAA;AAElG;AAEO,IAAM,iBAAA,GAAoBhB,sBAAA,CAAM,IAAA,CAAK,0BAA0B","file":"chunk-A7MGQMOV.cjs","sourcesContent":["/**\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 { useArbiHost, useReferencedDocuments } from '@arbidocs/react'\nimport { EntityPill, getDocumentTitle } from '@arbidocs/react/ui'\nimport { FileText } from 'lucide-react'\nimport { hrefFor as defaultHrefFor } from '../../lib/routes'\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. */\nfunction DocumentReferenceView({\n workspaceId,\n docId,\n children,\n label,\n copyHref,\n className = 'inline-flex rounded-full border px-2 py-0.5 text-xs hover:bg-muted',\n}: {\n workspaceId?: string | null\n docId: string\n children?: ReactNode\n label?: string\n copyHref?: string\n className?: string\n}) {\n const { openDocument, hrefFor } = useBlocksEnvironment()\n\n const link =\n hrefFor({ kind: 'document', documentId: docId, workspaceId }) ??\n defaultHrefFor({ kind: 'document', documentId: docId, workspaceId }) ??\n copyHref\n const open = () => (workspaceId ? openDocument(docId, { workspaceId }) : openDocument(docId))\n if (!children || typeof children === 'string')\n return (\n <EntityPill\n icon={<FileText className=\"h-3.5 w-3.5 shrink-0\" />}\n label={label || (typeof children === 'string' ? children : 'File')}\n copyHref={link}\n onClick={open}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <button type=\"button\" className={className} onClick={open}>\n {children ?? docId}\n </button>\n )\n}\n\ntype ReferenceProps = Parameters<typeof DocumentReferenceView>[0]\nexport function WorkspaceDocumentReference(props: ReferenceProps) {\n const arbi = useArbiHost().arbi\n return arbi && props.workspaceId && !props.children && !props.label ? (\n <ResolvedDocumentReference {...props} workspaceId={props.workspaceId} />\n ) : (\n <DocumentReferenceView {...props} />\n )\n}\nfunction ResolvedDocumentReference(props: ReferenceProps & { workspaceId: string }) {\n const { data } = useReferencedDocuments(props.workspaceId)\n const doc = data?.find((d) => d.external_id === props.docId)\n return <DocumentReferenceView {...props} label={getDocumentTitle(doc)} />\n}\n","/**\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","/** Save the rendered graphic, including Mermaid's styles, as a standalone image. */\nexport function downloadMermaidSvg(rendered: string): void {\n const doc = new DOMParser().parseFromString(rendered, 'image/svg+xml')\n const svg = doc.documentElement\n if (svg.localName !== 'svg' || doc.querySelector('parsererror'))\n throw new Error('The diagram did not produce a valid SVG image')\n svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n const box = svg\n .getAttribute('viewBox')\n ?.trim()\n .split(/[\\s,]+/)\n .map(Number)\n if (box?.length === 4 && box.every(Number.isFinite) && box[2] > 0 && box[3] > 0) {\n svg.setAttribute('width', String(Math.ceil(box[2])))\n svg.setAttribute('height', String(Math.ceil(box[3])))\n }\n const blob = new Blob([new XMLSerializer().serializeToString(svg)], { type: 'image/svg+xml' })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = 'diagram.svg'\n document.body.append(link)\n try {\n link.click()\n } finally {\n link.remove()\n // Let the browser consume the download before releasing the image URL.\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n }\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 { Download } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { normalizeMermaidGraph } from '../../chat/mermaid-normalize'\nimport { downloadMermaidSvg } from './download-mermaid'\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 >\n <div className=\"mb-2 flex justify-end\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => downloadMermaidSvg(svg)}>\n <Download className=\"mr-2 size-4\" aria-hidden=\"true\" />\n Download SVG\n </Button>\n </div>\n <div dangerouslySetInnerHTML={{ __html: svg }} />\n </div>\n )\n}\n","import { DATABASES_OPEN_VIEW, type ArbiSessionStore } from '@arbidocs/react'\nimport type { Arbi } from '@arbidocs/sdk/browser'\nimport type { BlocksEnvironment } from '../../provider/environment'\n\n/** Navigation intents shared by copied entity links and inline entity menus. */\nexport async function openEntityReference(\n id: string,\n session: ArbiSessionStore,\n env: BlocksEnvironment,\n arbi?: Arbi\n) {\n const prefix = id.split('-')[0]\n switch (prefix) {\n case 'pag':\n session.setViewValue('pages.open', id)\n session.setPage('pages')\n break\n case 'dbs':\n session.setTransientView(DATABASES_OPEN_VIEW, { databaseId: id })\n session.setPage('databases')\n break\n case 'fct':\n env.openFacts?.({ focusId: id })\n break\n case 'tag':\n session.setPage('tags')\n session.setTransientView('tags.focus', id)\n break\n case 'viw': {\n if (!arbi) return\n const workspace = session.getState().workspaceId\n if (!workspace) return\n const view = await arbi.readInWorkspace(workspace, () => arbi.views.get(id))\n if (session.getState().workspaceId !== workspace) return\n if (view.target === 'documents') {\n session.setTransientView('documents.openView', id)\n session.setPage('documents')\n } else {\n session.setTransientView(DATABASES_OPEN_VIEW, { databaseId: view.target, viewId: id })\n session.setPage('databases')\n }\n break\n }\n case 'wfl':\n env.openWorkflow?.(id)\n break\n case 'prj':\n env.openProject(id)\n break\n case 'usr':\n case 'agt':\n env.openDirectChat?.(id)\n break\n case 'cht':\n env.openChat?.(id)\n break\n case 'cal':\n env.openCalendar()\n break\n }\n}\n","import {\n useArbiHost,\n useArbiSessionState,\n useArbiSessionStore,\n openCall,\n useEntityReferenceTitle,\n} from '@arbidocs/react'\nimport { EntityPill, EntityIcon } from '@arbidocs/react/ui'\nimport {\n CalendarDays,\n Phone,\n Database,\n LayoutDashboard,\n Workflow,\n StickyNote,\n Table2,\n Tags,\n User,\n MessagesSquare,\n Folder,\n} from 'lucide-react'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useDocumentWorkspace } from './DocumentWorkspaceContext'\nimport { hrefFor, parseHref } from '../../lib/routes'\nimport { openEntityReference } from './open-entity-reference'\nimport { parseCallFragment } from '@arbidocs/client'\n\nconst kinds = {\n evt: ['Appointment', CalendarDays],\n call: ['Call', Phone],\n con: ['Thread', MessagesSquare],\n wrk: ['Workspace', Folder],\n prj: ['Project', Folder],\n wfl: ['Workflow', Workflow],\n pag: ['Page', LayoutDashboard],\n dbs: ['Database', Database],\n viw: ['Saved view', Table2],\n fct: ['Fact', StickyNote],\n tag: ['Tag', Tags],\n usr: ['Person', User],\n agt: ['Agent', User],\n cht: ['Chat', MessagesSquare],\n cal: ['Calendar', CalendarDays],\n} as const\n\n/** A permission-aware reference, shared by main conversations and encrypted DMs. */\nfunction ConnectedEntityReference({\n id,\n href,\n title,\n workspaceId: explicitWorkspace,\n}: {\n id: string\n href?: string\n title?: string\n workspaceId?: string | null\n}) {\n const contextWorkspace = useDocumentWorkspace()\n const selected = useArbiSessionState((s) => s.workspaceId)\n const workspaceId = explicitWorkspace ?? contextWorkspace ?? selected\n const prefix = id.split('-')[0] as keyof typeof kinds\n const global = ['evt', 'call', 'cal', 'usr', 'agt', 'prj', 'cht'].includes(prefix)\n const metadata = useEntityReferenceTitle(\n id,\n workspaceId,\n global || prefix === 'con' || workspaceId === selected\n )\n return (\n <EntityReferenceView id={id} href={href} title={metadata || title} workspaceId={workspaceId} />\n )\n}\n\ninterface ReferenceProps {\n id: string\n href?: string\n title?: string\n workspaceId?: string | null\n}\nexport function EntityReference(props: ReferenceProps) {\n const arbi = useArbiHost().arbi\n return arbi ? <ConnectedEntityReference {...props} /> : <EntityReferenceView {...props} />\n}\nfunction EntityReferenceView({ id, href, title, workspaceId: explicitWorkspace }: ReferenceProps) {\n const arbi = useArbiHost().arbi\n const env = useBlocksEnvironment()\n const session = useArbiSessionStore()\n const contextWorkspace = useDocumentWorkspace()\n const selected = useArbiSessionState((s) => s.workspaceId)\n const workspaceId = explicitWorkspace ?? contextWorkspace ?? selected\n const prefix = id.split('-')[0] as keyof typeof kinds\n const [kind, Icon] = kinds[prefix] ?? ['Entity', Folder]\n const global = ['evt', 'call', 'cal', 'usr', 'agt', 'prj', 'cht'].includes(prefix)\n const target =\n prefix === 'con'\n ? hrefFor({ kind: 'conversation', conversationId: id, workspaceId })\n : prefix === 'evt'\n ? hrefFor({ kind: 'calendar', eventId: id })\n : prefix === 'call'\n ? hrefFor({ kind: 'call', callId: id })\n : prefix === 'wrk'\n ? hrefFor({ kind: 'workspace', workspaceId: id })\n : hrefFor({\n kind: 'entity',\n entityId: id,\n workspaceId: global ? undefined : workspaceId,\n })\n const link = href ?? target\n const open = () => {\n if (prefix === 'con') {\n const route = href ? parseHref(href) : null\n env.openConversation(id, {\n workspaceId: workspaceId ?? undefined,\n messageId: route?.kind === 'conversation' ? route.messageId : undefined,\n })\n } else if (prefix === 'evt') env.openCalendar({ event: { id } })\n else if (prefix === 'call') {\n const fragment = href ? parseCallFragment(new URL(href, window.location.href).hash) : null\n if (arbi)\n void openCall(arbi, {\n callExtId: id,\n key: fragment?.key,\n linkVersion: fragment?.linkVersion,\n })\n else if (link) env.navigate(link)\n } else if (prefix === 'wrk') env.openWorkspace(id)\n else if (workspaceId && workspaceId !== selected && link) env.navigate(link)\n else\n void openEntityReference(id, session, env, arbi).catch(() =>\n env.notify('Unable to open content.', 'error')\n )\n }\n return (\n <EntityPill\n icon={\n prefix === 'con' ? (\n <EntityIcon entityType=\"CONVERSATION\" className=\"h-3.5 w-3.5 shrink-0\" />\n ) : (\n <Icon className=\"h-3.5 w-3.5 shrink-0\" />\n )\n }\n label={title || kind}\n copyHref={link}\n onClick={open}\n tooltipContent={`${kind}: ${title || id}`}\n labelMaxWidth=\"max-w-[min(20rem,65vw)]\"\n data-testid={`entity-reference-${id}`}\n />\n )\n}\n","import { EntityReference } from './EntityReference'\nimport { ENTITY_ID } from './entity-references'\nimport { parseHref } from '../../lib/routes'\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, useArbiSessionState, 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) =>\n typeof child === 'string' || typeof child === 'number'\n ? String(child)\n : React.isValidElement<{ children?: React.ReactNode }>(child)\n ? childrenText(child.props.children)\n : ''\n )\n .join('')\n}\n\n/** Text labels may be formatted; a non-text leaf (such as an image) needs the rich-child path. */\nfunction plainLinkText(children: React.ReactNode): string | null {\n const parts = React.Children.toArray(children).map((child): string | null => {\n if (typeof child === 'string' || typeof child === 'number') return String(child)\n if (\n React.isValidElement<{ children?: React.ReactNode }>(child) &&\n child.props.children != null\n ) {\n return plainLinkText(child.props.children)\n }\n return null\n })\n return parts.includes(null) ? null : parts.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 { runtimeConfig } = useBlocksEnvironment()\n const conversationWorkspace = useDocumentWorkspace()\n const selectedWorkspace = useArbiSessionState((s) => s.workspaceId)\n // A delegated reference can target a different workspace than its Home DM. Only trust the\n // route after the same origin/deployment check used by the markdown adapters.\n const route =\n href && workspaceDocIdFromHref(href, runtimeConfig.deploymentDomain) === docId\n ? parseHref(href)\n : null\n const workspaceId =\n (route?.kind === 'document' ? route.workspaceId : null) ??\n conversationWorkspace ??\n selectedWorkspace\n const text = plainLinkText(children)?.trim()\n const isAddress = !text || text === href || text === docId\n\n return (\n <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId} copyHref={href}>\n {text === undefined ? children : isAddress ? undefined : text}\n </WorkspaceDocumentReference>\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, hrefFor } = useBlocksEnvironment()\n const selectedWorkspace = useArbiSessionState((s) => s.workspaceId)\n const copyHref = hrefFor({ kind: 'document', documentId: docId, workspaceId: selectedWorkspace })\n if (!doc)\n return (\n <EntityPill\n icon={<FileText className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label=\"File\"\n copyHref={copyHref}\n size=\"sm\"\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <DocumentEntity\n doc={doc}\n copyHref={copyHref}\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n}\n\n/** An email of the person's mailbox, as a pill: the host's chip, else a plain \"Email\". */\nfunction 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 const route = parseHref(href)\n const reference =\n route?.kind === 'entity'\n ? route.entityId\n : route?.kind === 'conversation'\n ? route.conversationId\n : route?.kind === 'workspace'\n ? route.workspaceId\n : route?.kind === 'call'\n ? route.callId\n : route?.kind === 'calendar'\n ? route.eventId\n : undefined\n if (reference && !reference.startsWith('doc-')) {\n const url = new URL(href, window.location.href)\n const trusted =\n url.origin === window.location.origin ||\n (url.protocol === 'https:' && url.hostname === deploymentDomain)\n if (trusted)\n return (\n <EntityReference\n id={reference}\n href={href}\n title={childrenText(children) === href ? undefined : childrenText(children)}\n workspaceId={url.pathname.match(/\\b(wrk-[a-zA-Z0-9]{8})\\b/)?.[1]}\n />\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 if (ENTITY_ID.test(codeText)) return <EntityReference id={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 entityId = (props as Record<string, unknown>)['data-entity-id'] as string | undefined\n if (entityId) return <EntityReference id={entityId} />\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<\n KitMarkdownRendererProps,\n 'rehypePlugins' | 'allowHtml' | 'renderCitation'\n>\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"]}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkDRYJIRBS_cjs = require('./chunk-DRYJIRBS.cjs');
4
+ var chunkEAH7LFJN_cjs = require('./chunk-EAH7LFJN.cjs');
5
5
  var zustand = require('zustand');
6
6
  var middleware = require('zustand/middleware');
7
7
 
@@ -50,7 +50,7 @@ var useFilesPrefs = zustand.create()(
50
50
  (state) => state.viewModes[prefsKey] === viewMode ? state : { viewModes: { ...state.viewModes, [prefsKey]: viewMode } }
51
51
  ),
52
52
  // New users start at the compact minimum (more rows at once).
53
- rowHeight: chunkDRYJIRBS_cjs.DOCUMENTS_ROW_HEIGHT_INITIAL,
53
+ rowHeight: chunkEAH7LFJN_cjs.DOCUMENTS_ROW_HEIGHT_INITIAL,
54
54
  setRowHeight: (rowHeight) => set({ rowHeight })
55
55
  }),
56
56
  {
@@ -121,5 +121,5 @@ exports.useFilesGridStates = useFilesGridStates;
121
121
  exports.useFilesPrefs = useFilesPrefs;
122
122
  exports.useFilesStore = useFilesStore;
123
123
  exports.usePendingFolders = usePendingFolders;
124
- //# sourceMappingURL=chunk-3P766LID.cjs.map
125
- //# sourceMappingURL=chunk-3P766LID.cjs.map
124
+ //# sourceMappingURL=chunk-AZUPMHZI.cjs.map
125
+ //# sourceMappingURL=chunk-AZUPMHZI.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connection/files/store.ts"],"names":["create","persist","createJSONStorage","DOCUMENTS_ROW_HEIGHT_INITIAL"],"mappings":";;;;;;AAmBO,IAAM,gBAAgBA,cAAA,EAAmB;AAAA,EAC9CC,kBAAA;AAAA,IACE,CAAC,GAAA,MAAS;AAAA,MACR,gBAAgB,EAAC;AAAA,MACjB,kBAAkB,CAAC,WAAA,EAAa,IAAA,KAC9B,GAAA,CAAI,CAAC,KAAA,KAAU;AACb,QAAA,MAAM,OAAA,GAAU,KAAA,CAAM,cAAA,CAAe,WAAW,KAAK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EAAoB,SAASC,4BAAA,CAAkB,MAAM,YAAY,CAAA;AAAE;AAE/E;AA0BO,IAAM,eAAA,GAAkBF,cAAA,EAA0B,CAAE,CAAC,GAAA,MAAS;AAAA,EACnE,IAAA,EAAM,IAAA;AAAA,EACN,QAAA,EAAU,CAAC,MAAA,GAAS,IAAA,KAAS,GAAA,CAAI,EAAE,IAAA,EAAM,EAAE,MAAA,EAAO,EAAG,CAAA;AAAA,EACrD,WAAW,MAAM,GAAA,CAAI,EAAE,IAAA,EAAM,MAAM,CAAA;AAAA,EACnC,YAAA,EAAc,KAAA;AAAA,EACd,iBAAiB,CAAC,YAAA,KAAiB,GAAA,CAAI,EAAE,cAAc,CAAA;AAAA,EACvD,aAAA,EAAe,IAAA;AAAA,EACf,eAAe,CAAC,aAAA,KAAkB,GAAA,CAAI,EAAE,eAAe,CAAA;AAAA,EACvD,UAAA,EAAY,KAAA;AAAA,EACZ,eAAe,CAAC,UAAA,KAAe,GAAA,CAAI,EAAE,YAAY;AACnD,CAAA,CAAE","file":"chunk-3P766LID.cjs","sourcesContent":["/**\n * The Files kits' own state: empty folders the user created (a folder exists only through its\n * documents, so a new one is a placeholder until something is moved into it), per workspace, for\n * the session (kept in `sessionStorage`, so a reload keeps them).\n */\n\nimport type { GridState } from 'ag-grid-community'\nimport { create } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport { DOCUMENTS_ROW_HEIGHT_INITIAL } from '../../files/documentColumns'\nimport type { ExplorerFolder } from '../../files/folders/folderPaths'\n\ninterface FilesState {\n /** Placeholder folder paths per workspace. */\n pendingFolders: Readonly<Record<string, readonly string[]>>\n addPendingFolder: (workspaceId: string, path: string) => void\n removePendingFolder: (workspaceId: string, path: string) => void\n}\n\nexport const useFilesStore = create<FilesState>()(\n persist(\n (set) => ({\n pendingFolders: {},\n addPendingFolder: (workspaceId, path) =>\n set((state) => {\n const current = state.pendingFolders[workspaceId] ?? []\n if (current.includes(path)) return state\n return { pendingFolders: { ...state.pendingFolders, [workspaceId]: [...current, path] } }\n }),\n removePendingFolder: (workspaceId, path) =>\n set((state) => {\n const current = state.pendingFolders[workspaceId] ?? []\n if (!current.includes(path)) return state\n return {\n pendingFolders: {\n ...state.pendingFolders,\n [workspaceId]: current.filter((p) => p !== path),\n },\n }\n }),\n }),\n {\n name: 'arbi_explorer_pending_folders',\n storage: createJSONStorage(() => sessionStorage),\n partialize: (state) => ({ pendingFolders: state.pendingFolders }),\n }\n )\n)\n\nconst NONE: readonly string[] = []\n\n/** A workspace's placeholder folders. */\nexport function usePendingFolders(workspaceId: string | null | undefined): readonly string[] {\n return useFilesStore(\n (state) => (workspaceId ? state.pendingFolders[workspaceId] : undefined) ?? NONE\n )\n}\n\n/** How the files page shows the documents: a table, the explorer, review one by one, or search. */\nexport type FilesViewMode = 'grid' | 'explorer' | 'navigator' | 'search'\n\n/** The files page's own preferences key (`ConnectedFilesPage` `prefsKey`). */\nexport const FILES_PREFS_KEY = 'files'\nconst DEFAULT_VIEW_MODE: FilesViewMode = 'explorer'\n\ninterface FilesPrefsState {\n /** The documents list's tri-state filters (filter id → include / exclude / off). */\n documentFilters: Readonly<Record<string, 'include' | 'exclude' | null>>\n setDocumentFilters: (filters: Record<string, 'include' | 'exclude' | null>) => void\n /**\n * Each files page's view, by its `prefsKey` (a page that is the same kit in another role, e.g.\n * a tabular review in the table view, keeps its own). Absent: that page's default.\n */\n viewModes: Readonly<Record<string, FilesViewMode>>\n /** Set a page's view (default: the files page's). */\n setViewMode: (mode: FilesViewMode, prefsKey?: string) => void\n /** The table's row height (density). */\n rowHeight: number\n setRowHeight: (height: number) => void\n}\n\n/** The Files kits' preferences, kept on this device (`localStorage`) across sessions. */\nexport const useFilesPrefs = create<FilesPrefsState>()(\n persist(\n (set) => ({\n documentFilters: {},\n setDocumentFilters: (documentFilters) => set({ documentFilters }),\n viewModes: {},\n setViewMode: (viewMode, prefsKey = FILES_PREFS_KEY) =>\n set((state) =>\n state.viewModes[prefsKey] === viewMode\n ? state\n : { viewModes: { ...state.viewModes, [prefsKey]: viewMode } }\n ),\n // New users start at the compact minimum (more rows at once).\n rowHeight: DOCUMENTS_ROW_HEIGHT_INITIAL,\n setRowHeight: (rowHeight) => set({ rowHeight }),\n }),\n {\n name: 'arbi_files_prefs',\n storage: createJSONStorage(() => localStorage),\n version: 1,\n // Version 0 kept one view for every files page: it becomes the files page's own.\n migrate: (persisted, version) => {\n const state = (persisted ?? {}) as Record<string, unknown>\n if (version >= 1) return state as Partial<FilesPrefsState>\n const { viewMode, ...rest } = state\n return {\n ...rest,\n viewModes: viewMode ? { [FILES_PREFS_KEY]: viewMode as FilesViewMode } : {},\n } as Partial<FilesPrefsState>\n },\n partialize: (state) => ({\n documentFilters: state.documentFilters,\n viewModes: state.viewModes,\n rowHeight: state.rowHeight,\n }),\n }\n )\n)\n\n/** A files page's view (`prefsKey`, default the files page's), else its `defaultViewMode`. */\nexport function filesViewMode(\n state: Pick<FilesPrefsState, 'viewModes'>,\n prefsKey: string = FILES_PREFS_KEY,\n defaultViewMode: FilesViewMode = DEFAULT_VIEW_MODE\n): FilesViewMode {\n return state.viewModes[prefsKey] ?? defaultViewMode\n}\n\n/** An AI review run: the fields, the documents, and which of them the server finished. */\nexport interface AiReviewRun {\n tags: { id: string; name: string }[]\n docIds: string[]\n /** The documents the server finished (a finished cell with no value will not fill). */\n finishedDocIds?: string[]\n /** It replaces values already there: a cell shows its new value only once finished. */\n replacing?: boolean\n}\n\ninterface AiReviewState {\n /** The AI review dialog is open. */\n open: boolean\n /** The run on screen, kept after closing so \"View results\" can bring the answers back. */\n run: AiReviewRun | null\n setOpen: (open: boolean) => void\n setRun: (run: AiReviewRun | null) => void\n /** The server finished these documents of the run (with or without a value). */\n markFinished: (docIds: string[]) => void\n}\n\n/** The AI review dialog and its run, reachable from outside React (a finished-run notice). */\nexport const useAiReviewStore = create<AiReviewState>()((set) => ({\n open: false,\n run: null,\n setOpen: (open) => set({ open }),\n setRun: (run) => set({ run }),\n markFinished: (docIds) =>\n set((state) => {\n const run = state.run\n if (!run) return state\n const finished = new Set(run.finishedDocIds ?? [])\n const added = docIds.filter((id) => run.docIds.includes(id) && !finished.has(id))\n if (added.length === 0) return state\n return { run: { ...run, finishedDocIds: [...finished, ...added] } }\n }),\n}))\n\ninterface GridStatesState {\n /** AG Grid's saved state (columns, widths, sort) per grid id. */\n gridStates: Readonly<Record<string, GridState>>\n setGridState: (gridId: string, state: GridState) => void\n}\n\n/** The Files grids' saved state, kept on this device, for hosts that keep none of their own. */\nexport const useFilesGridStates = create<GridStatesState>()(\n persist(\n (set) => ({\n gridStates: {},\n setGridState: (gridId, state) =>\n set((current) => ({ gridStates: { ...current.gridStates, [gridId]: state } })),\n }),\n { name: 'arbi_files_grids', storage: createJSONStorage(() => localStorage) }\n )\n)\n\n/** A document the Delete confirmation asks about. */\nexport interface DeleteRequestDocument {\n external_id: string\n file_name?: string | null\n doc_metadata?: { title?: string | null } | null\n}\n\ninterface FilesDialogsState {\n /** Move the selection (or `folder`) to a folder. */\n move: { folder: ExplorerFolder | null } | null\n openMove: (folder?: ExplorerFolder | null) => void\n closeMove: () => void\n /** Edit the selection's labels and fields. */\n bulkTagsOpen: boolean\n setBulkTagsOpen: (open: boolean) => void\n /** Confirm deleting one document. */\n deleteRequest: DeleteRequestDocument | null\n requestDelete: (doc: DeleteRequestDocument | null) => void\n /** Export, copy or move the selection (the page's own dialog, when the host has none). */\n exportOpen: boolean\n setExportOpen: (open: boolean) => void\n}\n\n/** The files page's dialogs, also opened from outside it (commands, the viewer's related files). */\nexport const useFilesDialogs = create<FilesDialogsState>()((set) => ({\n move: null,\n openMove: (folder = null) => set({ move: { folder } }),\n closeMove: () => set({ move: null }),\n bulkTagsOpen: false,\n setBulkTagsOpen: (bulkTagsOpen) => set({ bulkTagsOpen }),\n deleteRequest: null,\n requestDelete: (deleteRequest) => set({ deleteRequest }),\n exportOpen: false,\n setExportOpen: (exportOpen) => set({ exportOpen }),\n}))\n"]}
1
+ {"version":3,"s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A,EACpE,CAAC;AACL,CAAA,CAAE;AASK,IAAM,qBAAqBA,cAAA,EAAwB;AAAA,EACxDC,kBAAA;AAAA,IACE,CAAC,GAAA,MAAS;AAAA,MACR,YAAY,EAAC;AAAA,MACb,cAAc,CAAC,MAAA,EAAQ,UACrB,GAAA,CAAI,CAAC,aAAa,EAAE,UAAA,EAAY,EAAE,GAAG,QAAQ,UAAA,EAAY,CAAC,MAAM,GAAG,KAAA,IAAQ,CAAE;AAAA,KACjF,CAAA;AAAA,IACA,EAAE,IAAA,EAAM,kBAAA,EAAoB,SAASC,4BAAA,CAAkB,MAAM,YAAY,CAAA;AAAE;AAE/E;AA0BO,IAAM,eAAA,GAAkBF,cAAA,EAA0B,CAAE,CAAC,GAAA,MAAS;AAAA,EACnE,IAAA,EAAM,IAAA;AAAA,EACN,QAAA,EAAU,CAAC,MAAA,GAAS,IAAA,KAAS,GAAA,CAAI,EAAE,IAAA,EAAM,EAAE,MAAA,EAAO,EAAG,CAAA;AAAA,EACrD,WAAW,MAAM,GAAA,CAAI,EAAE,IAAA,EAAM,MAAM,CAAA;AAAA,EACnC,YAAA,EAAc,KAAA;AAAA,EACd,iBAAiB,CAAC,YAAA,KAAiB,GAAA,CAAI,EAAE,cAAc,CAAA;AAAA,EACvD,aAAA,EAAe,IAAA;AAAA,EACf,eAAe,CAAC,aAAA,KAAkB,GAAA,CAAI,EAAE,eAAe,CAAA;AAAA,EACvD,UAAA,EAAY,KAAA;AAAA,EACZ,eAAe,CAAC,UAAA,KAAe,GAAA,CAAI,EAAE,YAAY;AACnD,CAAA,CAAE","file":"chunk-AZUPMHZI.cjs","sourcesContent":["/**\n * The Files kits' own state: empty folders the user created (a folder exists only through its\n * documents, so a new one is a placeholder until something is moved into it), per workspace, for\n * the session (kept in `sessionStorage`, so a reload keeps them).\n */\n\nimport type { GridState } from 'ag-grid-community'\nimport { create } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport { DOCUMENTS_ROW_HEIGHT_INITIAL } from '../../files/documentColumns'\nimport type { ExplorerFolder } from '../../files/folders/folderPaths'\n\ninterface FilesState {\n /** Placeholder folder paths per workspace. */\n pendingFolders: Readonly<Record<string, readonly string[]>>\n addPendingFolder: (workspaceId: string, path: string) => void\n removePendingFolder: (workspaceId: string, path: string) => void\n}\n\nexport const useFilesStore = create<FilesState>()(\n persist(\n (set) => ({\n pendingFolders: {},\n addPendingFolder: (workspaceId, path) =>\n set((state) => {\n const current = state.pendingFolders[workspaceId] ?? []\n if (current.includes(path)) return state\n return { pendingFolders: { ...state.pendingFolders, [workspaceId]: [...current, path] } }\n }),\n removePendingFolder: (workspaceId, path) =>\n set((state) => {\n const current = state.pendingFolders[workspaceId] ?? []\n if (!current.includes(path)) return state\n return {\n pendingFolders: {\n ...state.pendingFolders,\n [workspaceId]: current.filter((p) => p !== path),\n },\n }\n }),\n }),\n {\n name: 'arbi_explorer_pending_folders',\n storage: createJSONStorage(() => sessionStorage),\n partialize: (state) => ({ pendingFolders: state.pendingFolders }),\n }\n )\n)\n\nconst NONE: readonly string[] = []\n\n/** A workspace's placeholder folders. */\nexport function usePendingFolders(workspaceId: string | null | undefined): readonly string[] {\n return useFilesStore(\n (state) => (workspaceId ? state.pendingFolders[workspaceId] : undefined) ?? NONE\n )\n}\n\n/** How the files page shows the documents: a table, the explorer, review one by one, or search. */\nexport type FilesViewMode = 'grid' | 'explorer' | 'navigator' | 'search'\n\n/** The files page's own preferences key (`ConnectedFilesPage` `prefsKey`). */\nexport const FILES_PREFS_KEY = 'files'\nconst DEFAULT_VIEW_MODE: FilesViewMode = 'explorer'\n\ninterface FilesPrefsState {\n /** The documents list's tri-state filters (filter id → include / exclude / off). */\n documentFilters: Readonly<Record<string, 'include' | 'exclude' | null>>\n setDocumentFilters: (filters: Record<string, 'include' | 'exclude' | null>) => void\n /**\n * Each files page's view, by its `prefsKey` (a page that is the same kit in another role, e.g.\n * a tabular review in the table view, keeps its own). Absent: that page's default.\n */\n viewModes: Readonly<Record<string, FilesViewMode>>\n /** Set a page's view (default: the files page's). */\n setViewMode: (mode: FilesViewMode, prefsKey?: string) => void\n /** The table's row height (density). */\n rowHeight: number\n setRowHeight: (height: number) => void\n}\n\n/** The Files kits' preferences, kept on this device (`localStorage`) across sessions. */\nexport const useFilesPrefs = create<FilesPrefsState>()(\n persist(\n (set) => ({\n documentFilters: {},\n setDocumentFilters: (documentFilters) => set({ documentFilters }),\n viewModes: {},\n setViewMode: (viewMode, prefsKey = FILES_PREFS_KEY) =>\n set((state) =>\n state.viewModes[prefsKey] === viewMode\n ? state\n : { viewModes: { ...state.viewModes, [prefsKey]: viewMode } }\n ),\n // New users start at the compact minimum (more rows at once).\n rowHeight: DOCUMENTS_ROW_HEIGHT_INITIAL,\n setRowHeight: (rowHeight) => set({ rowHeight }),\n }),\n {\n name: 'arbi_files_prefs',\n storage: createJSONStorage(() => localStorage),\n version: 1,\n // Version 0 kept one view for every files page: it becomes the files page's own.\n migrate: (persisted, version) => {\n const state = (persisted ?? {}) as Record<string, unknown>\n if (version >= 1) return state as Partial<FilesPrefsState>\n const { viewMode, ...rest } = state\n return {\n ...rest,\n viewModes: viewMode ? { [FILES_PREFS_KEY]: viewMode as FilesViewMode } : {},\n } as Partial<FilesPrefsState>\n },\n partialize: (state) => ({\n documentFilters: state.documentFilters,\n viewModes: state.viewModes,\n rowHeight: state.rowHeight,\n }),\n }\n )\n)\n\n/** A files page's view (`prefsKey`, default the files page's), else its `defaultViewMode`. */\nexport function filesViewMode(\n state: Pick<FilesPrefsState, 'viewModes'>,\n prefsKey: string = FILES_PREFS_KEY,\n defaultViewMode: FilesViewMode = DEFAULT_VIEW_MODE\n): FilesViewMode {\n return state.viewModes[prefsKey] ?? defaultViewMode\n}\n\n/** An AI review run: the fields, the documents, and which of them the server finished. */\nexport interface AiReviewRun {\n tags: { id: string; name: string }[]\n docIds: string[]\n /** The documents the server finished (a finished cell with no value will not fill). */\n finishedDocIds?: string[]\n /** It replaces values already there: a cell shows its new value only once finished. */\n replacing?: boolean\n}\n\ninterface AiReviewState {\n /** The AI review dialog is open. */\n open: boolean\n /** The run on screen, kept after closing so \"View results\" can bring the answers back. */\n run: AiReviewRun | null\n setOpen: (open: boolean) => void\n setRun: (run: AiReviewRun | null) => void\n /** The server finished these documents of the run (with or without a value). */\n markFinished: (docIds: string[]) => void\n}\n\n/** The AI review dialog and its run, reachable from outside React (a finished-run notice). */\nexport const useAiReviewStore = create<AiReviewState>()((set) => ({\n open: false,\n run: null,\n setOpen: (open) => set({ open }),\n setRun: (run) => set({ run }),\n markFinished: (docIds) =>\n set((state) => {\n const run = state.run\n if (!run) return state\n const finished = new Set(run.finishedDocIds ?? [])\n const added = docIds.filter((id) => run.docIds.includes(id) && !finished.has(id))\n if (added.length === 0) return state\n return { run: { ...run, finishedDocIds: [...finished, ...added] } }\n }),\n}))\n\ninterface GridStatesState {\n /** AG Grid's saved state (columns, widths, sort) per grid id. */\n gridStates: Readonly<Record<string, GridState>>\n setGridState: (gridId: string, state: GridState) => void\n}\n\n/** The Files grids' saved state, kept on this device, for hosts that keep none of their own. */\nexport const useFilesGridStates = create<GridStatesState>()(\n persist(\n (set) => ({\n gridStates: {},\n setGridState: (gridId, state) =>\n set((current) => ({ gridStates: { ...current.gridStates, [gridId]: state } })),\n }),\n { name: 'arbi_files_grids', storage: createJSONStorage(() => localStorage) }\n )\n)\n\n/** A document the Delete confirmation asks about. */\nexport interface DeleteRequestDocument {\n external_id: string\n file_name?: string | null\n doc_metadata?: { title?: string | null } | null\n}\n\ninterface FilesDialogsState {\n /** Move the selection (or `folder`) to a folder. */\n move: { folder: ExplorerFolder | null } | null\n openMove: (folder?: ExplorerFolder | null) => void\n closeMove: () => void\n /** Edit the selection's labels and fields. */\n bulkTagsOpen: boolean\n setBulkTagsOpen: (open: boolean) => void\n /** Confirm deleting one document. */\n deleteRequest: DeleteRequestDocument | null\n requestDelete: (doc: DeleteRequestDocument | null) => void\n /** Export, copy or move the selection (the page's own dialog, when the host has none). */\n exportOpen: boolean\n setExportOpen: (open: boolean) => void\n}\n\n/** The files page's dialogs, also opened from outside it (commands, the viewer's related files). */\nexport const useFilesDialogs = create<FilesDialogsState>()((set) => ({\n move: null,\n openMove: (folder = null) => set({ move: { folder } }),\n closeMove: () => set({ move: null }),\n bulkTagsOpen: false,\n setBulkTagsOpen: (bulkTagsOpen) => set({ bulkTagsOpen }),\n deleteRequest: null,\n requestDelete: (deleteRequest) => set({ deleteRequest }),\n exportOpen: false,\n setExportOpen: (exportOpen) => set({ exportOpen }),\n}))\n"]}