@e-llm-studio/citation 0.0.251 → 0.0.252

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 (231) hide show
  1. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js.map +1 -1
  3. package/dist/cjs/features/CognitiveCompare/CitationRenderer.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/CitationRenderer.js.map +1 -1
  5. package/dist/cjs/features/CognitiveCompare/CitationRendererInner.js +2 -0
  6. package/dist/cjs/features/CognitiveCompare/CitationRendererInner.js.map +1 -0
  7. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
  9. package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
  11. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  12. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
  13. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
  14. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js.map +1 -1
  15. package/dist/cjs/features/CognitiveCompare/CompareContext.js +1 -1
  16. package/dist/cjs/features/CognitiveCompare/CompareContext.js.map +1 -1
  17. package/dist/cjs/features/CognitiveCompare/GptWebCitationPanel.js +2 -0
  18. package/dist/cjs/features/CognitiveCompare/GptWebCitationPanel.js.map +1 -0
  19. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  20. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
  21. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  22. package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
  23. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js +2 -0
  24. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js.map +1 -0
  25. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
  26. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
  27. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  28. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
  29. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +2 -0
  30. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js.map +1 -0
  31. package/dist/cjs/features/CognitiveCompare/components/GuidelineSkeletonLoader.js +2 -0
  32. package/dist/cjs/features/CognitiveCompare/components/GuidelineSkeletonLoader.js.map +1 -0
  33. package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
  34. package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
  35. package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
  36. package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
  37. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  38. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
  39. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  40. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
  41. package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  42. package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
  43. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  44. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
  45. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  46. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
  47. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  48. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
  49. package/dist/cjs/features/CognitiveCompare/hooks/useOnDemandCitationCache.js +2 -0
  50. package/dist/cjs/features/CognitiveCompare/hooks/useOnDemandCitationCache.js.map +1 -0
  51. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  52. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
  53. package/dist/cjs/features/CognitiveCompare/onDemandCitations/cacheKey.js +2 -0
  54. package/dist/cjs/features/CognitiveCompare/onDemandCitations/cacheKey.js.map +1 -0
  55. package/dist/cjs/features/CognitiveCompare/onDemandCitations/contextBuilder.js +2 -0
  56. package/dist/cjs/features/CognitiveCompare/onDemandCitations/contextBuilder.js.map +1 -0
  57. package/dist/cjs/features/CognitiveCompare/onDemandCitations/href.js +2 -0
  58. package/dist/cjs/features/CognitiveCompare/onDemandCitations/href.js.map +1 -0
  59. package/dist/cjs/features/CognitiveCompare/onDemandCitations/payload.js +2 -0
  60. package/dist/cjs/features/CognitiveCompare/onDemandCitations/payload.js.map +1 -0
  61. package/dist/cjs/features/CognitiveCompare/onDemandCitations/response.js +2 -0
  62. package/dist/cjs/features/CognitiveCompare/onDemandCitations/response.js.map +1 -0
  63. package/dist/cjs/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js +2 -0
  64. package/dist/cjs/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js.map +1 -0
  65. package/dist/cjs/features/CognitiveCompare/utils/normalizeInlineMarkdown.js +2 -0
  66. package/dist/cjs/features/CognitiveCompare/utils/normalizeInlineMarkdown.js.map +1 -0
  67. package/dist/cjs/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js +2 -0
  68. package/dist/cjs/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js.map +1 -0
  69. package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  70. package/dist/cjs/features/SegmentReviewComponents/BoundaryCard.js.map +1 -1
  71. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  72. package/dist/cjs/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js.map +1 -1
  73. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  74. package/dist/features/CognitiveCompare/CitationAnchor.js.map +1 -1
  75. package/dist/features/CognitiveCompare/CitationRenderer.js +1 -1
  76. package/dist/features/CognitiveCompare/CitationRenderer.js.map +1 -1
  77. package/dist/features/CognitiveCompare/CitationRendererInner.js +2 -0
  78. package/dist/features/CognitiveCompare/CitationRendererInner.js.map +1 -0
  79. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  80. package/dist/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
  81. package/dist/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
  82. package/dist/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
  83. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  84. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
  85. package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
  86. package/dist/features/CognitiveCompare/CognitivePopup.js.map +1 -1
  87. package/dist/features/CognitiveCompare/CompareContext.js +1 -1
  88. package/dist/features/CognitiveCompare/CompareContext.js.map +1 -1
  89. package/dist/features/CognitiveCompare/GptWebCitationPanel.js +2 -0
  90. package/dist/features/CognitiveCompare/GptWebCitationPanel.js.map +1 -0
  91. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
  92. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
  93. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
  94. package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
  95. package/dist/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js +2 -0
  96. package/dist/features/CognitiveCompare/Guidelines/utils/guidelineTargets.js.map +1 -0
  97. package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js +2 -0
  98. package/dist/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.js.map +1 -0
  99. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  100. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
  101. package/dist/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js +2 -0
  102. package/dist/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.js.map +1 -0
  103. package/dist/features/CognitiveCompare/components/GuidelineSkeletonLoader.js +2 -0
  104. package/dist/features/CognitiveCompare/components/GuidelineSkeletonLoader.js.map +1 -0
  105. package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
  106. package/dist/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
  107. package/dist/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
  108. package/dist/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
  109. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  110. package/dist/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
  111. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  112. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
  113. package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  114. package/dist/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
  115. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  116. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
  117. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  118. package/dist/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
  119. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  120. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
  121. package/dist/features/CognitiveCompare/hooks/useOnDemandCitationCache.js +2 -0
  122. package/dist/features/CognitiveCompare/hooks/useOnDemandCitationCache.js.map +1 -0
  123. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  124. package/dist/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
  125. package/dist/features/CognitiveCompare/onDemandCitations/cacheKey.js +2 -0
  126. package/dist/features/CognitiveCompare/onDemandCitations/cacheKey.js.map +1 -0
  127. package/dist/features/CognitiveCompare/onDemandCitations/contextBuilder.js +2 -0
  128. package/dist/features/CognitiveCompare/onDemandCitations/contextBuilder.js.map +1 -0
  129. package/dist/features/CognitiveCompare/onDemandCitations/href.js +2 -0
  130. package/dist/features/CognitiveCompare/onDemandCitations/href.js.map +1 -0
  131. package/dist/features/CognitiveCompare/onDemandCitations/payload.js +2 -0
  132. package/dist/features/CognitiveCompare/onDemandCitations/payload.js.map +1 -0
  133. package/dist/features/CognitiveCompare/onDemandCitations/response.js +2 -0
  134. package/dist/features/CognitiveCompare/onDemandCitations/response.js.map +1 -0
  135. package/dist/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js +2 -0
  136. package/dist/features/CognitiveCompare/utils/normalizeCompactedGfmTables.js.map +1 -0
  137. package/dist/features/CognitiveCompare/utils/normalizeInlineMarkdown.js +2 -0
  138. package/dist/features/CognitiveCompare/utils/normalizeInlineMarkdown.js.map +1 -0
  139. package/dist/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js +2 -0
  140. package/dist/features/CognitiveCompare/utils/normalizeRedlineMarkdown.js.map +1 -0
  141. package/dist/features/SegmentReviewComponents/BoundaryCard.js +1 -1
  142. package/dist/features/SegmentReviewComponents/BoundaryCard.js.map +1 -1
  143. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js +1 -1
  144. package/dist/features/SegmentReviewComponents/SegmentReviewPdfWrapper.js.map +1 -1
  145. package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts +2 -0
  146. package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  147. package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts +8 -1
  148. package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts.map +1 -1
  149. package/dist/types/features/CognitiveCompare/CitationRendererInner.d.ts +13 -0
  150. package/dist/types/features/CognitiveCompare/CitationRendererInner.d.ts.map +1 -0
  151. package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  152. package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  153. package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts +1 -1
  154. package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts.map +1 -1
  155. package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts +14 -1
  156. package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  157. package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts +12 -0
  158. package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  159. package/dist/types/features/CognitiveCompare/CognitivePopup.d.ts.map +1 -1
  160. package/dist/types/features/CognitiveCompare/CompareContext.d.ts +10 -1
  161. package/dist/types/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
  162. package/dist/types/features/CognitiveCompare/GptWebCitationPanel.d.ts +7 -0
  163. package/dist/types/features/CognitiveCompare/GptWebCitationPanel.d.ts.map +1 -0
  164. package/dist/types/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
  165. package/dist/types/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
  166. package/dist/types/features/CognitiveCompare/Guidelines/utils/guidelineTargets.d.ts +3 -0
  167. package/dist/types/features/CognitiveCompare/Guidelines/utils/guidelineTargets.d.ts.map +1 -0
  168. package/dist/types/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts +3 -0
  169. package/dist/types/features/CognitiveCompare/Guidelines/utils/hasGptCitationObjects.d.ts.map +1 -0
  170. package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +14 -1
  171. package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  172. package/dist/types/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts +19 -0
  173. package/dist/types/features/CognitiveCompare/Guidelines/utils/resolveGuidelineSelection.d.ts.map +1 -0
  174. package/dist/types/features/CognitiveCompare/components/GuidelineSkeletonLoader.d.ts +8 -0
  175. package/dist/types/features/CognitiveCompare/components/GuidelineSkeletonLoader.d.ts.map +1 -0
  176. package/dist/types/features/CognitiveCompare/components/LHSSectionRow.d.ts.map +1 -1
  177. package/dist/types/features/CognitiveCompare/components/RHSSectionRow.d.ts.map +1 -1
  178. package/dist/types/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  179. package/dist/types/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  180. package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts +3 -2
  181. package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
  182. package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts +2 -1
  183. package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  184. package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
  185. package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  186. package/dist/types/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  187. package/dist/types/features/CognitiveCompare/hooks/useOnDemandCitationCache.d.ts +10 -0
  188. package/dist/types/features/CognitiveCompare/hooks/useOnDemandCitationCache.d.ts.map +1 -0
  189. package/dist/types/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  190. package/dist/types/features/CognitiveCompare/onDemandCitations/cacheKey.d.ts +3 -0
  191. package/dist/types/features/CognitiveCompare/onDemandCitations/cacheKey.d.ts.map +1 -0
  192. package/dist/types/features/CognitiveCompare/onDemandCitations/contextBuilder.d.ts +16 -0
  193. package/dist/types/features/CognitiveCompare/onDemandCitations/contextBuilder.d.ts.map +1 -0
  194. package/dist/types/features/CognitiveCompare/onDemandCitations/href.d.ts +6 -0
  195. package/dist/types/features/CognitiveCompare/onDemandCitations/href.d.ts.map +1 -0
  196. package/dist/types/features/CognitiveCompare/onDemandCitations/index.d.ts +7 -0
  197. package/dist/types/features/CognitiveCompare/onDemandCitations/index.d.ts.map +1 -0
  198. package/dist/types/features/CognitiveCompare/onDemandCitations/payload.d.ts +4 -0
  199. package/dist/types/features/CognitiveCompare/onDemandCitations/payload.d.ts.map +1 -0
  200. package/dist/types/features/CognitiveCompare/onDemandCitations/response.d.ts +3 -0
  201. package/dist/types/features/CognitiveCompare/onDemandCitations/response.d.ts.map +1 -0
  202. package/dist/types/features/CognitiveCompare/onDemandCitations/types.d.ts +134 -0
  203. package/dist/types/features/CognitiveCompare/onDemandCitations/types.d.ts.map +1 -0
  204. package/dist/types/features/CognitiveCompare/utils/normalizeCompactedGfmTables.d.ts +7 -0
  205. package/dist/types/features/CognitiveCompare/utils/normalizeCompactedGfmTables.d.ts.map +1 -0
  206. package/dist/types/features/CognitiveCompare/utils/normalizeInlineMarkdown.d.ts +6 -0
  207. package/dist/types/features/CognitiveCompare/utils/normalizeInlineMarkdown.d.ts.map +1 -0
  208. package/dist/types/features/CognitiveCompare/utils/normalizeRedlineMarkdown.d.ts +6 -0
  209. package/dist/types/features/CognitiveCompare/utils/normalizeRedlineMarkdown.d.ts.map +1 -0
  210. package/dist/types/features/SegmentReviewComponents/BoundaryCard.d.ts.map +1 -1
  211. package/dist/types/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts +3 -1
  212. package/dist/types/features/SegmentReviewComponents/SegmentReviewPdfWrapper.d.ts.map +1 -1
  213. package/package.json +1 -1
  214. package/dist/cjs/features/Bookemon/BookemonStyles.js +0 -2
  215. package/dist/cjs/features/Bookemon/BookemonStyles.js.map +0 -1
  216. package/dist/cjs/lib/ui/icons.js +0 -2
  217. package/dist/cjs/lib/ui/icons.js.map +0 -1
  218. package/dist/cjs/lib/ui/materialCompat.js +0 -2
  219. package/dist/cjs/lib/ui/materialCompat.js.map +0 -1
  220. package/dist/features/Bookemon/BookemonStyles.js +0 -2
  221. package/dist/features/Bookemon/BookemonStyles.js.map +0 -1
  222. package/dist/lib/ui/icons.js +0 -2
  223. package/dist/lib/ui/icons.js.map +0 -1
  224. package/dist/lib/ui/materialCompat.js +0 -2
  225. package/dist/lib/ui/materialCompat.js.map +0 -1
  226. package/dist/types/features/Bookemon/BookemonStyles.d.ts +0 -6
  227. package/dist/types/features/Bookemon/BookemonStyles.d.ts.map +0 -1
  228. package/dist/types/lib/ui/icons.d.ts +0 -46
  229. package/dist/types/lib/ui/icons.d.ts.map +0 -1
  230. package/dist/types/lib/ui/materialCompat.d.ts +0 -117
  231. package/dist/types/lib/ui/materialCompat.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useSideBySide.js","sources":["../../../../src/features/CognitiveCompare/hooks/useSideBySide.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\"\nimport { DEVIATION_BADGE_SEPARATOR, resetClauseHighlight, smoothScrollTo } from \"../CognitiveComparehelpers\";\n\nexport const useSideBySide = ({ \n isGuidelineMode, // ── NEW PROP ──\n maintainRelativeOrder,\n proposedSections, existingSections,\n leftContainerRef, rightContainerRef, scrollContainerRef,\n sectionLeftRefs, sectionRightRefs,\n subSectionLeftRefs, subSectionRightRefs,\n lhsBadgeRefs, rhsBadgeRefs,\n sectionRowRefs, sectionRightRowRefs,\n rhsTopSpacerRef, rhsBottomSpacerRef,\n lhsTopSpacerRef, lhsBottomSpacerRef,\n calculateLinesRef,\n setConnectedSections, setConnectedLines, cachedConnectedPositions,\n closeMoreFunctionsPopup, setErrorToast,\n moreFunctions, closeSummaryPopup,\n}: any) => {\n const [isSideBySide, setIsSideBySide] = useState(false);\n const [isArrowVisible, setIsArrowVisible] = useState(false);\n const [isResizing, setIsResizing] = useState(false);\n const [isSideBySideLoading, setIsSideBySideLoading] = useState(false)\n const [activeSideBySideSection, setActiveSideBySideSection] = useState<number | string | null>(null)\n\n\n const scrollLock = useRef(false);\n const sideBySideCacheRef = useRef<{ badgeScreenY: number; initialScrollTop: number; leftTop: number; leftBottom: number; cTop: number; } | null>(null);\n const isSideBySideRef = useRef(false);\n const activeSideBySideSectionRef = useRef<number | string | null>(null);\n const activeSideBySideRightSectionRef = useRef<number | string | null>(null);\n const sideBySideLineRef = useRef<SVGLineElement | null>(null);\n const highlightedClauseRefs = useRef<Set<HTMLElement>>(new Set());\n\n // Helpers\n const clearClauseHighlight = () => {\n highlightedClauseRefs.current.forEach((el) => {\n resetClauseHighlight(el);\n });\n highlightedClauseRefs.current.clear();\n };\n\n const applyAlignmentPadding = (isSub: boolean, idx: any, activeRightIdx: any) => {\n let leftPadTarget: HTMLElement | null = null;\n let rightPadTarget: HTMLElement | null = null;\n let leftAlignEl: HTMLElement | null = null;\n let rightAlignEl: HTMLElement | null = null;\n let leftBadgeEl: HTMLElement | null = null;\n let rightBadgeEl: HTMLElement | null = null;\n const maxBadgeOffset = 32;\n\n const isVisibleInContainer = (el: HTMLElement | null, container: HTMLElement | null) => {\n if (!el || !container) return true;\n const rect = el.getBoundingClientRect();\n const cRect = container.getBoundingClientRect();\n return rect.bottom >= cRect.top && rect.top <= cRect.bottom;\n };\n\n if (isSub) {\n const parts = (idx as string).split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n leftPadTarget = subSectionLeftRefs.current[parts[2]]?.current || sectionLeftRefs.current[Number(parts[2])]?.current || null;\n rightPadTarget = subSectionRightRefs.current[parts[3]]?.current || sectionRightRefs.current[Number(parts[3])]?.current || null;\n leftAlignEl = lhsBadgeRefs.current[refId]?.current || leftPadTarget;\n rightAlignEl = rhsBadgeRefs.current[refId]?.current || rightPadTarget;\n } else {\n const leftNumIdx = Number(idx);\n const rightNumIdx = activeRightIdx !== null ? Number(activeRightIdx) : leftNumIdx;\n\n leftPadTarget = sectionLeftRefs.current[leftNumIdx]?.current || null;\n rightPadTarget = sectionRightRefs.current[rightNumIdx]?.current || null;\n leftBadgeEl = lhsBadgeRefs.current[leftNumIdx]?.current || null;\n rightBadgeEl = rhsBadgeRefs.current[rightNumIdx]?.current || null;\n\n // Core Fix: Fallbacks guarantee we find an element even if badges are null\n leftAlignEl = leftBadgeEl || sectionRowRefs.current[leftNumIdx]?.current || leftPadTarget;\n rightAlignEl = rightBadgeEl || sectionRightRowRefs.current[rightNumIdx]?.current || rightPadTarget;\n }\n\n if (leftPadTarget) leftPadTarget.style.paddingTop = \"0px\";\n if (rightPadTarget) rightPadTarget.style.paddingTop = \"0px\";\n if (!isSub) {\n if (leftBadgeEl) leftBadgeEl.style.marginTop = \"0px\";\n if (rightBadgeEl) rightBadgeEl.style.marginTop = \"0px\";\n }\n\n if (!isSub && leftBadgeEl && rightBadgeEl) {\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n if (!isVisibleInContainer(leftBadgeEl, leftContainer) || !isVisibleInContainer(rightBadgeEl, rightContainer)) {\n return;\n }\n const lRect = leftBadgeEl.getBoundingClientRect();\n const rRect = rightBadgeEl.getBoundingClientRect();\n const badgeDiff = lRect.top - rRect.top;\n\n if (Math.abs(badgeDiff) > maxBadgeOffset) return;\n\n if (badgeDiff > 0) {\n rightBadgeEl.style.marginTop = `${badgeDiff}px`;\n }\n return;\n }\n\n if (leftAlignEl && rightAlignEl && leftPadTarget && rightPadTarget) {\n const lRect = leftAlignEl.getBoundingClientRect();\n const rRect = rightAlignEl.getBoundingClientRect();\n const badgeDiff = lRect.top - rRect.top;\n\n if (badgeDiff > 0) {\n rightPadTarget.style.paddingTop = `${badgeDiff}px`;\n }\n }\n };\n\n const clearAlignmentOffsets = useCallback(() => {\n const leftIdx = activeSideBySideSectionRef.current;\n const rightIdx = activeSideBySideRightSectionRef.current;\n\n if (leftIdx !== null) {\n if (typeof leftIdx === \"string\" && leftIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const parts = leftIdx.split(DEVIATION_BADGE_SEPARATOR);\n const leftPadTarget =\n subSectionLeftRefs.current[parts[2]]?.current ||\n sectionLeftRefs.current[Number(parts[2])]?.current ||\n null;\n const rightPadTarget =\n subSectionRightRefs.current[parts[3]]?.current ||\n sectionRightRefs.current[Number(parts[3])]?.current ||\n null;\n\n if (leftPadTarget) leftPadTarget.style.paddingTop = \"0px\";\n if (rightPadTarget) rightPadTarget.style.paddingTop = \"0px\";\n } else {\n const leftPadTarget = sectionLeftRefs.current[leftIdx as number]?.current || null;\n const rightPadTarget =\n sectionRightRefs.current[(rightIdx ?? leftIdx) as number]?.current || null;\n\n if (leftPadTarget) leftPadTarget.style.paddingTop = \"0px\";\n if (rightPadTarget) rightPadTarget.style.paddingTop = \"0px\";\n\n const leftBadge = lhsBadgeRefs.current[leftIdx as number]?.current || null;\n const rightBadge = rhsBadgeRefs.current[(rightIdx ?? leftIdx) as number]?.current || null;\n if (leftBadge) leftBadge.style.marginTop = \"0px\";\n if (rightBadge) rightBadge.style.marginTop = \"0px\";\n }\n }\n\n if (rhsTopSpacerRef.current) rhsTopSpacerRef.current.style.height = \"0px\";\n if (rhsBottomSpacerRef.current) rhsBottomSpacerRef.current.style.height = \"0px\";\n if (lhsTopSpacerRef.current) lhsTopSpacerRef.current.style.height = \"0px\";\n if (lhsBottomSpacerRef.current) lhsBottomSpacerRef.current.style.height = \"0px\";\n }, []);\n\n\n // Effects\n useEffect(() => {\n isSideBySideRef.current = isSideBySide;\n }, [isSideBySide]);\n\n useEffect(() => {\n activeSideBySideSectionRef.current = activeSideBySideSection;\n }, [activeSideBySideSection]);\n\n // Callbacks\n\n const resetSideBySide = useCallback(() => {\n clearClauseHighlight();\n setIsSideBySide(false);\n isSideBySideRef.current = false;\n sideBySideCacheRef.current = null;\n clearAlignmentOffsets();\n setActiveSideBySideSection(null);\n activeSideBySideSectionRef.current = null;\n activeSideBySideRightSectionRef.current = null;\n setIsArrowVisible(false);\n setIsSideBySideLoading(false);\n }, [clearAlignmentOffsets]);\n\n const activateSideBySide = useCallback(\n (\n idx: number | string,\n isOrphan: boolean,\n options?: { toggleIfSame?: boolean; onReady?: () => void; sourceSide?: \"left\" | \"right\" },\n ) => {\n const toggleIfSame = options?.toggleIfSame ?? true;\n const onReady = options?.onReady;\n const sourceSide = options?.sourceSide ?? \"left\";\n\n closeMoreFunctionsPopup();\n\n if (idx == null) return;\n\n // In Guideline Mode, we don't care about orphans, the whole rulebook is the counterpart.\n if (isOrphan && !isGuidelineMode) {\n setErrorToast(\"No counterpart exists for this section.\");\n return;\n }\n clearClauseHighlight();\n const isSameTarget = isSideBySide && activeSideBySideSection === idx;\n if (isSideBySide && activeSideBySideSection !== null) {\n clearAlignmentOffsets();\n }\n if (isSameTarget && toggleIfSame) {\n resetSideBySide();\n return;\n }\n\n setConnectedSections(new Set([idx]));\n setConnectedLines([]);\n cachedConnectedPositions.current = [];\n setIsSideBySideLoading(true);\n scrollLock.current = true;\n setActiveSideBySideSection(idx);\n activeSideBySideSectionRef.current = idx;\n setIsSideBySide(true);\n isSideBySideRef.current = true;\n setIsArrowVisible(false);\n\n if (rhsTopSpacerRef.current) rhsTopSpacerRef.current.style.height = \"0px\";\n if (rhsBottomSpacerRef.current) rhsBottomSpacerRef.current.style.height = \"0px\";\n if (lhsTopSpacerRef.current) lhsTopSpacerRef.current.style.height = \"0px\";\n if (lhsBottomSpacerRef.current) lhsBottomSpacerRef.current.style.height = \"0px\";\n\n requestAnimationFrame(() => {\n const executeAlignment = () => {\n const isSub = typeof idx === \"string\" && idx.includes(DEVIATION_BADGE_SEPARATOR);\n let leftEl: HTMLElement | null = null;\n let rightEl: HTMLElement | null = null;\n let activeRightIdx: number | string | null = null;\n\n if (isGuidelineMode) {\n // In guideline mode, grab leftEl normally, but rightEl is the injected <mark>\n if (isSub) {\n const parts = (idx as string).split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n leftEl = lhsBadgeRefs.current[refId]?.current || null;\n } else {\n leftEl = sectionLeftRefs.current[idx as number]?.current || sectionRowRefs.current[idx as number]?.current || null;\n }\n \n rightEl = document.getElementById('guideline-target-0');\n activeRightIdx = rightEl ? idx : null;\n } else {\n if (isSub) {\n const parts = (idx as string).split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n \n leftEl = lhsBadgeRefs.current[refId]?.current || null;\n rightEl = rhsBadgeRefs.current[refId]?.current || null;\n activeRightIdx = rightEl ? idx : null;\n } else {\n leftEl = sectionLeftRefs.current[idx as number]?.current || sectionRowRefs.current[idx as number]?.current || null;\n \n if (!maintainRelativeOrder) {\n rightEl = sectionRightRefs.current[idx as number]?.current || sectionRightRowRefs.current[idx as number]?.current || null;\n activeRightIdx = rightEl ? idx : null;\n } else {\n const leftSec = proposedSections[idx as number] as any;\n const refIdxs = (leftSec?.refIndexes || []) as number[];\n \n if (refIdxs.length > 0) {\n const rhsSelfIndex = refIdxs[0];\n const rhsArrayIdx = existingSections.findIndex(\n (s: any) => s.selfIndex === rhsSelfIndex,\n );\n if (rhsArrayIdx !== -1) {\n rightEl = sectionRightRefs.current[rhsArrayIdx]?.current || sectionRightRowRefs.current[rhsArrayIdx]?.current || null;\n activeRightIdx = rhsArrayIdx;\n }\n }\n }\n }\n }\n\n activeSideBySideRightSectionRef.current = activeRightIdx;\n\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n\n // Force visual alignment instantly after scroll animation completes\n const forceLayoutSync = () => {\n if (sourceSide === \"right\" && rightContainer) {\n rightContainer.dispatchEvent(new Event(\"scroll\"));\n } else if (leftContainer) {\n leftContainer.dispatchEvent(new Event(\"scroll\"));\n }\n };\n\n\n // CONSOLIDATED SCROLL COMPLETION HANDLER\n const finalizeSideBySide = () => {\n applyAlignmentPadding(isSub, idx, activeRightIdx);\n setIsArrowVisible(true);\n if (calculateLinesRef.current) calculateLinesRef.current();\n scrollLock.current = false;\n forceLayoutSync();\n setIsSideBySideLoading(false);\n onReady?.();\n };\n\n if (!leftEl || !leftContainer) {\n scrollLock.current = false;\n setIsSideBySideLoading(false);\n onReady?.();\n return;\n }\n\n if (!rightEl || !rightContainer) {\n finalizeSideBySide();\n return;\n }\n\n if (!maintainRelativeOrder) {\n let targetTop = 0;\n if (sourceSide === \"right\") {\n targetTop = rightEl ? rightEl.getBoundingClientRect().top : 0;\n } else {\n targetTop = leftEl ? leftEl.getBoundingClientRect().top : 0;\n }\n\n const scrollContainer = scrollContainerRef.current;\n const containerTop = scrollContainer?.getBoundingClientRect().top || 0;\n const nextTop = scrollContainer\n ? scrollContainer.scrollTop + targetTop - containerTop - 150\n : 0;\n const ANIM_SPEED = 200;\n\n if (!scrollContainer) {\n finalizeSideBySide();\n return;\n }\n\n smoothScrollTo(scrollContainer, nextTop, ANIM_SPEED, finalizeSideBySide);\n return;\n }\n\n const leftAbsoluteTop = leftEl.getBoundingClientRect().top - leftContainer.getBoundingClientRect().top + leftContainer.scrollTop;\n const rightAbsoluteTop = rightEl.getBoundingClientRect().top - rightContainer.getBoundingClientRect().top + rightContainer.scrollTop;\n const ANIM_SPEED = 200;\n\n if (sourceSide === \"left\") {\n const currentRelativeY = leftAbsoluteTop - leftContainer.scrollTop;\n const rawRightTargetScroll = rightAbsoluteTop - currentRelativeY;\n\n if (rawRightTargetScroll < 0) {\n if (rhsTopSpacerRef.current && !isGuidelineMode)\n rhsTopSpacerRef.current.style.height = `${Math.abs(rawRightTargetScroll)}px`;\n }\n\n requestAnimationFrame(() => {\n const rightMaxScroll = rightContainer.scrollHeight - rightContainer.clientHeight;\n let rightActualScroll: number;\n\n if (rawRightTargetScroll < 0) {\n rightActualScroll = 0;\n } else if (rawRightTargetScroll > rightMaxScroll) {\n const deficit = rawRightTargetScroll - rightMaxScroll;\n if (rhsBottomSpacerRef.current && !isGuidelineMode)\n rhsBottomSpacerRef.current.style.height = `${deficit + 150}px`;\n requestAnimationFrame(() => {\n smoothScrollTo(rightContainer, rawRightTargetScroll, ANIM_SPEED, finalizeSideBySide);\n });\n return;\n } else {\n rightActualScroll = rawRightTargetScroll;\n }\n\n smoothScrollTo(rightContainer, rightActualScroll, ANIM_SPEED, finalizeSideBySide);\n });\n } else {\n const currentRelativeY = rightAbsoluteTop - rightContainer.scrollTop;\n const rawLeftTargetScroll = leftAbsoluteTop - currentRelativeY;\n\n // STRICT FIX: Removed LHS Top Spacer injection. LHS acts strictly as scroll target without manipulation.\n requestAnimationFrame(() => {\n const leftMaxScroll = leftContainer.scrollHeight - leftContainer.clientHeight;\n let leftActualScroll: number;\n\n if (rawLeftTargetScroll < 0) {\n leftActualScroll = 0;\n } else if (rawLeftTargetScroll > leftMaxScroll) {\n requestAnimationFrame(() => smoothScrollTo(leftContainer, leftMaxScroll, ANIM_SPEED, finalizeSideBySide));\n return;\n } else {\n leftActualScroll = rawLeftTargetScroll;\n }\n smoothScrollTo(leftContainer, leftActualScroll, ANIM_SPEED, finalizeSideBySide);\n });\n }\n };\n\n // Because GuidelinePanel re-renders when setConnectedSections fires,\n // we must wait a tick for the `<mark>` tags to paint to the DOM before calculating scroll bounds.\n if (isGuidelineMode) {\n setTimeout(executeAlignment, 100);\n } else {\n executeAlignment();\n }\n });\n },\n [\n activeSideBySideSection,\n closeMoreFunctionsPopup,\n existingSections,\n isSideBySide,\n maintainRelativeOrder,\n proposedSections,\n clearAlignmentOffsets,\n resetSideBySide,\n isGuidelineMode\n ],\n );\n\n return {\n isSideBySide, setIsSideBySide,\n isArrowVisible, setIsArrowVisible,\n isResizing, setIsResizing,\n isSideBySideLoading, setIsSideBySideLoading,\n activeSideBySideSection, setActiveSideBySideSection,\n scrollLock,\n sideBySideCacheRef,\n isSideBySideRef,\n activeSideBySideSectionRef,\n activeSideBySideRightSectionRef,\n sideBySideLineRef,\n highlightedClauseRefs,\n clearClauseHighlight,\n applyAlignmentPadding,\n resetSideBySide,\n activateSideBySide,\n }\n}"],"names":["useSideBySide","isGuidelineMode","maintainRelativeOrder","proposedSections","existingSections","leftContainerRef","rightContainerRef","scrollContainerRef","sectionLeftRefs","sectionRightRefs","subSectionLeftRefs","subSectionRightRefs","lhsBadgeRefs","rhsBadgeRefs","sectionRowRefs","sectionRightRowRefs","rhsTopSpacerRef","rhsBottomSpacerRef","lhsTopSpacerRef","lhsBottomSpacerRef","calculateLinesRef","setConnectedSections","setConnectedLines","cachedConnectedPositions","closeMoreFunctionsPopup","setErrorToast","moreFunctions","closeSummaryPopup","isSideBySide","setIsSideBySide","useState","isArrowVisible","setIsArrowVisible","isResizing","setIsResizing","isSideBySideLoading","setIsSideBySideLoading","activeSideBySideSection","setActiveSideBySideSection","scrollLock","useRef","sideBySideCacheRef","isSideBySideRef","activeSideBySideSectionRef","activeSideBySideRightSectionRef","sideBySideLineRef","highlightedClauseRefs","Set","clearClauseHighlight","current","forEach","el","resetClauseHighlight","clear","applyAlignmentPadding","isSub","idx","activeRightIdx","leftPadTarget","rightPadTarget","leftAlignEl","rightAlignEl","leftBadgeEl","rightBadgeEl","isVisibleInContainer","container","rect","getBoundingClientRect","cRect","bottom","top","parts","split","DEVIATION_BADGE_SEPARATOR","refId","Number","leftNumIdx","rightNumIdx","style","paddingTop","marginTop","leftContainer","rightContainer","lRect","rRect","badgeDiff","Math","abs","clearAlignmentOffsets","useCallback","leftIdx","rightIdx","includes","leftBadge","rightBadge","height","useEffect","resetSideBySide","activateSideBySide","isOrphan","options","toggleIfSame","onReady","sourceSide","isSameTarget","requestAnimationFrame","executeAlignment","leftEl","rightEl","document","getElementById","leftSec","refIdxs","refIndexes","length","rhsSelfIndex","rhsArrayIdx","findIndex","s","selfIndex","finalizeSideBySide","dispatchEvent","Event","targetTop","scrollContainer","containerTop","nextTop","scrollTop","smoothScrollTo","leftAbsoluteTop","rightAbsoluteTop","ANIM_SPEED","rawRightTargetScroll","rightMaxScroll","scrollHeight","clientHeight","rightActualScroll","deficit","rawLeftTargetScroll","leftMaxScroll","leftActualScroll","setTimeout"],"mappings":"qMAGO,MAAMA,EAAgB,EACzBC,kBACAC,wBACAC,mBAAkBC,mBAClBC,mBAAkBC,oBAAmBC,qBACrCC,kBAAiBC,mBACjBC,qBAAoBC,sBACpBC,eAAcC,eACdC,iBAAgBC,sBAChBC,kBAAiBC,qBACjBC,kBAAiBC,qBACjBC,oBACAC,uBAAsBC,oBAAmBC,2BACzCC,0BAAyBC,gBACzBC,gBAAeC,wBAEf,MAAOC,EAAcC,GAAmBC,GAAS,IAC1CC,EAAgBC,GAAqBF,GAAS,IAC9CG,EAAYC,GAAiBJ,GAAS,IACtCK,EAAqBC,GAA0BN,GAAS,IACxDO,EAAyBC,GAA8BR,EAAiC,MAGzFS,EAAaC,GAAO,GACpBC,EAAqBD,EAAsH,MAC3IE,EAAkBF,GAAO,GACzBG,EAA6BH,EAA+B,MAC5DI,EAAkCJ,EAA+B,MACjEK,EAAoBL,EAA8B,MAClDM,EAAwBN,EAA6B,IAAAO,KAGrDC,EAAuB,KACHF,EAAAG,QAAQC,QAASC,IACnCC,EAAqBD,KAEzBL,EAAsBG,QAAQI,SAG5BC,EAAwB,CAACC,EAAgBC,EAAUC,KACrD,IAAIC,EAAoC,KACpCC,EAAqC,KACrCC,EAAkC,KAClCC,EAAmC,KACnCC,EAAkC,KAClCC,EAAmC,KACvC,MAEMC,EAAuB,CAACb,EAAwBc,KAClD,IAAKd,IAAOc,EAAkB,OAAA,EACxB,MAAAC,EAAOf,EAAGgB,wBACVC,EAAQH,EAAUE,wBACxB,OAAOD,EAAKG,QAAUD,EAAME,KAAOJ,EAAKI,KAAOF,EAAMC,QAGzD,GAAId,EAAO,CACD,MAAAgB,EAASf,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uBC,EAAgB,CAC9C,MAAMI,EAAUL,EAAuBC,EAMvC,OALIpH,EAAmBgC,UAAYhD,IAC/BgB,EAAmBgC,QAAQ6B,MAAMiB,OAAS,GAAG0C,EAAU,cAC3DhC,sBAAsB,KACHuB,EAAA9C,EAAgBkD,EAAsBD,EAAYX,IAErE,CAEoBgB,EAAAJ,CACxB,CAEeJ,EAAA9C,EAAgBsD,EAAmBL,EAAYX,IACjE,KACE,CACG,MACAkB,EAAsBT,GADHC,EAAmBhD,EAAe6C,WAI3DtB,sBAAsB,KACZ,MAAAkC,EAAgB1D,EAAcqD,aAAerD,EAAcsD,aAC7D,IAAAK,EAEJ,GAAIF,EAAsB,EACHE,EAAA,MACvB,IAAWF,EAAsBC,EAE7B,YADAlC,sBAAsB,IAAMuB,EAAe/C,EAAe0D,EAAeR,EAAYX,IAGlEoB,EAAAF,CACvB,CACeV,EAAA/C,EAAe2D,EAAkBT,EAAYX,IAEpE,GAKAvH,EACA4I,WAAWnC,EAAkB,KAEZA,QAI7B,CACIrE,EACAb,EACApB,EACAwB,EACA1B,EACAC,EACAqF,EACAS,GACAhG,IAID,MAAA,CACH2B,eAAcC,kBACdE,iBAAgBC,oBAChBC,aAAYC,gBACZC,sBAAqBC,yBACrBC,0BAAyBC,6BACzBC,aACAE,qBACAC,kBACAC,6BACAC,kCACAC,oBACAC,wBACAE,uBACAM,wBACA2C,mBACAC"}
