@e-llm-studio/citation 0.0.251-beta.1 → 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 (213) 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
@@ -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":["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","ANIM_SPEED","smoothScrollTo","leftAbsoluteTop","rightAbsoluteTop","rawRightTargetScroll","rightMaxScroll","scrollHeight","clientHeight","rightActualScroll","deficit","rawLeftTargetScroll","leftMaxScroll","leftActualScroll","setTimeout"],"mappings":"4JAG6B,EACzBA,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,YAAS,IAC1CC,EAAgBC,GAAqBF,YAAS,IAC9CG,EAAYC,GAAiBJ,YAAS,IACtCK,EAAqBC,GAA0BN,YAAS,IACxDO,EAAyBC,GAA8BR,WAAiC,MAGzFS,EAAaC,UAAO,GACpBC,EAAqBD,SAAsH,MAC3IE,EAAkBF,UA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EoB,EAAAF,CACvB,CACeT,EAAAA,eAAAhD,EAAe2D,EAAkBZ,EAAYR,IAEpE,GAKAvH,EACA4I,WAAWnC,EAAkB,KAEZA,QAI7B,CACIrE,EACAb,EACApB,EACAwB,EACA1B,EACAC,EACAqF,EACAS,EACAhG,IAID,MAAA,CACH2B,eAAcC,kBACdE,iBAAgBC,oBAChBC,aAAYC,gBACZC,sBAAqBC,yBACrBC,0BAAyBC,6BACzBC,aACAE,qBACAC,kBACAC,6BACAC,kCACAC,oBACAC,wBACAE,uBACAM,wBACA2C,kBACAC"}
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":["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","ANIM_SPEED","smoothScrollTo","leftAbsoluteTop","rightAbsoluteTop","rawRightTargetScroll","rightMaxScroll","scrollHeight","clientHeight","rightActualScroll","deficit","rawLeftTargetScroll","leftMaxScroll","leftActualScroll","setTimeout"],"mappings":"iNAI6B,EACzBA,kBACAC,wBACAC,mBAAkBC,mBAClBC,mBAAkBC,oBAAmBC,qB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EAAU,cAC3D/B,sBAAsB,KACHuB,EAAAA,eAAA9C,EAAgBiD,EAAsBJ,EAAYR,IAErE,CAEoBgB,EAAAJ,CACxB,CAEeH,EAAAA,eAAA9C,EAAgBqD,EAAmBR,EAAYR,IACjE,KACE,CACG,MACAkB,EAAsBR,GADHC,EAAmBhD,EAAe4C,WAI3DrB,sBAAsB,KACZ,MAAAiC,EAAgBzD,EAAcoD,aAAepD,EAAcqD,aAC7D,IAAAK,EAEJ,GAAIF,EAAsB,EACHE,EAAA,MACvB,IAAWF,EAAsBC,EAE7B,YADAjC,sBAAsB,IAAMuB,EAAAA,eAAe/C,EAAeyD,EAAeX,EAAYR,IAGlEoB,EAAAF,CACvB,CACeT,EAAAA,eAAA/C,EAAe0D,EAAkBZ,EAAYR,IAEpE,GAKAtH,EACA2I,WAAWlC,EAAkB,KAEZA,QAI7B,CACIrE,EACAb,EACApB,EACAwB,EACA1B,EACAC,EACAqF,EACAS,EACAhG,IAID,MAAA,CACH2B,eAAcC,kBACdE,iBAAgBC,oBAChBC,aAAYC,gBACZC,sBAAqBC,yBACrBC,0BAAyBC,6BACzBC,aACAE,qBACAC,kBACAC,6BACAC,kCACAC,oBACAC,wBACAE,uBACAM,wBACA2C,kBACAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.buildOnDemandCitationCacheKey=e=>[e.requestId||"",e.citationId||e.href,e.highlightType||"both",e.citationType||""].join("|");
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":["context","requestId","citationId","href","highlightType","citationType","join"],"mappings":"0GAGEA,GAKA,CACEA,EAAQC,WAAa,GACrBD,EAAQE,YAAcF,EAAQG,KAC9BH,EAAQI,eAAiB,OACzBJ,EAAQK,cAAgB,IACxBC,KAAK"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../CognitiveComparehelpers.js"),t=require("./href.js"),i=require("./cacheKey.js");const n=e=>e?.nodes||e||{},a=(e,t)=>{if(!t)return null;const i=n(e);return i?.[t]||null},o=({href:e,popupNodeId:i,treeData:a})=>{const o=t.parseOnDemandCitationHref(e),r=n(a);return o.identifier&&r?.[o.identifier]?o.identifier:o.identifierNodeId&&r?.[o.identifierNodeId]?o.identifierNodeId:i||null},r=({treeData:t,node:i,sideIndex:n,role:a,citationEntry:o,preferredContentId:r})=>{const d=t.input_index_map||{},s=d[n];if(!s)return;const c=(({items:e,preferredContentId:t,treeData:i})=>{if(!t)return e[0]||null;const n=e.find(e=>e.contentId===t);if(n)return n;const a=i?.content_mapping?.[t];return a&&"object"==typeof a?{contentId:t,data:a,attributes:a.additional_attributes||{}}:e[0]||null})({items:e.resolveComparisonInputItems(i,n,d,t.content_mapping||{}),preferredContentId:r,treeData:t});if(!c)return;const u=t.documents?.[s]||{},p=c.attributes||{},f=p.pdf_start_page_number||o?.custom_metadata?.pdf_start_page_number,l=p.pdf_end_page_number||o?.custom_metadata?.pdf_end_page_number,m=e.safeStringify(u.source_uri||"");return{contract_uuid:s,contract_role:a,source_type:"text",content:{text:e.safeStringify(c.data?.content||c.data?.change_history||"")},...m?{gcs_source_link:m}:{},...f?{pdf_start_page_number:f}:{},...l?{pdf_end_page_number:l}:{}}},d=({treeData:e,nodeId:t,citationNumber:i,citationMap:n,baseContentId:o,compareContentIds:d})=>{if(!e||!t)return;const s=a(e,t);if(!s)return;const c=e.input_index_map||{},u=c[0],p=c[1],f=n?.[i]||{},l={},m=r({treeData:e,node:s,sideIndex:"0",role:"base",citationEntry:u?f[u]:null,preferredContentId:o}),_=r({treeData:e,node:s,sideIndex:"1",role:"compare",citationEntry:p?f[p]:null,preferredContentId:d?.[0]});return m&&(l.base=m),_&&(l.compare=_),l.base||l.compare?l:void 0};exports.buildCitationSources=d,exports.buildOnDemandCitationContexts=({treeData:n,content:r,requestId:s,tabKey:c="deviation",popupNodeId:u,deviationKey:p,sectionTitle:f,referenceSectionTitle:l,docData:m,staticCitations:_,deviationData:I,cognitiveData:b,baseContentId:g,compareContentIds:y})=>{const h=t.extractCitationRequestsFromMarkdown(r),v=new Map,C=e.safeStringify(n?.comparison_id)||e.safeStringify(n?.comparisonId)||s||e.safeStringify(n?.msgRequestId);return h.forEach(e=>{const r=t.parseOnDemandCitationHref(e.href),s=o({href:e.href,popupNodeId:u,treeData:n}),h=p||r.identifierDeviationKey||void 0,D=(({treeData:e,nodeId:t,tabKey:i,deviationKey:n,staticCitations:o,deviationData:r,cognitiveData:d})=>{const s=a(e,t);if("association"===i)return s?.mapping_rationale?.citations||d?.citations||o||{};const c=((e,t)=>{if(!e||"object"!=typeof e)return null;const i=t||"0";return e.deviation_entries?.[i]?e.deviation_entries[i]:e.deviations?.[i]?e.deviations[i]:e[i]?e[i]:e})(s?.evaluation_result,n);return c?.cognitive_decisioning?.citations||r?.cognitive_decisioning?.citations||o||{}})({treeData:n,nodeId:s,tabKey:c,deviationKey:h,staticCitations:_,deviationData:I,cognitiveData:b}),x=d({treeData:n,nodeId:s,citationNumber:e.citationNumber,citationMap:D,baseContentId:g,compareContentIds:y}),N=(({nodeId:e,citationNumber:t,deviationKey:i})=>{if(e)return`${e}:${i||"0"}:${t}`})({nodeId:s,citationNumber:e.citationNumber,deviationKey:h}),T=i.buildOnDemandCitationCacheKey({requestId:C,citationId:N,href:e.href,highlightType:e.highlightType||"both",citationType:e.citationType});v.has(T)||v.set(T,{requestId:C,citationNumber:e.citationNumber,citationId:N,href:e.href,citationLabel:e.citationLabel,citedText:e.citedText,highlightType:e.highlightType||"both",citationType:e.citationType,tabKey:c,sectionTitle:f,referenceSectionTitle:l,sources:x,docData:m,staticCitations:D,deviationData:I,cognitiveData:b})}),Array.from(v.values())},exports.resolveCitationNodeId=o;
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","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":"qKAiBA,MAAMA,EAAYC,GAChBA,GAAUC,OAASD,GAAY,CAAA,EAE3BE,EAAU,CAACF,EAAkDG,KAC7D,IAACA,EAAe,OAAA,KACd,MAAAF,EAAQF,EAASC,GAChB,OAAAC,IAAQE,IAAW,MAGfC,EAAwB,EAACC,KACpCA,EACAC,cACAN,eAMM,MAAAO,EAAUC,4BAA0BH,GACpCJ,EAAQF,EAASC,GAEvB,OAAIO,EAAQE,YAAcR,IAAQM,EAAQE,YACjCF,EAAQE,WAGbF,EAAQG,kBAAoBT,IAAQM,EAAQG,kBACvCH,EAAQG,iBAGVJ,GAAe,MAsFlBK,EAAc,EAClBX,WACAY,OACAC,YACAC,OACAC,gBACAC,yBASM,MAAAC,EAAWjB,E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WF,GAGjCD,EAAiBC,GACZD,EAAiBC,GAGnBD,GA+BiBI,CAAmB/E,GAAMgF,kBAAmB5B,GACpE,OACEsB,GAAiBO,uBAAuBR,WACxChB,GAAewB,uBAAuBR,WACtCjB,GACA,IA8KoB0B,CAAmB,CACrC9F,WACAG,OAAQ8E,EACRlB,SACAC,aAAckB,EACdd,kBACAC,gBACAC,kBAEIb,EAAUR,EAAqB,CACnCjD,WACAG,OAAQ8E,EACR/B,eAAgB8B,EAAK9B,eACrBC,cACAC,gBACAC,sBAEI0C,EA/Dc,GACtB5F,SACA+C,iBACAc,mBAMI,GAAC7D,EACL,MAAO,GAAGA,KAAU6D,GAAgB,OAAOd,KAqDtB8C,CAAgB,CACjC7F,OAAQ8E,EACR/B,eAAgB8B,EAAK9B,eACrBc,aAAckB,IAEVe,EAAWC,EAAAA,8BAA8B,CAC7CpC,UAAWa,EACXoB,aACA1F,KAAM2E,EAAK3E,KACX8F,cAAenB,EAAKmB,eAAiB,OACrCC,aAAcpB,EAAKoB,eAGjB3B,EAAS4B,IAAIJ,IAEjBxB,EAAS6B,IAAIL,EAAU,CACrBnC,UAAWa,EACXzB,eAAgB8B,EAAK9B,eACrB6C,aACA1F,KAAM2E,EAAK3E,KACXkG,cAAevB,EAAKuB,cACpBC,UAAWxB,EAAKwB,UAChBL,cAAenB,EAAKmB,eAAiB,OACrCC,aAAcpB,EAAKoB,aACnBrC,SACAE,eACAC,wBACAT,UACAU,UACAC,gBAAiBjB,EACjBkB,gBACAC,oBAIGmC,MAAMC,KAAKjC,EAASkC"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../CognitiveComparehelpers.js");const e=/\[([^\]]+)\]\(([^)]+)\)/g,i=/<a\b[^>]*href=(["'])(.*?)\1[^>]*>([\s\S]*?)<\/a>/gi,r=e=>t.safeStringify(e).trim().replace(/\\&/g,"&").replace(/&amp;/g,"&"),n=e=>t.safeStringify(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}};exports.extractCitationRequestsFromMarkdown=o=>{const s=(e=>Array.isArray(e)?e.filter(Boolean).join("\n\n"):t.safeStringify(e))(o),l=[];return s.replace(e,(t,e,i,o)=>{const h=c(i);return h.citationNumber&&l.push({href:r(i),citationNumber:h.citationNumber,citationLabel:n(e),citedText:a(s,o),highlightType:h.highlightType||void 0,citationType:h.citationType||void 0,rawMatch:t,index:o}),t}),s.replace(i,(t,e,i,o,h)=>{const p=c(i);return p.citationNumber&&l.push({href:r(i),citationNumber:p.citationNumber,citationLabel:n(o),citedText:a(s,h),highlightType:p.highlightType||void 0,citationType:p.citationType||void 0,rawMatch:t,index:h}),t}),l.sort((t,e)=>t.index-e.index)},exports.getOnDemandCitationLinkKey=t=>{const e=r(t);return[e,c(e).citationNumber||""].join("|")},exports.normalizeOnDemandCitationHref=r,exports.parseOnDemandCitationHref=c;
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","normalizedContent","Array","isArray","filter","Boolean","join","normalizeContent","links","rawMatch","label","details","push","citationLabel","citedText","_quote","sort","a","b","normalized"],"mappings":"mHAMA,MAAMA,EAAsB,2BACtBC,EACJ,qDAGWC,EAAiCC,GAC5CC,gBAAcD,GAAME,OAAOC,QAAQ,OAAQ,KAAKA,QAAQ,SAAU,KAE9DC,EAAaC,GACjBJ,EAAAA,cAAcI,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,MAAMkB,EAAQnB,EAA8BC,GAAMkB,MAAM,8CACjD,OAAAA,IAAQ,IAAM,MAGVC,EAA6BnB,IAClC,MAAAoB,EA9BqB,CAACpB,IACtB,MAAAqB,EAAiBtB,EAA8BC,GAMrD,MAJiB,IADHqB,EAAeC,MAAM,MAEhCC,UACAC,KAA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AAMqD,EAAO7C,KACrE,MAAA8C,EAAUnC,EAA0BnB,GAanC,OAZHsD,EAAQjB,gBACVc,EAAMI,KAAK,CACTvD,KAAMD,EAA8BC,GACpCqC,eAAgBiB,EAAQjB,eACxBmB,cAAepD,EAAUiD,GACzBI,UAAWnD,EAAoBsC,EAAmBpC,GAClDgC,cAAec,EAAQd,oBAAiB,EACxCC,aAAca,EAAQb,mBAAgB,EACtCW,WACA5C,UAGG4C,IAGFD,EAAMQ,KAAK,CAACC,EAAGC,IAAMD,EAAEpD,MAAQqD,EAAErD,2CA9CCR,IACnC,MAAA8D,EAAa/D,EAA8BC,GAEjD,MAAO,CAAC8D,EADQ3C,EAA0B2C,GACdzB,gBAAkB,IAAIY,KAAK"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});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};exports.buildDefaultOnDemandCitationPayload=t,exports.buildOnDemandCitationPayload=(e,a)=>{const i=t(e,a);return e.buildPayload?.(i,a)??i};
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","defaultPayload","buildPayload"],"mappings":"oEAMA,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,sFAmC0C,CAC1CH,EACAC,KAEM,MAAA2B,EAAiB7B,EAAoCC,EAAQC,GACnE,OAAOD,EAAO6B,eAAeD,EAAgB3B,IAAY2B"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../CognitiveComparehelpers.js");exports.normalizeOnDemandCitationResponse=(i,e)=>{const n=((i,e)=>{const n=(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 n.find(t=>t.citation_id===e.citationId)||n.find(i=>t.safeStringify(i.node_uuid)===t.safeStringify(e.citationId?.split(":")[0])&&t.safeStringify(i.dev_index)===t.safeStringify(e.citationId?.split(":")[1]||"0")&&t.safeStringify(i.citation_number)===t.safeStringify(e.citationNumber))||n.find(i=>t.safeStringify(i.citation_number)===t.safeStringify(e.citationNumber))||null})(i,e),a=t.safeStringify(e.citationNumber||n?.citation_number),r=n?.citations;if(!a||!r||"object"!=typeof r)return{};const s=e.docData?.documents||{},o=Object.entries(r).reduce((t,[i,e])=>{const n=s?.[i],a={...e?.customMetaData||{},...e?.custom_metadata||{}},r=a.signed_url||n?.signed_url||n?.signedUrl||n?.metadata?.signed_url||n?.metadata?.signedUrl;return t[i]={...e,custom_metadata:{...a,...a.signed_url||!r?{}:{signed_url:r}}},t},{});return{[a]:o}};
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":["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":"6JAyCiD,CAC/CA,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,EAAAA,cAAcL,EAASM,aAAeD,EAAAA,cAAchB,EAAQe,YAAYG,MAAM,KAAK,KACnFF,EAAAA,cAAcL,EAASQ,aAAeH,gBAAchB,EAAQe,YAAYG,MAAM,KAAK,IAAM,MACzFF,EAAAA,cAAcL,EAASS,mBAAqBJ,EAAAA,cAAchB,EAAQqB,kBAEtEnB,EAAcW,KACXF,GACCK,EAAAA,cAAcL,EAASS,mBAAqBJ,EAAAA,cAAchB,EAAQqB,kBAEtE,MAQsBC,CAA6BvB,EAAUC,GACzDqB,EAAiBL,EAAAA,cACrBhB,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
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=(e,t=e.length)=>{const n=[];for(let l=0;l<t;l+=1){if("|"!==e[l])continue;let t=0;for(let n=l-1;n>=0&&"\\"===e[n];n-=1)t+=1;t%2==0&&n.push(l)}return n};exports.normalizeCompactedGfmTables=t=>t.split("\n").map(t=>{const n=/\|(?:[ \t]*:?-{3,}:?[ \t]*\|){2,}/.exec(t);if(void 0===n?.index)return t;const l=e(n[0]).length-1;if(l<2)return t;const r=e(t,n.index),i=l+1;if(r.length<i)return t;const s=r[r.length-i],c=t.slice(0,s).trimEnd(),o=t.slice(s),p=e(o);let f="",h=0;p.forEach((e,t)=>{if(f+=o.slice(h,e+1),h=e+1,(t+1)%i!==0)return;const n=o.slice(h).match(/^[ \t]*/)?.[0]??"";"|"===o[h+n.length]&&(f+="\n",h+=n.length)}),f+=o.slice(h);const u=f.split("\n");let a=!1;for(let e=0;e<u.length;e+=1){const t=u[e].trim().replace(/^\||\|$/g,"").split("|").map(e=>e.trim());t.length===l&&t.every(e=>/^:?-{3,}:?$/.test(e))&&(a&&e>0&&""!==u[e-1]&&(u.splice(e-1,0,""),e+=1),a=!0)}return f=u.join("\n"),c?`${c}\n\n${f}`:f}).join("\n");
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","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":"oEAAA,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,uCAQmCK,GAC1CA,EAAOC,MAAM,MAAMC,IAAKC,IAChB,MAAAC,EAAY,oCAAoCC,KAAKF,GACvD,QAAqB,IAArBC,GAAWR,MAA4B,OAAAO,EAE3C,MACMG,EADiBf,EAAqBa,EAAU,IACnBV,OAAS,EACxC,GAAAY,EAAc,EAAU,OAAAH,EAE5B,MAAMI,EAAuBhB,EAAqBY,EAAMC,EAAUR,OAC5DY,EAAcF,EAAc,EAC9B,GAAAC,EAAqBb,OAASc,EAAoB,OAAAL,EACtD,MAAMM,EAAaF,EAAqBA,EAAqBb,OAASc,GAEhEE,EAASP,EAAKQ,MAAM,EAAGF,GAAYG,UACnCC,EAAeV,EAAKQ,MAAMF,GAC1BK,EAAcvB,EAAqBsB,GACzC,IAAIE,EAAU,GACVjB,EAAS,EAEDgB,EAAAE,QAAQ,CAACC,EAAYC,KAG1B,GAFLH,GAAWF,EAAaF,MAAMb,EAAQmB,EAAa,GACnDnB,EAASmB,EAAa,GACjBC,EAAY,GAAKV,IAAgB,EAAG,OAEnC,MAAAW,EAAaN,EAAaF,MAAMb,GAAQsB,MAAM,aAAa,IAAM,GACtB,MAA7CP,EAAaf,EAASqB,EAAWzB,UACxBqB,GAAA,KACXjB,GAAUqB,EAAWzB,UAGdqB,GAAAF,EAAaF,MAAMb,GAExB,MAAAuB,EAAeN,EAAQd,MAAM,MACnC,IAAIqB,GAAmB,EAEvB,IAAA,IAASC,EAAY,EAAGA,EAAYF,EAAa3B,OAAQ6B,GAAa,EAAG,CACvE,MAAMC,EAAQH,EAAaE,GACxBE,OACAC,QAAQ,WAAY,IACpBzB,MAAM,KACNC,IAAKyB,GAASA,EAAKF,QAEpBD,EAAM9B,SAAWY,GACjBkB,EAAMI,MAAOD,GAAS,cAAcE,KAAKF,MAIvCL,GAAoBC,EAAY,GAAqC,KAAhCF,EAAaE,EAAY,KAChEF,EAAaS,OAAOP,EAAY,EAAG,EAAG,IACzBA,GAAA,GAEID,GAAA,EACrB,CAIO,OAFGP,EAAAM,EAAaU,KAAK,MAErBrB,EAAS,GAAGA,QAAaK,IAAYA,IAC3CgB,KAAK"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{if(!e||"string"!=typeof e)return e;let t=e;return t=t.replace(/\*\*([^*]*?)\*\*/g,"$1"),t=t.replace(/__([^_]*?)__/g,"$1"),t=t.replace(/\*([^*]*?)\*/g,"$1"),t=t.replace(/_([^_]*?)_/g,"$1"),t=t.replace(/~~([^~]*?)~~/g,"$1"),t=t.replace(/`([^`]*?)`/g,"$1"),t=t.replace(/\[([^\]]*?)\]\([^)]*?\)/g,"$1"),t=t.replace(/<[^>]*?>/g,""),t=t.replace(/\s+/g," "),t.trim()};exports.findTextRangeWithFormatting=(t,r)=>{if(!t||!r)return null;const n=t.indexOf(r);if(-1!==n)return{start:n,end:n+r.length};const l=e(t),i=e(r);if(!l||!i)return null;const f=l.indexOf(i);if(-1===f)return null;const s=function(e,t,r){let n=0,l=0,i=-1,f=-1;for(;n<e.length;){const s=e[n],c=s+e[n+1];let o=0;if("**"===c||"__"===c||"~~"===c)o=2;else if("<["===c){if("<"===s){const t=e.indexOf(">",n);-1!==t&&(o=t-n+1)}else if("["===s){const s=e.indexOf("]",n);if(-1!==s&&"("===e[s+1]){const c=e.indexOf(")",s);if(-1!==c){for(let e=n+1;e<s;e++)if(l===t&&-1===i&&(i=n+1),l++,l===t+r)return f=e+1,-1!==i&&-1!==f?{start:i,end:f}:null;n=c,o=1}}}}else"*"!==s&&"_"!==s&&"`"!==s&&"<"!==s||(o=1);if(o>0)n+=o;else{if(l===t&&-1===i&&(i=n),l++,l===t+r){f=n+1;break}n++}}if(-1===i||-1===f)return null;return{start:i,end:f}}(t,f,i.length);return s},exports.stripMarkdownFormatting=e;
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","originalContent","highlightText","exactIndex","indexOf","start","end","length","normalizedContent","normalizedHighlight","normalizedIndex","result","normalizedStartIndex","normalizedLength","originalPos","normalizedPos","normalizedStartInOriginal","normal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zB,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
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});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(" | ")} |`;exports.normalizeRedlineMarkdown=c=>{if(!c)return"";let g=c.replace(t,"");return g=g.replace(l,"\n\n$1"),g=g.replace(r,(e,t,n)=>`<deleted>${t}</deleted>\n\n| <changed>${n.trim()}</changed> |`),g=(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"),c=l.replace(d,"$1\n");return c.replace(n,(e,t,n,r)=>{if(!n.includes("|"))return e;const l=c.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")})})(g),g=g.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 c=e+1,g=0;const a=[];for(;c<t.length&&""!==t[c].trim();){const e=s(t[c]);if(!e)break;for(;e.length>l;){const t=e.findIndex(e=>""===e);if(-1===t)break;e.splice(t,1)}a.push({lineIndex:c,cells:e}),g=Math.max(g,e.length),c+=1}const h=Math.max(r.length,n.length,g);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")})(g)};
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","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":"oEAAA,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,EAAQU,WAAW,QAAYC,QAC/BX,EAAQY,SAAS,QAAYC,MAE1BV,GAG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,GAASY,EAAkB0B,EACnC,CAEO,OAAAD,EAAMxB,KAAK,OAsGXuC,CAA2BrC"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@mui/icons-material/ChevronRight"),r=require("@mui/icons-material/Close"),o=require("@mui/icons-material/ExpandMore"),n=require("@mui/material/Box"),l=require("@mui/material/Button"),a=require("@mui/material/ButtonBase"),d=require("@mui/material/Divider"),s=require("@mui/material/IconButton"),u=require("@mui/material/Paper"),c=require("@mui/material/Radio"),x=require("@mui/material/Stack"),p=require("@mui/material/TextField"),f=require("@mui/material/Typography"),h=require("./RevertSummaryNotice.js"),g=require("./CognitiveIcon.js"),m=require("./CognitiveScoreBadge.js"),b=require("../../assests/icons/InfoAlert.js");function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var C=E(i),j=E(r),F=E(o),S=E(n),y=E(l),v=E(a),w=E(d),R=E(s),M=E(u),A=E(c),I=E(x),T=E(p),z=E(f);const W=(e,t)=>[e,...Array.isArray(t)?t:null==t?[]:[t]],k="MERGE_ADJACENT";var P=(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))(P||{});const _=e=>Object.values(P).includes(e),N=(e,t,i,r)=>{if(!t||!e)return[];const o=t.additional_decisions,n=Array.isArray(o)?o:o?Object.values(o).flat():[],l=Array.from(new Set([...t.allowed_decisions,...n]));return l.flatMap(t=>{const o=e.focus_page,n=l.find(e=>e.toLowerCase().includes("merge")),a=null!=o&&null!=i&&null!=r&&o===i&&o===r,d=null!=o&&null!=i&&o===i,s=null!=o&&null!=r&&(o===r||o===r+1),u=d||s||!(null!=o&&(!(null!=i&&null!=r)||o>i&&o<r));switch(t){case"SET_RANGE":return[];case"KEEP":return[{id:t,title:"Keep as is",description:"Keep the current document boundary unchanged."}];case"SPLIT_HERE":return[{id:t,title:"Split to a separate document",description:u?"A valid page inside the document is required to split it.":o?`Start a new document at page ${o}.`:"Create a new document at this boundary.",disabled:u}];case"MERGE_PREV":case"MERGE_NEXT":case"MERGE_PREVIOUS":return t!==n?[]:a?[{id:k,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:k,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]}return[]})};exports.BoundaryReviewActionEnum=P,exports.createBoundaryCardOptions=N,exports.default=function({headerName:i="Boundary Check",title:r,pageNo:o,content:n,revertSummary:l,cognitiveScore:a,config:d,metadata:s,previousSegmentTitle:u,nextSegmentTitle:c,selectedIndex:x,defaultSelectedIndex:p=null,defaultStartPage:f,defaultEndPage:E,onSelectionChange:P,onConfirm:B,onActionConfirm:G,onCognitiveClick:D,onAdjustManually:q,onClose:H,confirmLabel:O="Confirm",manualPrompt:V="Didn't find the right option?",manualActionLabel:L="Adjust Manually",cognitiveLabel:U="Cognitive Integrity",showAdjustManually:X=!0,showCognitiveIntegrity:K=!0,showCloseButton:$=!0,confirmDisabled:J=!1,width:Y=260,maxWidth:Q=260,className:Z,styles:ee,reviewAction:te,totalPages:ie}){console.log("LOG: Total pages",ie);const re=t.useMemo(()=>(d??(s?N(s,te,f,E):[])).filter(e=>"SET_RANGE"!==e.id),[d,E,f,s,te]),[oe,ne]=t.useState(p),[le,ae]=t.useState(null==f?"":String(f)),[de,se]=t.useState(null==E?"":String(E)),[ue,ce]=t.useState(!1),[xe,pe]=t.useState(!1),[fe,he]=t.useState(null),[ge,me]=t.useState(!1),be=void 0===x?oe:x,Ee=null==be?void 0:re[be],Ce=Ee?.id===k,je=null!=u,Fe=null!=c,Se=e=>!0===e.disabled||"MERGE_PREV"===e.id&&!je||"MERGE_PREVIOUS"===e.id&&!je||"MERGE_NEXT"===e.id&&!Fe||e.id===k&&!je&&!Fe,ye=Number(le),ve=Number(de),we=le.trim().length>0&&de.trim().length>0&&Number.isInteger(ye)&&Number.isInteger(ve)&&ye>0&&ve>0,Re=null!=ie&&ye>ie,Me=null!=ie&&ve>ie,Ae=le.trim().length>0&&de.trim().length>0&&Number.isInteger(ye)&&Number.isInteger(ve)&&ye>ve,Ie=we&&ye<=ve&&!Re&&!Me,Te=Ie&&ye===f&&ve===E,ze=J||!Ee||Se(Ee)||Ce&&null==fe||!B&&!G;return e.jsx(M.default,{className:Z,elevation:4,sx:W({width:Y,maxWidth:Q,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",boxSizing:"border-box","@media (max-width: 372px)":{width:"calc(100vw - 32px)"}},ee?.root),children:e.jsxs(I.default,{spacing:.75,sx:{p:1},children:[e.jsxs(I.default,{direction:"row",alignItems:"center",spacing:.75,sx:ee?.header,children:[e.jsx(b.default,{color:"error",height:16,width:16}),e.jsx(z.default,{sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"},children:i}),$&&e.jsx(R.default,{size:"small",onClick:H,disabled:!H,"aria-label":"Close boundary check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}},children:e.jsx(j.default,{sx:{fontSize:17}})})]}),e.jsxs(S.default,{children:[e.jsx(z.default,{sx:{color:"text.primary",fontSize:14,fontWeight:500},children:r}),null!=o&&e.jsx(z.default,{sx:{mt:.125,color:"text.secondary",fontSize:12},children:o}),e.jsx(w.default,{sx:{my:.625}}),null!=l?e.jsx(h.default,{children:l}):null!=n&&e.jsx(z.default,{component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3},children:n})]}),e.jsxs(I.default,{spacing:.625,role:"radiogroup","aria-label":"Boundary options",children:[re.map((t,i)=>{const r=be===i,o=Se(t);return e.jsxs(M.default,{variant:"outlined",sx:W({borderColor:r?"#1976d2":"divider",borderRadius:2,bgcolor:o?"#F8FAFC":"background.paper",overflow:"hidden"},ee?.option),children:[e.jsxs(v.default,{role:"radio","aria-checked":r,disabled:J||o,onClick:()=>((e,t)=>{J||Se(t)||(void 0===x&&ne(e),t.id!==k&&he(null),ue&&(ce(!1),pe(!1)),P?.(e,t))})(i,t),sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left"},children:[e.jsx(A.default,{checked:r,disabled:J||o,tabIndex:-1,size:"small",sx:{p:.25,mr:.5,"&.Mui-disabled":{color:"#CBD5E1"}}}),e.jsxs(S.default,{sx:{minWidth:0},children:[e.jsx(z.default,{sx:{color:o?"#94A3B8":"text.primary",fontSize:12.5,fontWeight:500},children:t.title}),null!=t.description&&e.jsx(z.default,{sx:{mt:.125,color:o?"#94A3B8":"text.secondary",fontSize:11},children:t.description})]})]}),r&&t.id===k&&e.jsx(I.default,{direction:"row",spacing:.75,sx:W({px:.75,pb:.75},ee?.adjacentSelector),children:[{direction:"previous",title:u??"No Previous document",caption:"← Merge into Previous",available:je},{direction:"next",title:c??"No Next document",caption:"Merge into Next →",available:Fe}].map(t=>{const i=fe===t.direction;return e.jsxs(I.default,{sx:{flex:1,minWidth:0},children:[e.jsx(v.default,{disabled:J||!t.available,onClick:()=>he(t.direction),"aria-pressed":i,sx:{width:"100%",minWidth:0,minHeight:46,alignItems:"flex-start",justifyContent:"flex-start",p:.625,border:"1px solid",borderColor:i?"#7F56D9":"#D0D5DD",borderRadius:1.5,bgcolor:i?"#E0E7FF":"background.paper",color:i?"#7F56D9":t.available?"text.primary":"#98A2B3",textAlign:"left","&.Mui-disabled":{color:"#98A2B3",bgcolor:"#F8FAFC"}},children:e.jsx(z.default,{sx:{color:"inherit",fontSize:11,fontWeight:500,lineHeight:1.25,overflowWrap:"anywhere"},children:t.title})}),e.jsx(z.default,{sx:{mt:.5,color:i?"#5925DC":"text.secondary",fontSize:9.5,lineHeight:1.2,whiteSpace:"nowrap",textAlign:"next"===t.direction?"right":"left"},children:t.caption})]},t.direction)})})]},t.id)}),Ce&&null!=fe&&e.jsxs(I.default,{direction:"row",alignItems:"flex-start",spacing:.625,sx:W({p:.75,border:"1px solid #FCA5A5",borderRadius:1.5,bgcolor:"#FEF2F2"},ee?.impactWarning),children:[e.jsx(b.default,{color:"error",height:14,width:14,sx:{mt:.125}}),e.jsxs(z.default,{sx:{color:"#DC2626",fontSize:10.5,lineHeight:1.4},children:["This will impact the ",fe," document. Its content and page range will change."]})]}),e.jsx(y.default,{variant:"contained",fullWidth:!0,disabled:ze,onClick:()=>{if(ze||null==be||!Ee)return;const e=Ce?"previous"===fe?"MERGE_PREVIOUS":"MERGE_NEXT":Ee.id,t=Ce?{...Ee,id:e}:Ee,i={selectedIndex:be,option:t,metadata:s};B?.(be,t,i),G&&_(e)&&G(e,i)},sx:W({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},ee?.confirmButton),children:O})]}),X&&e.jsxs(I.default,{spacing:.625,sx:ee?.manualSection,children:[e.jsxs(v.default,{disabled:J,onClick:()=>{const e=!ue;ce(e),pe(!1),e&&(void 0===x&&ne(null),q?.())},"aria-expanded":ue,sx:{width:"100%",justifyContent:"space-between",borderRadius:1,textAlign:"left"},children:[e.jsx(S.default,{children:e.jsx(z.default,{sx:{color:"text.primary",fontSize:12,fontWeight:600},children:V})}),e.jsx(F.default,{sx:{color:"text.secondary",fontSize:16,transform:ue?"rotate(180deg)":"none",transition:"transform 150ms ease"}})]}),ue&&!xe&&e.jsxs(S.default,{sx:{pt:.5,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif'},children:[e.jsxs(S.default,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"},children:[e.jsx(z.default,{sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0},children:"Starts"}),e.jsx(z.default,{sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0},children:"Ends"})]}),e.jsxs(S.default,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"},children:[e.jsxs(S.default,{children:[e.jsx(T.default,{size:"small",type:"text",value:le,disabled:J,error:Re||Ae,onChange:e=>{const t=e.target.value;/^\d*$/.test(t)&&ae(t)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Re||Ae?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Re||Ae?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Re||Ae?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Re&&e.jsxs(z.default,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:["Must be ≤ ",ie," (total pages)"]}),Ae&&!Re&&e.jsx(z.default,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:"Must be ≤ end page"})]}),e.jsxs(S.default,{children:[e.jsx(T.default,{size:"small",type:"text",value:de,disabled:J,error:Me||Ae,onChange:e=>{const t=e.target.value;/^\d*$/.test(t)&&se(t)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Me||Ae?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Me||Ae?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Me||Ae?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Me&&e.jsxs(z.default,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:["Must be ≤ ",ie," (total pages)"]}),Ae&&!Me&&e.jsx(z.default,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:"Must be ≥ start page"})]})]}),e.jsx(S.default,{children:e.jsx(y.default,{onClick:()=>{Ie&&(Te?me(!0):pe(!0))},disabled:J||!Ie||Te,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":!Ie||Te?{}:{backgroundColor:"#FAF9FF",borderColor:"#7F6FF0"},"&:active":!Ie||Te?{}:{transform:"translateY(1px)"},"&.Mui-disabled":{backgroundColor:"#FFFFFF",borderColor:"#C3CFDC",color:"#A0ABBE",cursor:"not-allowed"}},children:"Apply"})}),Te&&ge&&e.jsx(S.default,{sx:{backgroundColor:"#FEF3C7",border:"1px solid #FBBF24",borderRadius:"6px",padding:"8px 10px",marginTop:"4px"},children:e.jsx(z.default,{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.jsx(S.default,{sx:{width:"100%",height:"1px",marginTop:"8px",backgroundColor:"#EEF0F2",border:"0"}})]}),ue&&xe&&e.jsxs(I.default,{spacing:.75,sx:W({p:.75,borderRadius:1.5,bgcolor:"#FFF7ED"},ee?.manualConfirmation),children:[e.jsxs(I.default,{direction:"row",alignItems:"center",spacing:.5,children:[e.jsx(b.default,{color:"warning",height:14,width:14}),e.jsx(z.default,{sx:{color:"#EA580C",fontSize:11,fontWeight:600},children:"Confirm this change?"})]}),e.jsxs(z.default,{sx:{color:"text.secondary",fontSize:10.5,lineHeight:1.4},children:["Pages ",ye,"-",ve," will become part of ",r,", including pages from other documents in this range."]}),e.jsxs(I.default,{direction:"row",spacing:.75,children:[e.jsx(y.default,{variant:"outlined",fullWidth:!0,onClick:()=>pe(!1),sx:{minHeight:28,borderRadius:1.5,fontSize:11,textTransform:"none"},children:"Cancel"}),e.jsx(y.default,{variant:"contained",fullWidth:!0,disabled:J||!B||!Ie||Te,onClick:()=>{if(!Ie||Te||!B)return;const e={id:"SET_RANGE",title:L};B(-1,e,{selectedIndex:-1,option:e,startPage:ye,endPage:ve,metadata:s})},sx:{minHeight:28,borderRadius:1.5,bgcolor:"#EA580C",fontSize:11,textTransform:"none","&:hover":{bgcolor:"#C2410C"}},children:"Confirm"})]})]})]}),e.jsx(I.default,{spacing:.625,sx:ee?.footer,children:K&&e.jsxs(e.Fragment,{children:[e.jsx(w.default,{}),e.jsxs(v.default,{onClick:D,disabled:!D,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:D?"pointer":"not-allowed"},children:[e.jsxs(I.default,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(g.default,{sx:{color:"text.secondary"}}),e.jsx(z.default,{sx:{color:"text.primary",fontSize:12},children:U})]}),e.jsxs(I.default,{direction:"row",alignItems:"center",spacing:.5,children:[e.jsx(m.default,{score:a}),e.jsx(C.default,{sx:{color:"text.secondary"}})]})]})]})})]})})},exports.isBoundaryReviewAction=_;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@mui/icons-material/ChevronRight"),r=require("@mui/icons-material/Close"),o=require("@mui/icons-material/ExpandMore"),n=require("@mui/material/Box"),l=require("@mui/material/Button"),a=require("@mui/material/ButtonBase"),d=require("@mui/material/Divider"),s=require("@mui/material/IconButton"),u=require("@mui/material/Paper"),c=require("@mui/material/Radio"),x=require("@mui/material/Stack"),h=require("@mui/material/TextField"),f=require("@mui/material/Typography"),p=require("./RevertSummaryNotice.js"),g=require("./CognitiveIcon.js"),m=require("./CognitiveScoreBadge.js"),b=require("../../assests/icons/InfoAlert.js");function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var C=E(i),j=E(r),F=E(o),S=E(n),y=E(l),v=E(a),R=E(d),w=E(s),M=E(u),A=E(c),I=E(x),T=E(h),W=E(f);const z=(e,t)=>[e,...Array.isArray(t)?t:null==t?[]:[t]],k="MERGE_ADJACENT";var P=(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))(P||{});const _=e=>Object.values(P).includes(e),N=(e,t,i,r)=>{if(!t||!e)return[];const o=t.additional_decisions,n=Array.isArray(o)?o:o?Object.values(o).flat():[],l=Array.from(new Set([...t.allowed_decisions,...n]));return l.flatMap(t=>{const o=e.focus_page,n=l.find(e=>e.toLowerCase().includes("merge")),a=null!=o&&null!=i&&null!=r&&o===i&&o===r,d=null!=o&&null!=i&&o===i,s=null!=o&&null!=r&&(o===r||o===r+1),u=d||s||!(null!=o&&(!(null!=i&&null!=r)||o>i&&o<r));switch(t){case"SET_RANGE":return[];case"KEEP":return[{id:t,title:"Keep as is",description:"Keep the current document boundary unchanged."}];case"SPLIT_HERE":return[{id:t,title:"Split to a separate document",description:u?"A valid page inside the document is required to split it.":o?`Start a new document at page ${o}.`:"Create a new document at this boundary.",disabled:u}];case"MERGE_PREV":case"MERGE_NEXT":case"MERGE_PREVIOUS":return t!==n?[]:a?[{id:k,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:k,title:"Merge with an adjacent document",description:"Choose to merge with the previous or next document."}]}return[]})};exports.BoundaryReviewActionEnum=P,exports.createBoundaryCardOptions=N,exports.default=function({headerName:i="Boundary Check",title:r,pageNo:o,content:n,revertSummary:l,cognitiveScore:a,config:d,metadata:s,previousSegmentTitle:u,nextSegmentTitle:c,selectedIndex:x,defaultSelectedIndex:h=null,defaultStartPage:f,defaultEndPage:E,onSelectionChange:P,onConfirm:B,onActionConfirm:G,onCognitiveClick:D,onAdjustManually:q,onClose:H,confirmLabel:O="Confirm",manualPrompt:V="Didn't find the right option?",manualActionLabel:L="Adjust Manually",cognitiveLabel:U="Cognitive Integrity",showAdjustManually:X=!0,showCognitiveIntegrity:K=!0,showCloseButton:$=!0,confirmDisabled:J=!1,width:Y=260,maxWidth:Q="100%",className:Z,styles:ee,reviewAction:te,totalPages:ie}){console.log("LOG: Total pages",ie);const re=t.useMemo(()=>(d??(s?N(s,te,f,E):[])).filter(e=>"SET_RANGE"!==e.id),[d,E,f,s,te]),[oe,ne]=t.useState(h),[le,ae]=t.useState(null==f?"":String(f)),[de,se]=t.useState(null==E?"":String(E)),[ue,ce]=t.useState(!1),[xe,he]=t.useState(!1),[fe,pe]=t.useState(null),[ge,me]=t.useState(!1),be=void 0===x?oe:x,Ee=null==be?void 0:re[be],Ce=Ee?.id===k,je=null!=u,Fe=null!=c,Se=e=>!0===e.disabled||"MERGE_PREV"===e.id&&!je||"MERGE_PREVIOUS"===e.id&&!je||"MERGE_NEXT"===e.id&&!Fe||e.id===k&&!je&&!Fe,ye=Number(le),ve=Number(de),Re=le.trim().length>0&&de.trim().length>0&&Number.isInteger(ye)&&Number.isInteger(ve)&&ye>0&&ve>0,we=null!=ie&&ye>ie,Me=null!=ie&&ve>ie,Ae=le.trim().length>0&&de.trim().length>0&&Number.isInteger(ye)&&Number.isInteger(ve)&&ye>ve,Ie=Re&&ye<=ve&&!we&&!Me,Te=Ie&&ye===f&&ve===E,We=J||!Ee||Se(Ee)||Ce&&null==fe||!B&&!G;return e.jsx(M.default,{className:Z,elevation:4,sx:z({width:Y,maxWidth:Q,borderTop:"4px solid",borderColor:"error.main",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",boxSizing:"border-box",minWidth:0},ee?.root),children:e.jsxs(I.default,{spacing:.75,sx:{p:1},children:[e.jsxs(I.default,{direction:"row",alignItems:"center",spacing:.75,sx:ee?.header,children:[e.jsx(b.default,{color:"error",height:16,width:16}),e.jsx(W.default,{sx:{flex:1,color:"error.main",fontSize:12,fontWeight:500,lineHeight:1.25,textTransform:"uppercase"},children:i}),$&&e.jsx(w.default,{size:"small",onClick:H,disabled:!H,"aria-label":"Close boundary check",sx:{p:0,"&.Mui-disabled":{color:"text.secondary"}},children:e.jsx(j.default,{sx:{fontSize:17}})})]}),e.jsxs(S.default,{children:[e.jsx(W.default,{sx:{color:"text.primary",fontSize:14,fontWeight:500},children:r}),null!=o&&e.jsx(W.default,{sx:{mt:.125,color:"text.secondary",fontSize:12},children:o}),e.jsx(R.default,{sx:{my:.625}}),null!=l?e.jsx(p.default,{children:l}):null!=n&&e.jsx(W.default,{component:"div",sx:{color:"text.secondary",fontSize:11.5,lineHeight:1.3},children:n})]}),e.jsxs(I.default,{spacing:.625,role:"radiogroup","aria-label":"Boundary options",children:[re.map((t,i)=>{const r=be===i,o=Se(t);return e.jsxs(M.default,{variant:"outlined",sx:z({borderColor:r?"#1976d2":"divider",borderRadius:2,bgcolor:o?"#F8FAFC":"background.paper",overflow:"hidden"},ee?.option),children:[e.jsxs(v.default,{role:"radio","aria-checked":r,disabled:J||o,onClick:()=>((e,t)=>{J||Se(t)||(void 0===x&&ne(e),t.id!==k&&pe(null),ue&&(ce(!1),he(!1)),P?.(e,t))})(i,t),sx:{width:"100%",justifyContent:"flex-start",px:.75,py:.5,textAlign:"left"},children:[e.jsx(A.default,{checked:r,disabled:J||o,tabIndex:-1,size:"small",sx:{p:.25,mr:.5,"&.Mui-disabled":{color:"#CBD5E1"}}}),e.jsxs(S.default,{sx:{minWidth:0},children:[e.jsx(W.default,{sx:{color:o?"#94A3B8":"text.primary",fontSize:12.5,fontWeight:500},children:t.title}),null!=t.description&&e.jsx(W.default,{sx:{mt:.125,color:o?"#94A3B8":"text.secondary",fontSize:11},children:t.description})]})]}),r&&t.id===k&&e.jsx(I.default,{direction:"row",spacing:.75,sx:z({px:.75,pb:.75,minWidth:0,"& > *":{minWidth:0}},ee?.adjacentSelector),children:[{direction:"previous",title:u??"No Previous document",caption:"← Merge into Previous",available:je},{direction:"next",title:c??"No Next document",caption:"Merge into Next →",available:Fe}].map(t=>{const i=fe===t.direction;return e.jsxs(I.default,{sx:{flex:1,minWidth:0},children:[e.jsx(v.default,{disabled:J||!t.available,onClick:()=>pe(t.direction),"aria-pressed":i,sx:{width:"100%",minWidth:0,minHeight:46,alignItems:"flex-start",justifyContent:"flex-start",p:.625,border:"1px solid",borderColor:i?"#7F56D9":"#D0D5DD",borderRadius:1.5,bgcolor:i?"#E0E7FF":"background.paper",color:i?"#7F56D9":t.available?"text.primary":"#98A2B3",textAlign:"left","&.Mui-disabled":{color:"#98A2B3",bgcolor:"#F8FAFC"}},children:e.jsx(W.default,{sx:{color:"inherit",fontSize:11,fontWeight:500,lineHeight:1.25,overflowWrap:"anywhere"},children:t.title})}),e.jsx(W.default,{sx:{mt:.5,color:i?"#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)}),Ce&&null!=fe&&e.jsxs(I.default,{direction:"row",alignItems:"flex-start",spacing:.625,sx:z({p:.75,border:"1px solid #FCA5A5",borderRadius:1.5,bgcolor:"#FEF2F2"},ee?.impactWarning),children:[e.jsx(b.default,{color:"error",height:14,width:14,sx:{mt:.125}}),e.jsxs(W.default,{sx:{color:"#DC2626",fontSize:10.5,lineHeight:1.4},children:["This will impact the ",fe," document. Its content and page range will change."]})]}),e.jsx(y.default,{variant:"contained",fullWidth:!0,disabled:We,onClick:()=>{if(We||null==be||!Ee)return;const e=Ce?"previous"===fe?"MERGE_PREVIOUS":"MERGE_NEXT":Ee.id,t=Ce?{...Ee,id:e}:Ee,i={selectedIndex:be,option:t,metadata:s};B?.(be,t,i),G&&_(e)&&G(e,i)},sx:z({minHeight:32,mt:.25,borderRadius:2,fontSize:13,fontWeight:600,textTransform:"none",backgroundColor:"#5925DC","&:hover":{backgroundColor:"#4A1FB8"},"&.Mui-disabled":{backgroundColor:"#D9D6FE",color:"#FFFFFF"}},ee?.confirmButton),children:O})]}),X&&e.jsxs(I.default,{spacing:.625,sx:ee?.manualSection,children:[e.jsxs(v.default,{disabled:J,onClick:()=>{const e=!ue;ce(e),he(!1),e&&(void 0===x&&ne(null),q?.())},"aria-expanded":ue,sx:{width:"100%",justifyContent:"space-between",borderRadius:1,textAlign:"left"},children:[e.jsx(S.default,{children:e.jsx(W.default,{sx:{color:"text.primary",fontSize:12,fontWeight:600},children:V})}),e.jsx(F.default,{sx:{color:"text.secondary",fontSize:16,transform:ue?"rotate(180deg)":"none",transition:"transform 150ms ease"}})]}),ue&&!xe&&e.jsxs(S.default,{sx:{pt:.5,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif'},children:[e.jsxs(S.default,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"},children:[e.jsx(W.default,{sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0},children:"Starts"}),e.jsx(W.default,{sx:{fontSize:"10.5px",fontWeight:400,lineHeight:"14px",color:"#57697E",margin:0},children:"Ends"})]}),e.jsxs(S.default,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",columnGap:"8px",mb:"4px"},children:[e.jsxs(S.default,{children:[e.jsx(T.default,{size:"small",type:"text",value:le,disabled:J,error:we||Ae,onChange:e=>{const t=e.target.value;/^\d*$/.test(t)&&ae(t)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:we||Ae?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:we||Ae?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:we||Ae?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),we&&e.jsxs(W.default,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:["Must be ≤ ",ie," (total pages)"]}),Ae&&!we&&e.jsx(W.default,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:"Must be ≤ end page"})]}),e.jsxs(S.default,{children:[e.jsx(T.default,{size:"small",type:"text",value:de,disabled:J,error:Me||Ae,onChange:e=>{const t=e.target.value;/^\d*$/.test(t)&&se(t)},inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{"& .MuiOutlinedInput-root":{height:"30px",backgroundColor:"#FFFFFF","& fieldset":{borderColor:Me||Ae?"#EF4444":"#C3CFDC",borderWidth:"1px",borderRadius:"6px"},"&:hover fieldset":{borderColor:Me||Ae?"#EF4444":"#C3CFDC"},"&.Mui-focused fieldset":{borderColor:Me||Ae?"#EF4444":"#9488F6",borderWidth:"1px"}},"& .MuiOutlinedInput-input":{fontSize:"12px",fontWeight:400,lineHeight:"1",color:"#34445A",padding:"0 10px",height:"30px"}}}),Me&&e.jsxs(W.default,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:["Must be ≤ ",ie," (total pages)"]}),Ae&&!Me&&e.jsx(W.default,{sx:{fontSize:"10px",color:"#EF4444",marginTop:"2px",fontWeight:500},children:"Must be ≥ start page"})]})]}),e.jsx(S.default,{children:e.jsx(y.default,{onClick:()=>{Ie&&(Te?me(!0):he(!0))},disabled:J||!Ie||Te,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":!Ie||Te?{}:{backgroundColor:"#FAF9FF",borderColor:"#7F6FF0"},"&:active":!Ie||Te?{}:{transform:"translateY(1px)"},"&.Mui-disabled":{backgroundColor:"#FFFFFF",borderColor:"#C3CFDC",color:"#A0ABBE",cursor:"not-allowed"}},children:"Apply"})}),Te&&ge&&e.jsx(S.default,{sx:{backgroundColor:"#FEF3C7",border:"1px solid #FBBF24",borderRadius:"6px",padding:"8px 10px",marginTop:"4px"},children:e.jsx(W.default,{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.jsx(S.default,{sx:{width:"100%",height:"1px",marginTop:"8px",backgroundColor:"#EEF0F2",border:"0"}})]}),ue&&xe&&e.jsxs(I.default,{spacing:.75,sx:z({p:.75,borderRadius:1.5,bgcolor:"#FFF7ED"},ee?.manualConfirmation),children:[e.jsxs(I.default,{direction:"row",alignItems:"center",spacing:.5,children:[e.jsx(b.default,{color:"warning",height:14,width:14}),e.jsx(W.default,{sx:{color:"#EA580C",fontSize:11,fontWeight:600},children:"Confirm this change?"})]}),e.jsxs(W.default,{sx:{color:"text.secondary",fontSize:10.5,lineHeight:1.4},children:["Pages ",ye,"-",ve," will become part of ",r,", including pages from other documents in this range."]}),e.jsxs(I.default,{direction:"row",spacing:.75,children:[e.jsx(y.default,{variant:"outlined",fullWidth:!0,onClick:()=>he(!1),sx:{minHeight:28,borderRadius:1.5,fontSize:11,textTransform:"none"},children:"Cancel"}),e.jsx(y.default,{variant:"contained",fullWidth:!0,disabled:J||!B||!Ie||Te,onClick:()=>{if(!Ie||Te||!B)return;const e={id:"SET_RANGE",title:L};B(-1,e,{selectedIndex:-1,option:e,startPage:ye,endPage:ve,metadata:s})},sx:{minHeight:28,borderRadius:1.5,bgcolor:"#EA580C",fontSize:11,textTransform:"none","&:hover":{bgcolor:"#C2410C"}},children:"Confirm"})]})]})]}),e.jsx(I.default,{spacing:.625,sx:ee?.footer,children:K&&e.jsxs(e.Fragment,{children:[e.jsx(R.default,{}),e.jsxs(v.default,{onClick:D,disabled:!D,sx:{justifyContent:"space-between",borderRadius:1,textAlign:"left",cursor:D?"pointer":"not-allowed"},children:[e.jsxs(I.default,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(g.default,{sx:{color:"text.secondary"}}),e.jsx(W.default,{sx:{color:"text.primary",fontSize:12},children:U})]}),e.jsxs(I.default,{direction:"row",alignItems:"center",spacing:.5,children:[e.jsx(m.default,{score:a}),e.jsx(C.default,{sx:{color:"text.secondary"}})]})]})]})})]})})},exports.isBoundaryReviewAction=_;
2
2
  //# sourceMappingURL=BoundaryCard.js.map