@arbidocs/blocks 0.4.147 → 0.4.151

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 (339) hide show
  1. package/dist/ConnectedNativeDocxComparison-OFPIXNJB.js +35 -0
  2. package/dist/ConnectedNativeDocxComparison-OFPIXNJB.js.map +1 -0
  3. package/dist/ConnectedNativeDocxComparison-Y5BNLNH6.cjs +44 -0
  4. package/dist/ConnectedNativeDocxComparison-Y5BNLNH6.cjs.map +1 -0
  5. package/dist/ConnectedNativeDocxEditor-HTEW5JAH.cjs +46 -0
  6. package/dist/ConnectedNativeDocxEditor-HTEW5JAH.cjs.map +1 -0
  7. package/dist/ConnectedNativeDocxEditor-LRYU5HPA.js +33 -0
  8. package/dist/ConnectedNativeDocxEditor-LRYU5HPA.js.map +1 -0
  9. package/dist/ConnectedStreamedWordArtifact-QAUVUCSX.js +35 -0
  10. package/dist/ConnectedStreamedWordArtifact-QAUVUCSX.js.map +1 -0
  11. package/dist/ConnectedStreamedWordArtifact-QW74LKHN.cjs +44 -0
  12. package/dist/ConnectedStreamedWordArtifact-QW74LKHN.cjs.map +1 -0
  13. package/dist/FactTextEditor-YESAU2IJ.js +25 -0
  14. package/dist/FactTextEditor-YESAU2IJ.js.map +1 -0
  15. package/dist/FactTextEditor-YUPBCTXK.cjs +27 -0
  16. package/dist/FactTextEditor-YUPBCTXK.cjs.map +1 -0
  17. package/dist/{NativeDocxEditor-BE2OEOTJ.cjs → NativeDocxEditor-5VBNM5I7.cjs} +8 -8
  18. package/dist/{NativeDocxEditor-BE2OEOTJ.cjs.map → NativeDocxEditor-5VBNM5I7.cjs.map} +1 -1
  19. package/dist/{NativeDocxEditor-KOPFMRYW.js → NativeDocxEditor-XT5ZLFGU.js} +4 -4
  20. package/dist/{NativeDocxEditor-KOPFMRYW.js.map → NativeDocxEditor-XT5ZLFGU.js.map} +1 -1
  21. package/dist/agents/index.cjs +263 -264
  22. package/dist/agents/index.js +6 -7
  23. package/dist/calendar/index.cjs +117 -125
  24. package/dist/calendar/index.d.ts +0 -1
  25. package/dist/calendar/index.js +1 -1
  26. package/dist/chat/index.cjs +78 -78
  27. package/dist/chat/index.js +3 -3
  28. package/dist/{chunk-2FL7QJKJ.js → chunk-265GOG4W.js} +3 -3
  29. package/dist/{chunk-2FL7QJKJ.js.map → chunk-265GOG4W.js.map} +1 -1
  30. package/dist/{chunk-LTU35TQN.cjs → chunk-2FLWPM3B.cjs} +636 -31
  31. package/dist/chunk-2FLWPM3B.cjs.map +1 -0
  32. package/dist/{chunk-SUUPR735.js → chunk-3PCBYOIZ.js} +4 -4
  33. package/dist/{chunk-SUUPR735.js.map → chunk-3PCBYOIZ.js.map} +1 -1
  34. package/dist/{chunk-WIZ7Z7FN.js → chunk-4236BRZK.js} +46 -221
  35. package/dist/chunk-4236BRZK.js.map +1 -0
  36. package/dist/{chunk-IL3WB3YX.cjs → chunk-4JNKXOFZ.cjs} +3 -3
  37. package/dist/{chunk-IL3WB3YX.cjs.map → chunk-4JNKXOFZ.cjs.map} +1 -1
  38. package/dist/{chunk-ODRHHWHY.cjs → chunk-4KMLM3GY.cjs} +4 -4
  39. package/dist/chunk-4KMLM3GY.cjs.map +1 -0
  40. package/dist/chunk-6I6CVX5G.cjs +22 -0
  41. package/dist/chunk-6I6CVX5G.cjs.map +1 -0
  42. package/dist/{chunk-MHFF5N65.cjs → chunk-757OYF6G.cjs} +4 -38
  43. package/dist/chunk-757OYF6G.cjs.map +1 -0
  44. package/dist/chunk-B3FMUFAW.cjs +1956 -0
  45. package/dist/chunk-B3FMUFAW.cjs.map +1 -0
  46. package/dist/{chunk-B3AHCIV5.js → chunk-BJ24VPOA.js} +4 -55
  47. package/dist/chunk-BJ24VPOA.js.map +1 -0
  48. package/dist/chunk-C7PTF6BQ.cjs +172 -0
  49. package/dist/chunk-C7PTF6BQ.cjs.map +1 -0
  50. package/dist/{chunk-LZRMXJIE.js → chunk-COA3S3CZ.js} +3 -3
  51. package/dist/{chunk-LZRMXJIE.js.map → chunk-COA3S3CZ.js.map} +1 -1
  52. package/dist/{chunk-VUR63NMQ.js → chunk-CROTH2BS.js} +6 -6
  53. package/dist/{chunk-VUR63NMQ.js.map → chunk-CROTH2BS.js.map} +1 -1
  54. package/dist/{chunk-AO7SK6WP.cjs → chunk-CU2O32Z4.cjs} +31 -31
  55. package/dist/{chunk-AO7SK6WP.cjs.map → chunk-CU2O32Z4.cjs.map} +1 -1
  56. package/dist/chunk-D3WFIFRY.cjs +659 -0
  57. package/dist/chunk-D3WFIFRY.cjs.map +1 -0
  58. package/dist/{chunk-DAHCRVPM.js → chunk-DB2OXRQC.js} +84 -82
  59. package/dist/chunk-DB2OXRQC.js.map +1 -0
  60. package/dist/{chunk-QXMR5YHC.js → chunk-DIB4JYUY.js} +19 -3
  61. package/dist/chunk-DIB4JYUY.js.map +1 -0
  62. package/dist/chunk-DVB5ZKOF.js +22 -0
  63. package/dist/chunk-DVB5ZKOF.js.map +1 -0
  64. package/dist/chunk-EYJMMGXF.js +19 -0
  65. package/dist/chunk-EYJMMGXF.js.map +1 -0
  66. package/dist/chunk-FAXXN7KI.cjs +213 -0
  67. package/dist/chunk-FAXXN7KI.cjs.map +1 -0
  68. package/dist/{chunk-2MJWWPHY.js → chunk-G4IYES7G.js} +140 -15
  69. package/dist/chunk-G4IYES7G.js.map +1 -0
  70. package/dist/{chunk-T5I4NRFP.cjs → chunk-GFOEWPAP.cjs} +8 -8
  71. package/dist/{chunk-T5I4NRFP.cjs.map → chunk-GFOEWPAP.cjs.map} +1 -1
  72. package/dist/{chunk-QI6AIHWP.cjs → chunk-GOWXP5KT.cjs} +145 -14
  73. package/dist/chunk-GOWXP5KT.cjs.map +1 -0
  74. package/dist/chunk-HALD6ZB5.cjs +18 -0
  75. package/dist/chunk-HALD6ZB5.cjs.map +1 -0
  76. package/dist/chunk-HUJF2XM2.js +6584 -0
  77. package/dist/chunk-HUJF2XM2.js.map +1 -0
  78. package/dist/{chunk-NRFAWUVD.js → chunk-JAANWQGB.js} +157 -157
  79. package/dist/chunk-JAANWQGB.js.map +1 -0
  80. package/dist/{chunk-7RJTEWYM.js → chunk-JGOST4IL.js} +350 -64
  81. package/dist/chunk-JGOST4IL.js.map +1 -0
  82. package/dist/chunk-KHXEIEXN.js +41 -0
  83. package/dist/chunk-KHXEIEXN.js.map +1 -0
  84. package/dist/chunk-KQYPP72K.js +644 -0
  85. package/dist/chunk-KQYPP72K.js.map +1 -0
  86. package/dist/chunk-KUT2Y7JF.cjs +43 -0
  87. package/dist/chunk-KUT2Y7JF.cjs.map +1 -0
  88. package/dist/{chunk-6YTHQ73P.cjs → chunk-LLYZGH3L.cjs} +3 -56
  89. package/dist/chunk-LLYZGH3L.cjs.map +1 -0
  90. package/dist/{chunk-YSHIC4NJ.cjs → chunk-LXTOOUEN.cjs} +159 -154
  91. package/dist/chunk-LXTOOUEN.cjs.map +1 -0
  92. package/dist/{chunk-EVUEIBNU.js → chunk-M4S75AEJ.js} +44 -5
  93. package/dist/chunk-M4S75AEJ.js.map +1 -0
  94. package/dist/{chunk-V5OAXIBN.cjs → chunk-NPR5BGFF.cjs} +11 -11
  95. package/dist/{chunk-V5OAXIBN.cjs.map → chunk-NPR5BGFF.cjs.map} +1 -1
  96. package/dist/{chunk-PLJ7PHWU.cjs → chunk-NS7NVX4E.cjs} +3 -3
  97. package/dist/{chunk-PLJ7PHWU.cjs.map → chunk-NS7NVX4E.cjs.map} +1 -1
  98. package/dist/{chunk-AINU3EJ6.cjs → chunk-Q4BY2CQQ.cjs} +92 -90
  99. package/dist/chunk-Q4BY2CQQ.cjs.map +1 -0
  100. package/dist/chunk-QN47Q4N7.js +16 -0
  101. package/dist/chunk-QN47Q4N7.js.map +1 -0
  102. package/dist/{chunk-I2QSDQQV.cjs → chunk-QT3A4PFC.cjs} +21 -2
  103. package/dist/chunk-QT3A4PFC.cjs.map +1 -0
  104. package/dist/{chunk-ZM26YEOT.js → chunk-RY2SODRN.js} +3 -3
  105. package/dist/{chunk-ZM26YEOT.js.map → chunk-RY2SODRN.js.map} +1 -1
  106. package/dist/chunk-SDOEHEJP.js +208 -0
  107. package/dist/chunk-SDOEHEJP.js.map +1 -0
  108. package/dist/{chunk-DETZZBG2.cjs → chunk-SIB6C7P7.cjs} +43 -2
  109. package/dist/chunk-SIB6C7P7.cjs.map +1 -0
  110. package/dist/{chunk-MFY2ZNP6.cjs → chunk-SMN32BQ3.cjs} +4 -4
  111. package/dist/chunk-SMN32BQ3.cjs.map +1 -0
  112. package/dist/chunk-T74Q3MCZ.cjs +6751 -0
  113. package/dist/chunk-T74Q3MCZ.cjs.map +1 -0
  114. package/dist/{chunk-AOSUHWIL.js → chunk-TZOQKV64.js} +4 -37
  115. package/dist/chunk-TZOQKV64.js.map +1 -0
  116. package/dist/{chunk-U37AYUPI.cjs → chunk-U6JQ4KMX.cjs} +46 -233
  117. package/dist/chunk-U6JQ4KMX.cjs.map +1 -0
  118. package/dist/chunk-WFA2GVZJ.js +16 -0
  119. package/dist/chunk-WFA2GVZJ.js.map +1 -0
  120. package/dist/chunk-WU34CHU5.js +1907 -0
  121. package/dist/chunk-WU34CHU5.js.map +1 -0
  122. package/dist/{chunk-O4YPVYPO.cjs → chunk-YAEXSCUW.cjs} +364 -60
  123. package/dist/chunk-YAEXSCUW.cjs.map +1 -0
  124. package/dist/{chunk-H74HEPKT.js → chunk-YXNNNP57.js} +598 -13
  125. package/dist/chunk-YXNNNP57.js.map +1 -0
  126. package/dist/chunk-Z27QMJ6S.cjs +25 -0
  127. package/dist/chunk-Z27QMJ6S.cjs.map +1 -0
  128. package/dist/{chunk-CSI2B2H5.js → chunk-Z4NQ3TED.js} +4 -4
  129. package/dist/chunk-Z4NQ3TED.js.map +1 -0
  130. package/dist/{chunk-DGV7HQA7.js → chunk-ZLEYLCE4.js} +4 -4
  131. package/dist/chunk-ZLEYLCE4.js.map +1 -0
  132. package/dist/chunk-ZNLTEZEF.js +170 -0
  133. package/dist/chunk-ZNLTEZEF.js.map +1 -0
  134. package/dist/chunk-ZP6Q3KXU.cjs +18 -0
  135. package/dist/chunk-ZP6Q3KXU.cjs.map +1 -0
  136. package/dist/citations/index.cjs +14 -14
  137. package/dist/citations/index.js +2 -2
  138. package/dist/collaboration/index.cjs +35 -35
  139. package/dist/collaboration/index.js +1 -1
  140. package/dist/connect/docx.cjs +21 -26
  141. package/dist/connect/docx.cjs.map +1 -1
  142. package/dist/connect/docx.js +10 -26
  143. package/dist/connect/docx.js.map +1 -1
  144. package/dist/connect/index.cjs +8662 -2824
  145. package/dist/connect/index.cjs.map +1 -1
  146. package/dist/connect/index.d.ts +10 -2
  147. package/dist/connect/index.js +8467 -2670
  148. package/dist/connect/index.js.map +1 -1
  149. package/dist/connect/viewer.cjs +2357 -0
  150. package/dist/connect/viewer.cjs.map +1 -0
  151. package/dist/connect/viewer.d.ts +8 -0
  152. package/dist/connect/viewer.js +2350 -0
  153. package/dist/connect/viewer.js.map +1 -0
  154. package/dist/connection/ConnectedWorkflowsTable.d.ts +2 -12
  155. package/dist/connection/ai.d.ts +2 -9
  156. package/dist/connection/billing/AddAddonDialog.d.ts +24 -0
  157. package/dist/connection/billing/BillingCard.d.ts +18 -0
  158. package/dist/connection/billing/BillingProjectEntity.d.ts +9 -0
  159. package/dist/connection/billing/ChangePlanDialog.d.ts +20 -0
  160. package/dist/connection/billing/ChangeProPlan.d.ts +20 -0
  161. package/dist/connection/billing/CheckoutTotal.d.ts +12 -0
  162. package/dist/connection/billing/DailyCapEditor.d.ts +4 -0
  163. package/dist/connection/billing/InvoicesModal.d.ts +6 -0
  164. package/dist/connection/billing/NewProjectFlow.d.ts +14 -0
  165. package/dist/connection/billing/PlanChangeLines.d.ts +13 -0
  166. package/dist/connection/billing/PlanSelector.d.ts +50 -0
  167. package/dist/connection/billing/ProjectBilling.d.ts +24 -0
  168. package/dist/connection/billing/ProjectDetail.d.ts +16 -0
  169. package/dist/connection/billing/ProjectUsageCard.d.ts +21 -0
  170. package/dist/connection/billing/ProjectUsageContent.d.ts +18 -0
  171. package/dist/connection/billing/ProjectsTable.d.ts +13 -0
  172. package/dist/connection/billing/ReduceAddonDialog.d.ts +18 -0
  173. package/dist/connection/billing/ReferralReward.d.ts +32 -0
  174. package/dist/connection/billing/SharedProjects.d.ts +13 -0
  175. package/dist/connection/billing/StripeCheckoutModal.d.ts +32 -0
  176. package/dist/connection/billing/SubscriptionPlans.d.ts +15 -0
  177. package/dist/connection/billing/SubscriptionStatus.d.ts +10 -0
  178. package/dist/connection/billing/addon-pricing.d.ts +97 -0
  179. package/dist/connection/billing/api-error.d.ts +6 -0
  180. package/dist/connection/billing/billing-country.d.ts +14 -0
  181. package/dist/connection/billing/billing-focus.d.ts +11 -0
  182. package/dist/connection/billing/index.d.ts +22 -0
  183. package/dist/connection/billing/plan-badge.d.ts +15 -0
  184. package/dist/connection/billing/plan-change-outcome.d.ts +15 -0
  185. package/dist/connection/billing/plan-constants.d.ts +29 -0
  186. package/dist/connection/billing/plan-pricing.d.ts +67 -0
  187. package/dist/connection/billing/quota-items.d.ts +33 -0
  188. package/dist/connection/billing/referral-reward.d.ts +28 -0
  189. package/dist/connection/billing/refusal-copy.d.ts +5 -0
  190. package/dist/connection/billing/reward-balance.d.ts +19 -0
  191. package/dist/connection/billing/support.d.ts +35 -0
  192. package/dist/connection/billing/tax-quote.d.ts +36 -0
  193. package/dist/connection/billing/useAddonPurchase.d.ts +32 -0
  194. package/dist/connection/billing/useAutoRefreshPendingProjects.d.ts +11 -0
  195. package/dist/connection/billing/useCheckoutQuote.d.ts +30 -0
  196. package/dist/connection/billing/useOpenBillingPortal.d.ts +12 -0
  197. package/dist/connection/calendar/CalendarSettingsDialog.d.ts +1 -1
  198. package/dist/connection/facts/ConnectedFactsPage.d.ts +50 -0
  199. package/dist/connection/facts/FactMarkdownEditor.d.ts +57 -0
  200. package/dist/connection/facts/FactSourcesPopover.d.ts +38 -0
  201. package/dist/connection/facts/FactTextEditor.d.ts +2 -0
  202. package/dist/connection/facts/factNouns.d.ts +4 -0
  203. package/dist/connection/facts/factPageColumns.d.ts +37 -0
  204. package/dist/connection/facts/types.d.ts +127 -0
  205. package/dist/connection/facts/useFactActions.d.ts +10 -0
  206. package/dist/connection/facts/useFactComposer.d.ts +54 -0
  207. package/dist/connection/facts/useFactFilters.d.ts +101 -0
  208. package/dist/connection/facts/useFactSelection.d.ts +82 -0
  209. package/dist/connection/facts/useFactsGrid.d.ts +87 -0
  210. package/dist/connection/facts/useFactsPageView.d.ts +4 -0
  211. package/dist/connection/mail/ConnectedMailComposer.d.ts +3 -1
  212. package/dist/connection/mail/ConnectedMailbox.d.ts +4 -2
  213. package/dist/connection/mail/MailComposerForm.d.ts +4 -2
  214. package/dist/connection/mail/MailRecipientInput.d.ts +14 -0
  215. package/dist/connection/mail/index.d.ts +1 -1
  216. package/dist/connection/mail/types.d.ts +10 -0
  217. package/dist/connection/search/ConnectedSearchPage.d.ts +64 -0
  218. package/dist/connection/search/SearchResultRows.d.ts +38 -0
  219. package/dist/connection/search/index.d.ts +2 -0
  220. package/dist/connection/tags/ConnectedTagTable.d.ts +108 -0
  221. package/dist/connection/tags/ConnectedTagsPage.d.ts +55 -0
  222. package/dist/connection/tags/DocTagPassages.d.ts +25 -0
  223. package/dist/connection/tags/GlossaryExport.d.ts +7 -0
  224. package/dist/connection/tags/TagCombineFilter.d.ts +14 -0
  225. package/dist/connection/tags/TagPlacement.d.ts +16 -0
  226. package/dist/connection/tags/TagsPageSections.d.ts +36 -0
  227. package/dist/connection/tags/tagCombine.d.ts +55 -0
  228. package/dist/connection/useConnectedWorkNotifications.d.ts +7 -24
  229. package/dist/connection/viewer/ConnectedDocumentToolsProvider.d.ts +11 -0
  230. package/dist/connection/viewer/ConnectedDocumentViewer.d.ts +21 -0
  231. package/dist/connection/viewer/FinaliseTranslationButton.d.ts +15 -0
  232. package/dist/connection/viewer/ViewerPdfPane.d.ts +46 -0
  233. package/dist/connection/viewer/parsed/ParsedPassage.d.ts +48 -0
  234. package/dist/connection/viewer/parsed/ParsedTextView.d.ts +17 -0
  235. package/dist/connection/viewer/parsed/PassageTagPanel.d.ts +18 -0
  236. package/dist/connection/viewer/parsed/citation-line.d.ts +17 -0
  237. package/dist/connection/viewer/parsed/document-tags.d.ts +8 -0
  238. package/dist/connection/viewer/parsed/useChunkTagging.d.ts +46 -0
  239. package/dist/connection/viewer/parsed/useCitationSelection.d.ts +27 -0
  240. package/dist/connection/viewer/parsed/useDocumentLabels.d.ts +38 -0
  241. package/dist/connection/viewer/parsed/useLazyPages.d.ts +18 -0
  242. package/dist/connection/viewer/parsed/usePageScrollSync.d.ts +17 -0
  243. package/dist/connection/viewer/parsed/usePassageCopy.d.ts +25 -0
  244. package/dist/connection/viewer/support.d.ts +97 -0
  245. package/dist/connection/viewer/useImageCrop.d.ts +13 -0
  246. package/dist/connection/viewer/useViewedDocument.d.ts +70 -0
  247. package/dist/connection/viewer/useViewerBlobs.d.ts +15 -0
  248. package/dist/connection/viewer/useViewerTabs.d.ts +18 -0
  249. package/dist/connection/viewer/useViewerVersions.d.ts +11 -0
  250. package/dist/connection/workspace-settings/useConnectedWorkspaceSettings.d.ts +6 -0
  251. package/dist/document-tools/index.cjs +59 -652
  252. package/dist/document-tools/index.cjs.map +1 -1
  253. package/dist/document-tools/index.js +2 -641
  254. package/dist/document-tools/index.js.map +1 -1
  255. package/dist/docx/index.cjs +48 -47
  256. package/dist/docx/index.js +4 -3
  257. package/dist/facts/FactsBulkBar.d.ts +6 -3
  258. package/dist/facts/cited-version-ref.d.ts +1 -0
  259. package/dist/facts/index.cjs +204 -1940
  260. package/dist/facts/index.cjs.map +1 -1
  261. package/dist/facts/index.d.ts +1 -0
  262. package/dist/facts/index.js +13 -1895
  263. package/dist/facts/index.js.map +1 -1
  264. package/dist/files/TagPassagePanel.d.ts +2 -1
  265. package/dist/files/ViewerChrome.d.ts +5 -4
  266. package/dist/files/ViewerControlBar.d.ts +12 -0
  267. package/dist/files/doc-labels.d.ts +35 -0
  268. package/dist/files/grid/FilterButton.d.ts +12 -0
  269. package/dist/files/grid/RowDensityControl.d.ts +18 -0
  270. package/dist/files/grid/row-density.d.ts +27 -0
  271. package/dist/files/index.cjs +778 -7099
  272. package/dist/files/index.cjs.map +1 -1
  273. package/dist/files/index.d.ts +5 -0
  274. package/dist/files/index.js +13 -6918
  275. package/dist/files/index.js.map +1 -1
  276. package/dist/index.cjs +993 -1209
  277. package/dist/index.cjs.map +1 -1
  278. package/dist/index.js +22 -355
  279. package/dist/index.js.map +1 -1
  280. package/dist/retrieval/SearchSnippet.d.ts +6 -0
  281. package/dist/retrieval/index.cjs +74 -41
  282. package/dist/retrieval/index.d.ts +2 -0
  283. package/dist/retrieval/index.js +2 -1
  284. package/dist/retrieval/search-results.d.ts +46 -0
  285. package/dist/settings/Billing.d.ts +0 -66
  286. package/dist/settings/SubscriptionParts.d.ts +1 -50
  287. package/dist/settings/index.cjs +166 -214
  288. package/dist/settings/index.d.ts +3 -2
  289. package/dist/settings/index.js +1 -1
  290. package/dist/settings/inverted-index-filter.d.ts +26 -0
  291. package/dist/studio/index.cjs +3 -3
  292. package/dist/studio/index.js +2 -2
  293. package/dist/tags/definitions.d.ts +10 -0
  294. package/dist/tags/index.d.ts +4 -1
  295. package/dist/tags/page/ExtractEntitiesDialog.d.ts +24 -0
  296. package/dist/tags/page/TagPicker.d.ts +16 -0
  297. package/dist/tags/page/tagsPageLabels.d.ts +36 -0
  298. package/dist/workflow-canvas/index.cjs +19 -20
  299. package/dist/workflow-canvas/index.cjs.map +1 -1
  300. package/dist/workflow-canvas/index.js +6 -7
  301. package/dist/workflow-canvas/index.js.map +1 -1
  302. package/node_modules/@arbidocs/coedit/package.json +1 -1
  303. package/package.json +13 -4
  304. package/dist/calendar/access-setup.d.ts +0 -8
  305. package/dist/chunk-2MJWWPHY.js.map +0 -1
  306. package/dist/chunk-3AFWGEDJ.cjs +0 -53
  307. package/dist/chunk-3AFWGEDJ.cjs.map +0 -1
  308. package/dist/chunk-6YTHQ73P.cjs.map +0 -1
  309. package/dist/chunk-7RJTEWYM.js.map +0 -1
  310. package/dist/chunk-AINU3EJ6.cjs.map +0 -1
  311. package/dist/chunk-AOSUHWIL.js.map +0 -1
  312. package/dist/chunk-B3AHCIV5.js.map +0 -1
  313. package/dist/chunk-CSI2B2H5.js.map +0 -1
  314. package/dist/chunk-DAHCRVPM.js.map +0 -1
  315. package/dist/chunk-DETZZBG2.cjs.map +0 -1
  316. package/dist/chunk-DGV7HQA7.js.map +0 -1
  317. package/dist/chunk-EVUEIBNU.js.map +0 -1
  318. package/dist/chunk-H74HEPKT.js.map +0 -1
  319. package/dist/chunk-I2QSDQQV.cjs.map +0 -1
  320. package/dist/chunk-J5CWKFSC.js +0 -170
  321. package/dist/chunk-J5CWKFSC.js.map +0 -1
  322. package/dist/chunk-LTU35TQN.cjs.map +0 -1
  323. package/dist/chunk-MFY2ZNP6.cjs.map +0 -1
  324. package/dist/chunk-MHFF5N65.cjs.map +0 -1
  325. package/dist/chunk-NRFAWUVD.js.map +0 -1
  326. package/dist/chunk-O4YPVYPO.cjs.map +0 -1
  327. package/dist/chunk-ODRHHWHY.cjs.map +0 -1
  328. package/dist/chunk-QI6AIHWP.cjs.map +0 -1
  329. package/dist/chunk-QXMR5YHC.js.map +0 -1
  330. package/dist/chunk-RFXJYIDV.js +0 -50
  331. package/dist/chunk-RFXJYIDV.js.map +0 -1
  332. package/dist/chunk-U37AYUPI.cjs.map +0 -1
  333. package/dist/chunk-WIZ7Z7FN.js.map +0 -1
  334. package/dist/chunk-XVUOMWMD.cjs +0 -177
  335. package/dist/chunk-XVUOMWMD.cjs.map +0 -1
  336. package/dist/chunk-YSHIC4NJ.cjs.map +0 -1
  337. package/dist/connection/ConnectedTagTable.d.ts +0 -32
  338. package/dist/connection/calendar/CopyField.d.ts +0 -9
  339. package/dist/connection/calendar/OpenAccessPanel.d.ts +0 -7