1
+ {"version":3,"file":"useSideBySide.js","sources":["../../../../src/features/CognitiveCompare/hooks/useSideBySide.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\"\nimport { DEVIATION_BADGE_SEPARATOR, resetClauseHighlight, smoothScrollTo } from \"../CognitiveComparehelpers\";\nimport { getVisibleGuidelineTargets } from \"../Guidelines/utils/guidelineTargets\";\n\nexport const useSideBySide = ({ \n isGuidelineMode, // ── NEW PROP ──\n maintainRelativeOrder,\n proposedSections, existingSections,\n leftContainerRef, rightContainerRef, scrollContainerRef,\n sectionLeftRefs, sectionRightRefs,\n subSectionLeftRefs, subSectionRightRefs,\n lhsBadgeRefs, rhsBadgeRefs,\n sectionRowRefs, sectionRightRowRefs,\n rhsTopSpacerRef, rhsBottomSpacerRef,\n lhsTopSpacerRef, lhsBottomSpacerRef,\n calculateLinesRef,\n setConnectedSections, setConnectedLines, cachedConnectedPositions,\n closeMoreFunctionsPopup, setErrorToast,\n moreFunctions, closeSummaryPopup,\n}: any) => {\n const [isSideBySide, setIsSideBySide] = useState(false);\n const [isArrowVisible, setIsArrowVisible] = useState(false);\n const [isResizing, setIsResizing] = useState(false);\n const [isSideBySideLoading, setIsSideBySideLoading] = useState(false)\n const [activeSideBySideSection, setActiveSideBySideSection] = useState<number | string | null>(null)\n\n\n const scrollLock = useRef(false);\n const sideBySideCacheRef = useRef<{ badgeScreenY: number; initialScrollTop: number; leftTop: number; leftBottom: number; cTop: number; } | null>(null);\n const isSideBySideRef = useRef(false);\n const activeSideBySideSectionRef = useRef<number | string | null>(null);\n const activeSideBySideRightSectionRef = useRef<number | string | null>(null);\n const sideBySideLineRef = useRef<SVGLineElement | null>(null);\n const highlightedClauseRefs = useRef<Set<HTMLElement>>(new Set());\n\n // Helpers\n const clearClauseHighlight = () => {\n highlightedClauseRefs.current.forEach((el) => {\n resetClauseHighlight(el);\n });\n highlightedClauseRefs.current.clear();\n };\n\n const applyAlignmentPadding = (isSub: boolean, idx: any, activeRightIdx: any) => {\n let leftPadTarget: HTMLElement | null = null;\n let rightPadTarget: HTMLElement | null = null;\n let leftAlignEl: HTMLElement | null = null;\n let rightAlignEl: HTMLElement | null = null;\n let leftBadgeEl: HTMLElement | null = null;\n let rightBadgeEl: HTMLElement | null = null;\n const maxBadgeOffset = 32;\n\n const isVisibleInContainer = (el: HTMLElement | null, container: HTMLElement | null) => {\n if (!el || !container) return true;\n const rect = el.getBoundingClientRect();\n const cRect = container.getBoundingClientRect();\n return rect.bottom >= cRect.top && rect.top <= cRect.bottom;\n };\n\n if (isSub) {\n const parts = (idx as string).split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n leftPadTarget = subSectionLeftRefs.current[parts[2]]?.current || sectionLeftRefs.current[Number(parts[2])]?.current || null;\n rightPadTarget = subSectionRightRefs.current[parts[3]]?.current || sectionRightRefs.current[Number(parts[3])]?.current || null;\n leftAlignEl = lhsBadgeRefs.current[refId]?.current || leftPadTarget;\n rightAlignEl = rhsBadgeRefs.current[refId]?.current || rightPadTarget;\n } else {\n const leftNumIdx = Number(idx);\n const rightNumIdx = activeRightIdx !== null ? Number(activeRightIdx) : leftNumIdx;\n\n leftPadTarget = sectionLeftRefs.current[leftNumIdx]?.current || null;\n rightPadTarget = sectionRightRefs.current[rightNumIdx]?.current || null;\n leftBadgeEl = lhsBadgeRefs.current[leftNumIdx]?.current || null;\n rightBadgeEl = rhsBadgeRefs.current[rightNumIdx]?.current || null;\n\n // Core Fix: Fallbacks guarantee we find an element even if badges are null\n leftAlignEl = leftBadgeEl || sectionRowRefs.current[leftNumIdx]?.current || leftPadTarget;\n rightAlignEl = rightBadgeEl || sectionRightRowRefs.current[rightNumIdx]?.current || rightPadTarget;\n }\n\n if (leftPadTarget) leftPadTarget.style.paddingTop = \"0px\";\n if (rightPadTarget) rightPadTarget.style.paddingTop = \"0px\";\n if (!isSub) {\n if (leftBadgeEl) leftBadgeEl.style.marginTop = \"0px\";\n if (rightBadgeEl) rightBadgeEl.style.marginTop = \"0px\";\n }\n\n if (!isSub && leftBadgeEl && rightBadgeEl) {\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n if (!isVisibleInContainer(leftBadgeEl, leftContainer) || !isVisibleInContainer(rightBadgeEl, rightContainer)) {\n return;\n }\n const lRect = leftBadgeEl.getBoundingClientRect();\n const rRect = rightBadgeEl.getBoundingClientRect();\n const badgeDiff = lRect.top - rRect.top;\n\n if (Math.abs(badgeDiff) > maxBadgeOffset) return;\n\n if (badgeDiff > 0) {\n rightBadgeEl.style.marginTop = `${badgeDiff}px`;\n }\n return;\n }\n\n if (leftAlignEl && rightAlignEl && leftPadTarget && rightPadTarget) {\n const lRect = leftAlignEl.getBoundingClientRect();\n const rRect = rightAlignEl.getBoundingClientRect();\n const badgeDiff = lRect.top - rRect.top;\n\n if (badgeDiff > 0) {\n rightPadTarget.style.paddingTop = `${badgeDiff}px`;\n }\n }\n };\n\n const clearAlignmentOffsets = useCallback(() => {\n const leftIdx = activeSideBySideSectionRef.current;\n const rightIdx = activeSideBySideRightSectionRef.current;\n\n if (leftIdx !== null) {\n if (typeof leftIdx === \"string\" && leftIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const parts = leftIdx.split(DEVIATION_BADGE_SEPARATOR);\n const leftPadTarget =\n subSectionLeftRefs.current[parts[2]]?.current ||\n sectionLeftRefs.current[Number(parts[2])]?.current ||\n null;\n const rightPadTarget =\n subSectionRightRefs.current[parts[3]]?.current ||\n sectionRightRefs.current[Number(parts[3])]?.current ||\n null;\n\n if (leftPadTarget) leftPadTarget.style.paddingTop = \"0px\";\n if (rightPadTarget) rightPadTarget.style.paddingTop = \"0px\";\n } else {\n const leftPadTarget = sectionLeftRefs.current[leftIdx as number]?.current || null;\n const rightPadTarget =\n sectionRightRefs.current[(rightIdx ?? leftIdx) as number]?.current || null;\n\n if (leftPadTarget) leftPadTarget.style.paddingTop = \"0px\";\n if (rightPadTarget) rightPadTarget.style.paddingTop = \"0px\";\n\n const leftBadge = lhsBadgeRefs.current[leftIdx as number]?.current || null;\n const rightBadge = rhsBadgeRefs.current[(rightIdx ?? leftIdx) as number]?.current || null;\n if (leftBadge) leftBadge.style.marginTop = \"0px\";\n if (rightBadge) rightBadge.style.marginTop = \"0px\";\n }\n }\n\n if (rhsTopSpacerRef.current) rhsTopSpacerRef.current.style.height = \"0px\";\n if (rhsBottomSpacerRef.current) rhsBottomSpacerRef.current.style.height = \"0px\";\n if (lhsTopSpacerRef.current) lhsTopSpacerRef.current.style.height = \"0px\";\n if (lhsBottomSpacerRef.current) lhsBottomSpacerRef.current.style.height = \"0px\";\n }, []);\n\n\n // Effects\n useEffect(() => {\n isSideBySideRef.current = isSideBySide;\n }, [isSideBySide]);\n\n useEffect(() => {\n activeSideBySideSectionRef.current = activeSideBySideSection;\n }, [activeSideBySideSection]);\n\n // Callbacks\n\n const resetSideBySide = useCallback(() => {\n clearClauseHighlight();\n setIsSideBySide(false);\n isSideBySideRef.current = false;\n sideBySideCacheRef.current = null;\n clearAlignmentOffsets();\n setActiveSideBySideSection(null);\n activeSideBySideSectionRef.current = null;\n activeSideBySideRightSectionRef.current = null;\n setIsArrowVisible(false);\n setIsSideBySideLoading(false);\n }, [clearAlignmentOffsets]);\n\n const activateSideBySide = useCallback(\n (\n idx: number | string,\n isOrphan: boolean,\n options?: { toggleIfSame?: boolean; onReady?: () => void; sourceSide?: \"left\" | \"right\" },\n ) => {\n const toggleIfSame = options?.toggleIfSame ?? true;\n const onReady = options?.onReady;\n const sourceSide = options?.sourceSide ?? \"left\";\n\n closeMoreFunctionsPopup();\n\n if (idx == null) return;\n\n // In Guideline Mode, we don't care about orphans, the whole rulebook is the counterpart.\n if (isOrphan && !isGuidelineMode) {\n setErrorToast(\"No counterpart exists for this section.\");\n return;\n }\n clearClauseHighlight();\n const isSameTarget = isSideBySide && activeSideBySideSection === idx;\n if (isSideBySide && activeSideBySideSection !== null) {\n clearAlignmentOffsets();\n }\n if (isSameTarget && toggleIfSame) {\n resetSideBySide();\n return;\n }\n\n setConnectedSections(new Set([idx]));\n setConnectedLines([]);\n cachedConnectedPositions.current = [];\n setIsSideBySideLoading(true);\n scrollLock.current = true;\n setActiveSideBySideSection(idx);\n activeSideBySideSectionRef.current = idx;\n setIsSideBySide(true);\n isSideBySideRef.current = true;\n setIsArrowVisible(false);\n\n if (rhsTopSpacerRef.current) rhsTopSpacerRef.current.style.height = \"0px\";\n if (rhsBottomSpacerRef.current) rhsBottomSpacerRef.current.style.height = \"0px\";\n if (lhsTopSpacerRef.current) lhsTopSpacerRef.current.style.height = \"0px\";\n if (lhsBottomSpacerRef.current) lhsBottomSpacerRef.current.style.height = \"0px\";\n\n requestAnimationFrame(() => {\n const executeAlignment = () => {\n const isSub = typeof idx === \"string\" && idx.includes(DEVIATION_BADGE_SEPARATOR);\n let leftEl: HTMLElement | null = null;\n let rightEl: HTMLElement | null = null;\n let activeRightIdx: number | string | null = null;\n\n if (isGuidelineMode) {\n // In guideline mode, grab leftEl normally, but rightEl is the injected <mark>\n if (isSub) {\n const parts = (idx as string).split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n leftEl = lhsBadgeRefs.current[refId]?.current || null;\n } else {\n leftEl = sectionLeftRefs.current[idx as number]?.current || sectionRowRefs.current[idx as number]?.current || null;\n }\n \n rightEl = getVisibleGuidelineTargets(rightContainerRef.current)[0] || null;\n activeRightIdx = rightEl ? idx : null;\n } else {\n if (isSub) {\n const parts = (idx as string).split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n \n leftEl = lhsBadgeRefs.current[refId]?.current || null;\n rightEl = rhsBadgeRefs.current[refId]?.current || null;\n activeRightIdx = rightEl ? idx : null;\n } else {\n leftEl = sectionLeftRefs.current[idx as number]?.current || sectionRowRefs.current[idx as number]?.current || null;\n \n if (!maintainRelativeOrder) {\n rightEl = sectionRightRefs.current[idx as number]?.current || sectionRightRowRefs.current[idx as number]?.current || null;\n activeRightIdx = rightEl ? idx : null;\n } else {\n const leftSec = proposedSections[idx as number] as any;\n const refIdxs = (leftSec?.refIndexes || []) as number[];\n \n if (refIdxs.length > 0) {\n const rhsSelfIndex = refIdxs[0];\n const rhsArrayIdx = existingSections.findIndex(\n (s: any) => s.selfIndex === rhsSelfIndex,\n );\n if (rhsArrayIdx !== -1) {\n rightEl = sectionRightRefs.current[rhsArrayIdx]?.current || sectionRightRowRefs.current[rhsArrayIdx]?.current || null;\n activeRightIdx = rhsArrayIdx;\n }\n }\n }\n }\n }\n\n activeSideBySideRightSectionRef.current = activeRightIdx;\n\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n\n // Force visual alignment instantly after scroll animation completes\n const forceLayoutSync = () => {\n if (sourceSide === \"right\" && rightContainer) {\n rightContainer.dispatchEvent(new Event(\"scroll\"));\n } else if (leftContainer) {\n leftContainer.dispatchEvent(new Event(\"scroll\"));\n }\n };\n\n\n // CONSOLIDATED SCROLL COMPLETION HANDLER\n const finalizeSideBySide = () => {\n applyAlignmentPadding(isSub, idx, activeRightIdx);\n setIsArrowVisible(true);\n if (calculateLinesRef.current) calculateLinesRef.current();\n scrollLock.current = false;\n forceLayoutSync();\n setIsSideBySideLoading(false);\n onReady?.();\n };\n\n if (!leftEl || !leftContainer) {\n scrollLock.current = false;\n setIsSideBySideLoading(false);\n onReady?.();\n return;\n }\n\n if (!rightEl || !rightContainer) {\n finalizeSideBySide();\n return;\n }\n\n if (!maintainRelativeOrder) {\n let targetTop = 0;\n if (sourceSide === \"right\") {\n targetTop = rightEl ? rightEl.getBoundingClientRect().top : 0;\n } else {\n targetTop = leftEl ? leftEl.getBoundingClientRect().top : 0;\n }\n\n const scrollContainer = scrollContainerRef.current;\n const containerTop = scrollContainer?.getBoundingClientRect().top || 0;\n const nextTop = scrollContainer\n ? scrollContainer.scrollTop + targetTop - containerTop - 150\n : 0;\n const ANIM_SPEED = 200;\n\n if (!scrollContainer) {\n finalizeSideBySide();\n return;\n }\n\n smoothScrollTo(scrollContainer, nextTop, ANIM_SPEED, finalizeSideBySide);\n return;\n }\n\n const leftAbsoluteTop = leftEl.getBoundingClientRect().top - leftContainer.getBoundingClientRect().top + leftContainer.scrollTop;\n const rightAbsoluteTop = rightEl.getBoundingClientRect().top - rightContainer.getBoundingClientRect().top + rightContainer.scrollTop;\n const ANIM_SPEED = 200;\n\n if (sourceSide === \"left\") {\n const currentRelativeY = leftAbsoluteTop - leftContainer.scrollTop;\n const rawRightTargetScroll = rightAbsoluteTop - currentRelativeY;\n\n if (rawRightTargetScroll < 0) {\n if (rhsTopSpacerRef.current && !isGuidelineMode)\n rhsTopSpacerRef.current.style.height = `${Math.abs(rawRightTargetScroll)}px`;\n }\n\n requestAnimationFrame(() => {\n const rightMaxScroll = rightContainer.scrollHeight - rightContainer.clientHeight;\n let rightActualScroll: number;\n\n if (rawRightTargetScroll < 0) {\n rightActualScroll = 0;\n } else if (rawRightTargetScroll > rightMaxScroll) {\n const deficit = rawRightTargetScroll - rightMaxScroll;\n if (rhsBottomSpacerRef.current && !isGuidelineMode)\n rhsBottomSpacerRef.current.style.height = `${deficit + 150}px`;\n requestAnimationFrame(() => {\n smoothScrollTo(rightContainer, rawRightTargetScroll, ANIM_SPEED, finalizeSideBySide);\n });\n return;\n } else {\n rightActualScroll = rawRightTargetScroll;\n }\n\n smoothScrollTo(rightContainer, rightActualScroll, ANIM_SPEED, finalizeSideBySide);\n });\n } else {\n const currentRelativeY = rightAbsoluteTop - rightContainer.scrollTop;\n const rawLeftTargetScroll = leftAbsoluteTop - currentRelativeY;\n\n // STRICT FIX: Removed LHS Top Spacer injection. LHS acts strictly as scroll target without manipulation.\n requestAnimationFrame(() => {\n const leftMaxScroll = leftContainer.scrollHeight - leftContainer.clientHeight;\n let leftActualScroll: number;\n\n if (rawLeftTargetScroll < 0) {\n leftActualScroll = 0;\n } else if (rawLeftTargetScroll > leftMaxScroll) {\n requestAnimationFrame(() => smoothScrollTo(leftContainer, leftMaxScroll, ANIM_SPEED, finalizeSideBySide));\n return;\n } else {\n leftActualScroll = rawLeftTargetScroll;\n }\n smoothScrollTo(leftContainer, leftActualScroll, ANIM_SPEED, finalizeSideBySide);\n });\n }\n };\n\n // Because GuidelinePanel re-renders when setConnectedSections fires,\n // we must wait a tick for the `<mark>` tags to paint to the DOM before calculating scroll bounds.\n if (isGuidelineMode) {\n setTimeout(executeAlignment, 100);\n } else {\n executeAlignment();\n }\n });\n },\n [\n activeSideBySideSection,\n closeMoreFunctionsPopup,\n existingSections,\n isSideBySide,\n maintainRelativeOrder,\n proposedSections,\n clearAlignmentOffsets,\n resetSideBySide,\n isGuidelineMode\n ],\n );\n\n return {\n isSideBySide, setIsSideBySide,\n isArrowVisible, setIsArrowVisible,\n isResizing, setIsResizing,\n isSideBySideLoading, setIsSideBySideLoading,\n activeSideBySideSection, setActiveSideBySideSection,\n scrollLock,\n sideBySideCacheRef,\n isSideBySideRef,\n activeSideBySideSectionRef,\n activeSideBySideRightSectionRef,\n sideBySideLineRef,\n highlightedClauseRefs,\n clearClauseHighlight,\n applyAlignmentPadding,\n resetSideBySide,\n activateSideBySide,\n }\n}"],"names":["useSideBySide","isGuidelineMode","maintainRelativeOrder","proposedSections","existingSections","leftContainerRef","rightContainerRef","scrollContainerRef","sectionLeftRefs","sectionRightRefs","subSectionLeftRefs","subSectionRightRefs","lhsBadgeRefs","rhsBadgeRefs","sectionRowRefs","sectionRightRowRefs","rhsTopSpacerRef","rhsBottomSpacerRef","lhsTopSpacerRef","lhsBottomSpacerRef","calculateLinesRef","setConnectedSections","setConnectedLines","cachedConnectedPositions","closeMoreFunctionsPopup","setErrorToast","moreFunctions","closeSummaryPopup","isSideBySide","setIsSideBySide","useState","isArrowVisible","setIsArrowVisible","isResizing","setIsResizing","isSideBySideLoading","setIsSideBySideLoading","activeSideBySideSection","setActiveSideBySideSection","scrollLock","useRef","sideBySideCacheRef","isSideBySideRef","activeSideBySideSectionRef","activeSideBySideRightSectionRef","sideBySideLineRef","highlightedClauseRefs","Set","clearClauseHighlight","current","forEach","el","resetClauseHighlight","clear","applyAlignmentPadding","isSub","idx","activeRightIdx","leftPadTarget","rightPadTarget","leftAlignEl","rightAlignEl","leftBadgeEl","rightBadgeEl","isVisibleInContainer","container","rect","getBoundingClientRect","cRect","bottom","top","parts","split","DEVIATION_BADGE_SEPARATOR","refId","Number","leftNumIdx","rightNumIdx","style","paddingTop","marginTop","leftContainer","rightContainer","lRect","rRect","badgeDiff","Math","abs","clearAlignmentOffsets","useCallback","leftIdx","rightIdx","includes","leftBadge","rightBadge","height","useEffect","resetSideBySide","activateSideBySide","isOrphan","options","toggleIfSame","onReady","sourceSide","isSameTarget","requestAnimationFrame","executeAlignment","leftEl","rightEl","getVisibleGuidelineTargets","leftSec","refIdxs","refIndexes","length","rhsSelfIndex","rhsArrayIdx","findIndex","s","selfIndex","finalizeSideBySide","dispatchEvent","Event","targetTop","scrollContainer","containerTop","nextTop","scrollTop","smoothScrollTo","leftAbsoluteTop","rightAbsoluteTop","ANIM_SPEED","rawRightTargetScroll","rightMaxScroll","scrollHeight","clientHeight","rightActualScroll","deficit","rawLeftTargetScroll","leftMaxScroll","leftActualScroll","setTimeout"],"mappings":"0RAIO,MAAMA,EAAgB,EACzBC,kBACAC,wBACAC,mBAAkBC,mBAClBC,mBAAkBC,oBAAmBC,qBACrCC,kBAAiBC,mBACjBC,qBAAoBC,sBACpBC,eAAcC,eACdC,iBAAgBC,sBAChBC,kBAAiBC,qBACjBC,kBAAiBC,qBACjBC,oBACAC,uBAAsBC,oBAAmBC,2BACzCC,0BAAyBC,gBACzBC,gBAAeC,wBAEf,MAAOC,EAAcC,GAAmBC,GAAS,IAC1CC,EAAgBC,GAAqBF,GAAS,IAC9CG,EAAYC,GAAiBJ,GAAS,IACtCK,EAAqBC,GAA0BN,GAAS,IACxDO,EAAyBC,GAA8BR,EAAiC,MAGzFS,EAAaC,GAAO,GACpBC,EAAqBD,EAAsH,MAC3IE,EAAkBF,GAAO,GACzBG,EAA6BH,EAA+B,MAC5DI,EAAkCJ,EAA+B,MACjEK,EAAoBL,EAA8B,MAClDM,EAAwBN,EAA6B,IAAAO,KAGrDC,EAAuB,KACHF,EAAAG,QAAQC,QAASC,IACnCC,EAAqBD,KAEzBL,EAAsBG,QAAQI,SAG5BC,EAAwB,CAACC,EAAgBC,EAAUC,KACrD,IAAIC,EAAoC,KACpCC,EAAqC,KACrCC,EAAkC,KAClCC,EAAmC,KACnCC,EAAkC,K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/C,EAAc6C,WAGrDK,EAAuB,GACnBnH,EAAgBiC,UAAYhD,IAC5Be,EAAgBiC,QAAQ6B,MAAMiB,OAAS,GAAGT,KAAKC,IAAI4C,QAG3D1B,sBAAsB,KACZ,MAAA2B,EAAiBlD,EAAemD,aAAenD,EAAeoD,aAChE,IAAAC,EAEJ,GAAIJ,EAAuB,EACHI,EAAA,MACxB,IAAWJ,EAAuBC,EAAgB,CAC9C,MAAMI,EAAUL,EAAuBC,EAMvC,OALInH,EAAmBgC,UAAYhD,IAC/BgB,EAAmBgC,QAAQ6B,MAAMiB,OAAS,GAAGyC,EAAU,cAC3D/B,sBAAsB,KACHsB,EAAA7C,EAAgBiD,EAAsBD,EAAYX,IAErE,CAEoBgB,EAAAJ,CACxB,CAEeJ,EAAA7C,EAAgBqD,EAAmBL,EAAYX,IACjE,KACE,CACG,MACAkB,EAAsBT,GADHC,EAAmB/C,EAAe4C,WAI3DrB,sBAAsB,KACZ,MAAAiC,EAAgBzD,EAAcoD,aAAepD,EAAcqD,aAC7D,IAAAK,EAEJ,GAAIF,EAAsB,EACHE,EAAA,MACvB,IAAWF,EAAsBC,EAE7B,YADAjC,sBAAsB,IAAMsB,EAAe9C,EAAeyD,EAAeR,EAAYX,IAGlEoB,EAAAF,CACvB,CACeV,EAAA9C,EAAe0D,EAAkBT,EAAYX,IAEpE,GAKAtH,EACA2I,WAAWlC,EAAkB,KAEZA,QAI7B,CACIrE,EACAb,EACApB,EACAwB,EACA1B,EACAC,EACAqF,GACAS,GACAhG,IAID,MAAA,CACH2B,eAAcC,kBACdE,iBAAgBC,oBAChBC,aAAYC,gBACZC,sBAAqBC,yBACrBC,0BAAyBC,6BACzBC,aACAE,qBACAC,kBACAC,6BACAC,kCACAC,oBACAC,wBACAE,uBACAM,wBACA2C,mBACAC"}
@@ -0,0 +1,2 @@
1
+ const t=t=>[t.requestId||"",t.citationId||t.href,t.highlightType||"both",t.citationType||""].join("|");export{t as buildOnDemandCitationCacheKey};
2
+ //# sourceMappingURL=cacheKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cacheKey.js","sources":["../../../../src/features/CognitiveCompare/onDemandCitations/cacheKey.ts"],"sourcesContent":["import { OnDemandCitationContext } from \"./types\";\n\nexport const buildOnDemandCitationCacheKey = (\n context: Pick<\n OnDemandCitationContext,\n \"requestId\" | \"citationId\" | \"href\" | \"highlightType\" | \"citationType\"\n >,\n) =>\n [\n context.requestId || \"\",\n context.citationId || context.href,\n context.highlightType || \"both\",\n context.citationType || \"\",\n ].join(\"|\");\n"],"names":["buildOnDemandCitationCacheKey","context","requestId","citationId","href","highlightType","citationType","join"],"mappings":"AAEa,MAAAA,EACXC,GAKA,CACEA,EAAQC,WAAa,GACrBD,EAAQE,YAAcF,EAAQG,KAC9BH,EAAQI,eAAiB,OACzBJ,EAAQK,cAAgB,IACxBC,KAAK"}
@@ -0,0 +1,2 @@
1
+ import{safeStringify as t,resolveComparisonInputItems as e}from"../CognitiveComparehelpers.js";import{extractCitationRequestsFromMarkdown as i,parseOnDemandCitationHref as n}from"./href.js";import{buildOnDemandCitationCacheKey as a}from"./cacheKey.js";const o=t=>t?.nodes||t||{},r=(t,e)=>{if(!e)return null;const i=o(t);return i?.[e]||null},d=({href:t,popupNodeId:e,treeData:i})=>{const a=n(t),r=o(i);return a.identifier&&r?.[a.identifier]?a.identifier:a.identifierNodeId&&r?.[a.identifierNodeId]?a.identifierNodeId:e||null},c=({treeData:i,node:n,sideIndex:a,role:o,citationEntry:r,preferredContentId:d})=>{const c=i.input_index_map||{},s=c[a];if(!s)return;const u=(({items:t,preferredContentId:e,treeData:i})=>{if(!e)return t[0]||null;const n=t.find(t=>t.contentId===e);if(n)return n;const a=i?.content_mapping?.[e];return a&&"object"==typeof a?{contentId:e,data:a,attributes:a.additional_attributes||{}}:t[0]||null})({items:e(n,a,c,i.content_mapping||{}),preferredContentId:d,treeData:i});if(!u)return;const p=i.documents?.[s]||{},f=u.attributes||{},m=f.pdf_start_page_number||r?.custom_metadata?.pdf_start_page_number,_=f.pdf_end_page_number||r?.custom_metadata?.pdf_end_page_number,l=t(p.source_uri||"");return{contract_uuid:s,contract_role:o,source_type:"text",content:{text:t(u.data?.content||u.data?.change_history||"")},...l?{gcs_source_link:l}:{},...m?{pdf_start_page_number:m}:{},..._?{pdf_end_page_number:_}:{}}},s=({treeData:t,nodeId:e,citationNumber:i,citationMap:n,baseContentId:a,compareContentIds:o})=>{if(!t||!e)return;const d=r(t,e);if(!d)return;const s=t.input_index_map||{},u=s[0],p=s[1],f=n?.[i]||{},m={},_=c({treeData:t,node:d,sideIndex:"0",role:"base",citationEntry:u?f[u]:null,preferredContentId:a}),l=c({treeData:t,node:d,sideIndex:"1",role:"compare",citationEntry:p?f[p]:null,preferredContentId:o?.[0]});return _&&(m.base=_),l&&(m.compare=l),m.base||m.compare?m:void 0},u=({treeData:e,content:o,requestId:c,tabKey:u="deviation",popupNodeId:p,deviationKey:f,sectionTitle:m,referenceSectionTitle:_,docData:l,staticCitations:I,deviationData:b,cognitiveData:g,baseContentId:h,compareContentIds:y})=>{const v=i(o),D=new Map,C=t(e?.comparison_id)||t(e?.comparisonId)||c||t(e?.msgRequestId);return v.forEach(t=>{const i=n(t.href),o=d({href:t.href,popupNodeId:p,treeData:e}),c=f||i.identifierDeviationKey||void 0,v=(({treeData:t,nodeId:e,tabKey:i,deviationKey:n,staticCitations:a,deviationData:o,cognitiveData:d})=>{const c=r(t,e);if("association"===i)return c?.mapping_rationale?.citations||d?.citations||a||{};const s=((t,e)=>{if(!t||"object"!=typeof t)return null;const i=e||"0";return t.deviation_entries?.[i]?t.deviation_entries[i]:t.deviations?.[i]?t.deviations[i]:t[i]?t[i]:t})(c?.evaluation_result,n);return s?.cognitive_decisioning?.citations||o?.cognitive_decisioning?.citations||a||{}})({treeData:e,nodeId:o,tabKey:u,deviationKey:c,staticCitations:I,deviationData:b,cognitiveData:g}),N=s({treeData:e,nodeId:o,citationNumber:t.citationNumber,citationMap:v,baseContentId:h,compareContentIds:y}),T=(({nodeId:t,citationNumber:e,deviationKey:i})=>{if(t)return`${t}:${i||"0"}:${e}`})({nodeId:o,citationNumber:t.citationNumber,deviationKey:c}),K=a({requestId:C,citationId:T,href:t.href,highlightType:t.highlightType||"both",citationType:t.citationType});D.has(K)||D.set(K,{requestId:C,citationNumber:t.citationNumber,citationId:T,href:t.href,citationLabel:t.citationLabel,citedText:t.citedText,highlightType:t.highlightType||"both",citationType:t.citationType,tabKey:u,sectionTitle:m,referenceSectionTitle:_,sources:N,docData:l,staticCitations:v,deviationData:b,cognitiveData:g})}),Array.from(D.values())};export{s as buildCitationSources,u as buildOnDemandCitationContexts,d as resolveCitationNodeId};
2
+ //# sourceMappingURL=contextBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextBuilder.js","sources":["../../../../src/features/CognitiveCompare/onDemandCitations/contextBuilder.ts"],"sourcesContent":["import {\n resolveComparisonInputItems,\n safeStringify,\n} from \"../CognitiveComparehelpers\";\nimport {\n BuildOnDemandCitationContextsParams,\n OnDemandCitationContext,\n OnDemandCitationSource,\n OnDemandCitationSources,\n OnDemandCitationTabKey,\n} from \"./types\";\nimport {\n extractCitationRequestsFromMarkdown,\n parseOnDemandCitationHref,\n} from \"./href\";\nimport { buildOnDemandCitationCacheKey } from \"./cacheKey\";\n\nconst getNodes = (treeData?: Record<string, any> | null) =>\n treeData?.nodes || treeData || {};\n\nconst getNode = (treeData: Record<string, any> | null | undefined, nodeId?: string | null) => {\n if (!nodeId) return null;\n const nodes = getNodes(treeData);\n return nodes?.[nodeId] || null;\n};\n\nexport const resolveCitationNodeId = ({\n href,\n popupNodeId,\n treeData,\n}: {\n href: string;\n popupNodeId?: string | null;\n treeData?: Record<string, any> | null;\n}) => {\n const details = parseOnDemandCitationHref(href);\n const nodes = getNodes(treeData);\n\n if (details.identifier && nodes?.[details.identifier]) {\n return details.identifier;\n }\n\n if (details.identifierNodeId && nodes?.[details.identifierNodeId]) {\n return details.identifierNodeId;\n }\n\n return popupNodeId || null;\n};\n\nconst getEvaluationEntry = (\n evaluationResult: any,\n deviationKey?: string | null,\n) => {\n if (!evaluationResult || typeof evaluationResult !== \"object\") return null;\n const key = deviationKey || \"0\";\n\n if (evaluationResult.deviation_entries?.[key]) {\n return evaluationResult.deviation_entries[key];\n }\n\n if (evaluationResult.deviations?.[key]) {\n return evaluationResult.deviations[key];\n }\n\n if (evaluationResult[key]) {\n return evaluationResult[key];\n }\n\n return evaluationResult;\n};\n\nconst resolveCitationMap = ({\n treeData,\n nodeId,\n tabKey,\n deviationKey,\n staticCitations,\n deviationData,\n cognitiveData,\n}: {\n treeData?: Record<string, any> | null;\n nodeId?: string | null;\n tabKey?: OnDemandCitationTabKey;\n deviationKey?: string | null;\n staticCitations?: Record<string, any>;\n deviationData?: Record<string, any> | null;\n cognitiveData?: Record<string, any> | null;\n}) => {\n const node = getNode(treeData, nodeId);\n\n if (tabKey === \"association\") {\n return (\n node?.mapping_rationale?.citations ||\n cognitiveData?.citations ||\n staticCitations ||\n {}\n );\n }\n\n const evaluationEntry = getEvaluationEntry(node?.evaluation_result, deviationKey);\n return (\n evaluationEntry?.cognitive_decisioning?.citations ||\n deviationData?.cognitive_decisioning?.citations ||\n staticCitations ||\n {}\n );\n};\n\nconst getPreferredContentItem = ({\n items,\n preferredContentId,\n treeData,\n}: {\n items: ReturnType<typeof resolveComparisonInputItems>;\n preferredContentId?: string;\n treeData?: Record<string, any> | null;\n}) => {\n if (!preferredContentId) return items[0] || null;\n\n const matchedItem = items.find((item) => item.contentId === preferredContentId);\n if (matchedItem) return matchedItem;\n\n const mapped = treeData?.content_mapping?.[preferredContentId];\n if (!mapped || typeof mapped !== \"object\") return items[0] || null;\n\n return {\n contentId: preferredContentId,\n data: mapped,\n attributes: mapped.additional_attributes || {},\n };\n};\n\nconst buildSource = ({\n treeData,\n node,\n sideIndex,\n role,\n citationEntry,\n preferredContentId,\n}: {\n treeData: Record<string, any>;\n node: Record<string, any>;\n sideIndex: \"0\" | \"1\";\n role: \"base\" | \"compare\";\n citationEntry?: Record<string, any> | null;\n preferredContentId?: string;\n}): OnDemandCitationSource | undefined => {\n const indexMap = treeData.input_index_map || {};\n const contractUuid = indexMap[sideIndex];\n if (!contractUuid) return undefined;\n\n const items = resolveComparisonInputItems(\n node,\n sideIndex,\n indexMap,\n treeData.content_mapping || {},\n );\n const item = getPreferredContentItem({ items, preferredContentId, treeData });\n if (!item) return undefined;\n\n const document = treeData.documents?.[contractUuid] || {};\n const attributes = item.attributes || {};\n const startPage =\n attributes.pdf_start_page_number ||\n citationEntry?.custom_metadata?.pdf_start_page_number;\n const endPage =\n attributes.pdf_end_page_number ||\n citationEntry?.custom_metadata?.pdf_end_page_number;\n const gcsSourceLink = safeStringify(document.source_uri || \"\");\n\n return {\n contract_uuid: contractUuid,\n contract_role: role,\n source_type: \"text\",\n content: {\n text: safeStringify(item.data?.content || item.data?.change_history || \"\"),\n },\n ...(gcsSourceLink ? { gcs_source_link: gcsSourceLink } : {}),\n ...(startPage ? { pdf_start_page_number: startPage } : {}),\n ...(endPage ? { pdf_end_page_number: endPage } : {}),\n };\n};\n\nexport const buildCitationSources = ({\n treeData,\n nodeId,\n citationNumber,\n citationMap,\n baseContentId,\n compareContentIds,\n}: {\n treeData?: Record<string, any> | null;\n nodeId?: string | null;\n citationNumber: string;\n citationMap?: Record<string, any> | null;\n baseContentId?: string;\n compareContentIds?: string[];\n}): OnDemandCitationSources | undefined => {\n if (!treeData || !nodeId) return undefined;\n\n const node = getNode(treeData, nodeId);\n if (!node) return undefined;\n\n const indexMap = treeData.input_index_map || {};\n const baseUuid = indexMap[\"0\"];\n const compareUuid = indexMap[\"1\"];\n const citationGroup = citationMap?.[citationNumber] || {};\n const sources: OnDemandCitationSources = {};\n\n const baseSource = buildSource({\n treeData,\n node,\n sideIndex: \"0\",\n role: \"base\",\n citationEntry: baseUuid ? citationGroup[baseUuid] : null,\n preferredContentId: baseContentId,\n });\n const compareSource = buildSource({\n treeData,\n node,\n sideIndex: \"1\",\n role: \"compare\",\n citationEntry: compareUuid ? citationGroup[compareUuid] : null,\n preferredContentId: compareContentIds?.[0],\n });\n\n if (baseSource) sources.base = baseSource;\n if (compareSource) sources.compare = compareSource;\n\n return sources.base || sources.compare ? sources : undefined;\n};\n\nconst buildCitationId = ({\n nodeId,\n citationNumber,\n deviationKey,\n}: {\n nodeId?: string | null;\n citationNumber: string;\n deviationKey?: string | null;\n}) => {\n if (!nodeId) return undefined;\n return `${nodeId}:${deviationKey || \"0\"}:${citationNumber}`;\n};\n\nexport const buildOnDemandCitationContexts = ({\n treeData,\n content,\n requestId,\n tabKey = \"deviation\",\n popupNodeId,\n deviationKey,\n sectionTitle,\n referenceSectionTitle,\n docData,\n staticCitations,\n deviationData,\n cognitiveData,\n baseContentId,\n compareContentIds,\n}: BuildOnDemandCitationContextsParams): OnDemandCitationContext[] => {\n const links = extractCitationRequestsFromMarkdown(content);\n const contexts = new Map<string, OnDemandCitationContext>();\n const resolvedRequestId =\n safeStringify(treeData?.comparison_id) ||\n safeStringify(treeData?.comparisonId) ||\n requestId ||\n safeStringify(treeData?.msgRequestId);\n\n links.forEach((link) => {\n const details = parseOnDemandCitationHref(link.href);\n const resolvedNodeId = resolveCitationNodeId({\n href: link.href,\n popupNodeId,\n treeData,\n });\n const resolvedDeviationKey =\n deviationKey || details.identifierDeviationKey || undefined;\n const citationMap = resolveCitationMap({\n treeData,\n nodeId: resolvedNodeId,\n tabKey,\n deviationKey: resolvedDeviationKey,\n staticCitations,\n deviationData,\n cognitiveData,\n });\n const sources = buildCitationSources({\n treeData,\n nodeId: resolvedNodeId,\n citationNumber: link.citationNumber,\n citationMap,\n baseContentId,\n compareContentIds,\n });\n const citationId = buildCitationId({\n nodeId: resolvedNodeId,\n citationNumber: link.citationNumber,\n deviationKey: resolvedDeviationKey,\n });\n const cacheKey = buildOnDemandCitationCacheKey({\n requestId: resolvedRequestId,\n citationId,\n href: link.href,\n highlightType: link.highlightType || \"both\",\n citationType: link.citationType,\n });\n\n if (contexts.has(cacheKey)) return;\n\n contexts.set(cacheKey, {\n requestId: resolvedRequestId,\n citationNumber: link.citationNumber,\n citationId,\n href: link.href,\n citationLabel: link.citationLabel,\n citedText: link.citedText,\n highlightType: link.highlightType || \"both\",\n citationType: link.citationType,\n tabKey,\n sectionTitle,\n referenceSectionTitle,\n sources,\n docData,\n staticCitations: citationMap,\n deviationData,\n cognitiveData,\n });\n });\n\n return Array.from(contexts.values());\n};\n"],"names":["getNodes","treeData","nodes","getNode","nodeId","resolveCitationNodeId","href","popupNodeId","details","parseOnDemandCitationHref","identifier","identifierNodeId","buildSource","node","sideIndex","role","citationEntry","preferredContentId","indexMap","input_index_map","contractUuid","item","items","matchedItem","find","contentId","mapped","content_mapping","data","attributes","additional_attributes","getPreferredContentItem","resolveComparisonInputItems","document","documents","startPage","pdf_start_page_number","custom_metadata","endPage","pdf_end_page_number","gcsSourceLink","safeStringify","source_uri","contract_uuid","contract_role","source_type","content","text","change_history","gcs_source_link","buildCitationSources","citationNumber","citationMap","baseContentId","compareContentIds","baseUuid","compareUuid","citationGroup","sources","baseSource","compareSource","base","compare","buildOnDemandCitationContexts","requestId","tabKey","deviationKey","sectionTitle","referenceSectionTitle","docData","staticCitations","deviationData","cognitiveData","links","extractCitationRequestsFromMarkdown","contexts","Map","resolvedRequestId","comparison_id","comparisonId","msgRequestId","forEach","link","resolvedNodeId","resolvedDeviationKey","identifierDeviationKey","mapping_rationale","citations","evaluationEntry","evaluationResult","key","deviation_entries","deviations","getEvaluationEntry","evaluation_result","cognitive_decisioning","resolveCitationMap","citationId","buildCitationId","cacheKey","buildOnDemandCitationCacheKey","highlightType","citationType","has","set","citationLabel","citedText","Array","from","values"],"mappings":"4PAiBA,MAAMA,EAAYC,GAChBA,GAAUC,OAASD,GAAY,CAAA,EAE3BE,EAAU,CAACF,EAAkDG,KAC7D,IAACA,EAAe,OAAA,KACd,MAAAF,EAAQF,EAASC,GAChB,OAAAC,IAAQE,IAAW,MAGfC,EAA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Comparehelpers.js";const e=/\[([^\]]+)\]\(([^)]+)\)/g,i=/<a\b[^>]*href=(["'])(.*?)\1[^>]*>([\s\S]*?)<\/a>/gi,r=e=>t(e).trim().replace(/\\&/g,"&").replace(/&amp;/g,"&"),n=e=>t(e).replace(/<[^>]*>/g,"").trim(),a=(t,e)=>{const i=t.lastIndexOf("\n",e),r=t.indexOf("\n",e),n=-1===i?0:i+1,a=-1===r?t.length:r;return t.slice(n,a).trim()||t.trim()},o=t=>{const e=r(t).match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);return e?.[1]||null},c=t=>{const e=(t=>{const e=r(t);return[...e.split("$")].reverse().find(t=>t.startsWith("./")||t.startsWith("/")||/^https?:\/\//i.test(t))||e})(t),i=(t=>{try{return new URL(t,"http://localhost")}catch{return null}})(e),n=(a=i)&&decodeURIComponent(a.pathname.replace(/^\/+/,""))||null;var a;const c=n?.split(":")||[];return{hrefForUrl:e,citationNumber:i?.searchParams.get("citationNumber")||i?.searchParams.get("citation_number")||null||o(t),highlightType:i?.searchParams.get("highlight_type")||i?.searchParams.get("citationSource")||null,citationType:i?.searchParams.get("citation_type")||i?.searchParams.get("type")||null,identifier:n,identifierNodeId:c[0]||null,identifierDeviationKey:c.length>1?c[1]:null}},h=t=>{const e=r(t);return[e,c(e).citationNumber||""].join("|")},l=o=>{const h=(e=>Array.isArray(e)?e.filter(Boolean).join("\n\n"):t(e))(o),l=[];return h.replace(e,(t,e,i,o)=>{const s=c(i);return s.citationNumber&&l.push({href:r(i),citationNumber:s.citationNumber,citationLabel:n(e),citedText:a(h,o),highlightType:s.highlightType||void 0,citationType:s.citationType||void 0,rawMatch:t,index:o}),t}),h.replace(i,(t,e,i,o,s)=>{const p=c(i);return p.citationNumber&&l.push({href:r(i),citationNumber:p.citationNumber,citationLabel:n(o),citedText:a(h,s),highlightType:p.highlightType||void 0,citationType:p.citationType||void 0,rawMatch:t,index:s}),t}),l.sort((t,e)=>t.index-e.index)};export{l as extractCitationRequestsFromMarkdown,h as getOnDemandCitationLinkKey,r as normalizeOnDemandCitationHref,c as parseOnDemandCitationHref};
2
+ //# sourceMappingURL=href.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"href.js","sources":["../../../../src/features/CognitiveCompare/onDemandCitations/href.ts"],"sourcesContent":["import { safeStringify } from \"../CognitiveComparehelpers\";\nimport {\n ExtractedOnDemandCitationLink,\n ParsedOnDemandCitationHref,\n} from \"./types\";\n\nconst MARKDOWN_LINK_REGEX = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\nconst HTML_ANCHOR_REGEX =\n /<a\\b[^>]*href=([\"'])(.*?)\\1[^>]*>([\\s\\S]*?)<\\/a>/gi;\nconst DEFAULT_BASE_URL = \"http://localhost\";\n\nexport const normalizeOnDemandCitationHref = (href: string) =>\n safeStringify(href).trim().replace(/\\\\&/g, \"&\").replace(/&amp;/g, \"&\");\n\nconst stripHtml = (value: string) =>\n safeStringify(value).replace(/<[^>]*>/g, \"\").trim();\n\nconst normalizeContent = (content?: string | string[] | null) =>\n Array.isArray(content) ? content.filter(Boolean).join(\"\\n\\n\") : safeStringify(content);\n\nconst getCitedTextAtIndex = (content: string, index: number) => {\n const previousBreak = content.lastIndexOf(\"\\n\", index);\n const nextBreak = content.indexOf(\"\\n\", index);\n const start = previousBreak === -1 ? 0 : previousBreak + 1;\n const end = nextBreak === -1 ? content.length : nextBreak;\n const line = content.slice(start, end).trim();\n\n return line || content.trim();\n};\n\nconst getHrefForUrlParsing = (href: string) => {\n const normalizedHref = normalizeOnDemandCitationHref(href);\n const parts = normalizedHref.split(\"$\");\n const pathPart = [...parts]\n .reverse()\n .find((part) => part.startsWith(\"./\") || part.startsWith(\"/\") || /^https?:\\/\\//i.test(part));\n\n return pathPart || normalizedHref;\n};\n\nconst getUrl = (href: string) => {\n try {\n return new URL(href, DEFAULT_BASE_URL);\n } catch {\n return null;\n }\n};\n\nconst getPathIdentifier = (url: URL | null) => {\n if (!url) return null;\n const identifier = decodeURIComponent(url.pathname.replace(/^\\/+/, \"\"));\n return identifier || null;\n};\n\nconst getPrefixedCitationNumber = (href: string) => {\n const match = normalizeOnDemandCitationHref(href).match(/^(?:pdf_citation|deviation_summary)\\$(\\d+)/);\n return match?.[1] || null;\n};\n\nexport const parseOnDemandCitationHref = (href: string): ParsedOnDemandCitationHref => {\n const hrefForUrl = getHrefForUrlParsing(href);\n const parsedUrl = getUrl(hrefForUrl);\n const identifier = getPathIdentifier(parsedUrl);\n const identifierParts = identifier?.split(\":\") || [];\n const queryCitationNumber =\n parsedUrl?.searchParams.get(\"citationNumber\") ||\n parsedUrl?.searchParams.get(\"citation_number\") ||\n null;\n\n return {\n hrefForUrl,\n citationNumber: queryCitationNumber || getPrefixedCitationNumber(href),\n highlightType:\n parsedUrl?.searchParams.get(\"highlight_type\") ||\n parsedUrl?.searchParams.get(\"citationSource\") ||\n null,\n citationType:\n parsedUrl?.searchParams.get(\"citation_type\") ||\n parsedUrl?.searchParams.get(\"type\") ||\n null,\n identifier,\n identifierNodeId: identifierParts[0] || null,\n identifierDeviationKey: identifierParts.length > 1 ? identifierParts[1] : null,\n };\n};\n\nexport const getOnDemandCitationLinkKey = (href: string) => {\n const normalized = normalizeOnDemandCitationHref(href);\n const details = parseOnDemandCitationHref(normalized);\n return [normalized, details.citationNumber || \"\"].join(\"|\");\n};\n\nexport const extractCitationRequestsFromMarkdown = (\n content?: string | string[] | null,\n): ExtractedOnDemandCitationLink[] => {\n const normalizedContent = normalizeContent(content);\n const links: ExtractedOnDemandCitationLink[] = [];\n\n normalizedContent.replace(MARKDOWN_LINK_REGEX, (rawMatch, label, href, index) => {\n const details = parseOnDemandCitationHref(href);\n if (details.citationNumber) {\n links.push({\n href: normalizeOnDemandCitationHref(href),\n citationNumber: details.citationNumber,\n citationLabel: stripHtml(label),\n citedText: getCitedTextAtIndex(normalizedContent, index),\n highlightType: details.highlightType || undefined,\n citationType: details.citationType || undefined,\n rawMatch,\n index,\n });\n }\n return rawMatch;\n });\n\n normalizedContent.replace(HTML_ANCHOR_REGEX, (rawMatch, _quote, href, label, index) => {\n const details = parseOnDemandCitationHref(href);\n if (details.citationNumber) {\n links.push({\n href: normalizeOnDemandCitationHref(href),\n citationNumber: details.citationNumber,\n citationLabel: stripHtml(label),\n citedText: getCitedTextAtIndex(normalizedContent, index),\n highlightType: details.highlightType || undefined,\n citationType: details.citationType || undefined,\n rawMatch,\n index,\n });\n }\n return rawMatch;\n });\n\n return links.sort((a, b) => a.index - b.index);\n};\n"],"names":["MARKDOWN_LINK_REGEX","HTML_ANCHOR_REGEX","normalizeOnDemandCitationHref","href","safeStringify","trim","replace","stripHtml","value","getCitedTextAtIndex","content","index","previousBreak","lastIndexOf","nextBreak","indexOf","start","end","length","slice","getPrefixedCitationNumber","match","parseOnDemandCitationHref","hrefForUrl","normalizedHref","split","reverse","find","part","startsWith","test","getHrefForUrlParsing","parsedUrl","URL","getUrl","identifier","url","decodeURIComponent","pathname","identifierParts","citationNumber","searchParams","get","highlightType","citationType","identifierNodeId","identifierDeviationKey","getOnDemandCitationLinkKey","normalized","join","extractCitationRequestsFromMarkdown","normalizedContent","Array","isArray","filter","Boolean","normalizeContent","links","rawMatch","label","details","push","citationLabel","citedText","_quote","sort","a","b"],"mappings":"8DAMA,MAAMA,EAAsB,2BACtBC,EACJ,qDAGWC,EAAiCC,GAC5CC,EAAcD,GAAME,OAAOC,QAAQ,OAAQ,KAAKA,QAAQ,SAAU,KAE9DC,EAAaC,GACjBJ,EAAcI,GAAOF,QAAQ,WAAY,IAAID,OAKzCI,EAAsB,CAACC,EAAiBC,KAC5C,MAAMC,EAAgBF,EAAQG,YAAY,KAAMF,GAC1CG,EAAYJ,EAAQK,QAAQ,KAAMJ,GAClCK,GAA+B,IAAvBJ,EAAuB,EAAIA,EAAgB,EACnDK,GAAyB,IAAnBH,EAAmBJ,EAAQQ,OAASJ,EAGzC,OAFMJ,EAAQS,MAAMH,EAAOC,GAAKZ,QAExBK,EAAQL,QA2BnBe,EAA6BjB,IACjC,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,KAC/D,MAAAiD,EAAUtC,EAA0BnB,GAanC,OAZHyD,EAAQpB,gBACViB,EAAMI,KAAK,CACT1D,KAAMD,EAA8BC,GACpCqC,eAAgBoB,EAAQpB,eACxBsB,cAAevD,EAAUoD,GACzBI,UAAWtD,EAAoB0C,EAAmBxC,GAClDgC,cAAeiB,EAAQjB,oBAAiB,EACxCC,aAAcgB,EAAQhB,mBAAgB,EACtCc,WACA/C,UAGG+C,IAGTP,EAAkB7C,QAAQL,EAAmB,CAACyD,EAAUM,EAAQ7D,EAAMwD,EAAOhD,KACrE,MAAAiD,EAAUtC,EAA0BnB,GAanC,OAZHyD,EAAQpB,gBACViB,EAAMI,KAAK,CACT1D,KAAMD,EAA8BC,GACpCqC,eAAgBoB,EAAQpB,eACxBsB,cAAevD,EAAUoD,GACzBI,UAAWtD,EAAoB0C,EAAmBxC,GAClDgC,cAAeiB,EAAQjB,oBAAiB,EACxCC,aAAcgB,EAAQhB,mBAAgB,EACtCc,WACA/C,UAGG+C,IAGFD,EAAMQ,KAAK,CAACC,EAAGC,IAAMD,EAAEvD,MAAQwD,EAAExD"}
@@ -0,0 +1,2 @@
1
+ const t=(t,e)=>{return{name:t.identity.name,organizationName:t.identity.organizationName,prompt:"",useAgent:{agent_name:t.identity.agentName,metadata:(a=t.identity,"string"==typeof a.metadata?a.metadata:a.metadata?JSON.stringify(a.metadata):JSON.stringify({userName:a.userName,userEmailId:a.userEmailId})),arguments:{citation_type:t.citationType||"redline_citation",is_primary_agent_request:!1,ui_request_body:{request_id:e.requestId,citation_id:e.citationId,cited_text:e.citedText,highlight_type:e.highlightType||"both",sources:e.sources}}}};var a},e=(e,a)=>{const i=t(e,a);return e.buildPayload?.(i,a)??i};export{t as buildDefaultOnDemandCitationPayload,e as buildOnDemandCitationPayload};
2
+ //# sourceMappingURL=payload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payload.js","sources":["../../../../src/features/CognitiveCompare/onDemandCitations/payload.ts"],"sourcesContent":["import {\n CognitiveCompareCitationPayload,\n CognitiveCompareOnDemandCitationConfig,\n OnDemandCitationContext,\n} from \"./types\";\n\nconst getIdentityMetadata = (\n identity: CognitiveCompareOnDemandCitationConfig[\"identity\"],\n) => {\n if (typeof identity.metadata === \"string\") return identity.metadata;\n if (identity.metadata) return JSON.stringify(identity.metadata);\n\n return JSON.stringify({\n userName: identity.userName,\n userEmailId: identity.userEmailId,\n });\n};\n\nexport const buildDefaultOnDemandCitationPayload = (\n config: CognitiveCompareOnDemandCitationConfig,\n context: OnDemandCitationContext,\n): CognitiveCompareCitationPayload => ({\n name: config.identity.name,\n organizationName: config.identity.organizationName,\n prompt: \"\",\n useAgent: {\n agent_name: config.identity.agentName,\n metadata: getIdentityMetadata(config.identity),\n arguments: {\n citation_type: config.citationType || \"redline_citation\",\n is_primary_agent_request: false,\n ui_request_body: {\n request_id: context.requestId,\n citation_id: context.citationId,\n cited_text: context.citedText,\n highlight_type: context.highlightType || \"both\",\n sources: context.sources,\n },\n },\n },\n});\n\nexport const buildOnDemandCitationPayload = (\n config: CognitiveCompareOnDemandCitationConfig,\n context: OnDemandCitationContext,\n) => {\n const defaultPayload = buildDefaultOnDemandCitationPayload(config, context);\n return config.buildPayload?.(defaultPayload, context) ?? defaultPayload;\n};\n"],"names":["buildDefaultOnDemandCitationPayload","config","context","name","identity","organizationName","prompt","useAgent","agent_name","agentName","metadata","JSON","stringify","userName","userEmailId","arguments","citation_type","citationType","is_primary_agent_request","ui_request_body","request_id","requestId","citation_id","citationId","cited_text","citedText","highlight_type","highlightType","sources","buildOnDemandCitationPayload","defaultPayload","buildPayload"],"mappings":"AAMA,MAYaA,EAAsC,CACjDC,EACAC,KACqC,OACrCC,KAAMF,EAAOG,SAASD,KACtBE,iBAAkBJ,EAAOG,SAASC,iBAClCC,OAAQ,GACRC,SAAU,CACRC,WAAYP,EAAOG,SAASK,UAC5BC,UApBFN,EAoBgCH,EAAOG,SAlBN,iBAAtBA,EAASM,SAA8BN,EAASM,SACvDN,EAASM,SAAiBC,KAAKC,UAAUR,EAASM,UAE/CC,KAAKC,UAAU,CACpBC,SAAUT,EAASS,SACnBC,YAAaV,EAASU,eActBC,UAAW,CACTC,cAAef,EAAOgB,cAAgB,mBACtCC,0BAA0B,EAC1BC,gBAAiB,CACfC,WAAYlB,EAAQmB,UACpBC,YAAapB,EAAQqB,WACrBC,WAAYtB,EAAQuB,UACpBC,eAAgBxB,EAAQyB,eAAiB,OACzCC,QAAS1B,EAAQ0B,YA9BG,IAC1BxB,GAmCWyB,EAA+B,CAC1C5B,EACAC,KAEM,MAAA4B,EAAiB9B,EAAoCC,EAAQC,GACnE,OAAOD,EAAO8B,eAAeD,EAAgB5B,IAAY4B"}
@@ -0,0 +1,2 @@
1
+ import{safeStringify as t}from"../CognitiveComparehelpers.js";const i=(i,n)=>{const e=((i,n)=>{const e=(t=>{const i=t?.result||t?.responseData?.result||t?.responseData||t;return[i?.citations,i?.annotations?.flatMap(t=>t?.citations||[]),t?.citations].flat().filter(t=>t&&"object"==typeof t)})(i);return e.find(t=>t.citation_id===n.citationId)||e.find(i=>t(i.node_uuid)===t(n.citationId?.split(":")[0])&&t(i.dev_index)===t(n.citationId?.split(":")[1]||"0")&&t(i.citation_number)===t(n.citationNumber))||e.find(i=>t(i.citation_number)===t(n.citationNumber))||null})(i,n),a=t(n.citationNumber||e?.citation_number),o=e?.citations;if(!a||!o||"object"!=typeof o)return{};const r=n.docData?.documents||{},s=Object.entries(o).reduce((t,[i,n])=>{const e=r?.[i],a={...n?.customMetaData||{},...n?.custom_metadata||{}},o=a.signed_url||e?.signed_url||e?.signedUrl||e?.metadata?.signed_url||e?.metadata?.signedUrl;return t[i]={...n,custom_metadata:{...a,...a.signed_url||!o?{}:{signed_url:o}}},t},{});return{[a]:s}};export{i as normalizeOnDemandCitationResponse};
2
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sources":["../../../../src/features/CognitiveCompare/onDemandCitations/response.ts"],"sourcesContent":["import { safeStringify } from \"../CognitiveComparehelpers\";\nimport {\n NormalizedOnDemandCitationMap,\n OnDemandCitationContext,\n} from \"./types\";\n\nconst getCitationItemsFromResponse = (response: any): any[] => {\n const result = response?.result || response?.responseData?.result || response?.responseData || response;\n const citationSources = [\n result?.citations,\n result?.annotations?.flatMap((annotation: any) => annotation?.citations || []),\n response?.citations,\n ];\n\n return citationSources\n .flat()\n .filter((citation: any) => citation && typeof citation === \"object\");\n};\n\nconst findMatchingResponseCitation = (\n response: any,\n context: OnDemandCitationContext,\n) => {\n const citationItems = getCitationItemsFromResponse(response);\n\n return (\n citationItems.find((citation) => citation.citation_id === context.citationId) ||\n citationItems.find(\n (citation) =>\n safeStringify(citation.node_uuid) === safeStringify(context.citationId?.split(\":\")[0]) &&\n safeStringify(citation.dev_index) === safeStringify(context.citationId?.split(\":\")[1] || \"0\") &&\n safeStringify(citation.citation_number) === safeStringify(context.citationNumber),\n ) ||\n citationItems.find(\n (citation) =>\n safeStringify(citation.citation_number) === safeStringify(context.citationNumber),\n ) ||\n null\n );\n};\n\nexport const normalizeOnDemandCitationResponse = (\n response: any,\n context: OnDemandCitationContext,\n): NormalizedOnDemandCitationMap => {\n const matchedCitation = findMatchingResponseCitation(response, context);\n const citationNumber = safeStringify(\n context.citationNumber || matchedCitation?.citation_number,\n );\n const citations = matchedCitation?.citations;\n\n if (!citationNumber || !citations || typeof citations !== \"object\") {\n return {};\n }\n\n const documents = context.docData?.documents || {};\n const enrichedCitations = Object.entries(citations).reduce(\n (acc, [documentUuid, citationValue]: [string, any]) => {\n const document = documents?.[documentUuid];\n const customMetadata = {\n ...(citationValue?.customMetaData || {}),\n ...(citationValue?.custom_metadata || {}),\n };\n const signedUrl =\n customMetadata.signed_url ||\n document?.signed_url ||\n document?.signedUrl ||\n document?.metadata?.signed_url ||\n document?.metadata?.signedUrl;\n acc[documentUuid] = {\n ...citationValue,\n custom_metadata: {\n ...customMetadata,\n ...(customMetadata.signed_url || !signedUrl\n ? {}\n : { signed_url: signedUrl }),\n },\n };\n return acc;\n },\n {} as Record<string, any>,\n );\n\n return {\n [citationNumber]: enrichedCitations,\n };\n};\n"],"names":["normalizeOnDemandCitationResponse","response","context","matchedCitation","citationItems","result","responseData","citations","annotations","flatMap","annotation","flat","filter","citation","getCitationItemsFromResponse","find","citation_id","citationId","safeStringify","node_uuid","split","dev_index","citation_number","citationNumber","findMatchingResponseCitation","documents","docData","enrichedCitations","Object","entries","reduce","acc","documentUuid","citationValue","document","customMetadata","customMetaData","custom_metadata","signedUrl","signed_url","metadata"],"mappings":"8DAMA,MAmCaA,EAAoC,CAC/CC,EACAC,KAEM,MAAAC,EA1B6B,EACnCF,EACAC,KAEM,MAAAE,EAjB6B,CAACH,IACpC,MAAMI,EAASJ,GAAUI,QAAUJ,GAAUK,cAAcD,QAAUJ,GAAUK,cAAgBL,EAOxF,MANiB,CACtBI,GAAQE,UACRF,GAAQG,aAAaC,QAASC,GAAoBA,GAAYH,WAAa,IAC3EN,GAAUM,WAITI,OACAC,OAAQC,GAAkBA,GAAgC,iBAAbA,IAO1BC,CAA6Bb,GAGjD,OAAAG,EAAcW,KAAMF,GAAaA,EAASG,cAAgBd,EAAQe,aAClEb,EAAcW,KACXF,GACCK,EAAcL,EAASM,aAAeD,EAAchB,EAAQe,YAAYG,MAAM,KAAK,KACnFF,EAAcL,EAASQ,aAAeH,EAAchB,EAAQe,YAAYG,MAAM,KAAK,IAAM,MACzFF,EAAcL,EAASS,mBAAqBJ,EAAchB,EAAQqB,kBAEtEnB,EAAcW,KACXF,GACCK,EAAcL,EAASS,mBAAqBJ,EAAchB,EAAQqB,kBAEtE,MAQsBC,CAA6BvB,EAAUC,GACzDqB,EAAiBL,EACrBhB,EAAQqB,gBAAkBpB,GAAiBmB,iBAEvCf,EAAYJ,GAAiBI,UAEnC,IAAKgB,IAAmBhB,GAAkC,iBAAdA,EAC1C,MAAO,GAGT,MAAMkB,EAAYvB,EAAQwB,SAASD,WAAa,CAAA,EAC1CE,EAAoBC,OAAOC,QAAQtB,GAAWuB,OAClD,CAACC,GAAMC,EAAcC,MACb,MAAAC,EAAWT,IAAYO,GACvBG,EAAiB,IACjBF,GAAeG,gBAAkB,CAAC,KAClCH,GAAeI,iBAAmB,CAAC,GAEnCC,EACJH,EAAeI,YACfL,GAAUK,YACVL,GAAUI,WACVJ,GAAUM,UAAUD,YACpBL,GAAUM,UAAUF,UAUf,OATPP,EAAIC,GAAgB,IACfC,EACHI,gBAAiB,IACZF,KACCA,EAAeI,aAAeD,EAC9B,CAAA,EACA,CAAEC,WAAYD,KAGfP,GAET,CAAC,GAGI,MAAA,CACLR,CAACA,GAAiBI"}
@@ -0,0 +1,2 @@
1
+ const t=(t,e=t.length)=>{const n=[];for(let l=0;l<e;l+=1){if("|"!==t[l])continue;let e=0;for(let n=l-1;n>=0&&"\\"===t[n];n-=1)e+=1;e%2==0&&n.push(l)}return n},e=e=>e.split("\n").map(e=>{const n=/\|(?:[ \t]*:?-{3,}:?[ \t]*\|){2,}/.exec(e);if(void 0===n?.index)return e;const l=t(n[0]).length-1;if(l<2)return e;const i=t(e,n.index),r=l+1;if(i.length<r)return e;const c=i[i.length-r],s=e.slice(0,c).trimEnd(),o=e.slice(c),h=t(o);let f="",g=0;h.forEach((t,e)=>{if(f+=o.slice(g,t+1),g=t+1,(e+1)%r!==0)return;const n=o.slice(g).match(/^[ \t]*/)?.[0]??"";"|"===o[g+n.length]&&(f+="\n",g+=n.length)}),f+=o.slice(g);const p=f.split("\n");let u=!1;for(let t=0;t<p.length;t+=1){const e=p[t].trim().replace(/^\||\|$/g,"").split("|").map(t=>t.trim());e.length===l&&e.every(t=>/^:?-{3,}:?$/.test(t))&&(u&&t>0&&""!==p[t-1]&&(p.splice(t-1,0,""),t+=1),u=!0)}return f=p.join("\n"),s?`${s}\n\n${f}`:f}).join("\n");export{e as normalizeCompactedGfmTables};
2
+ //# sourceMappingURL=normalizeCompactedGfmTables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeCompactedGfmTables.js","sources":["../../../../src/features/CognitiveCompare/utils/normalizeCompactedGfmTables.ts"],"sourcesContent":["const unescapedPipeOffsets = (value: string, end = value.length) => {\n const offsets: number[] = [];\n for (let index = 0; index < end; index += 1) {\n if (value[index] !== \"|\") continue;\n let backslashes = 0;\n for (let cursor = index - 1; cursor >= 0 && value[cursor] === \"\\\\\"; cursor -= 1) {\n backslashes += 1;\n }\n if (backslashes % 2 === 0) offsets.push(index);\n }\n return offsets;\n};\n\n/**\n * Restore row boundaries when upstream flattened a complete GFM table onto one\n * physical line. The delimiter row makes the table and its column count\n * unambiguous; ordinary prose containing pipes is left unchanged.\n */\nexport const normalizeCompactedGfmTables = (source: string): string =>\n source.split(\"\\n\").map((line) => {\n const delimiter = /\\|(?:[ \\t]*:?-{3,}:?[ \\t]*\\|){2,}/.exec(line);\n if (delimiter?.index === undefined) return line;\n\n const delimiterPipes = unescapedPipeOffsets(delimiter[0]);\n const columnCount = delimiterPipes.length - 1;\n if (columnCount < 2) return line;\n\n const pipesBeforeDelimiter = unescapedPipeOffsets(line, delimiter.index);\n const pipesPerRow = columnCount + 1;\n if (pipesBeforeDelimiter.length < pipesPerRow) return line;\n const tableStart = pipesBeforeDelimiter[pipesBeforeDelimiter.length - pipesPerRow];\n\n const prefix = line.slice(0, tableStart).trimEnd();\n const compactTable = line.slice(tableStart);\n const pipeOffsets = unescapedPipeOffsets(compactTable);\n let rebuilt = \"\";\n let cursor = 0;\n\n pipeOffsets.forEach((pipeOffset, pipeIndex) => {\n rebuilt += compactTable.slice(cursor, pipeOffset + 1);\n cursor = pipeOffset + 1;\n if ((pipeIndex + 1) % pipesPerRow !== 0) return;\n\n const whitespace = compactTable.slice(cursor).match(/^[ \\t]*/)?.[0] ?? \"\";\n if (compactTable[cursor + whitespace.length] === \"|\") {\n rebuilt += \"\\n\";\n cursor += whitespace.length;\n }\n });\n rebuilt += compactTable.slice(cursor);\n\n const rebuiltLines = rebuilt.split(\"\\n\");\n let hasSeenDelimiter = false;\n\n for (let lineIndex = 0; lineIndex < rebuiltLines.length; lineIndex += 1) {\n const cells = rebuiltLines[lineIndex]\n .trim()\n .replace(/^\\||\\|$/g, \"\")\n .split(\"|\")\n .map((cell) => cell.trim());\n const isDelimiterRow =\n cells.length === columnCount &&\n cells.every((cell) => /^:?-{3,}:?$/.test(cell));\n\n if (!isDelimiterRow) continue;\n\n if (hasSeenDelimiter && lineIndex > 0 && rebuiltLines[lineIndex - 1] !== \"\") {\n rebuiltLines.splice(lineIndex - 1, 0, \"\");\n lineIndex += 1;\n }\n hasSeenDelimiter = true;\n }\n\n rebuilt = rebuiltLines.join(\"\\n\");\n\n return prefix ? `${prefix}\\n\\n${rebuilt}` : rebuilt;\n }).join(\"\\n\");\n"],"names":["unescapedPipeOffsets","value","end","length","offsets","index","backslashes","cursor","push","normalizeCompactedGfmTables","source","split","map","line","delimiter","exec","columnCount","pipesBeforeDelimiter","pipesPerRow","tableStart","prefix","slice","trimEnd","compactTable","pipeOffsets","rebuilt","forEach","pipeOffset","pipeIndex","whitespace","match","rebuiltLines","hasSeenDelimiter","lineIndex","cells","trim","replace","cell","every","test","splice","join"],"mappings":"AAAA,MAAMA,EAAuB,CAACC,EAAeC,EAAMD,EAAME,UACvD,MAAMC,EAAoB,GAC1B,IAAA,IAASC,EAAQ,EAAGA,EAAQH,EAAKG,GAAS,EAAG,CACvC,GAAiB,MAAjBJ,EAAMI,GAAgB,SAC1B,IAAIC,EAAc,EACT,IAAA,IAAAC,EAASF,EAAQ,EAAGE,GAAU,GAAuB,OAAlBN,EAAMM,GAAkBA,GAAU,EAC7DD,GAAA,EAEbA,EAAc,GAAM,GAAGF,EAAQI,KAAKH,EAC1C,CACO,OAAAD,GAQIK,EAA+BC,GAC1CA,EAAOC,MAAM,MAAMC,IAAKC,IAChB,MAAAC,EAAY,oCAAoCC,KAAKF,GACvD,QAAqB,IAArBC,GAAWT,MAA4B,OAAAQ,EAE3C,MACMG,EADiBhB,EAAqBc,EAAU,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*/g,"$1"),n=n.replace(/__([^_]*?)__/g,"$1"),n=n.replace(/\*([^*]*?)\*/g,"$1"),n=n.replace(/_([^_]*?)_/g,"$1"),n=n.replace(/~~([^~]*?)~~/g,"$1"),n=n.replace(/`([^`]*?)`/g,"$1"),n=n.replace(/\[([^\]]*?)\]\([^)]*?\)/g,"$1"),n=n.replace(/<[^>]*?>/g,""),n=n.replace(/\s+/g," "),n.trim()},n=(n,r)=>{if(!n||!r)return null;const t=n.indexOf(r);if(-1!==t)return{start:t,end:t+r.length};const l=e(n),f=e(r);if(!l||!f)return null;const i=l.indexOf(f);if(-1===i)return null;const c=function(e,n,r){let t=0,l=0,f=-1,i=-1;for(;t<e.length;){const c=e[t],s=c+e[t+1];let u=0;if("**"===s||"__"===s||"~~"===s)u=2;else if("<["===s){if("<"===c){const n=e.indexOf(">",t);-1!==n&&(u=n-t+1)}else if("["===c){const c=e.indexOf("]",t);if(-1!==c&&"("===e[c+1]){const s=e.indexOf(")",c);if(-1!==s){for(let e=t+1;e<c;e++)if(l===n&&-1===f&&(f=t+1),l++,l===n+r)return i=e+1,-1!==f&&-1!==i?{start:f,end:i}:null;t=s,u=1}}}}else"*"!==c&&"_"!==c&&"`"!==c&&"<"!==c||(u=1);if(u>0)t+=u;else{if(l===n&&-1===f&&(f=t),l++,l===n+r){i=t+1;break}t++}}if(-1===f||-1===i)return null;return{start:f,end:i}}(n,i,f.length);return c};export{n as findTextRangeWithFormatting,e as stripMarkdownFormatting};
2
+ //# sourceMappingURL=normalizeInlineMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeInlineMarkdown.js","sources":["../../../../src/features/CognitiveCompare/utils/normalizeInlineMarkdown.ts"],"sourcesContent":["export const stripMarkdownFormatting = (text: string): string => {\n if (!text || typeof text !== \"string\") return text;\n\n let normalized = text;\n\n // Remove bold markers: **text** and __text__\n normalized = normalized.replace(/\\*\\*([^*]*?)\\*\\*/g, \"$1\");\n normalized = normalized.replace(/__([^_]*?)__/g, \"$1\");\n\n // Remove italic markers: *text* and _text_\n normalized = normalized.replace(/\\*([^*]*?)\\*/g, \"$1\");\n normalized = normalized.replace(/_([^_]*?)_/g, \"$1\");\n\n // Remove strikethrough: ~~text~~\n normalized = normalized.replace(/~~([^~]*?)~~/g, \"$1\");\n\n // Remove inline code: `code`\n normalized = normalized.replace(/`([^`]*?)`/g, \"$1\");\n\n // Remove markdown links: [text](url) → text\n normalized = normalized.replace(/\\[([^\\]]*?)\\]\\([^)]*?\\)/g, \"$1\");\n\n // Remove HTML tags but preserve content: <tag>text</tag> → text\n normalized = normalized.replace(/<[^>]*?>/g, \"\");\n\n // Normalize multiple spaces to single space (can result from marker removal)\n normalized = normalized.replace(/\\s+/g, \" \");\n\n return normalized.trim();\n};\n\nexport const findTextRangeWithFormatting = (\n originalContent: string,\n highlightText: string,\n): { start: number; end: number } | null => {\n if (!originalContent || !highlightText) return null;\n\n // Attempt 1: Exact substring match in original content\n const exactIndex = originalContent.indexOf(highlightText);\n if (exactIndex !== -1) {\n return { start: exactIndex, end: exactIndex + highlightText.length };\n }\n\n // Attempt 2: Normalized match (strip formatting from both)\n const normalizedContent = stripMarkdownFormatting(originalContent);\n const normalizedHighlight = stripMarkdownFormatting(highlightText);\n\n if (!normalizedContent || !normalizedHighlight) return null;\n\n const normalizedIndex = normalizedContent.indexOf(normalizedHighlight);\n if (normalizedIndex === -1) return null;\n\n // Map normalized position back to original content\n // Walk through original, skipping formatting markers, counting chars\n const result = mapNormalizedRangeToOriginal(\n originalContent,\n normalizedIndex,\n normalizedHighlight.length,\n );\n\n return result;\n};\n\nfunction mapNormalizedRangeToOriginal(\n originalContent: string,\n normalizedStartIndex: number,\n normalizedLength: number,\n): { start: number; end: number } | null {\n let originalPos = 0;\n let normalizedPos = 0;\n let normalizedStartInOriginal = -1;\n let normalizedEndInOriginal = -1;\n\n while (originalPos < originalContent.length) {\n const char = originalContent[originalPos];\n const nextChar = originalContent[originalPos + 1];\n const twoChars = char + nextChar;\n\n // Check for multi-character markdown/HTML markers to skip\n let markerLength = 0;\n\n if (twoChars === \"**\" || twoChars === \"__\" || twoChars === \"~~\") {\n markerLength = 2;\n } else if (twoChars === \"<[\") {\n // Possible start of link or HTML tag\n if (char === \"<\") {\n const endTag = originalContent.indexOf(\">\", originalPos);\n if (endTag !== -1) {\n markerLength = endTag - originalPos + 1;\n }\n } else if (char === \"[\") {\n // Link: [text](url) - skip entire link\n const closeBracket = originalContent.indexOf(\"]\", originalPos);\n if (closeBracket !== -1 && originalContent[closeBracket + 1] === \"(\") {\n const closeParen = originalContent.indexOf(\")\", closeBracket);\n if (closeParen !== -1) {\n // Count the text inside brackets as real content\n for (let i = originalPos + 1; i < closeBracket; i++) {\n if (normalizedPos === normalizedStartIndex && normalizedStartInOriginal === -1) {\n normalizedStartInOriginal = originalPos + 1;\n }\n normalizedPos++;\n if (normalizedPos === normalizedStartIndex + normalizedLength) {\n normalizedEndInOriginal = i + 1;\n return normalizedStartInOriginal !== -1 && normalizedEndInOriginal !== -1\n ? { start: normalizedStartInOriginal, end: normalizedEndInOriginal }\n : null;\n }\n }\n originalPos = closeParen;\n markerLength = 1;\n }\n }\n }\n } else if (char === \"*\" || char === \"_\" || char === \"`\" || char === \"<\") {\n // Single character marker\n markerLength = 1;\n }\n\n // If we found a marker, skip it\n if (markerLength > 0) {\n originalPos += markerLength;\n continue;\n }\n\n // This is actual text content\n if (normalizedPos === normalizedStartIndex && normalizedStartInOriginal === -1) {\n normalizedStartInOriginal = originalPos;\n }\n\n normalizedPos++;\n\n if (normalizedPos === normalizedStartIndex + normalizedLength) {\n normalizedEndInOriginal = originalPos + 1;\n break;\n }\n\n originalPos++;\n }\n\n if (normalizedStartInOriginal === -1 || normalizedEndInOriginal === -1) {\n return null;\n }\n\n return { start: normalizedStartInOriginal, end: normalizedEndInOriginal };\n}\n\n"],"names":["stripMarkdownFormatting","text","normalized","replace","trim","findTextRangeWithFormatting","originalContent","highlightText","exactIndex","indexOf","start","end","length","normalizedContent","normalizedHighlight","normalizedIndex","result","normalizedStartIndex","normalizedLength","originalPos","normalizedPos","normalizedStartInOriginal","normalizedEndInOriginal","char","twoChars","markerLength","endTag","closeBracket","closeParen","i","mapNormalizedRangeToOriginal"],"mappings":"AAAa,MAAAA,EAA2BC,IACtC,IAAKA,GAAwB,iBAATA,EAA0B,OAAAA,EAE9C,IAAIC,EAAaD,EAyBjB,OAtBaC,EAAAA,EAAWC,QAAQ,oBAAqB,MACxCD,EAAAA,EAAWC,QAAQ,gBAAiB,MAGpCD,EAAAA,EAAWC,QAAQ,gBAAiB,MACpCD,EAAAA,EAAWC,QAAQ,cAAe,MAGlCD,EAAAA,EAAWC,QAAQ,gBAAiB,MAGpCD,EAAAA,EAAWC,QAAQ,cAAe,MAGlCD,EAAAA,EAAWC,QAAQ,2BAA4B,MAG/CD,EAAAA,EAAWC,QAAQ,YAAa,IAGhCD,EAAAA,EAAWC,QAAQ,OAAQ,KAEjCD,EAAWE,QAGPC,EAA8B,CACzCC,EACAC,KAEA,IAAKD,IAAoBC,EAAsB,OAAA,KAGzC,MAAAC,EAAaF,EAAgBG,QAAQF,GAC3C,IAAuB,IAAnBC,EACF,MAAO,CAAEE,MAAOF,EAAYG,IAAKH,EAAaD,EAAcK,QAIxD,MAAAC,EAAoBb,EAAwBM,GAC5CQ,EAAsBd,EAAwBO,GAEpD,IAAKM,IAAsBC,EAA4B,OAAA,KAEjD,MAAAC,EAAkBF,EAAkBJ,QAAQK,GAC9C,QAAAC,EAA+B,OAAA,KAInC,MAAMC,EASR,SACEV,EACAW,EACAC,GAEA,IAAIC,EAAc,EACdC,EAAgB,EAChBC,GAA4B,EAC5BC,GAA0B,EAEvB,KAAAH,EAAcb,EAAgBM,QAAQ,CACrC,MAAAW,EAAOjB,EAAgBa,GAEvBK,EAAWD,EADAjB,EAAgBa,EAAc,GAI/C,IAAIM,EAAe,EAEnB,GAAiB,OAAbD,GAAkC,OAAbA,GAAkC,OAAbA,EAC7BC,EAAA,OACjB,GAAwB,OAAbD,GAET,GAAa,MAATD,EAAc,CAChB,MAAMG,EAASpB,EAAgBG,QAAQ,IAAKU,IACzB,IAAfO,IACFD,EAAeC,EAASP,EAAc,EACxC,MACF,GAAoB,MAATI,EAAc,CAEvB,MAAMI,EAAerB,EAAgBG,QAAQ,IAAKU,GAClD,IAA2B,IAAvBQ,GAA6D,MAAtCrB,EAAgBqB,EAAe,GAAY,CACpE,MAAMC,EAAatB,EAAgBG,QAAQ,IAAKkB,GAChD,IAAuB,IAAnBC,EAAmB,CAErB,IAAA,IAASC,EAAIV,EAAc,EAAGU,EAAIF,EAAcE,IAK1C,GAJAT,IAAkBH,IAA0D,IAAlCI,IAC5CA,EAA4BF,EAAc,GAE5CC,IACIA,IAAkBH,EAAuBC,EAEpC,OADPI,EAA0BO,EAAI,OACvBR,IAAgE,IAA5BC,EACvC,CAAEZ,MAAOW,EAA2BV,IAAKW,GACzC,KAGMH,EAAAS,EACCH,EAAA,CACjB,CACF,CACF,MACkB,MAATF,GAAyB,MAATA,GAAyB,MAATA,GAAyB,MAATA,IAE1CE,EAAA,GAIjB,GAAIA,EAAe,EACFN,GAAAM,MADjB,CAYI,GANAL,IAAkBH,IAA0D,IAAlCI,IAChBA,EAAAF,GAG9BC,IAEIA,IAAkBH,EAAuBC,EAAkB,CAC7DI,EAA0BH,EAAc,EACxC,KACF,CAEAA,GAdA,CAeF,CAEI,IAAoC,IAApCE,IAAoE,IAAhCC,EAC/B,OAAA,KAGT,MAAO,CAAEZ,MAAOW,EAA2BV,IAAKW,EAClD,CA3FiBQ,CACbxB,EACAS,EACAD,EAAoBF,QAGf,OAAAI"}
@@ -0,0 +1,2 @@
1
+ const e=String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`,t=new RegExp(String.raw`<\/?(?:manual|updated)\b${e}>`,"gi"),n=new RegExp(String.raw`<(deleted|changed)\b${e}>([\s\S]*?)<\/\1\s*>`,"gi"),r=new RegExp(String.raw`<deleted\b${e}>([\s\S]*?)\n\n\|<\/deleted>\s*<changed\b${e}>([^|<]*)\|<\/changed>\s*\|`,"gi"),l=new RegExp(String.raw`[ \t]*(<changed\b${e}>)[ \t]*(?:\r?\n[ \t]*){2,}`,"gi"),s=e=>{const t=e.trim();if(!t.includes("|"))return null;const n=[];let r="";for(let e=0;e<t.length;e+=1){const l=t[e],s=e>0&&"\\"===t[e-1];"|"!==l||s?r+=l:(n.push(r.trim()),r="")}return n.push(r.trim()),t.startsWith("|")&&n.shift(),t.endsWith("|")&&n.pop(),n},i=e=>!!e?.length&&e.every(e=>/^:?-{3,}:?$/.test(e)),d=e=>`| ${e.join(" | ")} |`,g=g=>{if(!g)return"";let c=g.replace(t,"");return c=c.replace(l,"\n\n$1"),c=c.replace(r,(e,t,n)=>`<deleted>${t}</deleted>\n\n| <changed>${n.trim()}</changed> |`),c=(t=>{const r=new RegExp(String.raw`(<deleted\b${e}>(?:(?!<\/deleted\s*>)[\s\S])*?\|(?:(?!<\/deleted\s*>)[\s\S])*?<\/deleted\s*>)[ \t]*(<changed\b${e}>[^|]*?<\/changed\s*>)[ \t]*\|`,"gi"),l=t.replace(r,"$1 |\n$2"),d=new RegExp(String.raw`(<deleted\b${e}>(?:(?!<\/deleted\s*>)[\s\S])*?\|(?:(?!<\/deleted\s*>)[\s\S])*?<\/deleted\s*>)\s*(?=<changed\b${e}>)`,"gi"),g=l.replace(d,"$1\n");return g.replace(n,(e,t,n,r)=>{if(!n.includes("|"))return e;const l=g.slice(0,r),d=/(?:^|\n)[ \t]*$/.test(l);return n.split("\n").map((e,n)=>{if(!e)return e;let r=e;r.includes("|")&&!/^\s*\|/.test(r)&&(n>0||d)&&(r=`| ${r}`);const l=s(r);return i(l)?r:r.split(/(\|)/).map(e=>"|"!==e&&e.trim()?`<${t}>${e}</${t}>`:e).join("")}).join("\n")})})(c),c=c.replace(/([([])\s+(?=<(?:deleted|changed)>)/gi,"$1"),(e=>{const t=e.split("\n");for(let e=1;e<t.length;e+=1){const n=s(t[e]);if(!i(n))continue;const r=s(t[e-1]);if(!r?.length)continue;for(;r.length>n.length;){const e=r.findIndex(e=>""===e);if(-1===e)break;r.splice(e,1)}const l=Math.max(r.length,n.length);let g=e+1,c=0;const a=[];for(;g<t.length&&""!==t[g].trim();){const e=s(t[g]);if(!e)break;for(;e.length>l;){const t=e.findIndex(e=>""===e);if(-1===t)break;e.splice(t,1)}a.push({lineIndex:g,cells:e}),c=Math.max(c,e.length),g+=1}const h=Math.max(r.length,n.length,c);for(;r.length<h;)r.push("");for(;n.length<h;)n.push("---");a.forEach(({lineIndex:e,cells:n})=>{for(;n.length<h;)n.push("");t[e]=d(n)}),t[e-1]=d(r),t[e]=d(n)}return t.join("\n")})(c)};export{g as normalizeRedlineMarkdown};
2
+ //# sourceMappingURL=normalizeRedlineMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeRedlineMarkdown.js","sources":["../../../../src/features/CognitiveCompare/utils/normalizeRedlineMarkdown.ts"],"sourcesContent":["const HTML_TAG_ATTRIBUTES = String.raw`(?:[^>\"']|\"[^\"]*\"|'[^']*')*`;\n\nconst wrapperTagPattern = new RegExp(\n String.raw`<\\/?(?:manual|updated)\\b${HTML_TAG_ATTRIBUTES}>`,\n \"gi\",\n);\n\nconst redlineBlockPattern = new RegExp(\n String.raw`<(deleted|changed)\\b${HTML_TAG_ATTRIBUTES}>([\\s\\S]*?)<\\/\\1\\s*>`,\n \"gi\",\n);\n\nconst malformedRedlineHeaderPattern = new RegExp(\n String.raw`<deleted\\b${HTML_TAG_ATTRIBUTES}>([\\s\\S]*?)\\n\\n\\|<\\/deleted>\\s*<changed\\b${HTML_TAG_ATTRIBUTES}>([^|<]*)\\|<\\/changed>\\s*\\|`,\n \"gi\",\n);\n\nconst changedBlockWithLeadingParagraphBreakPattern = new RegExp(\n String.raw`[ \\t]*(<changed\\b${HTML_TAG_ATTRIBUTES}>)[ \\t]*(?:\\r?\\n[ \\t]*){2,}`,\n \"gi\",\n);\n\nconst splitTableRow = (line: string): string[] | null => {\n const trimmed = line.trim();\n if (!trimmed.includes(\"|\")) return null;\n\n const cells: string[] = [];\n let cell = \"\";\n\n for (let index = 0; index < trimmed.length; index += 1) {\n const character = trimmed[index];\n const isEscaped = index > 0 && trimmed[index - 1] === \"\\\\\";\n\n if (character === \"|\" && !isEscaped) {\n cells.push(cell.trim());\n cell = \"\";\n } else {\n cell += character;\n }\n }\n cells.push(cell.trim());\n\n if (trimmed.startsWith(\"|\")) cells.shift();\n if (trimmed.endsWith(\"|\")) cells.pop();\n\n return cells;\n};\n\nconst isDelimiterRow = (cells: string[] | null): cells is string[] =>\n !!cells?.length && cells.every((cell) => /^:?-{3,}:?$/.test(cell));\n\nconst serializeTableRow = (cells: string[]) => `| ${cells.join(\" | \")} |`;\n\nconst reconcileTableColumnCounts = (markdown: string): string => {\n const lines = markdown.split(\"\\n\");\n\n for (let index = 1; index < lines.length; index += 1) {\n const delimiterCells = splitTableRow(lines[index]);\n if (!isDelimiterRow(delimiterCells)) continue;\n\n const headerCells = splitTableRow(lines[index - 1]);\n if (!headerCells?.length) continue;\n\n // A redlined opening pipe can become an extra empty header cell. Remove\n // only empty surplus cells; never discard actual header content.\n while (headerCells.length > delimiterCells.length) {\n const emptyCellIndex = headerCells.findIndex((cell) => cell === \"\");\n if (emptyCellIndex === -1) break;\n headerCells.splice(emptyCellIndex, 1);\n }\n\n const initialColumnCount = Math.max(\n headerCells.length,\n delimiterCells.length,\n );\n let bodyEnd = index + 1;\n let bodyColumnCount = 0;\n const bodyRows: Array<{ lineIndex: number; cells: string[] }> = [];\n while (bodyEnd < lines.length && lines[bodyEnd].trim() !== \"\") {\n const bodyCells = splitTableRow(lines[bodyEnd]);\n if (!bodyCells) break;\n\n while (bodyCells.length > initialColumnCount) {\n const emptyCellIndex = bodyCells.findIndex((cell) => cell === \"\");\n if (emptyCellIndex === -1) break;\n bodyCells.splice(emptyCellIndex, 1);\n }\n\n bodyRows.push({ lineIndex: bodyEnd, cells: bodyCells });\n bodyColumnCount = Math.max(bodyColumnCount, bodyCells.length);\n bodyEnd += 1;\n }\n\n const columnCount = Math.max(\n headerCells.length,\n delimiterCells.length,\n bodyColumnCount,\n );\n\n while (headerCells.length < columnCount) headerCells.push(\"\");\n while (delimiterCells.length < columnCount) delimiterCells.push(\"---\");\n bodyRows.forEach(({ lineIndex, cells }) => {\n // GFM tolerates missing trailing cells, but highlight strings commonly\n // include them. Resolve both forms to the same width so a full-table\n // highlight can match the rendered redline content.\n while (cells.length < columnCount) cells.push(\"\");\n lines[lineIndex] = serializeTableRow(cells);\n });\n\n lines[index - 1] = serializeTableRow(headerCells);\n lines[index] = serializeTableRow(delimiterCells);\n }\n\n return lines.join(\"\\n\");\n};\n\nconst keepRedlineTagsInsideCells = (markdown: string): string => {\n const deletedTableWithTrailingPipePattern = new RegExp(\n String.raw`(<deleted\\b${HTML_TAG_ATTRIBUTES}>(?:(?!<\\/deleted\\s*>)[\\s\\S])*?\\|(?:(?!<\\/deleted\\s*>)[\\s\\S])*?<\\/deleted\\s*>)[ \\t]*(<changed\\b${HTML_TAG_ATTRIBUTES}>[^|]*?<\\/changed\\s*>)[ \\t]*\\|`,\n \"gi\",\n );\n\n // Some editor output places the deleted table's final pipe after the\n // replacement block: `... | |</deleted><changed>text</changed> |`. Move\n // that pipe back to the deleted row before splitting the two versions.\n const repairedTrailingPipe = markdown.replace(\n deletedTableWithTrailingPipePattern,\n \"$1 |\\n$2\",\n );\n\n // When either side of a redline contains a table, the changed version must\n // start on a fresh line. Otherwise a prose-only <changed> block following a\n // deleted table is parsed as another cell on the deleted table's last row.\n const deletedTableFollowedByChangePattern = new RegExp(\n String.raw`(<deleted\\b${HTML_TAG_ATTRIBUTES}>(?:(?!<\\/deleted\\s*>)[\\s\\S])*?\\|(?:(?!<\\/deleted\\s*>)[\\s\\S])*?<\\/deleted\\s*>)\\s*(?=<changed\\b${HTML_TAG_ATTRIBUTES}>)`,\n \"gi\",\n );\n\n const separatedVersions = repairedTrailingPipe.replace(\n deletedTableFollowedByChangePattern,\n \"$1\\n\",\n );\n\n return separatedVersions.replace(\n redlineBlockPattern,\n (fullMatch, tagName: string, body: string, offset: number) => {\n if (!body.includes(\"|\")) return fullMatch;\n\n const beforeTag = separatedVersions.slice(0, offset);\n const tagStartsLine = /(?:^|\\n)[ \\t]*$/.test(beforeTag);\n\n return body\n .split(\"\\n\")\n .map((rawLine, lineIndex) => {\n if (!rawLine) return rawLine;\n\n let line = rawLine;\n const needsLeadingPipe =\n line.includes(\"|\") &&\n !/^\\s*\\|/.test(line) &&\n (lineIndex > 0 || tagStartsLine);\n\n if (needsLeadingPipe) line = `| ${line}`;\n\n const cells = splitTableRow(line);\n if (isDelimiterRow(cells)) return line;\n\n return line\n .split(/(\\|)/)\n .map((part) => {\n if (part === \"|\" || !part.trim()) return part;\n return `<${tagName}>${part}</${tagName}>`;\n })\n .join(\"\");\n })\n .join(\"\\n\");\n },\n );\n};\n\n/**\n * Makes redline HTML safe for GFM parsing. GFM table pipes must remain outside\n * custom HTML tags and the header/delimiter must describe the same columns.\n */\nexport const normalizeRedlineMarkdown = (source: string): string => {\n if (!source) return \"\";\n\n let markdown = source.replace(wrapperTagPattern, \"\");\n\n // A blank Markdown line immediately after an inline custom tag closes the\n // tag before rehypeRaw sees it. Move that paragraph boundary in front of\n // <changed> so the added paragraph remains a child of the styled element.\n //\n // text <changed>\\n\\naddition</changed>\n // text\\n\\n<changed>addition</changed>\n markdown = markdown.replace(\n changedBlockWithLeadingParagraphBreakPattern,\n \"\\n\\n$1\",\n );\n\n markdown = markdown.replace(\n malformedRedlineHeaderPattern,\n (_match, deletedText: string, changedText: string) =>\n `<deleted>${deletedText}</deleted>\\n\\n` +\n `| <changed>${changedText.trim()}</changed> |`,\n );\n\n markdown = keepRedlineTagsInsideCells(markdown);\n // Editors often leave whitespace between a cell's opening punctuation and\n // the redline tag, e.g. `( <deleted>12)`. Removing only that boundary space\n // restores the backend highlight `(12)` without changing visible wording.\n markdown = markdown.replace(\n /([([])\\s+(?=<(?:deleted|changed)>)/gi,\n \"$1\",\n );\n return reconcileTableColumnCounts(markdown);\n};\n"],"names":["HTML_TAG_ATTRIBUTES","String","raw","wrapperTagPattern","RegExp","redlineBlockPattern","malformedRedlineHeaderPattern","changedBlockWithLeadingParagraphBreakPattern","splitTableRow","line","trimmed","trim","includes","cells","cell","index","length","character","isEscaped","push","startsWith","shift","endsWith","pop","isDelimiterRow","every","test","serializeTableRow","join","normalizeRedlineMarkdown","source","markdown","replace","_match","deletedText","changedText","deletedTableWithTrailingPipePattern","repairedTrailingPipe","deletedTableFollowedByChangePattern","separatedVersions","fullMatch","tagName","body","offset","beforeTag","slice","tagStartsLine","split","map","rawLine","lineIndex","part","keepRedlineTagsInsideCells","lines","delimiterCells","headerCells","emptyCellIndex","findIndex","splice","initialColumnCount","Math","max","bodyEnd","bodyColumnCount","bodyRows","bodyCells","columnCount","forEach","reconcileTableColumnCounts"],"mappings":"AAAA,MAAMA,EAAsBC,OAAOC,GAAA,8BAE7BC,EAAoB,IAAIC,OAC5BH,OAAOC,8BAA8BF,KACrC,MAGIK,EAAsB,IAAID,OAC9BH,OAAOC,0BAA0BF,wBACjC,MAGIM,EAAgC,IAAIF,OACxCH,OAAOC,GAAA,aAAgBF,6CAA+DA,+BACtF,MAGIO,EAA+C,IAAIH,OACvDH,OAAOC,uBAAuBF,+BAC9B,MAGIQ,EAAiBC,IACf,MAAAC,EAAUD,EAAKE,OACrB,IAAKD,EAAQE,SAAS,KAAa,OAAA,KAEnC,MAAMC,EAAkB,GACxB,IAAIC,EAAO,GAEX,IAAA,IAASC,EAAQ,EAAGA,EAAQL,EAAQM,OAAQD,GAAS,EAAG,CAChD,MAAAE,EAAYP,EAAQK,GACpBG,EAAYH,EAAQ,GAA4B,OAAvBL,EAAQK,EAAQ,GAE7B,MAAdE,GAAsBC,EAIhBJ,GAAAG,GAHFJ,EAAAM,KAAKL,EAAKH,QACTG,EAAA,GAIX,CAMO,OALDD,EAAAM,KAAKL,EAAKH,QAEZD,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AAavB,EAAkBd,KAGvCwC,EAAMtC,EAAQ,GAAKY,EAAkB4B,GAC/BF,EAAAtC,GAASY,EAAkB2B,EACnC,CAEO,OAAAD,EAAMzB,KAAK,OAsGXwC,CAA2BrC"}
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as i,Fragment as t}from"react/jsx-runtime";import{useMemo as o,useState as r}from"react";import n from"@mui/icons-material/ChevronRight";import l from"@mui/icons-material/Close";import a from"@mui/icons-material/ExpandMore";import d from"@mui/material/Box";import s from"@mui/material/Button";import c from"@mui/material/ButtonBase";import u from"@mui/material/Divider";import p from"@mui/material/IconButton";import m from"@mui/material/Paper";import h from"@mui/material/Radio";import g from"@mui/material/Stack";import x from"@mui/material/TextField";import f from"@mui/material/Typography";import b from"./RevertSummaryNotice.js";import E from"./CognitiveIcon.js";import C from"./CognitiveScoreBadge.js";import F from"../../assests/icons/InfoAlert.js";const S=(e,i)=>[e,...Array.isArray(i)?i:null==i?[]:[i]],y="MERGE_ADJACENT";var v=(e=>(e.KEEP="KEEP",e.SPLIT_HERE="SPLIT_HERE",e.MERGE_NEXT="MERGE_NEXT",e.MERGE_PREV="MERGE_PREV",e.MERGE_PREVIOUS="MERGE_PREVIOUS",e.SET_RANGE="SET_RANGE",e))(v||{});const w=e=>Object.values(v).includes(e),R=(e,i,t,o)=>{if(!i||!e)return[];const r=i.additional_decisions,n=Array.isArray(r)?r:r?Object.values(r).flat():[],l=Array.from(new Set([...i.allowed_decisions,...n]));return l.flatMap(i=>{const r=e.focus_page,n=l.find(e=>e.toLowerCase().includes("merge")),a=null!=r&&null!=t&&null!=o&&r===t&&r===o,d=null!=r&&null!=t&&r===t,s=null!=r&&null!=o&&(r===o||r===o+1),c=d||s||!(null!=r&&(!(null!=t&&null!=o)||r>t&&r<o));switch(i){case"SET_RANGE":return[];case"KEEP":return[{id:i,title:"Keep as is",description:"Keep the current document boundary unchanged."}];case"SPLIT_HERE":return[{id:i,title:"Split to a separate document",description:c?"A valid page inside the document is required to split it.":r?`Start a new document at page ${r}.`:"Create a new document at this boundary.",disabled:c}];case"MERGE_PREV":case"MERGE_NEXT":case"MERGE_PREVIOUS":return i!==n?[]:a?[{id:y,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]:d?[{id:"MERGE_PREVIOUS",title:"Merge with previous document",description:"Combine this document with the previous document."}]:s?[{id:"MERGE_NEXT",title:"Merge with next document",description:"Combine this document with the next document."}]:[{id:y,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]}return[]})};function M({headerName:v="Boundary Check",title:M,pageNo:A,content:I,revertSummary:T,cognitiveScore:z,config:W,metadata:k,previousSegmentTitle:P,nextSegmentTitle:_,selectedIndex:N,defaultSelectedIndex:G=null,defaultStartPage:B,defaultEndPage:D,onSelectionChange:H,onConfirm:j,onActionConfirm:O,onCognitiveClick:V,onAdjustManually:L,onClose:U,confirmLabel:X="Confirm",manualPrompt:K="Didn't find the right option?",manualActionLabel:$="Adjust Manually",cognitiveLabel:q="Cognitive Integrity",showAdjustManually:J=!0,showCognitiveIntegrity:Y=!0,showCloseButton:Q=!0,confirmDisabled:Z=!1,width:ee=260,maxWidth:ie=260,className:te,styles:oe,reviewAction:re,totalPages:ne}){console.log("LOG: Total pages",ne);const le=o(()=>(W??(k?R(k,re,B,D):[])).filter(e=>"SET_RANGE"!==e.id),[W,D,B,k,re]),[ae,de]=r(G),[se,ce]=r(null==B?"":String(B)),[ue,pe]=r(null==D?"":String(D)),[me,he]=r(!1),[ge,xe]=r(!1),[fe,be]=r(null),[Ee,Ce]=r(!1),Fe=void 0===N?ae:N,Se=null==Fe?void 0:le[Fe],ye=Se?.id===y,ve=null!=P,we=null!=_,Re=e=>!0===e.disabled||"MERGE_PREV"===e.id&&!ve||"MERGE_PREVIOUS"===e.id&&!ve||"MERGE_NEXT"===e.id&&!we||e.id===y&&!ve&&!we,Me=Number(se),Ae=Number(ue),Ie=se.trim().length>0&&ue.trim().length>0&&Number.isInteger(Me)&&Number.isInteger(Ae)&&Me>0&&Ae>0,Te=null!=ne&&Me>ne,ze=null!=ne&&Ae>ne,We=se.trim().length>0&&ue.trim().length>0&&Number.isInteger(Me)&&Number.isInteger(Ae)&&Me>Ae,ke=Ie&&Me<=Ae&&!Te&&!ze,Pe=ke&&Me===B&&Ae===D,_e=Z||!Se||Re(Se)||ye&&null==fe||!j&&!O;return e(m,{className:te,elevation:4,sx:S({width:ee,maxWidth:ie,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",boxSizing:"border-box","@media (max-width: 372px)":{width:"calc(100vw - 32px)"}},oe?.root),children:i(g,{spacing:.75,sx:{p:1},children:[i(g,{direction:"row",alignItems:"center",spacing:.75,sx:oe?.header,children:[e(F,{color:"error",height:16,width:16}),e(f,{sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"},children:v}),Q&&e(p,{size:"small",onClick:U,disabled:!U,"aria-label":"Close boundary check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}},children:e(l,{sx:{fontSize:17}})})]}),i(d,{children:[e(f,{sx:{color:"text.primary",fontSize:14,fontWeight:500},children:M}),null!=A&&e(f,{sx:{mt:.125,color:"text.secondary",fontSize:12},children:A}),e(u,{sx:{my:.625}}),null!=T?e(b,{children:T}):null!=I&&e(f,{component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3},children:I})]}),i(g,{spacing:.625,role:"radiogroup","aria-label":"Boundary options",children:[le.map((t,o)=>{const r=Fe===o,n=Re(t);return i(m,{variant:"outlined",sx:S({borderColor:r?"#1976d2":"divider",borderRadius:2,bgcolor:n?"#F8FAFC":"background.paper",overflow:"hidden"},oe?.option),children:[i(c,{role:"radio","aria-checked":r,disabled:Z||n,onClick:()=>((e,i)=>{Z||Re(i)||(void 0===N&&de(e),i.id!==y&&be(null),me&&(he(!1),xe(!1)),H?.(e,i))})(o,t),sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left"},children:[e(h,{checked:r,disabled:Z||n,tabIndex:-1,size:"small",sx:{p:.25,mr:.5,"&.Mui-disabled":{color:"#CBD5E1"}}}),i(d,{sx:{minWidth:0},children:[e(f,{sx:{color:n?"#94A3B8":"text.primary",fontSize:12.5,fontWeight:500},children:t.title}),null!=t.description&&e(f,{sx:{mt:.125,color:n?"#94A3B8":"text.secondary",fontSize:11},children:t.description})]})]}),r&&t.id===y&&e(g,{direction:"row",spacing:.75,sx:S({px:.75,pb:.75},oe?.adjacentSelector),children:[{direction:"previous",title:P??"No Previous document",caption:"← Merge into Previous",available:ve},{direction:"next",title:_??"No Next document",caption:"Merge into Next →",available:we}].map(t=>{const o=fe===t.direction;return i(g,{sx:{flex:1,minWidth:0},children:[e(c,{disabled:Z||!t.available,onClick:()=>be(t.direction),"aria-pressed":o,sx:{width:"100%",minWidth:0,minHeight:46,alignItems:"flex-start",justifyContent:"flex-start",p:.625,border:"1px solid",borderColor:o?"#7F56D9":"#D0D5DD",borderRadius:1.5,bgcolor:o?"#E0E7FF":"background.paper",color:o?"#7F56D9":t.available?"text.primary":"#98A2B3",textAlign:"left","&.Mui-disabled":{color:"#98A2B3",bgcolor:"#F8FAFC"}},children:e(f,{sx:{color:"inherit",fontSize:11,fontWeight:500,lineHeight:1.25,overflowWrap:"anywhere"},children:t.title})}),e(f,{sx:{mt:.5,color:o?"#5925DC":"text.secondary",fontSize:9.5,lineHeight:1.2,whiteSpace:"nowrap",textAlign:"next"===t.direction?"right":"left"},children:t.caption})]},t.direction)})})]},t.id)}),ye&&null!=fe&&i(g,{direction:"row",alignItems:"flex-start",spacing:.625,sx:S({p:.75,border:"1px solid #FCA5A5",borderRadius:1.5,bgcolor:"#FEF2F2"},oe?.impactWarning),children:[e(F,{color:"error",height:14,width:14,sx:{mt:.125}}),i(f,{sx:{color:"#DC2626",fontSize:10.5,lineHeight:1.4},children:["This will impact the ",fe," document. Its content and page range will change."]})]}),e(s,{variant:"contained",fullWidth:!0,disabled:_e,onClick:()=>{if(_e||null==Fe||!Se)return;const e=ye?"previous"===fe?"MERGE_PREVIOUS":"MERGE_NEXT":Se.id,i=ye?{...Se,id:e}:Se,t={selectedIndex:Fe,option:i,metadata:k};j?.(Fe,i,t),O&&w(e)&&O(e,t)},sx:S({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},oe?.confirmButton),children:X})]}),J&&i(g,{spacing:.625,sx:oe?.manualSection,children:[i(c,{disabled:Z,onClick:()=>{const e=!me;he(e),xe(!1),e&&(void 0===N&&de(null),L?.())},"aria-expanded":me,sx:{width:"100%",justifyContent:"space-between",borderRadius:1,textAlign:"left"},children:[e(d,{children:e(f,{sx:{color:"text.primary",fontSize:12,fontWeight:600},children:K})}),e(a,{sx:{color:"text.secondary",fontSize:16,transform:me?"rotate(180deg)":"none",transition:"transform 150ms ease"}})]}),me&&!ge&&i(d,{sx:{pt:.5,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif'},children:[i(d,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"},children:[e(f,{sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0},children:"Starts"}),e(f,{sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0},children:"Ends"})]}),i(d,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"},children:[i(d,{children:[e(x,{size:"small",type:"text",value:se,disabled:Z,error:Te||We,onChange:e=>{const i=e.target.value;/^\d*$/.test(i)&&ce(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Te||We?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Te||We?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Te||We?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Te&&i(f,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:["Must be ≤ ",ne," (total pages)"]}),We&&!Te&&e(f,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:"Must be ≤ end page"})]}),i(d,{children:[e(x,{size:"small",type:"text",value:ue,disabled:Z,error:ze||We,onChange:e=>{const i=e.target.value;/^\d*$/.test(i)&&pe(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:ze||We?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:ze||We?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:ze||We?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),ze&&i(f,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:["Must be ≤ ",ne," (total pages)"]}),We&&!ze&&e(f,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:"Must be ≥ start page"})]})]}),e(d,{children:e(s,{onClick:()=>{ke&&(Pe?Ce(!0):xe(!0))},disabled:Z||!ke||Pe,sx:{height:"30px",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",backgroundColor:"#FFFFFF",border:"1px solid #8E80F3",borderRadius:"6px",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif',fontSize:"12px",fontWeight:600,lineHeight:"1",color:"#4A24CF",outline:"none",cursor:"pointer",textTransform:"none",transition:"all 150ms ease-in-out","&:hover":!ke||Pe?{}:{backgroundColor:"#FAF9FF",borderColor:"#7F6FF0"},"&:active":!ke||Pe?{}:{transform:"translateY(1px)"},"&.Mui-disabled":{backgroundColor:"#FFFFFF",borderColor:"#C3CFDC",color:"#A0ABBE",cursor:"not-allowed"}},children:"Apply"})}),Pe&&Ee&&e(d,{sx:{backgroundColor:"#FEF3C7",border:"1px solid #FBBF24",borderRadius:"6px",padding:"8px 10px",marginTop:"4px"},children:e(f,{sx:{fontSize:"10px",color:"#B45309",fontWeight:500,lineHeight:1.4},children:"Please change the boundary to change the document boundary as no changes will be applied."})}),e(d,{sx:{width:"100%",height:"1px",marginTop:"8px",backgroundColor:"#EEF0F2",border:"0"}})]}),me&&ge&&i(g,{spacing:.75,sx:S({p:.75,borderRadius:1.5,bgcolor:"#FFF7ED"},oe?.manualConfirmation),children:[i(g,{direction:"row",alignItems:"center",spacing:.5,children:[e(F,{color:"warning",height:14,width:14}),e(f,{sx:{color:"#EA580C",fontSize:11,fontWeight:600},children:"Confirm this change?"})]}),i(f,{sx:{color:"text.secondary",fontSize:10.5,lineHeight:1.4},children:["Pages ",Me,"-",Ae," will become part of ",M,", including pages from other documents in this range."]}),i(g,{direction:"row",spacing:.75,children:[e(s,{variant:"outlined",fullWidth:!0,onClick:()=>xe(!1),sx:{minHeight:28,borderRadius:1.5,fontSize:11,textTransform:"none"},children:"Cancel"}),e(s,{variant:"contained",fullWidth:!0,disabled:Z||!j||!ke||Pe,onClick:()=>{if(!ke||Pe||!j)return;const e={id:"SET_RANGE",title:$};j(-1,e,{selectedIndex:-1,option:e,startPage:Me,endPage:Ae,metadata:k})},sx:{minHeight:28,borderRadius:1.5,bgcolor:"#EA580C",fontSize:11,textTransform:"none","&:hover":{bgcolor:"#C2410C"}},children:"Confirm"})]})]})]}),e(g,{spacing:.625,sx:oe?.footer,children:Y&&i(t,{children:[e(u,{}),i(c,{onClick:V,disabled:!V,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:V?"pointer":"not-allowed"},children:[i(g,{direction:"row",alignItems:"center",spacing:1,children:[e(E,{sx:{color:"text.secondary"}}),e(f,{sx:{color:"text.primary",fontSize:12},children:q})]}),i(g,{direction:"row",alignItems:"center",spacing:.5,children:[e(C,{score:z}),e(n,{sx:{color:"text.secondary"}})]})]})]})})]})})}export{v as BoundaryReviewActionEnum,R as createBoundaryCardOptions,M as default,w as isBoundaryReviewAction};
1
+ import{jsx as e,jsxs as i,Fragment as t}from"react/jsx-runtime";import{useMemo as o,useState as r}from"react";import n from"@mui/icons-material/ChevronRight";import l from"@mui/icons-material/Close";import a from"@mui/icons-material/ExpandMore";import d from"@mui/material/Box";import s from"@mui/material/Button";import c from"@mui/material/ButtonBase";import u from"@mui/material/Divider";import m from"@mui/material/IconButton";import p from"@mui/material/Paper";import h from"@mui/material/Radio";import g from"@mui/material/Stack";import x from"@mui/material/TextField";import f from"@mui/material/Typography";import b from"./RevertSummaryNotice.js";import E from"./CognitiveIcon.js";import C from"./CognitiveScoreBadge.js";import F from"../../assests/icons/InfoAlert.js";const S=(e,i)=>[e,...Array.isArray(i)?i:null==i?[]:[i]],y="MERGE_ADJACENT";var v=(e=>(e.KEEP="KEEP",e.SPLIT_HERE="SPLIT_HERE",e.MERGE_NEXT="MERGE_NEXT",e.MERGE_PREV="MERGE_PREV",e.MERGE_PREVIOUS="MERGE_PREVIOUS",e.SET_RANGE="SET_RANGE",e))(v||{});const R=e=>Object.values(v).includes(e),w=(e,i,t,o)=>{if(!i||!e)return[];const r=i.additional_decisions,n=Array.isArray(r)?r:r?Object.values(r).flat():[],l=Array.from(new Set([...i.allowed_decisions,...n]));return l.flatMap(i=>{const r=e.focus_page,n=l.find(e=>e.toLowerCase().includes("merge")),a=null!=r&&null!=t&&null!=o&&r===t&&r===o,d=null!=r&&null!=t&&r===t,s=null!=r&&null!=o&&(r===o||r===o+1),c=d||s||!(null!=r&&(!(null!=t&&null!=o)||r>t&&r<o));switch(i){case"SET_RANGE":return[];case"KEEP":return[{id:i,title:"Keep as is",description:"Keep the current document boundary unchanged."}];case"SPLIT_HERE":return[{id:i,title:"Split to a separate document",description:c?"A valid page inside the document is required to split it.":r?`Start a new document at page ${r}.`:"Create a new document at this boundary.",disabled:c}];case"MERGE_PREV":case"MERGE_NEXT":case"MERGE_PREVIOUS":return i!==n?[]:a?[{id:y,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]:d?[{id:"MERGE_PREVIOUS",title:"Merge with previous document",description:"Combine this document with the previous document."}]:s?[{id:"MERGE_NEXT",title:"Merge with next document",description:"Combine this document with the next document."}]:[{id:y,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]}return[]})};function M({headerName:v="Boundary Check",title:M,pageNo:A,content:I,revertSummary:T,cognitiveScore:W,config:z,metadata:k,previousSegmentTitle:P,nextSegmentTitle:_,selectedIndex:N,defaultSelectedIndex:G=null,defaultStartPage:B,defaultEndPage:D,onSelectionChange:H,onConfirm:j,onActionConfirm:O,onCognitiveClick:V,onAdjustManually:L,onClose:U,confirmLabel:X="Confirm",manualPrompt:K="Didn't find the right option?",manualActionLabel:$="Adjust Manually",cognitiveLabel:q="Cognitive Integrity",showAdjustManually:J=!0,showCognitiveIntegrity:Y=!0,showCloseButton:Q=!0,confirmDisabled:Z=!1,width:ee=260,maxWidth:ie="100%",className:te,styles:oe,reviewAction:re,totalPages:ne}){console.log("LOG: Total pages",ne);const le=o(()=>(z??(k?w(k,re,B,D):[])).filter(e=>"SET_RANGE"!==e.id),[z,D,B,k,re]),[ae,de]=r(G),[se,ce]=r(null==B?"":String(B)),[ue,me]=r(null==D?"":String(D)),[pe,he]=r(!1),[ge,xe]=r(!1),[fe,be]=r(null),[Ee,Ce]=r(!1),Fe=void 0===N?ae:N,Se=null==Fe?void 0:le[Fe],ye=Se?.id===y,ve=null!=P,Re=null!=_,we=e=>!0===e.disabled||"MERGE_PREV"===e.id&&!ve||"MERGE_PREVIOUS"===e.id&&!ve||"MERGE_NEXT"===e.id&&!Re||e.id===y&&!ve&&!Re,Me=Number(se),Ae=Number(ue),Ie=se.trim().length>0&&ue.trim().length>0&&Number.isInteger(Me)&&Number.isInteger(Ae)&&Me>0&&Ae>0,Te=null!=ne&&Me>ne,We=null!=ne&&Ae>ne,ze=se.trim().length>0&&ue.trim().length>0&&Number.isInteger(Me)&&Number.isInteger(Ae)&&Me>Ae,ke=Ie&&Me<=Ae&&!Te&&!We,Pe=ke&&Me===B&&Ae===D,_e=Z||!Se||we(Se)||ye&&null==fe||!j&&!O;return e(p,{className:te,elevation:4,sx:S({width:ee,maxWidth:ie,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",boxSizing:"border-box",minWidth:0},oe?.root),children:i(g,{spacing:.75,sx:{p:1},children:[i(g,{direction:"row",alignItems:"center",spacing:.75,sx:oe?.header,children:[e(F,{color:"error",height:16,width:16}),e(f,{sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"},children:v}),Q&&e(m,{size:"small",onClick:U,disabled:!U,"aria-label":"Close boundary check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}},children:e(l,{sx:{fontSize:17}})})]}),i(d,{children:[e(f,{sx:{color:"text.primary",fontSize:14,fontWeight:500},children:M}),null!=A&&e(f,{sx:{mt:.125,color:"text.secondary",fontSize:12},children:A}),e(u,{sx:{my:.625}}),null!=T?e(b,{children:T}):null!=I&&e(f,{component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3},children:I})]}),i(g,{spacing:.625,role:"radiogroup","aria-label":"Boundary options",children:[le.map((t,o)=>{const r=Fe===o,n=we(t);return i(p,{variant:"outlined",sx:S({borderColor:r?"#1976d2":"divider",borderRadius:2,bgcolor:n?"#F8FAFC":"background.paper",overflow:"hidden"},oe?.option),children:[i(c,{role:"radio","aria-checked":r,disabled:Z||n,onClick:()=>((e,i)=>{Z||we(i)||(void 0===N&&de(e),i.id!==y&&be(null),pe&&(he(!1),xe(!1)),H?.(e,i))})(o,t),sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left"},children:[e(h,{checked:r,disabled:Z||n,tabIndex:-1,size:"small",sx:{p:.25,mr:.5,"&.Mui-disabled":{color:"#CBD5E1"}}}),i(d,{sx:{minWidth:0},children:[e(f,{sx:{color:n?"#94A3B8":"text.primary",fontSize:12.5,fontWeight:500},children:t.title}),null!=t.description&&e(f,{sx:{mt:.125,color:n?"#94A3B8":"text.secondary",fontSize:11},children:t.description})]})]}),r&&t.id===y&&e(g,{direction:"row",spacing:.75,sx:S({px:.75,pb:.75,minWidth:0,"& > *":{minWidth:0}},oe?.adjacentSelector),children:[{direction:"previous",title:P??"No Previous document",caption:"← Merge into Previous",available:ve},{direction:"next",title:_??"No Next document",caption:"Merge into Next →",available:Re}].map(t=>{const o=fe===t.direction;return i(g,{sx:{flex:1,minWidth:0},children:[e(c,{disabled:Z||!t.available,onClick:()=>be(t.direction),"aria-pressed":o,sx:{width:"100%",minWidth:0,minHeight:46,alignItems:"flex-start",justifyContent:"flex-start",p:.625,border:"1px solid",borderColor:o?"#7F56D9":"#D0D5DD",borderRadius:1.5,bgcolor:o?"#E0E7FF":"background.paper",color:o?"#7F56D9":t.available?"text.primary":"#98A2B3",textAlign:"left","&.Mui-disabled":{color:"#98A2B3",bgcolor:"#F8FAFC"}},children:e(f,{sx:{color:"inherit",fontSize:11,fontWeight:500,lineHeight:1.25,overflowWrap:"anywhere"},children:t.title})}),e(f,{sx:{mt:.5,color:o?"#5925DC":"text.secondary",fontSize:9.5,lineHeight:1.2,whiteSpace:"normal",overflowWrap:"anywhere",textAlign:"next"===t.direction?"right":"left"},children:t.caption})]},t.direction)})})]},t.id)}),ye&&null!=fe&&i(g,{direction:"row",alignItems:"flex-start",spacing:.625,sx:S({p:.75,border:"1px solid #FCA5A5",borderRadius:1.5,bgcolor:"#FEF2F2"},oe?.impactWarning),children:[e(F,{color:"error",height:14,width:14,sx:{mt:.125}}),i(f,{sx:{color:"#DC2626",fontSize:10.5,lineHeight:1.4},children:["This will impact the ",fe," document. Its content and page range will change."]})]}),e(s,{variant:"contained",fullWidth:!0,disabled:_e,onClick:()=>{if(_e||null==Fe||!Se)return;const e=ye?"previous"===fe?"MERGE_PREVIOUS":"MERGE_NEXT":Se.id,i=ye?{...Se,id:e}:Se,t={selectedIndex:Fe,option:i,metadata:k};j?.(Fe,i,t),O&&R(e)&&O(e,t)},sx:S({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},oe?.confirmButton),children:X})]}),J&&i(g,{spacing:.625,sx:oe?.manualSection,children:[i(c,{disabled:Z,onClick:()=>{const e=!pe;he(e),xe(!1),e&&(void 0===N&&de(null),L?.())},"aria-expanded":pe,sx:{width:"100%",justifyContent:"space-between",borderRadius:1,textAlign:"left"},children:[e(d,{children:e(f,{sx:{color:"text.primary",fontSize:12,fontWeight:600},children:K})}),e(a,{sx:{color:"text.secondary",fontSize:16,transform:pe?"rotate(180deg)":"none",transition:"transform 150ms ease"}})]}),pe&&!ge&&i(d,{sx:{pt:.5,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif'},children:[i(d,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"},children:[e(f,{sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0},children:"Starts"}),e(f,{sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0},children:"Ends"})]}),i(d,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"},children:[i(d,{children:[e(x,{size:"small",type:"text",value:se,disabled:Z,error:Te||ze,onChange:e=>{const i=e.target.value;/^\d*$/.test(i)&&ce(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Te||ze?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Te||ze?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Te||ze?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Te&&i(f,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:["Must be ≤ ",ne," (total pages)"]}),ze&&!Te&&e(f,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:"Must be ≤ end page"})]}),i(d,{children:[e(x,{size:"small",type:"text",value:ue,disabled:Z,error:We||ze,onChange:e=>{const i=e.target.value;/^\d*$/.test(i)&&me(i)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:We||ze?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:We||ze?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:We||ze?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),We&&i(f,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:["Must be ≤ ",ne," (total pages)"]}),ze&&!We&&e(f,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:"Must be ≥ start page"})]})]}),e(d,{children:e(s,{onClick:()=>{ke&&(Pe?Ce(!0):xe(!0))},disabled:Z||!ke||Pe,sx:{height:"30px",padding:"0 12px",display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",backgroundColor:"#FFFFFF",border:"1px solid #8E80F3",borderRadius:"6px",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif',fontSize:"12px",fontWeight:600,lineHeight:"1",color:"#4A24CF",outline:"none",cursor:"pointer",textTransform:"none",transition:"all 150ms ease-in-out","&:hover":!ke||Pe?{}:{backgroundColor:"#FAF9FF",borderColor:"#7F6FF0"},"&:active":!ke||Pe?{}:{transform:"translateY(1px)"},"&.Mui-disabled":{backgroundColor:"#FFFFFF",borderColor:"#C3CFDC",color:"#A0ABBE",cursor:"not-allowed"}},children:"Apply"})}),Pe&&Ee&&e(d,{sx:{backgroundColor:"#FEF3C7",border:"1px solid #FBBF24",borderRadius:"6px",padding:"8px 10px",marginTop:"4px"},children:e(f,{sx:{fontSize:"10px",color:"#B45309",fontWeight:500,lineHeight:1.4},children:"Please change the boundary to change the document boundary as no changes will be applied."})}),e(d,{sx:{width:"100%",height:"1px",marginTop:"8px",backgroundColor:"#EEF0F2",border:"0"}})]}),pe&&ge&&i(g,{spacing:.75,sx:S({p:.75,borderRadius:1.5,bgcolor:"#FFF7ED"},oe?.manualConfirmation),children:[i(g,{direction:"row",alignItems:"center",spacing:.5,children:[e(F,{color:"warning",height:14,width:14}),e(f,{sx:{color:"#EA580C",fontSize:11,fontWeight:600},children:"Confirm this change?"})]}),i(f,{sx:{color:"text.secondary",fontSize:10.5,lineHeight:1.4},children:["Pages ",Me,"-",Ae," will become part of ",M,", including pages from other documents in this range."]}),i(g,{direction:"row",spacing:.75,children:[e(s,{variant:"outlined",fullWidth:!0,onClick:()=>xe(!1),sx:{minHeight:28,borderRadius:1.5,fontSize:11,textTransform:"none"},children:"Cancel"}),e(s,{variant:"contained",fullWidth:!0,disabled:Z||!j||!ke||Pe,onClick:()=>{if(!ke||Pe||!j)return;const e={id:"SET_RANGE",title:$};j(-1,e,{selectedIndex:-1,option:e,startPage:Me,endPage:Ae,metadata:k})},sx:{minHeight:28,borderRadius:1.5,bgcolor:"#EA580C",fontSize:11,textTransform:"none","&:hover":{bgcolor:"#C2410C"}},children:"Confirm"})]})]})]}),e(g,{spacing:.625,sx:oe?.footer,children:Y&&i(t,{children:[e(u,{}),i(c,{onClick:V,disabled:!V,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:V?"pointer":"not-allowed"},children:[i(g,{direction:"row",alignItems:"center",spacing:1,children:[e(E,{sx:{color:"text.secondary"}}),e(f,{sx:{color:"text.primary",fontSize:12},children:q})]}),i(g,{direction:"row",alignItems:"center",spacing:.5,children:[e(C,{score:W}),e(n,{sx:{color:"text.secondary"}})]})]})]})})]})})}export{v as BoundaryReviewActionEnum,w as createBoundaryCardOptions,M as default,R as isBoundaryReviewAction};
2
2
  //# sourceMappingURL=BoundaryCard.js.map