@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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=({containerRef:n,leftContainerRef:r,rightContainerRef:i,svgContainerRef:c,pathRefs:l,leftHeaderRef:u,rightHeaderRef:s,proposedSections:o,existingSections:h,visibleFields:g,leftRefs:a,rightRefs:d,sectionLeftRefs:f,sectionRightRefs:p,subSectionLeftRefs:b,subSectionRightRefs:A,lhsBadgeRefs:y,rhsBadgeRefs:$,sectionRowRefs:R,expandedSections:x,expandedSubSections:m,connectedSections:B,isSideBySide:S,activeSideBySideSection:I,maintainRelativeOrder:T,isGuidelineMode:C,cognitiveMap:E,getSectionCompareStyle:M,getSubSectionCompareStyle:v,getDeviationStyleByKey:D,isArrowVisible:O,isAnimatingRef:L,isSideBySideRef:_,sideBySideCacheRef:F,sideBySideLineRef:N,activeSideBySideSectionRef:H,activeSideBySideRightSectionRef:P,connectedLines:k,setConnectedLines:w,cachedConnectedPositions:G,calculateLinesRef:V,resizeTimerRef:Y,scrollLock:j,scrollSyncLocked:z,handleResizeRef:Q,activeProposed:X,existingRule:q,analysisData:K,pendingScrollTargetRef:J,pendingScrollCallbackRef:U,resolvedComparisonConfig:W,getFieldData:Z})=>{const[tt,et]=t.useState([]),[nt,rt]=t.useState(null),[it,ct]=t.useState([]),lt=k??it,ut=w??ct,[st,ot]=t.useState({width:0,height:0}),ht=t.useRef(!1),gt=t.useRef(!1),at=t.useRef(!1),dt=t.useRef(null),ft=t.useRef([]),pt=G??ft,bt=(t,e,n,r,i,c,l)=>{if(Math.abs(r-e)<=1)return c&&l?`M ${t},${e} L ${n},${r}`:c&&!l?`M ${t},${e} L ${i},${e}`:!c&&l?`M ${i},${e} L ${n},${r}`:`M ${i},${e} L ${i},${r}`;const u=Math.min(15,Math.abs(i-t),Math.abs(r-e)/2),s=Math.min(15,Math.abs(n-i),Math.abs(r-e)/2),o=r>e?u:-u,h=r>e?s:-s,g=n>i?s:-s;return c&&l?`M ${t},${e} L ${i-u},${e} Q ${i},${e} ${i},${e+o} L ${i},${r-h} Q ${i},${r} ${i+g},${r} L ${n},${r}`:c&&!l?`M ${t},${e} L ${i-u},${e} Q ${i},${e} ${i},${e+o} L ${i},${r}`:!c&&l?`M ${i},${e} L ${i},${r-h} Q ${i},${r} ${i+g},${r} L ${n},${r}`:`M ${i},${e} L ${i},${r}`},At=t.useCallback(()=>{if(!ht.current&&!L.current){ht.current=!0;try{if(!n.current)return;const t=t=>{const e=t.split("-"),n=e[0];if(!x[n]&&!1===T)return!1;if(T&&!x[`left-${n}`]&&!x[`right-${n}`]&&!x[n])return!1;let r=n;for(let t=1;t<e.length-1;t++)if(r+=`-${e[t]}`,!m[r])return!1;return!0},c=n.current.getBoundingClientRect();ot({width:c.width,height:c.height});const l=[];if(g.forEach(({key:t})=>{const e=a.current[t]?.current,n=d.current[t]?.current;e&&n&&(e.style.height="auto",n.style.height="auto",e.style.minHeight="0px",n.style.minHeight="0px")}),!L.current){for(let t=0;t<Math.max(o.length,h.length);t++){const e=f.current[t]?.current,n=p.current[t]?.current;e&&(e.style.height="auto",e.style.minHeight="0px"),n&&(n.style.height="auto",n.style.minHeight="0px")}T||Object.keys(b.current).forEach(e=>{if(!t(e))return;const n=b.current[e]?.current,r=A.current[e]?.current;n&&r&&(n.style.height="auto",r.style.height="auto",n.style.minHeight="0px",r.style.minHeight="0px")})}const R={};g.forEach(({key:t})=>{const e=a.current[t]?.current,n=d.current[t]?.current;if(e&&n){const r=e.getBoundingClientRect(),i=n.getBoundingClientRect();R[t]=Math.max(r.height,i.height)}});const O={left:{},right:{}},_={};if(!L.current)if(T){if(S&&null!==I)if("number"==typeof I){const t=I,e=o[t],n=f.current[t]?.current;n&&e&&(e.refIndexes||[]).forEach(e=>{const r=h.findIndex(t=>t.selfIndex===e),i=p.current[r]?.current;if(i&&(x[`left-${t}`]||x[`right-${r}`])){const e=Math.max(n.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[t]=Math.max(O.left[t]||0,e),O.right[r]=Math.max(O.right[r]||0,e)}})}else{const t=I.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(t){const e=b.current[t]?.current,n=A.current[t]?.current;if(e&&n){const r=Math.max(e.getBoundingClientRect().height,n.getBoundingClientRect().height);_[t]=Math.max(_[t]||0,r)}}}}else{Object.keys(b.current).forEach(e=>{if(!t(e))return;const n=b.current[e]?.current,r=A.current[e]?.current;if(n&&r&&null!==n.offsetParent&&null!==r.offsetParent){const t=n.getBoundingClientRect(),i=r.getBoundingClientRect(),c=Math.max(t.height,i.height);_[e]=c,n.style.minHeight=`${c}px`,r.style.minHeight=`${c}px`}});for(let t=0;t<Math.min(o.length,h.length);t++){const e=f.current[t]?.current,n=p.current[t]?.current;if(e&&n){const r=Math.max(e.getBoundingClientRect().height,n.getBoundingClientRect().height);O.left[t]=r,O.right[t]=r}}}if(g.forEach(({key:t})=>{const e=a.current[t]?.current,n=d.current[t]?.current;if(e&&n){const r=R[t];e.style.minHeight=`${r}px`,n.style.minHeight=`${r}px`}}),L.current||(Object.entries(O.left).forEach(([t,e])=>{const n=f.current[Number(t)]?.current;n&&(n.style.minHeight=`${e}px`)}),Object.entries(O.right).forEach(([t,e])=>{const n=p.current[Number(t)]?.current;n&&(n.style.minHeight=`${e}px`)}),T||Object.keys(_).forEach(t=>{const e=b.current[t]?.current,n=A.current[t]?.current;if(e&&n&&_[t]){const r=_[t];e.style.minHeight=`${r}px`,n.style.minHeight=`${r}px`}})),!C){const t=(t,e)=>{if(!T)return h[e]?[e]:[];const n=(t.refIndexes||[]).map(t=>h.findIndex(e=>e.selfIndex===t)).filter(t=>-1!==t);return!n.length&&h[e]?[e]:Array.from(new Set(n))};o.forEach((e,n)=>{const u=e.continuationSourceRowId?o.findIndex(t=>t.comparisonRowId===e.continuationSourceRowId):-1,s=u>=0?u:n,g=f.current[s]?.current;if(!g)return;t(e,n).forEach(t=>{const e=p.current[t]?.current;if(!e)return;const a=g.getBoundingClientRect(),d=e.getBoundingClientRect(),f=a.right-c.left,b=d.left-c.left;let A=a.top+18-c.top,y=d.top+18-c.top;if(T&&S&&I===n){const t=r.current?.getBoundingClientRect().top??0,e=i.current?.getBoundingClientRect().top??0,n=t+(r.current?.clientHeight??1/0),l=e+(i.current?.clientHeight??1/0),u=(t,e,n)=>Math.max(e,Math.min(n,t));A=u(a.top+18,t,n)-c.top,y=u(d.top+18,e,l)-c.top}const $=M(s);$&&l.push({id:`line-${s}-${t}`,x1:f,y1:A,x2:b,y2:y,style:$,sectionIdx:s,targetRightIdx:t,isSubSection:!1,isMappingContinuation:u>=0,hasCognitive:!!(o[s]?.cognitiveData||h[t]?.cognitiveData||o[s]?.nodeId&&E[o[s].nodeId])})})})}if(!C&&S&&"string"==typeof I&&I.includes(e.DEVIATION_BADGE_SEPARATOR)){const[t,n,u,s]=I.split(e.DEVIATION_BADGE_SEPARATOR),o=`${t}${e.DEVIATION_BADGE_SEPARATOR}${n}`,h=y.current[o]?.current,g=$.current[o]?.current;if(h&&g){const e=h.getBoundingClientRect(),s=g.getBoundingClientRect(),a=e.right-c.left,d=s.left-c.left;let f=e.top+e.height/2-c.top,p=s.top+s.height/2-c.top;if(T){const t=r.current?.getBoundingClientRect().top??0,n=i.current?.getBoundingClientRect().top??0,l=t+(r.current?.clientHeight??1/0),u=n+(i.current?.clientHeight??1/0),o=(t,e,n)=>Math.max(e,Math.min(n,t));f=o(e.top+e.height/2,t,l)-c.top,p=o(s.top+s.height/2,n,u)-c.top}const b=D(t,n)??v(u);b&&l.push({id:`line-subsec-${o}`,x1:a,y1:f,x2:d,y2:p,style:b,sectionIdx:Number(u.split("-")[0]),isSubSection:!0,subSectionKeyPath:I})}}if(et(l),u.current&&s.current){const t=u.current.getBoundingClientRect(),e=s.current.getBoundingClientRect(),n=(t.top+t.height/2-c.top+e.top+e.height/2-c.top)/2;rt({x1:t.right-c.left,x2:e.left-c.left,y:n})}else rt(null);if(B.size>0){const t=[],n=r.current,l=i.current;if(n&&l){const r=[],i=n.getBoundingClientRect().top,u=l.getBoundingClientRect().top,s=i+n.clientHeight,g=u+l.clientHeight,a=n.scrollTop,d=l.scrollTop,f=c.top,p=(t,e,n)=>Math.max(e,Math.min(n,t));B.forEach(n=>{if(C){let l=null,o=null,h=null;if("string"==typeof n&&n.includes(e.DEVIATION_BADGE_SEPARATOR)){const[t,r,i]=n.split(e.DEVIATION_BADGE_SEPARATOR),c=`${t}${e.DEVIATION_BADGE_SEPARATOR}${r}`;l=y.current[c]?.current,h=D(t,r)??v(i),o=Number(i?.split("-")[0]||0)}else o=Number(n),l=y.current[o]?.current,h=M(o);if(!l)return;const b=document.querySelectorAll('[id^="guideline-target-"]');b.forEach((o,A)=>{const y=l.getBoundingClientRect(),$=o.getBoundingClientRect(),R=y.right-c.left,x=$.left-c.left-0,m=R+75,B=y.top+y.height/2,S=$.top+$.height/2,I=B-i+a,T=S-u+d,C=`conn-guide-${n}-${A}`;let E="";if("string"==typeof n&&n.includes(e.DEVIATION_BADGE_SEPARATOR)){E=(n.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(t=>Number(t)+1).join(".")}else E=String(Number(n)+1);const M=String.fromCharCode(97+A),v=1===b.length?null:`${E}(${M})`;r.push({lhsScrollY:I,rhsScrollY:T,x1:R,x2:x,containerTop:f,leftIdx:n,rhsArrayIdx:A,styleColor:h?.badgeBorder||"#6366F1",styleBg:h?.badgeBg||"#FFFFFF",styleText:h?.badgeText||"#A16207",styleId:C,centerX:m});const D=p(B,i,s),O=p(S,u,g),L=D-f,_=O-f,F=bt(R,L,x,_,m,B>=i-4&&B<=s+4,S>=u-4&&S<=g+4);t.push({id:C,pathD:F,style:h,leftIdx:n,rhsArrayIdx:A,x1:R,x2:x,y1:L,y2:_,centerX:m,matchLabel:v,isGuideline:!0})})}else if("string"==typeof n&&n.includes(e.DEVIATION_BADGE_SEPARATOR)){const[l,o,h,b]=n.split(e.DEVIATION_BADGE_SEPARATOR),A=`${l}${e.DEVIATION_BADGE_SEPARATOR}${o}`,R=y.current[A]?.current,x=$.current[A]?.current;if(!R||!x)return;const m=R.getBoundingClientRect(),B=x.getBoundingClientRect(),S=D(l,o)??v(h),I=m.right-c.left,T=B.left-c.left-0,C=I+75,E=m.top+m.height/2,M=B.top+B.height/2,O=E-i+a,L=M-u+d,_=`conn-subsec-${A}`,F=((h||"").split("-").map(t=>Number(t)+1).join("."),null);r.push({lhsScrollY:O,rhsScrollY:L,x1:I,x2:T,containerTop:f,leftIdx:n,rhsArrayIdx:n,styleColor:S?.badgeBorder||"#6366F1",styleBg:S?.badgeBg||"#FFFFFF",styleText:S?.badgeText||"#A16207",styleId:_,centerX:C});const N=p(E,i,s),H=p(M,u,g),P=N-f,k=H-f,w=bt(I,P,T,k,C,E>=i-4&&E<=s+4,M>=u-4&&M<=g+4);t.push({id:_,pathD:w,style:S,leftIdx:n,rhsArrayIdx:n,x1:I,x2:T,y1:P,y2:k,matchLabel:F})}else if(T){const e=n,l=o[e];if(!l?.refIndexes?.length)return;l.refIndexes.forEach((o,b)=>{const A=h.findIndex(t=>t.selfIndex===o);if(-1===A)return;const R=y.current[e]?.current,x=$.current[A]?.current;if(!R||!x)return;const m=R.getBoundingClientRect(),B=x.getBoundingClientRect(),S=M(e),I=m.right-c.left,T=B.left-c.left-0,C=I+75,E=m.top+m.height/2,v=B.top+B.height/2,D=E-i+a,O=v-u+d,L=`conn-${e}-${A}`,_=String(Number(n)+1),F=String.fromCharCode(97+b),N=1===l.refIndexes.length?null:`${_}(${F})`;r.push({lhsScrollY:D,rhsScrollY:O,x1:I,x2:T,containerTop:f,leftIdx:e,rhsArrayIdx:A,styleColor:S?.badgeBorder||"#6366F1",styleBg:S?.badgeBg||"#FFFFFF",styleText:S?.badgeText||"#A16207",styleId:L,centerX:C});const H=p(E,i,s),P=p(v,u,g),k=H-f,w=P-f,G=bt(I,k,T,w,C,E>=i-4&&E<=s+4,v>=u-4&&v<=g+4);t.push({id:L,pathD:G,style:S,leftIdx:e,rhsArrayIdx:A,x1:I,x2:T,y1:k,y2:w,matchLabel:N})})}else{const e=n,l=e,o=y.current[e]?.current,h=$.current[l]?.current;if(!o||!h)return;const b=o.getBoundingClientRect(),A=h.getBoundingClientRect(),R=M(e),x=b.right-c.left,m=A.left-c.left-0,B=x+75,S=b.top+b.height/2,I=A.top+A.height/2,T=S-i+a,C=I-u+d,E=`conn-${e}-${l}`,v=(String(Number(n)+1),null);r.push({lhsScrollY:T,rhsScrollY:C,x1:x,x2:m,containerTop:f,leftIdx:e,rhsArrayIdx:l,styleColor:R?.badgeBorder||"#6366F1",styleBg:R?.badgeBg||"#FFFFFF",styleText:R?.badgeText||"#A16207",styleId:E,centerX:B});const D=p(S,i,s),O=p(I,u,g),L=D-f,_=O-f,F=bt(x,L,m,_,B,S>=i-4&&S<=s+4,I>=u-4&&I<=g+4);t.push({id:E,pathD:F,style:R,leftIdx:e,rhsArrayIdx:l,x1:x,x2:m,y1:L,y2:_,matchLabel:v})}}),pt.current=r}ut(t),setTimeout(()=>yt(),10)}else ut([]),pt.current=[],setTimeout(()=>yt(),10)}catch(t){console.error("Line render safe fail: ",t)}finally{ht.current=!1}}},[g,o,h,E,W,Z,M,D,T,S,I,B,x,m,C]),yt=t.useCallback(()=>{const t=pt.current;if(!t.length)return l.current["guideline-up-stroke"]?.setAttribute("visibility","hidden"),l.current["guideline-up-badge"]?.setAttribute("visibility","hidden"),l.current["guideline-down-stroke"]?.setAttribute("visibility","hidden"),void l.current["guideline-down-badge"]?.setAttribute("visibility","hidden");if(L.current)return;const e=r.current?.scrollTop??0,c=i.current?.scrollTop??0,u=r.current?.clientHeight??1/0,s=i.current?.clientHeight??1/0,o=r.current?.getBoundingClientRect().top??0,h=i.current?.getBoundingClientRect().top??0,g=o+u,a=h+s,d=n.current?.getBoundingClientRect(),f=d?.top??0,p=d?.height??1/0,b=(t,e,n)=>Math.max(e,Math.min(n,t));let A=0,y=0,$=0,R=0,x="#6366F1",m="#A16207",B=!1,S=0;if(t.forEach(t=>{const n=t.lhsScrollY-e+o,r=t.rhsScrollY-c+h,i=l.current[t.styleId+"-stroke"],u=l.current[t.styleId+"-bg"],s=l.current[t.styleId+"-btn"],d=l.current[t.styleId+"-number"];if(!i&&!u)return;const p=b(n,o,g),I=b(r,h,a),T=p-f,C=I-f,E=n>=o-4&&n<=g+4,M=r>=h-4&&r<=a+4;let v=!0;B=!0;const D=t.centerX||t.x1+75;0===$&&($=t.x1,R=T,S=D,x=t.styleColor,t.styleBg,m=t.styleText||"#A16207"),r<h-4?(A++,v=!1):r>a+4&&(y++,v=!1);const O=bt(t.x1,T,t.x2,C,S,E,M);i&&(v&&O?(i.setAttribute("visibility","visible"),i.setAttribute("d",O)):i.setAttribute("visibility","hidden")),u&&(v&&O?(u.setAttribute("visibility","visible"),u.setAttribute("d",O)):u.setAttribute("visibility","hidden")),s&&(E&&v?(s.setAttribute("visibility","visible"),s.setAttribute("y",String(T-12))):s.setAttribute("visibility","hidden")),d&&(E&&v?(d.setAttribute("visibility","visible"),d.setAttribute("transform",`translate(${t.x2-42}, ${C})`)):d.setAttribute("visibility","hidden"))}),B&&S>0){const t=l.current["guideline-up-stroke"],e=l.current["guideline-up-badge"],n=l.current["guideline-up-arrow"],r=l.current["guideline-up-text"],i=l.current["guideline-up-badge-rect"];if(A>0){const c=Math.max(15,h-f+15),l=Math.min(15,Math.abs(S-$),Math.max(0,R-c)),u=`M ${$},${R} L ${S-l},${R} Q ${S},${R} ${S},${R-l} L ${S},${c}`;t?.setAttribute("visibility","visible"),t?.setAttribute("d",u),t?.setAttribute("stroke",x),e?.setAttribute("visibility","visible"),e?.setAttribute("transform",`translate(${S}, ${c})`),n&&n.setAttribute("fill",x),r&&(r.textContent=`+${A}`,r.setAttribute("fill",m)),i&&i.setAttribute("stroke",x)}else t?.setAttribute("visibility","hidden"),e?.setAttribute("visibility","hidden");const c=l.current["guideline-down-stroke"],u=l.current["guideline-down-badge"],s=l.current["guideline-down-arrow"],o=l.current["guideline-down-text"],g=l.current["guideline-down-badge-rect"];if(y>0){const t=Math.min(p-15,a-f-15),e=Math.min(15,Math.abs(S-$),Math.max(0,t-R)),n=`M ${$},${R} L ${S-e},${R} Q ${S},${R} ${S},${R+e} L ${S},${t}`;c?.setAttribute("visibility","visible"),c?.setAttribute("d",n),c?.setAttribute("stroke",x),u?.setAttribute("visibility","visible"),u?.setAttribute("transform",`translate(${S}, ${t})`),s&&s.setAttribute("fill",x),o&&(o.textContent=`+${y}`,o.setAttribute("fill",m)),g&&g.setAttribute("stroke",x)}else c?.setAttribute("visibility","hidden"),u?.setAttribute("visibility","hidden")}},[]),$t=t.useCallback(()=>{pt.current.length>0&&!L.current||(null!==dt.current&&clearTimeout(dt.current),dt.current=setTimeout(()=>{V.current(),dt.current=null},50))},[]),Rt=t.useCallback(t=>{if(null!==J.current&&U.current&&Math.abs(t.currentTarget.scrollTop-J.current)<=2){const t=U.current;J.current=null,U.current=null,t()}if(!at.current&&!j.current){if(T&&z&&(_.current||B.size>0)){const n=t.currentTarget,c=r.current,l=i.current,u=n===c?l:n===l?c:null;if(n&&u){const t=()=>{const t=H.current,n=P.current;if(null===t)return{leftAnchor:null,rightAnchor:null};if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){const n=t.split(e.DEVIATION_BADGE_SEPARATOR),r=`${n[0]}${e.DEVIATION_BADGE_SEPARATOR}${n[1]}`;return{leftAnchor:y.current[r]?.current||b.current[n[2]]?.current||f.current[Number(n[2])]?.current||null,rightAnchor:$.current[r]?.current||A.current[n[3]]?.current||p.current[Number(n[3])]?.current||null}}const r=Number(t),i=null!==n?Number(n):r;return{leftAnchor:y.current[r]?.current||R.current[r]?.current||f.current[r]?.current||null,rightAnchor:$.current[i]?.current||p.current[i]?.current||null}},{leftAnchor:r,rightAnchor:i}=t(),l=n===c?r:i,s=n===c?i:r;let o=null;if(l&&s){const t=l.getBoundingClientRect(),e=s.getBoundingClientRect(),n=u.getBoundingClientRect(),r=t.top+t.height/2;o=e.top-n.top+u.scrollTop+e.height/2-(r-n.top)}else{const t=Math.max(0,n.scrollHeight-n.clientHeight),e=Math.max(0,u.scrollHeight-u.clientHeight);o=t>0?n.scrollTop/t*e:n.scrollTop}const h=Math.max(0,u.scrollHeight-u.clientHeight);o=Math.max(0,Math.min(o,h)),Math.abs(u.scrollTop-o)>1&&(at.current=!0,u.scrollTop=o,requestAnimationFrame(()=>{at.current=!1}))}}T||$t(),gt.current||(gt.current=!0,requestAnimationFrame(()=>{if(_.current){const t=r.current,c=i.current;if(t&&c&&N.current){if(!F.current){const r=H.current;let i;if("string"==typeof r&&r.includes(e.DEVIATION_BADGE_SEPARATOR)){const t=r.split(e.DEVIATION_BADGE_SEPARATOR),n=`${t[0]}${e.DEVIATION_BADGE_SEPARATOR}${t[1]}`;i=y.current[n]?.current}else i=y.current[r]?.current;if(i){const e=i.getBoundingClientRect();F.current={badgeScreenY:e.top+e.height/2,initialScrollTop:t.scrollTop,leftTop:t.getBoundingClientRect().top,leftBottom:t.getBoundingClientRect().top+t.clientHeight,cTop:n.current?.getBoundingClientRect().top??0}}}if(F.current){const e=F.current,n=t.scrollTop-e.initialScrollTop,r=e.badgeScreenY-n,i=(((t,e,n)=>Math.max(e,Math.min(n,t)))(r,e.leftTop,e.leftBottom)-e.cTop).toString(),c=r>=e.leftTop-4&&r<=e.leftBottom+4;N.current.setAttribute("y1",i),N.current.setAttribute("y2",i),N.current.setAttribute("visibility",c?"visible":"hidden")}}}yt(),gt.current=!1}))}},[yt,T,z,B,$t]);return t.useEffect(()=>{V.current=At},[At]),t.useEffect(()=>{const t=setTimeout($t,250),e=()=>Q.current();return window.addEventListener("resize",e),()=>{clearTimeout(t),null!==dt.current&&clearTimeout(dt.current),null!==Y.current&&clearTimeout(Y.current),window.removeEventListener("resize",e)}},[X,q,K,g,x,m,o,h,W,$t,S,I,O,B]),{lines:tt,setLines:et,overallConnector:nt,setOverallConnector:rt,connectedLines:lt,setConnectedLines:ut,svgDimensions:st,cachedConnectedPositions:pt,calculateLines:At,calculateLinesRef:V,calculateLinesDebounced:$t,handleColumnScroll:Rt}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js"),n=require("../Guidelines/utils/guidelineTargets.js");exports.useLinesCalculator=({containerRef:r,leftContainerRef:i,rightContainerRef:c,svgContainerRef:l,pathRefs:u,leftHeaderRef:s,rightHeaderRef:o,proposedSections:g,existingSections:h,visibleFields:a,leftRefs:d,rightRefs:f,sectionLeftRefs:p,sectionRightRefs:b,subSectionLeftRefs:A,subSectionRightRefs:y,lhsBadgeRefs:$,rhsBadgeRefs:R,sectionRowRefs:x,expandedSections:m,expandedSubSections:B,connectedSections:S,isSideBySide:T,activeSideBySideSection:I,maintainRelativeOrder:C,isGuidelineMode:E,cognitiveMap:M,getSectionCompareStyle:v,getSubSectionCompareStyle:D,getDeviationStyleByKey:O,isArrowVisible:L,isAnimatingRef:_,isSideBySideRef:F,sideBySideCacheRef:N,sideBySideLineRef:H,activeSideBySideSectionRef:P,activeSideBySideRightSectionRef:k,connectedLines:w,setConnectedLines:G,cachedConnectedPositions:V,calculateLinesRef:Y,resizeTimerRef:j,scrollLock:z,scrollSyncLocked:Q,handleResizeRef:X,activeProposed:q,existingRule:K,analysisData:J,pendingScrollTargetRef:U,pendingScrollCallbackRef:W,resolvedComparisonConfig:Z,getFieldData:tt})=>{const[et,nt]=t.useState([]),[rt,it]=t.useState(null),[ct,lt]=t.useState([]),ut=w??ct,st=G??lt,[ot,gt]=t.useState({width:0,height:0}),ht=t.useRef(!1),at=t.useRef(!1),dt=t.useRef(!1),ft=t.useRef(null),pt=t.useRef([]),bt=V??pt,At=(t,e,n,r,i,c,l)=>{if(Math.abs(r-e)<=1)return c&&l?`M ${t},${e} L ${n},${r}`:c&&!l?`M ${t},${e} L ${i},${e}`:!c&&l?`M ${i},${e} L ${n},${r}`:`M ${i},${e} L ${i},${r}`;const u=Math.min(15,Math.abs(i-t),Math.abs(r-e)/2),s=Math.min(15,Math.abs(n-i),Math.abs(r-e)/2),o=r>e?u:-u,g=r>e?s:-s,h=n>i?s:-s;return c&&l?`M ${t},${e} L ${i-u},${e} Q ${i},${e} ${i},${e+o} L ${i},${r-g} Q ${i},${r} ${i+h},${r} L ${n},${r}`:c&&!l?`M ${t},${e} L ${i-u},${e} Q ${i},${e} ${i},${e+o} L ${i},${r}`:!c&&l?`M ${i},${e} L ${i},${r-g} Q ${i},${r} ${i+h},${r} L ${n},${r}`:`M ${i},${e} L ${i},${r}`},yt=t.useCallback(()=>{if(!ht.current&&!_.current){ht.current=!0;try{if(!r.current)return;const t=t=>{const e=t.split("-"),n=e[0];if(!m[n]&&!1===C)return!1;if(C&&!m[`left-${n}`]&&!m[`right-${n}`]&&!m[n])return!1;let r=n;for(let t=1;t<e.length-1;t++)if(r+=`-${e[t]}`,!B[r])return!1;return!0},l=r.current.getBoundingClientRect();gt({width:l.width,height:l.height});const u=[];if(a.forEach(({key:t})=>{const e=d.current[t]?.current,n=f.current[t]?.current;e&&n&&(e.style.height="auto",n.style.height="auto",e.style.minHeight="0px",n.style.minHeight="0px")}),!_.current){for(let t=0;t<Math.max(g.length,h.length);t++){const e=p.current[t]?.current,n=b.current[t]?.current;e&&(e.style.height="auto",e.style.minHeight="0px"),n&&(n.style.height="auto",n.style.minHeight="0px")}C||Object.keys(A.current).forEach(e=>{if(!t(e))return;const n=A.current[e]?.current,r=y.current[e]?.current;n&&r&&(n.style.height="auto",r.style.height="auto",n.style.minHeight="0px",r.style.minHeight="0px")})}const x={};a.forEach(({key:t})=>{const e=d.current[t]?.current,n=f.current[t]?.current;if(e&&n){const r=e.getBoundingClientRect(),i=n.getBoundingClientRect();x[t]=Math.max(r.height,i.height)}});const L={left:{},right:{}},F={};if(!_.current)if(C){if(T&&null!==I)if("number"==typeof I){const t=I,e=g[t],n=p.current[t]?.current;n&&e&&(e.refIndexes||[]).forEach(e=>{const r=h.findIndex(t=>t.selfIndex===e),i=b.current[r]?.current;if(i&&(m[`left-${t}`]||m[`right-${r}`])){const e=Math.max(n.getBoundingClientRect().height,i.getBoundingClientRect().height);L.left[t]=Math.max(L.left[t]||0,e),L.right[r]=Math.max(L.right[r]||0,e)}})}else{const t=I.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(t){const e=A.current[t]?.current,n=y.current[t]?.current;if(e&&n){const r=Math.max(e.getBoundingClientRect().height,n.getBoundingClientRect().height);F[t]=Math.max(F[t]||0,r)}}}}else{Object.keys(A.current).forEach(e=>{if(!t(e))return;const n=A.current[e]?.current,r=y.current[e]?.current;if(n&&r&&null!==n.offsetParent&&null!==r.offsetParent){const t=n.getBoundingClientRect(),i=r.getBoundingClientRect(),c=Math.max(t.height,i.height);F[e]=c,n.style.minHeight=`${c}px`,r.style.minHeight=`${c}px`}});for(let t=0;t<Math.min(g.length,h.length);t++){const e=p.current[t]?.current,n=b.current[t]?.current;if(e&&n){const r=Math.max(e.getBoundingClientRect().height,n.getBoundingClientRect().height);L.left[t]=r,L.right[t]=r}}}if(a.forEach(({key:t})=>{const e=d.current[t]?.current,n=f.current[t]?.current;if(e&&n){const r=x[t];e.style.minHeight=`${r}px`,n.style.minHeight=`${r}px`}}),_.current||(Object.entries(L.left).forEach(([t,e])=>{const n=p.current[Number(t)]?.current;n&&(n.style.minHeight=`${e}px`)}),Object.entries(L.right).forEach(([t,e])=>{const n=b.current[Number(t)]?.current;n&&(n.style.minHeight=`${e}px`)}),C||Object.keys(F).forEach(t=>{const e=A.current[t]?.current,n=y.current[t]?.current;if(e&&n&&F[t]){const r=F[t];e.style.minHeight=`${r}px`,n.style.minHeight=`${r}px`}})),!E){const t=(t,e)=>{if(!C)return h[e]?[e]:[];const n=(t.refIndexes||[]).map(t=>h.findIndex(e=>e.selfIndex===t)).filter(t=>-1!==t);return!n.length&&h[e]?[e]:Array.from(new Set(n))};g.forEach((e,n)=>{const r=e.continuationSourceRowId?g.findIndex(t=>t.comparisonRowId===e.continuationSourceRowId):-1,s=r>=0?r:n,o=p.current[s]?.current;if(!o)return;t(e,n).forEach(t=>{const e=b.current[t]?.current;if(!e)return;const a=o.getBoundingClientRect(),d=e.getBoundingClientRect(),f=a.right-l.left,p=d.left-l.left;let A=a.top+18-l.top,y=d.top+18-l.top;if(C&&T&&I===n){const t=i.current?.getBoundingClientRect().top??0,e=c.current?.getBoundingClientRect().top??0,n=t+(i.current?.clientHeight??1/0),r=e+(c.current?.clientHeight??1/0),u=(t,e,n)=>Math.max(e,Math.min(n,t));A=u(a.top+18,t,n)-l.top,y=u(d.top+18,e,r)-l.top}const $=v(s);$&&u.push({id:`line-${s}-${t}`,x1:f,y1:A,x2:p,y2:y,style:$,sectionIdx:s,targetRightIdx:t,isSubSection:!1,isMappingContinuation:r>=0,hasCognitive:!!(g[s]?.cognitiveData||h[t]?.cognitiveData||g[s]?.nodeId&&M[g[s].nodeId])})})})}if(!E&&T&&"string"==typeof I&&I.includes(e.DEVIATION_BADGE_SEPARATOR)){const[t,n,r,s]=I.split(e.DEVIATION_BADGE_SEPARATOR),o=`${t}${e.DEVIATION_BADGE_SEPARATOR}${n}`,g=$.current[o]?.current,h=R.current[o]?.current;if(g&&h){const e=g.getBoundingClientRect(),s=h.getBoundingClientRect(),a=e.right-l.left,d=s.left-l.left;let f=e.top+e.height/2-l.top,p=s.top+s.height/2-l.top;if(C){const t=i.current?.getBoundingClientRect().top??0,n=c.current?.getBoundingClientRect().top??0,r=t+(i.current?.clientHeight??1/0),u=n+(c.current?.clientHeight??1/0),o=(t,e,n)=>Math.max(e,Math.min(n,t));f=o(e.top+e.height/2,t,r)-l.top,p=o(s.top+s.height/2,n,u)-l.top}const b=O(t,n)??D(r);b&&u.push({id:`line-subsec-${o}`,x1:a,y1:f,x2:d,y2:p,style:b,sectionIdx:Number(r.split("-")[0]),isSubSection:!0,subSectionKeyPath:I})}}if(nt(u),s.current&&o.current){const t=s.current.getBoundingClientRect(),e=o.current.getBoundingClientRect(),n=(t.top+t.height/2-l.top+e.top+e.height/2-l.top)/2;it({x1:t.right-l.left,x2:e.left-l.left,y:n})}else it(null);if(S.size>0){const t=[],r=i.current,u=c.current;if(r&&u){const i=[],c=r.getBoundingClientRect().top,s=u.getBoundingClientRect().top,o=c+r.clientHeight,a=s+u.clientHeight,d=r.scrollTop,f=u.scrollTop,p=l.top,b=(t,e,n)=>Math.max(e,Math.min(n,t));S.forEach(r=>{if(E){let g=null,h=null,A=null;if("string"==typeof r&&r.includes(e.DEVIATION_BADGE_SEPARATOR)){const[t,n,i]=r.split(e.DEVIATION_BADGE_SEPARATOR),c=`${t}${e.DEVIATION_BADGE_SEPARATOR}${n}`;g=$.current[c]?.current,A=O(t,n)??D(i),h=Number(i?.split("-")[0]||0)}else h=Number(r),g=$.current[h]?.current,A=v(h);if(!g)return;const y=n.getVisibleGuidelineTargets(u);y.forEach((n,u)=>{const h=g.getBoundingClientRect(),$=n.getBoundingClientRect(),R=h.right-l.left,x=$.left-l.left-0,m=R+75,B=h.top+h.height/2,S=$.top+$.height/2,T=B-c+d,I=S-s+f,C=`conn-guide-${r}-${u}`;let E="";if("string"==typeof r&&r.includes(e.DEVIATION_BADGE_SEPARATOR)){E=(r.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(t=>Number(t)+1).join(".")}else E=String(Number(r)+1);const M=String.fromCharCode(97+u),v=1===y.length?null:`${E}(${M})`;i.push({lhsScrollY:T,rhsScrollY:I,x1:R,x2:x,containerTop:p,leftIdx:r,rhsArrayIdx:u,styleColor:A?.badgeBorder||"#6366F1",styleBg:A?.badgeBg||"#FFFFFF",styleText:A?.badgeText||"#A16207",styleId:C,centerX:m});const D=b(B,c,o),O=b(S,s,a),L=D-p,_=O-p,F=At(R,L,x,_,m,B>=c-4&&B<=o+4,S>=s-4&&S<=a+4);t.push({id:C,pathD:F,style:A,leftIdx:r,rhsArrayIdx:u,x1:R,x2:x,y1:L,y2:_,centerX:m,matchLabel:v,isGuideline:!0})})}else if("string"==typeof r&&r.includes(e.DEVIATION_BADGE_SEPARATOR)){const[n,u,g,h]=r.split(e.DEVIATION_BADGE_SEPARATOR),A=`${n}${e.DEVIATION_BADGE_SEPARATOR}${u}`,y=$.current[A]?.current,x=R.current[A]?.current;if(!y||!x)return;const m=y.getBoundingClientRect(),B=x.getBoundingClientRect(),S=O(n,u)??D(g),T=m.right-l.left,I=B.left-l.left-0,C=T+75,E=m.top+m.height/2,M=B.top+B.height/2,v=E-c+d,L=M-s+f,_=`conn-subsec-${A}`,F=((g||"").split("-").map(t=>Number(t)+1).join("."),null);i.push({lhsScrollY:v,rhsScrollY:L,x1:T,x2:I,containerTop:p,leftIdx:r,rhsArrayIdx:r,styleColor:S?.badgeBorder||"#6366F1",styleBg:S?.badgeBg||"#FFFFFF",styleText:S?.badgeText||"#A16207",styleId:_,centerX:C});const N=b(E,c,o),H=b(M,s,a),P=N-p,k=H-p,w=At(T,P,I,k,C,E>=c-4&&E<=o+4,M>=s-4&&M<=a+4);t.push({id:_,pathD:w,style:S,leftIdx:r,rhsArrayIdx:r,x1:T,x2:I,y1:P,y2:k,matchLabel:F})}else if(C){const e=r,n=g[e];if(!n?.refIndexes?.length)return;n.refIndexes.forEach((u,g)=>{const A=h.findIndex(t=>t.selfIndex===u);if(-1===A)return;const y=$.current[e]?.current,x=R.current[A]?.current;if(!y||!x)return;const m=y.getBoundingClientRect(),B=x.getBoundingClientRect(),S=v(e),T=m.right-l.left,I=B.left-l.left-0,C=T+75,E=m.top+m.height/2,M=B.top+B.height/2,D=E-c+d,O=M-s+f,L=`conn-${e}-${A}`,_=String(Number(r)+1),F=String.fromCharCode(97+g),N=1===n.refIndexes.length?null:`${_}(${F})`;i.push({lhsScrollY:D,rhsScrollY:O,x1:T,x2:I,containerTop:p,leftIdx:e,rhsArrayIdx:A,styleColor:S?.badgeBorder||"#6366F1",styleBg:S?.badgeBg||"#FFFFFF",styleText:S?.badgeText||"#A16207",styleId:L,centerX:C});const H=b(E,c,o),P=b(M,s,a),k=H-p,w=P-p,G=At(T,k,I,w,C,E>=c-4&&E<=o+4,M>=s-4&&M<=a+4);t.push({id:L,pathD:G,style:S,leftIdx:e,rhsArrayIdx:A,x1:T,x2:I,y1:k,y2:w,matchLabel:N})})}else{const e=r,n=e,u=$.current[e]?.current,g=R.current[n]?.current;if(!u||!g)return;const h=u.getBoundingClientRect(),A=g.getBoundingClientRect(),y=v(e),x=h.right-l.left,m=A.left-l.left-0,B=x+75,S=h.top+h.height/2,T=A.top+A.height/2,I=S-c+d,C=T-s+f,E=`conn-${e}-${n}`,M=(String(Number(r)+1),null);i.push({lhsScrollY:I,rhsScrollY:C,x1:x,x2:m,containerTop:p,leftIdx:e,rhsArrayIdx:n,styleColor:y?.badgeBorder||"#6366F1",styleBg:y?.badgeBg||"#FFFFFF",styleText:y?.badgeText||"#A16207",styleId:E,centerX:B});const D=b(S,c,o),O=b(T,s,a),L=D-p,_=O-p,F=At(x,L,m,_,B,S>=c-4&&S<=o+4,T>=s-4&&T<=a+4);t.push({id:E,pathD:F,style:y,leftIdx:e,rhsArrayIdx:n,x1:x,x2:m,y1:L,y2:_,matchLabel:M})}}),bt.current=i}st(t),setTimeout(()=>$t(),10)}else st([]),bt.current=[],setTimeout(()=>$t(),10)}catch(t){console.error("Line render safe fail: ",t)}finally{ht.current=!1}}},[a,g,h,M,Z,tt,v,O,C,T,I,S,m,B,E]),$t=t.useCallback(()=>{const t=bt.current;if(!t.length)return u.current["guideline-up-stroke"]?.setAttribute("visibility","hidden"),u.current["guideline-up-badge"]?.setAttribute("visibility","hidden"),u.current["guideline-down-stroke"]?.setAttribute("visibility","hidden"),void u.current["guideline-down-badge"]?.setAttribute("visibility","hidden");if(_.current)return;const e=i.current?.scrollTop??0,n=c.current?.scrollTop??0,l=i.current?.clientHeight??1/0,s=c.current?.clientHeight??1/0,o=i.current?.getBoundingClientRect().top??0,g=c.current?.getBoundingClientRect().top??0,h=o+l,a=g+s,d=r.current?.getBoundingClientRect(),f=d?.top??0,p=d?.height??1/0,b=(t,e,n)=>Math.max(e,Math.min(n,t));let A=0,y=0,$=0,R=0,x="#6366F1",m="#A16207",B=!1,S=0;if(t.forEach(t=>{const r=t.lhsScrollY-e+o,i=t.rhsScrollY-n+g,c=u.current[t.styleId+"-stroke"],l=u.current[t.styleId+"-bg"],s=u.current[t.styleId+"-btn"],d=u.current[t.styleId+"-number"];if(!c&&!l)return;const p=b(r,o,h),T=b(i,g,a),I=p-f,C=T-f,E=r>=o-4&&r<=h+4,M=i>=g-4&&i<=a+4;let v=!0;B=!0;const D=t.centerX||t.x1+75;0===$&&($=t.x1,R=I,S=D,x=t.styleColor,t.styleBg,m=t.styleText||"#A16207"),i<g-4?(A++,v=!1):i>a+4&&(y++,v=!1);const O=At(t.x1,I,t.x2,C,S,E,M);c&&(v&&O?(c.setAttribute("visibility","visible"),c.setAttribute("d",O)):c.setAttribute("visibility","hidden")),l&&(v&&O?(l.setAttribute("visibility","visible"),l.setAttribute("d",O)):l.setAttribute("visibility","hidden")),s&&(E&&v?(s.setAttribute("visibility","visible"),s.setAttribute("y",String(I-12))):s.setAttribute("visibility","hidden")),d&&(E&&v?(d.setAttribute("visibility","visible"),d.setAttribute("transform",`translate(${t.x2-42}, ${C})`)):d.setAttribute("visibility","hidden"))}),B&&S>0){const t=u.current["guideline-up-stroke"],e=u.current["guideline-up-badge"],n=u.current["guideline-up-arrow"],r=u.current["guideline-up-text"],i=u.current["guideline-up-badge-rect"];if(A>0){const c=Math.max(15,g-f+15),l=Math.min(15,Math.abs(S-$),Math.max(0,R-c)),u=`M ${$},${R} L ${S-l},${R} Q ${S},${R} ${S},${R-l} L ${S},${c}`;t?.setAttribute("visibility","visible"),t?.setAttribute("d",u),t?.setAttribute("stroke",x),e?.setAttribute("visibility","visible"),e?.setAttribute("transform",`translate(${S}, ${c})`),n&&n.setAttribute("fill",x),r&&(r.textContent=`+${A}`,r.setAttribute("fill",m)),i&&i.setAttribute("stroke",x)}else t?.setAttribute("visibility","hidden"),e?.setAttribute("visibility","hidden");const c=u.current["guideline-down-stroke"],l=u.current["guideline-down-badge"],s=u.current["guideline-down-arrow"],o=u.current["guideline-down-text"],h=u.current["guideline-down-badge-rect"];if(y>0){const t=Math.min(p-15,a-f-15),e=Math.min(15,Math.abs(S-$),Math.max(0,t-R)),n=`M ${$},${R} L ${S-e},${R} Q ${S},${R} ${S},${R+e} L ${S},${t}`;c?.setAttribute("visibility","visible"),c?.setAttribute("d",n),c?.setAttribute("stroke",x),l?.setAttribute("visibility","visible"),l?.setAttribute("transform",`translate(${S}, ${t})`),s&&s.setAttribute("fill",x),o&&(o.textContent=`+${y}`,o.setAttribute("fill",m)),h&&h.setAttribute("stroke",x)}else c?.setAttribute("visibility","hidden"),l?.setAttribute("visibility","hidden")}},[]),Rt=t.useCallback(()=>{bt.current.length>0&&!_.current||(null!==ft.current&&clearTimeout(ft.current),ft.current=setTimeout(()=>{Y.current(),ft.current=null},50))},[]),xt=t.useCallback(t=>{if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){const t=W.current;U.current=null,W.current=null,t()}if(!dt.current&&!z.current){if(C&&Q&&(F.current||S.size>0)){const n=t.currentTarget,r=i.current,l=c.current,u=n===r?l:n===l?r:null;if(n&&u){const t=()=>{const t=P.current,n=k.current;if(null===t)return{leftAnchor:null,rightAnchor:null};if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){const n=t.split(e.DEVIATION_BADGE_SEPARATOR),r=`${n[0]}${e.DEVIATION_BADGE_SEPARATOR}${n[1]}`;return{leftAnchor:$.current[r]?.current||A.current[n[2]]?.current||p.current[Number(n[2])]?.current||null,rightAnchor:R.current[r]?.current||y.current[n[3]]?.current||b.current[Number(n[3])]?.current||null}}const r=Number(t),i=null!==n?Number(n):r;return{leftAnchor:$.current[r]?.current||x.current[r]?.current||p.current[r]?.current||null,rightAnchor:R.current[i]?.current||b.current[i]?.current||null}},{leftAnchor:i,rightAnchor:c}=t(),l=n===r?i:c,s=n===r?c:i;let o=null;if(l&&s){const t=l.getBoundingClientRect(),e=s.getBoundingClientRect(),n=u.getBoundingClientRect(),r=t.top+t.height/2;o=e.top-n.top+u.scrollTop+e.height/2-(r-n.top)}else{const t=Math.max(0,n.scrollHeight-n.clientHeight),e=Math.max(0,u.scrollHeight-u.clientHeight);o=t>0?n.scrollTop/t*e:n.scrollTop}const g=Math.max(0,u.scrollHeight-u.clientHeight);o=Math.max(0,Math.min(o,g)),Math.abs(u.scrollTop-o)>1&&(dt.current=!0,u.scrollTop=o,requestAnimationFrame(()=>{dt.current=!1}))}}C||Rt(),at.current||(at.current=!0,requestAnimationFrame(()=>{if(F.current){const t=i.current,n=c.current;if(t&&n&&H.current){if(!N.current){const n=P.current;let i;if("string"==typeof n&&n.includes(e.DEVIATION_BADGE_SEPARATOR)){const t=n.split(e.DEVIATION_BADGE_SEPARATOR),r=`${t[0]}${e.DEVIATION_BADGE_SEPARATOR}${t[1]}`;i=$.current[r]?.current}else i=$.current[n]?.current;if(i){const e=i.getBoundingClientRect();N.current={badgeScreenY:e.top+e.height/2,initialScrollTop:t.scrollTop,leftTop:t.getBoundingClientRect().top,leftBottom:t.getBoundingClientRect().top+t.clientHeight,cTop:r.current?.getBoundingClientRect().top??0}}}if(N.current){const e=N.current,n=t.scrollTop-e.initialScrollTop,r=e.badgeScreenY-n,i=(((t,e,n)=>Math.max(e,Math.min(n,t)))(r,e.leftTop,e.leftBottom)-e.cTop).toString(),c=r>=e.leftTop-4&&r<=e.leftBottom+4;H.current.setAttribute("y1",i),H.current.setAttribute("y2",i),H.current.setAttribute("visibility",c?"visible":"hidden")}}}$t(),at.current=!1}))}},[$t,C,Q,S,Rt]);return t.useEffect(()=>{Y.current=yt},[yt]),t.useEffect(()=>{const t=setTimeout(Rt,250),e=()=>X.current();return window.addEventListener("resize",e),()=>{clearTimeout(t),null!==ft.current&&clearTimeout(ft.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,a,m,B,g,h,Z,Rt,T,I,L,S]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:it,connectedLines:ut,setConnectedLines:st,svgDimensions:ot,cachedConnectedPositions:bt,calculateLines:yt,calculateLinesRef:Y,calculateLinesDebounced:Rt,handleColumnScroll:xt}};
2
2
  //# sourceMappingURL=useLinesCalculator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLinesCalculator.js","sources":["../../../../../src/features/CognitiveCompare/hooks/useLinesCalculator.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\"\nimport { CachedBadgePosition, SectionBlock } from \"../CognitiveCompareTypes\";\nimport { DEVIATION_BADGE_SEPARATOR, getBentArrowPath, hasValue } from \"../CognitiveComparehelpers\";\nimport { maxHeight } from \"@mui/system\";\n\nexport const useLinesCalculator = ({\n containerRef,\n leftContainerRef,\n rightContainerRef,\n svgContainerRef,\n pathRefs,\n leftHeaderRef, rightHeaderRef,\n proposedSections, existingSections,\n visibleFields,\n leftRefs, rightRefs,\n sectionLeftRefs, sectionRightRefs,\n subSectionLeftRefs, subSectionRightRefs,\n lhsBadgeRefs, rhsBadgeRefs,\n sectionRowRefs,\n expandedSections, expandedSubSections,\n connectedSections,\n isSideBySide, activeSideBySideSection,\n maintainRelativeOrder,\n isGuidelineMode, // ── NEW PROP ──\n cognitiveMap,\n getSectionCompareStyle, getSubSectionCompareStyle, getDeviationStyleByKey,\n isArrowVisible,\n\n isAnimatingRef,\n isSideBySideRef,\n sideBySideCacheRef,\n sideBySideLineRef,\n activeSideBySideSectionRef,\n activeSideBySideRightSectionRef,\n connectedLines: providedConnectedLines,\n setConnectedLines: providedSetConnectedLines,\n cachedConnectedPositions: providedCachedConnectedPositions,\n calculateLinesRef,\n resizeTimerRef,\n scrollLock,\n scrollSyncLocked,\n\n handleResizeRef,\n activeProposed, existingRule, analysisData,\n pendingScrollTargetRef, pendingScrollCallbackRef,\n\n resolvedComparisonConfig,\n getFieldData\n}: any) => {\n // States and Refs\n const [lines, setLines] = useState<Record<string, any>[]>([]);\n const [overallConnector, setOverallConnector] = useState<{ x1: number; x2: number; y: number; } | null>(null);\n const [internalConnectedLines, internalSetConnectedLines] = useState<Record<string, any>[]>([]);\n const connectedLines = providedConnectedLines ?? internalConnectedLines;\n const setConnectedLines = providedSetConnectedLines ?? internalSetConnectedLines;\n const [svgDimensions, setSvgDimensions] = useState<{ width: number; height: number }>({ width: 0, height: 0 });\n\n const isCalculatingLines = useRef(false);\n const scrollTicking = useRef(false);\n const scrollSyncing = useRef(false);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const internalCachedConnectedPositions = useRef<CachedBadgePosition[]>([]);\n const cachedConnectedPositions =\n providedCachedConnectedPositions ?? internalCachedConnectedPositions;\n\n\n \n // Helpers\n // ── UNIFIED ROUNDED PATH GENERATOR (Guarantees shared trunk for ALL modes) ──\n const getRoundedStaggeredPath = (x1: number, y1: number, x2: number, y2: number, cX: number, visL: boolean, visR: boolean) => {\n if (Math.abs(y2 - y1) <= 1) {\n if (visL && visR) return `M ${x1},${y1} L ${x2},${y2}`;\n if (visL && !visR) return `M ${x1},${y1} L ${cX},${y1}`;\n if (!visL && visR) return `M ${cX},${y1} L ${x2},${y2}`;\n return `M ${cX},${y1} L ${cX},${y2}`;\n }\n const r1 = Math.min(15, Math.abs(cX - x1), Math.abs(y2 - y1) / 2);\n const r2 = Math.min(15, Math.abs(x2 - cX), Math.abs(y2 - y1) / 2);\n const dy1 = y2 > y1 ? r1 : -r1;\n const dy2 = y2 > y1 ? r2 : -r2;\n const dx2 = x2 > cX ? r2 : -r2; // Safe horizontal direction\n \n if (visL && visR) {\n return `M ${x1},${y1} L ${cX - r1},${y1} Q ${cX},${y1} ${cX},${y1 + dy1} L ${cX},${y2 - dy2} Q ${cX},${y2} ${cX + dx2},${y2} L ${x2},${y2}`;\n } else if (visL && !visR) {\n return `M ${x1},${y1} L ${cX - r1},${y1} Q ${cX},${y1} ${cX},${y1 + dy1} L ${cX},${y2}`;\n } else if (!visL && visR) {\n return `M ${cX},${y1} L ${cX},${y2 - dy2} Q ${cX},${y2} ${cX + dx2},${y2} L ${x2},${y2}`;\n } else {\n return `M ${cX},${y1} L ${cX},${y2}`;\n }\n };\n\n // Helper to check if a subsection is actually visible in the expanded section\n const isSubSectionVisible = (keyPath: string) => {\n const pathParts = keyPath.split('-');\n const rootIdx = pathParts[0];\n\n // Edge case\n // Early return if root parent is not expanded\n // Only happens in side by side view for deeply nested children\n if (!expandedSections[rootIdx] && maintainRelativeOrder === false) return;\n\n if (maintainRelativeOrder) {\n if (!expandedSections[`left-${rootIdx}`] && !expandedSections[`right-${rootIdx}`] && !expandedSections[rootIdx]) return false;\n }\n\n // Check to confirm if all the ancestors of the node are expanded otherwise early return\n let ancestorPath = rootIdx;\n for (let i = 1; i < pathParts.length - 1; i++) {\n ancestorPath += `-${pathParts[i]}`;\n if (!expandedSections[ancestorPath]) return false;\n }\n\n return true;\n };\n\n // Callbacks\n const calculateLines = useCallback(() => {\n if (isCalculatingLines.current) return;\n if (isAnimatingRef.current) return;\n isCalculatingLines.current = true;\n try {\n if (!containerRef.current) return;\n\n // Helper to check if a subsection is actually visible in the expanded accordion tree\n const isSubSectionVisible = (keyPath: string) => {\n const pathParts = keyPath.split('-');\n const rootIdx = pathParts[0];\n\n // 1. Root Parent must be expanded\n if (!expandedSections[rootIdx] && maintainRelativeOrder === false) return false;\n if (maintainRelativeOrder) {\n if (!expandedSections[`left-${rootIdx}`] && !expandedSections[`right-${rootIdx}`] && !expandedSections[rootIdx]) return false;\n }\n\n // 2. All intermediate ancestor subsections must be expanded\n let ancestorPath = rootIdx;\n for (let i = 1; i < pathParts.length - 1; i++) {\n ancestorPath += `-${pathParts[i]}`;\n if (!expandedSubSections[ancestorPath]) {\n return false;\n }\n }\n return true;\n };\n\n // 3. Keep the SVG setup and field heights logic intact\n const containerRect = containerRef.current.getBoundingClientRect();\n setSvgDimensions({\n width: containerRect.width,\n height: containerRect.height,\n });\n\n const newLines: Record<string, any>[] = [];\n\n // RESET STYLES (WRITE ONLY)\n visibleFields.forEach(({ key }: {key: any}) => {\n const l = leftRefs.current[key]?.current;\n const r = rightRefs.current[key]?.current;\n\n if (l && r) {\n l.style.height = \"auto\";\n r.style.height = \"auto\";\n l.style.minHeight = \"0px\";\n r.style.minHeight = \"0px\";\n }\n });\n\n if (!isAnimatingRef.current) {\n for (let idx = 0; idx < Math.max(proposedSections.length, existingSections.length); idx++) {\n const l = sectionLeftRefs.current[idx]?.current;\n const r = sectionRightRefs.current[idx]?.current;\n\n if (l) {\n l.style.height = \"auto\";\n l.style.minHeight = \"0px\";\n }\n if (r) {\n r.style.height = \"auto\";\n r.style.minHeight = \"0px\";\n }\n }\n \n if (!maintainRelativeOrder) {\n // Subsections reset\n Object.keys(subSectionLeftRefs.current).forEach(keyPath => {\n if (!isSubSectionVisible(keyPath)) return;\n const l = subSectionLeftRefs.current[keyPath]?.current;\n const r = subSectionRightRefs.current[keyPath]?.current;\n if (l && r) {\n l.style.height = \"auto\";\n r.style.height = \"auto\";\n l.style.minHeight = \"0px\";\n r.style.minHeight = \"0px\";\n }\n });\n }\n }\n\n // READ HEIGHTS (READ ONLY)\n const fieldHeights: Record<string, number> = {};\n\n visibleFields.forEach(({ key } : {key: any}) => {\n const l = leftRefs.current[key]?.current;\n const r = rightRefs.current[key]?.current;\n\n if (l && r) {\n const lRect = l.getBoundingClientRect();\n const rRect = r.getBoundingClientRect();\n fieldHeights[key] = Math.max(lRect.height, rRect.height);\n }\n });\n\n const syncHeights = { left: {} as Record<number, number>, right: {} as Record<number, number> };\n const subSectionHeights: Record<string, number> = {};\n\n if (!isAnimatingRef.current) {\n if (!maintainRelativeOrder) {\n // ── FIX: Measure and apply subsection heights FIRST so their new heights push the parent containers ──\n Object.keys(subSectionLeftRefs.current).forEach(keyPath => {\n if (!isSubSectionVisible(keyPath)) return;\n const l = subSectionLeftRefs.current[keyPath]?.current;\n const r = subSectionRightRefs.current[keyPath]?.current;\n if (l && r && l.offsetParent !== null && r.offsetParent !== null) {\n const lRect = l.getBoundingClientRect();\n const rRect = r.getBoundingClientRect();\n const maxH = Math.max(lRect.height, rRect.height);\n subSectionHeights[keyPath] = maxH;\n \n // Apply immediately so the browser recalculates layout for the parent block below\n l.style.minHeight = `${maxH}px`;\n r.style.minHeight = `${maxH}px`;\n }\n });\n\n // ── NOW measure main sections (which will naturally wrap the aligned subsections) ──\n for (let idx = 0; idx < Math.min(proposedSections.length, existingSections.length); idx++) {\n const l = sectionLeftRefs.current[idx]?.current;\n const r = sectionRightRefs.current[idx]?.current;\n\n if (l && r) {\n const maxH = Math.max(l.getBoundingClientRect().height, r.getBoundingClientRect().height);\n syncHeights.left[idx] = maxH;\n syncHeights.right[idx] = maxH;\n }\n }\n\n } else if (isSideBySide && activeSideBySideSection !== null) {\n if (typeof activeSideBySideSection === \"number\") {\n const leftIdx = activeSideBySideSection;\n const leftSec = proposedSections[leftIdx] as any;\n const l = sectionLeftRefs.current[leftIdx]?.current;\n\n if (l && leftSec) {\n (leftSec.refIndexes || []).forEach((rhsSelfIdx: number) => {\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIdx);\n const r = sectionRightRefs.current[rhsArrayIdx]?.current;\n if (!r) return;\n\n if (expandedSections[`left-${leftIdx}`] || expandedSections[`right-${rhsArrayIdx}`]) {\n const maxH = Math.max(l.getBoundingClientRect().height, r.getBoundingClientRect().height);\n syncHeights.left[leftIdx] = Math.max(syncHeights.left[leftIdx] || 0, maxH);\n syncHeights.right[rhsArrayIdx] = Math.max(syncHeights.right[rhsArrayIdx] || 0, maxH);\n }\n });\n }\n } else {\n const keyPath = activeSideBySideSection.split(DEVIATION_BADGE_SEPARATOR)[2]; \n if (keyPath) {\n const l = subSectionLeftRefs.current[keyPath]?.current;\n const r = subSectionRightRefs.current[keyPath]?.current;\n if (l && r) {\n const maxH = Math.max(l.getBoundingClientRect().height, r.getBoundingClientRect().height);\n subSectionHeights[keyPath] = Math.max(subSectionHeights[keyPath] || 0, maxH);\n }\n }\n }\n }\n }\n\n visibleFields.forEach(({ key } : {key : any}) => {\n const l = leftRefs.current[key]?.current;\n const r = rightRefs.current[key]?.current;\n\n if (l && r) {\n const maxH = fieldHeights[key];\n l.style.minHeight = `${maxH}px`;\n r.style.minHeight = `${maxH}px`;\n }\n });\n\n if (!isAnimatingRef.current) {\n Object.entries(syncHeights.left).forEach(([idx, maxH]) => {\n const l = sectionLeftRefs.current[Number(idx)]?.current;\n if (l) l.style.minHeight = `${maxH}px`;\n });\n \n Object.entries(syncHeights.right).forEach(([idx, maxH]) => {\n const r = sectionRightRefs.current[Number(idx)]?.current;\n if (r) r.style.minHeight = `${maxH}px`;\n });\n\n if (!maintainRelativeOrder) {\n Object.keys(subSectionHeights).forEach(keyPath => {\n const l = subSectionLeftRefs.current[keyPath]?.current;\n const r = subSectionRightRefs.current[keyPath]?.current;\n if (l && r && subSectionHeights[keyPath]) {\n const maxH = subSectionHeights[keyPath];\n l.style.minHeight = `${maxH}px`;\n r.style.minHeight = `${maxH}px`;\n }\n });\n }\n }\n\n // SECTION CONNECTORS\n // ── SKIP SECTION LINES IF IN GUIDELINE MODE ──\n if (!isGuidelineMode) {\n const getMappedRightIndexes = (leftSec: any, leftIdx: number) => {\n // Standard/Side-by-Side data is already materialized as explicit\n // mapping rows, so its counterpart is always at the same row index.\n // Looking up by display_index is ambiguous when a target section is\n // intentionally repeated for more than one mapping edge.\n if (!maintainRelativeOrder) {\n return existingSections[leftIdx] ? [leftIdx] : [];\n }\n\n const mapped = (leftSec.refIndexes || [])\n .map((rhsSelfIdx: number) =>\n existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIdx),\n )\n .filter((idx: number) => idx !== -1);\n\n // Backward-compatible fallback for old one-to-one/index-based data\n if (!mapped.length && existingSections[leftIdx]) {\n return [leftIdx];\n }\n\n return Array.from(new Set(mapped));\n };\n\n proposedSections.forEach((leftSec: any, leftIdx: number) => {\n const continuationSourceIdx = leftSec.continuationSourceRowId\n ? proposedSections.findIndex(\n (section: any) =>\n section.comparisonRowId === leftSec.continuationSourceRowId,\n )\n : -1;\n const resolvedLeftIdx =\n continuationSourceIdx >= 0 ? continuationSourceIdx : leftIdx;\n const lWrap = sectionLeftRefs.current[resolvedLeftIdx]?.current;\n if (!lWrap) return;\n\n const rightIndexes = getMappedRightIndexes(leftSec, leftIdx);\n\n rightIndexes.forEach((rhsArrayIdx: any) => {\n const rWrap = sectionRightRefs.current[rhsArrayIdx]?.current;\n if (!rWrap) return;\n\n const leftRect = lWrap.getBoundingClientRect();\n const rightRect = rWrap.getBoundingClientRect();\n\n const x1 = leftRect.right - containerRect.left;\n const x2 = rightRect.left - containerRect.left;\n\n let y1 = leftRect.top + 18 - containerRect.top;\n let y2 = rightRect.top + 18 - containerRect.top;\n\n if (maintainRelativeOrder && isSideBySide && activeSideBySideSection === leftIdx) {\n const leftTop = leftContainerRef.current?.getBoundingClientRect().top ?? 0;\n const rightTop = rightContainerRef.current?.getBoundingClientRect().top ?? 0;\n const leftBottom = leftTop + (leftContainerRef.current?.clientHeight ?? Infinity);\n const rightBottom = rightTop + (rightContainerRef.current?.clientHeight ?? Infinity);\n\n const clamp = (v: number, min: number, max: number) =>\n Math.max(min, Math.min(max, v));\n\n y1 = clamp(leftRect.top + 18, leftTop, leftBottom) - containerRect.top;\n y2 = clamp(rightRect.top + 18, rightTop, rightBottom) - containerRect.top;\n }\n\n const style = getSectionCompareStyle(resolvedLeftIdx);\n\n if (style) {\n newLines.push({\n id: `line-${resolvedLeftIdx}-${rhsArrayIdx}`,\n x1,\n y1,\n x2,\n y2,\n style,\n sectionIdx: resolvedLeftIdx,\n targetRightIdx: rhsArrayIdx,\n isSubSection: false,\n isMappingContinuation: continuationSourceIdx >= 0,\n hasCognitive: !!(\n proposedSections[resolvedLeftIdx]?.cognitiveData ||\n existingSections[rhsArrayIdx]?.cognitiveData ||\n proposedSections[resolvedLeftIdx]?.nodeId &&\n cognitiveMap[proposedSections[resolvedLeftIdx].nodeId as string]\n ),\n });\n }\n });\n });\n }\n\n if (!isGuidelineMode && isSideBySide && typeof activeSideBySideSection === 'string' && activeSideBySideSection.includes(DEVIATION_BADGE_SEPARATOR)) {\n const [nodeId, devKey, leftKeyPath, rightKeyPath] = activeSideBySideSection.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n\n const lBadgeEl = lhsBadgeRefs.current[refId]?.current;\n const rBadgeEl = rhsBadgeRefs.current[refId]?.current;\n\n if (lBadgeEl && rBadgeEl) {\n const lRect = lBadgeEl.getBoundingClientRect();\n const rRect = rBadgeEl.getBoundingClientRect();\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left;\n \n let y1 = lRect.top + lRect.height / 2 - containerRect.top;\n let y2 = rRect.top + rRect.height / 2 - containerRect.top;\n\n if (maintainRelativeOrder) {\n const leftTop = leftContainerRef.current?.getBoundingClientRect().top ?? 0;\n const rightTop = rightContainerRef.current?.getBoundingClientRect().top ?? 0;\n const leftBottom = leftTop + (leftContainerRef.current?.clientHeight ?? Infinity);\n const rightBottom = rightTop + (rightContainerRef.current?.clientHeight ?? Infinity);\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n\n y1 = clamp(lRect.top + lRect.height / 2, leftTop, leftBottom) - containerRect.top;\n y2 = clamp(rRect.top + rRect.height / 2, rightTop, rightBottom) - containerRect.top;\n }\n \n const style =\n getDeviationStyleByKey(nodeId, devKey) ??\n getSubSectionCompareStyle(leftKeyPath);\n if (style) {\n newLines.push({\n id: `line-subsec-${refId}`,\n x1, y1, x2, y2,\n style,\n sectionIdx: Number(leftKeyPath.split('-')[0]),\n isSubSection: true,\n subSectionKeyPath: activeSideBySideSection,\n });\n }\n }\n }\n\n setLines(newLines);\n\n if (leftHeaderRef.current && rightHeaderRef.current) {\n const leftHeaderRect = leftHeaderRef.current.getBoundingClientRect();\n const rightHeaderRect = rightHeaderRef.current.getBoundingClientRect();\n const overallY =\n (leftHeaderRect.top +\n leftHeaderRect.height / 2 -\n containerRect.top +\n rightHeaderRect.top +\n rightHeaderRect.height / 2 -\n containerRect.top) /\n 2;\n setOverallConnector({\n x1: leftHeaderRect.right - containerRect.left,\n x2: rightHeaderRect.left - containerRect.left,\n y: overallY,\n });\n } else {\n setOverallConnector(null);\n }\n\n if (connectedSections.size > 0) {\n const newConnectedLines: Record<string, any>[] = [];\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n\n if (leftContainer && rightContainer) {\n const newCache: CachedBadgePosition[] = [];\n \n const leftTop = leftContainer.getBoundingClientRect().top;\n const rightTop = rightContainer.getBoundingClientRect().top;\n const leftBottom = leftTop + leftContainer.clientHeight;\n const rightBottom = rightTop + rightContainer.clientHeight;\n\n const leftScrollTop = leftContainer.scrollTop;\n const rightScrollTop = rightContainer.scrollTop;\n const cTop = containerRect.top;\n\n const clamp = (v: number, min: number, max: number) =>\n Math.max(min, Math.min(max, v));\n\n connectedSections.forEach((connectedIdx:any) => {\n // ── GUIDELINE MODE LOGIC ──\n if (isGuidelineMode) {\n let lBadge: HTMLElement | null = null;\n let leftIdxNum: number | null = null;\n let style: any = null;\n\n if (typeof connectedIdx === 'string' && connectedIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const [nodeId, devKey, leftKeyPath] = connectedIdx.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n lBadge = lhsBadgeRefs.current[refId]?.current;\n style = getDeviationStyleByKey(nodeId, devKey) ?? getSubSectionCompareStyle(leftKeyPath);\n leftIdxNum = Number(leftKeyPath?.split('-')[0] || 0);\n } else {\n leftIdxNum = Number(connectedIdx);\n lBadge = lhsBadgeRefs.current[leftIdxNum]?.current;\n style = getSectionCompareStyle(leftIdxNum);\n }\n\n if (!lBadge) return;\n\n const targetMarks = document.querySelectorAll('[id^=\"guideline-target-\"]');\n \n targetMarks.forEach((rBadge, index) => {\n const lRect = lBadge!.getBoundingClientRect();\n const rRect = rBadge.getBoundingClientRect();\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left - 0;\n \n // ── UNIVERSAL SPINE JUNCTION PUSHED TO X1+75 TO CLEAR LOCK ICON ──\n const centerX = x1 + 75;\n\n const rawLhsY = lRect.top + lRect.height / 2;\n // Target the middle of the highlighted text vertically\n const rawRhsY = rRect.top + rRect.height / 2;\n\n const lhsScrollY = (rawLhsY - leftTop) + leftScrollTop;\n const rhsScrollY = (rawRhsY - rightTop) + rightScrollTop;\n \n const styleId = `conn-guide-${connectedIdx}-${index}`;\n \n // ── BULLETPROOF MATH LABEL GENERATION ──\n let baseLabel = \"\";\n if (typeof connectedIdx === 'string' && connectedIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const parts = connectedIdx.split(DEVIATION_BADGE_SEPARATOR);\n const leftKeyPath = parts[2] || \"\";\n baseLabel = leftKeyPath.split('-').map(n => Number(n) + 1).join('.');\n } else {\n baseLabel = String(Number(connectedIdx) + 1);\n }\n const letter = String.fromCharCode(97 + index); // a, b, c...\n const matchLabel = targetMarks.length === 1 ? null : `${baseLabel}(${letter})`;\n\n newCache.push({\n lhsScrollY, rhsScrollY, x1, x2, containerTop: cTop,\n leftIdx: connectedIdx, rhsArrayIdx: index, \n styleColor: style?.badgeBorder || \"#6366F1\", \n styleBg: style?.badgeBg || \"#FFFFFF\",\n styleText: style?.badgeText || \"#A16207\",\n styleId, centerX,\n });\n\n const clampedLhsY = clamp(rawLhsY, leftTop, leftBottom);\n const clampedRhsY = clamp(rawRhsY, rightTop, rightBottom);\n\n const y1 = clampedLhsY - cTop;\n const y2 = clampedRhsY - cTop;\n\n const lhsVisible = rawLhsY >= leftTop - 4 && rawLhsY <= leftBottom + 4;\n const rhsVisible = rawRhsY >= rightTop - 4 && rawRhsY <= rightBottom + 4;\n\n const pathD = getRoundedStaggeredPath(x1, y1, x2, y2, centerX, lhsVisible, rhsVisible);\n\n newConnectedLines.push({ \n id: styleId, pathD, style, leftIdx: connectedIdx, rhsArrayIdx: index, \n x1, x2, y1, y2, centerX, matchLabel, isGuideline: true \n });\n });\n } else {\n // ── UNIFIED CONTRACT TO CONTRACT LOGIC ──\n if (typeof connectedIdx === 'string' && connectedIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const [nodeId, devKey, leftKeyPath, rightKeyPath] = connectedIdx.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n\n const lBadge = lhsBadgeRefs.current[refId]?.current;\n const rBadge = rhsBadgeRefs.current[refId]?.current;\n if (!lBadge || !rBadge) return;\n\n const lRect = lBadge.getBoundingClientRect();\n const rRect = rBadge.getBoundingClientRect();\n const style = getDeviationStyleByKey(nodeId, devKey) ?? getSubSectionCompareStyle(leftKeyPath);\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left - 0;\n const centerX = x1 + 75; // ── UNIVERSAL SPINE JUNCTION ──\n\n const rawLhsY = lRect.top + lRect.height / 2;\n const rawRhsY = rRect.top + rRect.height / 2;\n\n const lhsScrollY = (rawLhsY - leftTop) + leftScrollTop;\n const rhsScrollY = (rawRhsY - rightTop) + rightScrollTop;\n const styleId = `conn-subsec-${refId}`;\n \n const leftKeyP = leftKeyPath || \"\";\n const baseLabel = leftKeyP.split('-').map(n => Number(n) + 1).join('.');\n const matchLabel = null; // 1-to-1 connection, no badge needed\n\n newCache.push({\n lhsScrollY, rhsScrollY, x1, x2, containerTop: cTop,\n leftIdx: connectedIdx, rhsArrayIdx: connectedIdx,\n styleColor: style?.badgeBorder || \"#6366F1\", styleBg: style?.badgeBg || \"#FFFFFF\", styleText: style?.badgeText || \"#A16207\",\n styleId, centerX, \n });\n\n const clampedLhsY = clamp(rawLhsY, leftTop, leftBottom);\n const clampedRhsY = clamp(rawRhsY, rightTop, rightBottom);\n const y1 = clampedLhsY - cTop;\n const y2 = clampedRhsY - cTop;\n const lhsVisible = rawLhsY >= leftTop - 4 && rawLhsY <= leftBottom + 4;\n const rhsVisible = rawRhsY >= rightTop - 4 && rawRhsY <= rightBottom + 4;\n\n const pathD = getRoundedStaggeredPath(x1, y1, x2, y2, centerX, lhsVisible, rhsVisible);\n\n newConnectedLines.push({ id: styleId, pathD, style, leftIdx: connectedIdx, rhsArrayIdx: connectedIdx, x1, x2, y1, y2, matchLabel });\n } else {\n if (!maintainRelativeOrder) {\n const leftIdx = connectedIdx;\n const rhsArrayIdx = leftIdx as number;\n const lBadge = lhsBadgeRefs.current[leftIdx]?.current;\n const rBadge = rhsBadgeRefs.current[rhsArrayIdx]?.current;\n if (!lBadge || !rBadge) return;\n\n const lRect = lBadge.getBoundingClientRect();\n const rRect = rBadge.getBoundingClientRect();\n const style = getSectionCompareStyle(leftIdx as number);\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left - 0;\n const centerX = x1 + 75; // ── UNIVERSAL SPINE JUNCTION ──\n\n const rawLhsY = lRect.top + lRect.height / 2;\n const rawRhsY = rRect.top + rRect.height / 2;\n const lhsScrollY = (rawLhsY - leftTop) + leftScrollTop;\n const rhsScrollY = (rawRhsY - rightTop) + rightScrollTop;\n const styleId = `conn-${leftIdx}-${rhsArrayIdx}`;\n \n const baseLabel = String(Number(connectedIdx) + 1);\n const matchLabel = null; // 1-to-1 connection, no badge needed\n\n newCache.push({\n lhsScrollY, rhsScrollY, x1, x2, containerTop: cTop,\n leftIdx, rhsArrayIdx, \n styleColor: style?.badgeBorder || \"#6366F1\", styleBg: style?.badgeBg || \"#FFFFFF\", styleText: style?.badgeText || \"#A16207\",\n styleId, centerX,\n });\n\n const clampedLhsY = clamp(rawLhsY, leftTop, leftBottom);\n const clampedRhsY = clamp(rawRhsY, rightTop, rightBottom);\n const y1 = clampedLhsY - cTop;\n const y2 = clampedRhsY - cTop;\n const lhsVisible = rawLhsY >= leftTop - 4 && rawLhsY <= leftBottom + 4;\n const rhsVisible = rawRhsY >= rightTop - 4 && rawRhsY <= rightBottom + 4;\n\n const pathD = getRoundedStaggeredPath(x1, y1, x2, y2, centerX, lhsVisible, rhsVisible);\n\n newConnectedLines.push({ id: styleId, pathD, style, leftIdx, rhsArrayIdx, x1, x2, y1, y2, matchLabel });\n } else {\n const leftIdx = connectedIdx as number;\n const leftSec = proposedSections[leftIdx] as any;\n if (!leftSec?.refIndexes?.length) return;\n\n leftSec.refIndexes.forEach((rhsSelfIdx: number, index: number) => {\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIdx);\n if (rhsArrayIdx === -1) return;\n\n const lBadge = lhsBadgeRefs.current[leftIdx]?.current;\n const rBadge = rhsBadgeRefs.current[rhsArrayIdx]?.current;\n if (!lBadge || !rBadge) return;\n\n const lRect = lBadge.getBoundingClientRect();\n const rRect = rBadge.getBoundingClientRect();\n const style = getSectionCompareStyle(leftIdx);\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left - 0;\n \n const centerX = x1 + 75; // ── UNIVERSAL SPINE JUNCTION ──\n\n const rawLhsY = lRect.top + lRect.height / 2;\n const rawRhsY = rRect.top + rRect.height / 2;\n const lhsScrollY = (rawLhsY - leftTop) + leftScrollTop;\n const rhsScrollY = (rawRhsY - rightTop) + rightScrollTop;\n const styleId = `conn-${leftIdx}-${rhsArrayIdx}`;\n \n const baseLabel = String(Number(connectedIdx) + 1);\n const letter = String.fromCharCode(97 + index); \n const matchLabel = leftSec.refIndexes.length === 1 ? null : `${baseLabel}(${letter})`;\n\n newCache.push({\n lhsScrollY, rhsScrollY, x1, x2, containerTop: cTop,\n leftIdx, rhsArrayIdx,\n styleColor: style?.badgeBorder || \"#6366F1\", styleBg: style?.badgeBg || \"#FFFFFF\", styleText: style?.badgeText || \"#A16207\",\n styleId, centerX,\n });\n\n const clampedLhsY = clamp(rawLhsY, leftTop, leftBottom);\n const clampedRhsY = clamp(rawRhsY, rightTop, rightBottom);\n const y1 = clampedLhsY - cTop;\n const y2 = clampedRhsY - cTop;\n const lhsVisible = rawLhsY >= leftTop - 4 && rawLhsY <= leftBottom + 4;\n const rhsVisible = rawRhsY >= rightTop - 4 && rawRhsY <= rightBottom + 4;\n\n const pathD = getRoundedStaggeredPath(x1, y1, x2, y2, centerX, lhsVisible, rhsVisible);\n\n newConnectedLines.push({\n id: styleId, pathD, style, leftIdx, rhsArrayIdx, x1, x2, y1, y2, matchLabel,\n });\n });\n }\n }\n }\n });\n cachedConnectedPositions.current = newCache;\n }\n setConnectedLines(newConnectedLines);\n\n setTimeout(() => updateConnectedLinesOnScroll(), 10);\n } else {\n setConnectedLines([]);\n cachedConnectedPositions.current = [];\n setTimeout(() => updateConnectedLinesOnScroll(), 10);\n }\n } catch (e) {\n console.error(\"Line render safe fail: \", e);\n } finally {\n isCalculatingLines.current = false;\n }\n }, [\n visibleFields,\n proposedSections,\n existingSections,\n cognitiveMap,\n resolvedComparisonConfig,\n getFieldData,\n getSectionCompareStyle,\n getDeviationStyleByKey,\n maintainRelativeOrder,\n isSideBySide, \n activeSideBySideSection, \n connectedSections,\n expandedSections,\n expandedSubSections,\n isGuidelineMode, \n ]);\n\n const updateConnectedLinesOnScroll = useCallback(() => {\n const cache = cachedConnectedPositions.current;\n \n if (!cache.length) {\n pathRefs.current[\"guideline-up-stroke\"]?.setAttribute(\"visibility\", \"hidden\");\n pathRefs.current[\"guideline-up-badge\"]?.setAttribute(\"visibility\", \"hidden\");\n pathRefs.current[\"guideline-down-stroke\"]?.setAttribute(\"visibility\", \"hidden\");\n pathRefs.current[\"guideline-down-badge\"]?.setAttribute(\"visibility\", \"hidden\");\n return;\n }\n\n if (isAnimatingRef.current) return;\n \n const leftScroll = leftContainerRef.current?.scrollTop ?? 0;\n const rightScroll = rightContainerRef.current?.scrollTop ?? 0;\n \n const leftHeight = leftContainerRef.current?.clientHeight ?? Infinity;\n const rightHeight = rightContainerRef.current?.clientHeight ?? Infinity;\n \n const leftTop = leftContainerRef.current?.getBoundingClientRect().top ?? 0;\n const rightTop = rightContainerRef.current?.getBoundingClientRect().top ?? 0;\n \n const leftBottom = leftTop + leftHeight;\n const rightBottom = rightTop + rightHeight;\n \n const containerRect = containerRef.current?.getBoundingClientRect();\n const containerTop = containerRect?.top ?? 0;\n const containerHeight = containerRect?.height ?? Infinity;\n \n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n \n let topCount = 0;\n let bottomCount = 0;\n let sharedX1 = 0, sharedY1 = 0;\n let sharedColor = \"#6366F1\", sharedBg = \"#FFFFFF\", sharedTextCol = \"#A16207\";\n let hasActiveConnections = false;\n let universalSpineX = 0; \n\n cache.forEach((entry: any) => {\n const lhsViewportY = (entry.lhsScrollY - leftScroll) + leftTop;\n const rhsViewportY = (entry.rhsScrollY - rightScroll) + rightTop;\n \n const strokeEl = pathRefs.current[entry.styleId + \"-stroke\"];\n const bgEl = pathRefs.current[entry.styleId + \"-bg\"];\n const btnEl = pathRefs.current[entry.styleId + \"-btn\"];\n const numberBadgeEl = pathRefs.current[entry.styleId + \"-number\"];\n \n if (!strokeEl && !bgEl) return;\n \n const visibleLhsY = clamp(lhsViewportY, leftTop, leftBottom);\n const visibleRhsY = clamp(rhsViewportY, rightTop, rightBottom);\n \n const y1 = visibleLhsY - containerTop;\n const y2 = visibleRhsY - containerTop;\n \n const lhsVisible = lhsViewportY >= leftTop - 4 && lhsViewportY <= leftBottom + 4;\n const rhsVisible = rhsViewportY >= rightTop - 4 && rhsViewportY <= rightBottom + 4;\n \n let showLine = true;\n hasActiveConnections = true;\n\n // Enforce absolute strict universal spine\n const centerX = entry.centerX || (entry.x1 + 75);\n\n if (sharedX1 === 0) {\n sharedX1 = entry.x1;\n sharedY1 = y1;\n universalSpineX = centerX;\n sharedColor = entry.styleColor;\n sharedBg = entry.styleBg || \"#FFFFFF\";\n sharedTextCol = entry.styleText || \"#A16207\";\n }\n\n if (rhsViewportY < rightTop - 4) {\n topCount++; showLine = false; \n } else if (rhsViewportY > rightBottom + 4) {\n bottomCount++; showLine = false; \n } \n \n const pathD = getRoundedStaggeredPath(entry.x1, y1, entry.x2, y2, universalSpineX, lhsVisible, rhsVisible);\n \n if (strokeEl) {\n if (showLine && pathD) {\n strokeEl.setAttribute(\"visibility\", \"visible\");\n strokeEl.setAttribute(\"d\", pathD);\n } else { strokeEl.setAttribute(\"visibility\", \"hidden\"); }\n }\n \n if (bgEl) {\n if (showLine && pathD) {\n bgEl.setAttribute(\"visibility\", \"visible\");\n bgEl.setAttribute(\"d\", pathD);\n } else { bgEl.setAttribute(\"visibility\", \"hidden\"); }\n }\n\n if (btnEl) {\n if (!lhsVisible || !showLine) {\n btnEl.setAttribute(\"visibility\", \"hidden\");\n } else {\n btnEl.setAttribute(\"visibility\", \"visible\");\n btnEl.setAttribute(\"y\", String(y1 - 12)); \n }\n }\n\n if (numberBadgeEl) {\n if (!lhsVisible || !showLine) {\n numberBadgeEl.setAttribute(\"visibility\", \"hidden\");\n } else {\n numberBadgeEl.setAttribute(\"visibility\", \"visible\");\n numberBadgeEl.setAttribute(\"transform\", `translate(${entry.x2 - 42}, ${y2})`);\n }\n }\n });\n\n // ── UNIVERSAL OFF-SCREEN ARROWS (ALWAYS ORIGINATE EXACTLY AT THE SPINE: X1 + 75) ──\n if (hasActiveConnections && universalSpineX > 0) {\n const upStroke = pathRefs.current[\"guideline-up-stroke\"];\n const upBadge = pathRefs.current[\"guideline-up-badge\"];\n const upArrow = pathRefs.current[\"guideline-up-arrow\"];\n const upText = pathRefs.current[\"guideline-up-text\"];\n const upRect = pathRefs.current[\"guideline-up-badge-rect\"];\n\n if (topCount > 0) {\n const upY = Math.max(15, rightTop - containerTop + 15); \n const r = Math.min(15, Math.abs(universalSpineX - sharedX1), Math.max(0, sharedY1 - upY));\n const pathD = `M ${sharedX1},${sharedY1} L ${universalSpineX - r},${sharedY1} Q ${universalSpineX},${sharedY1} ${universalSpineX},${sharedY1 - r} L ${universalSpineX},${upY}`;\n\n upStroke?.setAttribute(\"visibility\", \"visible\");\n upStroke?.setAttribute(\"d\", pathD);\n upStroke?.setAttribute(\"stroke\", sharedColor);\n\n upBadge?.setAttribute(\"visibility\", \"visible\");\n upBadge?.setAttribute(\"transform\", `translate(${universalSpineX}, ${upY})`);\n \n if (upArrow) { upArrow.setAttribute(\"fill\", sharedColor); }\n if (upText) { upText.textContent = `+${topCount}`; upText.setAttribute(\"fill\", sharedTextCol); }\n if (upRect) { upRect.setAttribute(\"stroke\", sharedColor); }\n } else {\n upStroke?.setAttribute(\"visibility\", \"hidden\");\n upBadge?.setAttribute(\"visibility\", \"hidden\");\n }\n\n const downStroke = pathRefs.current[\"guideline-down-stroke\"];\n const downBadge = pathRefs.current[\"guideline-down-badge\"];\n const downArrow = pathRefs.current[\"guideline-down-arrow\"];\n const downText = pathRefs.current[\"guideline-down-text\"];\n const downRect = pathRefs.current[\"guideline-down-badge-rect\"];\n\n if (bottomCount > 0) {\n const downY = Math.min(containerHeight - 15, rightBottom - containerTop - 15);\n const r = Math.min(15, Math.abs(universalSpineX - sharedX1), Math.max(0, downY - sharedY1));\n const pathD = `M ${sharedX1},${sharedY1} L ${universalSpineX - r},${sharedY1} Q ${universalSpineX},${sharedY1} ${universalSpineX},${sharedY1 + r} L ${universalSpineX},${downY}`;\n\n downStroke?.setAttribute(\"visibility\", \"visible\");\n downStroke?.setAttribute(\"d\", pathD);\n downStroke?.setAttribute(\"stroke\", sharedColor);\n\n downBadge?.setAttribute(\"visibility\", \"visible\");\n downBadge?.setAttribute(\"transform\", `translate(${universalSpineX}, ${downY})`);\n \n if (downArrow) { downArrow.setAttribute(\"fill\", sharedColor); }\n if (downText) { downText.textContent = `+${bottomCount}`; downText.setAttribute(\"fill\", sharedTextCol); }\n if (downRect) { downRect.setAttribute(\"stroke\", sharedColor); }\n } else {\n downStroke?.setAttribute(\"visibility\", \"hidden\");\n downBadge?.setAttribute(\"visibility\", \"hidden\");\n }\n }\n }, []);\n\n const calculateLinesDebounced = useCallback(() => {\n if (cachedConnectedPositions.current.length > 0 && !isAnimatingRef.current) {\n return;\n }\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n calculateLinesRef.current();\n timerRef.current = null;\n }, 50);\n }, []); \n \n \n const handleColumnScroll = useCallback((e: any) => {\n if (pendingScrollTargetRef.current !== null && pendingScrollCallbackRef.current) {\n if (Math.abs(e.currentTarget.scrollTop - pendingScrollTargetRef.current) <= 2) {\n const callback = pendingScrollCallbackRef.current;\n pendingScrollTargetRef.current = null;\n pendingScrollCallbackRef.current = null;\n callback();\n }\n }\n \n if (scrollSyncing.current) return;\n if (scrollLock.current) return;\n\n if (\n maintainRelativeOrder &&\n scrollSyncLocked &&\n (isSideBySideRef.current || connectedSections.size > 0)\n ) {\n const source = e.currentTarget as HTMLElement;\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n const target =\n source === leftContainer\n ? rightContainer\n : source === rightContainer\n ? leftContainer\n : null;\n\n if (source && target) {\n const resolveActiveAnchors = () => {\n const activeLeftIdx = activeSideBySideSectionRef.current;\n const activeRightIdx = activeSideBySideRightSectionRef.current;\n\n if (activeLeftIdx === null) return { leftAnchor: null, rightAnchor: null };\n\n if (\n typeof activeLeftIdx === \"string\" &&\n activeLeftIdx.includes(DEVIATION_BADGE_SEPARATOR)\n ) {\n const parts = activeLeftIdx.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n\n return {\n leftAnchor:\n lhsBadgeRefs.current[refId]?.current ||\n subSectionLeftRefs.current[parts[2]]?.current ||\n sectionLeftRefs.current[Number(parts[2])]?.current ||\n null,\n rightAnchor:\n rhsBadgeRefs.current[refId]?.current ||\n subSectionRightRefs.current[parts[3]]?.current ||\n sectionRightRefs.current[Number(parts[3])]?.current ||\n null,\n };\n }\n\n const leftIdx = Number(activeLeftIdx);\n const rightIdx = activeRightIdx !== null ? Number(activeRightIdx) : leftIdx;\n\n return {\n leftAnchor:\n lhsBadgeRefs.current[leftIdx]?.current ||\n sectionRowRefs.current[leftIdx]?.current ||\n sectionLeftRefs.current[leftIdx]?.current ||\n null,\n rightAnchor:\n rhsBadgeRefs.current[rightIdx]?.current ||\n sectionRightRefs.current[rightIdx]?.current ||\n null,\n };\n };\n\n const { leftAnchor, rightAnchor } = resolveActiveAnchors();\n const sourceAnchor = source === leftContainer ? leftAnchor : rightAnchor;\n const targetAnchor = source === leftContainer ? rightAnchor : leftAnchor;\n\n let nextTargetTop: number | null = null;\n\n if (sourceAnchor && targetAnchor) {\n const sourceAnchorRect = sourceAnchor.getBoundingClientRect();\n const targetAnchorRect = targetAnchor.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n\n const sourceAnchorCenterY =\n sourceAnchorRect.top + sourceAnchorRect.height / 2;\n const targetAnchorAbsoluteCenterY =\n targetAnchorRect.top -\n targetRect.top +\n target.scrollTop +\n targetAnchorRect.height / 2;\n\n nextTargetTop =\n targetAnchorAbsoluteCenterY - (sourceAnchorCenterY - targetRect.top);\n } else {\n const sourceMaxScroll = Math.max(0, source.scrollHeight - source.clientHeight);\n const targetMaxScroll = Math.max(0, target.scrollHeight - target.clientHeight);\n nextTargetTop = sourceMaxScroll > 0\n ? (source.scrollTop / sourceMaxScroll) * targetMaxScroll\n : source.scrollTop;\n }\n\n const targetMaxScroll = Math.max(0, target.scrollHeight - target.clientHeight);\n nextTargetTop = Math.max(0, Math.min(nextTargetTop, targetMaxScroll));\n\n if (Math.abs(target.scrollTop - nextTargetTop) > 1) {\n scrollSyncing.current = true;\n target.scrollTop = nextTargetTop;\n requestAnimationFrame(() => {\n scrollSyncing.current = false;\n });\n }\n }\n }\n \n if (!maintainRelativeOrder) {\n calculateLinesDebounced();\n }\n \n if (!scrollTicking.current) {\n scrollTicking.current = true;\n \n requestAnimationFrame(() => {\n if (isSideBySideRef.current) {\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n \n if (leftContainer && rightContainer && sideBySideLineRef.current) {\n if (!sideBySideCacheRef.current) {\n const activeLeftIdx = activeSideBySideSectionRef.current;\n let lBadge;\n \n if (typeof activeLeftIdx === 'string' && activeLeftIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const parts = activeLeftIdx.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n lBadge = lhsBadgeRefs.current[refId]?.current;\n } else {\n lBadge = lhsBadgeRefs.current[activeLeftIdx as number]?.current;\n }\n \n if (lBadge) {\n const lRect = lBadge.getBoundingClientRect();\n sideBySideCacheRef.current = {\n badgeScreenY: lRect.top + lRect.height / 2, \n initialScrollTop: leftContainer.scrollTop, \n leftTop: leftContainer.getBoundingClientRect().top,\n leftBottom: leftContainer.getBoundingClientRect().top + leftContainer.clientHeight,\n cTop: containerRef.current?.getBoundingClientRect().top ?? 0\n };\n }\n }\n \n if (sideBySideCacheRef.current) {\n const cache = sideBySideCacheRef.current;\n const scrollDelta = leftContainer.scrollTop - cache.initialScrollTop;\n const rawLhsY = cache.badgeScreenY - scrollDelta;\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n const clampedLhsY = clamp(rawLhsY, cache.leftTop, cache.leftBottom);\n const horizontalY = (clampedLhsY - cache.cTop).toString();\n const isVisible = rawLhsY >= cache.leftTop - 4 && rawLhsY <= cache.leftBottom + 4;\n \n sideBySideLineRef.current.setAttribute(\"y1\", horizontalY);\n sideBySideLineRef.current.setAttribute(\"y2\", horizontalY); \n sideBySideLineRef.current.setAttribute(\"visibility\", isVisible ? \"visible\" : \"hidden\");\n }\n }\n }\n \n updateConnectedLinesOnScroll(); \n scrollTicking.current = false;\n });\n }\n }, [\n updateConnectedLinesOnScroll,\n maintainRelativeOrder,\n scrollSyncLocked,\n connectedSections,\n calculateLinesDebounced,\n ]);\n\n\n useEffect(() => {\n calculateLinesRef.current = calculateLines;\n }, [calculateLines]);\n\n useEffect(() => {\n const timer = setTimeout(calculateLinesDebounced, 250);\n const onWindowResize = () => handleResizeRef.current();\n window.addEventListener(\"resize\", onWindowResize);\n \n return () => {\n clearTimeout(timer);\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n if (resizeTimerRef.current !== null) clearTimeout(resizeTimerRef.current);\n window.removeEventListener(\"resize\", onWindowResize);\n };\n }, [\n activeProposed,\n existingRule,\n analysisData,\n visibleFields,\n expandedSections,\n expandedSubSections,\n proposedSections,\n existingSections,\n resolvedComparisonConfig,\n calculateLinesDebounced,\n isSideBySide,\n activeSideBySideSection,\n isArrowVisible,\n connectedSections,\n ]);\n\n\n return {\n lines, setLines,\n overallConnector, setOverallConnector,\n connectedLines, setConnectedLines,\n svgDimensions,\n cachedConnectedPositions,\n calculateLines,\n calculateLinesRef,\n calculateLinesDebounced,\n handleColumnScroll,\n}\n\n}\n"],"names":["containerRef","leftContainerRef","rightContainerRef","svgContainerRef","pathRefs","leftHeaderRef","rightHeaderRef","proposedSections","existingSections","visibleFields","leftRefs","rightRefs","sectionLeftRefs","sectionRightRefs","subSectionLeftRefs","subSectionRightRefs","lhsBadgeRefs","rhsBadgeRefs","sectionRowRefs","expandedSections","expandedSubSections","connectedSections","isSideBySide","activeSideBySideSection","maintainRelativeOrder","isGuidelineMode","cognitiveMap","getSectionCompareStyle","getSubSectionCompareStyle","getDeviationStyleByKey","isArrowVisible","isAnimatingRef","isSideBySideRef","sideBySideCacheRef","sideBySideLineRef","activeSideBySideSectionRef","activeSideBySideRightSectionRef","connectedLines","providedConnectedLines","setConnectedLines","providedSetConnectedLines","cachedConnectedPositions","providedCachedConnectedPositions","calculateLinesRef","resizeTimerRef","scrollLock","scrollSyncLocked","handleResizeRef","activeProposed","existingRule","analysisData","pendingScrollTargetRef","pendingScrollCallbackRef","resolvedComparisonConfig","getFieldData","lines","setLines","useState","overallConnector","setOverallConnector","internalConnectedLines","internalSetConnectedLines","svgDimensions","setSvgDimensions","width","height","isCalculatingLines","useRef","scrollTicking","scrollSyncing","timerRef","internalCachedConnectedPositions","getRoundedStaggeredPath","x1","y1","x2","y2","cX","visL","visR","Math","abs","r1","min","r2","dy1","dy2","dx2","calculateLines","useCallback","current","isSubSectionVisible","keyPath","pathParts","split","rootIdx","ancestorPath","i","length","containerRect","getBoundingClientRect","newLines","forEach","key","l","r","style","minHeight","idx","max","Object","keys","fieldHeights","lRect","rRect","syncHeights","left","right","subSectionHeights","leftIdx","leftSec","refIndexes","rhsSelfIdx","rhsArrayIdx","findIndex","s","selfIndex","maxH","DEVIATION_BADGE_SEPARATOR","offsetParent","entries","Number","getMappedRightIndexes","mapped","map","filter","Array","from","Set","continuationSourceIdx","continuationSourceRowId","section","comparisonRowId","resolvedLeftIdx","lWrap","rWrap","leftRect","rightRect","top","leftTop","rightTop","leftBottom","clientHeight","Infinity","rightBottom","clamp","v","push","id","sectionIdx","targetRightIdx","isSubSection","isMappingContinuation","hasCognitive","cognitiveData","nodeId","includes","devKey","leftKeyPath","rightKeyPath","refId","lBadgeEl","rBadgeEl","subSectionKeyPath","leftHeaderRect","rightHeaderRect","overallY","y","size","newConnectedLines","leftContainer","rightContainer","newCache","leftScrollTop","scrollTop","rightScrollTop","cTop","connectedIdx","lBadge","leftIdxNum","targetMarks","document","querySelectorAll","rBadge","index","centerX","rawLhsY","rawRhsY","lhsScrollY","rhsScrollY","styleId","baseLabel","n","join","String","letter","fromCharCode","matchLabel","containerTop","styleColor","badgeBorder","styleBg","badgeBg","styleText","badgeText","clampedLhsY","clampedRhsY","pathD","isGuideline","setTimeout","updateConnectedLinesOnScroll","e","console","error","cache","setAttribute","leftScroll","rightScroll","leftHeight","rightHeight","containerHeight","topCount","bottomCount","sharedX1","sharedY1","sharedColor","sharedTextCol","hasActiveConnections","universalSpineX","entry","lhsViewportY","rhsViewportY","strokeEl","bgEl","btnEl","numberBadgeEl","visibleLhsY","visibleRhsY","lhsVisible","rhsVisible","showLine","upStroke","upBadge","upArrow","upText","upRect","upY","textContent","downStroke","downBadge","downArrow","downText","downRect","downY","calculateLinesDebounced","clearTimeout","handleColumnScroll","currentTarget","callback","source","target","resolveActiveAnchors","activeLeftIdx","activeRightIdx","leftAnchor","rightAnchor","parts","rightIdx","sourceAnchor","targetAnchor","nextTargetTop","sourceAnchorRect","targetAnchorRect","targetRect","sourceAnchorCenterY","sourceMaxScroll","scrollHeight","targetMaxScroll","requestAnimationFrame","badgeScreenY","initialScrollTop","scrollDelta","horizontalY","toString","isVisible","useEffect","timer","onWindowResize","window","addEventListener","removeEventListener"],"mappings":"iKAKkC,EAC9BA,eACAC,mBACAC,oBACAC,kBACAC,WACAC,gBAAeC,iBACfC,mBAAkBC,mBAClBC,gBACAC,WAAUC,YACVC,kBAAiBC,mBACjBC,qBAAoBC,sBACpBC,eAAcC,eACdC,iBACAC,mBAAkBC,sBAClBC,oBACAC,eAAcC,0BACdC,wBACAC,kBACAC,eACAC,yBAAwBC,4BAA2BC,yBACnDC,iBAEAC,iBACAC,kBACAC,qBACAC,oBACAC,6BACAC,kCACAC,eAAgBC,EAChBC,kBAAmBC,EACnBC,yBAA0BC,EAC1BC,oBACAC,iBACAC,aACAC,mBAEAC,kBACAC,iBAAgBC,eAAcC,eAC9BC,yBAAwBC,2BAExBC,2BACAC,mBAGA,MAAOC,GAAOC,IAAYC,EAAAA,SAAgC,KACnDC,GAAkBC,IAAuBF,WAAwD,OACjGG,GAAwBC,IAA6BJ,EAAAA,SAAgC,IACtFpB,GAAiBC,GAA0BsB,GAC3CrB,GAAoBC,GAA6BqB,IAChDC,GAAeC,IAAoBN,EAAAA,SAA4C,CAAEO,MAAO,EAAGC,OAAQ,IAEpGC,GAAqBC,UAAO,GAC5BC,GAAgBD,UAAO,GACvBE,GAAgBF,UAAO,GACvBG,GAAWH,SAA6C,MACxDI,GAAmCJ,SAA8B,IACjE1B,GACJC,GAAoC6B,GAMhCC,GAA0B,CAACC,EAAYC,EAAYC,EAAYC,EAAYC,EAAYC,EAAeC,KAC1G,GAAIC,KAAKC,IAAIL,EAAKF,IAAO,EACjB,OAAAI,GAAQC,EAAa,KAAKN,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"version":3,"file":"useLinesCalculator.js","sources":["../../../../../src/features/CognitiveCompare/hooks/useLinesCalculator.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\"\nimport { CachedBadgePosition, SectionBlock } from \"../CognitiveCompareTypes\";\nimport { DEVIATION_BADGE_SEPARATOR, getBentArrowPath, hasValue } from \"../CognitiveComparehelpers\";\nimport { maxHeight } from \"@mui/system\";\nimport { getVisibleGuidelineTargets } from \"../Guidelines/utils/guidelineTargets\";\n\nexport const useLinesCalculator = ({\n containerRef,\n leftContainerRef,\n rightContainerRef,\n svgContainerRef,\n pathRefs,\n leftHeaderRef, rightHeaderRef,\n proposedSections, existingSections,\n visibleFields,\n leftRefs, rightRefs,\n sectionLeftRefs, sectionRightRefs,\n subSectionLeftRefs, subSectionRightRefs,\n lhsBadgeRefs, rhsBadgeRefs,\n sectionRowRefs,\n expandedSections, expandedSubSections,\n connectedSections,\n isSideBySide, activeSideBySideSection,\n maintainRelativeOrder,\n isGuidelineMode, // ── NEW PROP ──\n cognitiveMap,\n getSectionCompareStyle, getSubSectionCompareStyle, getDeviationStyleByKey,\n isArrowVisible,\n\n isAnimatingRef,\n isSideBySideRef,\n sideBySideCacheRef,\n sideBySideLineRef,\n activeSideBySideSectionRef,\n activeSideBySideRightSectionRef,\n connectedLines: providedConnectedLines,\n setConnectedLines: providedSetConnectedLines,\n cachedConnectedPositions: providedCachedConnectedPositions,\n calculateLinesRef,\n resizeTimerRef,\n scrollLock,\n scrollSyncLocked,\n\n handleResizeRef,\n activeProposed, existingRule, analysisData,\n pendingScrollTargetRef, pendingScrollCallbackRef,\n\n resolvedComparisonConfig,\n getFieldData\n}: any) => {\n // States and Refs\n const [lines, setLines] = useState<Record<string, any>[]>([]);\n const [overallConnector, setOverallConnector] = useState<{ x1: number; x2: number; y: number; } | null>(null);\n const [internalConnectedLines, internalSetConnectedLines] = useState<Record<string, any>[]>([]);\n const connectedLines = providedConnectedLines ?? internalConnectedLines;\n const setConnectedLines = providedSetConnectedLines ?? internalSetConnectedLines;\n const [svgDimensions, setSvgDimensions] = useState<{ width: number; height: number }>({ width: 0, height: 0 });\n\n const isCalculatingLines = useRef(false);\n const scrollTicking = useRef(false);\n const scrollSyncing = useRef(false);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const internalCachedConnectedPositions = useRef<CachedBadgePosition[]>([]);\n const cachedConnectedPositions =\n providedCachedConnectedPositions ?? internalCachedConnectedPositions;\n\n\n \n // Helpers\n // ── UNIFIED ROUNDED PATH GENERATOR (Guarantees shared trunk for ALL modes) ──\n const getRoundedStaggeredPath = (x1: number, y1: number, x2: number, y2: number, cX: number, visL: boolean, visR: boolean) => {\n if (Math.abs(y2 - y1) <= 1) {\n if (visL && visR) return `M ${x1},${y1} L ${x2},${y2}`;\n if (visL && !visR) return `M ${x1},${y1} L ${cX},${y1}`;\n if (!visL && visR) return `M ${cX},${y1} L ${x2},${y2}`;\n return `M ${cX},${y1} L ${cX},${y2}`;\n }\n const r1 = Math.min(15, Math.abs(cX - x1), Math.abs(y2 - y1) / 2);\n const r2 = Math.min(15, Math.abs(x2 - cX), Math.abs(y2 - y1) / 2);\n const dy1 = y2 > y1 ? r1 : -r1;\n const dy2 = y2 > y1 ? r2 : -r2;\n const dx2 = x2 > cX ? r2 : -r2; // Safe horizontal direction\n \n if (visL && visR) {\n return `M ${x1},${y1} L ${cX - r1},${y1} Q ${cX},${y1} ${cX},${y1 + dy1} L ${cX},${y2 - dy2} Q ${cX},${y2} ${cX + dx2},${y2} L ${x2},${y2}`;\n } else if (visL && !visR) {\n return `M ${x1},${y1} L ${cX - r1},${y1} Q ${cX},${y1} ${cX},${y1 + dy1} L ${cX},${y2}`;\n } else if (!visL && visR) {\n return `M ${cX},${y1} L ${cX},${y2 - dy2} Q ${cX},${y2} ${cX + dx2},${y2} L ${x2},${y2}`;\n } else {\n return `M ${cX},${y1} L ${cX},${y2}`;\n }\n };\n\n // Helper to check if a subsection is actually visible in the expanded section\n const isSubSectionVisible = (keyPath: string) => {\n const pathParts = keyPath.split('-');\n const rootIdx = pathParts[0];\n\n // Edge case\n // Early return if root parent is not expanded\n // Only happens in side by side view for deeply nested children\n if (!expandedSections[rootIdx] && maintainRelativeOrder === false) return;\n\n if (maintainRelativeOrder) {\n if (!expandedSections[`left-${rootIdx}`] && !expandedSections[`right-${rootIdx}`] && !expandedSections[rootIdx]) return false;\n }\n\n // Check to confirm if all the ancestors of the node are expanded otherwise early return\n let ancestorPath = rootIdx;\n for (let i = 1; i < pathParts.length - 1; i++) {\n ancestorPath += `-${pathParts[i]}`;\n if (!expandedSections[ancestorPath]) return false;\n }\n\n return true;\n };\n\n // Callbacks\n const calculateLines = useCallback(() => {\n if (isCalculatingLines.current) return;\n if (isAnimatingRef.current) return;\n isCalculatingLines.current = true;\n try {\n if (!containerRef.current) return;\n\n // Helper to check if a subsection is actually visible in the expanded accordion tree\n const isSubSectionVisible = (keyPath: string) => {\n const pathParts = keyPath.split('-');\n const rootIdx = pathParts[0];\n\n // 1. Root Parent must be expanded\n if (!expandedSections[rootIdx] && maintainRelativeOrder === false) return false;\n if (maintainRelativeOrder) {\n if (!expandedSections[`left-${rootIdx}`] && !expandedSections[`right-${rootIdx}`] && !expandedSections[rootIdx]) return false;\n }\n\n // 2. All intermediate ancestor subsections must be expanded\n let ancestorPath = rootIdx;\n for (let i = 1; i < pathParts.length - 1; i++) {\n ancestorPath += `-${pathParts[i]}`;\n if (!expandedSubSections[ancestorPath]) {\n return false;\n }\n }\n return true;\n };\n\n // 3. Keep the SVG setup and field heights logic intact\n const containerRect = containerRef.current.getBoundingClientRect();\n setSvgDimensions({\n width: containerRect.width,\n height: containerRect.height,\n });\n\n const newLines: Record<string, any>[] = [];\n\n // RESET STYLES (WRITE ONLY)\n visibleFields.forEach(({ key }: {key: any}) => {\n const l = leftRefs.current[key]?.current;\n const r = rightRefs.current[key]?.current;\n\n if (l && r) {\n l.style.height = \"auto\";\n r.style.height = \"auto\";\n l.style.minHeight = \"0px\";\n r.style.minHeight = \"0px\";\n }\n });\n\n if (!isAnimatingRef.current) {\n for (let idx = 0; idx < Math.max(proposedSections.length, existingSections.length); idx++) {\n const l = sectionLeftRefs.current[idx]?.current;\n const r = sectionRightRefs.current[idx]?.current;\n\n if (l) {\n l.style.height = \"auto\";\n l.style.minHeight = \"0px\";\n }\n if (r) {\n r.style.height = \"auto\";\n r.style.minHeight = \"0px\";\n }\n }\n \n if (!maintainRelativeOrder) {\n // Subsections reset\n Object.keys(subSectionLeftRefs.current).forEach(keyPath => {\n if (!isSubSectionVisible(keyPath)) return;\n const l = subSectionLeftRefs.current[keyPath]?.current;\n const r = subSectionRightRefs.current[keyPath]?.current;\n if (l && r) {\n l.style.height = \"auto\";\n r.style.height = \"auto\";\n l.style.minHeight = \"0px\";\n r.style.minHeight = \"0px\";\n }\n });\n }\n }\n\n // READ HEIGHTS (READ ONLY)\n const fieldHeights: Record<string, number> = {};\n\n visibleFields.forEach(({ key } : {key: any}) => {\n const l = leftRefs.current[key]?.current;\n const r = rightRefs.current[key]?.current;\n\n if (l && r) {\n const lRect = l.getBoundingClientRect();\n const rRect = r.getBoundingClientRect();\n fieldHeights[key] = Math.max(lRect.height, rRect.height);\n }\n });\n\n const syncHeights = { left: {} as Record<number, number>, right: {} as Record<number, number> };\n const subSectionHeights: Record<string, number> = {};\n\n if (!isAnimatingRef.current) {\n if (!maintainRelativeOrder) {\n // ── FIX: Measure and apply subsection heights FIRST so their new heights push the parent containers ──\n Object.keys(subSectionLeftRefs.current).forEach(keyPath => {\n if (!isSubSectionVisible(keyPath)) return;\n const l = subSectionLeftRefs.current[keyPath]?.current;\n const r = subSectionRightRefs.current[keyPath]?.current;\n if (l && r && l.offsetParent !== null && r.offsetParent !== null) {\n const lRect = l.getBoundingClientRect();\n const rRect = r.getBoundingClientRect();\n const maxH = Math.max(lRect.height, rRect.height);\n subSectionHeights[keyPath] = maxH;\n \n // Apply immediately so the browser recalculates layout for the parent block below\n l.style.minHeight = `${maxH}px`;\n r.style.minHeight = `${maxH}px`;\n }\n });\n\n // ── NOW measure main sections (which will naturally wrap the aligned subsections) ──\n for (let idx = 0; idx < Math.min(proposedSections.length, existingSections.length); idx++) {\n const l = sectionLeftRefs.current[idx]?.current;\n const r = sectionRightRefs.current[idx]?.current;\n\n if (l && r) {\n const maxH = Math.max(l.getBoundingClientRect().height, r.getBoundingClientRect().height);\n syncHeights.left[idx] = maxH;\n syncHeights.right[idx] = maxH;\n }\n }\n\n } else if (isSideBySide && activeSideBySideSection !== null) {\n if (typeof activeSideBySideSection === \"number\") {\n const leftIdx = activeSideBySideSection;\n const leftSec = proposedSections[leftIdx] as any;\n const l = sectionLeftRefs.current[leftIdx]?.current;\n\n if (l && leftSec) {\n (leftSec.refIndexes || []).forEach((rhsSelfIdx: number) => {\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIdx);\n const r = sectionRightRefs.current[rhsArrayIdx]?.current;\n if (!r) return;\n\n if (expandedSections[`left-${leftIdx}`] || expandedSections[`right-${rhsArrayIdx}`]) {\n const maxH = Math.max(l.getBoundingClientRect().height, r.getBoundingClientRect().height);\n syncHeights.left[leftIdx] = Math.max(syncHeights.left[leftIdx] || 0, maxH);\n syncHeights.right[rhsArrayIdx] = Math.max(syncHeights.right[rhsArrayIdx] || 0, maxH);\n }\n });\n }\n } else {\n const keyPath = activeSideBySideSection.split(DEVIATION_BADGE_SEPARATOR)[2]; \n if (keyPath) {\n const l = subSectionLeftRefs.current[keyPath]?.current;\n const r = subSectionRightRefs.current[keyPath]?.current;\n if (l && r) {\n const maxH = Math.max(l.getBoundingClientRect().height, r.getBoundingClientRect().height);\n subSectionHeights[keyPath] = Math.max(subSectionHeights[keyPath] || 0, maxH);\n }\n }\n }\n }\n }\n\n visibleFields.forEach(({ key } : {key : any}) => {\n const l = leftRefs.current[key]?.current;\n const r = rightRefs.current[key]?.current;\n\n if (l && r) {\n const maxH = fieldHeights[key];\n l.style.minHeight = `${maxH}px`;\n r.style.minHeight = `${maxH}px`;\n }\n });\n\n if (!isAnimatingRef.current) {\n Object.entries(syncHeights.left).forEach(([idx, maxH]) => {\n const l = sectionLeftRefs.current[Number(idx)]?.current;\n if (l) l.style.minHeight = `${maxH}px`;\n });\n \n Object.entries(syncHeights.right).forEach(([idx, maxH]) => {\n const r = sectionRightRefs.current[Number(idx)]?.current;\n if (r) r.style.minHeight = `${maxH}px`;\n });\n\n if (!maintainRelativeOrder) {\n Object.keys(subSectionHeights).forEach(keyPath => {\n const l = subSectionLeftRefs.current[keyPath]?.current;\n const r = subSectionRightRefs.current[keyPath]?.current;\n if (l && r && subSectionHeights[keyPath]) {\n const maxH = subSectionHeights[keyPath];\n l.style.minHeight = `${maxH}px`;\n r.style.minHeight = `${maxH}px`;\n }\n });\n }\n }\n\n // SECTION CONNECTORS\n // ── SKIP SECTION LINES IF IN GUIDELINE MODE ──\n if (!isGuidelineMode) {\n const getMappedRightIndexes = (leftSec: any, leftIdx: number) => {\n // Standard/Side-by-Side data is already materialized as explicit\n // mapping rows, so its counterpart is always at the same row index.\n // Looking up by display_index is ambiguous when a target section is\n // intentionally repeated for more than one mapping edge.\n if (!maintainRelativeOrder) {\n return existingSections[leftIdx] ? [leftIdx] : [];\n }\n\n const mapped = (leftSec.refIndexes || [])\n .map((rhsSelfIdx: number) =>\n existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIdx),\n )\n .filter((idx: number) => idx !== -1);\n\n // Backward-compatible fallback for old one-to-one/index-based data\n if (!mapped.length && existingSections[leftIdx]) {\n return [leftIdx];\n }\n\n return Array.from(new Set(mapped));\n };\n\n proposedSections.forEach((leftSec: any, leftIdx: number) => {\n const continuationSourceIdx = leftSec.continuationSourceRowId\n ? proposedSections.findIndex(\n (section: any) =>\n section.comparisonRowId === leftSec.continuationSourceRowId,\n )\n : -1;\n const resolvedLeftIdx =\n continuationSourceIdx >= 0 ? continuationSourceIdx : leftIdx;\n const lWrap = sectionLeftRefs.current[resolvedLeftIdx]?.current;\n if (!lWrap) return;\n\n const rightIndexes = getMappedRightIndexes(leftSec, leftIdx);\n\n rightIndexes.forEach((rhsArrayIdx: any) => {\n const rWrap = sectionRightRefs.current[rhsArrayIdx]?.current;\n if (!rWrap) return;\n\n const leftRect = lWrap.getBoundingClientRect();\n const rightRect = rWrap.getBoundingClientRect();\n\n const x1 = leftRect.right - containerRect.left;\n const x2 = rightRect.left - containerRect.left;\n\n let y1 = leftRect.top + 18 - containerRect.top;\n let y2 = rightRect.top + 18 - containerRect.top;\n\n if (maintainRelativeOrder && isSideBySide && activeSideBySideSection === leftIdx) {\n const leftTop = leftContainerRef.current?.getBoundingClientRect().top ?? 0;\n const rightTop = rightContainerRef.current?.getBoundingClientRect().top ?? 0;\n const leftBottom = leftTop + (leftContainerRef.current?.clientHeight ?? Infinity);\n const rightBottom = rightTop + (rightContainerRef.current?.clientHeight ?? Infinity);\n\n const clamp = (v: number, min: number, max: number) =>\n Math.max(min, Math.min(max, v));\n\n y1 = clamp(leftRect.top + 18, leftTop, leftBottom) - containerRect.top;\n y2 = clamp(rightRect.top + 18, rightTop, rightBottom) - containerRect.top;\n }\n\n const style = getSectionCompareStyle(resolvedLeftIdx);\n\n if (style) {\n newLines.push({\n id: `line-${resolvedLeftIdx}-${rhsArrayIdx}`,\n x1,\n y1,\n x2,\n y2,\n style,\n sectionIdx: resolvedLeftIdx,\n targetRightIdx: rhsArrayIdx,\n isSubSection: false,\n isMappingContinuation: continuationSourceIdx >= 0,\n hasCognitive: !!(\n proposedSections[resolvedLeftIdx]?.cognitiveData ||\n existingSections[rhsArrayIdx]?.cognitiveData ||\n proposedSections[resolvedLeftIdx]?.nodeId &&\n cognitiveMap[proposedSections[resolvedLeftIdx].nodeId as string]\n ),\n });\n }\n });\n });\n }\n\n if (!isGuidelineMode && isSideBySide && typeof activeSideBySideSection === 'string' && activeSideBySideSection.includes(DEVIATION_BADGE_SEPARATOR)) {\n const [nodeId, devKey, leftKeyPath, rightKeyPath] = activeSideBySideSection.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n\n const lBadgeEl = lhsBadgeRefs.current[refId]?.current;\n const rBadgeEl = rhsBadgeRefs.current[refId]?.current;\n\n if (lBadgeEl && rBadgeEl) {\n const lRect = lBadgeEl.getBoundingClientRect();\n const rRect = rBadgeEl.getBoundingClientRect();\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left;\n \n let y1 = lRect.top + lRect.height / 2 - containerRect.top;\n let y2 = rRect.top + rRect.height / 2 - containerRect.top;\n\n if (maintainRelativeOrder) {\n const leftTop = leftContainerRef.current?.getBoundingClientRect().top ?? 0;\n const rightTop = rightContainerRef.current?.getBoundingClientRect().top ?? 0;\n const leftBottom = leftTop + (leftContainerRef.current?.clientHeight ?? Infinity);\n const rightBottom = rightTop + (rightContainerRef.current?.clientHeight ?? Infinity);\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n\n y1 = clamp(lRect.top + lRect.height / 2, leftTop, leftBottom) - containerRect.top;\n y2 = clamp(rRect.top + rRect.height / 2, rightTop, rightBottom) - containerRect.top;\n }\n \n const style =\n getDeviationStyleByKey(nodeId, devKey) ??\n getSubSectionCompareStyle(leftKeyPath);\n if (style) {\n newLines.push({\n id: `line-subsec-${refId}`,\n x1, y1, x2, y2,\n style,\n sectionIdx: Number(leftKeyPath.split('-')[0]),\n isSubSection: true,\n subSectionKeyPath: activeSideBySideSection,\n });\n }\n }\n }\n\n setLines(newLines);\n\n if (leftHeaderRef.current && rightHeaderRef.current) {\n const leftHeaderRect = leftHeaderRef.current.getBoundingClientRect();\n const rightHeaderRect = rightHeaderRef.current.getBoundingClientRect();\n const overallY =\n (leftHeaderRect.top +\n leftHeaderRect.height / 2 -\n containerRect.top +\n rightHeaderRect.top +\n rightHeaderRect.height / 2 -\n containerRect.top) /\n 2;\n setOverallConnector({\n x1: leftHeaderRect.right - containerRect.left,\n x2: rightHeaderRect.left - containerRect.left,\n y: overallY,\n });\n } else {\n setOverallConnector(null);\n }\n\n if (connectedSections.size > 0) {\n const newConnectedLines: Record<string, any>[] = [];\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n\n if (leftContainer && rightContainer) {\n const newCache: CachedBadgePosition[] = [];\n \n const leftTop = leftContainer.getBoundingClientRect().top;\n const rightTop = rightContainer.getBoundingClientRect().top;\n const leftBottom = leftTop + leftContainer.clientHeight;\n const rightBottom = rightTop + rightContainer.clientHeight;\n\n const leftScrollTop = leftContainer.scrollTop;\n const rightScrollTop = rightContainer.scrollTop;\n const cTop = containerRect.top;\n\n const clamp = (v: number, min: number, max: number) =>\n Math.max(min, Math.min(max, v));\n\n connectedSections.forEach((connectedIdx:any) => {\n // ── GUIDELINE MODE LOGIC ──\n if (isGuidelineMode) {\n let lBadge: HTMLElement | null = null;\n let leftIdxNum: number | null = null;\n let style: any = null;\n\n if (typeof connectedIdx === 'string' && connectedIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const [nodeId, devKey, leftKeyPath] = connectedIdx.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n lBadge = lhsBadgeRefs.current[refId]?.current;\n style = getDeviationStyleByKey(nodeId, devKey) ?? getSubSectionCompareStyle(leftKeyPath);\n leftIdxNum = Number(leftKeyPath?.split('-')[0] || 0);\n } else {\n leftIdxNum = Number(connectedIdx);\n lBadge = lhsBadgeRefs.current[leftIdxNum]?.current;\n style = getSectionCompareStyle(leftIdxNum);\n }\n\n if (!lBadge) return;\n\n const targetMarks = getVisibleGuidelineTargets(rightContainer);\n \n targetMarks.forEach((rBadge: any, index) => {\n const lRect = lBadge!.getBoundingClientRect();\n const rRect = rBadge.getBoundingClientRect();\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left - 0;\n \n // ── UNIVERSAL SPINE JUNCTION PUSHED TO X1+75 TO CLEAR LOCK ICON ──\n const centerX = x1 + 75;\n\n const rawLhsY = lRect.top + lRect.height / 2;\n // Target the middle of the highlighted text vertically\n const rawRhsY = rRect.top + rRect.height / 2;\n\n const lhsScrollY = (rawLhsY - leftTop) + leftScrollTop;\n const rhsScrollY = (rawRhsY - rightTop) + rightScrollTop;\n \n const styleId = `conn-guide-${connectedIdx}-${index}`;\n \n // ── BULLETPROOF MATH LABEL GENERATION ──\n let baseLabel = \"\";\n if (typeof connectedIdx === 'string' && connectedIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const parts = connectedIdx.split(DEVIATION_BADGE_SEPARATOR);\n const leftKeyPath = parts[2] || \"\";\n baseLabel = leftKeyPath.split('-').map(n => Number(n) + 1).join('.');\n } else {\n baseLabel = String(Number(connectedIdx) + 1);\n }\n const letter = String.fromCharCode(97 + index); // a, b, c...\n const matchLabel = targetMarks.length === 1 ? null : `${baseLabel}(${letter})`;\n\n newCache.push({\n lhsScrollY, rhsScrollY, x1, x2, containerTop: cTop,\n leftIdx: connectedIdx, rhsArrayIdx: index, \n styleColor: style?.badgeBorder || \"#6366F1\", \n styleBg: style?.badgeBg || \"#FFFFFF\",\n styleText: style?.badgeText || \"#A16207\",\n styleId, centerX,\n });\n\n const clampedLhsY = clamp(rawLhsY, leftTop, leftBottom);\n const clampedRhsY = clamp(rawRhsY, rightTop, rightBottom);\n\n const y1 = clampedLhsY - cTop;\n const y2 = clampedRhsY - cTop;\n\n const lhsVisible = rawLhsY >= leftTop - 4 && rawLhsY <= leftBottom + 4;\n const rhsVisible = rawRhsY >= rightTop - 4 && rawRhsY <= rightBottom + 4;\n\n const pathD = getRoundedStaggeredPath(x1, y1, x2, y2, centerX, lhsVisible, rhsVisible);\n\n newConnectedLines.push({ \n id: styleId, pathD, style, leftIdx: connectedIdx, rhsArrayIdx: index, \n x1, x2, y1, y2, centerX, matchLabel, isGuideline: true \n });\n });\n } else {\n // ── UNIFIED CONTRACT TO CONTRACT LOGIC ──\n if (typeof connectedIdx === 'string' && connectedIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const [nodeId, devKey, leftKeyPath, rightKeyPath] = connectedIdx.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n\n const lBadge = lhsBadgeRefs.current[refId]?.current;\n const rBadge = rhsBadgeRefs.current[refId]?.current;\n if (!lBadge || !rBadge) return;\n\n const lRect = lBadge.getBoundingClientRect();\n const rRect = rBadge.getBoundingClientRect();\n const style = getDeviationStyleByKey(nodeId, devKey) ?? getSubSectionCompareStyle(leftKeyPath);\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left - 0;\n const centerX = x1 + 75; // ── UNIVERSAL SPINE JUNCTION ──\n\n const rawLhsY = lRect.top + lRect.height / 2;\n const rawRhsY = rRect.top + rRect.height / 2;\n\n const lhsScrollY = (rawLhsY - leftTop) + leftScrollTop;\n const rhsScrollY = (rawRhsY - rightTop) + rightScrollTop;\n const styleId = `conn-subsec-${refId}`;\n \n const leftKeyP = leftKeyPath || \"\";\n const baseLabel = leftKeyP.split('-').map(n => Number(n) + 1).join('.');\n const matchLabel = null; // 1-to-1 connection, no badge needed\n\n newCache.push({\n lhsScrollY, rhsScrollY, x1, x2, containerTop: cTop,\n leftIdx: connectedIdx, rhsArrayIdx: connectedIdx,\n styleColor: style?.badgeBorder || \"#6366F1\", styleBg: style?.badgeBg || \"#FFFFFF\", styleText: style?.badgeText || \"#A16207\",\n styleId, centerX, \n });\n\n const clampedLhsY = clamp(rawLhsY, leftTop, leftBottom);\n const clampedRhsY = clamp(rawRhsY, rightTop, rightBottom);\n const y1 = clampedLhsY - cTop;\n const y2 = clampedRhsY - cTop;\n const lhsVisible = rawLhsY >= leftTop - 4 && rawLhsY <= leftBottom + 4;\n const rhsVisible = rawRhsY >= rightTop - 4 && rawRhsY <= rightBottom + 4;\n\n const pathD = getRoundedStaggeredPath(x1, y1, x2, y2, centerX, lhsVisible, rhsVisible);\n\n newConnectedLines.push({ id: styleId, pathD, style, leftIdx: connectedIdx, rhsArrayIdx: connectedIdx, x1, x2, y1, y2, matchLabel });\n } else {\n if (!maintainRelativeOrder) {\n const leftIdx = connectedIdx;\n const rhsArrayIdx = leftIdx as number;\n const lBadge = lhsBadgeRefs.current[leftIdx]?.current;\n const rBadge = rhsBadgeRefs.current[rhsArrayIdx]?.current;\n if (!lBadge || !rBadge) return;\n\n const lRect = lBadge.getBoundingClientRect();\n const rRect = rBadge.getBoundingClientRect();\n const style = getSectionCompareStyle(leftIdx as number);\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left - 0;\n const centerX = x1 + 75; // ── UNIVERSAL SPINE JUNCTION ──\n\n const rawLhsY = lRect.top + lRect.height / 2;\n const rawRhsY = rRect.top + rRect.height / 2;\n const lhsScrollY = (rawLhsY - leftTop) + leftScrollTop;\n const rhsScrollY = (rawRhsY - rightTop) + rightScrollTop;\n const styleId = `conn-${leftIdx}-${rhsArrayIdx}`;\n \n const baseLabel = String(Number(connectedIdx) + 1);\n const matchLabel = null; // 1-to-1 connection, no badge needed\n\n newCache.push({\n lhsScrollY, rhsScrollY, x1, x2, containerTop: cTop,\n leftIdx, rhsArrayIdx, \n styleColor: style?.badgeBorder || \"#6366F1\", styleBg: style?.badgeBg || \"#FFFFFF\", styleText: style?.badgeText || \"#A16207\",\n styleId, centerX,\n });\n\n const clampedLhsY = clamp(rawLhsY, leftTop, leftBottom);\n const clampedRhsY = clamp(rawRhsY, rightTop, rightBottom);\n const y1 = clampedLhsY - cTop;\n const y2 = clampedRhsY - cTop;\n const lhsVisible = rawLhsY >= leftTop - 4 && rawLhsY <= leftBottom + 4;\n const rhsVisible = rawRhsY >= rightTop - 4 && rawRhsY <= rightBottom + 4;\n\n const pathD = getRoundedStaggeredPath(x1, y1, x2, y2, centerX, lhsVisible, rhsVisible);\n\n newConnectedLines.push({ id: styleId, pathD, style, leftIdx, rhsArrayIdx, x1, x2, y1, y2, matchLabel });\n } else {\n const leftIdx = connectedIdx as number;\n const leftSec = proposedSections[leftIdx] as any;\n if (!leftSec?.refIndexes?.length) return;\n\n leftSec.refIndexes.forEach((rhsSelfIdx: number, index: number) => {\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIdx);\n if (rhsArrayIdx === -1) return;\n\n const lBadge = lhsBadgeRefs.current[leftIdx]?.current;\n const rBadge = rhsBadgeRefs.current[rhsArrayIdx]?.current;\n if (!lBadge || !rBadge) return;\n\n const lRect = lBadge.getBoundingClientRect();\n const rRect = rBadge.getBoundingClientRect();\n const style = getSectionCompareStyle(leftIdx);\n\n const x1 = lRect.right - containerRect.left;\n const x2 = rRect.left - containerRect.left - 0;\n \n const centerX = x1 + 75; // ── UNIVERSAL SPINE JUNCTION ──\n\n const rawLhsY = lRect.top + lRect.height / 2;\n const rawRhsY = rRect.top + rRect.height / 2;\n const lhsScrollY = (rawLhsY - leftTop) + leftScrollTop;\n const rhsScrollY = (rawRhsY - rightTop) + rightScrollTop;\n const styleId = `conn-${leftIdx}-${rhsArrayIdx}`;\n \n const baseLabel = String(Number(connectedIdx) + 1);\n const letter = String.fromCharCode(97 + index); \n const matchLabel = leftSec.refIndexes.length === 1 ? null : `${baseLabel}(${letter})`;\n\n newCache.push({\n lhsScrollY, rhsScrollY, x1, x2, containerTop: cTop,\n leftIdx, rhsArrayIdx,\n styleColor: style?.badgeBorder || \"#6366F1\", styleBg: style?.badgeBg || \"#FFFFFF\", styleText: style?.badgeText || \"#A16207\",\n styleId, centerX,\n });\n\n const clampedLhsY = clamp(rawLhsY, leftTop, leftBottom);\n const clampedRhsY = clamp(rawRhsY, rightTop, rightBottom);\n const y1 = clampedLhsY - cTop;\n const y2 = clampedRhsY - cTop;\n const lhsVisible = rawLhsY >= leftTop - 4 && rawLhsY <= leftBottom + 4;\n const rhsVisible = rawRhsY >= rightTop - 4 && rawRhsY <= rightBottom + 4;\n\n const pathD = getRoundedStaggeredPath(x1, y1, x2, y2, centerX, lhsVisible, rhsVisible);\n\n newConnectedLines.push({\n id: styleId, pathD, style, leftIdx, rhsArrayIdx, x1, x2, y1, y2, matchLabel,\n });\n });\n }\n }\n }\n });\n cachedConnectedPositions.current = newCache;\n }\n setConnectedLines(newConnectedLines);\n\n setTimeout(() => updateConnectedLinesOnScroll(), 10);\n } else {\n setConnectedLines([]);\n cachedConnectedPositions.current = [];\n setTimeout(() => updateConnectedLinesOnScroll(), 10);\n }\n } catch (e) {\n console.error(\"Line render safe fail: \", e);\n } finally {\n isCalculatingLines.current = false;\n }\n }, [\n visibleFields,\n proposedSections,\n existingSections,\n cognitiveMap,\n resolvedComparisonConfig,\n getFieldData,\n getSectionCompareStyle,\n getDeviationStyleByKey,\n maintainRelativeOrder,\n isSideBySide, \n activeSideBySideSection, \n connectedSections,\n expandedSections,\n expandedSubSections,\n isGuidelineMode, \n ]);\n\n const updateConnectedLinesOnScroll = useCallback(() => {\n const cache = cachedConnectedPositions.current;\n \n if (!cache.length) {\n pathRefs.current[\"guideline-up-stroke\"]?.setAttribute(\"visibility\", \"hidden\");\n pathRefs.current[\"guideline-up-badge\"]?.setAttribute(\"visibility\", \"hidden\");\n pathRefs.current[\"guideline-down-stroke\"]?.setAttribute(\"visibility\", \"hidden\");\n pathRefs.current[\"guideline-down-badge\"]?.setAttribute(\"visibility\", \"hidden\");\n return;\n }\n\n if (isAnimatingRef.current) return;\n \n const leftScroll = leftContainerRef.current?.scrollTop ?? 0;\n const rightScroll = rightContainerRef.current?.scrollTop ?? 0;\n \n const leftHeight = leftContainerRef.current?.clientHeight ?? Infinity;\n const rightHeight = rightContainerRef.current?.clientHeight ?? Infinity;\n \n const leftTop = leftContainerRef.current?.getBoundingClientRect().top ?? 0;\n const rightTop = rightContainerRef.current?.getBoundingClientRect().top ?? 0;\n \n const leftBottom = leftTop + leftHeight;\n const rightBottom = rightTop + rightHeight;\n \n const containerRect = containerRef.current?.getBoundingClientRect();\n const containerTop = containerRect?.top ?? 0;\n const containerHeight = containerRect?.height ?? Infinity;\n \n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n \n let topCount = 0;\n let bottomCount = 0;\n let sharedX1 = 0, sharedY1 = 0;\n let sharedColor = \"#6366F1\", sharedBg = \"#FFFFFF\", sharedTextCol = \"#A16207\";\n let hasActiveConnections = false;\n let universalSpineX = 0; \n\n cache.forEach((entry: any) => {\n const lhsViewportY = (entry.lhsScrollY - leftScroll) + leftTop;\n const rhsViewportY = (entry.rhsScrollY - rightScroll) + rightTop;\n \n const strokeEl = pathRefs.current[entry.styleId + \"-stroke\"];\n const bgEl = pathRefs.current[entry.styleId + \"-bg\"];\n const btnEl = pathRefs.current[entry.styleId + \"-btn\"];\n const numberBadgeEl = pathRefs.current[entry.styleId + \"-number\"];\n \n if (!strokeEl && !bgEl) return;\n \n const visibleLhsY = clamp(lhsViewportY, leftTop, leftBottom);\n const visibleRhsY = clamp(rhsViewportY, rightTop, rightBottom);\n \n const y1 = visibleLhsY - containerTop;\n const y2 = visibleRhsY - containerTop;\n \n const lhsVisible = lhsViewportY >= leftTop - 4 && lhsViewportY <= leftBottom + 4;\n const rhsVisible = rhsViewportY >= rightTop - 4 && rhsViewportY <= rightBottom + 4;\n \n let showLine = true;\n hasActiveConnections = true;\n\n // Enforce absolute strict universal spine\n const centerX = entry.centerX || (entry.x1 + 75);\n\n if (sharedX1 === 0) {\n sharedX1 = entry.x1;\n sharedY1 = y1;\n universalSpineX = centerX;\n sharedColor = entry.styleColor;\n sharedBg = entry.styleBg || \"#FFFFFF\";\n sharedTextCol = entry.styleText || \"#A16207\";\n }\n\n if (rhsViewportY < rightTop - 4) {\n topCount++; showLine = false; \n } else if (rhsViewportY > rightBottom + 4) {\n bottomCount++; showLine = false; \n } \n \n const pathD = getRoundedStaggeredPath(entry.x1, y1, entry.x2, y2, universalSpineX, lhsVisible, rhsVisible);\n \n if (strokeEl) {\n if (showLine && pathD) {\n strokeEl.setAttribute(\"visibility\", \"visible\");\n strokeEl.setAttribute(\"d\", pathD);\n } else { strokeEl.setAttribute(\"visibility\", \"hidden\"); }\n }\n \n if (bgEl) {\n if (showLine && pathD) {\n bgEl.setAttribute(\"visibility\", \"visible\");\n bgEl.setAttribute(\"d\", pathD);\n } else { bgEl.setAttribute(\"visibility\", \"hidden\"); }\n }\n\n if (btnEl) {\n if (!lhsVisible || !showLine) {\n btnEl.setAttribute(\"visibility\", \"hidden\");\n } else {\n btnEl.setAttribute(\"visibility\", \"visible\");\n btnEl.setAttribute(\"y\", String(y1 - 12)); \n }\n }\n\n if (numberBadgeEl) {\n if (!lhsVisible || !showLine) {\n numberBadgeEl.setAttribute(\"visibility\", \"hidden\");\n } else {\n numberBadgeEl.setAttribute(\"visibility\", \"visible\");\n numberBadgeEl.setAttribute(\"transform\", `translate(${entry.x2 - 42}, ${y2})`);\n }\n }\n });\n\n // ── UNIVERSAL OFF-SCREEN ARROWS (ALWAYS ORIGINATE EXACTLY AT THE SPINE: X1 + 75) ──\n if (hasActiveConnections && universalSpineX > 0) {\n const upStroke = pathRefs.current[\"guideline-up-stroke\"];\n const upBadge = pathRefs.current[\"guideline-up-badge\"];\n const upArrow = pathRefs.current[\"guideline-up-arrow\"];\n const upText = pathRefs.current[\"guideline-up-text\"];\n const upRect = pathRefs.current[\"guideline-up-badge-rect\"];\n\n if (topCount > 0) {\n const upY = Math.max(15, rightTop - containerTop + 15); \n const r = Math.min(15, Math.abs(universalSpineX - sharedX1), Math.max(0, sharedY1 - upY));\n const pathD = `M ${sharedX1},${sharedY1} L ${universalSpineX - r},${sharedY1} Q ${universalSpineX},${sharedY1} ${universalSpineX},${sharedY1 - r} L ${universalSpineX},${upY}`;\n\n upStroke?.setAttribute(\"visibility\", \"visible\");\n upStroke?.setAttribute(\"d\", pathD);\n upStroke?.setAttribute(\"stroke\", sharedColor);\n\n upBadge?.setAttribute(\"visibility\", \"visible\");\n upBadge?.setAttribute(\"transform\", `translate(${universalSpineX}, ${upY})`);\n \n if (upArrow) { upArrow.setAttribute(\"fill\", sharedColor); }\n if (upText) { upText.textContent = `+${topCount}`; upText.setAttribute(\"fill\", sharedTextCol); }\n if (upRect) { upRect.setAttribute(\"stroke\", sharedColor); }\n } else {\n upStroke?.setAttribute(\"visibility\", \"hidden\");\n upBadge?.setAttribute(\"visibility\", \"hidden\");\n }\n\n const downStroke = pathRefs.current[\"guideline-down-stroke\"];\n const downBadge = pathRefs.current[\"guideline-down-badge\"];\n const downArrow = pathRefs.current[\"guideline-down-arrow\"];\n const downText = pathRefs.current[\"guideline-down-text\"];\n const downRect = pathRefs.current[\"guideline-down-badge-rect\"];\n\n if (bottomCount > 0) {\n const downY = Math.min(containerHeight - 15, rightBottom - containerTop - 15);\n const r = Math.min(15, Math.abs(universalSpineX - sharedX1), Math.max(0, downY - sharedY1));\n const pathD = `M ${sharedX1},${sharedY1} L ${universalSpineX - r},${sharedY1} Q ${universalSpineX},${sharedY1} ${universalSpineX},${sharedY1 + r} L ${universalSpineX},${downY}`;\n\n downStroke?.setAttribute(\"visibility\", \"visible\");\n downStroke?.setAttribute(\"d\", pathD);\n downStroke?.setAttribute(\"stroke\", sharedColor);\n\n downBadge?.setAttribute(\"visibility\", \"visible\");\n downBadge?.setAttribute(\"transform\", `translate(${universalSpineX}, ${downY})`);\n \n if (downArrow) { downArrow.setAttribute(\"fill\", sharedColor); }\n if (downText) { downText.textContent = `+${bottomCount}`; downText.setAttribute(\"fill\", sharedTextCol); }\n if (downRect) { downRect.setAttribute(\"stroke\", sharedColor); }\n } else {\n downStroke?.setAttribute(\"visibility\", \"hidden\");\n downBadge?.setAttribute(\"visibility\", \"hidden\");\n }\n }\n }, []);\n\n const calculateLinesDebounced = useCallback(() => {\n if (cachedConnectedPositions.current.length > 0 && !isAnimatingRef.current) {\n return;\n }\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n calculateLinesRef.current();\n timerRef.current = null;\n }, 50);\n }, []); \n \n \n const handleColumnScroll = useCallback((e: any) => {\n if (pendingScrollTargetRef.current !== null && pendingScrollCallbackRef.current) {\n if (Math.abs(e.currentTarget.scrollTop - pendingScrollTargetRef.current) <= 2) {\n const callback = pendingScrollCallbackRef.current;\n pendingScrollTargetRef.current = null;\n pendingScrollCallbackRef.current = null;\n callback();\n }\n }\n \n if (scrollSyncing.current) return;\n if (scrollLock.current) return;\n\n if (\n maintainRelativeOrder &&\n scrollSyncLocked &&\n (isSideBySideRef.current || connectedSections.size > 0)\n ) {\n const source = e.currentTarget as HTMLElement;\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n const target =\n source === leftContainer\n ? rightContainer\n : source === rightContainer\n ? leftContainer\n : null;\n\n if (source && target) {\n const resolveActiveAnchors = () => {\n const activeLeftIdx = activeSideBySideSectionRef.current;\n const activeRightIdx = activeSideBySideRightSectionRef.current;\n\n if (activeLeftIdx === null) return { leftAnchor: null, rightAnchor: null };\n\n if (\n typeof activeLeftIdx === \"string\" &&\n activeLeftIdx.includes(DEVIATION_BADGE_SEPARATOR)\n ) {\n const parts = activeLeftIdx.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n\n return {\n leftAnchor:\n lhsBadgeRefs.current[refId]?.current ||\n subSectionLeftRefs.current[parts[2]]?.current ||\n sectionLeftRefs.current[Number(parts[2])]?.current ||\n null,\n rightAnchor:\n rhsBadgeRefs.current[refId]?.current ||\n subSectionRightRefs.current[parts[3]]?.current ||\n sectionRightRefs.current[Number(parts[3])]?.current ||\n null,\n };\n }\n\n const leftIdx = Number(activeLeftIdx);\n const rightIdx = activeRightIdx !== null ? Number(activeRightIdx) : leftIdx;\n\n return {\n leftAnchor:\n lhsBadgeRefs.current[leftIdx]?.current ||\n sectionRowRefs.current[leftIdx]?.current ||\n sectionLeftRefs.current[leftIdx]?.current ||\n null,\n rightAnchor:\n rhsBadgeRefs.current[rightIdx]?.current ||\n sectionRightRefs.current[rightIdx]?.current ||\n null,\n };\n };\n\n const { leftAnchor, rightAnchor } = resolveActiveAnchors();\n const sourceAnchor = source === leftContainer ? leftAnchor : rightAnchor;\n const targetAnchor = source === leftContainer ? rightAnchor : leftAnchor;\n\n let nextTargetTop: number | null = null;\n\n if (sourceAnchor && targetAnchor) {\n const sourceAnchorRect = sourceAnchor.getBoundingClientRect();\n const targetAnchorRect = targetAnchor.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n\n const sourceAnchorCenterY =\n sourceAnchorRect.top + sourceAnchorRect.height / 2;\n const targetAnchorAbsoluteCenterY =\n targetAnchorRect.top -\n targetRect.top +\n target.scrollTop +\n targetAnchorRect.height / 2;\n\n nextTargetTop =\n targetAnchorAbsoluteCenterY - (sourceAnchorCenterY - targetRect.top);\n } else {\n const sourceMaxScroll = Math.max(0, source.scrollHeight - source.clientHeight);\n const targetMaxScroll = Math.max(0, target.scrollHeight - target.clientHeight);\n nextTargetTop = sourceMaxScroll > 0\n ? (source.scrollTop / sourceMaxScroll) * targetMaxScroll\n : source.scrollTop;\n }\n\n const targetMaxScroll = Math.max(0, target.scrollHeight - target.clientHeight);\n nextTargetTop = Math.max(0, Math.min(nextTargetTop, targetMaxScroll));\n\n if (Math.abs(target.scrollTop - nextTargetTop) > 1) {\n scrollSyncing.current = true;\n target.scrollTop = nextTargetTop;\n requestAnimationFrame(() => {\n scrollSyncing.current = false;\n });\n }\n }\n }\n \n if (!maintainRelativeOrder) {\n calculateLinesDebounced();\n }\n \n if (!scrollTicking.current) {\n scrollTicking.current = true;\n \n requestAnimationFrame(() => {\n if (isSideBySideRef.current) {\n const leftContainer = leftContainerRef.current;\n const rightContainer = rightContainerRef.current;\n \n if (leftContainer && rightContainer && sideBySideLineRef.current) {\n if (!sideBySideCacheRef.current) {\n const activeLeftIdx = activeSideBySideSectionRef.current;\n let lBadge;\n \n if (typeof activeLeftIdx === 'string' && activeLeftIdx.includes(DEVIATION_BADGE_SEPARATOR)) {\n const parts = activeLeftIdx.split(DEVIATION_BADGE_SEPARATOR);\n const refId = `${parts[0]}${DEVIATION_BADGE_SEPARATOR}${parts[1]}`;\n lBadge = lhsBadgeRefs.current[refId]?.current;\n } else {\n lBadge = lhsBadgeRefs.current[activeLeftIdx as number]?.current;\n }\n \n if (lBadge) {\n const lRect = lBadge.getBoundingClientRect();\n sideBySideCacheRef.current = {\n badgeScreenY: lRect.top + lRect.height / 2, \n initialScrollTop: leftContainer.scrollTop, \n leftTop: leftContainer.getBoundingClientRect().top,\n leftBottom: leftContainer.getBoundingClientRect().top + leftContainer.clientHeight,\n cTop: containerRef.current?.getBoundingClientRect().top ?? 0\n };\n }\n }\n \n if (sideBySideCacheRef.current) {\n const cache = sideBySideCacheRef.current;\n const scrollDelta = leftContainer.scrollTop - cache.initialScrollTop;\n const rawLhsY = cache.badgeScreenY - scrollDelta;\n const clamp = (v: number, min: number, max: number) => Math.max(min, Math.min(max, v));\n const clampedLhsY = clamp(rawLhsY, cache.leftTop, cache.leftBottom);\n const horizontalY = (clampedLhsY - cache.cTop).toString();\n const isVisible = rawLhsY >= cache.leftTop - 4 && rawLhsY <= cache.leftBottom + 4;\n \n sideBySideLineRef.current.setAttribute(\"y1\", horizontalY);\n sideBySideLineRef.current.setAttribute(\"y2\", horizontalY); \n sideBySideLineRef.current.setAttribute(\"visibility\", isVisible ? \"visible\" : \"hidden\");\n }\n }\n }\n \n updateConnectedLinesOnScroll(); \n scrollTicking.current = false;\n });\n }\n }, [\n updateConnectedLinesOnScroll,\n maintainRelativeOrder,\n scrollSyncLocked,\n connectedSections,\n calculateLinesDebounced,\n ]);\n\n\n useEffect(() => {\n calculateLinesRef.current = calculateLines;\n }, [calculateLines]);\n\n useEffect(() => {\n const timer = setTimeout(calculateLinesDebounced, 250);\n const onWindowResize = () => handleResizeRef.current();\n window.addEventListener(\"resize\", onWindowResize);\n \n return () => {\n clearTimeout(timer);\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n if (resizeTimerRef.current !== null) clearTimeout(resizeTimerRef.current);\n window.removeEventListener(\"resize\", onWindowResize);\n };\n }, [\n activeProposed,\n existingRule,\n analysisData,\n visibleFields,\n expandedSections,\n expandedSubSections,\n proposedSections,\n existingSections,\n resolvedComparisonConfig,\n calculateLinesDebounced,\n isSideBySide,\n activeSideBySideSection,\n isArrowVisible,\n connectedSections,\n ]);\n\n\n return {\n lines, setLines,\n overallConnector, setOverallConnector,\n connectedLines, setConnectedLines,\n svgDimensions,\n cachedConnectedPositions,\n calculateLines,\n calculateLinesRef,\n calculateLinesDebounced,\n handleColumnScroll,\n}\n\n}"],"names":["containerRef","leftContainerRef","rightContainerRef","svgContainerRef","pathRefs","leftHeaderRef","rightHeaderRef","proposedSections","existingSections","visibleFields","leftRefs","rightRefs","sectionLeftRefs","sectionRightRefs","subSectionLeftRefs","subSectionRightRefs","lhsBadgeRefs","rhsBadgeRefs","sectionRowRefs","expandedSections","expandedSubSections","connectedSections","isSideBySide","activeSideBySideSection","maintainRelativeOrder","isGuidelineMode","cognitiveMap","getSectionCompareStyle","getSubSectionCompareStyle","getDeviationStyleByKey","isArrowVisible","isAnimatingRef","isSideBySideRef","sideBySideCacheRef","sideBySideLineRef","activeSideBySideSectionRef","activeSideBySideRightSectionRef","connectedLines","providedConnectedLines","setConnectedLines","providedSetConnectedLines","cachedConnectedPositions","providedCachedConnectedPositions","calculateLinesRef","resizeTimerRef","scrollLock","scrollSyncLocked","handleResizeRef","activeProposed","existingRule","analysisData","pendingScrollTargetRef","pendingScrollCallbackRef","resolvedComparisonConfig","getFieldData","lines","setLines","useState","overallConnector","setOverallConnector","internalConnectedLines","internalSetConnectedLines","svgDimensions","setSvgDimensions","width","height","isCalculatingLines","useRef","scrollTicking","scrollSyncing","timerRef","internalCachedConnectedPositions","getRoundedStaggeredPath","x1","y1","x2","y2","cX","visL","visR","Math","abs","r1","min","r2","dy1","dy2","dx2","calculateLines","useCallback","current","isSubSectionVisible","keyPath","pathParts","split","rootIdx","ancestorPath","i","length","containerRect","getBoundingClientRect","newLines","forEach","key","l","r","style","minHeight","idx","max","Object","keys","fieldHeights","lRect","rRect","syncHeights","left","right","subSectionHeights","leftIdx","leftSec","refIndexes","rhsSelfIdx","rhsArrayIdx","findIndex","s","selfIndex","maxH","DEVIATION_BADGE_SEPARATOR","offsetParent","entries","Number","getMappedRightIndexes","mapped","map","filter","Array","from","Set","continuationSourceIdx","continuationSourceRowId","section","comparisonRowId","resolvedLeftIdx","lWrap","rWrap","leftRect","rightRect","top","leftTop","rightTop","leftBottom","clientHeight","Infinity","rightBottom","clamp","v","push","id","sectionIdx","targetRightIdx","isSubSection","isMappingContinuation","hasCognitive","cognitiveData","nodeId","includes","devKey","leftKeyPath","rightKeyPath","refId","lBadgeEl","rBadgeEl","subSectionKeyPath","leftHeaderRect","rightHeaderRect","overallY","y","size","newConnectedLines","leftContainer","rightContainer","newCache","leftScrollTop","scrollTop","rightScrollTop","cTop","connectedIdx","lBadge","leftIdxNum","targetMarks","getVisibleGuidelineTargets","rBadge","index","centerX","rawLhsY","rawRhsY","lhsScrollY","rhsScrollY","styleId","baseLabel","n","join","String","letter","fromCharCode","matchLabel","containerTop","styleColor","badgeBorder","styleBg","badgeBg","styleText","badgeText","clampedLhsY","clampedRhsY","pathD","isGuideline","setTimeout","updateConnectedLinesOnScroll","e","console","error","cache","setAttribute","leftScroll","rightScroll","leftHeight","rightHeight","containerHeight","topCount","bottomCount","sharedX1","sharedY1","sharedColor","sharedTextCol","hasActiveConnections","universalSpineX","entry","lhsViewportY","rhsViewportY","strokeEl","bgEl","btnEl","numberBadgeEl","visibleLhsY","visibleRhsY","lhsVisible","rhsVisible","showLine","upStroke","upBadge","upArrow","upText","upRect","upY","textContent","downStroke","downBadge","downArrow","downText","downRect","downY","calculateLinesDebounced","clearTimeout","handleColumnScroll","currentTarget","callback","source","target","resolveActiveAnchors","activeLeftIdx","activeRightIdx","leftAnchor","rightAnchor","parts","rightIdx","sourceAnchor","targetAnchor","nextTargetTop","sourceAnchorRect","targetAnchorRect","targetRect","sourceAnchorCenterY","sourceMaxScroll","scrollHeight","targetMaxScroll","requestAnimationFrame","badgeScreenY","initialScrollTop","scrollDelta","horizontalY","toString","isVisible","useEffect","timer","onWindowResize","window","addEventListener","removeEventListener"],"mappings":"sNAMkC,EAC9BA,eACAC,mBACAC,oBACAC,kBACAC,WACAC,gBAAeC,iBACfC,mBAAkBC,mBAClBC,gBACAC,WAAUC,YACVC,kBAAiBC,mBACjBC,qBAAoBC,sBACpBC,eAAcC,eACdC,iBACAC,mBAAkBC,sBAClBC,oBACAC,eAAcC,0BACdC,wBACAC,kBACAC,eACAC,yBAAwBC,4BAA2BC,yBACnDC,iBAEAC,iBACAC,kBACAC,qBACAC,oBACAC,6BACAC,kCACAC,eAAgBC,EAChBC,kBAAmBC,EACnBC,yBAA0BC,EAC1BC,oBACAC,iBACAC,aACAC,mBAEAC,kBACAC,iBAAgBC,eAAcC,eAC9BC,yBAAwBC,2BAExBC,2BACAC,oBAGA,MAAOC,GAAOC,IAAYC,EAAAA,SAAgC,KACnDC,GAAkBC,IAAuBF,WAAwD,OACjGG,GAAwBC,IAA6BJ,EAAAA,SAAgC,IACtFpB,GAAiBC,GAA0BsB,GAC3CrB,GAAoBC,GAA6BqB,IAChDC,GAAeC,IAAoBN,EAAAA,SAA4C,CAAEO,MAAO,EAAGC,OAAQ,IAEpGC,GAAqBC,UAAO,GAC5BC,GAAgBD,UAAO,GACvBE,GAAgBF,UAAO,GACvBG,GAAWH,SAA6C,MACxDI,GAAmCJ,SAA8B,IACjE1B,GACJC,GAAoC6B,GAMhCC,GAA0B,CAACC,EAAYC,EAAYC,EAAYC,EAAYC,EAAYC,EAAeC,KAC1G,GAAIC,KAAKC,IAAIL,EAAKF,IAAO,EACjB,OAAAI,GAAQC,EAAa,KAAKN,KAAMC,OAAQC,KAAMC,IAC9CE,IAASC,EAAa,KAAKN,KAAMC,OAAQG,KAAMH,KAC9CI,GAAQC,EAAa,KAAKF,KAAMH,OAAQC,KAAMC,IAC5C,KAAKC,KAAMH,OAAQG,KAAMD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BAC9C9F,EAAU4B,EAAMiE,aAAeE,EAG/BC,GAFQ,EAACvI,EAAWzE,EAAa0B,IAAgB7B,KAAK6B,IAAI1B,EAAKH,KAAKG,IAAI0B,EAAK+C,IAC/DD,CAAMwC,EAAS4B,EAAM1E,QAAS0E,EAAMxE,YACrBwE,EAAMrC,MAAM0G,WACzCC,EAAYlG,GAAW4B,EAAM1E,QAAU,GAAK8C,GAAW4B,EAAMxE,WAAa,EAE9DrH,EAAAwD,QAAQsI,aAAa,KAAMmE,GAC3BjQ,EAAAwD,QAAQsI,aAAa,KAAMmE,GAC7CjQ,EAAkBwD,QAAQsI,aAAa,aAAcqE,EAAY,UAAY,SAC/E,CACF,CACF,CAE6B1E,KAC7BvJ,GAAcsB,SAAU,IA7JJ,GAgKvB,CACDiI,GACAnM,EACAsB,EACAzB,EACAkP,KAqCK,OAjCP+B,EAAAA,UAAU,KACR3P,EAAkB+C,QAAUF,IAC3B,CAACA,KAEJ8M,EAAAA,UAAU,KACA,MAAAC,EAAQ7E,WAAW6C,GAAyB,KAC5CiC,EAAiB,IAAMzP,EAAgB2C,UAG7C,OAFO+M,OAAAC,iBAAiB,SAAUF,GAE3B,KACLhC,aAAa+B,GACY,OAArBjO,GAASoB,SAAkB8K,aAAalM,GAASoB,SACtB,OAA3B9C,EAAe8C,SAAkB8K,aAAa5N,EAAe8C,SAC1D+M,OAAAE,oBAAoB,SAAUH,KAEtC,CACDxP,EACAC,EACAC,EACAzC,EACAU,EACAC,EACAb,EACAC,EACA6C,EACAkN,GACAjP,EACAC,EACAO,EACAT,IAIG,CACXkC,SAAOC,YACPE,oBAAkBC,uBAClBtB,kBAAgBE,qBAChBuB,iBACArB,4BACA+C,kBACA7C,oBACA4N,2BACAE"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../onDemandCitations/cacheKey.js"),r=require("../onDemandCitations/payload.js"),a=require("../onDemandCitations/response.js");const n=6e5,s=(e,t=6e5)=>Date.now()-e.updatedAt>t,o=e=>{const t={"content-type":"application/json",...e.request.headers||{}},r=Object.keys(t).some(e=>"authorization"===e.toLowerCase());return e.request.authToken&&!r&&(t.Authorization=`Bearer ${e.request.authToken}`),t};exports.useOnDemandCitationCache=c=>{const i=e.useRef(new Map),[u,l]=e.useState(0);e.useEffect(()=>()=>{i.current.forEach(e=>e.controller?.abort())},[]);const d=e.useCallback(()=>{l(e=>e+1)},[]),h=e.useCallback(e=>t.buildOnDemandCitationCacheKey(e),[]),p=e.useCallback(e=>{const t="string"==typeof e?e:h(e);return i.current.get(t)},[h,u]),C=e.useCallback((e,t)=>{i.current.set(e,t),d()},[d]),f=e.useCallback(async e=>{if(!c?.enabled||!c.request.url)return null;const t=h(e),u=c.cacheTtlMs??n,l=i.current.get(t);if("success"===l?.status&&!s(l,u))return l.data;if("loading"===l?.status&&l.promise)return l.promise;if("error"===l?.status&&!1===c.retryFailed&&!s(l,u))return null;const p=new AbortController,f=fetch(c.request.url,{method:c.request.method||"POST",headers:o(c),credentials:c.request.credentials,body:JSON.stringify(r.buildOnDemandCitationPayload(c,e)),signal:p.signal}).then(async t=>{const r=await(async e=>{if((e.headers.get("content-type")||"").includes("application/json"))return e.json();const t=await e.text();try{return JSON.parse(t)}catch{return t}})(t);if(!t.ok)throw new Error("string"==typeof r?r:r?.error?.errorMessage||r?.message||`Failed to fetch on-demand citation (${t.status})`);return c.parseResponse?.(r,e)??a.normalizeOnDemandCitationResponse(r,e)}).then(e=>(i.current.set(t,{status:"success",data:e,updatedAt:Date.now()}),d(),e)).catch(e=>{const r=e instanceof DOMException&&"AbortError"===e.name;if(i.current.set(t,{status:"error",error:e,updatedAt:Date.now()}),d(),r)return null;throw e});return C(t,{status:"loading",promise:f,controller:p,updatedAt:Date.now()}),f},[c,h,d,C]),y=e.useCallback(async e=>{c?.enabled&&0!==e.length&&await(async(e,t,r)=>{const a=[...e],n=Array.from({length:Math.max(1,Math.min(t,a.length))},async()=>{for(;a.length>0;){const e=a.shift();if(!e)return;try{await r(e)}catch{}}});await Promise.all(n)})(e,c.maxConcurrentRequests||3,f)},[c,f]),m=e.useCallback(e=>{e.forEach(e=>{const t=h(e),r=i.current.get(t);"loading"===r?.status&&r.controller?.abort()})},[h]);return{cacheVersion:u,getCacheKey:h,getCacheEntry:p,fetchCitationContext:f,prefetchCitationContexts:y,abortCitationContexts:m}};
2
+ //# sourceMappingURL=useOnDemandCitationCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnDemandCitationCache.js","sources":["../../../../../src/features/CognitiveCompare/hooks/useOnDemandCitationCache.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n CognitiveCompareOnDemandCitationConfig,\n OnDemandCitationCacheEntry,\n OnDemandCitationContext,\n} from \"../CognitiveCompareTypes\";\nimport {\n buildOnDemandCitationCacheKey,\n buildOnDemandCitationPayload,\n normalizeOnDemandCitationResponse,\n} from \"../onDemandCitations\";\n\nconst DEFAULT_CACHE_TTL_MS = 10 * 60 * 1000;\nconst DEFAULT_MAX_CONCURRENT_REQUESTS = 3;\n\nconst isExpired = (\n entry: OnDemandCitationCacheEntry,\n ttlMs = DEFAULT_CACHE_TTL_MS,\n) => Date.now() - entry.updatedAt > ttlMs;\n\nconst withConcurrencyLimit = async <T,>(\n items: T[],\n limit: number,\n worker: (item: T) => Promise<unknown>,\n) => {\n const queue = [...items];\n const workers = Array.from(\n { length: Math.max(1, Math.min(limit, queue.length)) },\n async () => {\n while (queue.length > 0) {\n const item = queue.shift();\n if (!item) return;\n try {\n await worker(item);\n } catch {\n // Individual request errors are written to cache by the worker.\n }\n }\n },\n );\n\n await Promise.all(workers);\n};\n\nconst getFetchHeaders = (\n config: CognitiveCompareOnDemandCitationConfig,\n) => {\n const headers: Record<string, string> = {\n \"content-type\": \"application/json\",\n ...(config.request.headers || {}),\n };\n const hasAuthorizationHeader = Object.keys(headers).some(\n (key) => key.toLowerCase() === \"authorization\",\n );\n\n if (config.request.authToken && !hasAuthorizationHeader) {\n headers.Authorization = `Bearer ${config.request.authToken}`;\n }\n\n return headers;\n};\n\nconst readResponseBody = async (response: Response) => {\n const contentType = response.headers.get(\"content-type\") || \"\";\n if (contentType.includes(\"application/json\")) {\n return response.json();\n }\n\n const text = await response.text();\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n};\n\nexport const useOnDemandCitationCache = (\n config?: CognitiveCompareOnDemandCitationConfig,\n) => {\n const cacheRef = useRef<Map<string, OnDemandCitationCacheEntry>>(new Map());\n const [cacheVersion, setCacheVersion] = useState(0);\n\n useEffect(() => {\n return () => {\n cacheRef.current.forEach((entry) => entry.controller?.abort());\n };\n }, []);\n\n const notifyCacheUpdated = useCallback(() => {\n setCacheVersion((version) => version + 1);\n }, []);\n\n const getCacheKey = useCallback(\n (context: OnDemandCitationContext) => buildOnDemandCitationCacheKey(context),\n [],\n );\n\n const getCacheEntry = useCallback(\n (contextOrKey: OnDemandCitationContext | string) => {\n const key =\n typeof contextOrKey === \"string\"\n ? contextOrKey\n : getCacheKey(contextOrKey);\n return cacheRef.current.get(key);\n },\n [getCacheKey, cacheVersion],\n );\n\n const setCacheEntry = useCallback(\n (key: string, entry: OnDemandCitationCacheEntry) => {\n cacheRef.current.set(key, entry);\n notifyCacheUpdated();\n },\n [notifyCacheUpdated],\n );\n\n const fetchCitationContext = useCallback(\n async (context: OnDemandCitationContext) => {\n if (!config?.enabled || !config.request.url) {\n return null;\n }\n\n const key = getCacheKey(context);\n const ttlMs = config.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;\n const existingEntry = cacheRef.current.get(key);\n\n if (\n existingEntry?.status === \"success\" &&\n !isExpired(existingEntry, ttlMs)\n ) {\n return existingEntry.data;\n }\n\n if (existingEntry?.status === \"loading\" && existingEntry.promise) {\n return existingEntry.promise;\n }\n\n if (\n existingEntry?.status === \"error\" &&\n config.retryFailed === false &&\n !isExpired(existingEntry, ttlMs)\n ) {\n return null;\n }\n\n const controller = new AbortController();\n const promise = fetch(config.request.url, {\n method: config.request.method || \"POST\",\n headers: getFetchHeaders(config),\n credentials: config.request.credentials,\n body: JSON.stringify(buildOnDemandCitationPayload(config, context)),\n signal: controller.signal,\n })\n .then(async (response) => {\n const body = await readResponseBody(response);\n if (!response.ok) {\n throw new Error(\n typeof body === \"string\"\n ? body\n : body?.error?.errorMessage ||\n body?.message ||\n `Failed to fetch on-demand citation (${response.status})`,\n );\n }\n\n return (\n config.parseResponse?.(body, context) ??\n normalizeOnDemandCitationResponse(body, context)\n );\n })\n .then((data) => {\n cacheRef.current.set(key, {\n status: \"success\",\n data,\n updatedAt: Date.now(),\n });\n notifyCacheUpdated();\n return data;\n })\n .catch((error) => {\n const isAbortError =\n error instanceof DOMException && error.name === \"AbortError\";\n cacheRef.current.set(key, {\n status: \"error\",\n error,\n updatedAt: Date.now(),\n });\n notifyCacheUpdated();\n\n if (isAbortError) return null;\n throw error;\n });\n\n setCacheEntry(key, {\n status: \"loading\",\n promise,\n controller,\n updatedAt: Date.now(),\n });\n\n return promise;\n },\n [config, getCacheKey, notifyCacheUpdated, setCacheEntry],\n );\n\n const prefetchCitationContexts = useCallback(\n async (contexts: OnDemandCitationContext[]) => {\n if (!config?.enabled || contexts.length === 0) return;\n\n await withConcurrencyLimit(\n contexts,\n config.maxConcurrentRequests || DEFAULT_MAX_CONCURRENT_REQUESTS,\n fetchCitationContext,\n );\n },\n [config, fetchCitationContext],\n );\n\n const abortCitationContexts = useCallback(\n (contexts: OnDemandCitationContext[]) => {\n contexts.forEach((context) => {\n const key = getCacheKey(context);\n const entry = cacheRef.current.get(key);\n if (entry?.status === \"loading\") {\n entry.controller?.abort();\n }\n });\n },\n [getCacheKey],\n );\n\n return {\n cacheVersion,\n getCacheKey,\n getCacheEntry,\n fetchCitationContext,\n prefetchCitationContexts,\n abortCitationContexts,\n };\n};\n"],"names":["DEFAULT_CACHE_TTL_MS","isExpired","entry","ttlMs","Date","now","updatedAt","getFetchHeaders","config","headers","request","hasAuthorizationHeader","Object","keys","some","key","toLowerCase","authToken","Authorization","cacheRef","useRef","Map","cacheVersion","setCacheVersion","useState","useEffect","current","forEach","controller","abort","notifyCacheUpdated","useCallback","version","getCacheKey","context","buildOnDemandCitationCacheKey","getCacheEntry","contextOrKey","get","setCacheEntry","set","fetchCitationContext","async","enabled","url","cacheTtlMs","existingEntry","status","data","promise","retryFailed","AbortController","fetch","method","credentials","body","JSON","stringify","buildOnDemandCitationPayload","signal","then","response","includes","json","text","parse","readResponseBody","ok","Error","error","errorMessage","message","parseResponse","normalizeOnDemandCitationResponse","catch","isAbortError","DOMException","name","prefetchCitationContexts","contexts","length","items","limit","worker","queue","workers","Array","from","Math","max","min","item","shift","Promise","all","withConcurrencyLimit","maxConcurrentRequests","abortCitationContexts"],"mappings":"oOAYA,MAAMA,EAAuB,IAGvBC,EAAY,CAChBC,EACAC,EAAQH,MACLI,KAAKC,MAAQH,EAAMI,UAAYH,EA0B9BI,EACJC,IAEA,MAAMC,EAAkC,CACtC,eAAgB,sBACZD,EAAOE,QAAQD,SAAW,CAAC,GAE3BE,EAAyBC,OAAOC,KAAKJ,GAASK,KACjDC,GAA8B,kBAAtBA,EAAIC,eAOR,OAJHR,EAAOE,QAAQO,YAAcN,IAC/BF,EAAQS,cAAgB,UAAUV,EAAOE,QAAQO,aAG5CR,oCAkBPD,IAEA,MAAMW,EAAWC,EAAAA,OAAoD,IAAAC,MAC9DC,EAAcC,GAAmBC,WAAS,GAEjDC,EAAAA,UAAU,IACD,KACLN,EAASO,QAAQC,QAASzB,GAAUA,EAAM0B,YAAYC,UAEvD,IAEG,MAAAC,EAAqBC,EAAAA,YAAY,KACrBR,EAACS,GAAYA,EAAU,IACtC,IAEGC,EAAcF,EAAAA,YACjBG,GAAqCC,EAAAA,8BAA8BD,GACpE,IAGIE,EAAgBL,EAAAA,YACnBM,IACC,MAAMtB,EACoB,iBAAjBsB,EACHA,EACAJ,EAAYI,GACX,OAAAlB,EAASO,QAAQY,IAAIvB,IAE9B,CAAC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0B,KAAMZ,IACI7B,EAAAO,QAAQc,IAAIzB,EAAK,CACxBgC,OAAQ,UACRC,OACA1C,UAAWF,KAAKC,QAECyB,IACZkB,IAER0B,MAAOL,IACN,MAAMM,EACJN,aAAiBO,cAA+B,eAAfP,EAAMQ,KAQzC,GAPS1D,EAAAO,QAAQc,IAAIzB,EAAK,CACxBgC,OAAQ,QACRsB,QACA/D,UAAWF,KAAKC,QAECyB,IAEf6C,EAAqB,OAAA,KACnB,MAAAN,IAUH,OAPP9B,EAAcxB,EAAK,CACjBgC,OAAQ,UACRE,UACArB,aACAtB,UAAWF,KAAKC,QAGX4C,GAET,CAACzC,EAAQyB,EAAaH,EAAoBS,IAGtCuC,EAA2B/C,EAAAA,YAC/BW,MAAOqC,IACAvE,GAAQmC,SAA+B,IAApBoC,EAASC,aA3LVtC,OAC3BuC,EACAC,EACAC,KAEM,MAAAC,EAAQ,IAAIH,GACZI,EAAUC,MAAMC,KACpB,CAAEP,OAAQQ,KAAKC,IAAI,EAAGD,KAAKE,IAAIR,EAAOE,EAAMJ,UAC5CtC,UACS,KAAA0C,EAAMJ,OAAS,GAAG,CACjB,MAAAW,EAAOP,EAAMQ,QACnB,IAAKD,EAAM,OACP,UACIR,EAAOQ,EAAI,CACX,MAER,CACF,UAIEE,QAAQC,IAAIT,IAwKRU,CACJhB,EACAvE,EAAOwF,uBAtMyB,EAuMhCvD,IAGJ,CAACjC,EAAQiC,IAGLwD,EAAwBlE,EAAAA,YAC3BgD,IACUA,EAAApD,QAASO,IACV,MAAAnB,EAAMkB,EAAYC,GAClBhC,EAAQiB,EAASO,QAAQY,IAAIvB,GACb,YAAlBb,GAAO6C,QACT7C,EAAM0B,YAAYC,WAIxB,CAACI,IAGI,MAAA,CACLX,eACAW,cACAG,gBACAK,uBACAqC,2BACAmB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../CognitiveComparehelpers.js");exports.useSideBySide=({isGuidelineMode:r,maintainRelativeOrder:n,proposedSections:u,existingSections:c,leftContainerRef:l,rightContainerRef:i,scrollContainerRef:s,sectionLeftRefs:o,sectionRightRefs:d,subSectionLeftRefs:p,subSectionRightRefs:g,lhsBadgeRefs:a,rhsBadgeRefs:f,sectionRowRefs:R,sectionRightRowRefs:S,rhsTopSpacerRef:h,rhsBottomSpacerRef:A,lhsTopSpacerRef:T,lhsBottomSpacerRef:y,calculateLinesRef:B,setConnectedSections:m,setConnectedLines:E,cachedConnectedPositions:x,closeMoreFunctionsPopup:C,setErrorToast:I,moreFunctions:v,closeSummaryPopup:O})=>{const[_,b]=e.useState(!1),[D,N]=e.useState(!1),[P,$]=e.useState(!1),[V,G]=e.useState(!1),[w,L]=e.useState(null),q=e.useRef(!1),F=e.useRef(null),H=e.useRef(!1),M=e.useRef(null),k=e.useRef(null),j=e.useRef(null),z=e.useRef(new Set),J=()=>{z.current.forEach(e=>{t.resetClauseHighlight(e)}),z.current.clear()},K=(e,r,n)=>{let u=null,c=null,s=null,h=null,A=null,T=null;const y=(e,t)=>{if(!e||!t)return!0;const r=e.getBoundingClientRect(),n=t.getBoundingClientRect();return r.bottom>=n.top&&r.top<=n.bottom};if(e){const e=r.split(t.DEVIATION_BADGE_SEPARATOR),n=`${e[0]}${t.DEVIATION_BADGE_SEPARATOR}${e[1]}`;u=p.current[e[2]]?.current||o.current[Number(e[2])]?.current||null,c=g.current[e[3]]?.current||d.current[Number(e[3])]?.current||null,s=a.current[n]?.current||u,h=f.current[n]?.current||c}else{const e=Number(r),t=null!==n?Number(n):e;u=o.current[e]?.current||null,c=d.current[t]?.current||null,A=a.current[e]?.current||null,T=f.current[t]?.current||null,s=A||R.current[e]?.current||u,h=T||S.current[t]?.current||c}if(u&&(u.style.paddingTop="0px"),c&&(c.style.paddingTop="0px"),e||(A&&(A.style.marginTop="0px"),T&&(T.style.marginTop="0px")),!e&&A&&T){const e=l.current,t=i.current;if(!y(A,e)||!y(T,t))return;const r=A.getBoundingClientRect(),n=T.getBoundingClientRect(),u=r.top-n.top;if(Math.abs(u)>32)return;return void(u>0&&(T.style.marginTop=`${u}px`))}if(s&&h&&u&&c){const e=s.getBoundingClientRect(),t=h.getBoundingClientRect(),r=e.top-t.top;r>0&&(c.style.paddingTop=`${r}px`)}},Q=e.useCallback(()=>{const e=M.current,r=k.current;if(null!==e)if("string"==typeof e&&e.includes(t.DEVIATION_BADGE_SEPARATOR)){const r=e.split(t.DEVIATION_BADGE_SEPARATOR),n=p.current[r[2]]?.current||o.current[Number(r[2])]?.current||null,u=g.current[r[3]]?.current||d.current[Number(r[3])]?.current||null;n&&(n.style.paddingTop="0px"),u&&(u.style.paddingTop="0px")}else{const t=o.current[e]?.current||null,n=d.current[r??e]?.current||null;t&&(t.style.paddingTop="0px"),n&&(n.style.paddingTop="0px");const u=a.current[e]?.current||null,c=f.current[r??e]?.current||null;u&&(u.style.marginTop="0px"),c&&(c.style.marginTop="0px")}h.current&&(h.current.style.height="0px"),A.current&&(A.current.style.height="0px"),T.current&&(T.current.style.height="0px"),y.current&&(y.current.style.height="0px")},[]);e.useEffect(()=>{H.current=_},[_]),e.useEffect(()=>{M.current=w},[w]);const U=e.useCallback(()=>{J(),b(!1),H.current=!1,F.current=null,Q(),L(null),M.current=null,k.current=null,N(!1),G(!1)},[Q]),W=e.useCallback((e,p,g)=>{const v=g?.toggleIfSame??!0,O=g?.onReady,D=g?.sourceSide??"left";if(C(),null==e)return;if(p&&!r)return void I("No counterpart exists for this section.");J();const P=_&&w===e;_&&null!==w&&Q(),P&&v?U():(m(new Set([e])),E([]),x.current=[],G(!0),q.current=!0,L(e),M.current=e,b(!0),H.current=!0,N(!1),h.current&&(h.current.style.height="0px"),A.current&&(A.current.style.height="0px"),T.current&&(T.current.style.height="0px"),y.current&&(y.current.style.height="0px"),requestAnimationFrame(()=>{const p=()=>{const p="string"==typeof e&&e.includes(t.DEVIATION_BADGE_SEPARATOR);let g=null,T=null,y=null;if(r){if(p){const r=e.split(t.DEVIATION_BADGE_SEPARATOR),n=`${r[0]}${t.DEVIATION_BADGE_SEPARATOR}${r[1]}`;g=a.current[n]?.current||null}else g=o.current[e]?.current||R.current[e]?.current||null;T=document.getElementById("guideline-target-0"),y=T?e:null}else if(p){const r=e.split(t.DEVIATION_BADGE_SEPARATOR),n=`${r[0]}${t.DEVIATION_BADGE_SEPARATOR}${r[1]}`;g=a.current[n]?.current||null,T=f.current[n]?.current||null,y=T?e:null}else if(g=o.current[e]?.current||R.current[e]?.current||null,n){const t=u[e],r=t?.refIndexes||[];if(r.length>0){const e=r[0],t=c.findIndex(t=>t.selfIndex===e);-1!==t&&(T=d.current[t]?.current||S.current[t]?.current||null,y=t)}}else T=d.current[e]?.current||S.current[e]?.current||null,y=T?e:null;k.current=y;const m=l.current,E=i.current,x=()=>{K(p,e,y),N(!0),B.current&&B.current(),q.current=!1,"right"===D&&E?E.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),G(!1),O?.()};if(!g||!m)return q.current=!1,G(!1),void O?.();if(!T||!E)return void x();if(!n){let e=0;e="right"===D?T?T.getBoundingClientRect().top:0:g?g.getBoundingClientRect().top:0;const r=s.current,n=r?.getBoundingClientRect().top||0,u=r?r.scrollTop+e-n-150:0,c=200;return r?void t.smoothScrollTo(r,u,c,x):void x()}const C=g.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,I=T.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop,v=200;if("left"===D){const e=I-(C-m.scrollTop);e<0&&h.current&&!r&&(h.current.style.height=`${Math.abs(e)}px`),requestAnimationFrame(()=>{const n=E.scrollHeight-E.clientHeight;let u;if(e<0)u=0;else{if(e>n){const u=e-n;return A.current&&!r&&(A.current.style.height=`${u+150}px`),void requestAnimationFrame(()=>{t.smoothScrollTo(E,e,v,x)})}u=e}t.smoothScrollTo(E,u,v,x)})}else{const e=C-(I-E.scrollTop);requestAnimationFrame(()=>{const r=m.scrollHeight-m.clientHeight;let n;if(e<0)n=0;else{if(e>r)return void requestAnimationFrame(()=>t.smoothScrollTo(m,r,v,x));n=e}t.smoothScrollTo(m,n,v,x)})}};r?setTimeout(p,100):p()}))},[w,C,c,_,n,u,Q,U,r]);return{isSideBySide:_,setIsSideBySide:b,isArrowVisible:D,setIsArrowVisible:N,isResizing:P,setIsResizing:$,isSideBySideLoading:V,setIsSideBySideLoading:G,activeSideBySideSection:w,setActiveSideBySideSection:L,scrollLock:q,sideBySideCacheRef:F,isSideBySideRef:H,activeSideBySideSectionRef:M,activeSideBySideRightSectionRef:k,sideBySideLineRef:j,highlightedClauseRefs:z,clearClauseHighlight:J,applyAlignmentPadding:K,resetSideBySide:U,activateSideBySide:W}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../CognitiveComparehelpers.js"),r=require("../Guidelines/utils/guidelineTargets.js");exports.useSideBySide=({isGuidelineMode:n,maintainRelativeOrder:u,proposedSections:i,existingSections:c,leftContainerRef:l,rightContainerRef:s,scrollContainerRef:o,sectionLeftRefs:d,sectionRightRefs:p,subSectionLeftRefs:g,subSectionRightRefs:a,lhsBadgeRefs:f,rhsBadgeRefs:R,sectionRowRefs:S,sectionRightRowRefs:h,rhsTopSpacerRef:T,rhsBottomSpacerRef:A,lhsTopSpacerRef:y,lhsBottomSpacerRef:B,calculateLinesRef:m,setConnectedSections:E,setConnectedLines:x,cachedConnectedPositions:C,closeMoreFunctionsPopup:I,setErrorToast:v,moreFunctions:O,closeSummaryPopup:_})=>{const[b,D]=e.useState(!1),[N,P]=e.useState(!1),[$,G]=e.useState(!1),[V,q]=e.useState(!1),[w,L]=e.useState(null),F=e.useRef(!1),H=e.useRef(null),M=e.useRef(!1),k=e.useRef(null),j=e.useRef(null),z=e.useRef(null),J=e.useRef(new Set),K=()=>{J.current.forEach(e=>{t.resetClauseHighlight(e)}),J.current.clear()},Q=(e,r,n)=>{let u=null,i=null,c=null,o=null,T=null,A=null;const y=(e,t)=>{if(!e||!t)return!0;const r=e.getBoundingClientRect(),n=t.getBoundingClientRect();return r.bottom>=n.top&&r.top<=n.bottom};if(e){const e=r.split(t.DEVIATION_BADGE_SEPARATOR),n=`${e[0]}${t.DEVIATION_BADGE_SEPARATOR}${e[1]}`;u=g.current[e[2]]?.current||d.current[Number(e[2])]?.current||null,i=a.current[e[3]]?.current||p.current[Number(e[3])]?.current||null,c=f.current[n]?.current||u,o=R.current[n]?.current||i}else{const e=Number(r),t=null!==n?Number(n):e;u=d.current[e]?.current||null,i=p.current[t]?.current||null,T=f.current[e]?.current||null,A=R.current[t]?.current||null,c=T||S.current[e]?.current||u,o=A||h.current[t]?.current||i}if(u&&(u.style.paddingTop="0px"),i&&(i.style.paddingTop="0px"),e||(T&&(T.style.marginTop="0px"),A&&(A.style.marginTop="0px")),!e&&T&&A){const e=l.current,t=s.current;if(!y(T,e)||!y(A,t))return;const r=T.getBoundingClientRect(),n=A.getBoundingClientRect(),u=r.top-n.top;if(Math.abs(u)>32)return;return void(u>0&&(A.style.marginTop=`${u}px`))}if(c&&o&&u&&i){const e=c.getBoundingClientRect(),t=o.getBoundingClientRect(),r=e.top-t.top;r>0&&(i.style.paddingTop=`${r}px`)}},U=e.useCallback(()=>{const e=k.current,r=j.current;if(null!==e)if("string"==typeof e&&e.includes(t.DEVIATION_BADGE_SEPARATOR)){const r=e.split(t.DEVIATION_BADGE_SEPARATOR),n=g.current[r[2]]?.current||d.current[Number(r[2])]?.current||null,u=a.current[r[3]]?.current||p.current[Number(r[3])]?.current||null;n&&(n.style.paddingTop="0px"),u&&(u.style.paddingTop="0px")}else{const t=d.current[e]?.current||null,n=p.current[r??e]?.current||null;t&&(t.style.paddingTop="0px"),n&&(n.style.paddingTop="0px");const u=f.current[e]?.current||null,i=R.current[r??e]?.current||null;u&&(u.style.marginTop="0px"),i&&(i.style.marginTop="0px")}T.current&&(T.current.style.height="0px"),A.current&&(A.current.style.height="0px"),y.current&&(y.current.style.height="0px"),B.current&&(B.current.style.height="0px")},[]);e.useEffect(()=>{M.current=b},[b]),e.useEffect(()=>{k.current=w},[w]);const W=e.useCallback(()=>{K(),D(!1),M.current=!1,H.current=null,U(),L(null),k.current=null,j.current=null,P(!1),q(!1)},[U]),X=e.useCallback((e,g,a)=>{const O=a?.toggleIfSame??!0,_=a?.onReady,N=a?.sourceSide??"left";if(I(),null==e)return;if(g&&!n)return void v("No counterpart exists for this section.");K();const $=b&&w===e;b&&null!==w&&U(),$&&O?W():(E(new Set([e])),x([]),C.current=[],q(!0),F.current=!0,L(e),k.current=e,D(!0),M.current=!0,P(!1),T.current&&(T.current.style.height="0px"),A.current&&(A.current.style.height="0px"),y.current&&(y.current.style.height="0px"),B.current&&(B.current.style.height="0px"),requestAnimationFrame(()=>{const g=()=>{const g="string"==typeof e&&e.includes(t.DEVIATION_BADGE_SEPARATOR);let a=null,y=null,B=null;if(n){if(g){const r=e.split(t.DEVIATION_BADGE_SEPARATOR),n=`${r[0]}${t.DEVIATION_BADGE_SEPARATOR}${r[1]}`;a=f.current[n]?.current||null}else a=d.current[e]?.current||S.current[e]?.current||null;y=r.getVisibleGuidelineTargets(s.current)[0]||null,B=y?e:null}else if(g){const r=e.split(t.DEVIATION_BADGE_SEPARATOR),n=`${r[0]}${t.DEVIATION_BADGE_SEPARATOR}${r[1]}`;a=f.current[n]?.current||null,y=R.current[n]?.current||null,B=y?e:null}else if(a=d.current[e]?.current||S.current[e]?.current||null,u){const t=i[e],r=t?.refIndexes||[];if(r.length>0){const e=r[0],t=c.findIndex(t=>t.selfIndex===e);-1!==t&&(y=p.current[t]?.current||h.current[t]?.current||null,B=t)}}else y=p.current[e]?.current||h.current[e]?.current||null,B=y?e:null;j.current=B;const E=l.current,x=s.current,C=()=>{Q(g,e,B),P(!0),m.current&&m.current(),F.current=!1,"right"===N&&x?x.dispatchEvent(new Event("scroll")):E&&E.dispatchEvent(new Event("scroll")),q(!1),_?.()};if(!a||!E)return F.current=!1,q(!1),void _?.();if(!y||!x)return void C();if(!u){let e=0;e="right"===N?y?y.getBoundingClientRect().top:0:a?a.getBoundingClientRect().top:0;const r=o.current,n=r?.getBoundingClientRect().top||0,u=r?r.scrollTop+e-n-150:0,i=200;return r?void t.smoothScrollTo(r,u,i,C):void C()}const I=a.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop,v=y.getBoundingClientRect().top-x.getBoundingClientRect().top+x.scrollTop,O=200;if("left"===N){const e=v-(I-E.scrollTop);e<0&&T.current&&!n&&(T.current.style.height=`${Math.abs(e)}px`),requestAnimationFrame(()=>{const r=x.scrollHeight-x.clientHeight;let u;if(e<0)u=0;else{if(e>r){const u=e-r;return A.current&&!n&&(A.current.style.height=`${u+150}px`),void requestAnimationFrame(()=>{t.smoothScrollTo(x,e,O,C)})}u=e}t.smoothScrollTo(x,u,O,C)})}else{const e=I-(v-x.scrollTop);requestAnimationFrame(()=>{const r=E.scrollHeight-E.clientHeight;let n;if(e<0)n=0;else{if(e>r)return void requestAnimationFrame(()=>t.smoothScrollTo(E,r,O,C));n=e}t.smoothScrollTo(E,n,O,C)})}};n?setTimeout(g,100):g()}))},[w,I,c,b,u,i,U,W,n]);return{isSideBySide:b,setIsSideBySide:D,isArrowVisible:N,setIsArrowVisible:P,isResizing:$,setIsResizing:G,isSideBySideLoading:V,setIsSideBySideLoading:q,activeSideBySideSection:w,setActiveSideBySideSection:L,scrollLock:F,sideBySideCacheRef:H,isSideBySideRef:M,activeSideBySideSectionRef:k,activeSideBySideRightSectionRef:j,sideBySideLineRef:z,highlightedClauseRefs:J,clearClauseHighlight:K,applyAlignmentPadding:Q,resetSideBySide:W,activateSideBySide:X}};
2
2
  //# sourceMappingURL=useSideBySide.js.map