@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 e=require("react/jsx-runtime"),t=require("react"),n=require("@mui/material"),i=require("lucide-react"),o=require("../hooks/memoizedMarkdown.js"),s=require("../CompareContext.js"),r=require("../CognitiveComparehelpers.js"),l=require("../CognitiveCompareConstants.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=d(t);const c=(t,n=!1)=>{if(!t)return null;return r.safeStringify(t).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map((t,i)=>t.startsWith("**")&&t.endsWith("**")?e.jsx("strong",{children:t.slice(2,-2)},i):e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"},children:[e.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t}),n&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"},children:"Multiple"})]},i))};exports.default=({section:d,idx:u,columnKey:f,colRef:p,mb:g=1,isExpanded:h,onToggle:x,navigation:I,parentNodeId:m=""})=>{const{showOpenNodeRef:v,resolvedMarkdownStyles:y,maintainRelativeOrder:S,showDeviationBadges:b=!1,renderSubSectionAccordion:A,treeData:R,proposedSections:_,existingSections:E,deviationNumberRegistry:w,deviationParentRegistry:M,getBadgeRef:O,openSummaryPopup:N,getSectionCompareStyle:$,connectedSections:T,openMoreFunctionsPopup:D,isProposingFix:j,proposingFixNodeId:B,isRedlineFlow:C,isSideBySide:F,activeSideBySideSection:k,scrollSyncLocked:P,unifiedNumbering:V,toggleScrollSyncLocked:G,summaryPopupAnchorEl:W}=s.useCompareContext(),L=`${F?"1":"0"}-${String(k??"")}`,q=(d.displayTitle??!0)&&r.hasValue(d.title),z=!(!j||!B||"left"!==f||d.id!==B&&d.nodeId!==B),K=r.hasMeaningfulRedlineTags(d.content),X="boolean"==typeof C?C:K,H=K,U=X&&K,Y=U?r.stripRedlineTags(d.content):d.content,J=U?d.content:void 0,Q=((d.displayContent??!0)||K)&&r.hasValue(d.content),Z=!q&&!Q;let ee=d.title;q||(ee=Q?"No Title Found":"No Matching Section Found");const te="left"===f&&(d.isMultipleMapping||(d.refContentIds?.length??1)>1),ne="left"===f&&ee.length>29?`${ee.slice(0,29).trimEnd()}...`:ee;let ie=d.evaluationResult;if(!ie&&"right"===f)if(S){const e=d.refIndexes?.[0],t=_.find(t=>t.selfIndex===e);ie=t?.evaluationResult}else ie=_[u]?.evaluationResult;const oe=R?.input_index_map?.[0],se=R?.input_index_map?.[1],re="left"===f?se:oe,le=(e,t)=>{if(!t||!e)return null;for(const n of e){if(n.id===t||n.nodeId===t||n.contentId===t)return n;if(n.subsections?.length){const e=le(n.subsections,t);if(e)return e}}return null};let de="left"===f?d:le(_,d.id),ae="right"===f?d:le(E,d.id);const ce=a.default.useMemo(()=>{if(!S)return 0;let e=1/0;const t=e=>{const t=r.hasMeaningfulRedlineTags(e)?r.stripRedlineTags(e):e;return r.safeStringify(t||"").replace(/\\n/g,"\n")},n=(i,o,s,l)=>{if(!i)return;let d=i.nodeId||i.id;if(l&&"right"===f){const e=_.filter(e=>e.refIndexes?.includes(i.selfIndex));e.length>0&&(d=e[0].nodeId||e[0].id)}let a=i.nodeId||i.id||o?.nodeId||o?.id||s?.nodeId||s?.id;const c=i.evaluationResult||o?.evaluationResult||s?.evaluationResult,u=c?.deviations||{};Object.keys(u).forEach(n=>{const l=u[n]?.[m];if(!((e,n)=>{if("string"!=typeof n||r.isMissingStr(n))return!1;const i=t(e?.content),o=t(n);return!!o&&i.includes(o)})("left"===f?o||i:s||i,l))return;const c=`${d}${r.DEVIATION_BADGE_SEPARATOR}${n}`,p=w?.[c];null!=p&&p<e&&(e=p);const g=`${a}${r.DEVIATION_BADGE_SEPARATOR}${n}`,h=w?.[g];null!=h&&h<e&&(e=h)});const p=i.subsections||[],g=o?.subsections||[],h=s?.subsections||[],x=Math.max(p.length,g.length,h.length);for(let e=0;e<x;e++)n(p[e],g[e],h[e],!1)},i="right"===f?_.filter(e=>e.refIndexes?.includes(d.selfIndex)):[];if(1===i.length){const e=i[0];(e.refIndexes||[]).map(e=>E.find(t=>t.selfIndex===e)).filter(Boolean).forEach(t=>{n(t,e,t,!0)})}else n(d,de,ae,!0);return e!==1/0?e-1:0},[d,de,ae,f,m,w,S,_,E]);if(S)if("left"===f){const e=d.refIndexes?.[0],t=E.findIndex(t=>t.selfIndex===e);ae=-1!==t?E[t]:le(E,d.id)}else{const e=d.refIndexes?.[0],t=_.findIndex(t=>t.selfIndex===e);de=-1!==t?_[t]:le(_,d.id)}const ue="left"===f?!ae:!de,fe=S&&"right"===f&&r.hasSingleMappedLhsSection(d,_),pe=ie||de?.evaluationResult||ae?.evaluationResult,ge=pe?.evaluation_outputs?.metadata?.label_color??l.DEFAULT_DEVIAION_COLOR,he=r.generateColorPalette(ge),{highlightBg:xe}=he,Ie=pe?.deviations||{},me=a.default.useMemo(()=>S&&"right"===f?r.getLhsDeviationDisplayIndexes(_,oe,w):new Map,[S,f,_,oe,w]);let ve=d.nodeId||d.id;if(S&&"left"!==f){const e=_.filter(e=>e.refIndexes?.includes(d.selfIndex));e.length>0?ve=e[0].nodeId||e[0].id:de?.id&&(ve=de.nodeId||de.id)}const ye=a.default.useMemo(()=>{const e=new Map;if(!S||"right"!==f)return e;let t=1;const n=_.filter(e=>e.refIndexes?.includes(d.selfIndex)),i=1===n.length&&1===n[0].refIndexes?.length,o=e=>r.safeStringify(e||"").replace(/\\n/g,"\n"),s=(e,t)=>{const i=t?n[0]:le(_,e.nodeId||e.id||e.contentId);return{lhsNode:i,evalResult:e.evaluationResult||i?.evaluationResult,registryNodeId:i?i.nodeId||i.id:e.nodeId||e.id}};if(i){const e=(n,i=!1)=>{if(!n)return;const{lhsNode:l,evalResult:d,registryNodeId:a}=s(n,i),c=o(n.content);Object.entries(d?.deviations||{}).forEach(([e,n])=>{const i=n[m],s=o(i);if(!(!!l&&!r.isMissingStr(n[re]))||!s||!c.includes(s))return;const d=`${a}${r.DEVIATION_BADGE_SEPARATOR}${e}`,u=w[d];null!=u&&(t=Math.max(t,Math.max(1,u-(ce||0))+1))}),(n.subsections||[]).forEach(t=>e(t))};e(d,!0)}const l=(n,i=!1)=>{if(!n)return;const{lhsNode:d,evalResult:a,registryNodeId:c}=s(n,i),u=a?.deviations||{},f=o(n.content);Object.entries(u).map(([e,t])=>{const n=t[m],i=!d||r.isMissingStr(t[re]),s=o(n),l=s?f.indexOf(s):-1,a=`${c}${r.DEVIATION_BADGE_SEPARATOR}${e}`;return{refId:a,isRenderable:i&&!!s&&!r.isMissingStr(n),position:l,registryIndex:w[a]??Number.MAX_SAFE_INTEGER}}).filter(e=>e.isRenderable).sort((e,t)=>(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)-(-1===t.position?Number.MAX_SAFE_INTEGER:t.position)||e.registryIndex-t.registryIndex).forEach(n=>{e.set(n.refId,t++)}),(n.subsections||[]).forEach(e=>l(e))};return l(d,!0),e},[S,f,d,_,m,re,w,ce]),Se=Object.keys(Ie)[0],be=Se?`${ve}${r.DEVIATION_BADGE_SEPARATOR}${Se}`:null,Ae=be?M?.[be]:null;let Re=u+1;if(S&&V){const e="left"===f?V.leftNums.get(d?.id):V.rightNums.get(d?.id);ue&&void 0!==e?Re=e:null!=Ae&&Ae>=0?Re=Ae:void 0!==e&&(Re=e)}else null!=Ae&&Ae>=0&&(Re=Ae);const _e=Object.entries(Ie).map(([e,t])=>{const n=`${ve}${r.DEVIATION_BADGE_SEPARATOR}${e}`;return{deviationKey:e,deviationMap:t,refId:n,currentIndex:w[n]}}).filter(e=>void 0!==e.currentIndex&&null!==e.currentIndex);_e.sort((e,t)=>e.currentIndex-t.currentIndex);const Ee=_e.map(e=>{const{deviationKey:t,deviationMap:n,refId:i}=e;let o=e.currentIndex,s=n[m];const l=r.isMissingStr(s);if(l)s="";else if(!s)return null;let a=u,c=u;if(S)if("left"===f){const e=d.refIndexes?.[0],t=E.findIndex(t=>t.selfIndex===e);if(-1!==t)c=t;else{const e=E.findIndex(e=>e.id===d.id||e.nodeId===d.nodeId||e.contentId===d.contentId);c=-1!==e?e:u}}else{const e=d.refIndexes?.[0],t=_.findIndex(t=>t.selfIndex===e);if(-1!==t)a=t;else{const e=_.findIndex(e=>e.id===d.id||e.nodeId===d.nodeId||e.contentId===d.contentId);a=-1!==e?e:u}}const p=`${ve}${r.DEVIATION_BADGE_SEPARATOR}${t}${r.DEVIATION_BADGE_SEPARATOR}${a}${r.DEVIATION_BADGE_SEPARATOR}${c}`,g=n[re],h=ue||r.isMissingStr(g),x=ye.get(i),I=me.get(i);S&&"right"===f&&h&&void 0!==x?o=x:S&&"right"===f&&!h&&void 0!==I?o=I:S&&void 0!==ce&&("right"!==f||h||fe)&&(o-=ce),o=Math.max(1,o);const v=`${S&&"right"===f&&h&&V?r.getRhsMappedSectionNumber({section:d,proposedSections:_,leftNums:V.leftNums,fallbackNumber:String(Re),firstOnly:!0}):Re}.${o}`;let y=u;if("right"===f&&S){const e=d.refIndexes?.[0],t=_.findIndex(t=>t.selfIndex===e);if(-1!==t)y=t;else{const e=_.findIndex(e=>e.id===d.id||e.nodeId===d.nodeId||e.contentId===d.contentId);-1!==e&&(y=e)}}const b=$?$(y):null,A=n?.evaluation_outputs||pe?.evaluation_outputs,R=A?.output_value??null,w=A?.metadata?.label_color??ge,M=r.generateColorPalette(w);let j=b?{...b,badgeBg:M.badgeBg,badgeBorder:M.badgeBorder,badgeText:M.badgeText}:{...M};const B=n?.deviation_summary?{deviation_summary:n.deviation_summary,deviation_title:n?.deviation_title||pe?.deviation_title,deviation_impact:n?.deviation_impact||pe?.deviation_impact,deviation_explanation:n?.deviation_explanation||pe?.deviation_explanation,evaluation_outputs:A,cognitive_decisioning:n?.cognitive_decisioning||pe?.cognitive_decisioning}:null;let C=0;const L=Y||"";if(s&&L){const e=L.split(/\n{2,}/),n=e.findIndex(e=>e.includes(s));if(-1!==n){const i=Object.entries(Ie).filter(([t,i])=>{const o=i[m];return o&&e[n].includes(o)}).sort((t,i)=>e[n].indexOf(t[1][m])-e[n].indexOf(i[1][m])).filter(([e,t])=>{const n=t[m];return n&&(n.includes(s)||s.includes(n))});i.length>1&&(C=Math.max(0,i.findIndex(([e])=>e===t)))}}const q=O(f,i);return{id:i,actionId:p,label:v,highlight:s,side:f,style:j,stackIndex:C,score:R,isConnected:T?.has(p),showScrollLockToggle:T?.has(p)||F&&k===p||!!W&&W===q.current,scrollSyncLocked:P,toggleScrollSyncLocked:G,isOrphan:h,isMissingClause:l,badgeRef:q,onClick:e=>{e.stopPropagation(),D&&D(e,de||{id:"orphan-left",title:"",content:""},h,ae||{id:"orphan-right",title:"",content:""},p,j)},onSummaryClick:e=>{e.stopPropagation(),N(e,p,h,B)}}}).filter(Boolean),we=b||!X&&z?Ee:[],Me=Ee.map(e=>e.highlight).filter(Boolean),Oe=d.id&&f===I?.columnKey?I:null,Ne=a.default.useRef(!1);return t.useEffect(()=>{h||(Ne.current=!1)},[h]),e.jsxs(n.Box,{ref:p,sx:{mb:g,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0},children:[h&&Oe?.showAbove&&e.jsx("div",{style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:()=>Oe?.showAboveRef?.current?.scrollIntoView({behavior:"smooth",block:"center"}),children:e.jsx("div",{style:{transform:`translateY(-50%) translateX(calc(100% ${"left"===f?"+":"-"} 130px))`,position:"absolute",paddingTop:"20px",..."left"===f?{right:"-20px"}:{left:"-20px"}},children:e.jsx(i.ChevronUp,{color:Oe?.showAboveRef?.current?window.getComputedStyle(Oe.showAboveRef.current).color:void 0})})}),e.jsxs(n.Accordion,{disableGutters:!0,expanded:!Z&&h,onChange:()=>{Z||(x(),v.current=d.id)},sx:{boxShadow:"none",border:Z?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Z?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}},children:[e.jsx(n.AccordionSummary,{expandIcon:Z?null:e.jsx(i.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Z?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}},children:q&&e.jsx(n.Tooltip,{title:ee,placement:"top",children:e.jsx(n.Typography,{component:"div",sx:{fontSize:"12px",color:Z?"#94A3B8":"#19213D",fontWeight:Z?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0},children:c(ne,te)})})}),!Z&&e.jsxs(n.AccordionDetails,{sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[Q&&e.jsx(o.MemoizedMarkdown,{content:Y,overlayContent:J,sxStyles:y,highlights:Me,maintainRelativeOrder:S,highlightBg:xe,suppressHighlightBg:H,deviationBadges:we,collisionKey:L}),(d.subsections||[]).map((e,t)=>A({section:e,keyPath:`${u}-${t}`,depth:0,columnKey:f,parentNodeId:m,sectionOffset:ce,rhsOrphanVisualIndexes:ye}))]})]}),h&&Oe?.showBelow&&e.jsx("div",{style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:()=>Oe?.showBelowRef?.current?.scrollIntoView({behavior:"smooth",block:"center"}),children:e.jsx("div",{style:{transform:`translateY(-50%) translateX(calc(100% ${"left"===f?"+":"-"} 130px))`,position:"absolute",paddingBottom:"20px",..."left"===f?{right:"-20px"}:{left:"-20px"}},children:e.jsx(i.ChevronDown,{color:Oe?.showBelowRef?.current?window.getComputedStyle(Oe.showBelowRef.current).color:void 0})})})]},`${f}-sec-${u}`)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@mui/material"),i=require("lucide-react"),o=require("../hooks/memoizedMarkdown.js"),s=require("../CompareContext.js"),r=require("../CognitiveComparehelpers.js"),l=require("../utils/normalizeInlineMarkdown.js"),d=require("../CognitiveCompareConstants.js"),a=require("../utils/normalizeRedlineMarkdown.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(t);const f=(t,n=!1)=>{if(!t)return null;return r.safeStringify(t).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map((t,i)=>t.startsWith("**")&&t.endsWith("**")?e.jsx("strong",{children:t.slice(2,-2)},i):e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"},children:[e.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t}),n&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",flexShrink:0,lineHeight:1.4,marginRight:"4px"},children:"Multiple"})]},i))};exports.default=({section:c,idx:p,columnKey:g,colRef:h,mb:x=1,isExpanded:I,onToggle:m,navigation:v,parentNodeId:y=""})=>{const{showOpenNodeRef:R,resolvedMarkdownStyles:S,maintainRelativeOrder:b,showDeviationBadges:A=!1,renderSubSectionAccordion:_,treeData:E,proposedSections:w,existingSections:M,deviationNumberRegistry:O,deviationParentRegistry:T,getBadgeRef:$,openSummaryPopup:N,getSectionCompareStyle:j,connectedSections:D,openMoreFunctionsPopup:B,isProposingFix:k,proposingFixNodeId:F,isRedlineFlow:C,isSideBySide:P,activeSideBySideSection:V,scrollSyncLocked:G,unifiedNumbering:W,toggleScrollSyncLocked:q,summaryPopupAnchorEl:z}=s.useCompareContext(),L=`${P?"1":"0"}-${String(V??"")}`,K=(c.displayTitle??!0)&&r.hasValue(c.title),X=!(!k||!F||"left"!==g||c.id!==F&&c.nodeId!==F&&c.contentId!==F),H=r.hasMeaningfulRedlineTags(c.content),U="boolean"==typeof C?C:H,Y=H,J=c.change_history,Q=U&&H,Z=u.default.useMemo(()=>Q?a.normalizeRedlineMarkdown(r.safeStringify(c.content)):r.safeStringify(c.content),[c.content,Q]),ee=Q?r.stripRedlineTags(Z):c.content,te=Q?Z:void 0,ne=H&&r.hasValue(J)?r.safeStringify(J):void 0,ie=((c.displayContent??!0)||H)&&r.hasValue(c.content),oe=!K&&!ie;let se=c.title;K||(se=ie?"No Title Found":"No Matching Section Found");const re="left"===g&&(c.isMultipleMapping||(c.refContentIds?.length??1)>1),le="left"===g&&se.length>29?`${se.slice(0,29).trimEnd()}...`:se;let de=c.evaluationResult;if(!de&&"right"===g)if(b){const e=c.refIndexes?.[0],t=w.find(t=>t.selfIndex===e);de=t?.evaluationResult}else de=w[p]?.evaluationResult;const ae=E?.input_index_map?.[0],ce=E?.input_index_map?.[1],ue="left"===g?ce:ae,fe=(e,t)=>{if(!t||!e)return null;for(const n of e){if(n.id===t||n.nodeId===t||n.contentId===t)return n;if(n.subsections?.length){const e=fe(n.subsections,t);if(e)return e}}return null};let pe="left"===g?c:fe(w,c.id),ge="right"===g?c:fe(M,c.id);const he=u.default.useMemo(()=>{if(!b)return 0;let e=1/0;const t=e=>{const t=r.safeStringify(e||"").replace(/\\n/g,"\n");return r.hasMeaningfulRedlineTags(t)?r.stripRedlineTags(a.normalizeRedlineMarkdown(t)):t},n=(i,o,s,l)=>{if(!i)return;let d=i.nodeId||i.id;if(l&&"right"===g){const e=w.filter(e=>e.refIndexes?.includes(i.selfIndex));e.length>0&&(d=e[0].nodeId||e[0].id)}let a=i.nodeId||i.id||o?.nodeId||o?.id||s?.nodeId||s?.id;const c=i.evaluationResult||o?.evaluationResult||s?.evaluationResult,u=c?.deviations||{};Object.keys(u).forEach(n=>{const l=u[n]?.[y];if(!((e,n)=>{if("string"!=typeof n||r.isMissingStr(n))return!1;const i=t(e?.content),o=t(n);return!!o&&!!r.findTextMatchRange(i,o)})("left"===g?o||i:s||i,l))return;const c=`${d}${r.DEVIATION_BADGE_SEPARATOR}${n}`,f=O?.[c];null!=f&&f<e&&(e=f);const p=`${a}${r.DEVIATION_BADGE_SEPARATOR}${n}`,h=O?.[p];null!=h&&h<e&&(e=h)});const f=i.subsections||[],p=o?.subsections||[],h=s?.subsections||[],x=Math.max(f.length,p.length,h.length);for(let e=0;e<x;e++)n(f[e],p[e],h[e],!1)},i="right"===g?w.filter(e=>e.refIndexes?.includes(c.selfIndex)):[];if(1===i.length){const e=i[0];(e.refIndexes||[]).map(e=>M.find(t=>t.selfIndex===e)).filter(Boolean).forEach(t=>{n(t,e,t,!0)})}else n(c,pe,ge,!0);return e!==1/0?e-1:0},[c,pe,ge,g,y,O,b,w,M]);if(b)if("left"===g){const e=c.refIndexes?.[0],t=M.findIndex(t=>t.selfIndex===e);ge=-1!==t?M[t]:fe(M,c.id)}else{const e=c.refIndexes?.[0],t=w.findIndex(t=>t.selfIndex===e);pe=-1!==t?w[t]:fe(w,c.id)}const xe="left"===g?!ge:!pe,Ie=b&&"right"===g&&r.hasSingleMappedLhsSection(c,w),me=de||pe?.evaluationResult||ge?.evaluationResult,ve=me?.evaluation_outputs?.metadata?.label_color??d.DEFAULT_DEVIAION_COLOR,ye=r.generateColorPalette(ve),{highlightBg:Re}=ye,Se=me?.deviations||{},be=u.default.useMemo(()=>b&&"right"===g?r.getLhsDeviationDisplayIndexes(w,ae,O):new Map,[b,g,w,ae,O]);let Ae=c.nodeId||c.id;if(b&&"left"!==g){const e=w.filter(e=>e.refIndexes?.includes(c.selfIndex));e.length>0?Ae=e[0].nodeId||e[0].id:pe?.id&&(Ae=pe.nodeId||pe.id)}const _e=u.default.useMemo(()=>{const e=new Map;if(!b||"right"!==g)return e;let t=1;const n=w.filter(e=>e.refIndexes?.includes(c.selfIndex)),i=1===n.length&&1===n[0].refIndexes?.length,o=e=>r.safeStringify(e||"").replace(/\\n/g,"\n"),s=(e,t)=>{const i=t?n[0]:fe(w,e.nodeId||e.id||e.contentId);return{lhsNode:i,evalResult:e.evaluationResult||i?.evaluationResult,registryNodeId:i?i.nodeId||i.id:e.nodeId||e.id}};if(i){const e=(n,i=!1)=>{if(!n)return;const{lhsNode:l,evalResult:d,registryNodeId:a}=s(n,i),c=o(n.content);Object.entries(d?.deviations||{}).forEach(([e,n])=>{const i=n[y],s=o(i);if(!(!!l&&!r.isMissingStr(n[ue]))||!s||!r.findTextMatchRange(c,s))return;const d=`${a}${r.DEVIATION_BADGE_SEPARATOR}${e}`,u=O[d];null!=u&&(t=Math.max(t,Math.max(1,u-(he||0))+1))}),(n.subsections||[]).forEach(t=>e(t))};e(c,!0)}const d=(n,i=!1)=>{if(!n)return;const{lhsNode:a,evalResult:c,registryNodeId:u}=s(n,i),f=c?.deviations||{},p=o(n.content);Object.entries(f).map(([e,t])=>{const n=t[y],i=!a||r.isMissingStr(t[ue]),s=o(n);let d=-1;s&&(d=r.findTextMatchRange(p,s)?.start??-1,-1===d&&(d=l.findTextRangeWithFormatting(p,s)?.start??-1));const c=`${u}${r.DEVIATION_BADGE_SEPARATOR}${e}`;return{refId:c,isRenderable:i&&!!s&&!r.isMissingStr(n),position:d,registryIndex:O[c]??Number.MAX_SAFE_INTEGER}}).filter(e=>e.isRenderable).sort((e,t)=>(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)-(-1===t.position?Number.MAX_SAFE_INTEGER:t.position)||e.registryIndex-t.registryIndex).forEach(n=>{e.set(n.refId,t++)}),(n.subsections||[]).forEach(e=>d(e))};return d(c,!0),e},[b,g,c,w,y,ue,O,he]),Ee=Object.keys(Se)[0],we=Ee?`${Ae}${r.DEVIATION_BADGE_SEPARATOR}${Ee}`:null,Me=we?T?.[we]:null;let Oe=p+1;if(b&&W){const e="left"===g?W.leftNums.get(c?.id):W.rightNums.get(c?.id);xe&&void 0!==e?Oe=e:null!=Me&&Me>=0?Oe=Me:void 0!==e&&(Oe=e)}else null!=Me&&Me>=0&&(Oe=Me);let Te=Math.max(0,...Object.keys(Se).map(e=>O[`${Ae}${r.DEVIATION_BADGE_SEPARATOR}${e}`]).filter(e=>"number"==typeof e&&Number.isFinite(e)))+1;const $e=Object.entries(Se).map(([e,t])=>{const n=`${Ae}${r.DEVIATION_BADGE_SEPARATOR}${e}`;return{deviationKey:e,deviationMap:t,refId:n,currentIndex:O[n]??Te++}});$e.sort((e,t)=>e.currentIndex-t.currentIndex);const Ne=$e.map(e=>{const{deviationKey:t,deviationMap:n,refId:i}=e;let o=e.currentIndex,s=n[y];const l=r.isMissingStr(s);if(l)s="";else if(!s)return null;let d=p,a=p;if(b)if("left"===g){const e=c.refIndexes?.[0],t=M.findIndex(t=>t.selfIndex===e);if(-1!==t)a=t;else{const e=M.findIndex(e=>e.id===c.id||e.nodeId===c.nodeId||e.contentId===c.contentId);a=-1!==e?e:p}}else{const e=c.refIndexes?.[0],t=w.findIndex(t=>t.selfIndex===e);if(-1!==t)d=t;else{const e=w.findIndex(e=>e.id===c.id||e.nodeId===c.nodeId||e.contentId===c.contentId);d=-1!==e?e:p}}const u=`${Ae}${r.DEVIATION_BADGE_SEPARATOR}${t}${r.DEVIATION_BADGE_SEPARATOR}${d}${r.DEVIATION_BADGE_SEPARATOR}${a}`,f=n[ue],h=xe||r.isMissingStr(f),x=_e.get(i),I=be.get(i);b&&"right"===g&&h&&void 0!==x?o=x:b&&"right"===g&&!h&&void 0!==I?o=I:b&&void 0!==he&&("right"!==g||h||Ie)&&(o-=he),o=Math.max(1,o);const m=`${b&&"right"===g&&h&&W?r.getRhsMappedSectionNumber({section:c,proposedSections:w,leftNums:W.leftNums,fallbackNumber:String(Oe),firstOnly:!0}):Oe}.${o}`;let v=p;if("right"===g&&b){const e=c.refIndexes?.[0],t=w.findIndex(t=>t.selfIndex===e);if(-1!==t)v=t;else{const e=w.findIndex(e=>e.id===c.id||e.nodeId===c.nodeId||e.contentId===c.contentId);-1!==e&&(v=e)}}const R=j?j(v):null,S=n?.evaluation_outputs||me?.evaluation_outputs,A=S?.output_value??null,_=S?.metadata?.label_color??ve,E=r.generateColorPalette(_);let O=R?{...R,badgeBg:E.badgeBg,badgeBorder:E.badgeBorder,badgeText:E.badgeText}:{...E};const T=n?.deviation_summary?{deviation_summary:n.deviation_summary,deviation_title:n?.deviation_title||me?.deviation_title,deviation_impact:n?.deviation_impact||me?.deviation_impact,deviation_explanation:n?.deviation_explanation||me?.deviation_explanation,evaluation_outputs:S,cognitive_decisioning:n?.cognitive_decisioning||me?.cognitive_decisioning}:null;let k=0;const F=ee||"";if(s&&F){const e=F.split(/\n{2,}/),n=e.findIndex(e=>e.includes(s));if(-1!==n){const i=Object.entries(Se).filter(([t,i])=>{const o=i[y];return o&&e[n].includes(o)}).sort((t,i)=>e[n].indexOf(t[1][y])-e[n].indexOf(i[1][y])).filter(([e,t])=>{const n=t[y];return n&&(n.includes(s)||s.includes(n))});i.length>1&&(k=Math.max(0,i.findIndex(([e])=>e===t)))}}const C=$(g,i);return{id:i,actionId:u,label:m,highlight:s,side:g,style:O,stackIndex:k,score:A,isConnected:D?.has(u),showScrollLockToggle:D?.has(u)||P&&V===u||!!z&&z===C.current,scrollSyncLocked:G,toggleScrollSyncLocked:q,isOrphan:h,isMissingClause:l,badgeRef:C,onClick:e=>{e.stopPropagation(),B&&B(e,pe||{id:"orphan-left",title:"",content:""},h,ge||{id:"orphan-right",title:"",content:""},u,O)},onSummaryClick:e=>{e.stopPropagation(),N(e,u,h,T)}}}).filter(Boolean),je=A||X?Ne:[],De=Ne.map(e=>e.highlight).filter(Boolean),Be=c.id&&g===v?.columnKey?v:null,ke=u.default.useRef(!1);return t.useEffect(()=>{I||(ke.current=!1)},[I]),e.jsxs(n.Box,{ref:h,sx:{mb:x,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0},children:[I&&Be?.showAbove&&e.jsx("div",{style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:()=>Be?.showAboveRef?.current?.scrollIntoView({behavior:"smooth",block:"center"}),children:e.jsx("div",{style:{transform:`translateY(-50%) translateX(calc(100% ${"left"===g?"+":"-"} 130px))`,position:"absolute",paddingTop:"20px",..."left"===g?{right:"-20px"}:{left:"-20px"}},children:e.jsx(i.ChevronUp,{color:Be?.showAboveRef?.current?window.getComputedStyle(Be.showAboveRef.current).color:void 0})})}),e.jsxs(n.Accordion,{disableGutters:!0,expanded:!oe&&I,onChange:()=>{oe||(m(),R.current=c.id)},sx:{boxShadow:"none",border:oe?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:oe?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}},children:[e.jsx(n.AccordionSummary,{expandIcon:oe?null:e.jsx(i.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:oe?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}},children:K&&e.jsx(n.Tooltip,{title:se,placement:"top",children:e.jsx(n.Typography,{component:"div",sx:{fontSize:"12px",color:oe?"#94A3B8":"#19213D",fontWeight:oe?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0},children:f(le,re)})})}),!oe&&e.jsxs(n.AccordionDetails,{sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[ie&&e.jsx(o.MemoizedMarkdown,{content:ee,overlayContent:te,fallbackContent:ne,sxStyles:S,highlights:De,maintainRelativeOrder:b,highlightBg:Re,suppressHighlightBg:Y,deviationBadges:je,collisionKey:L}),(c.subsections||[]).map((e,t)=>_({section:e,keyPath:`${p}-${t}`,depth:0,columnKey:g,parentNodeId:y,sectionOffset:he,rhsOrphanVisualIndexes:_e}))]})]}),I&&Be?.showBelow&&e.jsx("div",{style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:()=>Be?.showBelowRef?.current?.scrollIntoView({behavior:"smooth",block:"center"}),children:e.jsx("div",{style:{transform:`translateY(-50%) translateX(calc(100% ${"left"===g?"+":"-"} 130px))`,position:"absolute",paddingBottom:"20px",..."left"===g?{right:"-20px"}:{left:"-20px"}},children:e.jsx(i.ChevronDown,{color:Be?.showBelowRef?.current?window.getComputedStyle(Be.showBelowRef.current).color:void 0})})})]},`${g}-sec-${p}`)};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SectionAccordion.js","sources":["../../../../../src/features/CognitiveCompare/components/SectionAccordion.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Box,\n Tooltip,\n Typography,\n} from \"@mui/material\";\nimport { ChevronDown, ChevronUp } from \"lucide-react\";\nimport { MemoizedMarkdown } from \"../hooks/memoizedMarkdown\";\nimport { useCompareContext } from \"../CompareContext\";\nimport { \n generateColorPalette, \n hasValue, \n safeStringify,\n DEVIATION_BADGE_SEPARATOR,\n isMissingStr,\n escapeRegExp,\n hasMeaningfulRedlineTags,\n stripRedlineTags,\n getRhsMappedSectionNumber,\n hasSingleMappedLhsSection,\n getLhsDeviationDisplayIndexes,\n} from \"../CognitiveComparehelpers\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport { DeviationDataEntry, SectionBlock, StyleVariant } from \"../CognitiveCompareTypes\";\nimport { DeviationNavigationEntry } from \"../hooks/useDeviationNavigation\";\n\nconst renderSimpleMarkdown = (text: string, isMultiTag = false) => {\n if (!text) return null;\n\n const normalizedText = safeStringify(text).replace(/\\\\n/g, \"\\n\");\n const parts = normalizedText.split(/(\\*\\*.*?\\*\\*)/g);\n\n return parts.map((part: string, i: number) => {\n if (part.startsWith(\"**\") && part.endsWith(\"**\")) {\n return <strong key={i}>{part.slice(2, -2)}</strong>;\n }\n\n return (\n <div\n key={i}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n gap: \"8px\",\n width: \"100%\",\n }}\n >\n <span\n style={{\n minWidth: 0,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }}\n >\n {part}\n </span>\n\n {isMultiTag && (\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: \"0px 6px\",\n borderRadius: \"9999px\",\n background: \"#F3F4F6\",\n border: \"1px solid #D1D5DB\",\n color: \"#6B7280\",\n fontSize: \"9px\",\n fontWeight: 500,\n whiteSpace: \"nowrap\",\n flexShrink: 0,\n lineHeight: 1.4,\n marginRight: \"4px\",\n }}\n >\n Multiple\n </span>\n )}\n </div>\n );\n });\n};\n\nconst findScrollParent = (element: HTMLElement | null): HTMLElement | null => {\n let current = element?.parentElement || null;\n while (current) {\n const style = window.getComputedStyle(current);\n const overflowY = style.overflowY;\n const canScroll =\n (overflowY === \"auto\" || overflowY === \"scroll\") &&\n current.scrollHeight > current.clientHeight;\n\n if (canScroll) return current;\n current = current.parentElement;\n }\n\n return null;\n};\n\nconst isElementVisibleInScrollParent = (element: HTMLElement) => {\n const scrollParent = findScrollParent(element);\n const rect = element.getBoundingClientRect();\n const parentRect = scrollParent?.getBoundingClientRect() || {\n top: 0,\n bottom: window.innerHeight,\n };\n\n return rect.top >= parentRect.top && rect.bottom <= parentRect.bottom;\n};\n\ntype SectionAccordionProps = {\n section: SectionBlock;\n idx: number;\n columnKey: \"left\" | \"right\";\n colRef: React.RefObject<HTMLDivElement>;\n mb?: number;\n parentNodeId?: string;\n isExpanded: boolean;\n onToggle: () => void;\n navigation: DeviationNavigationEntry | null;\n};\n\nconst SectionAccordion = ({\n section,\n idx,\n columnKey,\n colRef,\n mb = 1,\n isExpanded,\n onToggle,\n navigation,\n parentNodeId = \"\",\n}: SectionAccordionProps) => {\n const {\n showOpenNodeRef,\n resolvedMarkdownStyles,\n maintainRelativeOrder,\n showDeviationBadges = false,\n renderSubSectionAccordion,\n treeData,\n proposedSections,\n existingSections,\n deviationNumberRegistry,\n deviationParentRegistry,\n getBadgeRef,\n openSummaryPopup,\n getSectionCompareStyle,\n connectedSections,\n openMoreFunctionsPopup,\n isProposingFix,\n proposingFixNodeId,\n isRedlineFlow,\n isSideBySide,\n activeSideBySideSection,\n scrollSyncLocked,\n unifiedNumbering,\n toggleScrollSyncLocked,\n summaryPopupAnchorEl,\n } = useCompareContext();\n const collisionKey = `${isSideBySide ? \"1\" : \"0\"}-${String(activeSideBySideSection ?? \"\")}`;\n const hasTitle = (section.displayTitle ?? true) && hasValue(section.title);\n const isProposedFixTarget =\n !!isProposingFix &&\n !!proposingFixNodeId &&\n columnKey === \"left\" &&\n (section.id === proposingFixNodeId || section.nodeId === proposingFixNodeId);\n \n const hasRedlineTags = hasMeaningfulRedlineTags(section.content);\n const inferredRedlineFlow = hasRedlineTags;\n const resolvedRedlineFlow =\n typeof isRedlineFlow === \"boolean\" ? isRedlineFlow : inferredRedlineFlow;\n const suppressHighlightBg = hasRedlineTags;\n\n // Use history as the base when redlines exist so badge matching still works.\n const shouldOverlayContent = resolvedRedlineFlow && hasRedlineTags;\n const baseContent = shouldOverlayContent\n ? stripRedlineTags(section.content)\n : section.content;\n const overlayContent = shouldOverlayContent ? section.content : undefined;\n const hasContent = ((section.displayContent ?? true) || hasRedlineTags) && hasValue(section.content);\n const isEmpty = !hasTitle && !hasContent;\n // const changeHistoryContent = section.change_history;\n // const isProposedFixTarget =\n // !!isProposingFix &&\n // !!proposingFixNodeId &&\n // columnKey === \"left\" &&\n // section.id === proposingFixNodeId;\n // const shouldOverlayContent = isProposedFixTarget && hasValue(changeHistoryContent);\n // const baseContent = shouldOverlayContent ? (changeHistoryContent || \"\") : section.content;\n // const overlayContent = shouldOverlayContent ? section.content : undefined;\n // const hasContent = (section.displayContent ?? true) && hasValue(baseContent);\n // const isEmpty = !hasTitle && !hasContent;\n\n \n\n let displayTitle = section.title;\n if (!hasTitle) {\n displayTitle = hasContent ? \"No Title Found\" : \"No Matching Section Found\";\n }\n const isMultipleMapping =\n columnKey === \"left\" &&\n (section.isMultipleMapping || (section.refContentIds?.length ?? 1) > 1);\n const visibleTitle =\n columnKey === \"left\" && displayTitle.length > 29\n ? `${displayTitle.slice(0, 29).trimEnd()}...`\n : displayTitle;\n\n let targetEvalResult = section.evaluationResult;\n if (!targetEvalResult && columnKey === \"right\") {\n if (maintainRelativeOrder) {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsSection = proposedSections.find((s: any) => s.selfIndex === lhsSelfIndex);\n targetEvalResult = lhsSection?.evaluationResult;\n } else {\n targetEvalResult = proposedSections[idx]?.evaluationResult;\n }\n }\n\n const leftDocId = treeData?.input_index_map?.[\"0\"];\n const rightDocId = treeData?.input_index_map?.[\"1\"];\n const counterPartNodeId = columnKey === \"left\" ? rightDocId : leftDocId;\n const findNodeByIdDeep = (nodes: any[], id?: string): any => {\n if (!id || !nodes) return null;\n for (const n of nodes) {\n if (n.id === id || n.nodeId === id || n.contentId === id) return n;\n if (n.subsections?.length) {\n const found = findNodeByIdDeep(n.subsections, id);\n if (found) return found;\n }\n }\n return null;\n };\n\n let popupBaseSec: any = columnKey === \"left\" ? section : findNodeByIdDeep(proposedSections, section.id);\n let popupRefSec: any = columnKey === \"right\" ? section : findNodeByIdDeep(existingSections, section.id);\n\n const sectionOffset = React.useMemo(() => {\n if (!maintainRelativeOrder) return 0;\n let min = Infinity;\n\n const normalizeInlineContent = (value: unknown) => {\n const raw = hasMeaningfulRedlineTags(value) ? stripRedlineTags(value) : value;\n return safeStringify(raw || \"\").replace(/\\\\n/g, \"\\n\");\n };\n\n const canRenderInlineHighlight = (node: SectionBlock, highlight: unknown) => {\n if (typeof highlight !== \"string\" || isMissingStr(highlight)) return false;\n const content = normalizeInlineContent(node?.content);\n const normalizedHighlight = normalizeInlineContent(highlight);\n return !!normalizedHighlight && content.includes(normalizedHighlight);\n };\n\n const traverse = (node: any, bNode: any, rNode: any, isTopLevel: boolean) => {\n if (!node) return;\n\n let topNodeId = node.nodeId || node.id;\n if (isTopLevel && columnKey === \"right\") {\n const mappedLhs = proposedSections.filter((l: any) => l.refIndexes?.includes(node.selfIndex));\n if (mappedLhs.length > 0) topNodeId = mappedLhs[0].nodeId || mappedLhs[0].id;\n }\n\n let subNodeId = node.nodeId || node.id || bNode?.nodeId || bNode?.id || rNode?.nodeId || rNode?.id;\n\n const evalResult = node.evaluationResult || bNode?.evaluationResult || rNode?.evaluationResult;\n const devs = evalResult?.deviations || {};\n Object.keys(devs).forEach(devKey => {\n const highlight = devs[devKey]?.[parentNodeId];\n const renderNode = columnKey === \"left\" ? (bNode || node) : (rNode || node);\n if (!canRenderInlineHighlight(renderNode, highlight)) return;\n\n const refId1 = `${topNodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n const idx1 = deviationNumberRegistry?.[refId1];\n if (idx1 !== undefined && idx1 !== null && idx1 < min) min = idx1;\n\n const refId2 = `${subNodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n const idx2 = deviationNumberRegistry?.[refId2];\n if (idx2 !== undefined && idx2 !== null && idx2 < min) min = idx2;\n });\n\n const subs = node.subsections || [];\n const bSubs = bNode?.subsections || [];\n const rSubs = rNode?.subsections || [];\n const maxLen = Math.max(subs.length, bSubs.length, rSubs.length);\n\n for (let i = 0; i < maxLen; i++) {\n traverse(subs[i], bSubs[i], rSubs[i], false);\n }\n };\n\n const mappedLhsSections = columnKey === \"right\"\n ? proposedSections.filter((lhs: SectionBlock) => lhs.refIndexes?.includes(section.selfIndex as number))\n : [];\n\n if (mappedLhsSections.length === 1) {\n const mappedLhs = mappedLhsSections[0] as SectionBlock;\n const mappedRhsSections = (mappedLhs.refIndexes || [])\n .map((rhsSelfIndex: number) =>\n existingSections.find((rhs: SectionBlock) => rhs.selfIndex === rhsSelfIndex),\n )\n .filter(Boolean);\n\n mappedRhsSections.forEach((rhsSection: any) => {\n traverse(rhsSection, mappedLhs, rhsSection, true);\n });\n } else {\n traverse(section, popupBaseSec, popupRefSec, true);\n }\n\n return min !== Infinity ? min - 1 : 0;\n }, [section, popupBaseSec, popupRefSec, columnKey, parentNodeId, deviationNumberRegistry, maintainRelativeOrder, proposedSections, existingSections]);\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = section.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n popupRefSec = rhsArrayIdx !== -1\n ? existingSections[rhsArrayIdx]\n : findNodeByIdDeep(existingSections, section.id);\n } else {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n popupBaseSec = lhsArrayIdx !== -1\n ? proposedSections[lhsArrayIdx]\n : findNodeByIdDeep(proposedSections, section.id);\n }\n }\n\n const isSecOrphan = columnKey === \"left\" ? !popupRefSec : !popupBaseSec;\n const hasSingleMappedLhs =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n hasSingleMappedLhsSection(section, proposedSections);\n\n const resolvedEvalResult = targetEvalResult || popupBaseSec?.evaluationResult || popupRefSec?.evaluationResult;\n const deviationColorData = resolvedEvalResult?.evaluation_outputs?.metadata?.label_color ?? DEFAULT_DEVIAION_COLOR;\n const deviationPalette = generateColorPalette(deviationColorData);\n const { highlightBg } = deviationPalette;\n const deviations = resolvedEvalResult?.deviations || {};\n\n const lhsDeviationDisplayIndexes = React.useMemo(\n () =>\n maintainRelativeOrder && columnKey === \"right\"\n ? getLhsDeviationDisplayIndexes(\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n )\n : new Map<string, number>(),\n [\n maintainRelativeOrder,\n columnKey,\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n ],\n );\n\n let nodeId = section.nodeId || section.id;\n\n // For RHS mapped sections, nodeId must match what the registry used (LHS id)\n if (maintainRelativeOrder && columnKey !== \"left\") {\n const mappedLhs = proposedSections.filter((l: any) => l.refIndexes?.includes(section.selfIndex));\n if (mappedLhs.length > 0) {\n nodeId = mappedLhs[0].nodeId || mappedLhs[0].id;\n } else if (popupBaseSec?.id) {\n nodeId = popupBaseSec.nodeId || popupBaseSec.id;\n }\n }\n\n const rhsOrphanVisualIndexes = React.useMemo(() => {\n const indexes = new Map<string, number>();\n if (!maintainRelativeOrder || columnKey !== \"right\") return indexes;\n\n let nextIndex = 1;\n const mappedLhsSections = proposedSections.filter((lhs: SectionBlock) =>\n lhs.refIndexes?.includes(section.selfIndex as number),\n );\n const isOneToOneSection =\n mappedLhsSections.length === 1 &&\n mappedLhsSections[0].refIndexes?.length === 1;\n const normalizeContent = (value: unknown) =>\n safeStringify(value || \"\").replace(/\\\\n/g, \"\\n\");\n\n const resolveNode = (rhsNode: SectionBlock, isRoot: boolean) => {\n const lhsNode = isRoot\n ? mappedLhsSections[0]\n : findNodeByIdDeep(\n proposedSections,\n rhsNode.nodeId || rhsNode.id || rhsNode.contentId,\n );\n const evalResult =\n rhsNode.evaluationResult || lhsNode?.evaluationResult;\n const registryNodeId = lhsNode\n ? lhsNode.nodeId || lhsNode.id\n : rhsNode.nodeId || rhsNode.id;\n return { lhsNode, evalResult, registryNodeId };\n };\n\n if (isOneToOneSection) {\n const reserveMappedIndexes = (rhsNode: SectionBlock | null, isRoot = false) => {\n if (!rhsNode) return;\n const { lhsNode, evalResult, registryNodeId } = resolveNode(\n rhsNode,\n isRoot,\n );\n const normalizedContent = normalizeContent(rhsNode.content);\n\n Object.entries(evalResult?.deviations || {}).forEach(\n ([deviationKey, deviationMap]: [string, any]) => {\n const highlight = deviationMap[parentNodeId];\n const normalizedHighlight = normalizeContent(highlight);\n const isMapped =\n !!lhsNode &&\n !isMissingStr(deviationMap[counterPartNodeId as string]);\n if (\n !isMapped ||\n !normalizedHighlight ||\n !normalizedContent.includes(normalizedHighlight)\n ) return;\n\n const refId = `${registryNodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n const registryIndex = deviationNumberRegistry[refId];\n if (registryIndex === undefined || registryIndex === null) return;\n nextIndex = Math.max(\n nextIndex,\n Math.max(1, registryIndex - (sectionOffset || 0)) + 1,\n );\n },\n );\n\n (rhsNode.subsections || []).forEach((child: SectionBlock) =>\n reserveMappedIndexes(child),\n );\n };\n\n reserveMappedIndexes(section, true);\n }\n\n const visit = (rhsNode: SectionBlock | null, isRoot = false) => {\n if (!rhsNode) return;\n\n const { lhsNode, evalResult, registryNodeId } = resolveNode(\n rhsNode,\n isRoot,\n );\n const nodeDeviations = evalResult?.deviations || {};\n const normalizedContent = normalizeContent(rhsNode.content);\n\n Object.entries(nodeDeviations)\n .map(([deviationKey, deviationMap]: [string, any]) => {\n const highlight = deviationMap[parentNodeId];\n const isOrphan =\n !lhsNode || isMissingStr(deviationMap[counterPartNodeId as string]);\n const normalizedHighlight = normalizeContent(highlight);\n const position = normalizedHighlight\n ? normalizedContent.indexOf(normalizedHighlight)\n : -1;\n const refId = `${registryNodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n return {\n refId,\n isRenderable:\n isOrphan && !!normalizedHighlight && !isMissingStr(highlight),\n position,\n registryIndex: deviationNumberRegistry[refId] ?? Number.MAX_SAFE_INTEGER,\n };\n })\n .filter((entry) => entry.isRenderable)\n .sort((a, b) => {\n const aPosition =\n a.position === -1 ? Number.MAX_SAFE_INTEGER : a.position;\n const bPosition =\n b.position === -1 ? Number.MAX_SAFE_INTEGER : b.position;\n return aPosition - bPosition || a.registryIndex - b.registryIndex;\n })\n .forEach((entry) => {\n indexes.set(entry.refId, nextIndex++);\n });\n\n (rhsNode.subsections || []).forEach((child: SectionBlock) => visit(child));\n };\n\n visit(section, true);\n return indexes;\n }, [\n maintainRelativeOrder,\n columnKey,\n section,\n proposedSections,\n parentNodeId,\n counterPartNodeId,\n deviationNumberRegistry,\n sectionOffset,\n ]);\n\n // Derive validatedParentNum from registry\n const firstDeviationKey = Object.keys(deviations)[0];\n const firstRefId = firstDeviationKey ? `${nodeId}${DEVIATION_BADGE_SEPARATOR}${firstDeviationKey}` : null;\n const registeredParentNum = firstRefId ? (deviationParentRegistry?.[firstRefId] as number) : null;\n\n let validatedParentNum: string | number = idx + 1;\n\n if (maintainRelativeOrder && unifiedNumbering) {\n const unifiedNum = columnKey === \"left\" \n ? unifiedNumbering.leftNums.get(section?.id as string) \n : unifiedNumbering.rightNums.get(section?.id as string);\n \n if (isSecOrphan && unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n } else if (unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n }\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n }\n // const deviationNodeIdRef = useRef<string | undefined>(deviationNodeIdToView);\n // const deviationNodeParentRef = useRef<string | null>(deviationTargetParentId || null);\n const highlights: string[] = [];\n // Mapp through deviations to pass to memoized markdown for highlighting, also prepare deviation badges \n const rawDeviationEntries = Object.entries(deviations).map(([deviationKey, deviationMap]: [string, any]) => {\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n const currentIndex = deviationNumberRegistry[refId];\n return { deviationKey, deviationMap, refId, currentIndex };\n }).filter(item => item.currentIndex !== undefined && item.currentIndex !== null);\n\n // Sort by global index BEFORE mapping to prevent negative/zero offsets\n rawDeviationEntries.sort((a, b) => a.currentIndex - b.currentIndex);\n\n const deviationEntries = rawDeviationEntries.map((item) => {\n const { deviationKey, deviationMap, refId } = item;\n let currentIndex = item.currentIndex;\n\n let highlight = deviationMap[parentNodeId];\n const isMissingClause = isMissingStr(highlight);\n\n if (isMissingClause) {\n highlight = \"\"; \n } else if (!highlight) {\n return null; \n }\n\n highlights.push(highlight);\n\n // MAPPING Stricter Left/Right Index mapping to prevent cross-wiring\n let leftIdx = idx;\n let rightIdx = idx;\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = section.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n if (rhsArrayIdx !== -1) {\n rightIdx = rhsArrayIdx;\n } else {\n const rhsByIdIdx = existingSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n rightIdx = rhsByIdIdx !== -1 ? rhsByIdIdx : idx;\n }\n } else {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (lhsArrayIdx !== -1) {\n leftIdx = lhsArrayIdx;\n } else {\n const lhsByIdIdx = proposedSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n leftIdx = lhsByIdIdx !== -1 ? lhsByIdIdx : idx;\n }\n }\n }\n\n const actionId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}${DEVIATION_BADGE_SEPARATOR}${leftIdx}${DEVIATION_BADGE_SEPARATOR}${rightIdx}`;\n \n // CONTENT Use the calculated mapped indices to grab correct counterpart text\n // const counterPartContentRaw = columnKey === \"left\" ? existingSections[rightIdx]?.content : proposedSections[leftIdx]?.content;\n const counterpartHighlight = deviationMap[counterPartNodeId as string];\n \n // Commented Out code for removing the highlight swallowing logic\n // let simulatedContent = safeStringify(counterPartContentRaw);\n\n // const counterPartHighlight = Object.keys(deviations)\n // .map(key => ({ key, text: deviations[key][counterPartNodeId as string] }))\n // .filter(item => !isMissingStr(item.text))\n // .sort((a, b) => b.text.length - a.text.length);\n\n // const survivingKeys = new Set();\n // counterPartHighlight.forEach(item => {\n // const clean = item.text.replace(/\\\\(['’])/g, \"$1\").replace(/\\\\n/g, \"\\n\");\n // if(!clean) return;\n\n // const regex = new RegExp(escapeRegExp(clean));\n // if(regex.test(simulatedContent)){\n // survivingKeys.add(item.key);\n // simulatedContent = simulatedContent.replace(regex, `__TOKEN_${item.key}__`);\n // }\n // });\n\n // const isCounterPartOverlapping = !isMissingStr(counterpartHighlight) && !survivingKeys.has(deviationKey);\n\n const isDeviationOrphan = isSecOrphan || isMissingStr(counterpartHighlight);\n const orphanVisualIndex = rhsOrphanVisualIndexes.get(refId);\n const mappedLhsIndex = lhsDeviationDisplayIndexes.get(refId);\n if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n orphanVisualIndex !== undefined\n ) {\n currentIndex = orphanVisualIndex;\n } else if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n !isDeviationOrphan &&\n mappedLhsIndex !== undefined\n ) {\n currentIndex = mappedLhsIndex;\n } else if (\n maintainRelativeOrder &&\n sectionOffset !== undefined &&\n (columnKey !== \"right\" || isDeviationOrphan || hasSingleMappedLhs)\n ) {\n currentIndex = currentIndex - sectionOffset;\n }\n currentIndex = Math.max(1, currentIndex);\n\n const badgeParentNum =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n unifiedNumbering\n ? getRhsMappedSectionNumber({\n section,\n proposedSections,\n leftNums: unifiedNumbering.leftNums,\n fallbackNumber: String(validatedParentNum),\n firstOnly: true,\n })\n : validatedParentNum;\n const badgeLabel = `${badgeParentNum}.${currentIndex}`;\n\n let mappedIdx = idx;\n if (columnKey === \"right\" && maintainRelativeOrder) {\n const lhsSelfIndex = section.refIndexes?.[0];\n const actualLhsIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (actualLhsIdx !== -1) {\n mappedIdx = actualLhsIdx;\n } else {\n const lhsByIdIdx = proposedSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n if (lhsByIdIdx !== -1) mappedIdx = lhsByIdIdx;\n }\n }\n const baseStyle = getSectionCompareStyle ? getSectionCompareStyle(mappedIdx) : null;\n \n // let isUIOverlapping = false;\n // if (highlight) {\n // const allHighlights = Object.values(deviations).map((d: any) => d[parentNodeId as string]).filter(Boolean);\n // isUIOverlapping = allHighlights.some((otherHl: any) => otherHl.length > highlight.length && otherHl.includes(highlight));\n // }\n\n const deviationOutput = deviationMap?.evaluation_outputs || resolvedEvalResult?.evaluation_outputs;\n const deviationScore = deviationOutput?.output_value ?? null;\n const deviationColorForBadge = deviationOutput?.metadata?.label_color ?? deviationColorData;\n const deviationPaletteForBadge = generateColorPalette(deviationColorForBadge);\n let badgeStyle = baseStyle\n ? {\n ...baseStyle,\n badgeBg: deviationPaletteForBadge.badgeBg,\n badgeBorder: deviationPaletteForBadge.badgeBorder,\n badgeText: deviationPaletteForBadge.badgeText,\n }\n : { ...deviationPaletteForBadge };\n\n // if (isUIOverlapping) {\n // badgeStyle.badgeBg = \"#FFFBEB\";\n // badgeStyle.badgeBorder = \"#FCD34D\";\n // badgeStyle.badgeText = \"#B45309\";\n // badgeStyle.highlightBg = \"#FDE68A\";\n // }\n\n const summaryPayload = deviationMap?.deviation_summary\n ? {\n deviation_summary: deviationMap.deviation_summary,\n deviation_title: deviationMap?.deviation_title || resolvedEvalResult?.deviation_title,\n deviation_impact: deviationMap?.deviation_impact || resolvedEvalResult?.deviation_impact,\n deviation_explanation:\n deviationMap?.deviation_explanation || resolvedEvalResult?.deviation_explanation,\n evaluation_outputs: deviationOutput,\n cognitive_decisioning:\n deviationMap?.cognitive_decisioning || resolvedEvalResult?.cognitive_decisioning,\n }\n : null;\n\n // Logic for overlapping highlight badges\n let stackIndex = 0;\n const contentStr = baseContent || \"\";\n if (highlight && contentStr) {\n const paragraphs = contentStr.split(/\\n{2,}/);\n const paraIndex = paragraphs.findIndex(p => p.includes(highlight));\n if (paraIndex !== -1) {\n const devsInPara = Object.entries(deviations)\n .filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && paragraphs[paraIndex].includes(hl);\n })\n .sort((a: any, b: any) => paragraphs[paraIndex].indexOf(a[1][parentNodeId]) - paragraphs[paraIndex].indexOf(b[1][parentNodeId]));\n const overlappingDevs = devsInPara.filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && (hl.includes(highlight) || highlight.includes(hl));\n });\n if (overlappingDevs.length > 1) {\n stackIndex = Math.max(0, overlappingDevs.findIndex(([k]) => k === deviationKey));\n }\n }\n }\n const badgeRef = getBadgeRef(columnKey, refId);\n\n return {\n id: refId,\n actionId: actionId,\n label: badgeLabel,\n highlight,\n side: columnKey,\n style: badgeStyle,\n stackIndex,\n score: deviationScore,\n isConnected: connectedSections?.has(actionId),\n showScrollLockToggle:\n connectedSections?.has(actionId) ||\n (isSideBySide && activeSideBySideSection === actionId) ||\n (!!summaryPopupAnchorEl && summaryPopupAnchorEl === badgeRef.current),\n scrollSyncLocked,\n toggleScrollSyncLocked,\n isOrphan: isDeviationOrphan,\n isMissingClause,\n badgeRef,\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n\n if (openMoreFunctionsPopup) {\n openMoreFunctionsPopup(\n e as any, \n popupBaseSec || { id: \"orphan-left\", title: \"\", content: \"\" }, \n isDeviationOrphan, \n popupRefSec || { id: \"orphan-right\", title: \"\", content: \"\" }, \n actionId as any, \n badgeStyle as StyleVariant | null\n );\n }\n },\n\n onSummaryClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n openSummaryPopup(e, actionId, isDeviationOrphan, summaryPayload);\n },\n };\n }).filter(Boolean);\n const baseShouldRenderBadges =\n showDeviationBadges || (!resolvedRedlineFlow && isProposedFixTarget);\n const shouldRenderBadges = baseShouldRenderBadges;\n const deviationBadgesToRender = shouldRenderBadges ? deviationEntries : [];\n\n // NEW: Sync highlights to prevent ghost highlights\n const highlightsToRender = deviationEntries.map((b: any) => b.highlight).filter(Boolean)\n\n const show =\n section.id && columnKey === navigation?.columnKey ? navigation : null;\n\n // Local ref added to prevent race conditions\n const hasScrolledRef = React.useRef(false);\n\n // Reset scroll flag when section closed\n useEffect(() => {\n if (!isExpanded) {\n hasScrolledRef.current = false;\n }\n }, [isExpanded]);\n // useEffect(()=>{\n // deviationNodeIdRef.current = deviationNodeIdToView;\n // deviationNodeParentRef.current = deviationTargetParentId || null;\n // }, [deviationNodeIdToView, deviationTargetParentId]);\n\n // Commented out the auto scroll functionality which was breaking the LSC -> RHS opening\n // useEffect(() => {\n // const isDeviationTargetSection =\n // !!deviationNodeIdRef.current &&\n // !!deviationNodeParentRef.current &&\n // nodeId === deviationNodeParentRef.current;\n // // NEW CONDITION: Check if the deviation target is one of the direct subsections\n // const isTargetInSubsections =\n // !!deviationNodeIdRef.current &&\n // (section.subsections || []).some(\n // (sub) => sub.id === deviationNodeIdRef.current\n // );\n\n // // Abort scroll if it's already scrolled, not expanded, is the target section, \n // // OR if the target is inside its subsections\n // if (\n // !isExpanded ||\n // hasScrolledRef.current ||\n // isDeviationTargetSection ||\n // isTargetInSubsections\n // ) {\n // return;\n // }\n\n // const timer = setTimeout(() => {\n // const firstDeviationEl = show?.firstDeviationRef?.current;\n // const firstDeviationPosition = show?.firstDeviationPosition;\n\n // if (!firstDeviationEl) {\n // hasScrolledRef.current = true;\n // return;\n // }\n\n // if (\n // firstDeviationPosition === \"inside\" ||\n // isElementVisibleInScrollParent(firstDeviationEl)\n // ) {\n // hasScrolledRef.current = true;\n // return;\n // }\n\n // hasScrolledRef.current = true;\n // firstDeviationEl.scrollIntoView({\n // behavior: \"smooth\",\n // block: \"center\",\n // });\n // }, 600);\n\n // return () => clearTimeout(timer);\n // }, [\n // isExpanded,\n // nodeId,\n // show?.firstDeviationPosition,\n // show?.firstDeviationRef,\n // ]);\n \n return (\n <Box\n key={`${columnKey}-sec-${idx}`}\n ref={colRef}\n sx={{\n mb,\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n position: \"relative\",\n minWidth: 0,\n }}\n >\n {isExpanded && show?.showAbove && (\n <div\n style={{\n position: \"sticky\",\n top: 0,\n height: \"0px\",\n cursor: \"pointer\",\n }}\n onClick={() =>\n show?.showAboveRef?.current?.scrollIntoView({\n behavior: \"smooth\" as ScrollBehavior,\n block: \"center\",\n })\n }\n >\n <div\n style={{\n transform: `translateY(-50%) translateX(calc(100% ${\n columnKey === \"left\" ? \"+\" : \"-\"\n } 130px))`,\n position: \"absolute\",\n paddingTop: \"20px\",\n ...(columnKey === \"left\" ? {right: \"-20px\"} : {left: \"-20px\"}),\n }}\n >\n <ChevronUp\n color={\n show?.showAboveRef?.current\n ? window.getComputedStyle(show.showAboveRef.current).color\n : undefined\n }\n />\n </div>\n </div>\n )}\n <Accordion\n disableGutters\n expanded={isEmpty ? false : isExpanded}\n onChange={() => {\n if (!isEmpty) {\n onToggle();\n showOpenNodeRef.current = section.id;\n }\n }}\n sx={{\n boxShadow: \"none\",\n border: isEmpty ? \"1px dashed #E2E8F0\" : \"1px solid #E2E8F0\",\n bgcolor: isEmpty ? \"#FAFAFA\" : \"#FFFFFF\",\n borderRadius: \"6px\",\n flexGrow: 1,\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n minWidth: 0,\n \"&:before\": { display: \"none\" },\n \"& .MuiAccordion-heading\": {\n position: \"sticky\",\n top: -12,\n zIndex: 10,\n background: \"#fff\",\n },\n }}\n >\n <AccordionSummary\n expandIcon={isEmpty ? null : <ChevronDown size={16} />}\n sx={{\n minHeight: \"36px\",\n flexShrink: 0,\n cursor: isEmpty ? \"default\" : \"pointer\",\n \"& .MuiAccordionSummary-content\": {\n my: 0.5,\n display: \"grid\",\n alignItems: \"center\",\n minWidth: 0,\n width: \"100%\",\n },\n \"& .MuiAccordionSummary-expandIconWrapper\": {\n transition: \"transform 0.2s ease\",\n },\n \"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded\": {\n transform: \"rotate(180deg)\",\n },\n }}\n >\n {hasTitle && (\n <Tooltip title={displayTitle} placement=\"top\">\n <Typography\n component=\"div\"\n sx={{\n fontSize: \"12px\",\n color: isEmpty ? \"#94A3B8\" : \"#19213D\",\n fontWeight: isEmpty ? 400 : 700,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n width: \"100%\",\n minWidth: 0,\n }}\n >\n {renderSimpleMarkdown(visibleTitle, isMultipleMapping)}\n </Typography>\n </Tooltip>\n )}\n </AccordionSummary>\n {!isEmpty && (\n <AccordionDetails\n sx={{\n pt: 0,\n pb: 1.25,\n bgcolor: \"#FFFFFF\",\n flex: 1,\n display: \"flex\",\n flexDirection: \"column\",\n minWidth: 0,\n }}\n >\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n sxStyles={resolvedMarkdownStyles}\n highlights={highlightsToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n deviationBadges={deviationBadgesToRender}\n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) =>\n renderSubSectionAccordion({\n section: sub,\n keyPath: `${idx}-${subIdx}`,\n depth: 0,\n columnKey,\n parentNodeId,\n sectionOffset,\n rhsOrphanVisualIndexes,\n }),\n )}\n </AccordionDetails>\n )}\n </Accordion>\n {isExpanded && show?.showBelow && (\n <div\n style={{\n position: \"sticky\",\n bottom: 0,\n height: \"0px\",\n cursor: \"pointer\",\n }}\n onClick={() =>\n show?.showBelowRef?.current?.scrollIntoView({\n behavior: \"smooth\" as ScrollBehavior,\n block: \"center\",\n })\n }\n >\n <div\n style={{\n transform: `translateY(-50%) translateX(calc(100% ${\n columnKey === \"left\" ? \"+\" : \"-\"\n } 130px))`,\n position: \"absolute\",\n paddingBottom: \"20px\",\n ...(columnKey === \"left\" ? {right: \"-20px\"} : {left: \"-20px\"}),\n }}\n >\n <ChevronDown\n color={\n show?.showBelowRef?.current\n ? window.getComputedStyle(show.showBelowRef.current).color\n : undefined\n }\n />\n </div>\n </div>\n )}\n </Box>\n );\n};\n\nexport default SectionAccordion;\n"],"names":["renderSimpleMarkdown","text","isMultiTag","safeStringify","replace","split","map","part","i","startsWith","endsWith","children","slice","jsxs","style","display","alignItems","justifyContent","gap","width","jsx","minWidth","overflow","textOverflow","whiteSpace","padding","borderRadius","background","border","color","fontSize","fontWeight","flexShrink","lineHeight","marginRight","section","idx","columnKey","colRef","mb","isExpanded","onToggle","navigation","parentNodeId","showOpenNodeRef","resolvedMarkdownStyles","maintainRelativeOrder","showDeviationBadges","renderSubSectionAccordion","treeData","proposedSections","existingSections","deviationNumberRegistry","deviationParentRegistry","getBadgeRef","openSummaryPopup","getSectionCompareStyle","connectedSections","openMoreFunctionsPopup","isProposingFix","proposingFixNodeId","isRedlineFlow","isSideBySide","activeSideBySideSection","scrollSyncLocked","unifiedNumbering","toggleScrollSyncLocked","summaryPopupAnchorEl","useCompareContext","collisionKey","String","hasTitle","displayTitle","hasValue","title","isProposedFixTarget","id","nodeId","hasRedlineTags","hasMeaningfulRedlineTags","content","resolvedRedlineFlow","suppressHighlightBg","shouldOverlayContent","baseContent","stripRedlineTags","overlayContent","hasContent","displayContent","isEmpty","isMultipleMapping","refContentIds","length","visibleTitle","trimEnd","targetEvalResult","evaluationResult","lhsSelfIndex","refIndexes","lhsSection","find","s","selfIndex","leftDocId","input_index_map","rightDocId","counterPartNodeId","findNodeByIdDeep","nodes","n","contentId","subsections","found","popupBaseSec","popupRefSec","sectionOffset","React","useMemo","min","Infinity","normalizeInlineContent","value","raw","traverse","node","bNode","rNode","isTopLevel","topNodeId","mappedLhs","filter","l","includes","subNodeId","evalResult","devs","deviations","Object","keys","forEach","devKey","highlight","isMissingStr","normalizedHighlight","canRenderInlineHighlight","refId1","DEVIATION_BADGE_SEPARATOR","idx1","refId2","idx2","subs","bSubs","rSubs","maxLen","Math","max","mappedLhsSections","lhs","rhsSelfIndex","rhs","Boolean","rhsSection","rhsArrayIdx","findIndex","lhsArrayIdx","isSecOrphan","hasSingleMappedLhs","hasSingleMappedLhsSection","resolvedEvalResult","deviationColorData","evaluation_outputs","metadata","label_color","DEFAULT_DEVIAION_COLOR","deviationPalette","generateColorPalette","highlightBg","lhsDeviationDisplayIndexes","getLhsDeviationDisplayIndexes","Map","rhsOrphanVisualIndexes","indexes","nextIndex","isOneToOneSection","normalizeContent","resolveNode","rhsNode","isRoot","lhsNode","registryNodeId","reserveMappedIndexes","normalizedContent","entries","deviationKey","deviationMap","refId","registryIndex","child","visit","nodeDeviations","isOrphan","position","indexOf","isRenderable","Number","MAX_SAFE_INTEGER","entry","sort","a","b","set","firstDeviationKey","firstRefId","registeredParentNum","validatedParentNum","unifiedNum","leftNums","get","rightNums","rawDeviationEntries","currentIndex","item","deviationEntries","isMissingClause","leftIdx","rightIdx","rhsByIdIdx","lhsByIdIdx","actionId","counterpartHighlight","isDeviationOrphan","orphanVisualIndex","mappedLhsIndex","badgeLabel","getRhsMappedSectionNumber","fallbackNumber","firstOnly","mappedIdx","actualLhsIdx","baseStyle","deviationOutput","deviationScore","output_value","deviationColorForBadge","deviationPaletteForBadge","badgeStyle","badgeBg","badgeBorder","badgeText","summaryPayload","deviation_summary","deviation_title","deviation_impact","deviation_explanation","cognitive_decisioning","stackIndex","contentStr","paragraphs","paraIndex","p","overlappingDevs","_","dMap","hl","k","badgeRef","label","side","score","isConnected","has","showScrollLockToggle","current","onClick","e","stopPropagation","onSummaryClick","deviationBadgesToRender","highlightsToRender","show","hasScrolledRef","useRef","useEffect","Box","ref","sx","flexDirection","showAbove","top","height","cursor","showAboveRef","scrollIntoView","behavior","block","transform","paddingTop","right","left","ChevronUp","window","getComputedStyle","Accordion","disableGutters","expanded","onChange","boxShadow","bgcolor","flexGrow","zIndex","AccordionSummary","expandIcon","ChevronDown","size","minHeight","my","transition","Tooltip","placement","Typography","component","AccordionDetails","pt","pb","flex","MemoizedMarkdown","sxStyles","highlights","deviationBadges","sub","subIdx","keyPath","depth","showBelow","bottom","showBelowRef","paddingBottom"],"mappings":"saA6BA,MAAMA,EAAuB,CAACC,EAAcC,GAAa,KACnD,IAACD,EAAa,OAAA,KAKlB,OAHuBE,EAAAA,cAAcF,GAAMG,QAAQ,OAAQ,MAC9BC,MAAM,kBAEtBC,IAAI,CAACC,EAAcC,IAC1BD,EAAKE,WAAW,OAASF,EAAKG,SAAS,YACjC,SAAgB,CAAAC,SAAAJ,EAAKK,MAAM,GAAG,IAAlBJ,GAIpBK,EAAAA,KAAC,MAAA,CAECC,MAAO,CACLC,QAAS,OACTC,WAAY,SACZC,eAAgB,gBAChBC,IAAK,MACLC,MAAO,QAGTR,SAAA,CAAAS,EAAAA,IAAC,OAAA,CACCN,MAAO,CACLO,SAAU,EACVC,SAAU,SACVC,aAAc,WACdC,WAAY,UAGbb,SAAAJ,IAGFL,GACCkB,EAAAA,IAAC,OAAA,CACCN,MAAO,CACLC,QAAS,cACTC,WAAY,SACZC,eAAgB,SAChBQ,QAAS,UACTC,aAAc,SACdC,WAAY,UACZC,OAAQ,oBACRC,MAAO,UACPC,SAAU,MACVC,WAAY,IACZP,WAAY,SACZQ,WAAY,EACZC,WAAY,IACZC,YAAa,OAEhBvB,SAAA,eAtCEH,qBAsFY,EACvB2B,UACAC,MACAC,YACAC,SACAC,KAAK,EACLC,aACAC,WACAC,aACAC,eAAe,OAET,MAAAC,gBACJA,EAAAC,uBACAA,EAAAC,sBACAA,EAAAC,oBACAA,GAAsB,EAAAC,0BACtBA,EAAAC,SACAA,EAAAC,iBACAA,EAAAC,iBACAA,EAAAC,wBACAA,EAAAC,wBACAA,EAAAC,YACAA,EAAAC,iBACAA,EAAAC,uBACAA,EAAAC,kBACAA,EAAAC,uBACAA,EAAAC,eACAA,EAAAC,mBACAA,EAAAC,cACAA,EAAA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AiBD"}
1
+ {"version":3,"file":"SectionAccordion.js","sources":["../../../../../src/features/CognitiveCompare/components/SectionAccordion.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Box,\n Tooltip,\n Typography,\n} from \"@mui/material\";\nimport { ChevronDown, ChevronUp } from \"lucide-react\";\nimport { MemoizedMarkdown } from \"../hooks/memoizedMarkdown\";\nimport { useCompareContext } from \"../CompareContext\";\nimport { \n generateColorPalette, \n hasValue, \n safeStringify,\n DEVIATION_BADGE_SEPARATOR,\n isMissingStr,\n escapeRegExp,\n hasMeaningfulRedlineTags,\n stripRedlineTags,\n findTextMatchRange,\n getRhsMappedSectionNumber,\n hasSingleMappedLhsSection,\n getLhsDeviationDisplayIndexes,\n} from \"../CognitiveComparehelpers\";\nimport { findTextRangeWithFormatting } from \"../utils/normalizeInlineMarkdown\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport { DeviationDataEntry, SectionBlock, StyleVariant } from \"../CognitiveCompareTypes\";\nimport { DeviationNavigationEntry } from \"../hooks/useDeviationNavigation\";\nimport { normalizeRedlineMarkdown } from \"../utils/normalizeRedlineMarkdown\";\n\nconst renderSimpleMarkdown = (text: string, isMultiTag = false) => {\n if (!text) return null;\n\n const normalizedText = safeStringify(text).replace(/\\\\n/g, \"\\n\");\n const parts = normalizedText.split(/(\\*\\*.*?\\*\\*)/g);\n\n return parts.map((part: string, i: number) => {\n if (part.startsWith(\"**\") && part.endsWith(\"**\")) {\n return <strong key={i}>{part.slice(2, -2)}</strong>;\n }\n\n return (\n <div\n key={i}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n gap: \"8px\",\n width: \"100%\",\n }}\n >\n <span\n style={{\n minWidth: 0,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }}\n >\n {part}\n </span>\n\n {isMultiTag && (\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: \"0px 6px\",\n borderRadius: \"9999px\",\n background: \"#F3F4F6\",\n border: \"1px solid #D1D5DB\",\n color: \"#6B7280\",\n fontSize: \"9px\",\n fontWeight: 500,\n whiteSpace: \"nowrap\",\n flexShrink: 0,\n lineHeight: 1.4,\n marginRight: \"4px\",\n }}\n >\n Multiple\n </span>\n )}\n </div>\n );\n });\n};\n\nconst findScrollParent = (element: HTMLElement | null): HTMLElement | null => {\n let current = element?.parentElement || null;\n while (current) {\n const style = window.getComputedStyle(current);\n const overflowY = style.overflowY;\n const canScroll =\n (overflowY === \"auto\" || overflowY === \"scroll\") &&\n current.scrollHeight > current.clientHeight;\n\n if (canScroll) return current;\n current = current.parentElement;\n }\n\n return null;\n};\n\nconst isElementVisibleInScrollParent = (element: HTMLElement) => {\n const scrollParent = findScrollParent(element);\n const rect = element.getBoundingClientRect();\n const parentRect = scrollParent?.getBoundingClientRect() || {\n top: 0,\n bottom: window.innerHeight,\n };\n\n return rect.top >= parentRect.top && rect.bottom <= parentRect.bottom;\n};\n\ntype SectionAccordionProps = {\n section: SectionBlock;\n idx: number;\n columnKey: \"left\" | \"right\";\n colRef: React.RefObject<HTMLDivElement>;\n mb?: number;\n parentNodeId?: string;\n isExpanded: boolean;\n onToggle: () => void;\n navigation: DeviationNavigationEntry | null;\n};\n\nconst SectionAccordion = ({\n section,\n idx,\n columnKey,\n colRef,\n mb = 1,\n isExpanded,\n onToggle,\n navigation,\n parentNodeId = \"\",\n}: SectionAccordionProps) => {\n const {\n showOpenNodeRef,\n resolvedMarkdownStyles,\n maintainRelativeOrder,\n showDeviationBadges = false,\n renderSubSectionAccordion,\n treeData,\n proposedSections,\n existingSections,\n deviationNumberRegistry,\n deviationParentRegistry,\n getBadgeRef,\n openSummaryPopup,\n getSectionCompareStyle,\n connectedSections,\n openMoreFunctionsPopup,\n isProposingFix,\n proposingFixNodeId,\n isRedlineFlow,\n isSideBySide,\n activeSideBySideSection,\n scrollSyncLocked,\n unifiedNumbering,\n toggleScrollSyncLocked,\n summaryPopupAnchorEl,\n } = useCompareContext();\n const collisionKey = `${isSideBySide ? \"1\" : \"0\"}-${String(activeSideBySideSection ?? \"\")}`;\n const hasTitle = (section.displayTitle ?? true) && hasValue(section.title);\n const isProposedFixTarget =\n !!isProposingFix &&\n !!proposingFixNodeId &&\n columnKey === \"left\" &&\n (section.id === proposingFixNodeId ||\n section.nodeId === proposingFixNodeId ||\n section.contentId === proposingFixNodeId);\n \n const hasRedlineTags = hasMeaningfulRedlineTags(section.content);\n const inferredRedlineFlow = hasRedlineTags;\n const resolvedRedlineFlow =\n typeof isRedlineFlow === \"boolean\" ? isRedlineFlow : inferredRedlineFlow;\n const suppressHighlightBg = hasRedlineTags;\n const changeHistoryContent = section.change_history;\n\n // Use all visible redline text as the base so changed-only highlights can match.\n const shouldOverlayContent = resolvedRedlineFlow && hasRedlineTags;\n const normalizedRedlineContent = React.useMemo(\n () => shouldOverlayContent\n ? normalizeRedlineMarkdown(safeStringify(section.content))\n : safeStringify(section.content),\n [section.content, shouldOverlayContent],\n );\n const baseContent = shouldOverlayContent\n ? stripRedlineTags(normalizedRedlineContent)\n : section.content;\n const overlayContent = shouldOverlayContent ? normalizedRedlineContent : undefined;\n const fallbackContent =\n hasRedlineTags && hasValue(changeHistoryContent)\n ? safeStringify(changeHistoryContent)\n : undefined;\n const hasContent = ((section.displayContent ?? true) || hasRedlineTags) && hasValue(section.content);\n const isEmpty = !hasTitle && !hasContent;\n\n \n\n let displayTitle = section.title;\n if (!hasTitle) {\n displayTitle = hasContent ? \"No Title Found\" : \"No Matching Section Found\";\n }\n const isMultipleMapping =\n columnKey === \"left\" &&\n (section.isMultipleMapping || (section.refContentIds?.length ?? 1) > 1);\n const visibleTitle =\n columnKey === \"left\" && displayTitle.length > 29\n ? `${displayTitle.slice(0, 29).trimEnd()}...`\n : displayTitle;\n\n let targetEvalResult = section.evaluationResult;\n if (!targetEvalResult && columnKey === \"right\") {\n if (maintainRelativeOrder) {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsSection = proposedSections.find((s: any) => s.selfIndex === lhsSelfIndex);\n targetEvalResult = lhsSection?.evaluationResult;\n } else {\n targetEvalResult = proposedSections[idx]?.evaluationResult;\n }\n }\n\n const leftDocId = treeData?.input_index_map?.[\"0\"];\n const rightDocId = treeData?.input_index_map?.[\"1\"];\n const counterPartNodeId = columnKey === \"left\" ? rightDocId : leftDocId;\n const findNodeByIdDeep = (nodes: any[], id?: string): any => {\n if (!id || !nodes) return null;\n for (const n of nodes) {\n if (n.id === id || n.nodeId === id || n.contentId === id) return n;\n if (n.subsections?.length) {\n const found = findNodeByIdDeep(n.subsections, id);\n if (found) return found;\n }\n }\n return null;\n };\n\n let popupBaseSec: any = columnKey === \"left\" ? section : findNodeByIdDeep(proposedSections, section.id);\n let popupRefSec: any = columnKey === \"right\" ? section : findNodeByIdDeep(existingSections, section.id);\n\n const sectionOffset = React.useMemo(() => {\n if (!maintainRelativeOrder) return 0;\n let min = Infinity;\n\n const normalizeInlineContent = (value: unknown) => {\n const raw = safeStringify(value || \"\").replace(/\\\\n/g, \"\\n\");\n return hasMeaningfulRedlineTags(raw)\n ? stripRedlineTags(normalizeRedlineMarkdown(raw))\n : raw;\n };\n\n const canRenderInlineHighlight = (node: SectionBlock, highlight: unknown) => {\n if (typeof highlight !== \"string\" || isMissingStr(highlight)) return false;\n const content = normalizeInlineContent(node?.content);\n const normalizedHighlight = normalizeInlineContent(highlight);\n return !!normalizedHighlight && !!findTextMatchRange(content, normalizedHighlight);\n };\n\n const traverse = (node: any, bNode: any, rNode: any, isTopLevel: boolean) => {\n if (!node) return;\n\n let topNodeId = node.nodeId || node.id;\n if (isTopLevel && columnKey === \"right\") {\n const mappedLhs = proposedSections.filter((l: any) => l.refIndexes?.includes(node.selfIndex));\n if (mappedLhs.length > 0) topNodeId = mappedLhs[0].nodeId || mappedLhs[0].id;\n }\n\n let subNodeId = node.nodeId || node.id || bNode?.nodeId || bNode?.id || rNode?.nodeId || rNode?.id;\n\n const evalResult = node.evaluationResult || bNode?.evaluationResult || rNode?.evaluationResult;\n const devs = evalResult?.deviations || {};\n Object.keys(devs).forEach(devKey => {\n const highlight = devs[devKey]?.[parentNodeId];\n const renderNode = columnKey === \"left\" ? (bNode || node) : (rNode || node);\n if (!canRenderInlineHighlight(renderNode, highlight)) return;\n\n const refId1 = `${topNodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n const idx1 = deviationNumberRegistry?.[refId1];\n if (idx1 !== undefined && idx1 !== null && idx1 < min) min = idx1;\n\n const refId2 = `${subNodeId}${DEVIATION_BADGE_SEPARATOR}${devKey}`;\n const idx2 = deviationNumberRegistry?.[refId2];\n if (idx2 !== undefined && idx2 !== null && idx2 < min) min = idx2;\n });\n\n const subs = node.subsections || [];\n const bSubs = bNode?.subsections || [];\n const rSubs = rNode?.subsections || [];\n const maxLen = Math.max(subs.length, bSubs.length, rSubs.length);\n\n for (let i = 0; i < maxLen; i++) {\n traverse(subs[i], bSubs[i], rSubs[i], false);\n }\n };\n\n const mappedLhsSections = columnKey === \"right\"\n ? proposedSections.filter((lhs: SectionBlock) => lhs.refIndexes?.includes(section.selfIndex as number))\n : [];\n\n if (mappedLhsSections.length === 1) {\n const mappedLhs = mappedLhsSections[0] as SectionBlock;\n const mappedRhsSections = (mappedLhs.refIndexes || [])\n .map((rhsSelfIndex: number) =>\n existingSections.find((rhs: SectionBlock) => rhs.selfIndex === rhsSelfIndex),\n )\n .filter(Boolean);\n\n mappedRhsSections.forEach((rhsSection: any) => {\n traverse(rhsSection, mappedLhs, rhsSection, true);\n });\n } else {\n traverse(section, popupBaseSec, popupRefSec, true);\n }\n\n return min !== Infinity ? min - 1 : 0;\n }, [section, popupBaseSec, popupRefSec, columnKey, parentNodeId, deviationNumberRegistry, maintainRelativeOrder, proposedSections, existingSections]);\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = section.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n popupRefSec = rhsArrayIdx !== -1\n ? existingSections[rhsArrayIdx]\n : findNodeByIdDeep(existingSections, section.id);\n } else {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n popupBaseSec = lhsArrayIdx !== -1\n ? proposedSections[lhsArrayIdx]\n : findNodeByIdDeep(proposedSections, section.id);\n }\n }\n\n const isSecOrphan = columnKey === \"left\" ? !popupRefSec : !popupBaseSec;\n const hasSingleMappedLhs =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n hasSingleMappedLhsSection(section, proposedSections);\n\n const resolvedEvalResult = targetEvalResult || popupBaseSec?.evaluationResult || popupRefSec?.evaluationResult;\n const deviationColorData = resolvedEvalResult?.evaluation_outputs?.metadata?.label_color ?? DEFAULT_DEVIAION_COLOR;\n const deviationPalette = generateColorPalette(deviationColorData);\n const { highlightBg } = deviationPalette;\n const deviations = resolvedEvalResult?.deviations || {};\n\n const lhsDeviationDisplayIndexes = React.useMemo(\n () =>\n maintainRelativeOrder && columnKey === \"right\"\n ? getLhsDeviationDisplayIndexes(\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n )\n : new Map<string, number>(),\n [\n maintainRelativeOrder,\n columnKey,\n proposedSections,\n leftDocId,\n deviationNumberRegistry,\n ],\n );\n\n let nodeId = section.nodeId || section.id;\n\n // For RHS mapped sections, nodeId must match what the registry used (LHS id)\n if (maintainRelativeOrder && columnKey !== \"left\") {\n const mappedLhs = proposedSections.filter((l: any) => l.refIndexes?.includes(section.selfIndex));\n if (mappedLhs.length > 0) {\n nodeId = mappedLhs[0].nodeId || mappedLhs[0].id;\n } else if (popupBaseSec?.id) {\n nodeId = popupBaseSec.nodeId || popupBaseSec.id;\n }\n }\n\n const rhsOrphanVisualIndexes = React.useMemo(() => {\n const indexes = new Map<string, number>();\n if (!maintainRelativeOrder || columnKey !== \"right\") return indexes;\n\n let nextIndex = 1;\n const mappedLhsSections = proposedSections.filter((lhs: SectionBlock) =>\n lhs.refIndexes?.includes(section.selfIndex as number),\n );\n const isOneToOneSection =\n mappedLhsSections.length === 1 &&\n mappedLhsSections[0].refIndexes?.length === 1;\n const normalizeContent = (value: unknown) =>\n safeStringify(value || \"\").replace(/\\\\n/g, \"\\n\");\n\n const resolveNode = (rhsNode: SectionBlock, isRoot: boolean) => {\n const lhsNode = isRoot\n ? mappedLhsSections[0]\n : findNodeByIdDeep(\n proposedSections,\n rhsNode.nodeId || rhsNode.id || rhsNode.contentId,\n );\n const evalResult =\n rhsNode.evaluationResult || lhsNode?.evaluationResult;\n const registryNodeId = lhsNode\n ? lhsNode.nodeId || lhsNode.id\n : rhsNode.nodeId || rhsNode.id;\n return { lhsNode, evalResult, registryNodeId };\n };\n\n if (isOneToOneSection) {\n const reserveMappedIndexes = (rhsNode: SectionBlock | null, isRoot = false) => {\n if (!rhsNode) return;\n const { lhsNode, evalResult, registryNodeId } = resolveNode(\n rhsNode,\n isRoot,\n );\n const normalizedContent = normalizeContent(rhsNode.content);\n\n Object.entries(evalResult?.deviations || {}).forEach(\n ([deviationKey, deviationMap]: [string, any]) => {\n const highlight = deviationMap[parentNodeId];\n const normalizedHighlight = normalizeContent(highlight);\n const isMapped =\n !!lhsNode &&\n !isMissingStr(deviationMap[counterPartNodeId as string]);\n if (\n !isMapped ||\n !normalizedHighlight ||\n !findTextMatchRange(normalizedContent, normalizedHighlight)\n ) return;\n\n const refId = `${registryNodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n const registryIndex = deviationNumberRegistry[refId];\n if (registryIndex === undefined || registryIndex === null) return;\n nextIndex = Math.max(\n nextIndex,\n Math.max(1, registryIndex - (sectionOffset || 0)) + 1,\n );\n },\n );\n\n (rhsNode.subsections || []).forEach((child: SectionBlock) =>\n reserveMappedIndexes(child),\n );\n };\n\n reserveMappedIndexes(section, true);\n }\n\n const visit = (rhsNode: SectionBlock | null, isRoot = false) => {\n if (!rhsNode) return;\n\n const { lhsNode, evalResult, registryNodeId } = resolveNode(\n rhsNode,\n isRoot,\n );\n const nodeDeviations = evalResult?.deviations || {};\n const normalizedContent = normalizeContent(rhsNode.content);\n\n Object.entries(nodeDeviations)\n .map(([deviationKey, deviationMap]: [string, any]) => {\n const highlight = deviationMap[parentNodeId];\n const isOrphan =\n !lhsNode || isMissingStr(deviationMap[counterPartNodeId as string]);\n const normalizedHighlight = normalizeContent(highlight);\n let position = -1;\n if (normalizedHighlight) {\n position = findTextMatchRange(normalizedContent, normalizedHighlight)?.start ?? -1;\n if (position === -1) {\n position = findTextRangeWithFormatting(normalizedContent, normalizedHighlight)?.start ?? -1;\n }\n }\n const refId = `${registryNodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n return {\n refId,\n isRenderable:\n isOrphan && !!normalizedHighlight && !isMissingStr(highlight),\n position,\n registryIndex: deviationNumberRegistry[refId] ?? Number.MAX_SAFE_INTEGER,\n };\n })\n .filter((entry) => entry.isRenderable)\n .sort((a, b) => {\n const aPosition =\n a.position === -1 ? Number.MAX_SAFE_INTEGER : a.position;\n const bPosition =\n b.position === -1 ? Number.MAX_SAFE_INTEGER : b.position;\n return aPosition - bPosition || a.registryIndex - b.registryIndex;\n })\n .forEach((entry) => {\n indexes.set(entry.refId, nextIndex++);\n });\n\n (rhsNode.subsections || []).forEach((child: SectionBlock) => visit(child));\n };\n\n visit(section, true);\n return indexes;\n }, [\n maintainRelativeOrder,\n columnKey,\n section,\n proposedSections,\n parentNodeId,\n counterPartNodeId,\n deviationNumberRegistry,\n sectionOffset,\n ]);\n\n // Derive validatedParentNum from registry\n const firstDeviationKey = Object.keys(deviations)[0];\n const firstRefId = firstDeviationKey ? `${nodeId}${DEVIATION_BADGE_SEPARATOR}${firstDeviationKey}` : null;\n const registeredParentNum = firstRefId ? (deviationParentRegistry?.[firstRefId] as number) : null;\n\n let validatedParentNum: string | number = idx + 1;\n\n if (maintainRelativeOrder && unifiedNumbering) {\n const unifiedNum = columnKey === \"left\" \n ? unifiedNumbering.leftNums.get(section?.id as string) \n : unifiedNumbering.rightNums.get(section?.id as string);\n \n if (isSecOrphan && unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n } else if (unifiedNum !== undefined) {\n validatedParentNum = unifiedNum;\n }\n } else if (registeredParentNum !== null && registeredParentNum !== undefined && registeredParentNum >= 0) {\n validatedParentNum = registeredParentNum;\n }\n // const deviationNodeIdRef = useRef<string | undefined>(deviationNodeIdToView);\n // const deviationNodeParentRef = useRef<string | null>(deviationTargetParentId || null);\n const highlights: string[] = [];\n // Mapp through deviations to pass to memoized markdown for highlighting, also prepare deviation badges \n let nextFallbackDeviationIndex = Math.max(\n 0,\n ...Object.keys(deviations).map(\n (deviationKey) =>\n deviationNumberRegistry[\n `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`\n ],\n ).filter(\n (value): value is number => typeof value === \"number\" && Number.isFinite(value),\n ),\n ) + 1;\n const rawDeviationEntries = Object.entries(deviations).map(([deviationKey, deviationMap]: [string, any]) => {\n const refId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}`;\n // Registry numbering is presentation metadata, not a render gate. A valid\n // highlight must still receive a badge if registry traversal missed it.\n const currentIndex = deviationNumberRegistry[refId] ?? nextFallbackDeviationIndex++;\n return { deviationKey, deviationMap, refId, currentIndex };\n });\n\n // Sort by global index BEFORE mapping to prevent negative/zero offsets\n rawDeviationEntries.sort((a, b) => a.currentIndex - b.currentIndex);\n\n const deviationEntries = rawDeviationEntries.map((item) => {\n const { deviationKey, deviationMap, refId } = item;\n let currentIndex = item.currentIndex;\n\n let highlight = deviationMap[parentNodeId];\n const isMissingClause = isMissingStr(highlight);\n\n if (isMissingClause) {\n highlight = \"\"; \n } else if (!highlight) {\n return null; \n }\n\n highlights.push(highlight);\n\n // MAPPING Stricter Left/Right Index mapping to prevent cross-wiring\n let leftIdx = idx;\n let rightIdx = idx;\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = section.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n if (rhsArrayIdx !== -1) {\n rightIdx = rhsArrayIdx;\n } else {\n const rhsByIdIdx = existingSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n rightIdx = rhsByIdIdx !== -1 ? rhsByIdIdx : idx;\n }\n } else {\n const lhsSelfIndex = section.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (lhsArrayIdx !== -1) {\n leftIdx = lhsArrayIdx;\n } else {\n const lhsByIdIdx = proposedSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n leftIdx = lhsByIdIdx !== -1 ? lhsByIdIdx : idx;\n }\n }\n }\n\n const actionId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}${DEVIATION_BADGE_SEPARATOR}${leftIdx}${DEVIATION_BADGE_SEPARATOR}${rightIdx}`;\n \n // CONTENT Use the calculated mapped indices to grab correct counterpart text\n // const counterPartContentRaw = columnKey === \"left\" ? existingSections[rightIdx]?.content : proposedSections[leftIdx]?.content;\n const counterpartHighlight = deviationMap[counterPartNodeId as string];\n \n // Commented Out code for removing the highlight swallowing logic\n // let simulatedContent = safeStringify(counterPartContentRaw);\n\n // const counterPartHighlight = Object.keys(deviations)\n // .map(key => ({ key, text: deviations[key][counterPartNodeId as string] }))\n // .filter(item => !isMissingStr(item.text))\n // .sort((a, b) => b.text.length - a.text.length);\n\n // const survivingKeys = new Set();\n // counterPartHighlight.forEach(item => {\n // const clean = item.text.replace(/\\\\(['’])/g, \"$1\").replace(/\\\\n/g, \"\\n\");\n // if(!clean) return;\n\n // const regex = new RegExp(escapeRegExp(clean));\n // if(regex.test(simulatedContent)){\n // survivingKeys.add(item.key);\n // simulatedContent = simulatedContent.replace(regex, `__TOKEN_${item.key}__`);\n // }\n // });\n\n // const isCounterPartOverlapping = !isMissingStr(counterpartHighlight) && !survivingKeys.has(deviationKey);\n\n const isDeviationOrphan = isSecOrphan || isMissingStr(counterpartHighlight);\n const orphanVisualIndex = rhsOrphanVisualIndexes.get(refId);\n const mappedLhsIndex = lhsDeviationDisplayIndexes.get(refId);\n if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n orphanVisualIndex !== undefined\n ) {\n currentIndex = orphanVisualIndex;\n } else if (\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n !isDeviationOrphan &&\n mappedLhsIndex !== undefined\n ) {\n currentIndex = mappedLhsIndex;\n } else if (\n maintainRelativeOrder &&\n sectionOffset !== undefined &&\n (columnKey !== \"right\" || isDeviationOrphan || hasSingleMappedLhs)\n ) {\n currentIndex = currentIndex - sectionOffset;\n }\n currentIndex = Math.max(1, currentIndex);\n\n const badgeParentNum =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n isDeviationOrphan &&\n unifiedNumbering\n ? getRhsMappedSectionNumber({\n section,\n proposedSections,\n leftNums: unifiedNumbering.leftNums,\n fallbackNumber: String(validatedParentNum),\n firstOnly: true,\n })\n : validatedParentNum;\n const badgeLabel = `${badgeParentNum}.${currentIndex}`;\n\n let mappedIdx = idx;\n if (columnKey === \"right\" && maintainRelativeOrder) {\n const lhsSelfIndex = section.refIndexes?.[0];\n const actualLhsIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (actualLhsIdx !== -1) {\n mappedIdx = actualLhsIdx;\n } else {\n const lhsByIdIdx = proposedSections.findIndex((s: SectionBlock) =>\n s.id === section.id || s.nodeId === section.nodeId || s.contentId === section.contentId,\n );\n if (lhsByIdIdx !== -1) mappedIdx = lhsByIdIdx;\n }\n }\n const baseStyle = getSectionCompareStyle ? getSectionCompareStyle(mappedIdx) : null;\n \n // let isUIOverlapping = false;\n // if (highlight) {\n // const allHighlights = Object.values(deviations).map((d: any) => d[parentNodeId as string]).filter(Boolean);\n // isUIOverlapping = allHighlights.some((otherHl: any) => otherHl.length > highlight.length && otherHl.includes(highlight));\n // }\n\n const deviationOutput = deviationMap?.evaluation_outputs || resolvedEvalResult?.evaluation_outputs;\n const deviationScore = deviationOutput?.output_value ?? null;\n const deviationColorForBadge = deviationOutput?.metadata?.label_color ?? deviationColorData;\n const deviationPaletteForBadge = generateColorPalette(deviationColorForBadge);\n let badgeStyle = baseStyle\n ? {\n ...baseStyle,\n badgeBg: deviationPaletteForBadge.badgeBg,\n badgeBorder: deviationPaletteForBadge.badgeBorder,\n badgeText: deviationPaletteForBadge.badgeText,\n }\n : { ...deviationPaletteForBadge };\n\n // if (isUIOverlapping) {\n // badgeStyle.badgeBg = \"#FFFBEB\";\n // badgeStyle.badgeBorder = \"#FCD34D\";\n // badgeStyle.badgeText = \"#B45309\";\n // badgeStyle.highlightBg = \"#FDE68A\";\n // }\n\n const summaryPayload = deviationMap?.deviation_summary\n ? {\n deviation_summary: deviationMap.deviation_summary,\n deviation_title: deviationMap?.deviation_title || resolvedEvalResult?.deviation_title,\n deviation_impact: deviationMap?.deviation_impact || resolvedEvalResult?.deviation_impact,\n deviation_explanation:\n deviationMap?.deviation_explanation || resolvedEvalResult?.deviation_explanation,\n evaluation_outputs: deviationOutput,\n cognitive_decisioning:\n deviationMap?.cognitive_decisioning || resolvedEvalResult?.cognitive_decisioning,\n }\n : null;\n\n // Logic for overlapping highlight badges\n let stackIndex = 0;\n const contentStr = baseContent || \"\";\n if (highlight && contentStr) {\n const paragraphs = contentStr.split(/\\n{2,}/);\n const paraIndex = paragraphs.findIndex(p => p.includes(highlight));\n if (paraIndex !== -1) {\n const devsInPara = Object.entries(deviations)\n .filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && paragraphs[paraIndex].includes(hl);\n })\n .sort((a: any, b: any) => paragraphs[paraIndex].indexOf(a[1][parentNodeId]) - paragraphs[paraIndex].indexOf(b[1][parentNodeId]));\n const overlappingDevs = devsInPara.filter(([_, dMap]: any) => {\n const hl = dMap[parentNodeId];\n return hl && (hl.includes(highlight) || highlight.includes(hl));\n });\n if (overlappingDevs.length > 1) {\n stackIndex = Math.max(0, overlappingDevs.findIndex(([k]) => k === deviationKey));\n }\n }\n }\n const badgeRef = getBadgeRef(columnKey, refId);\n\n return {\n id: refId,\n actionId: actionId,\n label: badgeLabel,\n highlight,\n side: columnKey,\n style: badgeStyle,\n stackIndex,\n score: deviationScore,\n isConnected: connectedSections?.has(actionId),\n showScrollLockToggle:\n connectedSections?.has(actionId) ||\n (isSideBySide && activeSideBySideSection === actionId) ||\n (!!summaryPopupAnchorEl && summaryPopupAnchorEl === badgeRef.current),\n scrollSyncLocked,\n toggleScrollSyncLocked,\n isOrphan: isDeviationOrphan,\n isMissingClause,\n badgeRef,\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n\n if (openMoreFunctionsPopup) {\n openMoreFunctionsPopup(\n e as any, \n popupBaseSec || { id: \"orphan-left\", title: \"\", content: \"\" }, \n isDeviationOrphan, \n popupRefSec || { id: \"orphan-right\", title: \"\", content: \"\" }, \n actionId as any, \n badgeStyle as StyleVariant | null\n );\n }\n },\n\n onSummaryClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n openSummaryPopup(e, actionId, isDeviationOrphan, summaryPayload);\n },\n };\n }).filter(Boolean);\n const baseShouldRenderBadges = showDeviationBadges || isProposedFixTarget;\n const shouldRenderBadges = baseShouldRenderBadges;\n const deviationBadgesToRender = shouldRenderBadges ? deviationEntries : [];\n\n // NEW: Sync highlights to prevent ghost highlights\n const highlightsToRender = deviationEntries.map((b: any) => b.highlight).filter(Boolean)\n\n const show =\n section.id && columnKey === navigation?.columnKey ? navigation : null;\n\n // Local ref added to prevent race conditions\n const hasScrolledRef = React.useRef(false);\n\n // Reset scroll flag when section closed\n useEffect(() => {\n if (!isExpanded) {\n hasScrolledRef.current = false;\n }\n }, [isExpanded]);\n // useEffect(()=>{\n // deviationNodeIdRef.current = deviationNodeIdToView;\n // deviationNodeParentRef.current = deviationTargetParentId || null;\n // }, [deviationNodeIdToView, deviationTargetParentId]);\n\n // Commented out the auto scroll functionality which was breaking the LSC -> RHS opening\n // useEffect(() => {\n // const isDeviationTargetSection =\n // !!deviationNodeIdRef.current &&\n // !!deviationNodeParentRef.current &&\n // nodeId === deviationNodeParentRef.current;\n // // NEW CONDITION: Check if the deviation target is one of the direct subsections\n // const isTargetInSubsections =\n // !!deviationNodeIdRef.current &&\n // (section.subsections || []).some(\n // (sub) => sub.id === deviationNodeIdRef.current\n // );\n\n // // Abort scroll if it's already scrolled, not expanded, is the target section, \n // // OR if the target is inside its subsections\n // if (\n // !isExpanded ||\n // hasScrolledRef.current ||\n // isDeviationTargetSection ||\n // isTargetInSubsections\n // ) {\n // return;\n // }\n\n // const timer = setTimeout(() => {\n // const firstDeviationEl = show?.firstDeviationRef?.current;\n // const firstDeviationPosition = show?.firstDeviationPosition;\n\n // if (!firstDeviationEl) {\n // hasScrolledRef.current = true;\n // return;\n // }\n\n // if (\n // firstDeviationPosition === \"inside\" ||\n // isElementVisibleInScrollParent(firstDeviationEl)\n // ) {\n // hasScrolledRef.current = true;\n // return;\n // }\n\n // hasScrolledRef.current = true;\n // firstDeviationEl.scrollIntoView({\n // behavior: \"smooth\",\n // block: \"center\",\n // });\n // }, 600);\n\n // return () => clearTimeout(timer);\n // }, [\n // isExpanded,\n // nodeId,\n // show?.firstDeviationPosition,\n // show?.firstDeviationRef,\n // ]);\n \n return (\n <Box\n key={`${columnKey}-sec-${idx}`}\n ref={colRef}\n sx={{\n mb,\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n position: \"relative\",\n minWidth: 0,\n }}\n >\n {isExpanded && show?.showAbove && (\n <div\n style={{\n position: \"sticky\",\n top: 0,\n height: \"0px\",\n cursor: \"pointer\",\n }}\n onClick={() =>\n show?.showAboveRef?.current?.scrollIntoView({\n behavior: \"smooth\" as ScrollBehavior,\n block: \"center\",\n })\n }\n >\n <div\n style={{\n transform: `translateY(-50%) translateX(calc(100% ${\n columnKey === \"left\" ? \"+\" : \"-\"\n } 130px))`,\n position: \"absolute\",\n paddingTop: \"20px\",\n ...(columnKey === \"left\" ? {right: \"-20px\"} : {left: \"-20px\"}),\n }}\n >\n <ChevronUp\n color={\n show?.showAboveRef?.current\n ? window.getComputedStyle(show.showAboveRef.current).color\n : undefined\n }\n />\n </div>\n </div>\n )}\n <Accordion\n disableGutters\n expanded={isEmpty ? false : isExpanded}\n onChange={() => {\n if (!isEmpty) {\n onToggle();\n showOpenNodeRef.current = section.id;\n }\n }}\n sx={{\n boxShadow: \"none\",\n border: isEmpty ? \"1px dashed #E2E8F0\" : \"1px solid #E2E8F0\",\n bgcolor: isEmpty ? \"#FAFAFA\" : \"#FFFFFF\",\n borderRadius: \"6px\",\n flexGrow: 1,\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n minWidth: 0,\n \"&:before\": { display: \"none\" },\n \"& .MuiAccordion-heading\": {\n position: \"sticky\",\n top: -12,\n zIndex: 10,\n background: \"#fff\",\n },\n }}\n >\n <AccordionSummary\n expandIcon={isEmpty ? null : <ChevronDown size={16} />}\n sx={{\n minHeight: \"36px\",\n flexShrink: 0,\n cursor: isEmpty ? \"default\" : \"pointer\",\n \"& .MuiAccordionSummary-content\": {\n my: 0.5,\n display: \"grid\",\n alignItems: \"center\",\n minWidth: 0,\n width: \"100%\",\n },\n \"& .MuiAccordionSummary-expandIconWrapper\": {\n transition: \"transform 0.2s ease\",\n },\n \"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded\": {\n transform: \"rotate(180deg)\",\n },\n }}\n >\n {hasTitle && (\n <Tooltip title={displayTitle} placement=\"top\">\n <Typography\n component=\"div\"\n sx={{\n fontSize: \"12px\",\n color: isEmpty ? \"#94A3B8\" : \"#19213D\",\n fontWeight: isEmpty ? 400 : 700,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n width: \"100%\",\n minWidth: 0,\n }}\n >\n {renderSimpleMarkdown(visibleTitle, isMultipleMapping)}\n </Typography>\n </Tooltip>\n )}\n </AccordionSummary>\n {!isEmpty && (\n <AccordionDetails\n sx={{\n pt: 0,\n pb: 1.25,\n bgcolor: \"#FFFFFF\",\n flex: 1,\n display: \"flex\",\n flexDirection: \"column\",\n minWidth: 0,\n }}\n >\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n fallbackContent={fallbackContent}\n sxStyles={resolvedMarkdownStyles}\n highlights={highlightsToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n deviationBadges={deviationBadgesToRender}\n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) =>\n renderSubSectionAccordion({\n section: sub,\n keyPath: `${idx}-${subIdx}`,\n depth: 0,\n columnKey,\n parentNodeId,\n sectionOffset,\n rhsOrphanVisualIndexes,\n }),\n )}\n </AccordionDetails>\n )}\n </Accordion>\n {isExpanded && show?.showBelow && (\n <div\n style={{\n position: \"sticky\",\n bottom: 0,\n height: \"0px\",\n cursor: \"pointer\",\n }}\n onClick={() =>\n show?.showBelowRef?.current?.scrollIntoView({\n behavior: \"smooth\" as ScrollBehavior,\n block: \"center\",\n })\n }\n >\n <div\n style={{\n transform: `translateY(-50%) translateX(calc(100% ${\n columnKey === \"left\" ? \"+\" : \"-\"\n } 130px))`,\n position: \"absolute\",\n paddingBottom: \"20px\",\n ...(columnKey === \"left\" ? {right: \"-20px\"} : {left: \"-20px\"}),\n }}\n >\n <ChevronDown\n color={\n show?.showBelowRef?.current\n ? window.getComputedStyle(show.showBelowRef.current).color\n : undefined\n }\n />\n </div>\n </div>\n )}\n </Box>\n );\n};\n\nexport default SectionAccordion;\n"],"names":["renderSimpleMarkdown","text","isMultiTag","safeStringify","replace","split","map","part","i","startsWith","endsWith","children","slice","jsxs","style","display","alignItems","justifyContent","gap","width","jsx","minWidth","overflow","textOverflow","whiteSpace","padding","borderRadius","background","border","color","fontSize","fontWeight","flexShrink","lineHeight","marginRight","section","idx","columnKey","colRef","mb","isExpanded","onToggle","navigation","parentNodeId","showOpenNodeRef","resolvedMarkdownStyles","maintainRelativeOrder","showDeviationBadges","renderSubSectionAccordion","treeData","proposedSections","existingSections","deviationNumberRegistry","deviationParentRegistry","getBadgeRef","openSummaryPopup","getSectionCompareStyle","connectedSections","openMoreFunctionsPopup","isProposingFix","proposingFixNodeId","isRedlineFlow","isSideBySide","activeSideBySideSection","scrollSyncLocked","unifiedNumbering","toggleScrollSyncLocked","summaryPopupAnchorEl","useCompareContext","collisionKey","String","hasTitle","displayTitle","hasValue","title","isProposedFixTarget","id","nodeId","contentId","hasRedlineTags","hasMeaningfulRedlineTags","content","resolvedRedlineFlow","suppressHighlightBg","changeHistoryContent","change_history","shouldOverlayContent","normalizedRedlineContent","React","useMemo","normalizeRedlineMarkdown","baseContent","stripRedlineTags","overlayContent","fallbackContent","hasContent","displayContent","isEmpty","isMultipleMapping","refContentIds","length","visibleTitle","trimEnd","targetEvalResult","evaluationResult","lhsSelfIndex","refIndexes","lhsSection","find","s","selfIndex","leftDocId","input_index_map","rightDocId","counterPartNodeId","findNodeByIdDeep","nodes","n","subsections","found","popupBaseSec","popupRefSec","sectionOffset","min","Infinity","normalizeInlineContent","value","raw","traverse","node","bNode","rNode","isTopLevel","topNodeId","mappedLhs","filter","l","includes","subNodeId","evalResult","devs","deviations","Object","keys","forEach","devKey","highlight","isMissingStr","normalizedHighlight","findTextMatchRange","canRenderInlineHighlight","refId1","DEVIATION_BADGE_SEPARATOR","idx1","refId2","idx2","subs","bSubs","rSubs","maxLen","Math","max","mappedLhsSections","lhs","rhsSelfIndex","rhs","Boolean","rhsSection","rhsArrayIdx","findIndex","lhsArrayIdx","isSecOrphan","hasSingleMappedLhs","hasSingleMappedLhsSection","resolvedEvalResult","deviationColorData","evaluation_outputs","metadata","label_color","DEFAULT_DEVIAION_COLOR","deviationPalette","generateColorPalette","highlightBg","lhsDeviationDisplayIndexes","getLhsDeviationDisplayIndexes","Map","rhsOrphanVisualIndexes","indexes","nextIndex","isOneToOneSection","normalizeContent","resolveNode","rhsNode","isRoot","lhsNode","registryNodeId","reserveMappedIndexes","normalizedContent","entries","deviationKey","deviationMap","refId","registryIndex","child","visit","nodeDeviations","isOrphan","position","start","findTextRangeWithFormatting","isRenderable","Number","MAX_SAFE_INTEGER","entry","sort","a","b","set","firstDeviationKey","firstRefId","registeredParentNum","validatedParentNum","unifiedNum","leftNums","get","rightNums","nextFallbackDeviationIndex","isFinite","rawDeviationEntries","currentIndex","deviationEntries","item","isMissingClause","leftIdx","rightIdx","rhsByIdIdx","lhsByIdIdx","actionId","counterpartHighlight","isDeviationOrphan","orphanVisualIndex","mappedLhsIndex","badgeLabel","getRhsMappedSectionNumber","fallbackNumber","firstOnly","mappedIdx","actualLhsIdx","baseStyle","deviationOutput","deviationScore","output_value","deviationColorForBadge","deviationPaletteForBadge","badgeStyle","badgeBg","badgeBorder","badgeText","summaryPayload","deviation_summary","deviation_title","deviation_impact","deviation_explanation","cognitive_decisioning","stackIndex","contentStr","paragraphs","paraIndex","p","overlappingDevs","_","dMap","hl","indexOf","k","badgeRef","label","side","score","isConnected","has","showScrollLockToggle","current","onClick","e","stopPropagation","onSummaryClick","deviationBadgesToRender","highlightsToRender","show","hasScrolledRef","useRef","useEffect","Box","ref","sx","flexDirection","showAbove","top","height","cursor","showAboveRef","scrollIntoView","behavior","block","transform","paddingTop","right","left","ChevronUp","window","getComputedStyle","Accordion","disableGutters","expanded","onChange","boxShadow","bgcolor","flexGrow","zIndex","AccordionSummary","expandIcon","ChevronDown","size","minHeight","my","transition","Tooltip","placement","Typography","component","AccordionDetails","pt","pb","flex","MemoizedMarkdown","sxStyles","highlights","deviationBadges","sub","subIdx","keyPath","depth","showBelow","bottom","showBelowRef","paddingBottom"],"mappings":"ygBAgCA,MAAMA,EAAuB,CAACC,EAAcC,GAAa,KACnD,IAACD,EAAa,OAAA,KAKlB,OAHuBE,EAAAA,cAAcF,GAAMG,QAAQ,OAAQ,MAC9BC,MAAM,kBAEtBC,IAAI,CAACC,EAAcC,IAC1BD,EAAKE,WAAW,OAASF,EAAKG,SAAS,YACjC,SAAgB,CAAAC,SAAAJ,EAAKK,MAAM,GAAG,IAAlBJ,GAIpBK,EAAAA,KAAC,MAAA,CAECC,MAAO,CACLC,QAAS,OACTC,WAAY,SACZC,eAAgB,gBAChBC,IAAK,MACLC,MAAO,QAGTR,SAAA,CAAAS,EAAAA,IAAC,OAAA,CACCN,MAAO,CACLO,SAAU,EACVC,SAAU,SACVC,aAAc,WACdC,WAAY,UAGbb,SAAAJ,IAGFL,GACCkB,EAAAA,IAAC,OAAA,CACCN,MAAO,CACLC,QAAS,cACTC,WAAY,SACZC,eAAgB,SAChBQ,QAAS,UACTC,aAAc,SACdC,WAAY,UACZC,OAAQ,oBACRC,MAAO,UACPC,SAAU,MACVC,WAAY,IACZP,WAAY,SACZQ,WAAY,EACZC,WAAY,IACZC,YAAa,OAEhBvB,SAAA,eAtCEH,qBAsFY,EACvB2B,UACAC,MACAC,YACAC,SACAC,KAAK,EACLC,aACAC,WACAC,aACAC,eAAe,OAET,MAAAC,gBACJA,EAAAC,uBACAA,EAAAC,sBACAA,EAAAC,oBACAA,GAAsB,EAAAC,0BACtBA,EAAAC,SACAA,EAAAC,iBACAA,EAAAC,iBACAA,EAAAC,wBACAA,EAAAC,wBACAA,EAAAC,YACAA,EAAAC,iBACAA,EAAAC,uBACAA,EAAAC,kBACAA,EAAAC,uBACAA,EAAAC,eACAA,EAAAC,mBACAA,EAAAC,cACAA,EAAAC,aACAA,EAAAC,wBACAA,EAAAC,iBACAA,EAAAC,iBACAA,EAAAC,uBACAA,EAAAC,qBACAA,GACEC,EAAk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SACVyI,OAAQ,EACR7C,OAAQ,MACRC,OAAQ,WAEVjB,QAAS,IACPM,IAAMwD,cAAc/D,SAASoB,eAAe,CAC1CC,SAAU,SACVC,MAAO,WAIXrS,SAAAS,EAAAA,IAAC,MAAA,CACCN,MAAO,CACLmS,UAAW,yCACK,SAAd5Q,EAAuB,IAAM,cAE/B0K,SAAU,WACV2I,cAAe,UACG,SAAdrT,EAAuB,CAAC8Q,MAAO,SAAW,CAACC,KAAM,UAGvDzS,SAAAS,EAAAA,IAAC8S,EAAAA,YAAA,CACCrS,MACEoQ,IAAMwD,cAAc/D,QAChB4B,OAAOC,iBAAiBtB,GAAKwD,aAAa/D,SAAS7P,WACnD,UAxLT,GAAGQ,SAAiBD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),n=require("lucide-react"),o=require("../hooks/memoizedMarkdown.js"),s=require("../CompareContext.js"),d=require("../CognitiveComparehelpers.js"),r=require("../CognitiveCompareConstants.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const a=l(t).default.memo(l=>{const{section:c,keyPath:u,depth:p=0,columnKey:h="left",parentNodeId:g="",sectionOffset:f,rhsOrphanVisualIndexes:m}=l,{expandedSubSections:x,setExpandedSubSections:S,maintainRelativeOrder:v,showDeviationBadges:I=!1,proposedSections:y,existingSections:_,treeData:b,deviationNumberRegistry:O,deviationParentRegistry:A,connectedSections:E,activeSideBySideSection:M,isSideBySide:R,scrollSyncLocked:$,toggleScrollSyncLocked:P,summaryPopupAnchorEl:k,resolvedMarkdownStyles:B,getSubSectionRef:C,getSubSectionCompareStyle:N,getBadgeRef:j,openMoreFunctionsPopup:w,openSummaryPopup:F,resetSideBySide:D,setConnectedSections:T,setConnectedLines:V,cachedConnectedPositions:L,isProposingFix:q,proposingFixNodeId:G,isRedlineFlow:K,unifiedNumbering:W}=s.useCompareContext(),z=M??"",H=(c.displayTitle??!0)&&d.hasValue(c.title),U=!(!q||!G||"left"!==h||c.id!==G&&c.nodeId!==G),X=d.hasMeaningfulRedlineTags(c.content),J="boolean"==typeof K?K:X,Q=X,Y=J&&X,Z=Y?d.stripRedlineTags(c.content):c.content,ee=Y?c.content:void 0,te=((c.displayContent??!0)||X)&&d.hasValue(c.content),ie=!H&&!te,ne=H?c.title:te?"No Title Found":"No Matching Section Found",oe=!!x[u],se=C(h,u),de=u.split("-").map(Number)[0];let re=y[de],le=_[de],ae=de,ce=de,ue=!1;const pe=(e,t,i)=>{if(!e||!t)return null;if(e.id===t||e.nodeId===t||e.contentId===t)return{section:e,keyPath:i};const n=(e.subsections||[]).map((e,t)=>({section:e,keyPath:`${i}-${t}`}));for(;n.length>0;){const e=n.shift();if(e?.section){if(e.section.id===t||e.section.nodeId===t||e.section.contentId===t)return e;(e.section.subsections||[]).forEach((t,i)=>{n.push({section:t,keyPath:`${e.keyPath}-${i}`})})}}return null};if(v)if("left"===h){const e=re?.refIndexes?.[0],t=_.findIndex(t=>t.selfIndex===e);-1!==t?(le=_[t],ce=t):ue=!0}else{const e=le?.refIndexes?.[0],t=y.findIndex(t=>t.selfIndex===e);-1!==t?(re=y[t],ae=t):ue=!0}const he=(e,t)=>{if(!t||!e)return null;for(let i=0;i<e.length;i++){const n=pe(e[i],t,String(i));if(n)return n}return null};let ge=null,fe=null,me="",xe="";if(v)if("left"===h){ge=c,me=u;let e=pe(le,c.nodeId||c.id,String(ce));e||(e=he(_,c.nodeId||c.id)),fe=e?.section||null,xe=e?.keyPath||""}else{fe=c,xe=u;let e=pe(re,c.nodeId||c.id,String(ae));e||(e=he(y,c.nodeId||c.id)),ge=e?.section||null,me=e?.keyPath||""}else if("left"===h){ge=c,me=u;const e=he(_,c.nodeId||c.id);fe=e?.section||null,xe=e?.keyPath||""}else{fe=c,xe=u;const e=he(y,c.nodeId||c.id);ge=e?.section||null,me=e?.keyPath||""}const Se=(me?N(me):null)||N(u),ve=b?.input_index_map?.[0],Ie=b?.input_index_map?.[1],ye="left"===h?Ie:ve,_e="left"===h?!fe:!ge,be=v&&"right"===h&&d.hasSingleMappedLhsSection(le,y),Oe=c.evaluationResult||ge?.evaluationResult||fe?.evaluationResult,Ae=Oe?.deviations||{},Ee=t.useMemo(()=>v&&"right"===h?d.getLhsDeviationDisplayIndexes(y,ve,O):new Map,[v,h,y,ve,O]);let Me=c.nodeId||c.id||ge?.nodeId||ge?.id||fe?.nodeId||fe?.id;v&&"left"!==h&&ge?.id&&(Me=ge.nodeId||ge.id);const Re=Object.keys(Ae)[0],$e=Re?`${Me}${d.DEVIATION_BADGE_SEPARATOR}${Re}`:null,Pe=$e?A?.[$e]:null;let ke=de+1;if(v&&W){const e="left"===h?W.leftNums.get(re?.id):W.rightNums.get(le?.id);ue&&void 0!==e?ke=e:null!=Pe&&Pe>=0?ke=Pe:void 0!==e&&(ke=e)}else null!=Pe&&Pe>=0&&(ke=Pe);const Be=Oe?.evaluation_outputs?.metadata?.label_color??r.DEFAULT_DEVIAION_COLOR,Ce=d.generateColorPalette(Be),{highlightBg:Ne}=Ce,je=Object.entries(Ae).map(([e,t])=>{const i=`${Me}${d.DEVIATION_BADGE_SEPARATOR}${e}`;return{deviationKey:e,deviationMap:t,refId:i,currentIndex:O[i]}}).filter(e=>void 0!==e.currentIndex&&null!==e.currentIndex);je.sort((e,t)=>e.currentIndex-t.currentIndex);const we=new Map;if(!m&&v&&"right"===h){const e=d.safeStringify(Z||"").replace(/\\n/g,"\n");je.filter(({deviationMap:e})=>{const t=e[g];return(_e||d.isMissingStr(e[ye]))&&!!t&&!d.isMissingStr(t)}).map(t=>{const i=d.safeStringify(t.deviationMap[g]||"").replace(/\\n/g,"\n"),n=i?e.indexOf(i):-1;return{...t,position:n}}).sort((e,t)=>(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)-(-1===t.position?Number.MAX_SAFE_INTEGER:t.position)||e.currentIndex-t.currentIndex).forEach((e,t)=>{we.set(e.refId,t+1)})}const Fe=je.map(e=>{const{deviationKey:t,deviationMap:i,refId:n}=e;let o=e.currentIndex,s=i[g];const r=d.isMissingStr(s);if(r)s="";else if(!s)return null;const l=i[ye],a=_e||d.isMissingStr(l),c=m?.get(n)??we.get(n),u=Ee.get(n);v&&"right"===h&&a&&void 0!==c?o=c:v&&"right"===h&&!a&&void 0!==u?o=u:v&&void 0!==f&&("right"!==h||a||be)&&(o-=f),o=Math.max(1,o);const p=`${v&&"right"===h&&a&&W?d.getRhsMappedSectionNumber({section:le,proposedSections:y,leftNums:W.leftNums,fallbackNumber:String(ke),firstOnly:!0}):ke}.${o}`,x=`${Me}${d.DEVIATION_BADGE_SEPARATOR}${t}${d.DEVIATION_BADGE_SEPARATOR}${me}${d.DEVIATION_BADGE_SEPARATOR}${xe}`,S=i?.evaluation_outputs||Oe?.evaluation_outputs,I=S?.output_value??null,_=S?.metadata?.label_color??Be;let b={...d.generateColorPalette(_)};const O=i?.deviation_summary?{deviation_summary:i.deviation_summary||Oe?.deviation_summary,deviation_title:i?.deviation_title||Oe?.deviation_title,deviation_impact:i?.deviation_impact||Oe?.deviation_impact,deviation_explanation:i?.deviation_explanation||Oe?.deviation_explanation,evaluation_outputs:S,cognitive_decisioning:i?.cognitive_decisioning||Oe?.cognitive_decisioning}:null;let A=0;const B=Z||"";if(s&&B){const e=B.split(/\n{2,}/),i=e.findIndex(e=>e.includes(s));if(-1!==i){const n=Object.entries(Ae).filter(([t,n])=>{const o=n[g];return o&&e[i].includes(o)}).sort((t,n)=>e[i].indexOf(t[1][g])-e[i].indexOf(n[1][g])).filter(([e,t])=>{const i=t[g];return i&&(i.includes(s)||s.includes(i))});n.length>1&&(A=Math.max(0,n.findIndex(([e])=>e===t)))}}const C=j(h,n);return{id:n,actionId:x,label:p,highlight:s,side:h,style:b,stackIndex:A,score:I,isConnected:E.has(x),showScrollLockToggle:E.has(x)||R&&M===x||!!k&&k===C.current,scrollSyncLocked:$,toggleScrollSyncLocked:P,isOrphan:a,isMissingClause:r,badgeRef:C,onClick:e=>{e.stopPropagation();const t=ge?{...ge,title:re?.title||ge?.title||""}:{id:"orphan-left",title:"",content:""},i=fe?{...fe,title:le?.title||fe?.title||""}:{id:"orphan-right",title:"",content:""};w(e,t,a,i,x,b)},onSummaryClick:e=>{e.stopPropagation(),F(e,x,a,O)}}}).filter(Boolean).sort((e,t)=>parseFloat(e.label)-parseFloat(t.label)),De=t.useMemo(()=>{const e=new Set;return Fe.filter(t=>!e.has(t.id)&&(e.add(t.id),!0))},[Fe]),Te=I||!J&&U?De:[],Ve=De.map(e=>e.highlight).filter(Boolean),Le=Fe.find(e=>E.has(e.actionId)),qe=!!Le;if(!(H||te||c.subsections&&0!==c.subsections.length))return null;const Ge=Le?.style?.badgeBorder||Se?.badgeBorder,Ke=qe&&Ge?{borderRadius:"4px",outline:`2px solid ${Ge}`,outlineOffset:"1px"}:{};return H?e.jsx(i.Box,{ref:se,sx:{mt:1,width:"100%",minWidth:0,position:"relative"},children:e.jsx(i.Box,{sx:{width:"100%",...Ke},children:e.jsxs(i.Accordion,{disableGutters:!0,expanded:!ie&&oe,onChange:()=>{if(!ie){if(oe){const e=String(M||"");let t=e.includes(me)||e.includes(xe);t||E.forEach(e=>{(String(e).includes(me)||String(e).includes(xe))&&(t=!0)}),t&&(D(),T(new Set),V([]),L.current=[])}S(e=>({...e,[u]:!e[u]}))}},sx:{mt:0,boxShadow:"none",border:ie?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}},children:[e.jsx(i.AccordionSummary,{expandIcon:ie?null:e.jsx(n.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}},children:e.jsx(i.Typography,{component:"div",sx:{fontSize:"11px",fontWeight:600,color:ie?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0},children:ne||"Untitled Subsection"})}),!ie&&e.jsxs(i.AccordionDetails,{sx:{pt:0,pb:1,minWidth:0},children:[te&&e.jsx(o.MemoizedMarkdown,{content:Z,overlayContent:ee,sxStyles:B,deviationBadges:Te,maintainRelativeOrder:v,highlightBg:Ne,suppressHighlightBg:Q,highlights:Ve,collisionKey:z}),(c.subsections||[]).map((t,i)=>e.jsx(a,{section:t,keyPath:`${u}-${i}`,depth:p+1,columnKey:h,parentNodeId:g,sectionOffset:f,rhsOrphanVisualIndexes:m},`${u}-${i}`))]})]})})}):e.jsx(i.Box,{ref:se,sx:{mt:0===p?1:.75,width:"100%",minWidth:0,position:"relative"},children:!ie&&e.jsxs(i.Box,{sx:{width:"100%",...Ke},children:[te&&e.jsx(o.MemoizedMarkdown,{content:Z,overlayContent:ee,sxStyles:B,deviationBadges:Te,maintainRelativeOrder:v,highlightBg:Ne,suppressHighlightBg:Q,highlights:Ve,collisionKey:z}),(c.subsections||[]).map((t,i)=>e.jsx(a,{section:t,keyPath:`${u}-${i}`,depth:p+1,columnKey:h,parentNodeId:g,sectionOffset:f,rhsOrphanVisualIndexes:m},`${u}-${i}`))]})})});exports.default=a;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),n=require("lucide-react"),o=require("../hooks/memoizedMarkdown.js"),s=require("../CompareContext.js"),r=require("../CognitiveComparehelpers.js"),l=require("../CognitiveCompareConstants.js"),d=require("../utils/normalizeRedlineMarkdown.js"),a=require("../utils/normalizeInlineMarkdown.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const u=c(t).default.memo(c=>{const{section:p,keyPath:h,depth:g=0,columnKey:f="left",parentNodeId:m="",sectionOffset:x,rhsOrphanVisualIndexes:S}=c,{expandedSubSections:y,setExpandedSubSections:I,maintainRelativeOrder:v,showDeviationBadges:b=!1,proposedSections:_,existingSections:A,treeData:M,deviationNumberRegistry:R,deviationParentRegistry:E,connectedSections:O,activeSideBySideSection:k,isSideBySide:$,scrollSyncLocked:N,toggleScrollSyncLocked:P,summaryPopupAnchorEl:B,resolvedMarkdownStyles:C,getSubSectionRef:j,getSubSectionCompareStyle:w,getBadgeRef:T,openMoreFunctionsPopup:F,openSummaryPopup:D,resetSideBySide:V,setConnectedSections:q,setConnectedLines:L,cachedConnectedPositions:G,isProposingFix:z,proposingFixNodeId:W,isRedlineFlow:K,unifiedNumbering:H}=s.useCompareContext(),U=k??"",X=(p.displayTitle??!0)&&r.hasValue(p.title),J=!(!z||!W||"left"!==f||p.id!==W&&p.nodeId!==W&&p.contentId!==W),Q=r.hasMeaningfulRedlineTags(p.content),Y="boolean"==typeof K?K:Q,Z=Q,ee=p.change_history,te=Y&&Q,ie=t.useMemo(()=>te?d.normalizeRedlineMarkdown(r.safeStringify(p.content)):r.safeStringify(p.content),[p.content,te]),ne=te?r.stripRedlineTags(ie):p.content,oe=te?ie:void 0,se=Q&&r.hasValue(ee)?r.safeStringify(ee):void 0,re=((p.displayContent??!0)||Q)&&r.hasValue(p.content),le=!X&&!re,de=X?p.title:re?"No Title Found":"No Matching Section Found",ae=!!y[h],ce=j(f,h),ue=h.split("-").map(Number)[0];let pe=_[ue],he=A[ue],ge=ue,fe=ue,me=!1;const xe=(e,t,i)=>{if(!e||!t)return null;if(e.id===t||e.nodeId===t||e.contentId===t)return{section:e,keyPath:i};const n=(e.subsections||[]).map((e,t)=>({section:e,keyPath:`${i}-${t}`}));for(;n.length>0;){const e=n.shift();if(e?.section){if(e.section.id===t||e.section.nodeId===t||e.section.contentId===t)return e;(e.section.subsections||[]).forEach((t,i)=>{n.push({section:t,keyPath:`${e.keyPath}-${i}`})})}}return null};if(v)if("left"===f){const e=pe?.refIndexes?.[0],t=A.findIndex(t=>t.selfIndex===e);-1!==t?(he=A[t],fe=t):me=!0}else{const e=he?.refIndexes?.[0],t=_.findIndex(t=>t.selfIndex===e);-1!==t?(pe=_[t],ge=t):me=!0}const Se=(e,t)=>{if(!t||!e)return null;for(let i=0;i<e.length;i++){const n=xe(e[i],t,String(i));if(n)return n}return null};let ye=null,Ie=null,ve="",be="";if(v)if("left"===f){ye=p,ve=h;let e=xe(he,p.nodeId||p.id,String(fe));e||(e=Se(A,p.nodeId||p.id)),Ie=e?.section||null,be=e?.keyPath||""}else{Ie=p,be=h;let e=xe(pe,p.nodeId||p.id,String(ge));e||(e=Se(_,p.nodeId||p.id)),ye=e?.section||null,ve=e?.keyPath||""}else if("left"===f){ye=p,ve=h;const e=Se(A,p.nodeId||p.id);Ie=e?.section||null,be=e?.keyPath||""}else{Ie=p,be=h;const e=Se(_,p.nodeId||p.id);ye=e?.section||null,ve=e?.keyPath||""}const _e=(ve?w(ve):null)||w(h),Ae=M?.input_index_map?.[0],Me=M?.input_index_map?.[1],Re="left"===f?Me:Ae,Ee="left"===f?!Ie:!ye,Oe=v&&"right"===f&&r.hasSingleMappedLhsSection(he,_),ke=p.evaluationResult||ye?.evaluationResult||Ie?.evaluationResult,$e=ke?.deviations||{},Ne=t.useMemo(()=>v&&"right"===f?r.getLhsDeviationDisplayIndexes(_,Ae,R):new Map,[v,f,_,Ae,R]);let Pe=p.nodeId||p.id||ye?.nodeId||ye?.id||Ie?.nodeId||Ie?.id;v&&"left"!==f&&ye?.id&&(Pe=ye.nodeId||ye.id);const Be=Object.keys($e)[0],Ce=Be?`${Pe}${r.DEVIATION_BADGE_SEPARATOR}${Be}`:null,je=Ce?E?.[Ce]:null;let we=ue+1;if(v&&H){const e="left"===f?H.leftNums.get(pe?.id):H.rightNums.get(he?.id);me&&void 0!==e?we=e:null!=je&&je>=0?we=je:void 0!==e&&(we=e)}else null!=je&&je>=0&&(we=je);const Te=ke?.evaluation_outputs?.metadata?.label_color??l.DEFAULT_DEVIAION_COLOR,Fe=r.generateColorPalette(Te),{highlightBg:De}=Fe;let Ve=Math.max(0,...Object.keys($e).map(e=>R[`${Pe}${r.DEVIATION_BADGE_SEPARATOR}${e}`]).filter(e=>"number"==typeof e&&Number.isFinite(e)))+1;const qe=Object.entries($e).map(([e,t])=>{const i=`${Pe}${r.DEVIATION_BADGE_SEPARATOR}${e}`;return{deviationKey:e,deviationMap:t,refId:i,currentIndex:R[i]??Ve++}});qe.sort((e,t)=>e.currentIndex-t.currentIndex);const Le=new Map;if(!S&&v&&"right"===f){const e=r.safeStringify(ne||"").replace(/\\n/g,"\n");qe.filter(({deviationMap:e})=>{const t=e[m];return(Ee||r.isMissingStr(e[Re]))&&!!t&&!r.isMissingStr(t)}).map(t=>{const i=r.safeStringify(t.deviationMap[m]||"").replace(/\\n/g,"\n");let n=-1;return i&&(n=r.findTextMatchRange(e,i)?.start??-1,-1===n&&(n=a.findTextRangeWithFormatting(e,i)?.start??-1)),{...t,position:n}}).sort((e,t)=>(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)-(-1===t.position?Number.MAX_SAFE_INTEGER:t.position)||e.currentIndex-t.currentIndex).forEach((e,t)=>{Le.set(e.refId,t+1)})}const Ge=qe.map(e=>{const{deviationKey:t,deviationMap:i,refId:n}=e;let o=e.currentIndex,s=i[m];const l=r.isMissingStr(s);if(l)s="";else if(!s)return null;const d=i[Re],a=Ee||r.isMissingStr(d),c=S?.get(n)??Le.get(n),u=Ne.get(n);v&&"right"===f&&a&&void 0!==c?o=c:v&&"right"===f&&!a&&void 0!==u?o=u:v&&void 0!==x&&("right"!==f||a||Oe)&&(o-=x),o=Math.max(1,o);const p=`${v&&"right"===f&&a&&H?r.getRhsMappedSectionNumber({section:he,proposedSections:_,leftNums:H.leftNums,fallbackNumber:String(we),firstOnly:!0}):we}.${o}`,h=`${Pe}${r.DEVIATION_BADGE_SEPARATOR}${t}${r.DEVIATION_BADGE_SEPARATOR}${ve}${r.DEVIATION_BADGE_SEPARATOR}${be}`,g=i?.evaluation_outputs||ke?.evaluation_outputs,y=g?.output_value??null,I=g?.metadata?.label_color??Te;let b={...r.generateColorPalette(I)};const M=i?.deviation_summary?{deviation_summary:i.deviation_summary||ke?.deviation_summary,deviation_title:i?.deviation_title||ke?.deviation_title,deviation_impact:i?.deviation_impact||ke?.deviation_impact,deviation_explanation:i?.deviation_explanation||ke?.deviation_explanation,evaluation_outputs:g,cognitive_decisioning:i?.cognitive_decisioning||ke?.cognitive_decisioning}:null;let R=0;const E=ne||"";if(s&&E){const e=E.split(/\n{2,}/),i=e.findIndex(e=>e.includes(s));if(-1!==i){const n=Object.entries($e).filter(([t,n])=>{const o=n[m];return o&&e[i].includes(o)}).sort((t,n)=>e[i].indexOf(t[1][m])-e[i].indexOf(n[1][m])).filter(([e,t])=>{const i=t[m];return i&&(i.includes(s)||s.includes(i))});n.length>1&&(R=Math.max(0,n.findIndex(([e])=>e===t)))}}const C=T(f,n);return{id:n,actionId:h,label:p,highlight:s,side:f,style:b,stackIndex:R,score:y,isConnected:O.has(h),showScrollLockToggle:O.has(h)||$&&k===h||!!B&&B===C.current,scrollSyncLocked:N,toggleScrollSyncLocked:P,isOrphan:a,isMissingClause:l,badgeRef:C,onClick:e=>{e.stopPropagation();const t=ve&&_[Number(ve.split("-")[0])]||pe,i=be&&A[Number(be.split("-")[0])]||he,n=ye?{...ye,title:t?.title||ye?.title||""}:{id:"orphan-left",title:"",content:""},o=Ie?{...Ie,title:i?.title||Ie?.title||""}:{id:"orphan-right",title:"",content:""};F(e,n,a,o,h,b)},onSummaryClick:e=>{e.stopPropagation(),D(e,h,a,M)}}}).filter(Boolean).sort((e,t)=>parseFloat(e.label)-parseFloat(t.label)),ze=t.useMemo(()=>{const e=new Set;return Ge.filter(t=>!e.has(t.id)&&(e.add(t.id),!0))},[Ge]),We=b||J?ze:[],Ke=ze.map(e=>e.highlight).filter(Boolean),He=Ge.find(e=>O.has(e.actionId)),Ue=!!He;if(!(X||re||p.subsections&&0!==p.subsections.length))return null;const Xe=He?.style?.badgeBorder||_e?.badgeBorder,Je=Ue&&Xe?{borderRadius:"4px",outline:`2px solid ${Xe}`,outlineOffset:"1px"}:{};return X?e.jsx(i.Box,{ref:ce,sx:{mt:1,width:"100%",minWidth:0,position:"relative"},children:e.jsx(i.Box,{sx:{width:"100%",...Je},children:e.jsxs(i.Accordion,{disableGutters:!0,expanded:!le&&ae,onChange:()=>{if(!le){if(ae){const e=String(k||"");let t=e.includes(ve)||e.includes(be);t||O.forEach(e=>{(String(e).includes(ve)||String(e).includes(be))&&(t=!0)}),t&&(V(),q(new Set),L([]),G.current=[])}I(e=>({...e,[h]:!e[h]}))}},sx:{mt:0,boxShadow:"none",border:le?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}},children:[e.jsx(i.AccordionSummary,{expandIcon:le?null:e.jsx(n.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}},children:e.jsx(i.Typography,{component:"div",sx:{fontSize:"11px",fontWeight:600,color:le?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0},children:de||"Untitled Subsection"})}),!le&&e.jsxs(i.AccordionDetails,{sx:{pt:0,pb:1,minWidth:0},children:[re&&e.jsx(o.MemoizedMarkdown,{content:ne,overlayContent:oe,fallbackContent:se,sxStyles:C,deviationBadges:We,maintainRelativeOrder:v,highlightBg:De,suppressHighlightBg:Z,highlights:Ke,collisionKey:U}),(p.subsections||[]).map((t,i)=>e.jsx(u,{section:t,keyPath:`${h}-${i}`,depth:g+1,columnKey:f,parentNodeId:m,sectionOffset:x,rhsOrphanVisualIndexes:S},`${h}-${i}`))]})]})})}):e.jsx(i.Box,{ref:ce,sx:{mt:0===g?1:.75,width:"100%",minWidth:0,position:"relative"},children:!le&&e.jsxs(i.Box,{sx:{width:"100%",...Je},children:[re&&e.jsx(o.MemoizedMarkdown,{content:ne,overlayContent:oe,fallbackContent:se,sxStyles:C,deviationBadges:We,maintainRelativeOrder:v,highlightBg:De,suppressHighlightBg:Z,highlights:Ke,collisionKey:U}),(p.subsections||[]).map((t,i)=>e.jsx(u,{section:t,keyPath:`${h}-${i}`,depth:g+1,columnKey:f,parentNodeId:m,sectionOffset:x,rhsOrphanVisualIndexes:S},`${h}-${i}`))]})})});exports.default=u;
2
2
  //# sourceMappingURL=SubSectionAccordion.js.map