@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,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lucide-react"),i=require("../../../assests/svg/ButtonCognitiveIcon.js"),n=require("../CognitiveComparehelpers.js"),o=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lucide-react"),i=require("../../../assests/svg/ButtonCognitiveIcon.js"),n=require("../CognitiveComparehelpers.js"),o=require("./ThreeDotsLoader.js"),s=require("./connectedLines.js"),l=require("@mui/material");exports.default=function({svgContainerRef:r,svgDimensions:a,isResizing:c,overallConnector:d,rootDeviationStyle:u,lines:p,isSideBySide:g,activeSideBySideSection:x,isArrowVisible:h,maintainRelativeOrder:y,proposedSections:v,existingSections:b,cognitivePopup:f,activeBadgeId:S,closeCognitivePopup:m,setActiveBadgeId:j,openCognitivePopupFromState:B,buildSectionPopupState:I,connectedLines:C,pathRefs:R,isGuidelineMode:P,deviationAnalysisStatus:w}){const A=[...p].sort((e,t)=>Number(Boolean(t.isMappingContinuation))-Number(Boolean(e.isMappingContinuation)));return e.jsxs("svg",{ref:r,style:{position:"absolute",top:0,left:0,width:a.width||"100%",height:a.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:c?0:1,transition:"opacity 0.15s ease-in-out"},children:[d&&e.jsx("g",{children:e.jsx("line",{x1:d.x1,y1:d.y,x2:d.x2,y2:d.y,stroke:u.badgeBorder,strokeWidth:"1.5"})}),A.map(s=>{const r=s.x1+.5*(s.x2-s.x1),a=(s.y1+s.y2)/2,c=r;if("Not Defined"===s.style.label&&!s.hasCognitive)return null;if(s.isSubSection?g&&x===s.subSectionKeyPath&&h:g&&x===s.sectionIdx&&h)return null;if(y)return null;const d=s.isMappingContinuation?`M ${c} ${s.y1} L ${c} ${s.y2} L ${s.x2} ${s.y2}`:s.isSubSection?n.getBentArrowPath(s.x1,s.y1,s.x2,s.y2):`M ${s.x1} ${s.y1} L ${s.x2} ${s.y2}`;let u=v[s.sectionIdx]||{title:"",content:""},p=b[s.targetRightIdx??s.sectionIdx]||{title:"",content:""};if(s.isSubSection&&s.subSectionKeyPath){const e=s.subSectionKeyPath.includes(n.DEVIATION_BADGE_SEPARATOR)?s.subSectionKeyPath.split(n.DEVIATION_BADGE_SEPARATOR):[],t=e[2]||s.subSectionKeyPath,i=e[3]||t,o=t.split("-").map(Number),l=i.split("-").map(Number);let r=null,a=null;o.length>0&&(r=v[o[0]]||null),l.length>0&&(a=b[l[0]]||null);const c=r?.title||"",d=a?.title||"";for(let e=1;e<o.length;e+=1)r?.subsections&&(r=r.subsections[o[e]]||null);for(let e=1;e<l.length;e+=1)a?.subsections&&(a=a.subsections[l[e]]||null);r&&(u={...r,title:c||r.title}),a&&(p={...a,title:d||a.title})}const C=!u.cognitiveData?.isMissingRationale||Boolean(u.cognitiveData?.decisioning?.length),R=u.evaluationResult?.cognitive_decisioning?.decisioning_factors?.length||!1,P=C||R,A=null!=u.evaluationResult||null!=p.evaluationResult,D=("mapping_ready"===w||"deviations_streaming"===w)&&!A,$="complete"!==w||A?null:"Same";return e.jsxs("g",{children:[e.jsx("path",{d:d,fill:"none",stroke:s.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),!s.isMappingContinuation&&e.jsx("foreignObject",{x:r-100,y:a-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"},children:e.jsx(l.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:e.jsxs(l.Box,{onClick:e=>{e.stopPropagation(),P&&(f.open&&S===s.id?m():(j(s.id),B(I(e.currentTarget,u,p,s.sectionIdx,!1,s.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:s.style.badgeBg,color:s.style.badgeText,border:`1px solid ${s.style.badgeBorder}`,borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:P?"pointer":"default"},children:[D?e.jsx(l.Tooltip,{title:"Deviation data generation in progress",placement:"top",arrow:!0,children:e.jsx(l.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center"},children:e.jsx(o.default,{color:s.style.badgeText})})}):null==s.style.label?$:"0"===String(s.style.label)?"Same":s.style.label,e.jsx(l.Box,{component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}},children:e.jsx(i.ButtonCognitiveIcon,{})}),P&&e.jsx(t.ChevronDown,{size:11,style:{transform:f.open&&S===s.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]})})})]},s.id)}),e.jsx(s.default,{maintainRelativeOrder:y,connectedLines:C,pathRefs:R,isGuidelineMode:P})]})};
|
|
2
2
|
//# sourceMappingURL=SvgConnectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SvgConnectors.js","sources":["../../../../../src/features/CognitiveCompare/components/SvgConnectors.tsx"],"sourcesContent":["import { ChevronDown } from \"lucide-react\";\nimport { ButtonCognitiveIcon } from \"../../../assests/svg/ButtonCognitiveIcon\";\nimport { DEVIATION_BADGE_SEPARATOR, getBentArrowPath } from \"../CognitiveComparehelpers\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport ThreeDotsLoader from \"./ThreeDotsLoader\";\nimport ConnectedLinesComp from \"./connectedLines\";\nimport { Box } from \"@mui/material\";\nimport {\n SectionBlock,\n SectionPopupState,\n StyleVariant,\n} from \"../CognitiveCompareTypes\";\n\ntype SvgConnectorLine = {\n id: string;\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n style: StyleVariant;\n sectionIdx: number | string;\n targetRightIdx?: number;\n isSubSection?: boolean;\n isMappingContinuation?: boolean;\n subSectionKeyPath?: string;\n hasCognitive?: boolean;\n};\n\ntype SvgConnectorsProps = {\n svgContainerRef: React.MutableRefObject<SVGSVGElement | null>;\n svgDimensions: { width: number; height: number };\n isResizing: boolean;\n overallConnector: { x1: number; x2: number; y: number } | null;\n rootDeviationStyle: { badgeBorder: string };\n lines: Record<string, any>[];\n isSideBySide: boolean;\n activeSideBySideSection: number | string | null;\n isArrowVisible: boolean;\n maintainRelativeOrder: boolean | undefined;\n proposedSections: SectionBlock[];\n existingSections: SectionBlock[];\n cognitivePopup: SectionPopupState;\n activeBadgeId: string | null;\n closeCognitivePopup: () => void;\n setActiveBadgeId: React.Dispatch<React.SetStateAction<string | null>>;\n openCognitivePopupFromState: (nextPopup: SectionPopupState) => void;\n buildSectionPopupState: (\n anchorEl: HTMLElement | null,\n baseSec: SectionBlock | null,\n refSec: SectionBlock | null,\n sectionIdx: number | string,\n isOrphan?: boolean,\n style?: StyleVariant | null,\n rootNode?: boolean,\n ) => SectionPopupState;\n connectedLines: Record<string, any>[];\n pathRefs: React.MutableRefObject<Record<string, SVGPathElement | null>>;\n isGuidelineMode ?: boolean;\n};\n\nexport default function SvgConnectors({\n svgContainerRef,\n svgDimensions,\n isResizing,\n overallConnector,\n rootDeviationStyle,\n lines,\n isSideBySide,\n activeSideBySideSection,\n isArrowVisible,\n maintainRelativeOrder,\n proposedSections,\n existingSections,\n cognitivePopup,\n activeBadgeId,\n closeCognitivePopup,\n setActiveBadgeId,\n openCognitivePopupFromState,\n buildSectionPopupState,\n connectedLines,\n pathRefs,\n isGuidelineMode,\n}: SvgConnectorsProps) {\n const orderedLines = [...lines].sort(\n (left, right) =>\n Number(Boolean(right.isMappingContinuation)) -\n Number(Boolean(left.isMappingContinuation)),\n );\n\n return (\n <svg\n ref={svgContainerRef}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: svgDimensions.width || \"100%\",\n height: svgDimensions.height || \"100%\",\n pointerEvents: \"none\",\n zIndex: 10,\n overflow: \"visible\",\n opacity: isResizing ? 0 : 1,\n transition: \"opacity 0.15s ease-in-out\",\n }}\n >\n {overallConnector && (\n <g>\n <line\n x1={overallConnector.x1}\n y1={overallConnector.y}\n x2={overallConnector.x2}\n y2={overallConnector.y}\n stroke={rootDeviationStyle.badgeBorder}\n strokeWidth=\"1.5\"\n />\n </g>\n )}\n\n {orderedLines.map((line) => {\n const bendX = line.x1 + (line.x2 - line.x1) * 0.5;\n const midY = (line.y1 + line.y2) / 2;\n const continuationJunctionX = bendX;\n\n if (line.style.label === \"Not Defined\" && !line.hasCognitive) {\n return null;\n }\n\n const isActive = line.isSubSection\n ? isSideBySide &&\n activeSideBySideSection === line.subSectionKeyPath &&\n isArrowVisible\n : isSideBySide &&\n activeSideBySideSection === line.sectionIdx &&\n isArrowVisible;\n\n if (isActive) {\n return null;\n }\n\n if (maintainRelativeOrder) {\n return null;\n }\n\n const pathD = line.isMappingContinuation\n ? `M ${continuationJunctionX} ${line.y1} L ${continuationJunctionX} ${line.y2} L ${line.x2} ${line.y2}`\n : !line.isSubSection\n ? `M ${line.x1} ${line.y1} L ${line.x2} ${line.y2}`\n : getBentArrowPath(line.x1, line.y1, line.x2, line.y2);\n\n let baseSec = proposedSections[line.sectionIdx as number] || { title: \"\", content: \"\" };\n let refSec = existingSections[line.targetRightIdx ?? (line.sectionIdx as number)] || {\n title: \"\",\n content: \"\",\n };\n\n if (line.isSubSection && line.subSectionKeyPath) {\n const pathParts = line.subSectionKeyPath.includes(DEVIATION_BADGE_SEPARATOR)\n ? line.subSectionKeyPath.split(DEVIATION_BADGE_SEPARATOR)\n : [];\n const leftPath = pathParts[2] || line.subSectionKeyPath;\n const rightPath = pathParts[3] || leftPath;\n const leftPathParts = leftPath.split(\"-\").map(Number);\n const rightPathParts = rightPath.split(\"-\").map(Number);\n let leftSection: SectionBlock | null = null;\n let rightSection: SectionBlock | null = null;\n\n if (leftPathParts.length > 0) {\n leftSection = proposedSections[leftPathParts[0]] || null;\n }\n if (rightPathParts.length > 0) {\n rightSection = existingSections[rightPathParts[0]] || null;\n }\n\n const rootParentTitle = leftSection?.title || \"\";\n const rootRefParentTitle = rightSection?.title || \"\";\n\n for (let i = 1; i < leftPathParts.length; i += 1) {\n if (leftSection?.subsections) leftSection = leftSection.subsections[leftPathParts[i]] || null;\n }\n for (let i = 1; i < rightPathParts.length; i += 1) {\n if (rightSection?.subsections) rightSection = rightSection.subsections[rightPathParts[i]] || null;\n }\n\n if (leftSection) baseSec = { ...leftSection, title: rootParentTitle || leftSection.title };\n if (rightSection) refSec = { ...rightSection, title: rootRefParentTitle || rightSection.title };\n }\n\n const isMappingCD =\n !baseSec.cognitiveData?.isMissingRationale ||\n Boolean(baseSec.cognitiveData?.decisioning?.length);\n const isDeviationCD =\n baseSec.evaluationResult?.cognitive_decisioning?.decisioning_factors?.length || false;\n const hasMapping = isMappingCD || isDeviationCD;\n\n return (\n <g key={line.id}>\n <path\n d={pathD}\n fill=\"none\"\n stroke={line.style.badgeBorder || \"#E2E8F0\"}\n strokeWidth=\"1.5\"\n />\n {!line.isMappingContinuation && (\n <foreignObject\n x={bendX - 100}\n y={midY - 14}\n width=\"200\"\n height=\"28\"\n style={{ pointerEvents: \"auto\", overflow: \"visible\" }}\n >\n <Box\n sx={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: \"100%\",\n }}\n >\n <Box\n onClick={(e) => {\n e.stopPropagation();\n if (!hasMapping) return;\n if (cognitivePopup.open && activeBadgeId === line.id) {\n closeCognitivePopup();\n return;\n }\n\n setActiveBadgeId(line.id);\n openCognitivePopupFromState(\n buildSectionPopupState(\n e.currentTarget as HTMLElement,\n baseSec,\n refSec,\n line.sectionIdx,\n false,\n line.style,\n ),\n );\n }}\n sx={{\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"4px\",\n fontSize: \"11px\",\n bgcolor: line.style.badgeBg,\n color: line.style.badgeText,\n border: `1px solid ${line.style.badgeBorder}`,\n borderRadius: \"12px\",\n px: 1.5,\n py: 0.5,\n fontWeight: 600,\n textAlign: \"center\",\n whiteSpace: \"nowrap\",\n cursor: !hasMapping ? \"default\" : \"pointer\",\n }}\n >\n {line.style.badgeText === DEFAULT_DEVIAION_COLOR && line.style.label == null\n ? <ThreeDotsLoader color={line.style.badgeText} />\n : line.style.label == null\n ? null\n : String(line.style.label) === \"0\"\n ? \"Same\"\n : line.style.label}\n <Box\n component=\"span\"\n sx={{\n width: 14,\n height: 14,\n display: \"flex\",\n alignItems: \"center\",\n \"& svg\": { width: \"14px\", height: \"14px\" },\n }}\n >\n <ButtonCognitiveIcon />\n </Box>\n\n {hasMapping && (\n <ChevronDown\n size={11}\n style={{\n transform:\n cognitivePopup.open && activeBadgeId === line.id\n ? \"rotate(180deg)\"\n : \"rotate(0deg)\",\n transition: \"transform 0.25s ease\",\n }}\n />\n )}\n </Box>\n </Box>\n </foreignObject>\n )}\n </g>\n );\n })}\n\n <ConnectedLinesComp \n maintainRelativeOrder={maintainRelativeOrder} \n connectedLines={connectedLines} \n pathRefs={pathRefs} \n isGuidelineMode={isGuidelineMode}\n />\n </svg>\n );\n}\n"],"names":["svgContainerRef","svgDimensions","isResizing","overallConnector","rootDeviationStyle","lines","isSideBySide","activeSideBySideSection","isArrowVisible","maintainRelativeOrder","proposedSections","existingSections","cognitivePopup","activeBadgeId","closeCognitivePopup","setActiveBadgeId","openCognitivePopupFromState","buildSectionPopupState","connectedLines","pathRefs","isGuidelineMode","orderedLines","sort","left","right","Number","Boolean","isMappingContinuation","jsxs","ref","style","position","top","width","height","pointerEvents","zIndex","overflow","opacity","transition","children","jsx","x1","y1","y","x2","y2","stroke","badgeBorder","strokeWidth","map","line","bendX","midY","continuationJunctionX","label","hasCognitive","isSubSection","subSectionKeyPath","sectionIdx","pathD","getBentArrowPath","baseSec","title","content","refSec","targetRightIdx","pathParts","includes","DEVIATION_BADGE_SEPARATOR","split","leftPath","rightPath","leftPathParts","rightPathParts","leftSection","rightSection","length","rootParentTitle","rootRefParentTitle","i","subsections","isMappingCD","cognitiveData","isMissingRationale","decisioning","isDeviationCD","evaluationResult","cognitive_decisioning","decisioning_factors","hasMapping","d","fill","x","Box","sx","display","justifyContent","alignItems","onClick","e","stopPropagation","open","id","currentTarget","gap","fontSize","bgcolor","badgeBg","color","badgeText","border","borderRadius","px","py","fontWeight","textAlign","whiteSpace","cursor","DEFAULT_DEVIAION_COLOR","ThreeDotsLoader","String","component","ButtonCognitiveIcon","ChevronDown","size","transform","ConnectedLinesComp"],"mappings":"gYA4DA,UAAsCA,gBACpCA,EAAAC,cACAA,EAAAC,WACAA,EAAAC,iBACAA,EAAAC,mBACAA,EAAAC,MACAA,EAAAC,aACAA,EAAAC,wBACAA,EAAAC,eACAA,EAAAC,sBACAA,EAAAC,iBACAA,EAAAC,iBACAA,EAAAC,eACAA,EAAAC,cACAA,EAAAC,oBACAA,EAAAC,iBACAA,EAAAC,4BACAA,EAAAC,uBACAA,EAAAC,eACAA,EAAAC,SACAA,EAAAC,gBACAA,IAEA,MAAMC,EAAe,IAAIhB,GAAOiB,KAC9B,CAACC,EAAMC,IACLC,OAAOC,QAAQF,EAAMG,wBACrBF,OAAOC,QAAQH,EAAKI,yBAItB,OAAAC,EAAAA,KAAC,MAAA,CACCC,IAAK7B,EACL8B,MAAO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EAAKoD,MAqGjB9D,EAAAA,IAACsF,EAAA,QAAA,CACCtH,wBAAAS,eACAA,EACAC,WACAC,sBAIR"}
|
|
1
|
+
{"version":3,"file":"SvgConnectors.js","sources":["../../../../../src/features/CognitiveCompare/components/SvgConnectors.tsx"],"sourcesContent":["import { ChevronDown } from \"lucide-react\";\nimport { ButtonCognitiveIcon } from \"../../../assests/svg/ButtonCognitiveIcon\";\nimport { DEVIATION_BADGE_SEPARATOR, getBentArrowPath } from \"../CognitiveComparehelpers\";\nimport ThreeDotsLoader from \"./ThreeDotsLoader\";\nimport ConnectedLinesComp from \"./connectedLines\";\nimport { Box, Tooltip } from \"@mui/material\";\nimport {\n DeviationAnalysisStatus,\n SectionBlock,\n SectionPopupState,\n StyleVariant,\n} from \"../CognitiveCompareTypes\";\n\ntype SvgConnectorLine = {\n id: string;\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n style: StyleVariant;\n sectionIdx: number | string;\n targetRightIdx?: number;\n isSubSection?: boolean;\n isMappingContinuation?: boolean;\n subSectionKeyPath?: string;\n hasCognitive?: boolean;\n};\n\ntype SvgConnectorsProps = {\n svgContainerRef: React.MutableRefObject<SVGSVGElement | null>;\n svgDimensions: { width: number; height: number };\n isResizing: boolean;\n overallConnector: { x1: number; x2: number; y: number } | null;\n rootDeviationStyle: { badgeBorder: string };\n lines: Record<string, any>[];\n isSideBySide: boolean;\n activeSideBySideSection: number | string | null;\n isArrowVisible: boolean;\n maintainRelativeOrder: boolean | undefined;\n proposedSections: SectionBlock[];\n existingSections: SectionBlock[];\n cognitivePopup: SectionPopupState;\n activeBadgeId: string | null;\n closeCognitivePopup: () => void;\n setActiveBadgeId: React.Dispatch<React.SetStateAction<string | null>>;\n openCognitivePopupFromState: (nextPopup: SectionPopupState) => void;\n buildSectionPopupState: (\n anchorEl: HTMLElement | null,\n baseSec: SectionBlock | null,\n refSec: SectionBlock | null,\n sectionIdx: number | string,\n isOrphan?: boolean,\n style?: StyleVariant | null,\n rootNode?: boolean,\n ) => SectionPopupState;\n connectedLines: Record<string, any>[];\n pathRefs: React.MutableRefObject<Record<string, SVGPathElement | null>>;\n isGuidelineMode ?: boolean;\n deviationAnalysisStatus: DeviationAnalysisStatus;\n};\n\nexport default function SvgConnectors({\n svgContainerRef,\n svgDimensions,\n isResizing,\n overallConnector,\n rootDeviationStyle,\n lines,\n isSideBySide,\n activeSideBySideSection,\n isArrowVisible,\n maintainRelativeOrder,\n proposedSections,\n existingSections,\n cognitivePopup,\n activeBadgeId,\n closeCognitivePopup,\n setActiveBadgeId,\n openCognitivePopupFromState,\n buildSectionPopupState,\n connectedLines,\n pathRefs,\n isGuidelineMode,\n deviationAnalysisStatus,\n}: SvgConnectorsProps) {\n const orderedLines = [...lines].sort(\n (left, right) =>\n Number(Boolean(right.isMappingContinuation)) -\n Number(Boolean(left.isMappingContinuation)),\n );\n\n return (\n <svg\n ref={svgContainerRef}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: svgDimensions.width || \"100%\",\n height: svgDimensions.height || \"100%\",\n pointerEvents: \"none\",\n zIndex: 10,\n overflow: \"visible\",\n opacity: isResizing ? 0 : 1,\n transition: \"opacity 0.15s ease-in-out\",\n }}\n >\n {overallConnector && (\n <g>\n <line\n x1={overallConnector.x1}\n y1={overallConnector.y}\n x2={overallConnector.x2}\n y2={overallConnector.y}\n stroke={rootDeviationStyle.badgeBorder}\n strokeWidth=\"1.5\"\n />\n </g>\n )}\n\n {orderedLines.map((line) => {\n const bendX = line.x1 + (line.x2 - line.x1) * 0.5;\n const midY = (line.y1 + line.y2) / 2;\n const continuationJunctionX = bendX;\n\n if (line.style.label === \"Not Defined\" && !line.hasCognitive) {\n return null;\n }\n\n const isActive = line.isSubSection\n ? isSideBySide &&\n activeSideBySideSection === line.subSectionKeyPath &&\n isArrowVisible\n : isSideBySide &&\n activeSideBySideSection === line.sectionIdx &&\n isArrowVisible;\n\n if (isActive) {\n return null;\n }\n\n if (maintainRelativeOrder) {\n return null;\n }\n\n const pathD = line.isMappingContinuation\n ? `M ${continuationJunctionX} ${line.y1} L ${continuationJunctionX} ${line.y2} L ${line.x2} ${line.y2}`\n : !line.isSubSection\n ? `M ${line.x1} ${line.y1} L ${line.x2} ${line.y2}`\n : getBentArrowPath(line.x1, line.y1, line.x2, line.y2);\n\n let baseSec = proposedSections[line.sectionIdx as number] || { title: \"\", content: \"\" };\n let refSec = existingSections[line.targetRightIdx ?? (line.sectionIdx as number)] || {\n title: \"\",\n content: \"\",\n };\n\n if (line.isSubSection && line.subSectionKeyPath) {\n const pathParts = line.subSectionKeyPath.includes(DEVIATION_BADGE_SEPARATOR)\n ? line.subSectionKeyPath.split(DEVIATION_BADGE_SEPARATOR)\n : [];\n const leftPath = pathParts[2] || line.subSectionKeyPath;\n const rightPath = pathParts[3] || leftPath;\n const leftPathParts = leftPath.split(\"-\").map(Number);\n const rightPathParts = rightPath.split(\"-\").map(Number);\n let leftSection: SectionBlock | null = null;\n let rightSection: SectionBlock | null = null;\n\n if (leftPathParts.length > 0) {\n leftSection = proposedSections[leftPathParts[0]] || null;\n }\n if (rightPathParts.length > 0) {\n rightSection = existingSections[rightPathParts[0]] || null;\n }\n\n const rootParentTitle = leftSection?.title || \"\";\n const rootRefParentTitle = rightSection?.title || \"\";\n\n for (let i = 1; i < leftPathParts.length; i += 1) {\n if (leftSection?.subsections) leftSection = leftSection.subsections[leftPathParts[i]] || null;\n }\n for (let i = 1; i < rightPathParts.length; i += 1) {\n if (rightSection?.subsections) rightSection = rightSection.subsections[rightPathParts[i]] || null;\n }\n\n if (leftSection) baseSec = { ...leftSection, title: rootParentTitle || leftSection.title };\n if (rightSection) refSec = { ...rightSection, title: rootRefParentTitle || rightSection.title };\n }\n\n const isMappingCD =\n !baseSec.cognitiveData?.isMissingRationale ||\n Boolean(baseSec.cognitiveData?.decisioning?.length);\n const isDeviationCD =\n baseSec.evaluationResult?.cognitive_decisioning?.decisioning_factors?.length || false;\n const hasMapping = isMappingCD || isDeviationCD;\n const hasDeviationResult =\n baseSec.evaluationResult != null ||\n refSec.evaluationResult != null;\n const isDeviationGenerationInProgress =\n deviationAnalysisStatus === \"mapping_ready\" ||\n deviationAnalysisStatus === \"deviations_streaming\";\n const shouldShowDeviationLoader =\n isDeviationGenerationInProgress && !hasDeviationResult;\n const fallbackLabel =\n deviationAnalysisStatus === \"complete\" && !hasDeviationResult\n ? \"Same\"\n : null;\n\n return (\n <g key={line.id}>\n <path\n d={pathD}\n fill=\"none\"\n stroke={line.style.badgeBorder || \"#E2E8F0\"}\n strokeWidth=\"1.5\"\n />\n {!line.isMappingContinuation && (\n <foreignObject\n x={bendX - 100}\n y={midY - 14}\n width=\"200\"\n height=\"28\"\n style={{ pointerEvents: \"auto\", overflow: \"visible\" }}\n >\n <Box\n sx={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: \"100%\",\n }}\n >\n <Box\n onClick={(e) => {\n e.stopPropagation();\n if (!hasMapping) return;\n if (cognitivePopup.open && activeBadgeId === line.id) {\n closeCognitivePopup();\n return;\n }\n\n setActiveBadgeId(line.id);\n openCognitivePopupFromState(\n buildSectionPopupState(\n e.currentTarget as HTMLElement,\n baseSec,\n refSec,\n line.sectionIdx,\n false,\n line.style,\n ),\n );\n }}\n sx={{\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"4px\",\n fontSize: \"11px\",\n bgcolor: line.style.badgeBg,\n color: line.style.badgeText,\n border: `1px solid ${line.style.badgeBorder}`,\n borderRadius: \"12px\",\n px: 1.5,\n py: 0.5,\n fontWeight: 600,\n textAlign: \"center\",\n whiteSpace: \"nowrap\",\n cursor: !hasMapping ? \"default\" : \"pointer\",\n }}\n >\n {shouldShowDeviationLoader\n ? (\n <Tooltip title=\"Deviation data generation in progress\" placement=\"top\" arrow>\n <Box component=\"span\" sx={{ display: \"inline-flex\", alignItems: \"center\" }}>\n <ThreeDotsLoader color={line.style.badgeText} />\n </Box>\n </Tooltip>\n )\n : line.style.label == null\n ? fallbackLabel\n : String(line.style.label) === \"0\"\n ? \"Same\"\n : line.style.label}\n <Box\n component=\"span\"\n sx={{\n width: 14,\n height: 14,\n display: \"flex\",\n alignItems: \"center\",\n \"& svg\": { width: \"14px\", height: \"14px\" },\n }}\n >\n <ButtonCognitiveIcon />\n </Box>\n\n {hasMapping && (\n <ChevronDown\n size={11}\n style={{\n transform:\n cognitivePopup.open && activeBadgeId === line.id\n ? \"rotate(180deg)\"\n : \"rotate(0deg)\",\n transition: \"transform 0.25s ease\",\n }}\n />\n )}\n </Box>\n </Box>\n </foreignObject>\n )}\n </g>\n );\n })}\n\n <ConnectedLinesComp \n maintainRelativeOrder={maintainRelativeOrder} \n connectedLines={connectedLines} \n pathRefs={pathRefs} \n isGuidelineMode={isGuidelineMode}\n />\n </svg>\n );\n}\n"],"names":["svgContainerRef","svgDimensions","isResizing","overallConnector","rootDeviationStyle","lines","isSideBySide","activeSideBySideSection","isArrowVisible","maintainRelativeOrder","proposedSections","existingSections","cognitivePopup","activeBadgeId","closeCognitivePopup","setActiveBadgeId","openCognitivePopupFromState","buildSectionPopupState","connectedLines","pathRefs","isGuidelineMode","deviationAnalysisStatus","orderedLines","sort","left","right","Number","Boolean","isMappingContinuation","jsxs","ref","style","position","top","width","height","pointerEvents","zIndex","overflow","opacity","transition","children","jsx","x1","y1","y","x2","y2","stroke","badgeBorder","strokeWidth","map","line","bendX","midY","continuationJunctionX","label","hasCognitive","isSubSection","subSectionKeyPath","sectionIdx","pathD","getBentArrowPath","baseSec","title","content","refSec","targetRightIdx","pathParts","includes","DEVIATION_BADGE_SEPARATOR","split","leftPath","rightPath","leftPathParts","rightPathParts","leftSection","rightSection","length","rootParentTitle","rootRefParentTitle","i","subsections","isMappingCD","cognitiveData","isMissingRationale","decisioning","isDeviationCD","evaluationResult","cognitive_decisioning","decisioning_factors","hasMapping","hasDeviationResult","shouldShowDeviationLoader","fallbackLabel","d","fill","x","Box","sx","display","justifyContent","alignItems","onClick","e","stopPropagation","open","id","currentTarget","gap","fontSize","bgcolor","badgeBg","color","badgeText","border","borderRadius","px","py","fontWeight","textAlign","whiteSpace","cursor","Tooltip","placement","arrow","component","ThreeDotsLoader","String","ButtonCognitiveIcon","ChevronDown","size","transform","ConnectedLinesComp"],"mappings":"mVA6DA,UAAsCA,gBACpCA,EAAAC,cACAA,EAAAC,WACAA,EAAAC,iBACAA,EAAAC,mBACAA,EAAAC,MACAA,EAAAC,aACAA,EAAAC,wBACAA,EAAAC,eACAA,EAAAC,sBACAA,EAAAC,iBACAA,EAAAC,iBACAA,EAAAC,eACAA,EAAAC,cACAA,EAAAC,oBACAA,EAAAC,iBACAA,EAAAC,4BACAA,EAAAC,uBACAA,EAAAC,eACAA,EAAAC,SACAA,EAAAC,gBACAA,EAAAC,wBACAA,IAEA,MAAMC,EAAe,IAAIjB,GAAOkB,KAC9B,CAACC,EAAMC,IACLC,OAAOC,QAAQF,EAAMG,wBACrBF,OAAOC,QAAQH,EAAKI,yBAItB,OAAAC,EAAAA,KAAC,MAAA,CACCC,IAAK9B,EACL+B,MAAO,CACLC,SAAU,WACVC,IAAK,EACLT,KAAM,EACNU,MAAOjC,EAAciC,OAAS,OAC9BC,OAAQlC,EAAckC,QAAU,OAChCC,cAAe,OACfC,OAAQ,GACRC,SAAU,UACVC,QAASrC,EAAa,EAAI,EAC1BsC,WAAY,6BAGbC,SAAA,CAAAtC,SACE,IACC,CAAAsC,SAAAC,EAAAA,IAAC,OAAA,CACCC,GAAIxC,EAAiBwC,GACrBC,GAAIzC,EAAiB0C,EACrBC,GAAI3C,EAAiB2C,GACrBC,GAAI5C,EAAiB0C,EACrBG,OAAQ5C,EAAmB6C,YAC3BC,YAAY,UAKjB5B,EAAa6B,IAAKC,IACjB,MAAMC,EAAQD,EAAKT,GAA2B,IAArBS,EAAKN,GAAKM,EAAKT,IAClCW,GAAQF,EAAKR,GAAKQ,EAAKL,IAAM,EAC7BQ,EAAwBF,EAE9B,GAAyB,gBAArBD,EAAKrB,MAAMyB,QAA4BJ,EAAKK,a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D,EAAKrB,MAAMiF,QACpBC,MAAO7D,EAAKrB,MAAMmF,UAClBC,OAAQ,aAAa/D,EAAKrB,MAAMkB,cAChCmE,aAAc,OACdC,GAAI,IACJC,GAAI,GACJC,WAAY,IACZC,UAAW,SACXC,WAAY,SACZC,OAAS/B,EAAyB,UAAZ,WAGvBlD,SAAA,CAAAoD,QAEI8B,EAAQA,QAAA,CAAA3D,MAAM,wCAAwC4D,UAAU,MAAMC,OAAK,EAC1EpF,SAAAC,MAACwD,EAAAA,IAAI,CAAA4B,UAAU,OAAO3B,GAAI,CAAEC,QAAS,cAAeE,WAAY,UAC9D7D,SAAAC,EAAAA,IAACqF,EAAAA,QAAgB,CAAAd,MAAO7D,EAAKrB,MAAMmF,gBAInB,MAApB9D,EAAKrB,MAAMyB,MACTsC,EAC6B,MAA7BkC,OAAO5E,EAAKrB,MAAMyB,OAChB,OACAJ,EAAKrB,MAAMyB,MACnBd,EAAAA,IAACwD,EAAAA,IAAA,CACC4B,UAAU,OACV3B,GAAI,CACFjE,MAAO,GACPC,OAAQ,GACRiE,QAAS,OACTE,WAAY,SACZ,QAAS,CAAEpE,MAAO,OAAQC,OAAQ,SAGpCM,eAACwF,EAAoBA,oBAAA,MAGtBtC,GACCjD,EAAAA,IAACwF,EAAAA,YAAA,CACCC,KAAM,GACNpG,MAAO,CACLqG,UACExH,EAAe8F,MAAQ7F,IAAkBuC,EAAKuD,GAC1C,iBACA,eACNnE,WAAY,mCA/FpBY,EAAKuD,MA2GjBjE,EAAAA,IAAC2F,EAAA,QAAA,CACC5H,wBAAAS,eACAA,EACAC,WACAC,sBAIR"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@mui/material"),r=require("react"),n=require("../CognitiveCompareConstants.js"),i=require("lucide-react"),o=require("react-markdown"),l=require("../CognitiveComparehelpers.js"),a=require("../utils/normalizeInlineMarkdown.js"),s=require("rehype-raw"),d=require("remark-gfm"),c=require("../utils/normalizeRedlineMarkdown.js"),h=require("../utils/normalizeCompactedGfmTables.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=p(r),u=p(o),m=p(s);const x=e=>"function"==typeof e?e:e?.default||e,f=[x(p(d).default)],b=[x(m.default)],y=g.default.memo(({content:o,overlayContent:s,fallbackContent:d,sxStyles:p,deviationBadges:m=[],highlights:x=[],maintainRelativeOrder:y=!0,highlightBg:v,suppressHighlightBg:B=!1,collisionKey:E})=>{const j=r.useRef(null),k=!!s,w=r.useMemo(()=>m.reduce((e,t)=>({...e,[t.id]:t}),{}),[m]),S=r.useRef({badgeMap:w,highlightBg:v,hideHighlightBg:k,suppressHighlightBg:B});S.current={badgeMap:w,highlightBg:v,hideHighlightBg:k,suppressHighlightBg:B};const C=(e,t)=>g.default.Children.map(e,e=>{if(!g.default.isValidElement(e))return e;const r=e.props?.children?C(e.props.children,t):e.props.children,n=g.default.cloneElement(e,{...e.props,children:r});return t(n)}),F=r.useMemo(()=>({mark:({children:t,...r})=>{const{badgeMap:n,highlightBg:i,hideHighlightBg:o,suppressHighlightBg:l}=S.current,a=r["data-badge-id"],s=a?n[a]:null,d=r["data-highlight-color"]??s?.style?.highlightBg??s?.style?.badgeBg??i,c="true"===r["data-is-suggested-deviation-fix"]||l;return e.jsx("span",{style:{...c?{}:{backgroundColor:d},borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px",...o?{color:"transparent"}:{}},children:t})},br:()=>e.jsx("br",{}),span:({children:r,...o})=>{const{badgeMap:l}=S.current,a=o["data-badge-id"];if(!a)return e.jsx("span",{...o,children:r});const s=l[a];if(!s)return e.jsx("span",{...o,children:r});const d="number"==typeof s.stackIndex?s.stackIndex:0,c=`translateY(calc(-20% + ${12*d}px + var(--badge-nudge, 0px)))`;return e.jsxs(t.Box,{component:"span",sx:{position:"static",display:"inline"},children:[e.jsxs(t.Box,{ref:s.badgeRef,className:"deviation-badge","data-side":s.side||"right",sx:{fontStyle:"normal",position:"absolute",zIndex:30+d,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:s.style?.badgeBg||"#EEF2FF",color:s.style?.badgeText||n.DEFAULT_DEVIAION_COLOR,border:`1px solid ${s.style?.badgeBorder||"#C7D2FE"}`,borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none",..."left"===s.side?{right:"-16px",transform:`${c} translateX(calc(100% + 8px))`}:{left:"-16px",transform:`${c} translateX(calc(-100% - 8px))`},...s.isConnected&&s.style&&{outline:`2px solid ${s.style.badgeBorder}`,outlineOffset:"1px"}},children:[e.jsxs(t.Box,{onClick:e=>{e.stopPropagation(),s.onSummaryClick&&s.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}},children:[e.jsx(t.Box,{component:"span",sx:{fontSize:"10px",fontWeight:700},children:s.label}),("left"===s.side||s.isOrphan)&&e.jsx(t.Box,{component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:`1px solid ${s.style?.badgeBorder||"#C7D2FE"}`},children:null!=s.score&&"N/A"!==s.score&&"NA"!==s.score&&0!==s.score?`${s.score}`:"N/A"===s.score||"NA"===s.score?"N/A":"Same"})]}),("left"===s.side||s.isOrphan)&&e.jsx(t.Box,{onClick:e=>{e.stopPropagation(),s.onClick&&s.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:`1px solid ${s.style?.badgeBorder||"#C7D2FE"}`,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}},children:e.jsx(i.EllipsisVertical,{size:12,color:s.style?.badgeText||"#3730A3"})})]}),r]})},table:({children:r})=>e.jsx(t.Box,{sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1},children:e.jsx(t.Box,{component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"},children:r})}),thead:({children:r})=>e.jsx(t.Box,{component:"thead",children:r}),tbody:({children:r})=>e.jsx(t.Box,{component:"tbody",children:r}),tr:({children:r})=>e.jsx(t.Box,{component:"tr",sx:{borderBottom:"1px solid #E5E7EB"},children:r}),th:({children:r})=>e.jsx(t.Box,{component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"},children:r}),td:({children:r})=>e.jsx(t.Box,{component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"},children:r}),code:({children:t})=>e.jsx("span",{style:{fontFamily:"inherit",fontSize:"inherit"},children:t}),pre:({children:t})=>e.jsx("span",{style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"},children:t}),updated:({children:t})=>e.jsx(e.Fragment,{children:t}),deleted:({children:t})=>{const r=C(t,e=>g.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"}));return e.jsx("span",{style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"},children:r})},changed:({children:t})=>{const r=C(t,e=>g.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"}));return e.jsx("span",{style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"},children:r})},ul:({children:r,...n})=>e.jsx(t.Box,{component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"},...n,children:r}),ol:({children:r,...n})=>e.jsx(t.Box,{component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"},...n,children:r}),li:({children:r,...n})=>e.jsx(t.Box,{component:"li",sx:{mb:.5,display:"list-item"},...n,children:r})}),[]),M=e=>{if(!e||"string"!=typeof e)return"";let t=h.normalizeCompactedGfmTables(e);t=t.replace(/((?:<\/?(?:updated|changed|deleted|manual)\b[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1"),t=t.replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n"),t=t.replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,(e,t,r,n)=>`${t}${r.slice(0,-1)}\\.${n}`),t=t.replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,(e,t,r,n)=>`${t} ${n}`),t=t.replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2"),t=t.replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2"),t=t.replace(/\n{3,}/g,"\n\n"),t=t.replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,e=>e.replace(/ /g," ").replace(/\t/g," "));const r=t.split(/(\n{2,})/);return t=r.map(e=>/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,(t,r)=>{const n=e.slice(r+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(n)?"\n":" "})).join(""),t.trim()},T=r.useMemo(()=>m.map(e=>({id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size})),[m]),$=e=>M(c.normalizeRedlineMarkdown(e||"")),z=r.useMemo(()=>{let e=M(c.normalizeRedlineMarkdown(o||""));const t=d?M(c.normalizeRedlineMarkdown(d)):"",r=(m||[]).map(e=>({id:e?.id,highlight:$(e?.highlight||""),highlightColor:e?.style?.highlightBg||e?.style?.badgeBg||v})).filter(e=>e.id&&e.highlight);if(t&&r.length>0){const n=(e,t)=>B?l.findRedlineTextAnchorRange(e,t):l.findTextMatchRange(e,t,!1),i=r.some(({highlight:t})=>!n(e,t)),o=r.every(({highlight:e})=>!!n(t,e));i&&o&&(e=t)}const n={};r.forEach(e=>{n[e.highlight]||(n[e.highlight]=[]),n[e.highlight].push(e)});const i=(e,t="",r,n=[])=>{let i=!1;const o=e=>{const o=((e,t="",r)=>{const n=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!n)return e;const i=n[1]??"",o=n[2]??"",l=n[3]??"";return o?i+((e="",t)=>`<mark${e?` data-badge-id="${e}"`:""}${t?` data-highlight-color="${t}"`:""}>`)(t,r)+o+"</mark>"+l:e})(e,t,r);let l=o;if(!i&&n.length>0){i=!0;let e="",t="";n.forEach(r=>{e+=(e=>`<span data-badge-id="${e}">`)(r.id),t="</span>"+t}),l=e+o+t}return""+l};return e.split(/(\n+)/).map(e=>{if(/^\n+$/.test(e))return e;if(!e.trim())return e;return""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(e=>"|"!==e&&e.trim()?o(e):e).join(""):o(e)}).join("")},s=[];Object.entries(n).forEach(([t,r])=>{let n=B?l.findRedlineTextAnchorRange(e,t):l.findTextMatchRange(e,t,!1);if(n||B||(n=a.findTextRangeWithFormatting(e,t)),!n)return;const i=e.slice(n.start,n.end)!==t;let o=r[0].highlightColor;for(let e=1;e<r.length;e++)o=l.mixHexColors(o,r[e].highlightColor||"");s.push({highlight:t,start:n.start,end:n.end,badges:r,color:o,usedLooseMatch:i})});const h=new Set(Object.keys(n));(x||[]).forEach(t=>{if(!t)return;const r=$(t);if(!r||h.has(r))return;const n=B?l.findRedlineTextAnchorRange(e,r):l.findTextMatchRange(e,r,!1);if(!n)return;const i=e.slice(n.start,n.end)!==r,o=e.slice(0,n.start);(o.match(/</g)||[]).length===(o.match(/>/g)||[]).length&&s.push({highlight:r,start:n.start,end:n.end,badges:[],color:v||"",usedLooseMatch:i})}),s.sort((e,t)=>e.start-t.start||t.end-e.end);const p=[],g={};s.forEach((e,t)=>{let r=e.start,n=e.end;for(const i of p){const o=i.start,l=i.end,a=r<l&&n>l&&r>=o,s=r<o&&n>o&&n<=l;if(r>=o&&n<=l){e.orphaned=!0,g[t]=i.matchIdx;break}a&&(r=l),s&&(n=o)}e.trimmedStart=r,e.trimmedEnd=n,!e.orphaned&&r<n&&p.push({start:r,end:n,matchIdx:t})});const u={};Object.entries(g).forEach(([e,t])=>{const r=Number(e);u[t]||(u[t]=[]),u[t].push(r)});return s.map((e,t)=>({...e,idx:t})).filter(e=>!e.orphaned).sort((e,t)=>(t.trimmedStart??t.start)-(e.trimmedStart??e.start)).forEach(t=>{const r=t.trimmedStart??t.start,n=t.trimmedEnd??t.end;if(r>=n)return;const o=e.slice(r,n),a=((e,t,r,n)=>{if(!r.length)return e;const o=r.map(e=>s[e]).sort((e,t)=>e.start-t.start);let a="",d=0;return o.forEach(r=>{const o=Math.max(d,r.start-t),s=Math.max(o,r.end-t);if(o>=s)return;const c=l.mixHexColors(n,r.color||"");a+=e.slice(d,o),a+=i(e.slice(o,s),r.badges?.[0]?.id||"",c,r.badges||[]),d=s}),a+=e.slice(d),a})(t.usedLooseMatch||r!==t.start||n!==t.end?o:t.highlight,t.start,u[t.idx]||[],t.color),d=i(a,t.badges?.[0]?.id||"",t.color,t.badges||[]);e=e.slice(0,r)+d+e.slice(n)}),e},[o,d,m,x,v,B]),A=r.useMemo(()=>s?M(c.normalizeRedlineMarkdown(s||"")):"",[s]),R=!!s,q={...p,"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap",lineHeight:"1.5"},position:"relative",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"inherit",fontWeight:"400",lineHeight:"1.5",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"},W={...q,zIndex:2,...R?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}},I={...q,zIndex:1,pointerEvents:"auto"};return r.useLayoutEffect(()=>{if(!j.current)return;const e=()=>{const e=Array.from(j.current.querySelectorAll(".deviation-badge"));if(0===e.length)return;e.forEach(e=>{e.style.setProperty("--badge-nudge","0px")});const t=j.current.getBoundingClientRect(),r=t.bottom-4,n=t.top+4,i=j.current.querySelector('div[data-layer="base"]')||j.current.querySelector("div")?.firstElementChild,o=R?j.current.querySelector('div[data-layer="overlay"]')||j.current.querySelector("div")?.lastElementChild:null,l=i?Array.from(i.querySelectorAll(".deviation-badge")):[],a=o?Array.from(o.querySelectorAll(".deviation-badge")):[],s=e.length>0?e.filter(e=>"left"===e.dataset.side):l.filter(e=>"left"===e.dataset.side),d=e.length>0?e.filter(e=>"left"!==e.dataset.side):l.filter(e=>"left"!==e.dataset.side),c=e=>{if(0===e.length)return;const t=e.map(e=>{const t=e.getBoundingClientRect();return{el:e,naturalTop:t.top,height:t.height,currentTop:t.top}});t.sort((e,t)=>e.naturalTop-t.naturalTop);const i=[];let o=[];t.forEach(e=>{if(0===o.length)o.push(e);else{const t=o[o.length-1],r=t.currentTop+t.height;e.naturalTop<r+8?(e.currentTop=r+8,o.push(e)):(i.push(o),o=[e])}}),o.length>0&&i.push(o),i.forEach(e=>{const t=e[e.length-1],i=t.currentTop+t.height;if(i>r){const t=i-r,o=e[0].currentTop-n,l=Math.max(0,Math.min(t,o));e.forEach(e=>{e.currentTop-=l})}}),i.flat().forEach(e=>{const t=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge",`${t}px`)})};if(R&&(l.length>0||a.length>0)){const e=l.filter(e=>"left"===e.dataset.side),t=l.filter(e=>"left"!==e.dataset.side),r=a.filter(e=>"left"===e.dataset.side),n=a.filter(e=>"left"!==e.dataset.side);c(e),c(t),c(r),c(n)}else c(s),c(d)},t=requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})}),r=new ResizeObserver(()=>{requestAnimationFrame(e)});return r.observe(j.current),()=>{r.disconnect(),cancelAnimationFrame(t)}},[z,E,T]),e.jsxs(t.Box,{ref:j,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0},children:[e.jsx(t.Typography,{component:"div",sx:W,children:e.jsx(u.default,{components:F,remarkPlugins:f,rehypePlugins:b,children:z.replace(/#{3}/g,"")})}),R&&e.jsx(t.Typography,{component:"div",sx:I,children:e.jsx(u.default,{components:F,remarkPlugins:f,rehypePlugins:b,children:A})})]})},l.areMarkdownPropsEqual);exports.MemoizedMarkdown=y;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@mui/material"),r=require("react"),n=require("../CognitiveCompareConstants.js"),i=require("lucide-react"),o=require("react-markdown"),a=require("../CognitiveComparehelpers.js"),s=require("rehype-raw"),l=require("remark-gfm");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(r),h=d(o),p=d(s);const g=e=>"function"==typeof e?e:e?.default||e,u=[g(d(l).default)],x=[g(p.default)],m=c.default.memo(({content:o,overlayContent:s,sxStyles:l,deviationBadges:d=[],highlights:p=[],maintainRelativeOrder:g=!0,highlightBg:m,suppressHighlightBg:f=!1,collisionKey:b})=>{const y=r.useRef(null),B=!!s,v=r.useMemo(()=>d.reduce((e,t)=>({...e,[t.id]:t}),{}),[d]),E=r.useRef({badgeMap:v,highlightBg:m,hideHighlightBg:B,suppressHighlightBg:f});E.current={badgeMap:v,highlightBg:m,hideHighlightBg:B,suppressHighlightBg:f};const j=(e,t)=>c.default.Children.map(e,e=>{if(!c.default.isValidElement(e))return e;const r=e.props?.children?j(e.props.children,t):e.props.children,n=c.default.cloneElement(e,{...e.props,children:r});return t(n)}),w=r.useMemo(()=>({mark:({children:t,...r})=>{const{badgeMap:n,highlightBg:i,hideHighlightBg:o,suppressHighlightBg:a}=E.current,s=r["data-badge-id"],l=s?n[s]:null,d=r["data-highlight-color"]??l?.style?.highlightBg??l?.style?.badgeBg??i,c="true"===r["data-is-suggested-deviation-fix"]||a;return e.jsx("span",{style:{...c?{}:{backgroundColor:d},borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px",...o?{color:"transparent"}:{}},children:t})},span:({children:r,...o})=>{const{badgeMap:a}=E.current,s=o["data-badge-id"];if(!s)return e.jsx("span",{...o,children:r});const l=a[s];if(!l)return e.jsx("span",{...o,children:r});const d="number"==typeof l.stackIndex?l.stackIndex:0,c=`translateY(calc(-20% + ${12*d}px + var(--badge-nudge, 0px)))`;return e.jsxs(t.Box,{component:"span",sx:{position:"static",display:"inline"},children:[e.jsxs(t.Box,{ref:l.badgeRef,className:"deviation-badge","data-side":l.side||"right",sx:{fontStyle:"normal",position:"absolute",zIndex:30+d,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:l.style?.badgeBg||"#EEF2FF",color:l.style?.badgeText||n.DEFAULT_DEVIAION_COLOR,border:`1px solid ${l.style?.badgeBorder||"#C7D2FE"}`,borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none",..."left"===l.side?{right:"-16px",transform:`${c} translateX(calc(100% + 8px))`}:{left:"-16px",transform:`${c} translateX(calc(-100% - 8px))`},...l.isConnected&&l.style&&{outline:`2px solid ${l.style.badgeBorder}`,outlineOffset:"1px"}},children:[e.jsxs(t.Box,{onClick:e=>{e.stopPropagation(),l.onSummaryClick&&l.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}},children:[e.jsx(t.Box,{component:"span",sx:{fontSize:"10px",fontWeight:700},children:l.label}),("left"===l.side||l.isOrphan)&&e.jsx(t.Box,{component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:`1px solid ${l.style?.badgeBorder||"#C7D2FE"}`},children:null!=l.score&&"N/A"!==l.score&&"NA"!==l.score&&0!==l.score?`${l.score}`:"N/A"===l.score||"NA"===l.score?"N/A":"Same"})]}),("left"===l.side||l.isOrphan)&&e.jsx(t.Box,{onClick:e=>{e.stopPropagation(),l.onClick&&l.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:`1px solid ${l.style?.badgeBorder||"#C7D2FE"}`,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}},children:e.jsx(i.EllipsisVertical,{size:12,color:l.style?.badgeText||"#3730A3"})})]}),r]})},table:({children:r})=>e.jsx(t.Box,{sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1},children:e.jsx(t.Box,{component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"},children:r})}),thead:({children:r})=>e.jsx(t.Box,{component:"thead",children:r}),tbody:({children:r})=>e.jsx(t.Box,{component:"tbody",children:r}),tr:({children:r})=>e.jsx(t.Box,{component:"tr",sx:{borderBottom:"1px solid #E5E7EB"},children:r}),th:({children:r})=>e.jsx(t.Box,{component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"},children:r}),td:({children:r})=>e.jsx(t.Box,{component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"},children:r}),code:({children:t})=>e.jsx("span",{style:{fontFamily:"inherit",fontSize:"inherit"},children:t}),pre:({children:t})=>e.jsx("span",{style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"},children:t}),updated:({children:t})=>e.jsx(e.Fragment,{children:t}),deleted:({children:t})=>{const r=j(t,e=>c.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"}));return e.jsx("span",{style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"},children:r})},changed:({children:t})=>{const r=j(t,e=>c.default.cloneElement(e,{"data-is-suggested-deviation-fix":"true"}));return e.jsx("span",{style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"},children:r})},ul:({children:r,...n})=>e.jsx(t.Box,{component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"},...n,children:r}),ol:({children:r,...n})=>e.jsx(t.Box,{component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"},...n,children:r}),li:({children:r,...n})=>e.jsx(t.Box,{component:"li",sx:{mb:.5,display:"list-item"},...n,children:r})}),[]),k=e=>{if(!e||"string"!=typeof e)return"";let t=e;t=t.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1"),t=t.replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n"),t=t.replace(/^(\d+\.)(\s{2,})/gm,(e,t,r)=>`${t.slice(0,-1)}\\.${r}`),t=t.replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,(e,t,r,n)=>`${t} ${n}`),t=t.replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2"),t=t.replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2"),t=t.replace(/\n{3,}/g,"\n\n"),t=t.replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,e=>e.replace(/ /g," ").replace(/\t/g," "));const r=t.split(/(\n{2,})/);return t=r.map(e=>/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,(t,r)=>{const n=e.slice(r+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(n)?"\n":" "})).join(""),t.trim()},C=e=>e.replace(/[\.,;:]/g," "),S=r.useMemo(()=>d.map(e=>({id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size})),[d]),F=r.useMemo(()=>{let e=k(o||"");const t=f?C(e):e,r=(d||[]).map(e=>({id:e?.id,highlight:k(e?.highlight||""),highlightColor:e?.style?.highlightBg||e?.style?.badgeBg||m})).filter(e=>e.id&&e.highlight),n={};r.forEach(e=>{n[e.highlight]||(n[e.highlight]=[]),n[e.highlight].push(e)});const i=(e,t="",r,n=[])=>{let i=!1;const o=e=>{const o=((e,t="",r)=>{const n=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!n)return e;const i=n[1]??"",o=n[2]??"",a=n[3]??"";return o?i+((e="",t)=>`<mark${e?` data-badge-id="${e}"`:""}${t?` data-highlight-color="${t}"`:""}>`)(t,r)+o+"</mark>"+a:e})(e,t,r);let a=o;if(!i&&n.length>0){i=!0;let e="",t="";n.forEach(r=>{e+=(e=>`<span data-badge-id="${e}">`)(r.id),t="</span>"+t}),a=e+o+t}return""+a};return e.split(/(\n+)/).map(e=>{if(/^\n+$/.test(e))return e;if(!e.trim())return e;return""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(e=>"|"!==e&&e.trim()?o(e):e).join(""):o(e)}).join("")},s=[];Object.entries(n).forEach(([r,n])=>{let i=e.indexOf(r),o=!1;if(-1===i&&f){const e=C(r);i=t.indexOf(e),-1!==i&&(o=!0)}if(-1===i)return;let l=n[0].highlightColor;for(let e=1;e<n.length;e++)l=a.mixHexColors(l,n[e].highlightColor||"");s.push({highlight:r,start:i,end:i+r.length,badges:n,color:l,usedLooseMatch:o})});const l=new Set(Object.keys(n));(p||[]).forEach(r=>{if(!r)return;const n=k(r);if(!n||l.has(n))return;let i=e.indexOf(n),o=!1;if(-1===i&&f){const e=C(n);i=t.indexOf(e),-1!==i&&(o=!0)}if(-1===i)return;const a=e.slice(0,i);(a.match(/</g)||[]).length===(a.match(/>/g)||[]).length&&s.push({highlight:n,start:i,end:i+n.length,badges:[],color:m||"",usedLooseMatch:o})}),s.sort((e,t)=>e.start-t.start||t.end-e.end);const c=[],h={};s.forEach((e,t)=>{let r=e.start,n=e.end;for(const i of c){const o=i.start,a=i.end,s=r<a&&n>a&&r>=o,l=r<o&&n>o&&n<=a;if(r>=o&&n<=a){e.orphaned=!0,h[t]=i.matchIdx;break}s&&(r=a),l&&(n=o)}e.trimmedStart=r,e.trimmedEnd=n,!e.orphaned&&r<n&&c.push({start:r,end:n,matchIdx:t})});const g={};Object.entries(h).forEach(([e,t])=>{const r=Number(e);g[t]||(g[t]=[]),g[t].push(r)});return s.map((e,t)=>({...e,idx:t})).filter(e=>!e.orphaned).sort((e,t)=>(t.trimmedStart??t.start)-(e.trimmedStart??e.start)).forEach(t=>{const r=t.trimmedStart??t.start,n=t.trimmedEnd??t.end;if(r>=n)return;const o=e.slice(r,n),l=((e,t,r,n)=>{if(!r.length)return e;const o=r.map(e=>s[e]).sort((e,t)=>e.start-t.start);let l="",d=0;return o.forEach(r=>{const o=Math.max(d,r.start-t),s=Math.max(o,r.end-t);if(o>=s)return;const c=a.mixHexColors(n,r.color||"");l+=e.slice(d,o),l+=i(e.slice(o,s),r.badges?.[0]?.id||"",c,r.badges||[]),d=s}),l+=e.slice(d),l})(t.usedLooseMatch||r!==t.start||n!==t.end?o:t.highlight,t.start,g[t.idx]||[],t.color),d=i(l,t.badges?.[0]?.id||"",t.color,t.badges||[]);e=e.slice(0,r)+d+e.slice(n)}),e},[o,d,p,m,f]),$=r.useMemo(()=>s?k(s||""):"",[s]),z=!!s,A={"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}},M={...l,...A,position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2,...z?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto"},"& table":{visibility:"hidden",margin:"0 !important"},"& th, & td":{padding:"0 !important",border:"none !important",backgroundColor:"transparent !important"},"& tr":{border:"none !important"},"& p:empty":{display:"none"}}:{}},T={...l,...A,position:"relative",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"};return r.useLayoutEffect(()=>{if(!y.current)return;const e=()=>{const e=Array.from(y.current.querySelectorAll(".deviation-badge"));if(0===e.length)return;e.forEach(e=>{e.style.setProperty("--badge-nudge","0px")});const t=e.filter(e=>"left"===e.dataset.side),r=e.filter(e=>"left"!==e.dataset.side),n=y.current.getBoundingClientRect(),i=n.bottom-4,o=n.top+4,a=e=>{if(0===e.length)return;const t=e.map(e=>{const t=e.getBoundingClientRect();return{el:e,naturalTop:t.top,height:t.height,currentTop:t.top}});t.sort((e,t)=>e.naturalTop-t.naturalTop);const r=[];let n=[];t.forEach(e=>{if(0===n.length)n.push(e);else{const t=n[n.length-1],i=t.currentTop+t.height;e.naturalTop<i+8?(e.currentTop=i+8,n.push(e)):(r.push(n),n=[e])}}),n.length>0&&r.push(n),r.forEach(e=>{const t=e[e.length-1],r=t.currentTop+t.height;if(r>i){const t=r-i,n=e[0].currentTop-o,a=Math.max(0,Math.min(t,n));e.forEach(e=>{e.currentTop-=a})}}),r.flat().forEach(e=>{const t=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge",`${t}px`)})};a(t),a(r)},t=requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})}),r=new ResizeObserver(()=>{requestAnimationFrame(e)});return r.observe(y.current),()=>{r.disconnect(),cancelAnimationFrame(t)}},[F,b,S]),e.jsxs(t.Box,{ref:y,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0},children:[e.jsx(t.Typography,{component:"div",sx:{...M,padding:"3px"},children:e.jsx(h.default,{components:w,remarkPlugins:u,rehypePlugins:x,children:F.replace(/#{3}/g,"")})}),z&&e.jsx(t.Typography,{component:"div",sx:T,children:e.jsx(h.default,{components:w,remarkPlugins:u,rehypePlugins:x,children:$})})]})},a.areMarkdownPropsEqual);exports.MemoizedMarkdown=m;
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoizedMarkdown.js","sources":["../../../../../src/features/CognitiveCompare/hooks/memoizedMarkdown.tsx"],"sourcesContent":["import { Box, Typography } from \"@mui/material\";\nimport React, { useMemo, useRef, useLayoutEffect, ReactElement, ReactNode } from \"react\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport { EllipsisVertical } from \"lucide-react\";\nimport ReactMarkdown from \"react-markdown\";\nimport {\n areMarkdownPropsEqual,\n findTextMatchRange,\n findRedlineTextAnchorRange,\n mixHexColors,\n} from \"../CognitiveComparehelpers\";\nimport { findTextRangeWithFormatting } from \"../utils/normalizeInlineMarkdown\";\nimport rehypeRaw from \"rehype-raw\";\nimport { HighlightMatch } from \"../CognitiveCompareTypes\";\nimport remarkGfm from \"remark-gfm\";\nimport { normalizeRedlineMarkdown } from \"../utils/normalizeRedlineMarkdown\";\nimport { normalizeCompactedGfmTables } from \"../utils/normalizeCompactedGfmTables\";\n\n// Ensures plugins work regardless of how the bundler exports them (ESM vs CJS)\nconst resolvePlugin = (plugin: any) => typeof plugin === \"function\" ? plugin : plugin?.default || plugin;\nconst remarkPlugins = [resolvePlugin(remarkGfm)];\nconst rehypePlugins = [resolvePlugin(rehypeRaw)];\n\ntype TransformFn = (element: ReactElement) => ReactElement;\nexport const MemoizedMarkdown = React.memo(({ \n content, \n overlayContent,\n fallbackContent,\n sxStyles, \n deviationBadges = [], \n highlights = [],\n maintainRelativeOrder = true,\n highlightBg,\n suppressHighlightBg = false,\n collisionKey\n}: { \n content: string; \n overlayContent?: string;\n fallbackContent?: string;\n sxStyles: any; \n deviationBadges?: any[]; \n highlights?: string[]; \n maintainRelativeOrder?: boolean;\n highlightBg: string;\n suppressHighlightBg?: boolean;\n collisionKey?: string | number;\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const hideHighlightBg = !!overlayContent;\n\n const badgeMap = useMemo(\n () => deviationBadges.reduce((acc, badge) => ({ ...acc, [badge.id]: badge }), {} as Record<string, any>),\n [deviationBadges],\n );\n\n const dynamicPropsRef = useRef({ badgeMap, highlightBg, hideHighlightBg, suppressHighlightBg });\n dynamicPropsRef.current = { badgeMap, highlightBg, hideHighlightBg, suppressHighlightBg };\n\n const mapChildrenDeep = (\n children: ReactNode,\n transform: TransformFn\n ): ReactNode => {\n return React.Children.map(children, (child) => {\n if (!React.isValidElement(child)) {\n return child;\n }\n\n const newChildren = child.props?.children\n ? mapChildrenDeep(child.props.children, transform)\n : child.props.children;\n\n const cloned = React.cloneElement(child, {\n ...child.props,\n children: newChildren,\n });\n\n return transform(cloned);\n });\n }\n\n const components = useMemo(() => ({\n mark: ({ children, ...props }: any) => {\n const { badgeMap, highlightBg, hideHighlightBg, suppressHighlightBg } = dynamicPropsRef.current;\n const badgeId = props[\"data-badge-id\"];\n const badge = badgeId ? badgeMap[badgeId] : null;\n const overrideBg = props[\"data-highlight-color\"];\n const bg =\n overrideBg\n ?? badge?.style?.highlightBg\n ?? badge?.style?.badgeBg\n ?? highlightBg;\n \n const shouldHideBg = props[\"data-is-suggested-deviation-fix\"] === \"true\" || suppressHighlightBg;\n \n return (\n <span style={{\n ...(!shouldHideBg ? { backgroundColor: bg } : {}),\n borderRadius: \"2px\",\n display: \"inline\",\n boxDecorationBreak: \"clone\",\n WebkitBoxDecorationBreak: \"clone\",\n backgroundClip: \"padding-box\",\n padding: \"0 1px\",\n ...(hideHighlightBg ? { color: \"transparent\" } : {})\n }}>\n {children}\n </span>\n );\n },\n br: () => <br />,\n span: ({ children, ...props }: any) => {\n const { badgeMap } = dynamicPropsRef.current;\n const badgeId = props[\"data-badge-id\"];\n if (!badgeId) return <span {...props}>{children}</span>;\n\n const badge = badgeMap[badgeId];\n if (!badge) return <span {...props}>{children}</span>;\n\n const stackIndex = typeof badge.stackIndex === \"number\" ? badge.stackIndex : 0;\n const stackOffset = stackIndex * 12;\n const translateY = `translateY(calc(-20% + ${stackOffset}px + var(--badge-nudge, 0px)))`;\n\n return (\n <Box component=\"span\" sx={{ position: \"static\", display: \"inline\" }}>\n <Box\n ref={badge.badgeRef}\n className=\"deviation-badge\"\n data-side={badge.side || \"right\"}\n sx={{\n fontStyle: \"normal\",\n position: \"absolute\",\n zIndex: 30 + stackIndex,\n display: \"inline-flex\",\n alignItems: \"stretch\",\n fontSize: \"10px\",\n bgcolor: badge.style?.badgeBg || \"#EEF2FF\",\n color: badge.style?.badgeText || DEFAULT_DEVIAION_COLOR,\n border: `1px solid ${badge.style?.badgeBorder || \"#C7D2FE\"}`,\n borderRadius: \"12px\",\n fontWeight: 600,\n whiteSpace: \"nowrap\",\n boxShadow: \"0 1px 3px rgba(0,0,0,0.07)\",\n overflow: \"hidden\",\n transition: \"none\",\n ...(badge.side === \"left\"\n ? { right: \"-16px\", transform: `${translateY} translateX(calc(100% + 8px))` }\n : { left: \"-16px\", transform: `${translateY} translateX(calc(-100% - 8px))` }),\n ...(badge.isConnected && badge.style && { outline: `2px solid ${badge.style.badgeBorder}`, outlineOffset: \"1px\" })\n }}\n >\n <Box\n onClick={(e) => {\n e.stopPropagation();\n if (badge.onSummaryClick) badge.onSummaryClick(e);\n }}\n sx={{\n display: \"flex\",\n alignItems: \"center\",\n px: 1,\n py: 0.3,\n cursor: \"pointer\",\n \"&:hover\": { bgcolor: \"rgba(0,0,0,0.04)\" },\n }}\n >\n <Box component=\"span\" sx={{ fontSize: \"10px\", fontWeight: 700 }}>\n {badge.label}\n </Box>\n {(badge.side === \"left\" || badge.isOrphan) && (\n <Box\n component=\"span\"\n sx={{\n fontSize: \"10px\",\n pl: 0.5,\n ml: 0.5,\n borderLeft: `1px solid ${badge.style?.badgeBorder || \"#C7D2FE\"}`,\n }}\n >\n {(badge.score != null && badge.score !== \"N/A\" && badge.score !== \"NA\" && badge.score !== 0)\n ? `${badge.score}`\n : (badge.score === \"N/A\" || badge.score === \"NA\")\n ? \"N/A\"\n : \"Same\"}\n </Box>\n )}\n </Box>\n\n {(badge.side === \"left\" || badge.isOrphan) && (\n <Box\n onClick={(e) => {\n e.stopPropagation();\n if (badge.onClick) badge.onClick(e);\n }}\n sx={{\n display: \"flex\",\n alignItems: \"center\",\n px: 0.5,\n borderLeft: `1px solid ${badge.style?.badgeBorder || \"#C7D2FE\"}`,\n cursor: \"pointer\",\n \"&:hover\": { bgcolor: \"rgba(0,0,0,0.06)\" },\n }}\n >\n <EllipsisVertical size={12} color={badge.style?.badgeText || \"#3730A3\"} />\n </Box>\n )}\n </Box>\n {children}\n </Box>\n );\n },\n table: ({ children }: any) => (\n <Box\n sx={{\n display: \"block\",\n width: \"100%\",\n maxWidth: \"100%\",\n minWidth: 0,\n boxSizing: \"border-box\",\n contain: \"inline-size\",\n overflowX: \"auto\",\n overflowY: \"hidden\",\n overscrollBehaviorX: \"contain\",\n WebkitOverflowScrolling: \"touch\",\n my: 1,\n }}\n >\n <Box\n component=\"table\"\n sx={{\n width: \"600px\",\n minWidth: \"600px\",\n tableLayout: \"fixed\",\n borderCollapse: \"collapse\",\n fontSize: \"inherit\",\n }}\n >\n {children}\n </Box>\n </Box>\n ),\n thead: ({ children }: any) => <Box component=\"thead\">{children}</Box>,\n tbody: ({ children }: any) => <Box component=\"tbody\">{children}</Box>,\n tr: ({ children }: any) => <Box component=\"tr\" sx={{ borderBottom: \"1px solid #E5E7EB\" }}>{children}</Box>,\n th: ({ children }: any) => <Box component=\"th\" sx={{ border: \"1px solid #E5E7EB\", padding: \"8px\", textAlign: \"left\", verticalAlign: \"top\", fontWeight: 600, backgroundColor: \"#F9FAFB\", whiteSpace: \"normal\", wordBreak: \"break-word\", overflowWrap: \"anywhere\" }}>{children}</Box>,\n td: ({ children }: any) => <Box component=\"td\" sx={{ border: \"1px solid #E5E7EB\", padding: \"8px\", verticalAlign: \"top\", whiteSpace: \"normal\", wordBreak: \"break-word\", overflowWrap: \"anywhere\" }}>{children}</Box>,\n code: ({ children }: any) => <span style={{ fontFamily: \"inherit\", fontSize: \"inherit\" }}>{children}</span>,\n pre: ({ children }: any) => <span style={{ fontFamily: \"inherit\", fontSize: \"inherit\", display: \"block\", whiteSpace: \"pre-wrap\" }}>{children}</span>,\n updated: ({ children }: any) => <>{children}</>,\n\n deleted: ({ children }: any) => {\n const updatedChildren = mapChildrenDeep(children, (el) => React.cloneElement(el, { \"data-is-suggested-deviation-fix\": \"true\" }));\n return <span style={{ boxShadow: \"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444\", backgroundColor: \"#FCCCCC\", textDecoration: \"line-through\" }}>{updatedChildren}</span>;\n },\n\n changed: ({ children }: any) => {\n const updatedChildren = mapChildrenDeep(children, (el) => React.cloneElement(el, { \"data-is-suggested-deviation-fix\": \"true\" }));\n return <span style={{ boxShadow: \"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF\", backgroundColor: \"#D5E8FF\" }}>{updatedChildren}</span>;\n },\n\n ul: ({ children, ...props }: any) => <Box component=\"ul\" sx={{ mt: 1, mb: 1, pl: 3, listStyleType: \"disc\" }} {...props}>{children}</Box>,\n ol: ({ children, ...props }: any) => <Box component=\"ol\" sx={{ mt: 1, mb: 1, pl: 3, listStyleType: \"decimal\" }} {...props}>{children}</Box>,\n li: ({ children, ...props }: any) => <Box component=\"li\" sx={{ mb: 0.5, display: \"list-item\" }} {...props}>{children}</Box>,\n }),\n []\n );\n\n const normalizeMarkdownText = (rawText: string): string => {\n if (!rawText || typeof rawText !== \"string\") return \"\";\n\n let text = normalizeCompactedGfmTables(rawText);\n\n text = text.replace(\n /((?:<\\/?(?:updated|changed|deleted|manual)\\b[^>]*>\\s*)+)([*+\\-] |\\d+\\. )/gi,\n \"$2$1\",\n );\n text = text\n .replace(/\\\\(['\"])/g, \"$1\")\n .replace(/\\\\n/g, \"\\n\")\n .replace(/\\\\\\./g, \".\") \n .replace(/\\r\\n/g, \"\\n\");\n \n // Redline wrapper removal can leave boundary indentation before a\n // numbered clause (` <deleted>4. ...`). Preserve that indentation while\n // escaping the marker so content and backend highlights normalize to\n // the same string before the final trim.\n text = text.replace(\n /^([ \\t]*)(\\d+\\.)(\\s{2,})/gm,\n (_, indent, num, spaces) =>\n `${indent}${num.slice(0, -1)}\\\\.${spaces}`,\n );\n text = text.replace(/^(\\d+\\.)\\s*\\n+(\\s+)(\\S)/gm, (_, marker, _indent, firstChar) => `${marker} ${firstChar}`);\n text = text.replace(/([^\\n])\\n(#{1,6} )/g, \"$1\\n\\n$2\");\n \n // Check for blank line before assign bullets\n text = text.replace(/([^\\n])\\n([ \\t]*(?:[#*+\\-] |\\d+\\. ))/g, \"$1\\n\\n$2\");\n\n text = text.replace(/\\n{3,}/g, \"\\n\\n\");\n\n // This protects the indentation required for markdown lists.\n text = text.replace(/^[ \\t]+(?![ \\t]*([\\*\\-\\+] |\\d+\\. ))/gm, (match) => {\n return match.replace(/ /g, \"\\u00A0\").replace(/\\t/g, \"\\u00A0\\u00A0\\u00A0\\u00A0\");\n });\n\n const parts = text.split(/(\\n{2,})/);\n text = parts.map((chunk) => {\n if (/^\\n+$/.test(chunk)) return chunk;\n if (/\\|.*\\|/.test(chunk) && /\\|[\\s:|-]+\\|/.test(chunk)) return chunk;\n if (/^#{1,6} /.test(chunk.trimStart())) return chunk;\n \n return chunk.replace(/\\n(?=[^\\n])/g, (_, offset) => {\n const remainingLine = chunk.slice(offset + 1);\n // If it is a bullet/number/table/heading, DO NOT collapse the newline\n const isStructural = /^[ \\t]*([#>|\\-*+]|\\d+\\.)/.test(remainingLine);\n return isStructural ? \"\\n\" : \" \";\n });\n }).join(\"\");\n\n // CRITICAL: Removed the duplicate `text = text.replace(/^[ \\t]+/gm...)` block from here!\n\n return text.trim();\n };\n\n const collisionDependency = useMemo(() => deviationBadges.map((badge) => ({\n id: badge.id,\n connected: badge.isConnected,\n stackIndex: badge.stackIndex,\n size: badge.size,\n })), [deviationBadges]);\n\n const buildMarkOpen = (badgeId: string = \"\", color?: string) => {\n const colorAttr = color ? ` data-highlight-color=\"${color}\"` : \"\";\n const badgeAttr = badgeId ? ` data-badge-id=\"${badgeId}\"` : \"\";\n return `<mark${badgeAttr}${colorAttr}>`;\n };\n \n const buildMarkClose = () => `</mark>`;\n const buildSpanOpen = (badgeId: string) => `<span data-badge-id=\"${badgeId}\">`;\n const buildSpanClose = () => `</span>`;\n\n const wrapWithMark = (value: string, badgeId: string = \"\", highlightColor?: string) => {\n const match = value.match(/^(\\s*)([\\s\\S]*?)(\\s*)$/);\n if (!match) return value;\n const leading = match[1] ?? \"\";\n const body = match[2] ?? \"\";\n const trailing = match[3] ?? \"\";\n if (!body) return value;\n return leading + buildMarkOpen(badgeId, highlightColor) + body + buildMarkClose() + trailing;\n };\n\n const normalizeHighlightText = (value: string): string =>\n normalizeMarkdownText(normalizeRedlineMarkdown(value || \"\"));\n\n const contentToRender = useMemo(() => {\n // 2. CRITICAL: Removed safeStringify here. Pure strings only to prevent encoded brackets.\n let normalizedContent = normalizeMarkdownText(\n normalizeRedlineMarkdown(content || \"\"),\n );\n const normalizedFallbackContent = fallbackContent\n ? normalizeMarkdownText(normalizeRedlineMarkdown(fallbackContent))\n : \"\";\n\n const badgeEntries = (deviationBadges || [])\n .map((badge: any) => ({\n id: badge?.id,\n // Content passes through table reconciliation before matching, so\n // highlights must use the same pipeline. This is especially\n // important for redlines whose deleted text ends in a GFM table.\n highlight: normalizeHighlightText(badge?.highlight || \"\"),\n highlightColor: badge?.style?.highlightBg || badge?.style?.badgeBg || highlightBg,\n }))\n .filter((entry: any) => entry.id && entry.highlight);\n\n // Fixed/redlined clauses can no longer contain the original deviation\n // text contiguously. Prefer the current content, but when at least one\n // badge cannot anchor there and every badge can anchor in change_history,\n // use that history as the invisible badge-positioning layer.\n if (normalizedFallbackContent && badgeEntries.length > 0) {\n const findAnchor = (anchorContent: string, highlight: string) =>\n suppressHighlightBg\n ? findRedlineTextAnchorRange(anchorContent, highlight)\n : findTextMatchRange(anchorContent, highlight, false);\n const hasPrimaryMiss = badgeEntries.some(\n ({ highlight }: any) => !findAnchor(normalizedContent, highlight),\n );\n const allMatchFallback = badgeEntries.every(\n ({ highlight }: any) => !!findAnchor(normalizedFallbackContent, highlight),\n );\n\n if (hasPrimaryMiss && allMatchFallback) {\n normalizedContent = normalizedFallbackContent;\n }\n }\n\n const groupedBadges: Record<string, any[]> = {};\n badgeEntries.forEach((entry) => {\n if (!groupedBadges[entry.highlight]) groupedBadges[entry.highlight] = [];\n groupedBadges[entry.highlight].push(entry);\n });\n\n const createMarkedHighlight = (text: string, badgeId: string = \"\", highlightColor?: string, badges: any[] = []) => {\n let spanEmitted = false;\n\n const wrapSegment = (segment: string): string => {\n const mark = wrapWithMark(segment, badgeId, highlightColor);\n let wrapped = mark;\n \n if (!spanEmitted && badges.length > 0) {\n spanEmitted = true;\n let spansOpen = \"\";\n let spansClose = \"\";\n \n // Emit spans for ALL badges in the group, not just badges[0]\n badges.forEach((b) => {\n spansOpen += buildSpanOpen(b.id);\n spansClose = buildSpanClose() + spansClose;\n });\n \n wrapped = spansOpen + mark + spansClose;\n }\n \n return \"\\u200B\" + wrapped;\n };\n\n return text\n .split(/(\\n+)/)\n .map((part) => {\n if (/^\\n+$/.test(part)) return part;\n if (!part.trim()) return part;\n const strippedForSeparatorCheck = part.replace(/[|:\\-\\s]/g, \"\");\n if (strippedForSeparatorCheck === \"\" && part.includes(\"-\")) return part;\n if (part.includes(\"|\")) {\n return part.split(/(\\|)/).map((cell) => {\n if (cell === \"|\" || !cell.trim()) return cell;\n return wrapSegment(cell);\n }).join(\"\");\n }\n return wrapSegment(part);\n })\n .join(\"\");\n };\n\n const allMatches: HighlightMatch[] = [];\n\n Object.entries(groupedBadges).forEach(([highlight, badges]) => {\n let range = suppressHighlightBg\n ? findRedlineTextAnchorRange(normalizedContent, highlight)\n : findTextMatchRange(normalizedContent, highlight, false);\n \n if (!range && !suppressHighlightBg) {\n range = findTextRangeWithFormatting(normalizedContent, highlight);\n }\n if (!range) return;\n const usedLooseMatch =\n normalizedContent.slice(range.start, range.end) !== highlight;\n\n let color = badges[0].highlightColor;\n for (let i = 1; i < badges.length; i++) {\n color = mixHexColors(color, badges[i].highlightColor || \"\");\n }\n\n allMatches.push({\n highlight,\n start: range.start,\n end: range.end,\n badges,\n color,\n usedLooseMatch,\n });\n });\n\n const badgeHighlightSet = new Set(Object.keys(groupedBadges));\n\n (highlights || []).forEach((highlight) => {\n if (!highlight) return;\n const cleanHighlight = normalizeHighlightText(highlight);\n if (!cleanHighlight || badgeHighlightSet.has(cleanHighlight)) return;\n\n const range = suppressHighlightBg\n ? findRedlineTextAnchorRange(normalizedContent, cleanHighlight)\n : findTextMatchRange(normalizedContent, cleanHighlight, false);\n if (!range) return;\n const usedLooseMatch =\n normalizedContent.slice(range.start, range.end) !== cleanHighlight;\n\n const before = normalizedContent.slice(0, range.start);\n const openTags = (before.match(/</g) || []).length;\n const closeTags = (before.match(/>/g) || []).length;\n \n if (openTags === closeTags) {\n allMatches.push({\n highlight: cleanHighlight,\n start: range.start,\n end: range.end,\n badges: [],\n color: highlightBg || \"\",\n usedLooseMatch,\n } as unknown as HighlightMatch);\n }\n });\n\n allMatches.sort((a, b) => a.start - b.start || b.end - a.end);\n\n const claimedRanges: Array<{ start: number; end: number; matchIdx: number }> = [];\n const containedBy: Record<number, number> = {};\n\n allMatches.forEach((match, i) => {\n let start = match.start;\n let end = match.end;\n\n for (const claimed of claimedRanges) {\n const cStart = claimed.start;\n const cEnd = claimed.end;\n const fullyContained = start >= cStart && end <= cEnd;\n const partialOverlapRight = start < cEnd && end > cEnd && start >= cStart;\n const partialOverlapLeft = start < cStart && end > cStart && end <= cEnd;\n\n if (fullyContained) {\n match.orphaned = true;\n containedBy[i] = claimed.matchIdx;\n break;\n }\n if (partialOverlapRight) start = cEnd;\n if (partialOverlapLeft) end = cStart;\n }\n\n match.trimmedStart = start;\n match.trimmedEnd = end;\n\n if (!match.orphaned && start < end) {\n claimedRanges.push({ start, end, matchIdx: i });\n }\n });\n\n const childrenOf: Record<number, number[]> = {};\n Object.entries(containedBy).forEach(([childIdxStr, parentIdx]) => {\n const childIdx = Number(childIdxStr);\n if (!childrenOf[parentIdx]) childrenOf[parentIdx] = [];\n childrenOf[parentIdx].push(childIdx);\n });\n\n const injectChildren = (highlightText: string, parentAbsStart: number, childIndices: number[], parentColor: string) => {\n if (!childIndices.length) return highlightText;\n const children = childIndices.map((ci) => allMatches[ci]).sort((a, b) => a.start - b.start);\n let result = \"\";\n let cursor = 0;\n\n children.forEach((child) => {\n const relStart = Math.max(cursor, child.start - parentAbsStart);\n const relEnd = Math.max(relStart, child.end - parentAbsStart);\n if (relStart >= relEnd) return;\n\n const mixedColor = mixHexColors(parentColor, child.color || \"\");\n result += highlightText.slice(cursor, relStart);\n\n // Removed the redundant wrapperStart/wrapperEnd logic.\n // createMarkedHighlight now handles the spans natively and cleanly.\n result += createMarkedHighlight(\n highlightText.slice(relStart, relEnd), \n child.badges?.[0]?.id || \"\", \n mixedColor, \n child.badges || []\n );\n \n cursor = relEnd;\n });\n\n result += highlightText.slice(cursor);\n return result;\n };\n\n const finalMatches = allMatches.map((m, i) => ({ ...m, idx: i })).filter((m) => !m.orphaned).sort((a, b) => (b.trimmedStart ?? b.start) - (a.trimmedStart ?? a.start));\n\n finalMatches.forEach((match) => {\n const tStart = match.trimmedStart ?? match.start;\n const tEnd = match.trimmedEnd ?? match.end;\n if (tStart >= tEnd) return;\n\n const rawSlice = normalizedContent.slice(tStart, tEnd);\n const effectiveHighlight = match.usedLooseMatch || tStart !== match.start || tEnd !== match.end ? rawSlice : match.highlight;\n const withChildren = injectChildren(effectiveHighlight, match.start, childrenOf[match.idx!] || [], match.color);\n const markedText = createMarkedHighlight(withChildren, match.badges?.[0]?.id || \"\", match.color, match.badges || []);\n\n normalizedContent = normalizedContent.slice(0, tStart) + markedText + normalizedContent.slice(tEnd);\n });\n\n return normalizedContent;\n }, [content, fallbackContent, deviationBadges, highlights, highlightBg, suppressHighlightBg]);\n\n const overlayContentToRender = useMemo(() => {\n if (!overlayContent) return \"\";\n return normalizeMarkdownText(\n normalizeRedlineMarkdown(overlayContent || \"\"),\n );\n }, [overlayContent]);\n\n const hasOverlay = !!overlayContent;\n\n const sharedContentSx = {\n \"& *\": { fontFamily: \"inherit\" },\n \"& code, & pre, & kbd, & samp\": {\n fontFamily: \"inherit !important\",\n fontSize: \"inherit\",\n background: \"none\",\n padding: 0,\n border: \"none\",\n whiteSpace: \"pre-wrap\",\n },\n \"& p, & li, & ul, & ol\": { \n position: \"static\", \n overflow: \"visible\", \n whiteSpace: \"pre-wrap\",\n lineHeight: \"1.5\"\n },\n };\n\n const layerSx = {\n ...sxStyles,\n ...sharedContentSx,\n position: \"relative\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n fontSize: \"inherit\",\n fontWeight: \"400\",\n lineHeight: \"1.5\",\n width: \"100%\",\n maxWidth: \"100%\",\n minWidth: 0,\n boxSizing: \"border-box\",\n overflow: \"visible\",\n whiteSpace: \"normal\",\n gridArea: \"1 / 1\",\n padding: \"3px\",\n };\n\n const baseSx = { ...layerSx, zIndex: 2, ...(hasOverlay ? {\n color: \"transparent\",\n userSelect: \"none\", \n pointerEvents: \"none\", \n \"& .deviation-badge\": { pointerEvents: \"auto\", visibility: \"visible\" },\n \"& table\": { visibility: \"hidden\" },\n } : {})\n };\n\n const overlaySx = { ...layerSx, zIndex: 1, pointerEvents: \"auto\" };\n\n useLayoutEffect(() => {\n if (!containerRef.current) return;\n\n const resolveCollisions = () => {\n const badges = Array.from(\n containerRef.current!.querySelectorAll(\".deviation-badge\")\n ) as HTMLElement[];\n \n if (badges.length === 0) return;\n\n badges.forEach((b) => { b.style.setProperty(\"--badge-nudge\", \"0px\"); });\n\n const containerRect = containerRef.current!.getBoundingClientRect();\n const maxBottom = containerRect.bottom - 4;\n const minTop = containerRect.top + 4;\n\n // Separate badges by layer to ensure collision detection respects layer boundaries\n const baseLayer = containerRef.current!.querySelector('div[data-layer=\"base\"]') || containerRef.current!.querySelector('div')?.firstElementChild;\n const overlayLayer = hasOverlay ? containerRef.current!.querySelector('div[data-layer=\"overlay\"]') || containerRef.current!.querySelector('div')?.lastElementChild : null;\n \n const baseLayerBadges = baseLayer ? Array.from(baseLayer.querySelectorAll(\".deviation-badge\")) as HTMLElement[] : [];\n const overlayLayerBadges = overlayLayer ? Array.from(overlayLayer.querySelectorAll(\".deviation-badge\")) as HTMLElement[] : [];\n \n // If layer separation fails, fall back to side-based separation for backward compatibility\n const leftBadges = badges.length > 0 ? badges.filter((b) => b.dataset.side === \"left\") : baseLayerBadges.filter((b) => b.dataset.side === \"left\");\n const rightBadges = badges.length > 0 ? badges.filter((b) => b.dataset.side !== \"left\") : baseLayerBadges.filter((b) => b.dataset.side !== \"left\");\n\n const applyPushDownAndClamp = (sideBadges: HTMLElement[]) => {\n if (sideBadges.length === 0) return;\n\n const metrics = sideBadges.map((el) => {\n const rect = el.getBoundingClientRect();\n return { \n el, \n naturalTop: rect.top, \n height: rect.height,\n currentTop: rect.top\n };\n });\n\n metrics.sort((a, b) => a.naturalTop - b.naturalTop);\n\n const MIN_GAP = 8;\n const clusters: typeof metrics[] = [];\n let currentCluster: typeof metrics = [];\n\n metrics.forEach((item) => {\n if (currentCluster.length === 0) {\n currentCluster.push(item);\n } else {\n const prev = currentCluster[currentCluster.length - 1];\n const prevBottom = prev.currentTop + prev.height;\n\n if (item.naturalTop < prevBottom + MIN_GAP) {\n item.currentTop = prevBottom + MIN_GAP;\n currentCluster.push(item);\n } else {\n clusters.push(currentCluster);\n currentCluster = [item];\n }\n }\n });\n if (currentCluster.length > 0) clusters.push(currentCluster);\n\n clusters.forEach((cluster) => {\n const lastItem = cluster[cluster.length - 1];\n const clusterBottom = lastItem.currentTop + lastItem.height;\n\n if (clusterBottom > maxBottom) {\n const overflowAmount = clusterBottom - maxBottom;\n\n const firstItem = cluster[0];\n const availableTopSpace = firstItem.currentTop - minTop;\n \n const actualShiftUp = Math.max(0, Math.min(overflowAmount, availableTopSpace));\n\n cluster.forEach((item) => {\n item.currentTop -= actualShiftUp;\n });\n }\n });\n\n clusters.flat().forEach((item) => {\n const nudge = item.currentTop - item.naturalTop;\n item.el.style.setProperty(\"--badge-nudge\", `${nudge}px`);\n });\n };\n\n // Apply collision resolution separately for each layer when overlay exists\n if (hasOverlay && (baseLayerBadges.length > 0 || overlayLayerBadges.length > 0)) {\n const baseLeftBadges = baseLayerBadges.filter((b) => b.dataset.side === \"left\");\n const baseRightBadges = baseLayerBadges.filter((b) => b.dataset.side !== \"left\");\n const overlayLeftBadges = overlayLayerBadges.filter((b) => b.dataset.side === \"left\");\n const overlayRightBadges = overlayLayerBadges.filter((b) => b.dataset.side !== \"left\");\n \n applyPushDownAndClamp(baseLeftBadges);\n applyPushDownAndClamp(baseRightBadges);\n applyPushDownAndClamp(overlayLeftBadges);\n applyPushDownAndClamp(overlayRightBadges);\n } else {\n // Single layer or backward compatibility mode\n applyPushDownAndClamp(leftBadges);\n applyPushDownAndClamp(rightBadges);\n }\n };\n\n const raf1 = requestAnimationFrame(()=>{\n requestAnimationFrame(()=>{\n resolveCollisions();\n })\n });\n\n const resizeObserver = new ResizeObserver(() => {\n requestAnimationFrame(resolveCollisions);\n });\n resizeObserver.observe(containerRef.current);\n\n return () => {\n resizeObserver.disconnect();\n cancelAnimationFrame(raf1);\n }\n }, [contentToRender, collisionKey, collisionDependency]);\n\n return (\n <Box\n ref={containerRef}\n sx={{\n position: \"relative\",\n display: \"grid\",\n gridTemplateColumns: \"minmax(0, 1fr)\",\n width: \"100%\",\n maxWidth: \"100%\",\n minWidth: 0,\n }}\n >\n <Typography component=\"div\" sx={baseSx}>\n <ReactMarkdown\n components={components}\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n >\n {/* 4. Removed safeStringify wrapper! It encodes < to < */}\n {contentToRender.replace(/#{3}/g, \"\")}\n </ReactMarkdown>\n </Typography>\n\n {hasOverlay && (\n <Typography component=\"div\" sx={overlaySx}>\n <ReactMarkdown\n components={components}\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n >\n {overlayContentToRender}\n </ReactMarkdown>\n </Typography>\n )}\n </Box>\n );\n },\n areMarkdownPropsEqual\n);\n"],"names":["resolvePlugin","plugin","default","remarkPlugins","rehypePlugins","rehypeRaw","MemoizedMarkdown","React","memo","content","overlayContent","fallbackContent","sxStyles","deviationBadges","highlights","maintainRelativeOrder","highlightBg","suppressHighlightBg","collisionKey","containerRef","useRef","hideHighlightBg","badgeMap","useMemo","reduce","acc","badge","id","dynamicPropsRef","current","mapChildrenDeep","children","transform","Children","map","child","isValidElement","newChildren","props","cloned","cloneElement","components","mark","badgeId","bg","style","badgeBg","shouldHideBg","jsx","backgroundColor","borderRadius","display","boxDecorationBreak","WebkitBoxDecorationBreak","backgroundClip","padding","color","br","span","stackIndex","translateY","jsxs","Box","component","sx","position","ref","badgeRef","className","side","fontStyle","zIndex","alignItems","fontSize","bgcolor","badgeText","DEFAULT_DEVIAION_COLOR","border","badgeBorder","fontWeight","whiteSpace","boxShadow","overflow","transition","right","left","isConnected","outline","outlineOffset","onClick","e","stopPropagation","onSummaryClick","px","py","cursor","label","isOrphan","pl","ml","borderLeft","score","EllipsisVertical","size","table","width","maxWidth","minWidth","boxSizing","contain","overflowX","overflowY","overscrollBehaviorX","WebkitOverflowScrolling","my","tableLayout","borderCollapse","thead","tbody","tr","borderBottom","th","textAlign","verticalAlign","wordBreak","overflowWrap","td","code","fontFamily","pre","updated","deleted","updatedChildren","el","textDecoration","changed","ul","mt","mb","listStyleType","ol","li","normalizeMarkdownText","rawText","text","normalizeCompactedGfmTables","replace","_","indent","num","spaces","slice","marker","_indent","firstChar","match","parts","split","chunk","test","trimStart","offset","remainingLine","join","trim","collisionDependency","connected","normalizeHighlightText","value","normalizeRedlineMarkdown","contentToRender","normalizedContent","normalizedFallbackContent","badgeEntries","highlight","highlightColor","filter","entry","length","findAnchor","anchorContent","findRedlineTextAnchorRange","findTextMatchRange","hasPrimaryMiss","some","allMatchFallback","every","groupedBadges","forEach","push","createMarkedHighlight","badges","spanEmitted","wrapSegment","segment","leading","body","trailing","buildMarkOpen","wrapWithMark","wrapped","spansOpen","spansClose","b","buildSpanOpen","part","includes","cell","allMatches","Object","entries","range","findTextRangeWithFormatting","usedLooseMatch","start","end","i","mixHexColors","badgeHighlightSet","Set","keys","cleanHighlight","has","before","sort","a","claimedRanges","containedBy","claimed","cStart","cEnd","partialOverlapRight","partialOverlapLeft","orphaned","matchIdx","trimmedStart","trimmedEnd","childrenOf","childIdxStr","parentIdx","childIdx","Number","m","idx","tStart","tEnd","rawSlice","withChildren","highlightText","parentAbsStart","childIndices","parentColor","ci","result","relStart","Math","max","relEnd","mixedColor","injectChildren","markedText","overlayContentToRender","hasOverlay","layerSx","background","lineHeight","gridArea","baseSx","userSelect","pointerEvents","visibility","overlaySx","useLayoutEffect","resolveCollisions","Array","from","querySelectorAll","setProperty","containerRect","getBoundingClientRect","maxBottom","bottom","minTop","top","baseLayer","querySelector","firstElementChild","overlayLayer","lastElementChild","baseLayerBadges","overlayLayerBadges","leftBadges","dataset","rightBadges","applyPushDownAndClamp","sideBadges","metrics","rect","naturalTop","height","currentTop","clusters","currentCluster","item","prev","prevBottom","cluster","lastItem","clusterBottom","overflowAmount","availableTopSpace","actualShiftUp","min","flat","nudge","baseLeftBadges","baseRightBadges","overlayLeftBadges","overlayRightBadges","raf1","requestAnimationFrame","resizeObserver","ResizeObserver","observe","disconnect","cancelAnimationFrame","gridTemplateColumns","Typography","ReactMarkdown","areMarkdownPropsEqual"],"mappings":"4kBAmBA,MAAMA,EAAiBC,GAAkC,mBAAXA,EAAwBA,EAASA,GAAQC,SAAWD,EAC5FE,EAAgB,CAACH,OAAuB,UACxCI,EAAgB,CAACJ,EAAcK,EAAS,UAGjCC,EAAmBC,EAAM,QAAAC,KAAK,EACzCC,UACAC,iBACAC,kBACAC,WACAC,kBAAkB,GAClBC,aAAa,GACbC,yBAAwB,EACxBC,cACAC,uBAAsB,EACtBC,mBAaM,MAAAC,EAAeC,SAAuB,MACtCC,IAAoBX,EAEpBY,EAAWC,EAAAA,QACf,IAAMV,EAAgBW,OAAO,CAACC,EAAKC,SAAgBD,EAAK,CAACC,EAAMC,IAAKD,IAAU,CAAA,GAC9E,CAACb,IAGGe,EAAkBR,EAAAA,OAAO,CAAEE,WAAUN,cAAaK,kBAAiBJ,wBACzEW,EAAgBC,QAAU,CAAEP,WAAUN,cAAaK,kBAAiBJ,uBAE9D,MAAAa,EAAkB,CACtBC,EACAC,IAEOzB,EAAM,QAAA0B,SAASC,IAAIH,EAAWI,IACnC,IAAK5B,EAAA,QAAM6B,eAAeD,GACjB,OAAAA,EAGH,MAAAE,EAAcF,EAAMG,OAAOP,SAC7BD,EAAgBK,EAAMG,MAAMP,SAAUC,GACtCG,EAAMG,MAAMP,SAEVQ,EAAShC,EAAAA,QAAMiC,aAAaL,EAAO,IACpCA,EAAMG,MACTP,SAAUM,IAGZ,OAAOL,EAAUO,KAIfE,EAAalB,EAAAA,QAAQ,KAAO,CAChCmB,KAAM,EAAGX,cAAaO,MACd,MAAEhB,SAAAA,EAAUN,YAAAA,EAAaK,gBAAAA,EAAiBJ,oBAAAA,GAAwBW,EAAgBC,QAClFc,EAAUL,EAAM,iBAChBZ,EAAQiB,EAAUrB,EAASq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AqBN,KAEtB,CAACrJ,EAAiBxJ,EAAcmJ,IAG/BxG,EAAAA,KAACC,EAAAA,IAAA,CACCI,IAAK/C,EACL6C,GAAI,CACFC,SAAU,WACVd,QAAS,OACTmR,oBAAqB,iBACrB7N,MAAO,OACPC,SAAU,OACVC,SAAU,GAGZ5E,SAAA,CAAAiB,EAAAA,IAACuR,EAAWA,WAAA,CAAAxQ,UAAU,MAAMC,GAAI2M,EAC9B5O,SAAAiB,EAAAA,IAACwR,EAAA,QAAA,CACC/R,aACAtC,gBACAC,gBAGC2B,SAAA2I,EAAgBxB,QAAQ,QAAS,QAIrCoH,GACEtN,EAAAA,IAAAuR,EAAAA,WAAA,CAAWxQ,UAAU,MAAMC,GAAI+M,EAC9BhP,SAAAiB,EAAAA,IAACwR,EAAA,QAAA,CACC/R,aACAtC,gBACAC,gBAEC2B,SAAAsO,UAOboE,EAAAA"}
|
|
1
|
+
{"version":3,"file":"memoizedMarkdown.js","sources":["../../../../../src/features/CognitiveCompare/hooks/memoizedMarkdown.tsx"],"sourcesContent":["import { Box, Typography } from \"@mui/material\";\nimport React, { useMemo, useRef, useLayoutEffect, ReactElement, ReactNode } from \"react\";\nimport { DEFAULT_DEVIAION_COLOR } from \"../CognitiveCompareConstants\";\nimport { EllipsisVertical } from \"lucide-react\";\nimport ReactMarkdown from \"react-markdown\";\nimport { areMarkdownPropsEqual, mixHexColors } from \"../CognitiveComparehelpers\";\nimport rehypeRaw from \"rehype-raw\";\nimport { HighlightMatch } from \"../CognitiveCompareTypes\";\nimport remarkGfm from \"remark-gfm\";\n\n// Ensures plugins work regardless of how the bundler exports them (ESM vs CJS)\nconst resolvePlugin = (plugin: any) => typeof plugin === \"function\" ? plugin : plugin?.default || plugin;\nconst remarkPlugins = [resolvePlugin(remarkGfm)];\nconst rehypePlugins = [resolvePlugin(rehypeRaw)];\n\ntype TransformFn = (element: ReactElement) => ReactElement;\nexport const MemoizedMarkdown = React.memo(({ \n content, \n overlayContent,\n sxStyles, \n deviationBadges = [], \n highlights = [],\n maintainRelativeOrder = true,\n highlightBg,\n suppressHighlightBg = false,\n collisionKey\n}: { \n content: string; \n overlayContent?: string;\n sxStyles: any; \n deviationBadges?: any[]; \n highlights?: string[]; \n maintainRelativeOrder?: boolean;\n highlightBg: string;\n suppressHighlightBg?: boolean;\n collisionKey?: string | number;\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const hideHighlightBg = !!overlayContent;\n\n const badgeMap = useMemo(\n () => deviationBadges.reduce((acc, badge) => ({ ...acc, [badge.id]: badge }), {} as Record<string, any>),\n [deviationBadges],\n );\n\n const dynamicPropsRef = useRef({ badgeMap, highlightBg, hideHighlightBg, suppressHighlightBg });\n dynamicPropsRef.current = { badgeMap, highlightBg, hideHighlightBg, suppressHighlightBg };\n\n const mapChildrenDeep = (\n children: ReactNode,\n transform: TransformFn\n ): ReactNode => {\n return React.Children.map(children, (child) => {\n if (!React.isValidElement(child)) {\n return child;\n }\n\n const newChildren = child.props?.children\n ? mapChildrenDeep(child.props.children, transform)\n : child.props.children;\n\n const cloned = React.cloneElement(child, {\n ...child.props,\n children: newChildren,\n });\n\n return transform(cloned);\n });\n }\n\n const components = useMemo(() => ({\n mark: ({ children, ...props }: any) => {\n const { badgeMap, highlightBg, hideHighlightBg, suppressHighlightBg } = dynamicPropsRef.current;\n const badgeId = props[\"data-badge-id\"];\n const badge = badgeId ? badgeMap[badgeId] : null;\n const overrideBg = props[\"data-highlight-color\"];\n const bg =\n overrideBg\n ?? badge?.style?.highlightBg\n ?? badge?.style?.badgeBg\n ?? highlightBg;\n \n const shouldHideBg = props[\"data-is-suggested-deviation-fix\"] === \"true\" || suppressHighlightBg;\n \n return (\n <span style={{\n ...(!shouldHideBg ? { backgroundColor: bg } : {}),\n borderRadius: \"2px\",\n display: \"inline\",\n boxDecorationBreak: \"clone\",\n WebkitBoxDecorationBreak: \"clone\",\n backgroundClip: \"padding-box\",\n padding: \"0 1px\",\n ...(hideHighlightBg ? { color: \"transparent\" } : {})\n }}>\n {children}\n </span>\n );\n },\n span: ({ children, ...props }: any) => {\n const { badgeMap } = dynamicPropsRef.current;\n const badgeId = props[\"data-badge-id\"];\n if (!badgeId) return <span {...props}>{children}</span>;\n\n const badge = badgeMap[badgeId];\n if (!badge) return <span {...props}>{children}</span>;\n\n const stackIndex = typeof badge.stackIndex === \"number\" ? badge.stackIndex : 0;\n const stackOffset = stackIndex * 12;\n const translateY = `translateY(calc(-20% + ${stackOffset}px + var(--badge-nudge, 0px)))`;\n\n return (\n <Box component=\"span\" sx={{ position: \"static\", display: \"inline\" }}>\n <Box\n ref={badge.badgeRef}\n className=\"deviation-badge\"\n data-side={badge.side || \"right\"}\n sx={{\n fontStyle: \"normal\",\n position: \"absolute\",\n zIndex: 30 + stackIndex,\n display: \"inline-flex\",\n alignItems: \"stretch\",\n fontSize: \"10px\",\n bgcolor: badge.style?.badgeBg || \"#EEF2FF\",\n color: badge.style?.badgeText || DEFAULT_DEVIAION_COLOR,\n border: `1px solid ${badge.style?.badgeBorder || \"#C7D2FE\"}`,\n borderRadius: \"12px\",\n fontWeight: 600,\n whiteSpace: \"nowrap\",\n boxShadow: \"0 1px 3px rgba(0,0,0,0.07)\",\n overflow: \"hidden\",\n transition: \"none\",\n ...(badge.side === \"left\"\n ? { right: \"-16px\", transform: `${translateY} translateX(calc(100% + 8px))` }\n : { left: \"-16px\", transform: `${translateY} translateX(calc(-100% - 8px))` }),\n ...(badge.isConnected && badge.style && { outline: `2px solid ${badge.style.badgeBorder}`, outlineOffset: \"1px\" })\n }}\n >\n <Box\n onClick={(e) => {\n e.stopPropagation();\n if (badge.onSummaryClick) badge.onSummaryClick(e);\n }}\n sx={{\n display: \"flex\",\n alignItems: \"center\",\n px: 1,\n py: 0.3,\n cursor: \"pointer\",\n \"&:hover\": { bgcolor: \"rgba(0,0,0,0.04)\" },\n }}\n >\n <Box component=\"span\" sx={{ fontSize: \"10px\", fontWeight: 700 }}>\n {badge.label}\n </Box>\n {(badge.side === \"left\" || badge.isOrphan) && (\n <Box\n component=\"span\"\n sx={{\n fontSize: \"10px\",\n pl: 0.5,\n ml: 0.5,\n borderLeft: `1px solid ${badge.style?.badgeBorder || \"#C7D2FE\"}`,\n }}\n >\n {(badge.score != null && badge.score !== \"N/A\" && badge.score !== \"NA\" && badge.score !== 0)\n ? `${badge.score}`\n : (badge.score === \"N/A\" || badge.score === \"NA\")\n ? \"N/A\"\n : \"Same\"}\n </Box>\n )}\n </Box>\n\n {(badge.side === \"left\" || badge.isOrphan) && (\n <Box\n onClick={(e) => {\n e.stopPropagation();\n if (badge.onClick) badge.onClick(e);\n }}\n sx={{\n display: \"flex\",\n alignItems: \"center\",\n px: 0.5,\n borderLeft: `1px solid ${badge.style?.badgeBorder || \"#C7D2FE\"}`,\n cursor: \"pointer\",\n \"&:hover\": { bgcolor: \"rgba(0,0,0,0.06)\" },\n }}\n >\n <EllipsisVertical size={12} color={badge.style?.badgeText || \"#3730A3\"} />\n </Box>\n )}\n </Box>\n {children}\n </Box>\n );\n },\n table: ({ children }: any) => (\n <Box\n sx={{\n display: \"block\",\n width: \"100%\",\n maxWidth: \"100%\",\n minWidth: 0,\n boxSizing: \"border-box\",\n contain: \"inline-size\",\n overflowX: \"auto\",\n overflowY: \"hidden\",\n overscrollBehaviorX: \"contain\",\n WebkitOverflowScrolling: \"touch\",\n my: 1,\n }}\n >\n <Box\n component=\"table\"\n sx={{\n width: \"600px\",\n minWidth: \"600px\",\n tableLayout: \"fixed\",\n borderCollapse: \"collapse\",\n fontSize: \"inherit\",\n }}\n >\n {children}\n </Box>\n </Box>\n ),\n thead: ({ children }: any) => <Box component=\"thead\">{children}</Box>,\n tbody: ({ children }: any) => <Box component=\"tbody\">{children}</Box>,\n tr: ({ children }: any) => <Box component=\"tr\" sx={{ borderBottom: \"1px solid #E5E7EB\" }}>{children}</Box>,\n th: ({ children }: any) => <Box component=\"th\" sx={{ border: \"1px solid #E5E7EB\", padding: \"8px\", textAlign: \"left\", verticalAlign: \"top\", fontWeight: 600, backgroundColor: \"#F9FAFB\", whiteSpace: \"normal\", wordBreak: \"break-word\", overflowWrap: \"anywhere\" }}>{children}</Box>,\n td: ({ children }: any) => <Box component=\"td\" sx={{ border: \"1px solid #E5E7EB\", padding: \"8px\", verticalAlign: \"top\", whiteSpace: \"normal\", wordBreak: \"break-word\", overflowWrap: \"anywhere\" }}>{children}</Box>,\n code: ({ children }: any) => <span style={{ fontFamily: \"inherit\", fontSize: \"inherit\" }}>{children}</span>,\n pre: ({ children }: any) => <span style={{ fontFamily: \"inherit\", fontSize: \"inherit\", display: \"block\", whiteSpace: \"pre-wrap\" }}>{children}</span>,\n updated: ({ children }: any) => <>{children}</>,\n\n deleted: ({ children }: any) => {\n const updatedChildren = mapChildrenDeep(children, (el) => React.cloneElement(el, { \"data-is-suggested-deviation-fix\": \"true\" }));\n return <span style={{ boxShadow: \"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444\", backgroundColor: \"#FCCCCC\", textDecoration: \"line-through\" }}>{updatedChildren}</span>;\n },\n\n changed: ({ children }: any) => {\n const updatedChildren = mapChildrenDeep(children, (el) => React.cloneElement(el, { \"data-is-suggested-deviation-fix\": \"true\" }));\n return <span style={{ boxShadow: \"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF\", backgroundColor: \"#D5E8FF\" }}>{updatedChildren}</span>;\n },\n\n ul: ({ children, ...props }: any) => <Box component=\"ul\" sx={{ mt: 1, mb: 1, pl: 3, listStyleType: \"disc\" }} {...props}>{children}</Box>,\n ol: ({ children, ...props }: any) => <Box component=\"ol\" sx={{ mt: 1, mb: 1, pl: 3, listStyleType: \"decimal\" }} {...props}>{children}</Box>,\n li: ({ children, ...props }: any) => <Box component=\"li\" sx={{ mb: 0.5, display: \"list-item\" }} {...props}>{children}</Box>,\n }),\n []\n );\n\n const normalizeMarkdownText = (rawText: string): string => {\n if (!rawText || typeof rawText !== \"string\") return \"\";\n\n let text = rawText;\n\n // This converts `<updated><changed> * text` into `* <updated><changed>text to show bullet points in change_history as well`\n text = text.replace(/((?:<\\/?[a-z]+[^>]*>\\s*)+)([*+\\-] |\\d+\\. )/gi, \"$2$1\");\n\n text = text\n .replace(/\\\\(['\"])/g, \"$1\")\n .replace(/\\\\n/g, \"\\n\")\n .replace(/\\\\\\./g, \".\") \n .replace(/\\r\\n/g, \"\\n\");\n \n text = text.replace(/^(\\d+\\.)(\\s{2,})/gm, (_, num, spaces) => `${num.slice(0, -1)}\\\\.${spaces}`);\n text = text.replace(/^(\\d+\\.)\\s*\\n+(\\s+)(\\S)/gm, (_, marker, _indent, firstChar) => `${marker} ${firstChar}`);\n text = text.replace(/([^\\n])\\n(#{1,6} )/g, \"$1\\n\\n$2\");\n \n // Check for blank line before assign bullets\n text = text.replace(/([^\\n])\\n([ \\t]*(?:[#*+\\-] |\\d+\\. ))/g, \"$1\\n\\n$2\");\n\n text = text.replace(/\\n{3,}/g, \"\\n\\n\");\n\n // This protects the indentation required for markdown lists.\n text = text.replace(/^[ \\t]+(?![ \\t]*([\\*\\-\\+] |\\d+\\. ))/gm, (match) => {\n return match.replace(/ /g, \"\\u00A0\").replace(/\\t/g, \"\\u00A0\\u00A0\\u00A0\\u00A0\");\n });\n\n const parts = text.split(/(\\n{2,})/);\n text = parts.map((chunk) => {\n if (/^\\n+$/.test(chunk)) return chunk;\n if (/\\|.*\\|/.test(chunk) && /\\|[\\s:|-]+\\|/.test(chunk)) return chunk;\n if (/^#{1,6} /.test(chunk.trimStart())) return chunk;\n \n return chunk.replace(/\\n(?=[^\\n])/g, (_, offset) => {\n const remainingLine = chunk.slice(offset + 1);\n // If it is a bullet/number/table/heading, DO NOT collapse the newline\n const isStructural = /^[ \\t]*([#>|\\-*+]|\\d+\\.)/.test(remainingLine);\n return isStructural ? \"\\n\" : \" \";\n });\n }).join(\"\");\n\n // CRITICAL: Removed the duplicate `text = text.replace(/^[ \\t]+/gm...)` block from here!\n\n return text.trim();\n };\n\n const normalizePunctuationForMatch = (text: string) => text.replace(/[\\.,;:]/g, \" \");\n\n const collisionDependency = useMemo(() => deviationBadges.map((badge) => ({\n id: badge.id,\n connected: badge.isConnected,\n stackIndex: badge.stackIndex,\n size: badge.size,\n })), [deviationBadges]);\n\n const buildMarkOpen = (badgeId: string = \"\", color?: string) => {\n const colorAttr = color ? ` data-highlight-color=\"${color}\"` : \"\";\n const badgeAttr = badgeId ? ` data-badge-id=\"${badgeId}\"` : \"\";\n return `<mark${badgeAttr}${colorAttr}>`;\n };\n \n const buildMarkClose = () => `</mark>`;\n const buildSpanOpen = (badgeId: string) => `<span data-badge-id=\"${badgeId}\">`;\n const buildSpanClose = () => `</span>`;\n\n const wrapWithMark = (value: string, badgeId: string = \"\", highlightColor?: string) => {\n const match = value.match(/^(\\s*)([\\s\\S]*?)(\\s*)$/);\n if (!match) return value;\n const leading = match[1] ?? \"\";\n const body = match[2] ?? \"\";\n const trailing = match[3] ?? \"\";\n if (!body) return value;\n return leading + buildMarkOpen(badgeId, highlightColor) + body + buildMarkClose() + trailing;\n };\n\n const contentToRender = useMemo(() => {\n // 2. CRITICAL: Removed safeStringify here. Pure strings only to prevent encoded brackets.\n let normalizedContent = normalizeMarkdownText(content || \"\");\n\n const matchContent = suppressHighlightBg ? normalizePunctuationForMatch(normalizedContent) : normalizedContent;\n\n const badgeEntries = (deviationBadges || [])\n .map((badge: any) => ({\n id: badge?.id,\n highlight: normalizeMarkdownText(badge?.highlight || \"\"),\n highlightColor: badge?.style?.highlightBg || badge?.style?.badgeBg || highlightBg,\n }))\n .filter((entry: any) => entry.id && entry.highlight);\n\n const groupedBadges: Record<string, any[]> = {};\n badgeEntries.forEach((entry) => {\n if (!groupedBadges[entry.highlight]) groupedBadges[entry.highlight] = [];\n groupedBadges[entry.highlight].push(entry);\n });\n\n const createMarkedHighlight = (text: string, badgeId: string = \"\", highlightColor?: string, badges: any[] = []) => {\n let spanEmitted = false;\n\n const wrapSegment = (segment: string): string => {\n const mark = wrapWithMark(segment, badgeId, highlightColor);\n let wrapped = mark;\n \n if (!spanEmitted && badges.length > 0) {\n spanEmitted = true;\n let spansOpen = \"\";\n let spansClose = \"\";\n \n // Emit spans for ALL badges in the group, not just badges[0]\n badges.forEach((b) => {\n spansOpen += buildSpanOpen(b.id);\n spansClose = buildSpanClose() + spansClose;\n });\n \n wrapped = spansOpen + mark + spansClose;\n }\n \n return \"\\u200B\" + wrapped;\n };\n\n return text\n .split(/(\\n+)/)\n .map((part) => {\n if (/^\\n+$/.test(part)) return part;\n if (!part.trim()) return part;\n const strippedForSeparatorCheck = part.replace(/[|:\\-\\s]/g, \"\");\n if (strippedForSeparatorCheck === \"\" && part.includes(\"-\")) return part;\n if (part.includes(\"|\")) {\n return part.split(/(\\|)/).map((cell) => {\n if (cell === \"|\" || !cell.trim()) return cell;\n return wrapSegment(cell);\n }).join(\"\");\n }\n return wrapSegment(part);\n })\n .join(\"\");\n };\n\n const allMatches: HighlightMatch[] = [];\n\n Object.entries(groupedBadges).forEach(([highlight, badges]) => {\n let idx = normalizedContent.indexOf(highlight);\n let usedLooseMatch = false;\n\n if (idx === -1 && suppressHighlightBg) {\n const matchHighlight = normalizePunctuationForMatch(highlight);\n idx = matchContent.indexOf(matchHighlight);\n if (idx !== -1) usedLooseMatch = true;\n }\n\n if (idx === -1) return;\n\n let color = badges[0].highlightColor;\n for (let i = 1; i < badges.length; i++) {\n color = mixHexColors(color, badges[i].highlightColor || \"\");\n }\n\n allMatches.push({ highlight, start: idx, end: idx + highlight.length, badges, color, usedLooseMatch });\n });\n\n const badgeHighlightSet = new Set(Object.keys(groupedBadges));\n\n (highlights || []).forEach((highlight) => {\n if (!highlight) return;\n const cleanHighlight = normalizeMarkdownText(highlight);\n if (!cleanHighlight || badgeHighlightSet.has(cleanHighlight)) return;\n\n let idx = normalizedContent.indexOf(cleanHighlight);\n let usedLooseMatch = false;\n\n if (idx === -1 && suppressHighlightBg) {\n const matchHighlight = normalizePunctuationForMatch(cleanHighlight);\n idx = matchContent.indexOf(matchHighlight);\n if (idx !== -1) usedLooseMatch = true;\n }\n\n if (idx === -1) return;\n\n const before = normalizedContent.slice(0, idx);\n const openTags = (before.match(/</g) || []).length;\n const closeTags = (before.match(/>/g) || []).length;\n \n if (openTags === closeTags) {\n allMatches.push({\n highlight: cleanHighlight, start: idx, end: idx + cleanHighlight.length, badges: [], color: highlightBg || \"\", usedLooseMatch,\n } as unknown as HighlightMatch);\n }\n });\n\n allMatches.sort((a, b) => a.start - b.start || b.end - a.end);\n\n const claimedRanges: Array<{ start: number; end: number; matchIdx: number }> = [];\n const containedBy: Record<number, number> = {};\n\n allMatches.forEach((match, i) => {\n let start = match.start;\n let end = match.end;\n\n for (const claimed of claimedRanges) {\n const cStart = claimed.start;\n const cEnd = claimed.end;\n const fullyContained = start >= cStart && end <= cEnd;\n const partialOverlapRight = start < cEnd && end > cEnd && start >= cStart;\n const partialOverlapLeft = start < cStart && end > cStart && end <= cEnd;\n\n if (fullyContained) {\n match.orphaned = true;\n containedBy[i] = claimed.matchIdx;\n break;\n }\n if (partialOverlapRight) start = cEnd;\n if (partialOverlapLeft) end = cStart;\n }\n\n match.trimmedStart = start;\n match.trimmedEnd = end;\n\n if (!match.orphaned && start < end) {\n claimedRanges.push({ start, end, matchIdx: i });\n }\n });\n\n const childrenOf: Record<number, number[]> = {};\n Object.entries(containedBy).forEach(([childIdxStr, parentIdx]) => {\n const childIdx = Number(childIdxStr);\n if (!childrenOf[parentIdx]) childrenOf[parentIdx] = [];\n childrenOf[parentIdx].push(childIdx);\n });\n\n const injectChildren = (highlightText: string, parentAbsStart: number, childIndices: number[], parentColor: string) => {\n if (!childIndices.length) return highlightText;\n const children = childIndices.map((ci) => allMatches[ci]).sort((a, b) => a.start - b.start);\n let result = \"\";\n let cursor = 0;\n\n children.forEach((child) => {\n const relStart = Math.max(cursor, child.start - parentAbsStart);\n const relEnd = Math.max(relStart, child.end - parentAbsStart);\n if (relStart >= relEnd) return;\n\n const mixedColor = mixHexColors(parentColor, child.color || \"\");\n result += highlightText.slice(cursor, relStart);\n\n // Removed the redundant wrapperStart/wrapperEnd logic.\n // createMarkedHighlight now handles the spans natively and cleanly.\n result += createMarkedHighlight(\n highlightText.slice(relStart, relEnd), \n child.badges?.[0]?.id || \"\", \n mixedColor, \n child.badges || []\n );\n \n cursor = relEnd;\n });\n\n result += highlightText.slice(cursor);\n return result;\n };\n\n const finalMatches = allMatches.map((m, i) => ({ ...m, idx: i })).filter((m) => !m.orphaned).sort((a, b) => (b.trimmedStart ?? b.start) - (a.trimmedStart ?? a.start));\n\n finalMatches.forEach((match) => {\n const tStart = match.trimmedStart ?? match.start;\n const tEnd = match.trimmedEnd ?? match.end;\n if (tStart >= tEnd) return;\n\n const rawSlice = normalizedContent.slice(tStart, tEnd);\n const effectiveHighlight = match.usedLooseMatch || tStart !== match.start || tEnd !== match.end ? rawSlice : match.highlight;\n const withChildren = injectChildren(effectiveHighlight, match.start, childrenOf[match.idx!] || [], match.color);\n const markedText = createMarkedHighlight(withChildren, match.badges?.[0]?.id || \"\", match.color, match.badges || []);\n\n normalizedContent = normalizedContent.slice(0, tStart) + markedText + normalizedContent.slice(tEnd);\n });\n\n return normalizedContent;\n }, [content, deviationBadges, highlights, highlightBg, suppressHighlightBg]);\n\n const overlayContentToRender = useMemo(() => {\n if (!overlayContent) return \"\";\n return normalizeMarkdownText(overlayContent || \"\");\n }, [overlayContent]);\n\n const hasOverlay = !!overlayContent;\n\n const sharedContentSx = {\n \"& *\": { fontFamily: \"inherit\" },\n \"& code, & pre, & kbd, & samp\": {\n fontFamily: \"inherit !important\",\n fontSize: \"inherit\",\n background: \"none\",\n padding: 0,\n border: \"none\",\n whiteSpace: \"pre-wrap\",\n },\n \"& p, & li, & ul, & ol\": { position: \"static\", overflow: \"visible\", whiteSpace: \"pre-wrap\" },\n };\n\n const baseSx = { ...sxStyles, ...sharedContentSx, position: \"relative\", width: \"100%\", maxWidth: \"100%\", minWidth: 0, boxSizing: \"border-box\", overflow: \"visible\", whiteSpace: \"normal\", gridArea: \"1 / 1\", zIndex: 2, ...(hasOverlay ? {\n color: \"transparent\",\n userSelect: \"none\", \n pointerEvents: \"none\", \n \"& .deviation-badge\": { pointerEvents: \"auto\" },\n \"& table\": { visibility: \"hidden\", margin: \"0 !important\" },\n \"& th, & td\": { padding: \"0 !important\", border: \"none !important\", backgroundColor: \"transparent !important\" },\n \"& tr\": { border: \"none !important\" },\n \"& p:empty\": { display: \"none\" }\n } : {})\n };\n\n const overlaySx = { ...sxStyles, ...sharedContentSx, position: \"relative\", width: \"100%\", maxWidth: \"100%\", minWidth: 0, boxSizing: \"border-box\", overflow: \"visible\", whiteSpace: \"normal\", gridArea: \"1 / 1\", zIndex: 1, pointerEvents: \"auto\" };\n\n useLayoutEffect(() => {\n if (!containerRef.current) return;\n\n const resolveCollisions = () => {\n const badges = Array.from(\n containerRef.current!.querySelectorAll(\".deviation-badge\")\n ) as HTMLElement[];\n \n if (badges.length === 0) return;\n\n badges.forEach((b) => { b.style.setProperty(\"--badge-nudge\", \"0px\"); });\n\n const leftBadges = badges.filter((b) => b.dataset.side === \"left\");\n const rightBadges = badges.filter((b) => b.dataset.side !== \"left\");\n\n const containerRect = containerRef.current!.getBoundingClientRect();\n const maxBottom = containerRect.bottom - 4;\n const minTop = containerRect.top + 4;\n\n const applyPushDownAndClamp = (sideBadges: HTMLElement[]) => {\n if (sideBadges.length === 0) return;\n\n const metrics = sideBadges.map((el) => {\n const rect = el.getBoundingClientRect();\n return { \n el, \n naturalTop: rect.top, \n height: rect.height,\n currentTop: rect.top\n };\n });\n\n metrics.sort((a, b) => a.naturalTop - b.naturalTop);\n\n const MIN_GAP = 8;\n const clusters: typeof metrics[] = [];\n let currentCluster: typeof metrics = [];\n\n metrics.forEach((item) => {\n if (currentCluster.length === 0) {\n currentCluster.push(item);\n } else {\n const prev = currentCluster[currentCluster.length - 1];\n const prevBottom = prev.currentTop + prev.height;\n\n if (item.naturalTop < prevBottom + MIN_GAP) {\n item.currentTop = prevBottom + MIN_GAP;\n currentCluster.push(item);\n } else {\n clusters.push(currentCluster);\n currentCluster = [item];\n }\n }\n });\n if (currentCluster.length > 0) clusters.push(currentCluster);\n\n clusters.forEach((cluster) => {\n const lastItem = cluster[cluster.length - 1];\n const clusterBottom = lastItem.currentTop + lastItem.height;\n\n if (clusterBottom > maxBottom) {\n const overflowAmount = clusterBottom - maxBottom;\n\n const firstItem = cluster[0];\n const availableTopSpace = firstItem.currentTop - minTop;\n \n const actualShiftUp = Math.max(0, Math.min(overflowAmount, availableTopSpace));\n\n cluster.forEach((item) => {\n item.currentTop -= actualShiftUp;\n });\n }\n });\n\n clusters.flat().forEach((item) => {\n const nudge = item.currentTop - item.naturalTop;\n item.el.style.setProperty(\"--badge-nudge\", `${nudge}px`);\n });\n };\n\n applyPushDownAndClamp(leftBadges);\n applyPushDownAndClamp(rightBadges);\n };\n\n const raf1 = requestAnimationFrame(()=>{\n requestAnimationFrame(()=>{\n resolveCollisions();\n })\n });\n\n const resizeObserver = new ResizeObserver(() => {\n requestAnimationFrame(resolveCollisions);\n });\n resizeObserver.observe(containerRef.current);\n\n return () => {\n resizeObserver.disconnect();\n cancelAnimationFrame(raf1);\n }\n }, [contentToRender, collisionKey, collisionDependency]);\n\n return (\n <Box\n ref={containerRef}\n sx={{\n position: \"relative\",\n display: \"grid\",\n gridTemplateColumns: \"minmax(0, 1fr)\",\n width: \"100%\",\n maxWidth: \"100%\",\n minWidth: 0,\n }}\n >\n <Typography component=\"div\" sx={{ ...baseSx, padding: \"3px\" }}>\n <ReactMarkdown\n components={components}\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n >\n {/* 4. Removed safeStringify wrapper! It encodes < to < */}\n {contentToRender.replace(/#{3}/g, \"\")}\n </ReactMarkdown>\n </Typography>\n\n {hasOverlay && (\n <Typography component=\"div\" sx={overlaySx}>\n <ReactMarkdown\n components={components}\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n >\n {overlayContentToRender}\n </ReactMarkdown>\n </Typography>\n )}\n </Box>\n );\n },\n areMarkdownPropsEqual\n);"],"names":["resolvePlugin","plugin","default","remarkPlugins","rehypePlugins","rehypeRaw","MemoizedMarkdown","React","memo","content","overlayContent","sxStyles","deviationBadges","highlights","maintainRelativeOrder","highlightBg","suppressHighlightBg","collisionKey","containerRef","useRef","hideHighlightBg","badgeMap","useMemo","reduce","acc","badge","id","dynamicPropsRef","current","mapChildrenDeep","children","transform","Children","map","child","isValidElement","newChildren","props","cloned","cloneElement","components","mark","badgeId","bg","style","badgeBg","shouldHideBg","jsx","backgroundColor","borderRadius","display","boxDecorationBreak","WebkitBoxDecorationBreak","backgroundClip","padding","color","span","stackIndex","translateY","jsxs","Box","component","sx","position","ref","badgeRef","className","side","fontStyle","zIndex","alignItems","fontSize","bgcolor","badgeText","DEFAULT_DEVIAION_COLOR","border","badgeBorder","fontWeight","whiteSpace","boxShadow","overflow","transition","right","left","isConnected","outline","outlineOffset","onClick","e","stopPropagation","onSummaryClick","px","py","cursor","label","isOrphan","pl","ml","borderLeft","score","EllipsisVertical","size","table","width","maxWidth","minWidth","boxSizing","contain","overflowX","overflowY","overscrollBehaviorX","WebkitOverflowScrolling","my","tableLayout","borderCollapse","thead","tbody","tr","borderBottom","th","textAlign","verticalAlign","wordBreak","overflowWrap","td","code","fontFamily","pre","updated","deleted","updatedChildren","el","textDecoration","changed","ul","mt","mb","listStyleType","ol","li","normalizeMarkdownText","rawText","text","replace","_","num","spaces","slice","marker","_indent","firstChar","match","parts","split","chunk","test","trimStart","offset","remainingLine","join","trim","normalizePunctuationForMatch","collisionDependency","connected","contentToRender","normalizedContent","matchContent","badgeEntries","highlight","highlightColor","filter","entry","groupedBadges","forEach","push","createMarkedHighlight","badges","spanEmitted","wrapSegment","segment","value","leading","body","trailing","buildMarkOpen","wrapWithMark","wrapped","length","spansOpen","spansClose","b","buildSpanOpen","part","includes","cell","allMatches","Object","entries","idx","indexOf","usedLooseMatch","matchHighlight","i","mixHexColors","start","end","badgeHighlightSet","Set","keys","cleanHighlight","has","before","sort","a","claimedRanges","containedBy","claimed","cStart","cEnd","partialOverlapRight","partialOverlapLeft","orphaned","matchIdx","trimmedStart","trimmedEnd","childrenOf","childIdxStr","parentIdx","childIdx","Number","m","tStart","tEnd","rawSlice","withChildren","highlightText","parentAbsStart","childIndices","parentColor","ci","result","relStart","Math","max","relEnd","mixedColor","injectChildren","markedText","overlayContentToRender","hasOverlay","sharedContentSx","background","baseSx","gridArea","userSelect","pointerEvents","visibility","margin","overlaySx","useLayoutEffect","resolveCollisions","Array","from","querySelectorAll","setProperty","leftBadges","dataset","rightBadges","containerRect","getBoundingClientRect","maxBottom","bottom","minTop","top","applyPushDownAndClamp","sideBadges","metrics","rect","naturalTop","height","currentTop","clusters","currentCluster","item","prev","prevBottom","cluster","lastItem","clusterBottom","overflowAmount","availableTopSpace","actualShiftUp","min","flat","nudge","raf1","requestAnimationFrame","resizeObserver","ResizeObserver","observe","disconnect","cancelAnimationFrame","gridTemplateColumns","Typography","ReactMarkdown","areMarkdownPropsEqual"],"mappings":"obAWA,MAAMA,EAAiBC,GAAkC,mBAAXA,EAAwBA,EAASA,GAAQC,SAAWD,EAC5FE,EAAgB,CAACH,OAAuB,UACxCI,EAAgB,CAACJ,EAAcK,EAAS,UAGjCC,EAAmBC,EAAM,QAAAC,KAAK,EACzCC,UACAC,iBACAC,WACAC,kBAAkB,GAClBC,aAAa,GACbC,yBAAwB,EACxBC,cACAC,uBAAsB,EACtBC,mBAYM,MAAAC,EAAeC,SAAuB,MACtCC,IAAoBV,EAEpBW,EAAWC,EAAAA,QACf,IAAMV,EAAgBW,OAAO,CAACC,EAAKC,SAAgBD,EAAK,CAACC,EAAMC,IAAKD,IAAU,CAAA,GAC9E,CAACb,IAGGe,EAAkBR,EAAAA,OAAO,CAAEE,WAAUN,cAAaK,kBAAiBJ,wBACzEW,EAAgBC,QAAU,CAAEP,WAAUN,cAAaK,kBAAiBJ,uBAE9D,MAAAa,EAAkB,CACtBC,EACAC,IAEOxB,EAAM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lB,EAAW,CAC7B,MAAMmB,EAAiBD,EAAgBlB,EAGjCoB,EADYJ,EAAQ,GACUN,WAAaR,EAE3CmB,EAAgBjD,KAAKC,IAAI,EAAGD,KAAKkD,IAAIH,EAAgBC,IAEnDJ,EAAAjH,QAAS8G,IACfA,EAAKH,YAAcW,GAEvB,IAGFV,EAASY,OAAOxH,QAAS8G,IACjB,MAAAW,EAAQX,EAAKH,WAAaG,EAAKL,WACrCK,EAAKxJ,GAAGvF,MAAM4N,YAAY,gBAAiB,GAAG8B,UAIlDpB,EAAsBT,GACtBS,EAAsBP,IAGlB4B,EAAOC,sBAAsB,KACjCA,sBAAsB,KACFpC,QAIhBqC,EAAiB,IAAIC,eAAe,KACxCF,sBAAsBpC,KAIxB,OAFeqC,EAAAE,QAAQzR,EAAaU,SAE7B,KACL6Q,EAAeG,aACfC,qBAAqBN,KAEtB,CAACnI,EAAiBnJ,EAAciJ,IAG/BvG,EAAAA,KAACC,EAAAA,IAAA,CACCI,IAAK9C,EACL4C,GAAI,CACFC,SAAU,WACVb,QAAS,OACT4P,oBAAqB,iBACrBvM,MAAO,OACPC,SAAU,OACVC,SAAU,GAGZ3E,SAAA,CAACiB,EAAAA,IAAAgQ,EAAAA,WAAA,CAAWlP,UAAU,MAAMC,GAAI,IAAK8L,EAAQtM,QAAS,OACpDxB,SAAAiB,EAAAA,IAACiQ,EAAA,QAAA,CACCxQ,aACArC,gBACAC,gBAGC0B,SAAAsI,EAAgBrB,QAAQ,QAAS,QAIrC0G,GACE1M,EAAAA,IAAAgQ,EAAAA,WAAA,CAAWlP,UAAU,MAAMC,GAAIoM,EAC9BpO,SAAAiB,EAAAA,IAACiQ,EAAA,QAAA,CACCxQ,aACArC,gBACAC,gBAEC0B,SAAA0N,UAObyD,EAAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../CognitiveComparehelpers.js"),n=require("../utils/buildComparisonRows.js");const i={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=(s,o,r,a,d=!0,c,l)=>{const u="string"==typeof r?r:JSON.stringify(r||{}),f=l??Boolean("string"==typeof c?c.trim():c&&(c.learnings_data||c.data?.artifactData?.userStorySnapshot)),{activeProposed:p,activeVariants:v,comparisonRows:I,parseError:_}=e.useMemo(()=>{if(!s||0===Object.keys(s).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};const e=JSON.parse(u);try{const i=s.nodes||s;let r=[],a=[],l=[];const u=s.base_root_id,p=s.input_index_map||{0:"left",1:"right"},v=s[u]||i[u];if(!v||!1===v.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};const I=s.content_mapping||{},_=e=>s[e]||i[e],g=(e,n,i)=>{if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(d)return e;const s=Object.keys(e).filter(e=>/^\d+$/.test(e));if(!s.length)return e;const o=s.sort((e,t)=>Number(e)-Number(t)),r={},a={};let c=null;return o.forEach(s=>{const o=e[s];if(!o||"object"!=typeof o)return;c||(c=o);const d="same"===t.safeStringify(o?.evaluation_outputs?.output_value).trim().toLowerCase(),l=!(o?.status&&"pending"!==o.status||d),u=o?.deviation_highlight||o?.web_search_answer?.deviation_highlight,f=e=>{const t=o?.cognitive_decisioning?.citations||o?.citations||{};return Object.values(t).map(t=>t?.[e]?.highlighted_text).filter(e=>"string"==typeof e&&e.trim().length>0)},v=(...e)=>{for(const n of e)if(Array.isArray(n)&&n.some(e=>!t.isMissingStr(e)))return n;return[]},I=l?v(o?.deviation_highlights?.[n]||o?.deviation_highlights?.[p[0]],"string"==typeof u?[u]:[],f(n),f(p[0])):[],_=l?v(o?.deviation_highlights?.[i]||o?.deviation_highlights?.[p[1]],f(i),f(p[1])):[];r[s]={[p[0]]:I[0]||"",[p[1]]:_[0]||"",deviation_summary:o?.deviation_summary||"",deviation_title:o?.deviation_title,deviation_impact:o?.deviation_impact,deviation_explanation:o?.deviation_explanation,evaluation_outputs:o?.evaluation_outputs,cognitive_decisioning:o?.cognitive_decisioning,deviation_highlights:o?.deviation_highlights},a[s]=o}),{...e,deviation_title:c?.deviation_title||e?.deviation_title,deviation_impact:c?.deviation_impact||e?.deviation_impact,deviation_summary:c?.deviation_summary||e?.deviation_summary,deviation_explanation:c?.deviation_explanation||e?.deviation_explanation,evaluation_outputs:c?.evaluation_outputs||e?.evaluation_outputs,cognitive_decisioning:c?.cognitive_decisioning||e?.cognitive_decisioning,deviations:r,deviation_entries:a}},h=e=>{const t=new Map,n=e=>{e.forEach(e=>{e.id&&t.set(e.id,e),e.subsections?.length&&n(e.subsections)})};n(e);const i=(e,n)=>{let s=[];for(const o of e){const e=o.ref_parent_section_node_id;if(e&&t.has(e)&&e!==n?.id){const n=t.get(e);n.subsections||(n.subsections=[]),n.subsections.some(e=>e.id===o.id)||n.subsections.push(o)}else o.subsections?.length&&(o.subsections=i(o.subsections,o)),s.push(o)}return s},s=i(e),o=e=>{e.forEach(e=>{e.subsections&&e.subsections.length>0&&(e.subsections.sort((e,t)=>e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:(e.selfIndex||0)-(t.selfIndex||0)),o(e.subsections))})};return o(s),s},m=e=>{const t=e.comparison_inputs?Object.keys(e.comparison_inputs):[];let n=p[0],i=p[1];return t.length>0&&(n=t.includes(p[0])?p[0]:t[0],i=t.includes(p[1])?p[1]:t.length>1?t[1]:t[0]),{nodeLeftId:n,nodeRightId:i}},x=e=>e?.entity_id||e?.ref_parent_section_node_id||e?.parent_entity_id||null,b=(e,n,i,s)=>{const o=n.attributes||{},r=n.data||{},a=!1!==o.display_title,d=!1!==o.display_content,c=a?t.safeStringify(r.title||""):"",l=d?t.safeStringify(r.content||""):"",u=d?t.safeStringify(r.change_history||""):"",f=void 0!==o.display_index&&null!==o.display_index?Number(o.display_index):-1,p=x(o),v=!(!c.trim()&&!l.trim());return{id:`${e}::${n.contentId}`,nodeId:e,contentId:n.contentId,parentContentId:p,title:c,content:l,change_history:u,displayTitle:a,displayContent:d,subsections:[],...v?s:{score:void 0,relation:"not_defined"},evaluationResult:i,evaluationResults:i?[i]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p}},y=(e,t)=>{e.refIndexes=Array.from(new Set([...e.refIndexes||[],...t.refIndexes||[]])),e.refContentIds=Array.from(new Set([...e.refContentIds||[],...t.refContentIds||[]]));const n=new Set((e.subsections||[]).map(e=>e.id||e.contentId||e.nodeId));(t.subsections||[]).forEach(t=>{const i=t.id||t.contentId||t.nodeId;n.has(i)||(e.subsections=[...e.subsections||[],t],n.add(i))});const i=[...e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),...t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[])].filter(Boolean),s=new Set;return e.evaluationResults=i.filter(e=>{const t=e?.nodeId||JSON.stringify(Object.keys(e?.deviations||e||{}));return!s.has(t)&&(s.add(t),!0)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},R=(e,t)=>e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:e.selfIndex-t.selfIndex,C=(n,i)=>{const s=_(n);if(!s||!1===s.display_node)return[];if(f&&"1"===i)return[];const{nodeLeftId:o,nodeRightId:r}=m(s),a=t.getRationale(s),d=e?.[n]?.evaluation_result||s.evaluation_result||null,c=g(d,o,r),l=c&&"object"==typeof c?{...c,nodeId:n}:c,u=t.resolveComparisonInputItems(s,i,p,I).map(e=>b(n,e,l,a));if(s.next){const e=Object.values(s.next).flatMap(e=>C(e,i));u.forEach(t=>{const n=e.filter(e=>!e.parentContentId||e.parentContentId===t.contentId||e.parentContentId===t.parentContentId);t.subsections=n.length?n:e})}return u};if(o){const n=(i,s=0)=>{let o=[],r=[];if(!i)return{refSections:o,baseSections:r};const a={},d={};let c=-1,l=-1;for(const o in i){const r=i[o],u=_(r);if(!u||!1===u.display_node)continue;const{nodeLeftId:v,nodeRightId:h}=m(u),x=t.getRationale(u),R=e?.[r]?.evaluation_result||u.evaluation_result||null,C=g(R,v,h),S=C&&"object"==typeof C?{...C,nodeId:r}:C,{refSections:E,baseSections:O}=n(u.next,s+1),j=t.resolveComparisonInputItems(u,"0",p,I).map(e=>{const t=b(r,e,S,x);return-1===t.selfIndex&&(t.selfIndex=l--),t});let N=[];if(!f){const e=t.resolveComparisonInputItems(u,"1",p,I);N=e.map(e=>{const t=b(r,e,S,x);return-1===t.selfIndex&&(t.selfIndex=c--),t})}j.forEach(e=>{N.forEach(t=>{Number(t.selfIndex)>=0&&Number(e.selfIndex)>=0&&(t.refIndexes?.includes(Number(e.selfIndex))||t.refIndexes?.push(Number(e.selfIndex)),e.refIndexes?.includes(Number(t.selfIndex))||e.refIndexes?.push(Number(t.selfIndex))),e.contentId&&!t.refContentIds?.includes(e.contentId)&&t.refContentIds?.push(e.contentId),t.contentId&&!e.refContentIds?.includes(t.contentId)&&e.refContentIds?.push(t.contentId)})}),N.forEach(e=>{const t=E.filter(t=>!t.parentContentId||t.parentContentId===e.contentId||t.parentContentId===e.parentContentId||e.refContentIds?.includes(t.parentContentId));t.length>0&&(e.subsections=t);const n=0===s?String(e.selfIndex):`${e.selfIndex}_${e.contentId||r}`;a[n]=a[n]?y(a[n],e):e}),j.forEach(e=>{const t=O.filter(t=>!t.parentContentId||t.parentContentId===e.contentId||t.parentContentId===e.parentContentId||e.refContentIds?.includes(t.parentContentId));t.length>0&&(e.subsections=t);const n=0===s?String(e.selfIndex):`${e.selfIndex}_${e.contentId||r}`;d[n]=d[n]?y(d[n],e):e})}return o=Object.values(a),r=Object.values(d),o.sort(R),r.sort(R),{refSections:o,baseSections:r}},{refSections:i,baseSections:s}=n(v.next);f||(a=h(i)),r=s}else v.next&&Object.values(v.next).forEach(e=>{const t=_(e);if(!t||!1===t.display_node)return;const i=C(e,"0");if(f)return void r.push(...i);const s=h(C(e,"1"));l.push(...n.buildComparisonRows(e,i,s))}),f||(r=l.map(e=>e.left),a=l.map(e=>e.right));const S=t.getSideData(v,"0",p,I),E=t.getSideData(v,"1",p,I),O={title:S.title||"Uploaded Contract",description:v.decision_scope_description||"",sections:r};return{activeProposed:O,activeVariants:[{id:"tree-variant-1",title:f?(()=>{if("string"!=typeof c&&c?.learnings_data&&Object.keys(c.learnings_data).length>0){const e=Object.keys(c.learnings_data)[0];return c.learnings_data[e]?.title||"Rulebook Guidelines"}return"string"!=typeof c&&c?.data?.artifactTitle||"Rulebook Guidelines"})():E.title||"Reference Template",similarity:0,sections:a,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:v.decision_scope_description||""},fields:{}}}}],comparisonRows:l,parseError:null}}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}},[s,o,u,d,c,f]),g=v?.[0]||i,h=e.useMemo(()=>p?.sections||[],[p?.sections]),m=e.useMemo(()=>g.sections||[],[g.sections]),x=h.length>0||m.length>0,b=e.useMemo(()=>a.fields.filter(({key:e})=>(!x||"description"!==e)&&(t.hasValue(p?.[e])||t.hasValue(g[e]))),[p,g,x,a.fields]),{parentDeviationRecord:y,registry:R,deviationParentRegistry:C}=e.useMemo(()=>{const e={},n={},i={};let r=0;const a=s?.input_index_map?.[0],d=s?.input_index_map?.[1],c=(e,t)=>{if(!o){const n="left"===t?h.indexOf(e):m.indexOf(e);return{rootKey:`${t}:${n}`,parentNum:n+1}}if("left"===t){const t=e.selfIndex,n=void 0!==t&&t>=0?t+1:h.indexOf(e)+1;return{rootKey:`left-root:${e.id}`,parentNum:n}}const n=e.selfIndex,i=h.find(e=>e.refIndexes?.includes(n));if(i){const e=i.selfIndex,t=void 0!==e&&e>=0?e+1:h.indexOf(i)+1;return{rootKey:`left-root:${i.id}`,parentNum:t}}const s=void 0!==n&&n>=0?n+1:m.indexOf(e)+1;return{rootKey:`right-orphan-root:${e.id}`,parentNum:s}},l=(e,t)=>{if(e&&t)return e.find(e=>e.id===t.id||e.nodeId&&e.nodeId===t.nodeId||e.contentId&&e.contentId===t.contentId)||void 0},u=(s,o,c,f,p,v,I)=>{if(o&&((e,s,o)=>{(e?.evaluationResults?.length?e.evaluationResults:e?.evaluationResult?[e.evaluationResult]:[]).forEach(r=>{const c=r?.deviations||{};Object.keys(c).sort().forEach(l=>{const u=c[l];if(!u)return;const f=!t.isMissingStr(u[a]),p=!t.isMissingStr(u[d]);if(f||p){const a=`${r?.nodeId||e.nodeId||e.id}${t.DEVIATION_BADGE_SEPARATOR}${l}`;void 0===n[a]&&(void 0===i[s]&&(i[s]=1),n[a]={index:i[s]++,rootKey:s,parentNum:o})}})})})(o,f,p),o&&!v){const t=I?.id||"fallback_parent_"+r++;e[t]||(e[t]=[]),e[t].push(o)}(o?.subsections||s?.subsections||c?.subsections||[]).forEach(e=>{const t=l(s?.subsections,e),n=l(c?.subsections,e);u(e,t,n,f,p,!1,o||I)})};h.forEach(e=>{const{rootKey:t,parentNum:n}=c(e,"left");let i=null;if(o){const t=e.refIndexes?.[0];i=m.find(e=>e.selfIndex===t)}else i=m[h.indexOf(e)];u(e,e,i,t,n,!0,e)}),f||m.forEach(e=>{const{rootKey:t,parentNum:n}=c(e,"right");t.startsWith("right-orphan-root:")&&u(e,null,e,t,n,!0,e)});const p=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t.index])),v=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t.parentNum]));return{parentDeviationRecord:e,registry:p,deviationParentRegistry:v}},[h,m,o,s,f]);return{isGuidelineMode:f,activeProposed:p,activeVariants:v,comparisonRows:I,existingRule:g,proposedSections:h,existingSections:m,visibleFields:b,parentDeviationRecord:y,deviationNumberRegistry:R,deviationParentRegistry:C,parseError:_}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../CognitiveComparehelpers.js"),n=require("../utils/buildComparisonRows.js");const i={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=(s,o,r,a,d=!0,c)=>{const l="string"==typeof r?r:JSON.stringify(r||{}),u=Boolean(c&&(c.learnings_data||c.data?.artifactData?.userStorySnapshot)),{activeProposed:f,activeVariants:p,comparisonRows:v,parseError:I}=e.useMemo(()=>{if(!s||0===Object.keys(s).length)return{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:"Tree data is required"};const e=JSON.parse(l);try{const i=s.nodes||s;let r=[],a=[],l=[];const f=s.base_root_id,p=s.input_index_map||{0:"left",1:"right"},v=s[f]||i[f];if(!v||!1===v.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],comparisonRows:[],parseError:null};const I=s.content_mapping||{},_=e=>s[e]||i[e],g=(e,n,i)=>{if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(d)return e;const s=Object.keys(e).filter(e=>/^\d+$/.test(e));if(!s.length)return e;const o=s.sort((e,t)=>Number(e)-Number(t)),r={},a={};let c=null;return o.forEach(s=>{const o=e[s];if(!o||"object"!=typeof o)return;c||(c=o);const d=!o?.status||"pending"===o.status,l=o?.deviation_highlight||o?.web_search_answer?.deviation_highlight,u=e=>{const t=o?.cognitive_decisioning?.citations||o?.citations||{};return Object.values(t).map(t=>t?.[e]?.highlighted_text).filter(e=>"string"==typeof e&&e.trim().length>0)},f=(...e)=>{for(const n of e)if(Array.isArray(n)&&n.some(e=>!t.isMissingStr(e)))return n;return[]},v=d?f(o?.deviation_highlights?.[n]||o?.deviation_highlights?.[p[0]],"string"==typeof l?[l]:[],u(n),u(p[0])):[],I=d?f(o?.deviation_highlights?.[i]||o?.deviation_highlights?.[p[1]],u(i),u(p[1])):[];r[s]={[p[0]]:v[0]||"",[p[1]]:I[0]||"",deviation_summary:o?.deviation_summary||"",deviation_title:o?.deviation_title,deviation_impact:o?.deviation_impact,deviation_explanation:o?.deviation_explanation,evaluation_outputs:o?.evaluation_outputs,cognitive_decisioning:o?.cognitive_decisioning,deviation_highlights:o?.deviation_highlights},a[s]=o}),{...e,deviation_title:c?.deviation_title||e?.deviation_title,deviation_impact:c?.deviation_impact||e?.deviation_impact,deviation_summary:c?.deviation_summary||e?.deviation_summary,deviation_explanation:c?.deviation_explanation||e?.deviation_explanation,evaluation_outputs:c?.evaluation_outputs||e?.evaluation_outputs,cognitive_decisioning:c?.cognitive_decisioning||e?.cognitive_decisioning,deviations:r,deviation_entries:a}},h=e=>{const t=new Map,n=e=>{e.forEach(e=>{e.id&&t.set(e.id,e),e.subsections?.length&&n(e.subsections)})};n(e);const i=(e,n)=>{let s=[];for(const o of e){const e=o.ref_parent_section_node_id;if(e&&t.has(e)&&e!==n?.id){const n=t.get(e);n.subsections||(n.subsections=[]),n.subsections.some(e=>e.id===o.id)||n.subsections.push(o)}else o.subsections?.length&&(o.subsections=i(o.subsections,o)),s.push(o)}return s},s=i(e),o=e=>{e.forEach(e=>{e.subsections&&e.subsections.length>0&&(e.subsections.sort((e,t)=>e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:(e.selfIndex||0)-(t.selfIndex||0)),o(e.subsections))})};return o(s),s},m=e=>{const t=e.comparison_inputs?Object.keys(e.comparison_inputs):[];let n=p[0],i=p[1];return t.length>0&&(n=t.includes(p[0])?p[0]:t[0],i=t.includes(p[1])?p[1]:t.length>1?t[1]:t[0]),{nodeLeftId:n,nodeRightId:i}},x=e=>e?.entity_id||e?.ref_parent_section_node_id||e?.parent_entity_id||null,b=(e,n,i,s)=>{const o=n.attributes||{},r=n.data||{},a=!1!==o.display_title,d=!1!==o.display_content,c=a?t.safeStringify(r.title||""):"",l=d?t.safeStringify(r.content||""):"",u=d?t.safeStringify(r.change_history||""):"",f=void 0!==o.display_index&&null!==o.display_index?Number(o.display_index):-1,p=x(o),v=!(!c.trim()&&!l.trim());return{id:`${e}::${n.contentId}`,nodeId:e,contentId:n.contentId,parentContentId:p,title:c,content:l,change_history:u,displayTitle:a,displayContent:d,subsections:[],...v?s:{score:void 0,relation:"not_defined"},evaluationResult:i,evaluationResults:i?[i]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p}},y=(e,t)=>{e.refIndexes=Array.from(new Set([...e.refIndexes||[],...t.refIndexes||[]])),e.refContentIds=Array.from(new Set([...e.refContentIds||[],...t.refContentIds||[]]));const n=new Set((e.subsections||[]).map(e=>e.id||e.contentId||e.nodeId));(t.subsections||[]).forEach(t=>{const i=t.id||t.contentId||t.nodeId;n.has(i)||(e.subsections=[...e.subsections||[],t],n.add(i))});const i=[...e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),...t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[])].filter(Boolean),s=new Set;return e.evaluationResults=i.filter(e=>{const t=e?.nodeId||JSON.stringify(Object.keys(e?.deviations||e||{}));return!s.has(t)&&(s.add(t),!0)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},R=(e,t)=>e.selfIndex<0&&t.selfIndex>=0?1:e.selfIndex>=0&&t.selfIndex<0?-1:e.selfIndex-t.selfIndex,C=(n,i)=>{const s=_(n);if(!s||!1===s.display_node)return[];if(u&&"1"===i)return[];const{nodeLeftId:o,nodeRightId:r}=m(s),a=t.getRationale(s),d=e?.[n]?.evaluation_result||s.evaluation_result||null,c=g(d,o,r),l=c&&"object"==typeof c?{...c,nodeId:n}:c,f=t.resolveComparisonInputItems(s,i,p,I).map(e=>b(n,e,l,a));if(s.next){const e=Object.values(s.next).flatMap(e=>C(e,i));f.forEach(t=>{const n=e.filter(e=>!e.parentContentId||e.parentContentId===t.contentId||e.parentContentId===t.parentContentId);t.subsections=n.length?n:e})}return f};if(o){const n=(i,s=0)=>{let o=[],r=[];if(!i)return{refSections:o,baseSections:r};const a={},d={};let c=-1,l=-1;for(const o in i){const r=i[o],f=_(r);if(!f||!1===f.display_node)continue;const{nodeLeftId:v,nodeRightId:h}=m(f),x=t.getRationale(f),R=e?.[r]?.evaluation_result||f.evaluation_result||null,C=g(R,v,h),S=C&&"object"==typeof C?{...C,nodeId:r}:C,{refSections:E,baseSections:O}=n(f.next,s+1),j=t.resolveComparisonInputItems(f,"0",p,I).map(e=>{const t=b(r,e,S,x);return-1===t.selfIndex&&(t.selfIndex=l--),t});let N=[];if(!u){const e=t.resolveComparisonInputItems(f,"1",p,I);N=e.map(e=>{const t=b(r,e,S,x);return-1===t.selfIndex&&(t.selfIndex=c--),t})}j.forEach(e=>{N.forEach(t=>{Number(t.selfIndex)>=0&&Number(e.selfIndex)>=0&&(t.refIndexes?.includes(Number(e.selfIndex))||t.refIndexes?.push(Number(e.selfIndex)),e.refIndexes?.includes(Number(t.selfIndex))||e.refIndexes?.push(Number(t.selfIndex))),e.contentId&&!t.refContentIds?.includes(e.contentId)&&t.refContentIds?.push(e.contentId),t.contentId&&!e.refContentIds?.includes(t.contentId)&&e.refContentIds?.push(t.contentId)})}),N.forEach(e=>{const t=E.filter(t=>!t.parentContentId||t.parentContentId===e.contentId||t.parentContentId===e.parentContentId||e.refContentIds?.includes(t.parentContentId));t.length>0&&(e.subsections=t);const n=0===s?String(e.selfIndex):`${e.selfIndex}_${e.contentId||r}`;a[n]=a[n]?y(a[n],e):e}),j.forEach(e=>{const t=O.filter(t=>!t.parentContentId||t.parentContentId===e.contentId||t.parentContentId===e.parentContentId||e.refContentIds?.includes(t.parentContentId));t.length>0&&(e.subsections=t);const n=0===s?String(e.selfIndex):`${e.selfIndex}_${e.contentId||r}`;d[n]=d[n]?y(d[n],e):e})}return o=Object.values(a),r=Object.values(d),o.sort(R),r.sort(R),{refSections:o,baseSections:r}},{refSections:i,baseSections:s}=n(v.next);u||(a=h(i)),r=s}else v.next&&Object.values(v.next).forEach(e=>{const t=_(e);if(!t||!1===t.display_node)return;const i=C(e,"0");if(u)return void r.push(...i);const s=h(C(e,"1"));l.push(...n.buildComparisonRows(e,i,s))}),u||(r=l.map(e=>e.left),a=l.map(e=>e.right));const S=t.getSideData(v,"0",p,I),E=t.getSideData(v,"1",p,I),O={title:S.title||"Uploaded Contract",description:v.decision_scope_description||"",sections:r};return{activeProposed:O,activeVariants:[{id:"tree-variant-1",title:u?(()=>{if(c?.learnings_data&&Object.keys(c.learnings_data).length>0){const e=Object.keys(c.learnings_data)[0];return c.learnings_data[e]?.title||"Rulebook Guidelines"}return c?.data?.artifactTitle||"Rulebook Guidelines"})():E.title||"Reference Template",similarity:0,sections:a,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:v.decision_scope_description||""},fields:{}}}}],comparisonRows:l,parseError:null}}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],comparisonRows:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}},[s,o,l,d,c]),_=p?.[0]||i,g=e.useMemo(()=>f?.sections||[],[f?.sections]),h=e.useMemo(()=>_.sections||[],[_.sections]),m=g.length>0||h.length>0,x=e.useMemo(()=>a.fields.filter(({key:e})=>(!m||"description"!==e)&&(t.hasValue(f?.[e])||t.hasValue(_[e]))),[f,_,m,a.fields]),{parentDeviationRecord:b,registry:y,deviationParentRegistry:R}=e.useMemo(()=>{const e={},n={},i={};let r=0;const a=s?.input_index_map?.[0],d=s?.input_index_map?.[1],c=(e,t)=>{if(!o){const n="left"===t?g.indexOf(e):h.indexOf(e);return{rootKey:`${t}:${n}`,parentNum:n+1}}if("left"===t){const t=e.selfIndex,n=void 0!==t&&t>=0?t+1:g.indexOf(e)+1;return{rootKey:`left-root:${e.id}`,parentNum:n}}const n=e.selfIndex,i=g.find(e=>e.refIndexes?.includes(n));if(i){const e=i.selfIndex,t=void 0!==e&&e>=0?e+1:g.indexOf(i)+1;return{rootKey:`left-root:${i.id}`,parentNum:t}}const s=void 0!==n&&n>=0?n+1:h.indexOf(e)+1;return{rootKey:`right-orphan-root:${e.id}`,parentNum:s}},l=(e,t)=>{if(e&&t)return e.find(e=>e.id===t.id||e.nodeId&&e.nodeId===t.nodeId||e.contentId&&e.contentId===t.contentId)||void 0},f=(s,o,c,u,p,v,I)=>{if(o&&((e,s,o)=>{(e?.evaluationResults?.length?e.evaluationResults:e?.evaluationResult?[e.evaluationResult]:[]).forEach(r=>{const c=r?.deviations||{};Object.keys(c).sort().forEach(l=>{const u=c[l];if(!u)return;const f=!t.isMissingStr(u[a]),p=!t.isMissingStr(u[d]);if(f||p){const a=`${r?.nodeId||e.nodeId||e.id}${t.DEVIATION_BADGE_SEPARATOR}${l}`;void 0===n[a]&&(void 0===i[s]&&(i[s]=1),n[a]={index:i[s]++,rootKey:s,parentNum:o})}})})})(o,u,p),o&&!v){const t=I?.id||"fallback_parent_"+r++;e[t]||(e[t]=[]),e[t].push(o)}(o?.subsections||s?.subsections||c?.subsections||[]).forEach(e=>{const t=l(s?.subsections,e),n=l(c?.subsections,e);f(e,t,n,u,p,!1,o||I)})};g.forEach(e=>{const{rootKey:t,parentNum:n}=c(e,"left");let i=null;if(o){const t=e.refIndexes?.[0];i=h.find(e=>e.selfIndex===t)}else i=h[g.indexOf(e)];f(e,e,i,t,n,!0,e)}),u||h.forEach(e=>{const{rootKey:t,parentNum:n}=c(e,"right");t.startsWith("right-orphan-root:")&&f(e,null,e,t,n,!0,e)});const p=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t.index])),v=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t.parentNum]));return{parentDeviationRecord:e,registry:p,deviationParentRegistry:v}},[g,h,o,s,u]);return{isGuidelineMode:u,activeProposed:f,activeVariants:p,comparisonRows:v,existingRule:_,proposedSections:g,existingSections:h,visibleFields:x,parentDeviationRecord:b,deviationNumberRegistry:y,deviationParentRegistry:R,parseError:I}};
|
|
2
2
|
//# sourceMappingURL=useCompareData.js.map
|