@@ -0,0 +1,1907 @@
1
+ "use client";
2
+ import { ViewToggle } from './chunk-JJA6GQKH.js';
3
+ import { formatSpan, TimelineCalendar, TimelineGantt } from './chunk-4EZVCGRL.js';
4
+ import { decodeWhitespaceEntities } from './chunk-AF6RDAJF.js';
5
+ import { SelectionBar, SelectionBarAction } from './chunk-NUNKSZKU.js';
6
+ import { FilterInput } from './chunk-YU2KUMGE.js';
7
+ import { detectTimeZone, listTimeZones } from './chunk-GTCC2VAR.js';
8
+ import { TabHeader } from './chunk-4WWM3GQ5.js';
9
+ import { observeResize } from './chunk-NPLYHR2E.js';
10
+ import { testIdOr } from './chunk-7F6CBP3Z.js';
11
+ import { PencilLine, Check, X, Info, Loader2, Trash2, CalendarDays, Paperclip, Tags, MoreHorizontal, FolderUp, Milestone, CalendarClock, Scale, Lightbulb, ArrowRight, Columns3, ChevronDown, RotateCcw, BookMarked, Plus, MoreVertical, Pencil, Quote, ChevronLeft, ChevronRight, Table2, CalendarRange, GanttChartSquare, Search } from 'lucide-react';
12
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
+ import { unwrapCitationLinks, versionRef } from '@arbidocs/react/artifacts';
14
+ import { Popover, PopoverTrigger, PopoverContent, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, cn, Tooltip, TooltipTrigger, TooltipContent, Button, Input, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, CommandSeparator } from '@arbidocs/react/ui';
15
+ import { memo, useState, useMemo, useRef, useEffect } from 'react';
16
+
17
+ var DEFAULT_FACT_SOURCE_GROUP_LABELS = {
18
+ remove: "Remove this document",
19
+ wholeDocument: "Whole document \u2014 open it to cite specific passages"
20
+ };
21
+ function FactSourceGroup({
22
+ docId,
23
+ document: document2,
24
+ isViewing,
25
+ onRemove,
26
+ children,
27
+ hasPassages,
28
+ labels,
29
+ testIds
30
+ }) {
31
+ const l = { ...DEFAULT_FACT_SOURCE_GROUP_LABELS, ...labels };
32
+ return /* @__PURE__ */ jsxs(
33
+ "div",
34
+ {
35
+ className: "flex flex-col gap-1",
36
+ "data-testid": testIdOr(testIds?.root?.(docId), { testId: `citation-doc-${docId}` }),
37
+ "data-viewing": isViewing || void 0,
38
+ "data-slot": "fact-source-group",
39
+ children: [
40
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 px-1 text-sm", children: [
41
+ document2,
42
+ /* @__PURE__ */ jsx("span", { className: "flex-1" }),
43
+ onRemove && /* @__PURE__ */ jsx(
44
+ "button",
45
+ {
46
+ type: "button",
47
+ onClick: onRemove,
48
+ "aria-label": l.remove,
49
+ "data-testid": testIdOr(testIds?.remove?.(docId), {
50
+ testId: `fact-source-remove-${docId}`
51
+ }),
52
+ className: "shrink-0 rounded p-0.5 hover:bg-destructive/20 hover:text-destructive pointer-coarse:p-3",
53
+ children: /* @__PURE__ */ jsx(X, { className: "size-3" })
54
+ }
55
+ )
56
+ ] }),
57
+ hasPassages ? children : /* @__PURE__ */ jsx("span", { className: "px-2 text-xs text-muted-foreground", children: l.wholeDocument })
58
+ ]
59
+ }
60
+ );
61
+ }
62
+ function toFactCitations(citations) {
63
+ if (!citations) return null;
64
+ return citations.map((d) => ({
65
+ doc_ext_id: d.doc_ext_id,
66
+ ...d.version ? { version: d.version } : {},
67
+ chunks: d.chunks ?? []
68
+ }));
69
+ }
70
+ function isWholeDoc(doc) {
71
+ return doc.chunks.length === 0;
72
+ }
73
+ function docIdsOf(citations) {
74
+ return (citations ?? []).map((d) => d.doc_ext_id);
75
+ }
76
+ function chunkIdsOf(citations) {
77
+ return (citations ?? []).flatMap((d) => d.chunks.map((c) => c.chunk_id));
78
+ }
79
+ function hasChunk(citations, chunkId) {
80
+ return (citations ?? []).some((d) => d.chunks.some((c) => c.chunk_id === chunkId));
81
+ }
82
+ function withDoc(citations, docExtId) {
83
+ const list = citations ?? [];
84
+ if (list.some((d) => d.doc_ext_id === docExtId)) return list;
85
+ return [...list, { doc_ext_id: docExtId, chunks: [] }];
86
+ }
87
+ function withoutDoc(citations, docExtId) {
88
+ const remaining = (citations ?? []).filter((d) => d.doc_ext_id !== docExtId);
89
+ return remaining.length ? remaining : null;
90
+ }
91
+ function withChunk(citations, docExtId, chunk) {
92
+ const list = citations ?? [];
93
+ const idx = list.findIndex((d) => d.doc_ext_id === docExtId);
94
+ if (idx === -1) return [...list, { doc_ext_id: docExtId, chunks: [chunk] }];
95
+ const doc = list[idx];
96
+ if (doc.chunks.some((c) => c.chunk_id === chunk.chunk_id)) return list;
97
+ const next = [...list];
98
+ next[idx] = { ...doc, chunks: [...doc.chunks, chunk] };
99
+ return next;
100
+ }
101
+ function withoutChunk(citations, chunkId, opts = {}) {
102
+ const keepDoc = opts.keepDoc ?? true;
103
+ const list = citations ?? [];
104
+ if (!hasChunk(list, chunkId)) return citations ?? null;
105
+ const next = [];
106
+ for (const doc of list) {
107
+ if (!doc.chunks.some((c) => c.chunk_id === chunkId)) {
108
+ next.push(doc);
109
+ continue;
110
+ }
111
+ const chunks = doc.chunks.filter((c) => c.chunk_id !== chunkId);
112
+ if (chunks.length || keepDoc) next.push({ ...doc, chunks });
113
+ }
114
+ return next.length ? next : null;
115
+ }
116
+ function repairBoldFlanking(md) {
117
+ return md.replace(/([.,;:!?"'’”)\]])(\*\*|__)(?=[A-Za-z0-9])/g, "$1$2 ");
118
+ }
119
+ var CHAT_LEAD_IN = /^(?:here(?:'s| is| are)|below (?:is|are)|sure|certainly)\b[^\n]*:[ \t]*(?:\n+|$)/i;
120
+ function dropChatLeadIn(md) {
121
+ const body = md.replace(CHAT_LEAD_IN, "");
122
+ return body.trim() ? body : md;
123
+ }
124
+ function buildFactCitations(content, activeCitations, citationData) {
125
+ const text = dropChatLeadIn(repairBoldFlanking(unwrapCitationLinks(content)).trim()).trim();
126
+ if (!activeCitations) return { text, citations: null };
127
+ const chunkMeta = /* @__PURE__ */ new Map();
128
+ for (const chunks of Object.values(citationData)) {
129
+ if (!Array.isArray(chunks)) continue;
130
+ for (const chunk of chunks) {
131
+ const meta = {
132
+ doc_ext_id: chunk.metadata?.doc_ext_id ?? null,
133
+ page: chunk.metadata?.page_number ?? null
134
+ };
135
+ for (const key of [chunk.metadata?.chunk_ext_id, chunk.chunk_id]) {
136
+ if (key && !chunkMeta.has(key)) chunkMeta.set(key, meta);
137
+ }
138
+ }
139
+ }
140
+ let citations = null;
141
+ for (const chunkIds of Object.values(activeCitations)) {
142
+ for (const chunkId of chunkIds) {
143
+ const meta = chunkMeta.get(chunkId);
144
+ if (!meta?.doc_ext_id) continue;
145
+ citations = withChunk(citations, meta.doc_ext_id, { chunk_id: chunkId, page: meta.page });
146
+ }
147
+ }
148
+ return { text, citations };
149
+ }
150
+ function citedVersionRef(docId, version, currentVersion) {
151
+ if (!version) return docId;
152
+ return currentVersion != null && currentVersion === version ? docId : versionRef(docId, version);
153
+ }
154
+ var DEFAULT_FACT_COMPOSER_LABELS = {
155
+ shared: "Shared",
156
+ verified: "Verified",
157
+ dates: "Dates",
158
+ deleteFact: "Delete fact",
159
+ cancel: "Cancel",
160
+ saveFact: "Save fact",
161
+ saving: "Saving\u2026",
162
+ addFact: "Add fact",
163
+ adding: "Adding\u2026"
164
+ };
165
+ var DEFAULT_FACT_SOURCES_ROW_LABELS = {
166
+ sources: "Sources",
167
+ hintButton: "How to add sources",
168
+ hint: "In the picker, tick a document's checkbox to add it as a source, or click its name to just open it. Inside a document, click a passage to add it \u2014 shift-click to take a whole range. Add as many as you like, from as many documents as you like."
169
+ };
170
+ function FactFieldRow({
171
+ label,
172
+ children,
173
+ className
174
+ }) {
175
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1.5", className), "data-slot": "fact-field-row", children: [
176
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: label }),
177
+ /* @__PURE__ */ jsx("div", { className: "min-w-0", children })
178
+ ] });
179
+ }
180
+ function FactSourcesRow({ toggle, picker, labels, hintTestId }) {
181
+ const l = { ...DEFAULT_FACT_SOURCES_ROW_LABELS, ...labels };
182
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", "data-slot": "fact-sources-row", children: [
183
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-sm font-medium text-foreground", children: [
184
+ l.sources,
185
+ /* @__PURE__ */ jsxs(Tooltip, { children: [
186
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
187
+ "button",
188
+ {
189
+ type: "button",
190
+ "aria-label": l.hintButton,
191
+ className: "text-muted-foreground hover:text-foreground",
192
+ "data-testid": testIdOr(hintTestId, { testId: "facts-source-hint" }),
193
+ children: /* @__PURE__ */ jsx(Info, { className: "size-3.5" })
194
+ }
195
+ ) }),
196
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: l.hint })
197
+ ] })
198
+ ] }),
199
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
200
+ toggle,
201
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: picker })
202
+ ] })
203
+ ] });
204
+ }
205
+ function FactComposer({
206
+ isOpen,
207
+ panelRef,
208
+ editor,
209
+ labels,
210
+ sharedToggle,
211
+ verifiedToggle,
212
+ dateInput,
213
+ isEditing,
214
+ canSave,
215
+ isSaving,
216
+ isDeleting,
217
+ onSave,
218
+ onCancel,
219
+ onDelete,
220
+ error,
221
+ uiLabels: labelOverrides,
222
+ testIds
223
+ }) {
224
+ const l = { ...DEFAULT_FACT_COMPOSER_LABELS, ...labelOverrides };
225
+ return /* @__PURE__ */ jsx(
226
+ "div",
227
+ {
228
+ className: cn(
229
+ "grid shrink-0 transition-[grid-template-rows,opacity] duration-500 ease-in-out",
230
+ isOpen ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
231
+ ),
232
+ "data-slot": "fact-composer",
233
+ children: /* @__PURE__ */ jsx("div", { className: "overflow-hidden", children: /* @__PURE__ */ jsxs(
234
+ "div",
235
+ {
236
+ ref: panelRef,
237
+ className: "facts-composer flex flex-col gap-4 border-b border-border bg-muted px-4 py-4",
238
+ children: [
239
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
240
+ editor,
241
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
242
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-2", children: [
243
+ /* @__PURE__ */ jsx(
244
+ "div",
245
+ {
246
+ "data-testid": testIdOr(testIds?.tags, { testId: "facts-page-composer-tags" }),
247
+ className: "min-w-[14rem] flex-1",
248
+ children: labels
249
+ }
250
+ ),
251
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-6", children: [
252
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-foreground", children: [
253
+ sharedToggle,
254
+ l.shared
255
+ ] }),
256
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-foreground", children: [
257
+ verifiedToggle,
258
+ l.verified
259
+ ] })
260
+ ] })
261
+ ] }),
262
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-2", children: [
263
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-[10rem] flex-1 flex-col gap-1.5", children: [
264
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: l.dates }),
265
+ dateInput
266
+ ] }),
267
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2 self-end max-sm:w-full max-sm:justify-end", children: [
268
+ isEditing && /* @__PURE__ */ jsx(
269
+ Button,
270
+ {
271
+ variant: "ghost",
272
+ size: "sm",
273
+ className: "size-7 p-0 text-destructive hover:bg-destructive/10 hover:text-destructive pointer-coarse:size-11",
274
+ onClick: onDelete,
275
+ disabled: isDeleting,
276
+ "data-testid": testIdOr(testIds?.delete, {
277
+ testId: "facts-page-composer-delete"
278
+ }),
279
+ "aria-label": l.deleteFact,
280
+ title: l.deleteFact,
281
+ children: isDeleting ? /* @__PURE__ */ jsx(Loader2, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" })
282
+ }
283
+ ),
284
+ /* @__PURE__ */ jsx(
285
+ Button,
286
+ {
287
+ variant: "ghost",
288
+ size: "sm",
289
+ className: "h-7 pointer-coarse:h-11",
290
+ onClick: onCancel,
291
+ children: l.cancel
292
+ }
293
+ ),
294
+ /* @__PURE__ */ jsx(
295
+ Button,
296
+ {
297
+ size: "sm",
298
+ className: "h-7 pointer-coarse:h-11",
299
+ disabled: !canSave,
300
+ onClick: onSave,
301
+ "data-testid": testIdOr(testIds?.save, { testId: "facts-page-composer-save" }),
302
+ children: isEditing ? isSaving ? l.saving : l.saveFact : isSaving ? l.adding : l.addFact
303
+ }
304
+ )
305
+ ] })
306
+ ] })
307
+ ] })
308
+ ] }),
309
+ error && /* @__PURE__ */ jsx(
310
+ "p",
311
+ {
312
+ className: "text-xs text-destructive",
313
+ "data-testid": testIdOr(testIds?.error, { testId: "facts-page-composer-error" }),
314
+ children: error
315
+ }
316
+ )
317
+ ]
318
+ }
319
+ ) })
320
+ }
321
+ );
322
+ }
323
+
324
+ // src/facts/fact-date.ts
325
+ var EMPTY_FACT_DATE_FIELDS = {
326
+ date: "",
327
+ time: "",
328
+ timezone: "",
329
+ endDate: "",
330
+ endTime: ""
331
+ };
332
+ function isMidnightUtc(d) {
333
+ return d.getUTCHours() === 0 && d.getUTCMinutes() === 0 && d.getUTCSeconds() === 0;
334
+ }
335
+ function isEndOfDayUtc(d) {
336
+ return d.getUTCHours() === 23 && d.getUTCMinutes() === 59;
337
+ }
338
+ function dayKeyUtc(d) {
339
+ return d.toISOString().slice(0, 10);
340
+ }
341
+ function safeTimeZone(tz) {
342
+ try {
343
+ new Intl.DateTimeFormat("en-US", { timeZone: tz });
344
+ return tz;
345
+ } catch {
346
+ return "UTC";
347
+ }
348
+ }
349
+ function isoToZonedParts(iso, timeZone) {
350
+ const d = new Date(iso);
351
+ const parts = Object.fromEntries(
352
+ new Intl.DateTimeFormat("en-US", {
353
+ timeZone: safeTimeZone(timeZone),
354
+ hourCycle: "h23",
355
+ year: "numeric",
356
+ month: "2-digit",
357
+ day: "2-digit",
358
+ hour: "2-digit",
359
+ minute: "2-digit"
360
+ }).formatToParts(d).map((p) => [p.type, p.value])
361
+ );
362
+ return {
363
+ date: `${parts.year}-${parts.month}-${parts.day}`,
364
+ time: `${parts.hour}:${parts.minute}`
365
+ };
366
+ }
367
+ function zonedPartsToIso(date, time, timeZone) {
368
+ const tz = safeTimeZone(timeZone);
369
+ const guess = /* @__PURE__ */ new Date(`${date}T${time}:00Z`);
370
+ const zoned = isoToZonedParts(guess.toISOString(), tz);
371
+ const [y, m, dd] = zoned.date.split("-").map(Number);
372
+ const [hh, mi] = zoned.time.split(":").map(Number);
373
+ const asIfUtc = Date.UTC(y, m - 1, dd, hh, mi);
374
+ const offsetMs = asIfUtc - guess.getTime();
375
+ return new Date(guess.getTime() - offsetMs).toISOString();
376
+ }
377
+ function factDateSpanToFields(dateStart, dateEnd, timezone) {
378
+ if (!dateStart) return EMPTY_FACT_DATE_FIELDS;
379
+ const start = new Date(dateStart);
380
+ if (Number.isNaN(start.getTime())) return EMPTY_FACT_DATE_FIELDS;
381
+ const end = dateEnd ? new Date(dateEnd) : start;
382
+ const dateOnly = isMidnightUtc(start) && (!dateEnd || isEndOfDayUtc(end));
383
+ if (dateOnly) {
384
+ const startKey = dayKeyUtc(start);
385
+ const endKey = dateEnd ? dayKeyUtc(end) : startKey;
386
+ return { ...EMPTY_FACT_DATE_FIELDS, date: startKey, endDate: endKey !== startKey ? endKey : "" };
387
+ }
388
+ const tz = timezone || "UTC";
389
+ const startParts = isoToZonedParts(dateStart, tz);
390
+ const isInstant = !dateEnd || dateStart === dateEnd;
391
+ const endParts = isInstant ? null : isoToZonedParts(dateEnd, tz);
392
+ return {
393
+ date: startParts.date,
394
+ time: startParts.time,
395
+ timezone: tz,
396
+ endDate: endParts?.date ?? "",
397
+ endTime: endParts?.time ?? ""
398
+ };
399
+ }
400
+ function factDateFieldsToSpan(fields) {
401
+ if (!fields.date) return { date: null, date_end: null, timezone: null };
402
+ const tz = fields.timezone || detectTimeZone();
403
+ const startIso = fields.time ? zonedPartsToIso(fields.date, fields.time, tz) : `${fields.date}T00:00:00.000Z`;
404
+ let endIso;
405
+ if (fields.endDate) {
406
+ endIso = fields.time && fields.endTime ? zonedPartsToIso(fields.endDate, fields.endTime, tz) : `${fields.endDate}T23:59:59.000Z`;
407
+ } else {
408
+ endIso = fields.time ? startIso : `${fields.date}T23:59:59.000Z`;
409
+ }
410
+ return { date: startIso, date_end: endIso, timezone: fields.time ? tz : null };
411
+ }
412
+ var DEFAULT_FACT_DATE_INPUT_LABELS = {
413
+ weekdays: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
414
+ months: [
415
+ "January",
416
+ "February",
417
+ "March",
418
+ "April",
419
+ "May",
420
+ "June",
421
+ "July",
422
+ "August",
423
+ "September",
424
+ "October",
425
+ "November",
426
+ "December"
427
+ ],
428
+ previousMonth: "Previous month",
429
+ earlierYears: "Earlier years",
430
+ nextMonth: "Next month",
431
+ laterYears: "Later years",
432
+ pickYear: "Pick a year",
433
+ addDate: "Add a date",
434
+ startTime: "Start time",
435
+ endTime: "End time",
436
+ setStartFirst: "Set a start time first",
437
+ timezone: "Timezone",
438
+ endDate: "End date (optional)",
439
+ clearDate: "Clear date"
440
+ };
441
+ function dayKey(year, monthIndex, day) {
442
+ const m = String(monthIndex + 1).padStart(2, "0");
443
+ const d = String(day).padStart(2, "0");
444
+ return `${year}-${m}-${d}`;
445
+ }
446
+ function prettyDay(iso) {
447
+ const [y, m, d] = iso.split("-").map(Number);
448
+ if (!y || !m || !d) return iso;
449
+ return new Date(Date.UTC(y, m - 1, d)).toLocaleDateString(void 0, {
450
+ year: "numeric",
451
+ month: "short",
452
+ day: "numeric",
453
+ timeZone: "UTC"
454
+ });
455
+ }
456
+ function summarizeWithTimes(v) {
457
+ const start = `${prettyDay(v.date)}, ${v.time}`;
458
+ const endDay = v.endDate || v.date;
459
+ if (v.endTime) return `${start} \u2013 ${prettyDay(endDay)}, ${v.endTime}`;
460
+ if (v.endDate && v.endDate !== v.date) return `${start} \u2013 ${prettyDay(v.endDate)}`;
461
+ return start;
462
+ }
463
+ function MonthCalendar({
464
+ selected,
465
+ onSelect,
466
+ labels: l,
467
+ testIds
468
+ }) {
469
+ const now = /* @__PURE__ */ new Date();
470
+ const todayKey = dayKey(now.getFullYear(), now.getMonth(), now.getDate());
471
+ const initial = useMemo(() => {
472
+ if (selected) {
473
+ const [y, m] = selected.split("-").map(Number);
474
+ if (y && m) return { year: y, monthIndex: m - 1 };
475
+ }
476
+ return { year: now.getFullYear(), monthIndex: now.getMonth() };
477
+ }, []);
478
+ const [view, setView] = useState(initial);
479
+ const [mode, setMode] = useState("days");
480
+ const [yearStart, setYearStart] = useState(initial.year - 5);
481
+ const firstWeekday = new Date(view.year, view.monthIndex, 1).getDay();
482
+ const daysInMonth = new Date(view.year, view.monthIndex + 1, 0).getDate();
483
+ const cells = [
484
+ ...Array.from({ length: firstWeekday }, () => null),
485
+ ...Array.from({ length: daysInMonth }, (_, i) => i + 1)
486
+ ];
487
+ const step = (delta) => {
488
+ const next = view.monthIndex + delta;
489
+ setView({
490
+ year: view.year + Math.floor(next / 12),
491
+ monthIndex: (next % 12 + 12) % 12
492
+ });
493
+ };
494
+ const openYears = () => {
495
+ setYearStart(view.year - 5);
496
+ setMode("years");
497
+ };
498
+ const pickYear = (year) => {
499
+ setView((v) => ({ ...v, year }));
500
+ setMode("days");
501
+ };
502
+ const years = Array.from({ length: 12 }, (_, i) => yearStart + i);
503
+ return /* @__PURE__ */ jsxs("div", { className: "w-[248px]", children: [
504
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-1 pb-2", children: [
505
+ /* @__PURE__ */ jsx(
506
+ "button",
507
+ {
508
+ type: "button",
509
+ onClick: () => mode === "days" ? step(-1) : setYearStart((s) => s - 12),
510
+ className: "rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground pointer-coarse:p-3",
511
+ "aria-label": mode === "days" ? l.previousMonth : l.earlierYears,
512
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" })
513
+ }
514
+ ),
515
+ mode === "days" ? /* @__PURE__ */ jsxs(
516
+ "button",
517
+ {
518
+ type: "button",
519
+ onClick: openYears,
520
+ className: "rounded px-1.5 py-0.5 text-sm font-medium hover:bg-accent hover:text-foreground",
521
+ "aria-label": l.pickYear,
522
+ "data-testid": testIdOr(testIds?.caption, { testId: "fact-calendar-caption" }),
523
+ children: [
524
+ l.months[view.monthIndex],
525
+ " ",
526
+ view.year
527
+ ]
528
+ }
529
+ ) : /* @__PURE__ */ jsxs("span", { className: "text-sm font-medium", children: [
530
+ yearStart,
531
+ " \u2013 ",
532
+ yearStart + 11
533
+ ] }),
534
+ /* @__PURE__ */ jsx(
535
+ "button",
536
+ {
537
+ type: "button",
538
+ onClick: () => mode === "days" ? step(1) : setYearStart((s) => s + 12),
539
+ className: "rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground pointer-coarse:p-3",
540
+ "aria-label": mode === "days" ? l.nextMonth : l.laterYears,
541
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })
542
+ }
543
+ )
544
+ ] }),
545
+ mode === "days" ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-7 gap-0.5", children: [
546
+ l.weekdays.map((w) => /* @__PURE__ */ jsx("div", { className: "py-1 text-center text-xs font-medium text-muted-foreground", children: w }, w)),
547
+ cells.map((day, i) => {
548
+ if (day === null) return /* @__PURE__ */ jsx("div", {}, `blank-${i}`);
549
+ const key = dayKey(view.year, view.monthIndex, day);
550
+ const isSelected = key === selected;
551
+ const isToday = key === todayKey;
552
+ return /* @__PURE__ */ jsx(
553
+ "button",
554
+ {
555
+ type: "button",
556
+ onClick: () => onSelect(key),
557
+ "data-testid": testIdOr(testIds?.day?.(key), { testId: `fact-calendar-day-${key}` }),
558
+ className: cn(
559
+ "h-8 rounded text-xs transition-colors hover:bg-accent pointer-coarse:h-11",
560
+ isSelected && "bg-primary text-primary-foreground hover:bg-primary",
561
+ !isSelected && isToday && "ring-1 ring-inset ring-primary/50"
562
+ ),
563
+ children: day
564
+ },
565
+ key
566
+ );
567
+ })
568
+ ] }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-1", children: years.map((y) => /* @__PURE__ */ jsx(
569
+ "button",
570
+ {
571
+ type: "button",
572
+ onClick: () => pickYear(y),
573
+ "data-testid": testIdOr(testIds?.year?.(y), { testId: `fact-calendar-year-${y}` }),
574
+ className: cn(
575
+ "h-9 rounded text-xs transition-colors hover:bg-accent pointer-coarse:h-11",
576
+ y === view.year && "bg-primary text-primary-foreground hover:bg-primary"
577
+ ),
578
+ children: y
579
+ },
580
+ y
581
+ )) })
582
+ ] });
583
+ }
584
+ function FactDateInput({ value, onChange, idPrefix, labels, testIds }) {
585
+ const l = { ...DEFAULT_FACT_DATE_INPUT_LABELS, ...labels };
586
+ const [open, setOpen] = useState(false);
587
+ const timezones = useMemo(() => listTimeZones(), []);
588
+ const timezoneListId = `${idPrefix}-timezone-options`;
589
+ const span = factDateFieldsToSpan(value);
590
+ const summary = value.time || value.endTime ? summarizeWithTimes(value) : formatSpan(span.date, span.date_end, span.timezone);
591
+ const setDate = (dateKey) => onChange({ ...value, date: dateKey, endDate: value.endDate && dateKey ? value.endDate : "" });
592
+ const setStartTime = (time) => onChange({
593
+ ...value,
594
+ time,
595
+ timezone: time ? value.timezone || detectTimeZone() : "",
596
+ endTime: time ? value.endTime : ""
597
+ });
598
+ const setEndTime = (endTime) => onChange({
599
+ ...value,
600
+ endTime,
601
+ endDate: endTime ? value.endDate || value.date : value.endDate
602
+ });
603
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1.5", children: /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
604
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
605
+ "button",
606
+ {
607
+ type: "button",
608
+ className: cn(
609
+ "inline-flex h-9 w-full items-center gap-2 rounded-md border border-input bg-transparent px-3 text-sm transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
610
+ !summary && "text-muted-foreground"
611
+ ),
612
+ "data-testid": `${idPrefix}-date-trigger`,
613
+ children: [
614
+ /* @__PURE__ */ jsx(CalendarDays, { className: "size-4 shrink-0 text-muted-foreground" }),
615
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: summary || l.addDate })
616
+ ]
617
+ }
618
+ ) }),
619
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "w-auto p-3", align: "start", children: [
620
+ /* @__PURE__ */ jsx(MonthCalendar, { selected: value.date, onSelect: setDate, labels: l, testIds }),
621
+ value.date && /* @__PURE__ */ jsxs("div", { className: "mt-3 flex flex-col gap-2 border-t border-border pt-3", children: [
622
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
623
+ /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1", children: [
624
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: l.startTime }),
625
+ /* @__PURE__ */ jsx(
626
+ Input,
627
+ {
628
+ type: "time",
629
+ value: value.time,
630
+ onChange: (e) => setStartTime(e.target.value),
631
+ className: "h-8 text-xs",
632
+ "data-testid": `${idPrefix}-time`
633
+ }
634
+ )
635
+ ] }),
636
+ /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1", children: [
637
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: l.endTime }),
638
+ /* @__PURE__ */ jsx(
639
+ Input,
640
+ {
641
+ type: "time",
642
+ value: value.endTime,
643
+ onChange: (e) => setEndTime(e.target.value),
644
+ disabled: !value.time,
645
+ title: value.time ? void 0 : l.setStartFirst,
646
+ className: "h-8 text-xs",
647
+ "data-testid": `${idPrefix}-end-time`
648
+ }
649
+ )
650
+ ] })
651
+ ] }),
652
+ value.time && /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1", children: [
653
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: l.timezone }),
654
+ /* @__PURE__ */ jsx(
655
+ Input,
656
+ {
657
+ list: timezoneListId,
658
+ value: value.timezone,
659
+ onChange: (e) => onChange({ ...value, timezone: e.target.value }),
660
+ placeholder: detectTimeZone(),
661
+ className: "h-8 text-xs",
662
+ "data-testid": `${idPrefix}-timezone`
663
+ }
664
+ ),
665
+ /* @__PURE__ */ jsx("datalist", { id: timezoneListId, children: timezones.map((tz) => /* @__PURE__ */ jsx("option", { value: tz }, tz)) })
666
+ ] }),
667
+ /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1", children: [
668
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: l.endDate }),
669
+ /* @__PURE__ */ jsx(
670
+ Input,
671
+ {
672
+ type: "date",
673
+ value: value.endDate,
674
+ min: value.date,
675
+ onChange: (e) => onChange({ ...value, endDate: e.target.value }),
676
+ className: "h-8 text-xs",
677
+ "data-testid": `${idPrefix}-end-date`
678
+ }
679
+ )
680
+ ] }),
681
+ /* @__PURE__ */ jsxs(
682
+ Button,
683
+ {
684
+ type: "button",
685
+ variant: "ghost",
686
+ size: "sm",
687
+ className: "h-7 self-start text-muted-foreground hover:text-foreground",
688
+ onClick: () => onChange(EMPTY_FACT_DATE_FIELDS),
689
+ "data-testid": `${idPrefix}-clear-date`,
690
+ children: [
691
+ /* @__PURE__ */ jsx(X, { className: "mr-1 size-3.5" }),
692
+ " ",
693
+ l.clearDate
694
+ ]
695
+ }
696
+ )
697
+ ] })
698
+ ] })
699
+ ] }) });
700
+ }
701
+ var DEFAULT_FACTS_BULK_BAR_LABELS = {
702
+ removeFromChat: "Remove from Chat",
703
+ addToChat: "Add to Chat",
704
+ label: "Label",
705
+ shared: "Shared",
706
+ more: "More",
707
+ export: "Export",
708
+ delete: "Delete",
709
+ budgetHint: "Facts added to this chat are always in ARBI's context for this chat, so they share one budget. This estimates the tokens they add (\u22484 characters per token), capped at ~2,000.",
710
+ budget: (tokens, cap) => `~${tokens}/${cap} tokens`,
711
+ removeFromChatTooltip: (n) => `Remove the selected ${n} from this chat`,
712
+ addToChatTooltip: (n) => `Add the selected ${n} to this chat, so they are always in its context`,
713
+ labelTooltip: (n) => `Add or remove labels from selected ${n}`
714
+ };
715
+ function FactsBulkBar({
716
+ count,
717
+ onClear,
718
+ allSelectedInChat,
719
+ onToggleInChat,
720
+ onLabel,
721
+ sharedToggle,
722
+ onExport,
723
+ onDelete,
724
+ budget,
725
+ pluralNoun = "facts",
726
+ labels,
727
+ testIds
728
+ }) {
729
+ const l = { ...DEFAULT_FACTS_BULK_BAR_LABELS, ...labels };
730
+ const none = count === 0;
731
+ return /* @__PURE__ */ jsx("div", { className: "pb-3", "data-slot": "facts-bulk-bar", children: /* @__PURE__ */ jsx(
732
+ SelectionBar,
733
+ {
734
+ count,
735
+ onClear,
736
+ status: budget ? /* @__PURE__ */ jsx(
737
+ "span",
738
+ {
739
+ className: cn(
740
+ "shrink-0 text-xs tabular-nums",
741
+ budget.isOver ? "text-destructive" : "text-muted-foreground"
742
+ ),
743
+ title: l.budgetHint,
744
+ "data-testid": testIdOr(testIds?.budget, { testId: "facts-page-chat-budget" }),
745
+ children: l.budget(budget.tokens.toLocaleString(), budget.cap.toLocaleString())
746
+ }
747
+ ) : null,
748
+ children: (isCompact) => /* @__PURE__ */ jsxs(Fragment, { children: [
749
+ onToggleInChat && /* @__PURE__ */ jsx(
750
+ SelectionBarAction,
751
+ {
752
+ icon: Paperclip,
753
+ label: allSelectedInChat ? l.removeFromChat : l.addToChat,
754
+ onClick: onToggleInChat,
755
+ disabled: none,
756
+ isCompact,
757
+ className: "border-blue-border text-blue-text hover:bg-blue-bg hover:text-blue-text",
758
+ tooltip: allSelectedInChat ? l.removeFromChatTooltip(pluralNoun) : l.addToChatTooltip(pluralNoun),
759
+ testId: testIdOr(testIds?.inChat, { testId: "bulk-in-chat-facts-button" })
760
+ }
761
+ ),
762
+ onLabel && /* @__PURE__ */ jsx(
763
+ SelectionBarAction,
764
+ {
765
+ icon: Tags,
766
+ label: l.label,
767
+ onClick: onLabel,
768
+ disabled: none,
769
+ isCompact,
770
+ className: "border-green-border text-green-text hover:bg-green-bg hover:text-green-text",
771
+ tooltip: l.labelTooltip(pluralNoun),
772
+ testId: testIdOr(testIds?.label, { testId: "bulk-label-facts-button" })
773
+ }
774
+ ),
775
+ /* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1", children: [
776
+ sharedToggle,
777
+ !isCompact && /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: l.shared })
778
+ ] }),
779
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
780
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
781
+ Button,
782
+ {
783
+ variant: "outline",
784
+ size: "sm",
785
+ className: "h-7 gap-1.5 px-2 pointer-coarse:h-11",
786
+ disabled: none,
787
+ "data-testid": testIdOr(testIds?.more, { testId: "facts-bulk-more-button" }),
788
+ children: [
789
+ /* @__PURE__ */ jsx(MoreHorizontal, { className: "size-4" }),
790
+ !isCompact && /* @__PURE__ */ jsx("span", { className: "text-sm", children: l.more })
791
+ ]
792
+ }
793
+ ) }),
794
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
795
+ onExport && /* @__PURE__ */ jsxs(Fragment, { children: [
796
+ /* @__PURE__ */ jsxs(
797
+ DropdownMenuItem,
798
+ {
799
+ onClick: onExport,
800
+ disabled: none,
801
+ "data-testid": testIdOr(testIds?.export, { testId: "export-facts-button" }),
802
+ children: [
803
+ /* @__PURE__ */ jsx(FolderUp, { className: "mr-2 size-4" }),
804
+ l.export
805
+ ]
806
+ }
807
+ ),
808
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {})
809
+ ] }),
810
+ /* @__PURE__ */ jsxs(
811
+ DropdownMenuItem,
812
+ {
813
+ onClick: onDelete,
814
+ disabled: none,
815
+ className: "text-red-text focus:text-red-text",
816
+ "data-testid": testIdOr(testIds?.delete, { testId: "bulk-delete-facts-button" }),
817
+ children: [
818
+ /* @__PURE__ */ jsx(Trash2, { className: "mr-2 size-4" }),
819
+ l.delete
820
+ ]
821
+ }
822
+ )
823
+ ] })
824
+ ] })
825
+ ] })
826
+ }
827
+ ) });
828
+ }
829
+ var DEFAULT_FACTS_EMPTY_STATE_LABELS = {
830
+ title: "Everything this workspace knows",
831
+ intro: "Facts are durable knowledge \u2014 a deadline, a decision, a preference. Write them yourself, or let the assistant distill them from your documents and chats.",
832
+ tryAdding: "Try adding a fact",
833
+ kinds: [
834
+ {
835
+ label: "Deadlines & dates",
836
+ desc: "A due date or milestone \u2014 it lands on the calendar and timeline"
837
+ },
838
+ { label: "Decisions", desc: "What was agreed, and why \u2014 so it is not lost in a thread" },
839
+ { label: "Preferences", desc: "How this workspace likes things done" }
840
+ ],
841
+ examples: [
842
+ "The renewal deadline is March 31, 2026",
843
+ "Payment terms are net 30",
844
+ "The team prefers email over phone for updates",
845
+ "Board approved the Q3 budget on May 12"
846
+ ],
847
+ loading: "Loading facts\u2026",
848
+ loadError: "Could not load facts.",
849
+ retry: "Try again"
850
+ };
851
+ var KIND_ICONS = [CalendarClock, Scale, Lightbulb];
852
+ function FactsEmptyState({ onUseExample, labels, testIds }) {
853
+ const l = { ...DEFAULT_FACTS_EMPTY_STATE_LABELS, ...labels };
854
+ return /* @__PURE__ */ jsx(
855
+ "div",
856
+ {
857
+ className: "flex min-h-full items-center justify-center p-10",
858
+ "data-testid": testIdOr(testIds?.root, { testId: "facts-page-empty-state" }),
859
+ "data-slot": "facts-empty-state",
860
+ children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-xl text-center", children: [
861
+ /* @__PURE__ */ jsx("div", { className: "mx-auto mb-4 flex size-12 items-center justify-center rounded-lg bg-accent text-accent-foreground", children: /* @__PURE__ */ jsx(Milestone, { className: "size-6" }) }),
862
+ /* @__PURE__ */ jsx("h2", { className: "mt-2 text-xl font-semibold text-foreground", children: l.title }),
863
+ /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: l.intro }),
864
+ /* @__PURE__ */ jsx("div", { className: "mt-7 grid gap-3 text-left @xl:grid-cols-3", children: l.kinds.map(({ label, desc }, i) => {
865
+ const KindIcon = KIND_ICONS[i % KIND_ICONS.length];
866
+ return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border bg-card p-3 shadow-xs", children: [
867
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-sm font-medium text-foreground", children: [
868
+ /* @__PURE__ */ jsx(KindIcon, { className: "size-4 text-primary" }),
869
+ label
870
+ ] }),
871
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs leading-snug text-muted-foreground", children: desc })
872
+ ] }, label);
873
+ }) }),
874
+ /* @__PURE__ */ jsx("p", { className: "mt-10 text-sm font-medium text-muted-foreground", children: l.tryAdding }),
875
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-wrap justify-center gap-2.5", children: l.examples.map((fact) => /* @__PURE__ */ jsxs(
876
+ "button",
877
+ {
878
+ type: "button",
879
+ onClick: () => onUseExample(fact),
880
+ className: "group inline-flex items-center gap-1.5 rounded-md border border-border bg-card px-3.5 py-2 text-sm text-foreground transition-colors hover:border-ring/50 hover:bg-accent/40 pointer-coarse:min-h-11",
881
+ "data-testid": testIdOr(testIds?.example, { testId: "facts-page-example" }),
882
+ children: [
883
+ fact,
884
+ /* @__PURE__ */ jsx(ArrowRight, { className: "size-3.5 text-muted-foreground transition-colors group-hover:text-primary" })
885
+ ]
886
+ },
887
+ fact
888
+ )) })
889
+ ] })
890
+ }
891
+ );
892
+ }
893
+ function FactsLoading({
894
+ label = DEFAULT_FACTS_EMPTY_STATE_LABELS.loading
895
+ }) {
896
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-10 text-muted-foreground", children: [
897
+ /* @__PURE__ */ jsx(Loader2, { className: "mr-2 size-4 animate-spin" }),
898
+ " ",
899
+ label
900
+ ] });
901
+ }
902
+ function FactsLoadError({
903
+ onRetry,
904
+ message = DEFAULT_FACTS_EMPTY_STATE_LABELS.loadError,
905
+ retryLabel = DEFAULT_FACTS_EMPTY_STATE_LABELS.retry
906
+ }) {
907
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-3 px-6 py-10 text-center", children: [
908
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: message }),
909
+ /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onRetry, children: retryLabel })
910
+ ] });
911
+ }
912
+ var DEFAULT_FACTS_FIELDS_BUTTON_LABELS = {
913
+ fields: "Fields",
914
+ defaultView: "Default view",
915
+ columns: "Columns",
916
+ columnNames: { in_chat: "In chat" }
917
+ };
918
+ function FactsFieldsButton({
919
+ getGridApi,
920
+ labels,
921
+ testIds
922
+ }) {
923
+ const l = { ...DEFAULT_FACTS_FIELDS_BUTTON_LABELS, ...labels };
924
+ const [open, setOpen] = useState(false);
925
+ const [version, setVersion] = useState(0);
926
+ const columns = useMemo(() => {
927
+ if (!open) return [];
928
+ const api = getGridApi();
929
+ if (!api || api.isDestroyed()) return [];
930
+ const state = api.getColumnState();
931
+ return state.filter((c) => c.colId !== "ag-Grid-SelectionColumn").map((c) => {
932
+ const def = api.getColumnDef(c.colId);
933
+ const label = def?.headerName && def.headerName.trim() || l.columnNames[c.colId] || c.colId;
934
+ return { colId: c.colId, label, visible: !c.hide };
935
+ });
936
+ }, [open, version, getGridApi, l.columnNames]);
937
+ const visibleCount = columns.filter((c) => c.visible).length;
938
+ const toggle = (colId, visible) => {
939
+ const api = getGridApi();
940
+ if (!api || api.isDestroyed()) return;
941
+ if (visible && visibleCount <= 1) return;
942
+ api.setColumnsVisible([colId], !visible);
943
+ setVersion((v) => v + 1);
944
+ };
945
+ const resetToDefault = () => {
946
+ const api = getGridApi();
947
+ if (!api || api.isDestroyed()) return;
948
+ api.resetColumnState();
949
+ setVersion((v) => v + 1);
950
+ };
951
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
952
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
953
+ Button,
954
+ {
955
+ variant: "ghost",
956
+ size: "sm",
957
+ className: "h-7 px-2 text-sm gap-1.5 text-muted-foreground hover:text-foreground font-light!",
958
+ "data-testid": testIdOr(testIds?.trigger, { testId: "facts-fields-trigger" }),
959
+ children: [
960
+ /* @__PURE__ */ jsx(Columns3, { className: "size-3.5" }),
961
+ l.fields,
962
+ /* @__PURE__ */ jsx(ChevronDown, { className: "size-3" })
963
+ ]
964
+ }
965
+ ) }),
966
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-[220px] p-0", align: "end", side: "bottom", sideOffset: 4, children: /* @__PURE__ */ jsx(Command, { shouldFilter: false, children: /* @__PURE__ */ jsxs(CommandList, { className: "max-h-[60dvh]", children: [
967
+ /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(
968
+ CommandItem,
969
+ {
970
+ onSelect: resetToDefault,
971
+ className: "cursor-pointer text-sm text-muted-foreground",
972
+ "data-testid": testIdOr(testIds?.defaultView, {
973
+ testId: "facts-fields-default-view"
974
+ }),
975
+ children: [
976
+ /* @__PURE__ */ jsx(RotateCcw, { className: "mr-2 size-3.5" }),
977
+ l.defaultView
978
+ ]
979
+ }
980
+ ) }),
981
+ /* @__PURE__ */ jsx(CommandSeparator, {}),
982
+ /* @__PURE__ */ jsx(CommandGroup, { heading: l.columns, children: columns.map((col) => /* @__PURE__ */ jsxs(
983
+ CommandItem,
984
+ {
985
+ onSelect: () => toggle(col.colId, col.visible),
986
+ className: "cursor-pointer text-sm",
987
+ "data-testid": testIdOr(testIds?.toggle?.(col.colId), {
988
+ testId: `facts-fields-toggle-${col.colId}`
989
+ }),
990
+ children: [
991
+ /* @__PURE__ */ jsx(
992
+ "div",
993
+ {
994
+ className: cn(
995
+ "mr-2 flex size-3.5 items-center justify-center rounded-sm border border-primary",
996
+ col.visible ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
997
+ ),
998
+ children: /* @__PURE__ */ jsx(Check, { className: "size-3" })
999
+ }
1000
+ ),
1001
+ col.label
1002
+ ]
1003
+ },
1004
+ col.colId
1005
+ )) })
1006
+ ] }) }) })
1007
+ ] });
1008
+ }
1009
+ var DEFAULT_FACT_TIMELINE_LABELS = {
1010
+ ganttEmpty: "Give a fact a date and it appears here."
1011
+ };
1012
+ function FactsCalendar({
1013
+ facts,
1014
+ onSelect,
1015
+ selectedId,
1016
+ navigatorContainer,
1017
+ navigatorTotal,
1018
+ testId
1019
+ }) {
1020
+ const calendarTestId = testIdOr(testId, { testId: "facts-calendar" });
1021
+ const items = useMemo(
1022
+ () => facts.filter((f) => f.date_start).map((f) => ({
1023
+ id: f.external_id,
1024
+ label: f.text,
1025
+ start: f.date_start,
1026
+ end: f.date_end,
1027
+ fact: f
1028
+ })),
1029
+ [facts]
1030
+ );
1031
+ const rootRef = useRef(null);
1032
+ const entryId = testIdOr(testId && `${testId}-entry-${selectedId}`, {
1033
+ testId: `facts-calendar-entry-${selectedId}`
1034
+ });
1035
+ useEffect(() => {
1036
+ const root = rootRef.current;
1037
+ if (!root) return;
1038
+ root.querySelectorAll(".fact-cal-selected").forEach((el) => el.classList.remove("fact-cal-selected"));
1039
+ if (!selectedId) return;
1040
+ root.querySelectorAll(`[data-testid="${entryId}"]`).forEach((el) => el.classList.add("fact-cal-selected"));
1041
+ }, [selectedId, items, entryId]);
1042
+ return /* @__PURE__ */ jsx("div", { ref: rootRef, className: "h-full border-t border-border", "data-slot": "facts-calendar", children: /* @__PURE__ */ jsx(
1043
+ TimelineCalendar,
1044
+ {
1045
+ items,
1046
+ testId: calendarTestId,
1047
+ maxLanes: Infinity,
1048
+ selectedIds: selectedId ? [selectedId] : [],
1049
+ onSelect: (item) => onSelect?.(item.fact),
1050
+ navigatorContainer,
1051
+ navigatorTotal
1052
+ }
1053
+ ) });
1054
+ }
1055
+ function FactsGanttPane({
1056
+ testId,
1057
+ emptyMessage,
1058
+ labels,
1059
+ ...props
1060
+ }) {
1061
+ const l = { ...DEFAULT_FACT_TIMELINE_LABELS, ...labels };
1062
+ return /* @__PURE__ */ jsx("div", { className: "facts-gantt h-full border-t border-border", "data-slot": "facts-gantt", children: /* @__PURE__ */ jsx(
1063
+ TimelineGantt,
1064
+ {
1065
+ testId: testIdOr(testId, { testId: "gantt" }),
1066
+ emptyMessage: emptyMessage ?? l.ganttEmpty,
1067
+ ...props
1068
+ }
1069
+ ) });
1070
+ }
1071
+ var DEFAULT_FACTS_VIEW_TOGGLE_LABELS = {
1072
+ table: "Table",
1073
+ calendar: "Calendar",
1074
+ timeline: "Timeline",
1075
+ smartSearch: "Smart Search"
1076
+ };
1077
+ var createOptions = (l) => [
1078
+ { value: "table", icon: /* @__PURE__ */ jsx(Table2, { className: "size-3.5" }), label: l.table },
1079
+ { value: "calendar", icon: /* @__PURE__ */ jsx(CalendarRange, { className: "size-3.5" }), label: l.calendar },
1080
+ { value: "gantt", icon: /* @__PURE__ */ jsx(GanttChartSquare, { className: "size-3.5" }), label: l.timeline },
1081
+ // Facts-only semantic/keyword recall — mirrors the Files "Smart Search" view
1082
+ // (same Search icon + label), but searches this workspace's facts, not docs.
1083
+ { value: "smart_search", icon: /* @__PURE__ */ jsx(Search, { className: "size-3.5" }), label: l.smartSearch }
1084
+ ];
1085
+ function FactsViewToggle({
1086
+ viewMode,
1087
+ onChange,
1088
+ collapsed = false,
1089
+ labels,
1090
+ testIdPrefix,
1091
+ testIds
1092
+ }) {
1093
+ const options = createOptions({ ...DEFAULT_FACTS_VIEW_TOGGLE_LABELS, ...labels }).map((o) => ({
1094
+ ...o,
1095
+ testId: testIds?.[o.value]
1096
+ }));
1097
+ return /* @__PURE__ */ jsx(
1098
+ ViewToggle,
1099
+ {
1100
+ options,
1101
+ value: viewMode,
1102
+ onChange: (value) => onChange(value),
1103
+ testIdPrefix: testIdOr(testIdPrefix, { testId: "facts-layout" }),
1104
+ showLabels: !collapsed,
1105
+ size: "sm"
1106
+ }
1107
+ );
1108
+ }
1109
+ var DEFAULT_FACTS_TOOLBAR_LABELS = {
1110
+ tags: "Tags",
1111
+ newFact: "New fact"
1112
+ };
1113
+ function FactsToolbar({
1114
+ count,
1115
+ hasActiveFilters,
1116
+ filterText,
1117
+ onFilterTextChange,
1118
+ searchFields,
1119
+ onSearchFieldsChange,
1120
+ quickFilter,
1121
+ onOpenTags,
1122
+ viewMode,
1123
+ onViewModeChange,
1124
+ onNewFact,
1125
+ navSlotRef,
1126
+ navigator,
1127
+ tools,
1128
+ showToolbarRow = true,
1129
+ labels,
1130
+ testIds,
1131
+ filterLabels,
1132
+ filterTestIds,
1133
+ viewToggleLabels,
1134
+ viewToggleTestIdPrefix
1135
+ }) {
1136
+ const l = { ...DEFAULT_FACTS_TOOLBAR_LABELS, ...labels };
1137
+ const headerRef = useRef(null);
1138
+ const [viewsCollapsed, setViewsCollapsed] = useState(false);
1139
+ const [isNarrow, setIsNarrow] = useState(false);
1140
+ useEffect(() => {
1141
+ const el = headerRef.current;
1142
+ if (!el) return;
1143
+ const measure = () => {
1144
+ const w = el.clientWidth;
1145
+ setViewsCollapsed((prev) => prev ? w < 990 : w < 950);
1146
+ const narrowAt = window.matchMedia?.("(pointer: coarse)")?.matches ? 820 : 640;
1147
+ setIsNarrow((prev) => prev ? w < narrowAt + 20 : w < narrowAt);
1148
+ };
1149
+ measure();
1150
+ return observeResize(el, measure);
1151
+ }, []);
1152
+ const tabs = [
1153
+ {
1154
+ id: "facts",
1155
+ // No name: the page needs no self-label, but the fact glyph stays in front of the count.
1156
+ countIcon: /* @__PURE__ */ jsx(Milestone, { className: "size-3.5" }),
1157
+ label: "",
1158
+ count,
1159
+ countPlacement: "leading",
1160
+ hasActiveFilters,
1161
+ testId: testIdOr(testIds?.tab, { testId: "facts-tab" }),
1162
+ presentation: "count"
1163
+ }
1164
+ ];
1165
+ const filterControls = /* @__PURE__ */ jsxs("div", { className: isNarrow ? "flex w-full items-center gap-1.5" : "flex items-center gap-1.5", children: [
1166
+ /* @__PURE__ */ jsx(
1167
+ FilterInput,
1168
+ {
1169
+ value: filterText,
1170
+ onChange: onFilterTextChange,
1171
+ fields: searchFields,
1172
+ onFieldsChange: onSearchFieldsChange,
1173
+ filter: quickFilter,
1174
+ className: isNarrow ? "min-w-0 flex-1" : void 0,
1175
+ labels: filterLabels,
1176
+ testIds: filterTestIds
1177
+ }
1178
+ ),
1179
+ onOpenTags && /* @__PURE__ */ jsxs(
1180
+ Button,
1181
+ {
1182
+ variant: "outline",
1183
+ size: "sm",
1184
+ className: "h-6 shrink-0 gap-1.5 px-2 pointer-coarse:h-11",
1185
+ onClick: onOpenTags,
1186
+ "data-testid": testIdOr(testIds?.tagsButton, { testId: "facts-tags-button" }),
1187
+ children: [
1188
+ /* @__PURE__ */ jsx(BookMarked, { className: "size-3.5" }),
1189
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: l.tags })
1190
+ ]
1191
+ }
1192
+ )
1193
+ ] });
1194
+ return /* @__PURE__ */ jsxs("div", { ref: headerRef, className: "sticky top-0 z-10 bg-background", "data-slot": "facts-toolbar", children: [
1195
+ /* @__PURE__ */ jsx(
1196
+ TabHeader,
1197
+ {
1198
+ tabs,
1199
+ activeTabId: "notes",
1200
+ onTabChange: () => {
1201
+ },
1202
+ firstTabContent: isNarrow ? null : filterControls,
1203
+ centerContent: isNarrow ? null : /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-center", children: /* @__PURE__ */ jsx(
1204
+ FactsViewToggle,
1205
+ {
1206
+ viewMode,
1207
+ onChange: onViewModeChange,
1208
+ collapsed: viewsCollapsed,
1209
+ labels: viewToggleLabels,
1210
+ testIdPrefix: viewToggleTestIdPrefix
1211
+ }
1212
+ ) }),
1213
+ rightContent: /* @__PURE__ */ jsxs(
1214
+ Button,
1215
+ {
1216
+ onClick: onNewFact,
1217
+ "data-testid": testIdOr(testIds?.newFact, { testId: "facts-page-new" }),
1218
+ children: [
1219
+ /* @__PURE__ */ jsx(Plus, { className: "mr-0.5 size-4" }),
1220
+ l.newFact
1221
+ ]
1222
+ }
1223
+ )
1224
+ }
1225
+ ),
1226
+ isNarrow && /* @__PURE__ */ jsxs(
1227
+ "div",
1228
+ {
1229
+ className: "flex flex-col gap-1.5 border-b border-border px-3 py-1.5",
1230
+ "data-slot": "facts-toolbar-stack",
1231
+ children: [
1232
+ filterControls,
1233
+ /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
1234
+ FactsViewToggle,
1235
+ {
1236
+ viewMode,
1237
+ onChange: onViewModeChange,
1238
+ collapsed: true,
1239
+ labels: viewToggleLabels,
1240
+ testIdPrefix: viewToggleTestIdPrefix
1241
+ }
1242
+ ) })
1243
+ ]
1244
+ }
1245
+ ),
1246
+ showToolbarRow && /* @__PURE__ */ jsxs(
1247
+ "div",
1248
+ {
1249
+ className: "flex min-h-8 flex-wrap items-center gap-x-1.5 border-b border-border bg-background px-3 py-0.5",
1250
+ "data-testid": testIdOr(testIds?.filterBar, { testId: "facts-filter-bar" }),
1251
+ children: [
1252
+ /* @__PURE__ */ jsx(
1253
+ "div",
1254
+ {
1255
+ ref: navSlotRef,
1256
+ className: "flex shrink-0 items-center empty:hidden",
1257
+ "data-testid": testIdOr(testIds?.filterBarNav, { testId: "facts-filter-bar-nav" }),
1258
+ children: navigator
1259
+ }
1260
+ ),
1261
+ /* @__PURE__ */ jsx("div", { className: "flex-1" }),
1262
+ /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center", children: tools })
1263
+ ]
1264
+ }
1265
+ )
1266
+ ] });
1267
+ }
1268
+
1269
+ // src/facts/fact-table-column-resize.ts
1270
+ var EDGE = 6;
1271
+ var MIN_WIDTH = 48;
1272
+ function enableFactTableColumnResize(container) {
1273
+ let drag = null;
1274
+ const cellFromEvent = (e) => {
1275
+ const el = e.target;
1276
+ const cell = el?.closest?.("td, th");
1277
+ if (!cell || cell.hasAttribute("data-tool-cell")) return null;
1278
+ if (!container.contains(cell)) return null;
1279
+ return cell;
1280
+ };
1281
+ const nearRightEdge = (cell, clientX) => {
1282
+ const rect = cell.getBoundingClientRect();
1283
+ return clientX >= rect.right - EDGE && clientX <= rect.right + 2;
1284
+ };
1285
+ const colForCell = (cell) => {
1286
+ const row = cell.parentElement;
1287
+ const table = cell.closest("table");
1288
+ const colgroup = table?.querySelector("colgroup");
1289
+ if (!row || !table || !colgroup) return null;
1290
+ const index = Array.prototype.indexOf.call(row.children, cell);
1291
+ return colgroup.children[index] ?? null;
1292
+ };
1293
+ const freezeWidths = (table) => {
1294
+ const colgroup = table.querySelector("colgroup");
1295
+ if (!colgroup) return;
1296
+ const ruler = table.querySelector("thead tr") ?? table.querySelector("tbody tr");
1297
+ const cells = ruler ? Array.from(ruler.children) : [];
1298
+ Array.from(colgroup.children).forEach((node, i) => {
1299
+ const col = node;
1300
+ const cell = cells[i];
1301
+ if (!col.style.width && cell) col.style.width = `${cell.getBoundingClientRect().width}px`;
1302
+ });
1303
+ table.style.tableLayout = "fixed";
1304
+ };
1305
+ const onPointerMove = (e) => {
1306
+ if (drag) {
1307
+ const next = Math.max(MIN_WIDTH, drag.startWidth + (e.clientX - drag.startX));
1308
+ drag.col.style.width = `${next}px`;
1309
+ e.preventDefault();
1310
+ return;
1311
+ }
1312
+ const cell = cellFromEvent(e);
1313
+ if (cell && nearRightEdge(cell, e.clientX)) {
1314
+ cell.style.cursor = "col-resize";
1315
+ } else if (cell) {
1316
+ cell.style.cursor = "";
1317
+ }
1318
+ };
1319
+ const endDrag = () => {
1320
+ if (!drag) return;
1321
+ drag = null;
1322
+ document.documentElement.classList.remove("fact-col-resizing");
1323
+ document.removeEventListener("pointermove", onPointerMove, true);
1324
+ document.removeEventListener("pointerup", endDrag, true);
1325
+ };
1326
+ const onPointerDown = (e) => {
1327
+ if (e.button !== 0) return;
1328
+ const cell = cellFromEvent(e);
1329
+ if (!cell || !nearRightEdge(cell, e.clientX)) return;
1330
+ const table = cell.closest("table");
1331
+ if (!table) return;
1332
+ freezeWidths(table);
1333
+ const col = colForCell(cell);
1334
+ if (!col) return;
1335
+ drag = {
1336
+ col,
1337
+ table,
1338
+ startX: e.clientX,
1339
+ startWidth: parseFloat(col.style.width) || cell.getBoundingClientRect().width
1340
+ };
1341
+ e.preventDefault();
1342
+ document.documentElement.classList.add("fact-col-resizing");
1343
+ document.addEventListener("pointermove", onPointerMove, true);
1344
+ document.addEventListener("pointerup", endDrag, true);
1345
+ };
1346
+ container.addEventListener("pointerdown", onPointerDown);
1347
+ container.addEventListener("pointermove", onPointerMove);
1348
+ return () => {
1349
+ endDrag();
1350
+ container.removeEventListener("pointerdown", onPointerDown);
1351
+ container.removeEventListener("pointermove", onPointerMove);
1352
+ };
1353
+ }
1354
+ var DEFAULT_FACT_LABELS_CELL_LABELS = {
1355
+ edit: "Edit labels",
1356
+ searchPlaceholder: "Search or create...",
1357
+ create: (name) => `Create \u201C${name}\u201D`,
1358
+ empty: "No labels yet"
1359
+ };
1360
+ var CHIP_ROW_H = 24;
1361
+ var CHIP_GAP = 4;
1362
+ var FactLabelsCell = memo(function FactLabelsCell2({
1363
+ options,
1364
+ selectedIds,
1365
+ onChange,
1366
+ onCreate,
1367
+ rowHeight = 52,
1368
+ labels,
1369
+ testIds
1370
+ }) {
1371
+ const l = { ...DEFAULT_FACT_LABELS_CELL_LABELS, ...labels };
1372
+ const [open, setOpen] = useState(false);
1373
+ const [search, setSearch] = useState("");
1374
+ const applied = useMemo(
1375
+ () => new Set(selectedIds.filter((id) => options.some((o) => o.id === id))),
1376
+ [selectedIds, options]
1377
+ );
1378
+ const toggle = (option) => onChange(
1379
+ applied.has(option.id) ? selectedIds.filter((id) => id !== option.id) : [...selectedIds, option.id]
1380
+ );
1381
+ const createAndApply = async (name) => {
1382
+ const trimmed = name.trim();
1383
+ if (!trimmed) return;
1384
+ const existing = options.find((o) => o.name.toLowerCase() === trimmed.toLowerCase());
1385
+ if (existing) {
1386
+ if (!applied.has(existing.id)) onChange([...selectedIds, existing.id]);
1387
+ setSearch("");
1388
+ return;
1389
+ }
1390
+ const id = await onCreate(trimmed);
1391
+ if (id) onChange([...selectedIds, id]);
1392
+ setSearch("");
1393
+ };
1394
+ const clampRows = Math.max(1, Math.floor((rowHeight + CHIP_GAP) / (CHIP_ROW_H + CHIP_GAP)));
1395
+ const appliedOptions = options.filter((o) => applied.has(o.id));
1396
+ const chipsRef = useRef(null);
1397
+ const [hasOverflow, setHasOverflow] = useState(false);
1398
+ useEffect(() => {
1399
+ const el = chipsRef.current;
1400
+ if (!el) return;
1401
+ const measure = () => setHasOverflow(el.scrollHeight > el.clientHeight + 1);
1402
+ measure();
1403
+ return observeResize(el, measure);
1404
+ }, [applied, clampRows, rowHeight, options]);
1405
+ const searchMatchesExisting = options.some(
1406
+ (o) => o.name.toLowerCase() === search.trim().toLowerCase()
1407
+ );
1408
+ return /* @__PURE__ */ jsxs(
1409
+ Popover,
1410
+ {
1411
+ open,
1412
+ onOpenChange: (next) => {
1413
+ setOpen(next);
1414
+ if (!next) setSearch("");
1415
+ },
1416
+ children: [
1417
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
1418
+ "button",
1419
+ {
1420
+ type: "button",
1421
+ "aria-label": l.edit,
1422
+ "data-slot": "fact-labels-cell",
1423
+ className: "group relative flex h-full w-full min-w-0 cursor-pointer items-center gap-1 pr-4 text-left hover:bg-muted",
1424
+ children: appliedOptions.length === 0 ? /* @__PURE__ */ jsx("span", { className: "flex-1 text-muted-foreground opacity-50", children: /* @__PURE__ */ jsx(PencilLine, { className: "size-3.5" }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1425
+ /* @__PURE__ */ jsx(
1426
+ "div",
1427
+ {
1428
+ ref: chipsRef,
1429
+ className: "flex min-w-0 flex-1 flex-wrap content-start gap-1 overflow-hidden",
1430
+ style: { maxHeight: CHIP_ROW_H * clampRows + CHIP_GAP * (clampRows - 1) },
1431
+ children: appliedOptions.map((o) => /* @__PURE__ */ jsxs(
1432
+ "span",
1433
+ {
1434
+ className: "inline-flex shrink-0 items-center gap-1 rounded border px-1.5 py-0.5 text-xs font-medium",
1435
+ title: o.name,
1436
+ style: { borderColor: o.color },
1437
+ children: [
1438
+ /* @__PURE__ */ jsx(
1439
+ "span",
1440
+ {
1441
+ className: "flex size-3.5 shrink-0 items-center justify-center rounded",
1442
+ style: { backgroundColor: o.color },
1443
+ children: /* @__PURE__ */ jsx(Check, { className: "size-2.5 text-white", strokeWidth: 3 })
1444
+ }
1445
+ ),
1446
+ /* @__PURE__ */ jsx("span", { className: "max-w-[80px] truncate", children: o.name })
1447
+ ]
1448
+ },
1449
+ o.id
1450
+ ))
1451
+ }
1452
+ ),
1453
+ hasOverflow && /* @__PURE__ */ jsx(
1454
+ "span",
1455
+ {
1456
+ className: "pointer-events-none absolute bottom-0.5 right-0.5 text-xs font-semibold leading-none text-muted-foreground",
1457
+ "aria-hidden": true,
1458
+ children: "\u2026"
1459
+ }
1460
+ )
1461
+ ] })
1462
+ }
1463
+ ) }),
1464
+ open && /* @__PURE__ */ jsx(PopoverContent, { className: "w-[360px] p-0", align: "start", side: "bottom", sideOffset: 4, children: /* @__PURE__ */ jsxs(Command, { shouldFilter: true, children: [
1465
+ /* @__PURE__ */ jsx(
1466
+ CommandInput,
1467
+ {
1468
+ placeholder: l.searchPlaceholder,
1469
+ value: search,
1470
+ onValueChange: setSearch,
1471
+ onKeyDown: (e) => {
1472
+ if (e.key === "Enter" && search.trim() && !searchMatchesExisting) {
1473
+ e.preventDefault();
1474
+ void createAndApply(search);
1475
+ }
1476
+ }
1477
+ }
1478
+ ),
1479
+ /* @__PURE__ */ jsxs(CommandList, { children: [
1480
+ /* @__PURE__ */ jsx(CommandEmpty, { children: search.trim() ? /* @__PURE__ */ jsx(
1481
+ "button",
1482
+ {
1483
+ type: "button",
1484
+ onClick: () => void createAndApply(search),
1485
+ onPointerDown: (e) => e.preventDefault(),
1486
+ className: "w-full cursor-pointer rounded px-2 py-1.5 text-left text-sm text-primary hover:bg-accent pointer-coarse:min-h-11",
1487
+ children: l.create(search.trim())
1488
+ }
1489
+ ) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: l.empty }) }),
1490
+ /* @__PURE__ */ jsx(CommandGroup, { children: options.map((o) => {
1491
+ const isApplied = applied.has(o.id);
1492
+ return /* @__PURE__ */ jsxs(
1493
+ CommandItem,
1494
+ {
1495
+ value: o.name,
1496
+ onSelect: () => toggle(o),
1497
+ onPointerDown: (e) => e.preventDefault(),
1498
+ className: "cursor-pointer pointer-coarse:min-h-11",
1499
+ "data-testid": testIdOr(testIds?.option?.(o.id), {
1500
+ testId: `fact-label-select-${o.id}`
1501
+ }),
1502
+ children: [
1503
+ /* @__PURE__ */ jsx(
1504
+ "span",
1505
+ {
1506
+ className: "mr-2 flex size-4 shrink-0 items-center justify-center rounded border-2",
1507
+ style: isApplied ? { borderColor: o.color, backgroundColor: o.color } : { borderColor: o.color },
1508
+ children: isApplied && /* @__PURE__ */ jsx(Check, { className: "size-3 text-white", strokeWidth: 3 })
1509
+ }
1510
+ ),
1511
+ /* @__PURE__ */ jsx("span", { className: "flex-1 text-sm", children: o.name })
1512
+ ]
1513
+ },
1514
+ o.id
1515
+ );
1516
+ }) })
1517
+ ] })
1518
+ ] }) })
1519
+ ]
1520
+ }
1521
+ );
1522
+ });
1523
+ var DEFAULT_FACT_COLUMN_LABELS = {
1524
+ inChatHeaderTooltip: "Facts added to this chat are always in context for this chat",
1525
+ inChatTitle: "In this chat \u2014 always in context for it. Click to remove from chat.",
1526
+ notInChatTitle: "Add to chat \u2014 always in context for this chat",
1527
+ removeFromChat: "Remove from chat",
1528
+ addToChat: "Add to chat",
1529
+ fact: "Fact",
1530
+ dates: "Dates",
1531
+ dateTitle: "Date of the fact itself, not when this was saved",
1532
+ labels: "Labels",
1533
+ verified: "Verified",
1534
+ verifiedTooltip: "Verified by a human",
1535
+ shared: "Shared",
1536
+ sharedTooltip: "Shared with the workspace, or private to you & your agents",
1537
+ createdBy: "Created by",
1538
+ sources: "Sources",
1539
+ sourcedFrom: (n) => `Sourced from ${n} document${n === 1 ? "" : "s"} \u2014 open the fact to see them`,
1540
+ createdAt: "Created at",
1541
+ updated: "Updated",
1542
+ id: "ID"
1543
+ };
1544
+ var ISO_DATE_FILTER_PARAMS = {
1545
+ browserDatePicker: true,
1546
+ comparator: (filterDate, cellValue) => {
1547
+ if (!cellValue || typeof cellValue !== "string") return -1;
1548
+ const cell = new Date(cellValue);
1549
+ if (Number.isNaN(cell.getTime())) return -1;
1550
+ const cellDay = Date.UTC(cell.getUTCFullYear(), cell.getUTCMonth(), cell.getUTCDate());
1551
+ const filterDay = Date.UTC(
1552
+ filterDate.getFullYear(),
1553
+ filterDate.getMonth(),
1554
+ filterDate.getDate()
1555
+ );
1556
+ return cellDay < filterDay ? -1 : cellDay > filterDay ? 1 : 0;
1557
+ }
1558
+ };
1559
+ function sourceDocCount(fact) {
1560
+ return fact?.citations?.length ?? 0;
1561
+ }
1562
+ var DEFAULT_FACT_COLUMN_ORDER = [
1563
+ "in_chat",
1564
+ "text",
1565
+ "sources",
1566
+ "tags",
1567
+ "date",
1568
+ "confirmed",
1569
+ "shared",
1570
+ "created_by",
1571
+ "created_at",
1572
+ "updated_at",
1573
+ "note_id"
1574
+ ];
1575
+ function createFactColumns(slots) {
1576
+ const fieldOf = (name) => name;
1577
+ const l = { ...DEFAULT_FACT_COLUMN_LABELS, ...slots.labels };
1578
+ const ids = slots.testIds;
1579
+ const { isInChat, onToggleInChat } = slots;
1580
+ const inChatColumn = isInChat && onToggleInChat ? [
1581
+ {
1582
+ colId: "in_chat",
1583
+ headerName: "",
1584
+ headerComponent: () => /* @__PURE__ */ jsx("span", { className: "flex size-full items-center justify-center", children: /* @__PURE__ */ jsx(Paperclip, { className: "size-3.5 text-muted-foreground" }) }),
1585
+ valueGetter: (params) => params.data ? isInChat(params.data) : false,
1586
+ width: 44,
1587
+ minWidth: 44,
1588
+ maxWidth: 44,
1589
+ sortable: true,
1590
+ resizable: false,
1591
+ headerTooltip: l.inChatHeaderTooltip,
1592
+ cellClass: "cell-hcenter",
1593
+ // A toggle, not a readout: a fact in the chat rides every message of it, so it flips
1594
+ // in place.
1595
+ cellRenderer: (params) => {
1596
+ if (!params.data) return null;
1597
+ const fact = params.data;
1598
+ const inChat = isInChat(fact);
1599
+ return /* @__PURE__ */ jsx(
1600
+ "button",
1601
+ {
1602
+ type: "button",
1603
+ onClick: () => onToggleInChat(fact),
1604
+ title: inChat ? l.inChatTitle : l.notInChatTitle,
1605
+ "aria-label": inChat ? l.removeFromChat : l.addToChat,
1606
+ "aria-pressed": inChat,
1607
+ "data-testid": testIdOr(ids?.inChat?.(fact.external_id), {
1608
+ testId: `facts-grid-in-chat-${fact.external_id}`
1609
+ }),
1610
+ className: "flex h-full items-center",
1611
+ children: /* @__PURE__ */ jsx(
1612
+ Paperclip,
1613
+ {
1614
+ className: cn(
1615
+ "size-3.5",
1616
+ inChat ? "text-primary" : "text-muted-foreground/30 transition-colors hover:text-muted-foreground"
1617
+ )
1618
+ }
1619
+ )
1620
+ }
1621
+ );
1622
+ }
1623
+ }
1624
+ ] : [];
1625
+ const columns = [
1626
+ ...inChatColumn,
1627
+ {
1628
+ colId: "text",
1629
+ suppressHeaderFilterButton: true,
1630
+ headerComponent: (p) => slots.renderHeader(p, "text"),
1631
+ headerName: l.fact,
1632
+ field: fieldOf("text"),
1633
+ flex: 3,
1634
+ minWidth: 280,
1635
+ sortable: true,
1636
+ filter: "agTextColumnFilter",
1637
+ // Decode the editor's whitespace entities (`&#x20;` for a trailing space) so the tooltip
1638
+ // reads as typed, not as raw markdown references.
1639
+ tooltipValueGetter: (p) => decodeWhitespaceEntities(p.data?.text),
1640
+ // Editable only via the grid api (Rename in the row's menu); clicks never open the editor
1641
+ // (suppressClickEdit on the grid).
1642
+ editable: true,
1643
+ cellEditor: "agLargeTextCellEditor",
1644
+ cellEditorPopup: true,
1645
+ cellEditorParams: { rows: 8, cols: 60 },
1646
+ valueSetter: (params) => {
1647
+ if (!params.data) return false;
1648
+ params.data.text = params.newValue;
1649
+ return true;
1650
+ },
1651
+ // NOT `cell-multiline`: this cell has its OWN clamp (the `.fact-clamp` span below, sized
1652
+ // from the row height). A second clamp cut the text in half at the minimum row height.
1653
+ cellClass: "relative",
1654
+ cellRenderer: (params) => {
1655
+ if (!params.data) return null;
1656
+ const fact = params.data;
1657
+ const rowH = params.node.rowHeight ?? 52;
1658
+ const clampLines = Math.max(1, Math.floor(rowH / 20));
1659
+ return /* @__PURE__ */ jsxs("div", { className: "relative flex size-full items-start pr-6", children: [
1660
+ /* @__PURE__ */ jsx(
1661
+ "span",
1662
+ {
1663
+ className: "fact-clamp whitespace-normal break-words text-sm leading-snug text-foreground",
1664
+ style: { ["--fact-clamp-lines"]: clampLines },
1665
+ "data-testid": testIdOr(ids?.text?.(fact.external_id), {
1666
+ testId: `facts-grid-text-${fact.external_id}`
1667
+ }),
1668
+ children: decodeWhitespaceEntities(fact.text)
1669
+ }
1670
+ ),
1671
+ /* @__PURE__ */ jsx("div", { className: "facts-row-kebab absolute right-0.5 top-1/2 -translate-y-1/2", children: slots.renderRowActions(fact, params) })
1672
+ ] });
1673
+ }
1674
+ },
1675
+ {
1676
+ colId: "date",
1677
+ // AG Grid's DEFAULT header, so the sort arrow and filter button are the native ones,
1678
+ // identical to the Files table's Date columns.
1679
+ headerName: l.dates,
1680
+ // Sort on the raw bound rather than the rendered string ("Oct 2019" sorts April first).
1681
+ field: fieldOf("date_start"),
1682
+ flex: 0.8,
1683
+ minWidth: 132,
1684
+ sortable: true,
1685
+ filter: "agDateColumnFilter",
1686
+ filterParams: ISO_DATE_FILTER_PARAMS,
1687
+ // The edit value is the date-only slice: a lexical sort matches a chronological one, and
1688
+ // the inline editor shows "2024-03-12" rather than a full ISO timestamp. Inline typing
1689
+ // accepts YYYY, YYYY-MM or YYYY-MM-DD; clearing the cell undates the fact.
1690
+ editable: true,
1691
+ singleClickEdit: true,
1692
+ valueGetter: (params) => params.data?.date_start ? params.data.date_start.slice(0, 10) : null,
1693
+ valueSetter: (params) => {
1694
+ if (!params.data) return false;
1695
+ params.data.date_start = params.newValue;
1696
+ return true;
1697
+ },
1698
+ cellClass: "relative cell-tnum",
1699
+ cellRenderer: (params) => {
1700
+ const when = formatSpan(
1701
+ params.data?.date_start,
1702
+ params.data?.date_end,
1703
+ params.data?.timezone
1704
+ );
1705
+ if (!when) return /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/50", children: "\u2014" });
1706
+ return /* @__PURE__ */ jsxs(
1707
+ "span",
1708
+ {
1709
+ className: "inline-flex items-center gap-1",
1710
+ "data-testid": testIdOr(ids?.date?.(params.data?.external_id ?? ""), {
1711
+ testId: `facts-grid-date-${params.data?.external_id}`
1712
+ }),
1713
+ title: l.dateTitle,
1714
+ children: [
1715
+ /* @__PURE__ */ jsx(CalendarDays, { className: "size-3 opacity-70" }),
1716
+ when
1717
+ ]
1718
+ }
1719
+ );
1720
+ }
1721
+ },
1722
+ {
1723
+ colId: "tags",
1724
+ suppressHeaderFilterButton: true,
1725
+ headerComponent: (p) => slots.renderHeader(p, "tags"),
1726
+ headerName: l.labels,
1727
+ flex: 0.9,
1728
+ // Never narrower than its own header, even with the filter button and sort indicator.
1729
+ minWidth: 160,
1730
+ sortable: true,
1731
+ filter: "agTextColumnFilter",
1732
+ cellClass: "overflow-visible",
1733
+ valueGetter: (params) => (params.data?.tags ?? []).map((t) => t.name).join(", "),
1734
+ // Editable in place: toggling a label persists immediately, no dialog round-trip.
1735
+ cellRenderer: (params) => params.data ? slots.renderLabels(params.data, params) : null
1736
+ },
1737
+ {
1738
+ colId: "confirmed",
1739
+ headerName: l.verified,
1740
+ headerTooltip: l.verifiedTooltip,
1741
+ field: fieldOf("confirmed"),
1742
+ // minWidth matches width so the header can't be clamped narrow enough to ellipsize.
1743
+ width: 116,
1744
+ minWidth: 116,
1745
+ sortable: true,
1746
+ cellDataType: "boolean",
1747
+ valueGetter: (params) => params.data?.confirmed ?? false,
1748
+ cellClass: "cell-hcenter",
1749
+ headerClass: "header-hcenter",
1750
+ cellRenderer: (params) => params.data ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: slots.renderVerified(params.data) }) : null
1751
+ },
1752
+ {
1753
+ colId: "shared",
1754
+ headerName: l.shared,
1755
+ headerTooltip: l.sharedTooltip,
1756
+ field: fieldOf("shared"),
1757
+ // minWidth (not just width) is raised too: AG Grid clamps any persisted width up to it.
1758
+ width: 110,
1759
+ minWidth: 110,
1760
+ sortable: true,
1761
+ headerClass: "header-hcenter",
1762
+ cellDataType: "boolean",
1763
+ valueGetter: (params) => params.data?.shared ?? false,
1764
+ cellRenderer: (params) => params.data ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: slots.renderShared(params.data, params) }) : null
1765
+ },
1766
+ {
1767
+ colId: "created_by",
1768
+ headerName: l.createdBy,
1769
+ headerTooltip: l.createdBy,
1770
+ width: 138,
1771
+ minWidth: 138,
1772
+ sortable: true,
1773
+ valueGetter: (params) => slots.getCreatorName(params),
1774
+ cellRenderer: (params) => params.data ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: slots.renderCreator(params.data, params) }) : null
1775
+ },
1776
+ {
1777
+ colId: "sources",
1778
+ headerName: l.sources,
1779
+ width: 112,
1780
+ minWidth: 104,
1781
+ sortable: true,
1782
+ // A hand-written fact has no sources, which is information rather than a gap: it reads as
1783
+ // an em dash instead of a zero.
1784
+ valueGetter: (params) => sourceDocCount(params.data),
1785
+ cellRenderer: (params) => {
1786
+ const n = sourceDocCount(params.data);
1787
+ if (n === 0) return /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", children: "\u2014" });
1788
+ return /* @__PURE__ */ jsxs(
1789
+ "span",
1790
+ {
1791
+ className: "inline-flex items-center gap-1 text-xs text-muted-foreground",
1792
+ title: l.sourcedFrom(n),
1793
+ children: [
1794
+ /* @__PURE__ */ jsx(Quote, { className: "size-3 opacity-70" }),
1795
+ n
1796
+ ]
1797
+ }
1798
+ );
1799
+ }
1800
+ },
1801
+ {
1802
+ colId: "created_at",
1803
+ suppressHeaderFilterButton: true,
1804
+ headerComponent: (p) => slots.renderHeader(p, "created_at"),
1805
+ headerName: l.createdAt,
1806
+ field: fieldOf("created_at"),
1807
+ width: 162,
1808
+ minWidth: 154,
1809
+ sortable: true,
1810
+ filter: "agDateColumnFilter",
1811
+ filterParams: ISO_DATE_FILTER_PARAMS,
1812
+ // Display-only: a valueFormatter avoids mounting a React component per row.
1813
+ cellClass: "text-muted-foreground",
1814
+ valueFormatter: (params) => params.value ? slots.formatDate(params.value) : ""
1815
+ },
1816
+ {
1817
+ colId: "updated_at",
1818
+ suppressHeaderFilterButton: true,
1819
+ headerComponent: (p) => slots.renderHeader(p, "updated_at"),
1820
+ headerName: l.updated,
1821
+ field: fieldOf("updated_at"),
1822
+ width: 140,
1823
+ minWidth: 140,
1824
+ // Hidden by default: a column-menu opt-in like the documents grid's long tail.
1825
+ hide: true,
1826
+ sortable: true,
1827
+ filter: "agDateColumnFilter",
1828
+ filterParams: ISO_DATE_FILTER_PARAMS,
1829
+ valueFormatter: (params) => params.value ? slots.formatDate(params.value) : ""
1830
+ },
1831
+ {
1832
+ colId: "note_id",
1833
+ headerName: l.id,
1834
+ field: fieldOf("external_id"),
1835
+ width: 120,
1836
+ minWidth: 100,
1837
+ sortable: true,
1838
+ filter: "agTextColumnFilter",
1839
+ // Hidden by default like the documents ID column: needed when quoting a fact to support.
1840
+ hide: true,
1841
+ cellClass: "font-mono text-xs text-muted-foreground"
1842
+ }
1843
+ ];
1844
+ return DEFAULT_FACT_COLUMN_ORDER.map((id) => columns.find((c) => c.colId === id)).filter(
1845
+ (c) => c !== void 0
1846
+ );
1847
+ }
1848
+ var DEFAULT_FACT_ROW_ACTIONS_LABELS = {
1849
+ actions: "Fact actions",
1850
+ edit: "Edit",
1851
+ editRestricted: "Only the creator or a workspace owner can reword this fact",
1852
+ delete: "Delete"
1853
+ };
1854
+ function FactRowActions({
1855
+ onEdit,
1856
+ canEdit = true,
1857
+ onDelete,
1858
+ labels,
1859
+ testIds
1860
+ }) {
1861
+ const l = { ...DEFAULT_FACT_ROW_ACTIONS_LABELS, ...labels };
1862
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
1863
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
1864
+ "button",
1865
+ {
1866
+ type: "button",
1867
+ onClick: (e) => e.stopPropagation(),
1868
+ className: "flex size-6 pointer-coarse:size-11 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground data-[state=open]:bg-muted data-[state=open]:text-foreground",
1869
+ "data-testid": testIdOr(testIds?.trigger, { testId: "fact-row-actions" }),
1870
+ "aria-label": l.actions,
1871
+ children: /* @__PURE__ */ jsx(MoreVertical, { className: "size-4" })
1872
+ }
1873
+ ) }),
1874
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", onClick: (e) => e.stopPropagation(), children: [
1875
+ /* @__PURE__ */ jsxs(
1876
+ DropdownMenuItem,
1877
+ {
1878
+ onSelect: onEdit,
1879
+ disabled: !canEdit,
1880
+ title: canEdit ? void 0 : l.editRestricted,
1881
+ "data-testid": testIdOr(testIds?.edit, { testId: "fact-action-edit" }),
1882
+ children: [
1883
+ /* @__PURE__ */ jsx(Pencil, { className: "mr-2 size-4" }),
1884
+ l.edit
1885
+ ]
1886
+ }
1887
+ ),
1888
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
1889
+ /* @__PURE__ */ jsxs(
1890
+ DropdownMenuItem,
1891
+ {
1892
+ onSelect: onDelete,
1893
+ className: "text-red-text focus:text-red-text",
1894
+ "data-testid": testIdOr(testIds?.delete, { testId: "fact-action-delete" }),
1895
+ children: [
1896
+ /* @__PURE__ */ jsx(Trash2, { className: "mr-2 size-4" }),
1897
+ l.delete
1898
+ ]
1899
+ }
1900
+ )
1901
+ ] })
1902
+ ] });
1903
+ }
1904
+
1905
+ export { DEFAULT_FACTS_BULK_BAR_LABELS, DEFAULT_FACTS_EMPTY_STATE_LABELS, DEFAULT_FACTS_FIELDS_BUTTON_LABELS, DEFAULT_FACTS_TOOLBAR_LABELS, DEFAULT_FACTS_VIEW_TOGGLE_LABELS, DEFAULT_FACT_COLUMN_LABELS, DEFAULT_FACT_COLUMN_ORDER, DEFAULT_FACT_COMPOSER_LABELS, DEFAULT_FACT_DATE_INPUT_LABELS, DEFAULT_FACT_LABELS_CELL_LABELS, DEFAULT_FACT_ROW_ACTIONS_LABELS, DEFAULT_FACT_SOURCES_ROW_LABELS, DEFAULT_FACT_SOURCE_GROUP_LABELS, DEFAULT_FACT_TIMELINE_LABELS, EMPTY_FACT_DATE_FIELDS, FactComposer, FactDateInput, FactFieldRow, FactLabelsCell, FactRowActions, FactSourceGroup, FactSourcesRow, FactsBulkBar, FactsCalendar, FactsEmptyState, FactsFieldsButton, FactsGanttPane, FactsLoadError, FactsLoading, FactsToolbar, FactsViewToggle, ISO_DATE_FILTER_PARAMS, buildFactCitations, chunkIdsOf, citedVersionRef, createFactColumns, docIdsOf, enableFactTableColumnResize, factDateFieldsToSpan, factDateSpanToFields, hasChunk, isWholeDoc, sourceDocCount, toFactCitations, withChunk, withDoc, withoutChunk, withoutDoc };
1906
+ //# sourceMappingURL=chunk-WU34CHU5.js.map
1907
+ //# sourceMappingURL=chunk-WU34CHU5.js.map