@viswa-test/test-citation 0.0.390 → 0.0.391
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.
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationRenderer.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationRenderer.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitivePopup.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CompareContext.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CompareContext.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js.map +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.css.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js.map +1 -1
- package/dist/cjs/features/PdfViewer/rotationManager.js +1 -1
- package/dist/cjs/features/PdfViewer/rotationManager.js.map +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js.map +1 -1
- package/dist/cjs/features/PdfViewer/zoomStateManager.js +2 -0
- package/dist/cjs/features/PdfViewer/zoomStateManager.js.map +1 -0
- package/dist/cjs/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/CognitiveScoreBadge.js.map +1 -1
- package/dist/cjs/features/SegmentReviewComponents/reviewStepAdapters.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/reviewStepAdapters.js.map +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js.map +1 -1
- package/dist/features/CognitiveCompare/CitationRenderer.js +1 -1
- package/dist/features/CognitiveCompare/CitationRenderer.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/features/CognitiveCompare/CognitivePopup.js.map +1 -1
- package/dist/features/CognitiveCompare/CompareContext.js +1 -1
- package/dist/features/CognitiveCompare/CompareContext.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
- package/dist/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js.map +1 -1
- package/dist/features/PdfViewer/PdfViewer.css.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js.map +1 -1
- package/dist/features/PdfViewer/rotationManager.js +1 -1
- package/dist/features/PdfViewer/rotationManager.js.map +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js.map +1 -1
- package/dist/features/PdfViewer/zoomStateManager.js +2 -0
- package/dist/features/PdfViewer/zoomStateManager.js.map +1 -0
- package/dist/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/features/SegmentReviewComponents/CognitiveScoreBadge.js.map +1 -1
- package/dist/features/SegmentReviewComponents/reviewStepAdapters.js +1 -1
- package/dist/features/SegmentReviewComponents/reviewStepAdapters.js.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts +0 -2
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts +1 -8
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts +3 -12
- package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts +0 -12
- package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitivePopup.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CompareContext.d.ts +2 -9
- package/dist/types/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +1 -14
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/LHSSectionRow.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/RHSSectionRow.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts +3 -2
- package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts +1 -2
- package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/rotationManager.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/usePdfHighlight.d.ts +1 -2
- package/dist/types/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/zoomStateManager.d.ts +21 -0
- package/dist/types/features/PdfViewer/zoomStateManager.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -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 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,cACT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AAc,WACdC,WAAY,SACZL,MAAO,OACPE,SAAU,GAGXV,SAAAX,EAAqBqG,GAAcH,WAK1CD,IACApF,EAAAA,KAAC8T,EAAAA,iBAAA,CACCpC,GAAI,CACFqC,GAAI,EACJC,GAAI,KACJhB,QAAS,UACTiB,KAAM,EACN/T,QAAS,OACTyR,cAAe,SACfnR,SAAU,GAGXV,SAAA,CACCoF,IAAA3E,EAAAA,IAAC2T,EAAAA,iBAAA,CACC9P,QAASU,GACTE,kBACAC,mBACAkP,SAAUnS,EACVoS,WAAYjD,GACZlP,wBACAwI,eACAnG,sBACA+P,gBAAiBnD,GACjB1N,kBAGFlC,EAAQmF,aAAe,IAAIhH,IAAI,CAAC6U,EAAKC,IACrCpS,EAA0B,CACxBb,QAASgT,EACTE,QAAS,GAAGjT,KAAOgT,IACnBE,MAAO,EACPjT,YACAM,eACA+E,iBACAgE,mCAMTlJ,GAAcyP,IAAMsD,WACnBnU,EAAAA,IAAC,MAAA,CACCN,MAAO,CACLiM,SAAU,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
|
+
{"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,oBACR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O,CACL2L,SAAU,SACVqI,OAAQ,EACR7C,OAAQ,MACRC,OAAQ,WAEVjB,QAAS,IACPM,IAAMwD,cAAc/D,SAASoB,eAAe,CAC1CC,SAAU,SACVC,MAAO,WAIX3R,SAAAS,EAAAA,IAAC,MAAA,CACCN,MAAO,CACLyR,UAAW,yCACK,SAAdlQ,EAAuB,IAAM,cAE/BoK,SAAU,WACVuI,cAAe,UACG,SAAd3S,EAAuB,CAACoQ,MAAO,SAAW,CAACC,KAAM,UAGvD/R,SAAAS,EAAAA,IAACoS,EAAAA,YAAA,CACC3R,MACE0P,IAAMwD,cAAc/D,QAChB4B,OAAOC,iBAAiBtB,GAAKwD,aAAa/D,SAASnP,WACnD,UAvLT,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"),
|
|
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;
|
|
2
2
|
//# sourceMappingURL=SubSectionAccordion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubSectionAccordion.js","sources":["../../../../../src/features/CognitiveCompare/components/SubSectionAccordion.tsx"],"sourcesContent":["import React, { useMemo, useEffect, useRef } from \"react\";\nimport {\n Box,\n Typography,\n Accordion,\n AccordionSummary,\n AccordionDetails,\n Tooltip,\n} from \"@mui/material\";\nimport { ChevronDown, EllipsisVertical } from \"lucide-react\";\n\nimport { ButtonCognitiveIcon } from \"../../../assests/svg/ButtonCognitiveIcon\";\nimport { MemoizedMarkdown } from \"../hooks/memoizedMarkdown\";\nimport { useCompareContext } from \"../CompareContext\";\nimport {\n hasValue,\n safeStringify,\n generateColorPalette,\n isMissingStr,\n DEVIATION_BADGE_SEPARATOR,\n hasMeaningfulRedlineTags,\n stripRedlineTags,\n findTextMatchRange,\n getRhsMappedSectionNumber,\n hasSingleMappedLhsSection,\n getLhsDeviationDisplayIndexes,\n} from \"../CognitiveComparehelpers\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport { DeviationDataEntry, SectionBlock, StyleVariant } from \"../CognitiveCompareTypes\";\nimport { normalizeRedlineMarkdown } from \"../utils/normalizeRedlineMarkdown\";\nimport { findTextRangeWithFormatting } from \"../utils/normalizeInlineMarkdown\";\n\ninterface SubSectionAccordionProps {\n section: SectionBlock;\n keyPath: string;\n depth?: number;\n columnKey?: \"left\" | \"right\";\n parentNodeId?: string;\n sectionOffset?: number;\n rhsOrphanVisualIndexes?: ReadonlyMap<string, number>;\n}\n\nconst SubSectionAccordion: React.FC<SubSectionAccordionProps> = React.memo((props) => {\n const {\n section,\n keyPath,\n depth = 0,\n columnKey = \"left\",\n parentNodeId = \"\",\n sectionOffset,\n rhsOrphanVisualIndexes,\n } = props;\n const {\n expandedSubSections,\n setExpandedSubSections,\n maintainRelativeOrder,\n showDeviationBadges = false,\n proposedSections,\n existingSections,\n treeData,\n deviationNumberRegistry,\n deviationParentRegistry,\n connectedSections,\n activeSideBySideSection,\n isSideBySide,\n scrollSyncLocked,\n toggleScrollSyncLocked,\n summaryPopupAnchorEl,\n resolvedMarkdownStyles,\n getSubSectionRef,\n getSubSectionCompareStyle,\n getBadgeRef,\n openMoreFunctionsPopup,\n openSummaryPopup,\n resetSideBySide,\n setConnectedSections,\n setConnectedLines,\n cachedConnectedPositions,\n isProposingFix,\n proposingFixNodeId,\n isRedlineFlow,\n unifiedNumbering,\n } = useCompareContext();\n\n const collisionKey = activeSideBySideSection ?? \"\";\n\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 = 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 const displayTitle = hasTitle ? section.title : hasContent ? \"No Title Found\" : \"No Matching Section Found\";\n const isExpanded = !!expandedSubSections[keyPath];\n const colRef = getSubSectionRef(columnKey, keyPath);\n \n const pathParts = keyPath.split('-').map(Number);\n const rootIndex = pathParts[0];\n\n let baseRoot: any = proposedSections[rootIndex];\n let refRoot: any = existingSections[rootIndex];\n let leftRootIndex = rootIndex;\n let rightRootIndex = rootIndex;\n let isRootOrphan = false;\n\n const findSectionPathById = (\n root: any,\n targetId: string | undefined,\n rootPath: string,\n ): { section: any; keyPath: string } | null => {\n if (!root || !targetId) return null;\n if (root.id === targetId || root.nodeId === targetId || root.contentId === targetId) return { section: root, keyPath: rootPath };\n\n const stack = (root.subsections || []).map((child: any, idx: number) => ({\n section: child,\n keyPath: `${rootPath}-${idx}`,\n }));\n\n while (stack.length > 0) {\n const current = stack.shift();\n if (!current?.section) continue;\n if (\n current.section.id === targetId ||\n current.section.nodeId === targetId ||\n current.section.contentId === targetId\n ) return current;\n\n (current.section.subsections || []).forEach((child: any, idx: number) => {\n stack.push({\n section: child,\n keyPath: `${current.keyPath}-${idx}`,\n });\n });\n }\n\n return null;\n };\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = baseRoot?.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n if (rhsArrayIdx !== -1) {\n refRoot = existingSections[rhsArrayIdx];\n rightRootIndex = rhsArrayIdx;\n } else {\n isRootOrphan = true;\n }\n } else {\n const lhsSelfIndex = refRoot?.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (lhsArrayIdx !== -1) {\n baseRoot = proposedSections[lhsArrayIdx];\n leftRootIndex = lhsArrayIdx;\n } else {\n isRootOrphan = true;\n }\n }\n }\n\n // --- UNIFIED COUNTERPART LOOKUP ENGINE ---\n const findGlobalPathById = (sections: any[], targetId: string | undefined) => {\n if (!targetId || !sections) return null;\n for (let i = 0; i < sections.length; i++) {\n const match = findSectionPathById(sections[i], targetId, String(i));\n if (match) return match;\n }\n return null;\n };\n\n let bSec: any = null;\n let rSec: any = null;\n let leftKeyPath = \"\";\n let rightKeyPath = \"\";\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n bSec = section;\n leftKeyPath = keyPath;\n\n // Try looking within the relative matched root section first\n let rightMatch = findSectionPathById(refRoot, section.nodeId || section.id, String(rightRootIndex));\n \n // Fallback globally across the entire RHS tree if cross-wired or mismatched\n if (!rightMatch) {\n rightMatch = findGlobalPathById(existingSections, section.nodeId || section.id);\n }\n\n rSec = rightMatch?.section || null;\n rightKeyPath = rightMatch?.keyPath || \"\";\n } else {\n rSec = section;\n rightKeyPath = keyPath;\n\n // Try looking within the relative matched root section first\n let leftMatch = findSectionPathById(baseRoot, section.nodeId || section.id, String(leftRootIndex));\n \n // Fallback globally across the entire LHS tree if cross-wired or mismatched\n if (!leftMatch) {\n leftMatch = findGlobalPathById(proposedSections, section.nodeId || section.id);\n }\n\n bSec = leftMatch?.section || null;\n leftKeyPath = leftMatch?.keyPath || \"\";\n }\n } else {\n // When maintainRelativeOrder is false, absolute structural paths diverge completely.\n // Index path crawling fails here. Execute absolute global ID tracing to handle re-routed clauses.\n if (columnKey === \"left\") {\n bSec = section;\n leftKeyPath = keyPath;\n\n const rightMatch = findGlobalPathById(existingSections, section.nodeId || section.id);\n rSec = rightMatch?.section || null;\n rightKeyPath = rightMatch?.keyPath || \"\";\n } else {\n rSec = section;\n rightKeyPath = keyPath;\n\n const leftMatch = findGlobalPathById(proposedSections, section.nodeId || section.id);\n bSec = leftMatch?.section || null;\n leftKeyPath = leftMatch?.keyPath || \"\";\n }\n }\n\n const style = (leftKeyPath ? getSubSectionCompareStyle(leftKeyPath) : null) || getSubSectionCompareStyle(keyPath);\n const leftDocId = treeData?.input_index_map?.[\"0\"];\n const rightDocId = treeData?.input_index_map?.[\"1\"];\n const counterpartNodeId = columnKey === \"left\" ? rightDocId : leftDocId;\n\n const isSecOrphan = columnKey === \"left\" ? !rSec : !bSec;\n const hasSingleMappedLhs =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n hasSingleMappedLhsSection(refRoot, proposedSections);\n \n const targetEvalResult = section.evaluationResult || bSec?.evaluationResult || rSec?.evaluationResult;\n\n const deviations = targetEvalResult?.deviations || {};\n const lhsDeviationDisplayIndexes = 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 let nodeId = section.nodeId || section.id || bSec?.nodeId || bSec?.id || rSec?.nodeId || rSec?.id;\n\n // For Subsections, use the exact LHS counterpart subsection (bSec) ID for registry lookup\n if (maintainRelativeOrder && columnKey !== \"left\") {\n if (bSec?.id) {\n nodeId = bSec.nodeId || bSec.id;\n }\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 = rootIndex + 1;\n\n if (maintainRelativeOrder && unifiedNumbering) {\n const unifiedNum = columnKey === \"left\" \n ? unifiedNumbering.leftNums.get(baseRoot?.id) \n : unifiedNumbering.rightNums.get(refRoot?.id);\n\n if (isRootOrphan && 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\n const deviationColorData = targetEvalResult?.evaluation_outputs?.metadata?.label_color ?? DEFAULT_DEVIAION_COLOR;\n const deviationPalette = generateColorPalette(deviationColorData);\n const { highlightBg } = deviationPalette;\n\n \n const highlights: string[] = [];\n \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 // Missing numbering metadata must not suppress an otherwise renderable\n // inline deviation badge.\n const currentIndex = deviationNumberRegistry[refId] ?? nextFallbackDeviationIndex++;\n return { deviationKey, deviationMap, refId, currentIndex };\n });\n\n rawDeviationEntries.sort((a, b) => a.currentIndex - b.currentIndex);\n\n const localRhsOrphanVisualIndexes = new Map<string, number>();\n if (\n !rhsOrphanVisualIndexes &&\n maintainRelativeOrder &&\n columnKey === \"right\"\n ) {\n const normalizedContent = safeStringify(baseContent || \"\").replace(/\\\\n/g, \"\\n\");\n rawDeviationEntries\n .filter(({ deviationMap }) => {\n const ownHighlight = deviationMap[parentNodeId];\n const isOrphan =\n isSecOrphan || isMissingStr(deviationMap[counterpartNodeId as string]);\n return isOrphan && !!ownHighlight && !isMissingStr(ownHighlight);\n })\n .map((entry) => {\n const normalizedHighlight = safeStringify(\n entry.deviationMap[parentNodeId] || \"\",\n ).replace(/\\\\n/g, \"\\n\");\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 return { ...entry, position };\n })\n .sort((a, b) => {\n const aPosition = a.position === -1 ? Number.MAX_SAFE_INTEGER : a.position;\n const bPosition = b.position === -1 ? Number.MAX_SAFE_INTEGER : b.position;\n return aPosition - bPosition || a.currentIndex - b.currentIndex;\n })\n .forEach((entry, index) => {\n localRhsOrphanVisualIndexes.set(entry.refId, index + 1);\n });\n }\n\n const deviationEntries = rawDeviationEntries\n .map((item) => {\n const { deviationKey, deviationMap, refId } = item;\n let currentIndex = item.currentIndex;\n\n // if (maintainRelativeOrder && sectionOffset !== undefined) {\n // currentIndex = currentIndex - sectionOffset;\n // }\n // currentIndex = Math.max(1, currentIndex);\n\n let highlight = deviationMap[parentNodeId];\n const isMissingClause = isMissingStr(highlight);\n\n if (isMissingClause) highlight = \"\";\n else if (!highlight) return null;\n\n highlights.push(highlight);\n\n const counterpartHighlight = deviationMap[counterpartNodeId as string];\n\n const isDeviationOrphan = isSecOrphan || isMissingStr(counterpartHighlight);\n const orphanVisualIndex =\n rhsOrphanVisualIndexes?.get(refId) ??\n localRhsOrphanVisualIndexes.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: refRoot,\n proposedSections,\n leftNums: unifiedNumbering.leftNums,\n fallbackNumber: String(validatedParentNum),\n firstOnly: true,\n })\n : validatedParentNum;\n const badgeLabel = `${badgeParentNum}.${currentIndex}`;\n const actionId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}${DEVIATION_BADGE_SEPARATOR}${leftKeyPath}${DEVIATION_BADGE_SEPARATOR}${rightKeyPath}`;\n const deviationOutput = deviationMap?.evaluation_outputs || targetEvalResult?.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 = { ...deviationPaletteForBadge } as StyleVariant;\n\n const summaryPayload = deviationMap?.deviation_summary\n ? {\n deviation_summary: deviationMap.deviation_summary || targetEvalResult?.deviation_summary,\n deviation_title: deviationMap?.deviation_title || targetEvalResult?.deviation_title,\n deviation_impact: deviationMap?.deviation_impact || targetEvalResult?.deviation_impact,\n deviation_explanation:\n deviationMap?.deviation_explanation || targetEvalResult?.deviation_explanation,\n evaluation_outputs: deviationOutput,\n cognitive_decisioning:\n deviationMap?.cognitive_decisioning || targetEvalResult?.cognitive_decisioning,\n }\n : null;\n\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\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 as any),\n showScrollLockToggle:\n connectedSections.has(actionId as any) ||\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 const matchedBaseRoot = leftKeyPath\n ? proposedSections[Number(leftKeyPath.split(\"-\")[0])] || baseRoot\n : baseRoot;\n const matchedRefRoot = rightKeyPath\n ? existingSections[Number(rightKeyPath.split(\"-\")[0])] || refRoot\n : refRoot;\n const popupBaseSec = bSec ? { ...bSec, title: matchedBaseRoot?.title || bSec?.title || \"\" } : { id: \"orphan-left\", title: \"\", content: \"\" };\n const popupRefSec = rSec ? { ...rSec, title: matchedRefRoot?.title || rSec?.title || \"\" } : { id: \"orphan-right\", title: \"\", content: \"\" };\n \n openMoreFunctionsPopup(e, popupBaseSec, isDeviationOrphan, popupRefSec, actionId, badgeStyle); \n },\n onSummaryClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n openSummaryPopup(e, actionId, isDeviationOrphan, summaryPayload);\n }\n };\n })\n .filter(Boolean)\n .sort((a: any, b: any) => {\n const numA = parseFloat(a.label);\n const numB = parseFloat(b.label);\n return numA - numB;\n });\n\n const deduplicatedEntries = useMemo(() => {\n const seenRefIds = new Set<string>();\n return deviationEntries.filter((entry: any) => {\n if (seenRefIds.has(entry.id)) return false;\n seenRefIds.add(entry.id);\n return true;\n });\n }, [deviationEntries]);\n\n\n const baseShouldRenderBadges = showDeviationBadges || isProposedFixTarget;\n const shouldRenderBadges = baseShouldRenderBadges;\n const deviationBadgesToRender = shouldRenderBadges ? deduplicatedEntries : [];\nconst highlightsToRender = deduplicatedEntries.map((b: any) => b.highlight).filter(Boolean);\n\n // const hasScrolledRef = useRef(false);\n\n // useEffect(() => {\n // if (!isExpanded) {\n // hasScrolledRef.current = false;\n // }\n // }, [isExpanded]);\n\n // useEffect(() => {\n // if (!isExpanded || hasScrolledRef.current) return;\n\n // const timer = setTimeout(() => {\n // hasScrolledRef.current = true;\n \n // const firstBadgeRef = deviationEntries[0]?.badgeRef?.current;\n \n // if (firstBadgeRef) {\n // firstBadgeRef.scrollIntoView({\n // behavior: \"smooth\",\n // block: \"center\",\n // });\n // }\n // }, 350); \n\n // return () => clearTimeout(timer);\n // }, [isExpanded, deviationEntries]);\n\n const connectedBadge = deviationEntries.find((b: any) => connectedSections.has(b.actionId));\n const isConnected = !!connectedBadge;\n\n if (!hasTitle && !hasContent && (!section.subsections || section.subsections.length === 0)) return null;\n\n const handleToggle = () => {\n if (!isEmpty) {\n if (isExpanded) {\n const activeBadgeIdStr = String(activeSideBySideSection || \"\");\n let needsReset = activeBadgeIdStr.includes(leftKeyPath) || activeBadgeIdStr.includes(rightKeyPath);\n\n if (!needsReset) {\n connectedSections.forEach((id) => {\n if (String(id).includes(leftKeyPath) || String(id).includes(rightKeyPath)) needsReset = true;\n });\n }\n\n if (needsReset) {\n resetSideBySide();\n setConnectedSections(new Set());\n setConnectedLines([]);\n cachedConnectedPositions.current = [];\n }\n }\n setExpandedSubSections((prev) => ({ ...prev, [keyPath]: !prev[keyPath] }));\n }\n };\n const outlineColor = connectedBadge?.style?.badgeBorder || style?.badgeBorder;\n const outlineStyles = isConnected && outlineColor\n ? { borderRadius: \"4px\", outline: `2px solid ${outlineColor}`, outlineOffset: \"1px\" }\n : {};\n\n if (!hasTitle) {\n return (\n <Box ref={colRef} sx={{ mt: depth === 0 ? 1 : 0.75, width: \"100%\", minWidth: 0, position: \"relative\" }}>\n {!isEmpty && (\n <Box sx={{ width: \"100%\", ...outlineStyles }}>\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n fallbackContent={fallbackContent}\n sxStyles={resolvedMarkdownStyles}\n deviationBadges={deviationBadgesToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n highlights={highlightsToRender} \n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) => (\n <SubSectionAccordion\n key={`${keyPath}-${subIdx}`}\n section={sub}\n keyPath={`${keyPath}-${subIdx}`}\n depth={depth + 1}\n columnKey={columnKey}\n parentNodeId={parentNodeId}\n sectionOffset={sectionOffset}\n rhsOrphanVisualIndexes={rhsOrphanVisualIndexes}\n />\n ))}\n </Box>\n )}\n </Box>\n );\n }\n\n return (\n <Box ref={colRef} sx={{ mt: 1, width: \"100%\", minWidth: 0, position: \"relative\" }}>\n <Box sx={{ width: \"100%\", ...outlineStyles }}>\n <Accordion\n disableGutters\n expanded={isEmpty ? false : isExpanded}\n onChange={handleToggle}\n sx={{\n mt: 0,\n boxShadow: \"none\",\n border: isEmpty ? \"1px dashed #E2E8F0\" : \"1px solid #EEF2F7\",\n borderRadius: \"4px !important\",\n bgcolor: \"#FFFFFF\",\n minWidth: 0,\n \"&:before\": { display: \"none\" },\n }}\n >\n <AccordionSummary expandIcon={isEmpty ? null : <ChevronDown size={14} />} sx={{ minHeight: \"32px\", \"& .MuiAccordionSummary-content\": { my: 0.5, display: \"grid\", alignItems: \"center\", minWidth: 0, width: \"100%\" } }}>\n <Typography component=\"div\" sx={{ fontSize: \"11px\", fontWeight: 600, color: isEmpty ? \"#94A3B8\" : \"#19213D\", overflow: \"hidden\", textOverflow: \"ellipsis\", whiteSpace: \"nowrap\", width: \"100%\", minWidth: 0 }}>\n {displayTitle || \"Untitled Subsection\"}\n </Typography>\n </AccordionSummary>\n {!isEmpty && (\n <AccordionDetails sx={{ pt: 0, pb: 1, minWidth: 0 }}>\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n fallbackContent={fallbackContent}\n sxStyles={resolvedMarkdownStyles}\n deviationBadges={deviationBadgesToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n highlights={highlightsToRender}\n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) => (\n <SubSectionAccordion\n key={`${keyPath}-${subIdx}`}\n section={sub}\n keyPath={`${keyPath}-${subIdx}`}\n depth={depth + 1}\n columnKey={columnKey}\n parentNodeId={parentNodeId}\n sectionOffset={sectionOffset}\n rhsOrphanVisualIndexes={rhsOrphanVisualIndexes}\n />\n ))}\n </AccordionDetails>\n )}\n </Accordion>\n </Box>\n </Box>\n );\n});\n\nexport default SubSectionAccordion;\n"],"names":["SubSectionAccordion","memo","props","section","keyPath","depth","columnKey","parentNodeId","sectionOffset","rhsOrphanVisualIndexes","expandedSubSections","setExpandedSubSections","maintainRelativeOrder","showDeviationBadges","proposedSections","existingSections","treeData","deviationNumberRegistry","deviationParentRegistry","connectedSections","activeSideBySideSection","isSideBySide","scrollSyncLocked","toggleScrollSyncLocked","summaryPopupAnchorEl","resolvedMarkdownStyles","getSubSectionRef","getSubSectionCompareStyle","getBadgeRef","openMoreFunctionsPopup","openSummaryPopup","resetSideBySide","setConnectedSections","setConnectedLines","cachedConnectedPositions","isProposingFix","proposingFixNodeId","isRedlineFlow","unifiedNumbering","useCompareContext","collisionKey","hasTitle","displayTitle","hasValue","title","isProposedFixTarget","id","nodeId","contentId","hasRedlineTags","hasMeaningfulRedlineTags","content","resolvedRedlineFlow","suppressHighlightBg","changeHistoryContent","change_history","shouldOverlayContent","normalizedRedlineContent","useMemo","normalizeRedlineMarkdown","safeStringify","baseContent","stripRedlineTags","overlayContent","fallbackContent","hasContent","displayContent","isEmpty","isExpanded","colRef","rootIndex","split","map","Number","baseRoot","refRoot","leftRootIndex","rightRootIndex","isRootOrphan","findSectionPathById","root","targetId","rootPath","stack","subsections","child","idx","length","current","shift","forEach","push","rhsSelfIndex","refIndexes","rhsArrayIdx","findIndex","s","selfIndex","lhsSelfIndex","lhsArrayIdx","findGlobalPathById","sections","i","match","String","bSec","rSec","leftKeyPath","rightKeyPath","rightMatch","leftMatch","style","leftDocId","input_index_map","rightDocId","counterpartNodeId","isSecOrphan","hasSingleMappedLhs","hasSingleMappedLhsSection","targetEvalResult","evaluationResult","deviations","lhsDeviationDisplayIndexes","getLhsDeviationDisplayIndexes","Map","firstDeviationKey","Object","keys","firstRefId","DEVIATION_BADGE_SEPARATOR","registeredParentNum","validatedParentNum","unifiedNum","leftNums","get","rightNums","deviationColorData","evaluation_outputs","metadata","label_color","DEFAULT_DEVIAION_COLOR","deviationPalette","generateColorPalette","highlightBg","nextFallbackDeviationIndex","Math","max","deviationKey","filter","value","isFinite","rawDeviationEntries","entries","deviationMap","refId","currentIndex","sort","a","b","localRhsOrphanVisualIndexes","normalizedContent","replace","ownHighlight","isMissingStr","entry","normalizedHighlight","position","findTextMatchRange","start","findTextRangeWithFormatting","MAX_SAFE_INTEGER","index","set","deviationEntries","item","highlight","isMissingClause","counterpartHighlight","isDeviationOrphan","orphanVisualIndex","mappedLhsIndex","badgeLabel","getRhsMappedSectionNumber","fallbackNumber","firstOnly","actionId","deviationOutput","deviationScore","output_value","deviationColorForBadge","badgeStyle","summaryPayload","deviation_summary","deviation_title","deviation_impact","deviation_explanation","cognitive_decisioning","stackIndex","contentStr","paragraphs","paraIndex","p","includes","overlappingDevs","_","dMap","hl","indexOf","k","badgeRef","label","side","score","isConnected","has","showScrollLockToggle","isOrphan","onClick","e","stopPropagation","matchedBaseRoot","matchedRefRoot","popupBaseSec","popupRefSec","onSummaryClick","Boolean","parseFloat","deduplicatedEntries","seenRefIds","Set","add","deviationBadgesToRender","highlightsToRender","connectedBadge","find","outlineColor","badgeBorder","outlineStyles","borderRadius","outline","outlineOffset","jsx","Box","ref","sx","mt","width","minWidth","children","jsxs","Accordion","disableGutters","expanded","onChange","activeBadgeIdStr","needsReset","prev","boxShadow","border","bgcolor","display","AccordionSummary","expandIcon","ChevronDown","size","minHeight","my","alignItems","Typography","component","fontSize","fontWeight","color","overflow","textOverflow","whiteSpace","AccordionDetails","pt","pb","MemoizedMarkdown","sxStyles","deviationBadges","highlights","sub","subIdx"],"mappings":"8fA0CA,MAAMA,OAA0D,QAAMC,KAAMC,IACpE,MAAAC,QACJA,EAAAC,QACAA,EAAAC,MACAA,EAAQ,EAAAC,UACRA,EAAY,OAAAC,aACZA,EAAe,GAAAC,cACfA,EAAAC,uBACAA,GACEP,GACEQ,oBACJA,EAAAC,uBACAA,EAAAC,sBACAA,EAAAC,oBACAA,GAAsB,EAAAC,iBACtBA,EAAAC,iBACAA,EAAAC,SACAA,EAAAC,wBACAA,EAAAC,wBACAA,EAAAC,kBACAA,EAAAC,wBACAA,EAAAC,aACAA,EAAAC,iBACAA,EAAAC,uBAC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,eACA1F,sBACAqO,WAAYlD,GACZhM,kBAGFrC,EAAQiF,aAAe,IAAIZ,IAAI,CAACmN,EAAKC,IACrC3C,EAAAA,IAACjP,EAAA,CAECG,QAASwR,EACTvR,QAAS,GAAGA,KAAWwR,IACvBvR,MAAOA,EAAQ,EACfC,YACAC,eACAC,gBACAC,0BAPK,GAAGL,KAAWwR,gBA3E9B3C,EAAAA,IAAAC,EAAAA,IAAA,CAAIC,IAAK9K,GAAQ+K,GAAI,CAAEC,GAAc,IAAVhP,EAAc,EAAI,IAAMiP,MAAO,OAAQC,SAAU,EAAGjF,SAAU,YACvFkF,UAACrL,IACCsL,EAAAA,KAAAP,EAAAA,IAAA,CAAIE,GAAI,CAAEE,MAAO,UAAWT,IAC1BW,SAAA,CACCvL,IAAAgL,EAAAA,IAACsC,EAAAA,iBAAA,CACCpO,QAASU,GACTE,kBACAC,mBACAwN,SAAU/P,EACVgQ,gBAAiBlD,GACjB3N,wBACAmI,eACA1F,sBACAqO,WAAYlD,GACZhM,kBAGFrC,EAAQiF,aAAe,IAAIZ,IAAI,CAACmN,EAAKC,IACnC3C,EAAAA,IAACjP,EAAA,CAECG,QAASwR,EACTvR,QAAS,GAAGA,KAAWwR,IACvBvR,MAAOA,EAAQ,EACfC,YACAC,eACAC,gBACAC,0BAPK,GAAGL,KAAWwR"}
|
|
1
|
+
{"version":3,"file":"SubSectionAccordion.js","sources":["../../../../../src/features/CognitiveCompare/components/SubSectionAccordion.tsx"],"sourcesContent":["import React, { useMemo, useEffect, useRef } from \"react\";\nimport {\n Box,\n Typography,\n Accordion,\n AccordionSummary,\n AccordionDetails,\n Tooltip,\n} from \"@mui/material\";\nimport { ChevronDown, EllipsisVertical } from \"lucide-react\";\n\nimport { ButtonCognitiveIcon } from \"../../../assests/svg/ButtonCognitiveIcon\";\nimport { MemoizedMarkdown } from \"../hooks/memoizedMarkdown\";\nimport { useCompareContext } from \"../CompareContext\";\nimport {\n hasValue,\n safeStringify,\n generateColorPalette,\n isMissingStr,\n DEVIATION_BADGE_SEPARATOR,\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\";\n\ninterface SubSectionAccordionProps {\n section: SectionBlock;\n keyPath: string;\n depth?: number;\n columnKey?: \"left\" | \"right\";\n parentNodeId?: string;\n sectionOffset?: number;\n rhsOrphanVisualIndexes?: ReadonlyMap<string, number>;\n}\n\nconst SubSectionAccordion: React.FC<SubSectionAccordionProps> = React.memo((props) => {\n const {\n section,\n keyPath,\n depth = 0,\n columnKey = \"left\",\n parentNodeId = \"\",\n sectionOffset,\n rhsOrphanVisualIndexes,\n } = props;\n const {\n expandedSubSections,\n setExpandedSubSections,\n maintainRelativeOrder,\n showDeviationBadges = false,\n proposedSections,\n existingSections,\n treeData,\n deviationNumberRegistry,\n deviationParentRegistry,\n connectedSections,\n activeSideBySideSection,\n isSideBySide,\n scrollSyncLocked,\n toggleScrollSyncLocked,\n summaryPopupAnchorEl,\n resolvedMarkdownStyles,\n getSubSectionRef,\n getSubSectionCompareStyle,\n getBadgeRef,\n openMoreFunctionsPopup,\n openSummaryPopup,\n resetSideBySide,\n setConnectedSections,\n setConnectedLines,\n cachedConnectedPositions,\n isProposingFix,\n proposingFixNodeId,\n isRedlineFlow,\n unifiedNumbering,\n } = useCompareContext();\n\n const collisionKey = activeSideBySideSection ?? \"\";\n\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\n const displayTitle = hasTitle ? section.title : hasContent ? \"No Title Found\" : \"No Matching Section Found\";\n const isExpanded = !!expandedSubSections[keyPath];\n const colRef = getSubSectionRef(columnKey, keyPath);\n \n const pathParts = keyPath.split('-').map(Number);\n const rootIndex = pathParts[0];\n\n let baseRoot: any = proposedSections[rootIndex];\n let refRoot: any = existingSections[rootIndex];\n let leftRootIndex = rootIndex;\n let rightRootIndex = rootIndex;\n let isRootOrphan = false;\n\n const findSectionPathById = (\n root: any,\n targetId: string | undefined,\n rootPath: string,\n ): { section: any; keyPath: string } | null => {\n if (!root || !targetId) return null;\n if (root.id === targetId || root.nodeId === targetId || root.contentId === targetId) return { section: root, keyPath: rootPath };\n\n const stack = (root.subsections || []).map((child: any, idx: number) => ({\n section: child,\n keyPath: `${rootPath}-${idx}`,\n }));\n\n while (stack.length > 0) {\n const current = stack.shift();\n if (!current?.section) continue;\n if (\n current.section.id === targetId ||\n current.section.nodeId === targetId ||\n current.section.contentId === targetId\n ) return current;\n\n (current.section.subsections || []).forEach((child: any, idx: number) => {\n stack.push({\n section: child,\n keyPath: `${current.keyPath}-${idx}`,\n });\n });\n }\n\n return null;\n };\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n const rhsSelfIndex = baseRoot?.refIndexes?.[0];\n const rhsArrayIdx = existingSections.findIndex((s: any) => s.selfIndex === rhsSelfIndex);\n if (rhsArrayIdx !== -1) {\n refRoot = existingSections[rhsArrayIdx];\n rightRootIndex = rhsArrayIdx;\n } else {\n isRootOrphan = true;\n }\n } else {\n const lhsSelfIndex = refRoot?.refIndexes?.[0];\n const lhsArrayIdx = proposedSections.findIndex((s: any) => s.selfIndex === lhsSelfIndex);\n if (lhsArrayIdx !== -1) {\n baseRoot = proposedSections[lhsArrayIdx];\n leftRootIndex = lhsArrayIdx;\n } else {\n isRootOrphan = true;\n }\n }\n }\n\n // --- UNIFIED COUNTERPART LOOKUP ENGINE ---\n const findGlobalPathById = (sections: any[], targetId: string | undefined) => {\n if (!targetId || !sections) return null;\n for (let i = 0; i < sections.length; i++) {\n const match = findSectionPathById(sections[i], targetId, String(i));\n if (match) return match;\n }\n return null;\n };\n\n let bSec: any = null;\n let rSec: any = null;\n let leftKeyPath = \"\";\n let rightKeyPath = \"\";\n\n if (maintainRelativeOrder) {\n if (columnKey === \"left\") {\n bSec = section;\n leftKeyPath = keyPath;\n\n // Try looking within the relative matched root section first\n let rightMatch = findSectionPathById(refRoot, section.nodeId || section.id, String(rightRootIndex));\n \n // Fallback globally across the entire RHS tree if cross-wired or mismatched\n if (!rightMatch) {\n rightMatch = findGlobalPathById(existingSections, section.nodeId || section.id);\n }\n\n rSec = rightMatch?.section || null;\n rightKeyPath = rightMatch?.keyPath || \"\";\n } else {\n rSec = section;\n rightKeyPath = keyPath;\n\n // Try looking within the relative matched root section first\n let leftMatch = findSectionPathById(baseRoot, section.nodeId || section.id, String(leftRootIndex));\n \n // Fallback globally across the entire LHS tree if cross-wired or mismatched\n if (!leftMatch) {\n leftMatch = findGlobalPathById(proposedSections, section.nodeId || section.id);\n }\n\n bSec = leftMatch?.section || null;\n leftKeyPath = leftMatch?.keyPath || \"\";\n }\n } else {\n // When maintainRelativeOrder is false, absolute structural paths diverge completely.\n // Index path crawling fails here. Execute absolute global ID tracing to handle re-routed clauses.\n if (columnKey === \"left\") {\n bSec = section;\n leftKeyPath = keyPath;\n\n const rightMatch = findGlobalPathById(existingSections, section.nodeId || section.id);\n rSec = rightMatch?.section || null;\n rightKeyPath = rightMatch?.keyPath || \"\";\n } else {\n rSec = section;\n rightKeyPath = keyPath;\n\n const leftMatch = findGlobalPathById(proposedSections, section.nodeId || section.id);\n bSec = leftMatch?.section || null;\n leftKeyPath = leftMatch?.keyPath || \"\";\n }\n }\n\n const style = (leftKeyPath ? getSubSectionCompareStyle(leftKeyPath) : null) || getSubSectionCompareStyle(keyPath);\n const leftDocId = treeData?.input_index_map?.[\"0\"];\n const rightDocId = treeData?.input_index_map?.[\"1\"];\n const counterpartNodeId = columnKey === \"left\" ? rightDocId : leftDocId;\n\n const isSecOrphan = columnKey === \"left\" ? !rSec : !bSec;\n const hasSingleMappedLhs =\n maintainRelativeOrder &&\n columnKey === \"right\" &&\n hasSingleMappedLhsSection(refRoot, proposedSections);\n \n const targetEvalResult = section.evaluationResult || bSec?.evaluationResult || rSec?.evaluationResult;\n\n const deviations = targetEvalResult?.deviations || {};\n const lhsDeviationDisplayIndexes = 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 let nodeId = section.nodeId || section.id || bSec?.nodeId || bSec?.id || rSec?.nodeId || rSec?.id;\n\n // For Subsections, use the exact LHS counterpart subsection (bSec) ID for registry lookup\n if (maintainRelativeOrder && columnKey !== \"left\") {\n if (bSec?.id) {\n nodeId = bSec.nodeId || bSec.id;\n }\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 = rootIndex + 1;\n\n if (maintainRelativeOrder && unifiedNumbering) {\n const unifiedNum = columnKey === \"left\" \n ? unifiedNumbering.leftNums.get(baseRoot?.id) \n : unifiedNumbering.rightNums.get(refRoot?.id);\n\n if (isRootOrphan && 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\n const deviationColorData = targetEvalResult?.evaluation_outputs?.metadata?.label_color ?? DEFAULT_DEVIAION_COLOR;\n const deviationPalette = generateColorPalette(deviationColorData);\n const { highlightBg } = deviationPalette;\n\n \n const highlights: string[] = [];\n \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 rawDeviationEntries.sort((a, b) => a.currentIndex - b.currentIndex);\n\n const localRhsOrphanVisualIndexes = new Map<string, number>();\n if (\n !rhsOrphanVisualIndexes &&\n maintainRelativeOrder &&\n columnKey === \"right\"\n ) {\n const normalizedContent = safeStringify(baseContent || \"\").replace(/\\\\n/g, \"\\n\");\n rawDeviationEntries\n .filter(({ deviationMap }) => {\n const ownHighlight = deviationMap[parentNodeId];\n const isOrphan =\n isSecOrphan || isMissingStr(deviationMap[counterpartNodeId as string]);\n return isOrphan && !!ownHighlight && !isMissingStr(ownHighlight);\n })\n .map((entry) => {\n const normalizedHighlight = safeStringify(\n entry.deviationMap[parentNodeId] || \"\",\n ).replace(/\\\\n/g, \"\\n\");\n const position = normalizedHighlight\n ? normalizedContent.indexOf(normalizedHighlight)\n : -1;\n return { ...entry, position };\n })\n .sort((a, b) => {\n const aPosition = a.position === -1 ? Number.MAX_SAFE_INTEGER : a.position;\n const bPosition = b.position === -1 ? Number.MAX_SAFE_INTEGER : b.position;\n return aPosition - bPosition || a.currentIndex - b.currentIndex;\n })\n .forEach((entry, index) => {\n localRhsOrphanVisualIndexes.set(entry.refId, index + 1);\n });\n }\n\n const deviationEntries = rawDeviationEntries\n .map((item) => {\n const { deviationKey, deviationMap, refId } = item;\n let currentIndex = item.currentIndex;\n\n // if (maintainRelativeOrder && sectionOffset !== undefined) {\n // currentIndex = currentIndex - sectionOffset;\n // }\n // currentIndex = Math.max(1, currentIndex);\n\n let highlight = deviationMap[parentNodeId];\n const isMissingClause = isMissingStr(highlight);\n\n if (isMissingClause) highlight = \"\";\n else if (!highlight) return null;\n\n highlights.push(highlight);\n\n const counterpartHighlight = deviationMap[counterpartNodeId as string];\n\n const isDeviationOrphan = isSecOrphan || isMissingStr(counterpartHighlight);\n const orphanVisualIndex =\n rhsOrphanVisualIndexes?.get(refId) ??\n localRhsOrphanVisualIndexes.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: refRoot,\n proposedSections,\n leftNums: unifiedNumbering.leftNums,\n fallbackNumber: String(validatedParentNum),\n firstOnly: true,\n })\n : validatedParentNum;\n const badgeLabel = `${badgeParentNum}.${currentIndex}`;\n const actionId = `${nodeId}${DEVIATION_BADGE_SEPARATOR}${deviationKey}${DEVIATION_BADGE_SEPARATOR}${leftKeyPath}${DEVIATION_BADGE_SEPARATOR}${rightKeyPath}`;\n const deviationOutput = deviationMap?.evaluation_outputs || targetEvalResult?.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 = { ...deviationPaletteForBadge } as StyleVariant;\n\n const summaryPayload = deviationMap?.deviation_summary\n ? {\n deviation_summary: deviationMap.deviation_summary || targetEvalResult?.deviation_summary,\n deviation_title: deviationMap?.deviation_title || targetEvalResult?.deviation_title,\n deviation_impact: deviationMap?.deviation_impact || targetEvalResult?.deviation_impact,\n deviation_explanation:\n deviationMap?.deviation_explanation || targetEvalResult?.deviation_explanation,\n evaluation_outputs: deviationOutput,\n cognitive_decisioning:\n deviationMap?.cognitive_decisioning || targetEvalResult?.cognitive_decisioning,\n }\n : null;\n\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\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 as any),\n showScrollLockToggle:\n connectedSections.has(actionId as any) ||\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 const popupBaseSec = bSec ? { ...bSec, title: baseRoot?.title || bSec?.title || \"\" } : { id: \"orphan-left\", title: \"\", content: \"\" };\n const popupRefSec = rSec ? { ...rSec, title: refRoot?.title || rSec?.title || \"\" } : { id: \"orphan-right\", title: \"\", content: \"\" };\n \n openMoreFunctionsPopup(e, popupBaseSec, isDeviationOrphan, popupRefSec, actionId, badgeStyle); \n },\n onSummaryClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n openSummaryPopup(e, actionId, isDeviationOrphan, summaryPayload);\n }\n };\n })\n .filter(Boolean)\n .sort((a: any, b: any) => {\n const numA = parseFloat(a.label);\n const numB = parseFloat(b.label);\n return numA - numB;\n });\n\n const deduplicatedEntries = useMemo(() => {\n const seenRefIds = new Set<string>();\n return deviationEntries.filter((entry: any) => {\n if (seenRefIds.has(entry.id)) return false;\n seenRefIds.add(entry.id);\n return true;\n });\n }, [deviationEntries]);\n\n\n const baseShouldRenderBadges =\n showDeviationBadges || (!resolvedRedlineFlow && isProposedFixTarget);\n const shouldRenderBadges = baseShouldRenderBadges;\n const deviationBadgesToRender = shouldRenderBadges ? deduplicatedEntries : [];\nconst highlightsToRender = deduplicatedEntries.map((b: any) => b.highlight).filter(Boolean);\n\n // const hasScrolledRef = useRef(false);\n\n // useEffect(() => {\n // if (!isExpanded) {\n // hasScrolledRef.current = false;\n // }\n // }, [isExpanded]);\n\n // useEffect(() => {\n // if (!isExpanded || hasScrolledRef.current) return;\n\n // const timer = setTimeout(() => {\n // hasScrolledRef.current = true;\n \n // const firstBadgeRef = deviationEntries[0]?.badgeRef?.current;\n \n // if (firstBadgeRef) {\n // firstBadgeRef.scrollIntoView({\n // behavior: \"smooth\",\n // block: \"center\",\n // });\n // }\n // }, 350); \n\n // return () => clearTimeout(timer);\n // }, [isExpanded, deviationEntries]);\n\n const connectedBadge = deviationEntries.find((b: any) => connectedSections.has(b.actionId));\n const isConnected = !!connectedBadge;\n\n if (!hasTitle && !hasContent && (!section.subsections || section.subsections.length === 0)) return null;\n\n const handleToggle = () => {\n if (!isEmpty) {\n if (isExpanded) {\n const activeBadgeIdStr = String(activeSideBySideSection || \"\");\n let needsReset = activeBadgeIdStr.includes(leftKeyPath) || activeBadgeIdStr.includes(rightKeyPath);\n\n if (!needsReset) {\n connectedSections.forEach((id) => {\n if (String(id).includes(leftKeyPath) || String(id).includes(rightKeyPath)) needsReset = true;\n });\n }\n\n if (needsReset) {\n resetSideBySide();\n setConnectedSections(new Set());\n setConnectedLines([]);\n cachedConnectedPositions.current = [];\n }\n }\n setExpandedSubSections((prev) => ({ ...prev, [keyPath]: !prev[keyPath] }));\n }\n };\n const outlineColor = connectedBadge?.style?.badgeBorder || style?.badgeBorder;\n const outlineStyles = isConnected && outlineColor\n ? { borderRadius: \"4px\", outline: `2px solid ${outlineColor}`, outlineOffset: \"1px\" }\n : {};\n\n if (!hasTitle) {\n return (\n <Box ref={colRef} sx={{ mt: depth === 0 ? 1 : 0.75, width: \"100%\", minWidth: 0, position: \"relative\" }}>\n {!isEmpty && (\n <Box sx={{ width: \"100%\", ...outlineStyles }}>\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n sxStyles={resolvedMarkdownStyles}\n deviationBadges={deviationBadgesToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n highlights={highlightsToRender} \n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) => (\n <SubSectionAccordion\n key={`${keyPath}-${subIdx}`}\n section={sub}\n keyPath={`${keyPath}-${subIdx}`}\n depth={depth + 1}\n columnKey={columnKey}\n parentNodeId={parentNodeId}\n sectionOffset={sectionOffset}\n rhsOrphanVisualIndexes={rhsOrphanVisualIndexes}\n />\n ))}\n </Box>\n )}\n </Box>\n );\n }\n\n return (\n <Box ref={colRef} sx={{ mt: 1, width: \"100%\", minWidth: 0, position: \"relative\" }}>\n <Box sx={{ width: \"100%\", ...outlineStyles }}>\n <Accordion\n disableGutters\n expanded={isEmpty ? false : isExpanded}\n onChange={handleToggle}\n sx={{\n mt: 0,\n boxShadow: \"none\",\n border: isEmpty ? \"1px dashed #E2E8F0\" : \"1px solid #EEF2F7\",\n borderRadius: \"4px !important\",\n bgcolor: \"#FFFFFF\",\n minWidth: 0,\n \"&:before\": { display: \"none\" },\n }}\n >\n <AccordionSummary expandIcon={isEmpty ? null : <ChevronDown size={14} />} sx={{ minHeight: \"32px\", \"& .MuiAccordionSummary-content\": { my: 0.5, display: \"grid\", alignItems: \"center\", minWidth: 0, width: \"100%\" } }}>\n <Typography component=\"div\" sx={{ fontSize: \"11px\", fontWeight: 600, color: isEmpty ? \"#94A3B8\" : \"#19213D\", overflow: \"hidden\", textOverflow: \"ellipsis\", whiteSpace: \"nowrap\", width: \"100%\", minWidth: 0 }}>\n {displayTitle || \"Untitled Subsection\"}\n </Typography>\n </AccordionSummary>\n {!isEmpty && (\n <AccordionDetails sx={{ pt: 0, pb: 1, minWidth: 0 }}>\n {hasContent && (\n <MemoizedMarkdown\n content={baseContent}\n overlayContent={overlayContent}\n sxStyles={resolvedMarkdownStyles}\n deviationBadges={deviationBadgesToRender}\n maintainRelativeOrder={maintainRelativeOrder}\n highlightBg={highlightBg}\n suppressHighlightBg={suppressHighlightBg}\n highlights={highlightsToRender}\n collisionKey={collisionKey}\n />\n )}\n {(section.subsections || []).map((sub, subIdx) => (\n <SubSectionAccordion\n key={`${keyPath}-${subIdx}`}\n section={sub}\n keyPath={`${keyPath}-${subIdx}`}\n depth={depth + 1}\n columnKey={columnKey}\n parentNodeId={parentNodeId}\n sectionOffset={sectionOffset}\n rhsOrphanVisualIndexes={rhsOrphanVisualIndexes}\n />\n ))}\n </AccordionDetails>\n )}\n </Accordion>\n </Box>\n </Box>\n );\n});\n\nexport default SubSectionAccordion;\n"],"names":["SubSectionAccordion","memo","props","section","keyPath","depth","columnKey","parentNodeId","sectionOffset","rhsOrphanVisualIndexes","expandedSubSections","setExpandedSubSections","maintainRelativeOrder","showDeviationBadges","proposedSections","existingSections","treeData","deviationNumberRegistry","deviationParentRegistry","connectedSections","activeSideBySideSection","isSideBySide","scrollSyncLocked","toggleScrollSyncLocked","summaryPopupAnchorEl","resolvedMarkdownStyles","getSubSectionRef","getSubSectionCompareStyle","getBadgeRef","openMoreFunctionsPopup","openSummaryPopup","resetSideBySide","setConnectedSections","setConnectedLines","cachedConnectedPositions","isProposingFix","proposingFixNodeId","isRedlineFlow","unifiedNumbering","useCompareContext","collisionKey","hasTitle","displayTitle","hasValue","title","isProposedFixTarget","id","nodeId","hasRedlineTags","hasMeaningfulRedlineTags","content","resolvedRedlineFlow","suppressHighlightBg","shouldOverlayContent","baseContent","stripRedlineTags","overlayContent","hasContent","displayContent","isEmpty","isExpanded","colRef","rootIndex","split","map","Number","baseRoot","refRoot","leftRootIndex","rightRootIndex","isRootOrphan","findSectionPathById","root","targetId","rootPath","contentId","stack","subsections","child","idx","length","current","shift","forEach","push","rhsSelfIndex","refIndexes","rhsArrayIdx","findIndex","s","selfIndex","lhsSelfIndex","lhsArrayIdx","findGlobalPathById","sections","i","match","String","bSec","rSec","leftKeyPath","rightKeyPath","rightMatch","leftMatch","style","leftDocId","input_index_map","rightDocId","counterpartNodeId","isSecOrphan","hasSingleMappedLhs","hasSingleMappedLhsSection","targetEvalResult","evaluationResult","deviations","lhsDeviationDisplayIndexes","useMemo","getLhsDeviationDisplayIndexes","Map","firstDeviationKey","Object","keys","firstRefId","DEVIATION_BADGE_SEPARATOR","registeredParentNum","validatedParentNum","unifiedNum","leftNums","get","rightNums","deviationColorData","evaluation_outputs","metadata","label_color","DEFAULT_DEVIAION_COLOR","deviationPalette","generateColorPalette","highlightBg","rawDeviationEntries","entries","deviationKey","deviationMap","refId","currentIndex","filter","item","sort","a","b","localRhsOrphanVisualIndexes","normalizedContent","safeStringify","replace","ownHighlight","isMissingStr","entry","normalizedHighlight","position","indexOf","MAX_SAFE_INTEGER","index","set","deviationEntries","highlight","isMissingClause","counterpartHighlight","isDeviationOrphan","orphanVisualIndex","mappedLhsIndex","Math","max","badgeLabel","getRhsMappedSectionNumber","fallbackNumber","firstOnly","actionId","deviationOutput","deviationScore","output_value","deviationColorForBadge","badgeStyle","summaryPayload","deviation_summary","deviation_title","deviation_impact","deviation_explanation","cognitive_decisioning","stackIndex","contentStr","paragraphs","paraIndex","p","includes","overlappingDevs","_","dMap","hl","k","badgeRef","label","side","score","isConnected","has","showScrollLockToggle","isOrphan","onClick","e","stopPropagation","popupBaseSec","popupRefSec","onSummaryClick","Boolean","parseFloat","deduplicatedEntries","seenRefIds","Set","add","deviationBadgesToRender","highlightsToRender","connectedBadge","find","outlineColor","badgeBorder","outlineStyles","borderRadius","outline","outlineOffset","jsx","Box","ref","sx","mt","width","minWidth","children","jsxs","Accordion","disableGutters","expanded","onChange","activeBadgeIdStr","needsReset","prev","boxShadow","border","bgcolor","display","AccordionSummary","expandIcon","ChevronDown","size","minHeight","my","alignItems","Typography","component","fontSize","fontWeight","color","overflow","textOverflow","whiteSpace","AccordionDetails","pt","pb","MemoizedMarkdown","sxStyles","deviationBadges","highlights","sub","subIdx"],"mappings":"2ZAuCA,MAAMA,OAA0D,QAAMC,KAAMC,IACpE,MAAAC,QACJA,EAAAC,QACAA,EAAAC,MACAA,EAAQ,EAAAC,UACRA,EAAY,OAAAC,aACZA,EAAe,GAAAC,cACfA,EAAAC,uBACAA,GACEP,GACEQ,oBACJA,EAAAC,uBACAA,EAAAC,sBACAA,EAAAC,oBACAA,GAAsB,EAAAC,iB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