@viswa-test/test-citation 0.0.230 → 0.0.232

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +2 -0
  3. package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -0
  4. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/components/connectedLines.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  9. package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js +2 -0
  10. package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js.map +1 -0
  11. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
  12. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
  13. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
  14. package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/theme/theme.css.js +1 -1
  15. package/dist/cjs/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
  16. package/dist/cjs/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
  17. package/dist/cjs/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
  18. package/dist/cjs/features/RequirementAI/utils/helpers.js +1 -1
  19. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  20. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +2 -0
  21. package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -0
  22. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  23. package/dist/features/CognitiveCompare/components/connectedLines.js +1 -1
  24. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  25. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  26. package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
  27. package/dist/features/GptWebCitation/GptWebCitationMarkdown.js +2 -0
  28. package/dist/features/GptWebCitation/GptWebCitationMarkdown.js.map +1 -0
  29. package/dist/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
  30. package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
  31. package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
  32. package/dist/features/RequirementAI/components/RichTextEditor/Editor/theme/theme.css.js +1 -1
  33. package/dist/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
  34. package/dist/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
  35. package/dist/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
  36. package/dist/features/RequirementAI/utils/helpers.js +1 -1
  37. package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
  38. package/dist/types/src/RedlineApprovalCardTest.d.ts +1 -0
  39. package/dist/types/src/RedlineApprovalCardTest.d.ts.map +1 -0
  40. package/dist/types/src/RedlineEditorTest.d.ts.map +1 -1
  41. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  42. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  43. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +5 -0
  44. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  45. package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts +1 -0
  46. package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
  47. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts +3 -0
  48. package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -0
  49. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +3379 -0
  50. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -0
  51. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  52. package/dist/types/src/features/CognitiveCompare/components/connectedLines.d.ts.map +1 -1
  53. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +2 -1
  54. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  55. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts +1 -1
  56. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  57. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts +1 -1
  58. package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
  59. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/Editor.d.ts.map +1 -1
  60. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.d.ts +2 -6
  61. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.d.ts.map +1 -1
  62. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.d.ts +2 -6
  63. package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.d.ts.map +1 -1
  64. package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts +6 -12
  65. package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts.map +1 -1
  66. package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts +2 -1
  67. package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts.map +1 -1
  68. package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts +0 -4
  69. package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts.map +1 -1
  70. package/dist/types/src/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.d.ts.map +1 -1
  71. package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts +0 -1
  72. package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts.map +1 -1
  73. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),s=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),y=require("./components/RHSSectionRow.js"),b=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),B=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js");exports.SHARED_MARKDOWN_STYLES=s.SHARED_MARKDOWN_STYLES,exports.default=function(T){var D,O,F,j,P,N,k,L,M,q,H,V,z,G,W,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,ue,se,ae,ce,de,fe=T.componentHeaderText,ve=void 0===fe?a.DEFAULT_COMPONENT_HEADER_TEXT:fe,ge=T.treeData,pe=T.comparisonConfig,he=T.leftColumnTitleText,me=T.rightColumnTitleText,Se=T.markdownStyles,Re=T.resetTrigger,xe=T.displayConfig,_e=void 0===xe?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:xe,ye=T.onMaintainRelativeOrderChange,be=T.popupConfig,Ce=T.deviationData,Ee=void 0===Ce?{}:Ce,Ae=T.deviationNodeIdToView,Be=T.resetDeviationNodeId,we=T.isProposingFix,Ie=void 0!==we&&we,Te=T.proposingFixNodeId,De=T.isRedlineFlow,Oe=T.badgeStyleOverride,Fe=i.useState(_e.maintainRelativeOrder),je=Fe[0],Pe=Fe[1],Ne=null!==(D=null==_e?void 0:_e.expandLevels)&&void 0!==D?D:0,ke=!!(null==_e?void 0:_e.expandAllSections),Le=!!je||!!(null==_e?void 0:_e.showDeviationBadges),Me=i.useState(!1),qe=Me[0],He=Me[1],Ve=i.useState(null),ze=Ve[0],Ge=Ve[1],We=i.useState(null===(F=null!==(O=null==ge?void 0:ge.newEvaluationResult)&&void 0!==O?O:null==_e?void 0:_e.enableDeviationSchemaBackwardCompatibility)||void 0===F||F)[0],Ke=i.useState(new Set),Ue=Ke[0],Ye=Ke[1],Je=i.useState([]),Xe=Je[0],$e=Je[1],Qe=i.useState(!1),Ze=Qe[0],en=Qe[1],nn=i.useRef(null),tn=i.useRef(null),on=i.useRef(null),rn=i.useRef(null),ln=i.useRef(null),un=i.useRef(!1),sn=i.useRef(null),an=i.useRef({}),cn=i.useRef([]),dn=i.useRef(function(){}),fn=i.useRef(null),vn=i.useRef(function(){}),gn=i.useMemo(function(){return JSON.stringify(Ee||{})},[JSON.stringify(Ee)]),pn=i.useMemo(function(){return Ee||{}},[gn]),hn=i.useMemo(function(){return(null==ge?void 0:ge.cognitive_decisioning)||{}},[ge]),mn=i.useMemo(function(){return e.__assign(e.__assign({},s.SHARED_MARKDOWN_STYLES),Se)},[Se]),Sn=i.useRef(null),Rn=i.useRef(null),xn=i.useRef(null),_n=i.useRef(null),yn=i.useRef(null),bn=i.useRef(null),Cn=i.useRef(null),En=i.useRef(null),An=i.useRef(null),Bn=i.useRef(null),wn=p.useComparePopups(Sn),In=wn.cognitivePopup,Tn=wn.setCognitivePopup,Dn=wn.moreFunctions,On=wn.setMoreFunctions,Fn=wn.position,jn=wn.setPosition,Pn=wn.activeBadgeId,Nn=wn.summaryPopup,kn=wn.setSummaryPopup,Ln=wn.closeSummaryPopup,Mn=wn.setActiveBadgeId,qn=wn.popupRef,Hn=wn.handleOpenCognitiveCompare,Vn=wn.openCognitivePopupFromState,zn=wn.closeCognitivePopup,Gn=wn.closeMoreFunctionsPopup,Wn=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==pe?void 0:pe.fields)&&void 0!==e?e:s.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==pe?void 0:pe.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:s.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==pe?void 0:pe.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:s.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==pe?void 0:pe.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:s.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[pe]),Kn=i.useState(null),Un=Kn[0];Kn[1];var Yn=null===(N=null===(j=null==ge?void 0:ge.documents)||void 0===j?void 0:j[null===(P=null==ge?void 0:ge.input_index_map)||void 0===P?void 0:P[0]])||void 0===N?void 0:N.title,Jn=null===(M=null===(k=null==ge?void 0:ge.documents)||void 0===k?void 0:k[null===(L=null==ge?void 0:ge.input_index_map)||void 0===L?void 0:L[1]])||void 0===M?void 0:M.title,Xn=u.safeStringify(he||Yn||"Uploaded Contract"),$n=null===(z=null===(V=null===(q=null==ge?void 0:ge.documents)||void 0===q?void 0:q[null===(H=null==ge?void 0:ge.input_index_map)||void 0===H?void 0:H[0]])||void 0===V?void 0:V.metadata)||void 0===z?void 0:z.file_name,Qn=u.safeStringify($n),Zn=null===(U=null===(K=null===(G=null==ge?void 0:ge.documents)||void 0===G?void 0:G[null===(W=null==ge?void 0:ge.input_index_map)||void 0===W?void 0:W[1]])||void 0===K?void 0:K.metadata)||void 0===U?void 0:U.file_name,ei=u.safeStringify(Zn),ni=u.safeStringify(me||Jn||"Reference Template"),ii=g.useCognitiveTreeData(ge,je,pn,Wn,We),ti=ii.activeProposed,oi=ii.existingRule,ri=ii.proposedSections,li=ii.existingSections,ui=ii.visibleFields,si=ii.parentDeviationRecord,ai=ii.deviationNumberRegistry,ci=ii.deviationParentRegistry,di=ii.parseError;i.useEffect(function(){di&&Ge("Failed to load comparison: ".concat(di))},[di]);var fi=ri.length>0||li.length>0,vi=i.useMemo(function(){if(!De)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";u.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(ri),i(li),"".concat(e,":").concat(n)},[De,ri,li]);i.useEffect(function(){if(ri.length||li.length)if(ke){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=je?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(ri,"left"),i(li,"right"),Yi(e),Xi(n)}else if(Ne>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=je?"".concat(n,"-").concat(r):String(r);t[u]=!0}var s=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&s(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&s(e.subsections,String(r),2)})};r(ri,"left",Ne),r(li,"right",Ne),Yi(t),Xi(o)}},[ke,Ne,ri,li,je]);var gi=h.useSectionRefs(ui.map(function(e){return e.key}),Math.max(ri.length,li.length)),pi=gi.leftRefs,hi=gi.rightRefs,mi=gi.sectionLeftRefs,Si=gi.sectionRightRefs,Ri=gi.lhsBadgeRefs,xi=gi.rhsBadgeRefs,_i=gi.sectionRightRowRefs,yi=gi.subSectionLeftRefs,bi=gi.subSectionRightRefs,Ci=gi.sectionRowRefs,Ei=gi.getSectionRowRef,Ai=gi.getSubSectionRef,Bi=gi.getBadgeRef,wi=w.useSideBySide({maintainRelativeOrder:je,proposedSections:ri,existingSections:li,leftContainerRef:En,rightContainerRef:xn,scrollContainerRef:Sn,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,sectionRowRefs:Ci,sectionRightRowRefs:_i,rhsTopSpacerRef:_n,rhsBottomSpacerRef:yn,lhsTopSpacerRef:bn,lhsBottomSpacerRef:Cn,calculateLinesRef:dn,setConnectedSections:Ye,setConnectedLines:$e,cachedConnectedPositions:cn,closeMoreFunctionsPopup:Gn,setErrorToast:Ge,moreFunctions:Dn,closeSummaryPopup:Ln}),Ii=wi.isSideBySide,Ti=wi.isArrowVisible,Di=wi.setIsArrowVisible,Oi=wi.isResizing,Fi=wi.setIsResizing,ji=wi.isSideBySideLoading,Pi=wi.activeSideBySideSection,Ni=wi.scrollLock,ki=wi.sideBySideCacheRef,Li=wi.isSideBySideRef,Mi=wi.activeSideBySideRightSectionRef,qi=wi.activeSideBySideSectionRef,Hi=wi.sideBySideLineRef,Vi=wi.highlightedClauseRefs,zi=wi.clearClauseHighlight,Gi=wi.resetSideBySide,Wi=wi.activateSideBySide,Ki=m.useAccordionState({maintainRelativeOrder:!!je,proposedSections:ri,existingSections:li,activeSideBySideSection:Pi,connectedSections:Ue,resetSideBySide:Gi,setConnectedSections:Ye,setConnectedLines:$e,cachedConnectedPositions:cn,svgContainerRef:nn,isAnimatingRef:un,animationTimerRef:sn,calculateLinesRef:dn,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi}),Ui=Ki.expandedSections,Yi=Ki.setExpandedSections,Ji=Ki.expandedSubSections,Xi=Ki.setExpandedSubSections,$i=Ki.handleSubSectionToggle,Qi=Ki.toggleSection,Zi=Ki.forceExpandCrossWiredSections,et=function(){var e,n;if(null!=Pi){var i=null===(e=mi.current[Pi])||void 0===e?void 0:e.current,t=null===(n=Si.current[Pi])||void 0===n?void 0:n.current,o=xn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),s=r.top-u.top,a=l.top-u.top-s;o.scrollBy({top:a,behavior:"smooth"})}}},nt=i.useCallback(function(e){null==e||e.stopPropagation(),en(function(e){var n=!e;return n&&requestAnimationFrame(function(){et()}),n})},[et]);i.useEffect(function(){De&&"off"!==vi&&"0:0"!==vi&&(ki.current=null,cn.current=[],requestAnimationFrame(function(){var e;null===(e=dn.current)||void 0===e||e.call(dn)}))},[De,vi]);var it=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(je)ri.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),li.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=ri.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(ri.length,li.length),o=0;o<t;o++){var r=ri[o],l=li[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[ri,li,je]),tt=oi.analysis,ot=u.safeStringify(null===(J=null===(Y=null==tt?void 0:tt.rule_difference_comparison)||void 0===Y?void 0:Y.summary)||void 0===J?void 0:J.overall_summary),rt=!!ot.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),lt=null!==(X=null==ge?void 0:ge.base_root_id)&&void 0!==X?X:"-1";null==ge||ge[lt];var ut=We?null!==(se=null!==(re=Ee&&(null===(oe=null==Ee?void 0:Ee[lt])||void 0===oe?void 0:oe.evaluation_result))&&void 0!==re?re:null===(ue=null===(le=null==ge?void 0:ge.nodes)||void 0===le?void 0:le[lt])||void 0===ue?void 0:ue.evaluation_result)&&void 0!==se?se:null:null!==(te=null!==(Z=Ee&&(null===(Q=null===($=null==Ee?void 0:Ee[lt])||void 0===$?void 0:$.evaluation_result)||void 0===Q?void 0:Q[0]))&&void 0!==Z?Z:null===(ie=null===(ne=null===(ee=null==ge?void 0:ge.nodes)||void 0===ee?void 0:ee[lt])||void 0===ne?void 0:ne.evaluation_result)||void 0===ie?void 0:ie[0])&&void 0!==te?te:null,st=u.extractDeviationScore(ut),at=u.generateColorPalette(null!==(de=null===(ce=null===(ae=null==ut?void 0:ut.evaluation_outputs)||void 0===ae?void 0:ae.metadata)||void 0===ce?void 0:ce.label_color)&&void 0!==de?de:a.DEFAULT_DEVIAION_COLOR);if(Oe){var ct=Oe(st);ct&&(at=e.__assign(e.__assign({},at),{badgeBg:ct.bg,badgeText:ct.text,badgeBorder:ct.border}))}var dt=i.useRef(Gi);i.useEffect(function(){dt.current=Gi},[Gi]);var ft=i.useRef(zn);i.useEffect(function(){ft.current=zn},[zn]);var vt=i.useCallback(function(e,n,i,t,o,r){return So.current(e,n,i,t,o,r)},[]),gt=i.useCallback(function(e,n,i,t,o){return xo.current(e,n,i,t,o)},[]),pt=i.useCallback(function(){return _o.current()},[]),ht=i.useCallback(function(e,n){return yo.current(e,n)},[]),mt=i.useCallback(function(e){return bo.current(e)},[]),St=i.useCallback(function(e){return Co.current(e)},[]),Rt=i.useCallback(function(){return Eo.current()},[]),xt=i.useCallback(function(){var e,n;zi(),null===(e=dt.current)||void 0===e||e.call(dt),en(!1),Ye(new Set),$e([]),cn.current=[],Mt([]),Ht(null),kn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=ft.current)||void 0===n||n.call(ft),requestAnimationFrame(function(){var e;null===(e=dn.current)||void 0===e||e.call(dn)})},[]),_t=i.useRef(xt);i.useEffect(function(){_t.current=xt},[xt]),i.useEffect(function(){Re&&_t.current()},[Re]);var yt=i.useMemo(function(){return{documents:null==ge?void 0:ge.documents,input_index_map:null==ge?void 0:ge.input_index_map}},[JSON.stringify(null==ge?void 0:ge.documents),JSON.stringify(null==ge?void 0:ge.input_index_map)]),bt=i.useRef(ge);i.useEffect(function(){bt.current=ge},[ge]);var Ct=i.useRef(hn);i.useEffect(function(){Ct.current=hn},[hn]);var Et=i.useCallback(function(n,i,t,o,r,l,s){var a,c,d,f,v,g,p,h,m,S,R=u.safeStringify(null==i?void 0:i.id)||u.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=Ct.current)||void 0===a?void 0:a[R]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:R,decisioning:[],gap:[],relevance_score:0},_=null!==(d=null===(c=Ci.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,s=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return s(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):s(l)}(),b=(null!==(g=null===(v=null===(f=null==y?void 0:y.cognitive_decisioning)||void 0===f?void 0:f.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0;return{isLoading:null!==(S=null==_e?void 0:_e.isLoading)&&void 0!==S&&S&&!b,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:_,badgeStyle:l||null,sectionIdx:o,docData:yt,deviationData:y,isOrphan:!!r}},[yt,null==_e?void 0:_e.isLoading]),At=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Dn.open&&Dn.sectionIdx===o)Gn();else{var s=e.currentTarget,a="left";(null===(l=xn.current)||void 0===l?void 0:l.contains(s))&&(a="right");zi(),Li.current&&Gi(),Ye(new Set),$e([]),cn.current=[],zn(),Nn.open?Qt():Ln(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=xi.current[l])||void 0===e?void 0:e.current:null===(n=Ri.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=xi.current[o])||void 0===i?void 0:i.current:null===(t=Ri.current[o])||void 0===t?void 0:t.current}()||s;On(Et(e,n,t,o,i,r))})}},[Dn.open,Dn.sectionIdx,Gn,Ln,Et]),Bt=i.useCallback(function(){var e=Dn.sectionIdx;Dn.isOrphan,Gn(),Ln(),null!==e&&(Zi(e),zi(),Li.current&&Gi(),$e([]),cn.current=[],Ye(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){dn.current&&dn.current()},50))},[Dn.sectionIdx,Dn.isOrphan,Gn,Ln,Gi]),wt=i.useCallback(function(){var e=ln.current;if(e){ln.current=null;var n=ri.findIndex(function(n){return n.id===e}),i=li.findIndex(function(n){return n.id===e}),t=-1===n?u.findKeyPathByNodeId(ri,e):null,o=-1===i?u.findKeyPathByNodeId(li,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Vi.current.add(r),u.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(je)-1!==r&&En.current&&a(function(){return s(n,t,mi,yi)},En.current),-1!==l&&xn.current&&a(function(){return s(i,o,Si,bi)},xn.current);else{var c=Sn.current;if(!c)return;a(function(){return-1!==r?s(n,t,mi,yi):s(i,o,Si,bi)},c)}}},[ri,li,je,mi,Si,yi,bi,En,xn,Sn]),It=i.useCallback(function(n){if(n){zi(),Gi(),Ye(new Set),$e([]),cn.current=[],Ln(),zn();var i=ri.findIndex(function(e){return e.id===n}),t=li.findIndex(function(e){return e.id===n}),o=-1===i?u.findKeyPathByNodeId(ri,n):null,r=-1===t?u.findKeyPathByNodeId(li,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,s=-1!==t?t:r?Number(r.split("-")[0]):-1;ln.current=n,Yi(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=je?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==s&&(t[i=je?"right-".concat(s):String(s)]||(t[i]=!0,o=!0));return o?t:n}),Xi(function(n){var i=e.__assign({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){ln.current===n&&Tt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[ri,li,je,Yi,Xi,Gi,Ln,zn]),Tt=i.useRef(wt);i.useEffect(function(){Tt.current=wt},[wt]);var Dt=i.useRef(null);i.useEffect(function(){if(Un){var e=Wn.fields.find(function(e){return e.analysisKey===Un||e.key===Un});if(e){var n=pi.current[e.key]||hi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Un,Wn.fields]);var Ot=i.useCallback(function(e){var n,i,t,o,r,l,u,s,a,c=null===(n=null==tt?void 0:tt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[e],f=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=v.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(s=d.highlights)||void 0===s?void 0:s.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[tt]),Ft=E.useStyleHelpers({proposedSections:ri,existingSections:li,maintainRelativeOrder:je,cognitiveMap:hn,deviationData:pn,treeData:ge,resolvedComparisonConfig:Wn,badgeStyleOverride:Oe}),jt=Ft.getSectionCompareStyle,Pt=Ft.getSubSectionCompareStyle,Nt=Ft.getDeviationStyleByKey,kt=B.useLinesCalculator({containerRef:tn,leftContainerRef:En,rightContainerRef:xn,svgContainerRef:nn,pathRefs:an,leftHeaderRef:on,rightHeaderRef:rn,proposedSections:ri,existingSections:li,visibleFields:ui,leftRefs:pi,rightRefs:hi,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,sectionRowRefs:Ci,expandedSections:Ui,expandedSubSections:Ji,connectedSections:Ue,isSideBySide:Ii,activeSideBySideSection:Pi,maintainRelativeOrder:je,cognitiveMap:hn,getSectionCompareStyle:jt,getSubSectionCompareStyle:Pt,getDeviationStyleByKey:Nt,isArrowVisible:Ti,isAnimatingRef:un,isSideBySideRef:Li,sideBySideCacheRef:ki,sideBySideLineRef:Hi,activeSideBySideSectionRef:qi,activeSideBySideRightSectionRef:Mi,connectedLines:Xe,setConnectedLines:$e,cachedConnectedPositions:cn,calculateLinesRef:dn,resizeTimerRef:fn,scrollLock:Ni,scrollSyncLocked:Ze,handleResizeRef:vn,activeProposed:ti,existingRule:oi,analysisData:tt,pendingScrollTargetRef:An,pendingScrollCallbackRef:Bn,resolvedComparisonConfig:Wn,getFieldData:Ot}),Lt=kt.lines,Mt=kt.setLines,qt=kt.overallConnector,Ht=kt.setOverallConnector,Vt=kt.svgDimensions,zt=kt.handleColumnScroll;i.useEffect(function(){Nn.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=dn.current)||void 0===e||e.call(dn)})})},[Nn.anchorEl,Ze]);var Gt=i.useCallback(function(){zi(),en(!1),Yi({}),Xi({}),Gi(),Ye(new Set),$e([]),cn.current=[],Ln(),zn(),Gn(),requestAnimationFrame(function(){dn.current&&dn.current()})},[Yi,Xi,Gi,Ln,zn,Gn]);i.useEffect(function(){Ii||0!==Ue.size||en(!1)},[Ii,Ue]);var Wt=i.useMemo(function(){return Object.values(Ui).some(Boolean)||Object.values(Ji).some(Boolean)},[Ui,Ji]),Kt=i.useRef(null),Ut=i.useRef(0),Yt=i.useRef(0),Jt=i.useRef(0),Xt=A.useResizeHandler({timerRef:Kt,ruleComponentRef:Rn,scrollContainerRef:Sn,containerRef:tn,maintainRelativeOrder:je,proposedSections:ri,existingSections:li,isSideBySideRef:Li,activeSideBySideSectionRef:qi,activeSideBySideRightSectionRef:Mi,sectionRowRefs:Ci,sectionRightRowRefs:_i,sectionLeftRefs:mi,sectionRightRefs:Si,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,leftContainerRef:En,rightContainerRef:xn,calculateLinesRef:dn,handleResizeRef:vn,setIsResizing:Fi,setIsArrowVisible:Di,sideBySideCacheRef:ki,cachedConnectedPositions:cn}).handleResize;i.useEffect(function(){vn.current=Xt},[Xt,vn]),i.useEffect(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var s=e[e.length-1];if(s){var a=null!==(u=null===(l=null===(r=s.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:s.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Rn.current&&o.push(e(Rn.current,Ut,n,function(){return vn.current()},function(){})),Sn.current&&o.push(e(Sn.current,Yt,i,function(){return vn.current()},function(){return dn.current()})),tn.current&&o.push(e(tn.current,Jt,t,function(){return vn.current()},function(){return dn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){Li.current=Ii},[Ii]),i.useEffect(function(){qi.current=Pi},[Pi]);var $t=i.useCallback(function(){var e,n=Dn.sectionIdx,i=Dn.isOrphan;if(Ln(),null!=n){var t="left";Dn.anchorEl&&(null===(e=xn.current)||void 0===e?void 0:e.contains(Dn.anchorEl))&&(t="right"),Zi(n),Wi(n,i,{sourceSide:t})}},[Wi,Dn.isOrphan,Dn.sectionIdx,Dn.anchorEl,Ln]),Qt=i.useCallback(function(){Ln(),Gi(),Ye(new Set),$e([]),cn.current=[]},[Ln,Gi]),Zt=null!==Dn.sectionIdx&&Ue.has(Dn.sectionIdx),eo=S.useDeviationNavigation({proposedSections:ri,existingSections:li,parentDeviationRecord:si,expandedSections:Ui,maintainRelativeOrder:!!je,scrollContainerRef:Sn,leftContainerRef:En,rightContainerRef:xn,lhsBadgeRefs:Ri,rhsBadgeRefs:xi}),no=eo.showDeviationNavigation,io=eo.showOpenNodeRef,to=eo.adjustScrollForPopup,oo=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?u.safeStringify(t).trim():u.safeStringify(null==t?void 0:t.deviation_summary).trim(),s=e.currentTarget;zn();var a="left";(null===(r=xn.current)||void 0===r?void 0:r.contains(s))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=xi.current[l])||void 0===e?void 0:e.current:null===(i=Ri.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=xi.current[n])||void 0===t?void 0:t.current:null===(o=Ri.current[n])||void 0===o?void 0:o.current};if(i)return Gi(),Ye(new Set),$e([]),cn.current=[],void(l&&(Zi(n),requestAnimationFrame(function(){var e=c()||s;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));kn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Zi(n),l?setTimeout(function(){Wi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,n,i,r=c()||s;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var u=l.top-window.innerHeight/2;je?(null===(e=En.current)||void 0===e||e.scrollBy({top:u,behavior:"smooth"}),null===(n=xn.current)||void 0===n||n.scrollBy({top:u,behavior:"smooth"})):null===(i=Sn.current)||void 0===i||i.scrollBy({top:u,behavior:"smooth"})}}kn({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){Wi(n,i,{toggleIfSame:!1,sourceSide:a})},350)},[Wi,zn,kn,Gi,Zi]),ro=i.useMemo(function(){var e;if(!Ae)return null;var n=null===(e=null==Ae?void 0:Ae.id)||void 0===e?void 0:e.split(":")[0];for(var i in si){if((si[i]||[]).some(function(e){return e.id===n}))return i}return null},[Ae,si]),lo=i.useRef({id:null,triggerMs:null}),uo=i.useRef(null);i.useEffect(function(){if(null==Ae?void 0:Ae.id){var n=Number(Ae.trigger),i=lo.current;if((null==i?void 0:i.triggerMs)!==n){if(!(Ae.id.includes(":")&&/:\d+$/.test(Ae.id)))return lo.current={id:Ae.id,triggerMs:n},void It(Ae.id);var t=Ae.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0";uo.current!==Ae.id&&(Ln(),zn(),Gi(),Ye(new Set),$e([]),cn.current=[],uo.current=Ae.id);var s=!1,a=0,c=null,d=null,f=!1,v=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},g=function(){var i,t,r,p;if(!s){var h=function(){lo.current={id:Ae.id,triggerMs:n}},m=null,S=null;for(var R in si){var x=si[R].find(function(e){return e.id===o});if(x){m=R,S=x;break}}if(S&&m){var _=ri.findIndex(function(e){return e.id===m}),y=li.findIndex(function(e){return e.id===m}),b=-1===_&&-1!==y,C=v(ri,S.id),E=v(li,S.id);if(C&&!E&&!b){var A=C.split("-"),B=Number(A[0]);if(je){var w=null===(t=null===(i=ri[B])||void 0===i?void 0:i.refIndexes)||void 0===t?void 0:t[0],I=li.findIndex(function(e){return e.selfIndex===w});-1!==I&&(B=I)}E=e.__spreadArray([B],A.slice(1),!0).join("-")}if(C||E){var T=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):y,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=ri[T],j=li[O],P=F&&!F.title&&!F.content,N=j&&!j.title&&!j.content,k=b||(!C&&!!E||P&&!N);if(k){if(!(je?!!Ro.current["right-".concat(D)]:!!Ro.current[String(D)])&&D>=0)return Qi(D,"right"),void(c=setTimeout(g,200))}else if(!(je?!!Ro.current["left-".concat(T)]:!!Ro.current[String(T)])&&T>=0)return Qi(T,"left"),void(c=setTimeout(g,200));var L=C||"",M=E||"",q="".concat(S.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l).concat(u.DEVIATION_BADGE_SEPARATOR).concat(L).concat(u.DEVIATION_BADGE_SEPARATOR).concat(M),H="".concat(S.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l);if(!f){Zi(q),f=!0,a=0;var V=function(){var e,n,i=null===(e=Ri.current[H])||void 0===e?void 0:e.current,t=null===(n=xi.current[H])||void 0===n?void 0:n.current;return k||!i&&!!t?t:i};return null==d||d(),void(c=setTimeout(function(){var e,n,i,t,o,r,l;s||(e=V,n=function(){s||(d=null,g())},t=0,o=null,r=null,l=function(){if(!s){var u=e();if(u&&0!==u.getBoundingClientRect().height){var a=u.getBoundingClientRect(),c=a.top,d=a.height,f=null!==o&&Math.abs(c-o)<.5,v=null!==r&&Math.abs(d-r)<.5;if(f&&v){if(++t>=5)return void n()}else t=0;o=c,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),d=function(){return cancelAnimationFrame(i)})},300))}var z=null===(r=Ri.current[H])||void 0===r?void 0:r.current,G=null===(p=xi.current[H])||void 0===p?void 0:p.current;if(z||G){var W=k||!z&&!!G,K=W?G:z,U=je?W?xn.current:En.current:Sn.current;if(K&&U){var Y=K.getBoundingClientRect();if(0!==Y.height){var J=U.getBoundingClientRect(),X=Y.top-J.top+U.scrollTop-J.height/2+Y.height/2,$=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),Q=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,a,c,d,f,v;return e.__generator(this,function(g){switch(g.label){case 0:return s?[2]:(h(),n=K instanceof Element?window.getComputedStyle(K).color:"",[z,G].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[z,G].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(a=S.evaluationResult)||void 0===a?void 0:a.deviations)||void 0===c?void 0:c[l])||S,t=(null===(d=S.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||S.evaluation_outputs,!!z&&!!G?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},je?[4,Promise.all([En.current?r(u.waitForScrollIdle(En.current),600):Promise.resolve(),xn.current?r(u.waitForScrollIdle(xn.current),600):Promise.resolve()])]:[3,2]):(o=W?(null===(f=xi.current[$?H:D])||void 0===f?void 0:f.current)||G:(null===(v=Ri.current[$?H:T])||void 0===v?void 0:v.current)||z,to(o,function(){kn({open:!0,anchorEl:o,displayImpact:Ae.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==Be||Be(),[2]));case 1:g.sent(),g.label=2;case 2:return Wi(q,!1,{toggleIfSame:!1,sourceSide:b?"right":"left",onReady:function(){var n,t,o,r;h();var l=W?(null===(n=xi.current[H])||void 0===n?void 0:n.current)||G:(null===(t=Ri.current[H])||void 0===t?void 0:t.current)||z,u=(null===(o=Ri.current[H])||void 0===o?void 0:o.current)||z,s=(null===(r=xi.current[H])||void 0===r?void 0:r.current)||G;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),s&&(s.style.scrollMarginTop="150px",s.scrollIntoView({behavior:"smooth",block:"start"})),kn({open:!0,anchorEl:l,displayImpact:Ae.displayImpact,summary:e.__assign({},i)}),null==Be||Be()}}),[2]}})})};Math.abs(U.scrollTop-X)<=2?Q():u.scrollAndWait(U,X,Q)}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}};return c=setTimeout(g,100),function(){s=!0,c&&clearTimeout(c),null==d||d()}}}},[Ae,si,ri,li,je,Ui,Wi,kn,It]),i.useEffect(function(){var n,i,t;if(Nn.open){var o=Nn.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Ri.current)||r(xi.current);if(l){var u=(null===(i=xi.current[l])||void 0===i?void 0:i.current)||(null===(t=Ri.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&kn(function(n){return e.__assign(e.__assign({},n),{anchorEl:u})})}}}},[Nn.open,Nn.anchorEl,Ze,Ue,Ui]);var so=In.open,ao=In.sectionIdx,co=In.isOrphan,fo=In.badgeStyle,vo=In.anchorEl,go=In.sectionAnchorEl;i.useEffect(function(){var n;if(_e.isStreamingEnabled&&so&&null!=ao&&ao!==lt){var i="string"==typeof ao?ao.split(u.DEVIATION_BADGE_SEPARATOR)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(ri,i):null,r=i&&"string"==typeof i?t(li,i):null,l="number"==typeof ao?ri[ao]||null:o||i&&((null===(n=null==ge?void 0:ge.nodes)||void 0===n?void 0:n[i])||(null==ge?void 0:ge[i]))||null,s="number"==typeof ao?li[ao]||null:r,a=Et(vo,l,s,ao,co,fo);Tn(function(n){return n.open?u.safeStringify(n.cognitiveData)===u.safeStringify(a.cognitiveData)&&u.safeStringify(n.deviationData)===u.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[so,ao,co,fo,vo,go,ri,li,Et]);var po=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,s=e.parentNodeId,a=void 0===s?"":s,c=e.sectionOffset;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:c})},[]),ho=i.useMemo(function(){return ri.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&je?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[ri]),mo=i.useMemo(function(){return li.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&je?null:n.jsx(y.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[li]),So=i.useRef(At);i.useEffect(function(){So.current=At},[At]);var Ro=i.useRef(Ui);i.useEffect(function(){Ro.current=Ui},[Ui]);var xo=i.useRef(oo);i.useEffect(function(){xo.current=oo},[oo]);var _o=i.useRef(Qt);i.useEffect(function(){_o.current=Qt},[Qt]);var yo=i.useRef(Qi);i.useEffect(function(){yo.current=Qi},[Qi]);var bo=i.useRef($i);i.useEffect(function(){bo.current=$i},[$i]);var Co=i.useRef(po);i.useEffect(function(){Co.current=po},[po]);var Eo=i.useRef(Gi);i.useEffect(function(){Eo.current=Gi},[Gi]);var Ao=i.useMemo(function(){return{maintainRelativeOrder:!!je,showDeviationBadges:Le,isProposingFix:Ie,proposingFixNodeId:Te,isRedlineFlow:De,isSideBySide:Ii,activeSideBySideSection:Pi,scrollSyncLocked:Ze,toggleScrollSyncLocked:nt,summaryPopupAnchorEl:Nn.anchorEl,connectedSections:Ue,proposedSections:ri,existingSections:li,deviationNumberRegistry:ai,deviationParentRegistry:ci,treeData:ge,displayConfig:_e,resolvedMarkdownStyles:mn,unifiedNumbering:it,expandedSections:Ui,expandedSubSections:Ji,setExpandedSubSections:Xi,getSectionCompareStyle:jt,getSubSectionCompareStyle:Pt,getBadgeRef:Bi,getSectionRowRef:Ei,getSubSectionRef:Ai,sectionLeftRefs:mi,sectionRightRefs:Si,sectionRowRefs:Ci,sectionRightRowRefs:_i,subSectionLeftRefs:yi,subSectionRightRefs:bi,lhsBadgeRefs:Ri,rhsBadgeRefs:xi,openMoreFunctionsPopup:vt,handleOpenSummaryPopup:gt,openSummaryPopup:gt,handleCloseSummaryPopup:pt,toggleSection:ht,handleSubSectionToggle:mt,renderSubSectionAccordion:St,resetSideBySide:Rt,setConnectedSections:Ye,setConnectedLines:$e,cachedConnectedPositions:cn,showDeviationNavigation:no,showOpenNodeRef:io,deviationNodeIdToView:null==Ae?void 0:Ae.id,deviationTargetParentId:ro}},[je,Le,Ie,Te,De,Ii,Pi,Ze,nt,Nn.anchorEl,Ue,ri,li,ai,_e,mn,it,Ui,Ji,Xi,jt,Pt,Bi,Ei,Ai,no,io,Ae,ro]);return n.jsx(C.CompareContextProvider,e.__assign({value:Ao},{children:n.jsxs(t.Box,e.__assign({ref:Rn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[qe&&n.jsx(t.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(f.default,{})})),Nn.open&&n.jsx(b.default,{open:Nn.open,anchorEl:Nn.anchorEl,containerEl:Dt.current,clipTopEl:on.current,scrollContainerEl:Sn.current,onClose:Qt,summary:Nn.summary,displayImpact:Nn.displayImpact,isScrollLocked:Ze}),n.jsx(d.default,{open:Dn.open,anchorEl:Dn.anchorEl,maintainRelativeOrder:!!je,sectionTitle:Dn.sectionTitle,referenceSectionTitle:Dn.refSectionTitle,onClose:Gn,onOpenCognitiveCompare:Hn,onOpenSideBySide:$t,onConnect:Bt,isConnected:Zt,isOrphan:Dn.isOrphan}),In.open&&n.jsx(c.default,{open:In.open,popupRef:qn,position:Fn,popupConfig:be,onClose:function(){jn(null),Tn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Mn(null)},markdownStyles:Se,sectionTitle:Qn,referenceSectionTitle:ei,cognitiveData:In.cognitiveData,anchorEl:In.anchorEl,sectionAnchorEl:In.sectionAnchorEl,scrollContainerEl:Sn.current,badgeStyle:In.badgeStyle,docData:In.docData,deviationData:In.deviationData,isLoading:In.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!ze,autoHideDuration:8e3,onClose:function(){return Ge(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ge(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ze}))})),n.jsx(R.default,{componentHeaderText:ve,displayConfig:_e,maintainRelativeOrder:je,onCollapseAll:Gt,showCollapseAll:Wt,onToggleView:function(e){He(!0),setTimeout(function(){Pe(!e),null==ye||ye(!e),en(!1),Gi(),Ln(),Ye(new Set),$e([]),cn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){He(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:Sn,onScroll:zt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:je?"visible":"auto",borderTop:ot&&rt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},je?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:tn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},je?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:nn,svgDimensions:Vt,isResizing:Oi,overallConnector:qt,rootDeviationStyle:at,lines:Lt,isSideBySide:Ii,activeSideBySideSection:Pi,isArrowVisible:Ti,maintainRelativeOrder:je,proposedSections:ri,existingSections:li,cognitivePopup:In,activeBadgeId:Pn,closeCognitivePopup:zn,setActiveBadgeId:Mn,openCognitivePopupFromState:Vn,buildSectionPopupState:Et,connectedLines:Xe,pathRefs:an}),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},je?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:on,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(t.Tooltip,e.__assign({title:Xn,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Xn}))}))})),n.jsxs(t.Box,e.__assign({ref:En,onScroll:zt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},je?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:bn,style:{width:"100%",height:"0px",flexShrink:0}}),fi&&ho,n.jsx("div",{ref:Cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:Dt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),In.open&&Pn===lt?zn():(Mn(lt),Vn(Et(n.currentTarget,{title:"",content:"",evaluationResult:ut,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,lt,!0,e.__assign(e.__assign({},at),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:at.badgeBg,color:at.badgeText,border:"1px solid ".concat(at.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=st?st:n.jsx(v.default,{}),n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:In.open&&Pn===lt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},je?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[ji&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:rn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(t.Tooltip,e.__assign({title:ni,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ni}))}))})),n.jsxs(t.Box,e.__assign({ref:xn,onScroll:zt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},je?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:_n,style:{width:"100%",height:"0px",flexShrink:0}}),fi&&mo,n.jsx("div",{ref:yn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("./CognitiveComparehelpers.js"),u=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),c=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./components/CompareHeader.js"),x=require("./components/SubSectionAccordion.js"),_=require("./components/LHSSectionRow.js"),b=require("./components/RHSSectionRow.js"),y=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),B=require("./hooks/useLinesCalculator.js"),w=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),T=require("./Guidelines/components/GuidelinePanel.js");exports.SHARED_MARKDOWN_STYLES=u.SHARED_MARKDOWN_STYLES,exports.default=function(D){var O,F,j,k,P,N,L,M,q,H,V,z,G,W,K,U,Y,J,X,$,Q,Z,ee,ne,ie,te,oe,re,le,se,ue,ae,ce,de,fe,ve=D.componentHeaderText,ge=void 0===ve?a.DEFAULT_COMPONENT_HEADER_TEXT:ve,pe=D.treeData,he=D.comparisonConfig,me=D.leftColumnTitleText,Se=D.rightColumnTitleText,Re=D.markdownStyles,xe=D.resetTrigger,_e=D.displayConfig,be=void 0===_e?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:_e,ye=D.onMaintainRelativeOrderChange,Ce=D.popupConfig,Ee=D.deviationData,Ae=void 0===Ee?{}:Ee,Be=D.deviationNodeIdToView,we=D.resetDeviationNodeId,Ie=D.isProposingFix,Te=void 0!==Ie&&Ie,De=D.proposingFixNodeId,Oe=D.isRedlineFlow,Fe=D.badgeStyleOverride,je=D.guidelinesData,ke=i.useState(be.maintainRelativeOrder),Pe=ke[0],Ne=ke[1],Le=null!==(O=null==be?void 0:be.expandLevels)&&void 0!==O?O:0,Me=!!(null==be?void 0:be.expandAllSections),qe=!!Pe||!!(null==be?void 0:be.showDeviationBadges),He=i.useState(!1),Ve=He[0],ze=He[1],Ge=i.useState(null),We=Ge[0],Ke=Ge[1],Ue=i.useState(null===(j=null!==(F=null==pe?void 0:pe.newEvaluationResult)&&void 0!==F?F:null==be?void 0:be.enableDeviationSchemaBackwardCompatibility)||void 0===j||j)[0],Ye=i.useState(new Set),Je=Ye[0],Xe=Ye[1],$e=i.useState([]),Qe=$e[0],Ze=$e[1],en=i.useState(!1),nn=en[0],tn=en[1],on=i.useRef(null),rn=i.useRef(null),ln=i.useRef(null),sn=i.useRef(null),un=i.useRef(null),an=i.useRef(!1),cn=i.useRef(null),dn=i.useRef({}),fn=i.useRef([]),vn=i.useRef(function(){}),gn=i.useRef(null),pn=i.useRef(function(){}),hn=i.useMemo(function(){return JSON.stringify(Ae||{})},[JSON.stringify(Ae)]),mn=i.useMemo(function(){return Ae||{}},[hn]),Sn=i.useMemo(function(){return(null==pe?void 0:pe.cognitive_decisioning)||{}},[pe]),Rn=i.useMemo(function(){return e.__assign(e.__assign({},u.SHARED_MARKDOWN_STYLES),Re)},[Re]),xn=i.useRef(null),_n=i.useRef(null),bn=i.useRef(null),yn=i.useRef(null),Cn=i.useRef(null),En=i.useRef(null),An=i.useRef(null),Bn=i.useRef(null),wn=i.useRef(null),In=i.useRef(null),Tn=p.useComparePopups(xn),Dn=Tn.cognitivePopup,On=Tn.setCognitivePopup,Fn=Tn.moreFunctions,jn=Tn.setMoreFunctions,kn=Tn.position,Pn=Tn.setPosition,Nn=Tn.activeBadgeId,Ln=Tn.summaryPopup,Mn=Tn.setSummaryPopup,qn=Tn.closeSummaryPopup,Hn=Tn.setActiveBadgeId,Vn=Tn.popupRef,zn=Tn.handleOpenCognitiveCompare,Gn=Tn.openCognitivePopupFromState,Wn=Tn.closeCognitivePopup,Kn=Tn.closeMoreFunctionsPopup,Un=i.useMemo(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==he?void 0:he.fields)&&void 0!==e?e:u.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(n=null==he?void 0:he.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:u.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(t=null==he?void 0:he.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:u.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==he?void 0:he.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:u.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[he]),Yn=i.useState(null),Jn=Yn[0];Yn[1];var Xn=null===(N=null===(k=null==pe?void 0:pe.documents)||void 0===k?void 0:k[null===(P=null==pe?void 0:pe.input_index_map)||void 0===P?void 0:P[0]])||void 0===N?void 0:N.title,$n=null===(q=null===(L=null==pe?void 0:pe.documents)||void 0===L?void 0:L[null===(M=null==pe?void 0:pe.input_index_map)||void 0===M?void 0:M[1]])||void 0===q?void 0:q.title,Qn=s.safeStringify(me||Xn||"Uploaded Contract"),Zn=null===(G=null===(z=null===(H=null==pe?void 0:pe.documents)||void 0===H?void 0:H[null===(V=null==pe?void 0:pe.input_index_map)||void 0===V?void 0:V[0]])||void 0===z?void 0:z.metadata)||void 0===G?void 0:G.file_name,ei=s.safeStringify(Zn),ni=null===(Y=null===(U=null===(W=null==pe?void 0:pe.documents)||void 0===W?void 0:W[null===(K=null==pe?void 0:pe.input_index_map)||void 0===K?void 0:K[1]])||void 0===U?void 0:U.metadata)||void 0===Y?void 0:Y.file_name,ii=s.safeStringify(ni),ti=s.safeStringify(Se||$n||"Reference Template"),oi=g.useCognitiveTreeData(pe,Pe,mn,Un,Ue,je),ri=oi.isGuidelineMode,li=oi.activeProposed,si=oi.existingRule,ui=oi.proposedSections,ai=oi.existingSections,ci=oi.visibleFields,di=oi.parentDeviationRecord,fi=oi.deviationNumberRegistry,vi=oi.deviationParentRegistry,gi=oi.parseError;i.useEffect(function(){gi&&Ke("Failed to load comparison: ".concat(gi))},[gi]);var pi=ui.length>0||ai.length>0,hi=i.useMemo(function(){if(!Oe)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";s.hasMeaningfulRedlineTags(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(ui),i(ai),"".concat(e,":").concat(n)},[Oe,ui,ai]);i.useEffect(function(){if(ui.length||ai.length)if(Me){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Pe?"".concat(t,"-").concat(o):String(o);e[l]=!0;var s=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&s(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&s(i.subsections,String(o))})};i(ui,"left"),i(ai,"right"),$i(e),Zi(n)}else if(Le>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var s=Pe?"".concat(n,"-").concat(r):String(r);t[s]=!0}var u=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&u(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&u(e.subsections,String(r),2)})};r(ui,"left",Le),r(ai,"right",Le),$i(t),Zi(o)}},[Me,Le,ui,ai,Pe]);var mi=h.useSectionRefs(ci.map(function(e){return e.key}),Math.max(ui.length,ai.length)),Si=mi.leftRefs,Ri=mi.rightRefs,xi=mi.sectionLeftRefs,_i=mi.sectionRightRefs,bi=mi.lhsBadgeRefs,yi=mi.rhsBadgeRefs,Ci=mi.sectionRightRowRefs,Ei=mi.subSectionLeftRefs,Ai=mi.subSectionRightRefs,Bi=mi.sectionRowRefs,wi=mi.getSectionRowRef,Ii=mi.getSubSectionRef,Ti=mi.getBadgeRef,Di=w.useSideBySide({isGuidelineMode:ri,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,leftContainerRef:Bn,rightContainerRef:bn,scrollContainerRef:xn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,rhsTopSpacerRef:yn,rhsBottomSpacerRef:Cn,lhsTopSpacerRef:En,lhsBottomSpacerRef:An,calculateLinesRef:vn,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:fn,closeMoreFunctionsPopup:Kn,setErrorToast:Ke,moreFunctions:Fn,closeSummaryPopup:qn}),Oi=Di.isSideBySide,Fi=Di.isArrowVisible,ji=Di.setIsArrowVisible,ki=Di.isResizing,Pi=Di.setIsResizing,Ni=Di.isSideBySideLoading,Li=Di.activeSideBySideSection,Mi=Di.scrollLock,qi=Di.sideBySideCacheRef,Hi=Di.isSideBySideRef,Vi=Di.activeSideBySideRightSectionRef,zi=Di.activeSideBySideSectionRef,Gi=Di.sideBySideLineRef,Wi=Di.highlightedClauseRefs,Ki=Di.clearClauseHighlight,Ui=Di.resetSideBySide,Yi=Di.activateSideBySide,Ji=m.useAccordionState({maintainRelativeOrder:!!Pe,proposedSections:ui,existingSections:ai,activeSideBySideSection:Li,connectedSections:Je,resetSideBySide:Ui,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:fn,svgContainerRef:on,isAnimatingRef:an,animationTimerRef:cn,calculateLinesRef:vn,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai}),Xi=Ji.expandedSections,$i=Ji.setExpandedSections,Qi=Ji.expandedSubSections,Zi=Ji.setExpandedSubSections,et=Ji.handleSubSectionToggle,nt=Ji.toggleSection,it=Ji.forceExpandCrossWiredSections,tt=function(){var e,n;if(null!=Li){var i=null===(e=xi.current[Li])||void 0===e?void 0:e.current,t=null===(n=_i.current[Li])||void 0===n?void 0:n.current,o=bn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),s=o.getBoundingClientRect(),u=r.top-s.top,a=l.top-s.top-u;o.scrollBy({top:a,behavior:"smooth"})}}},ot=i.useCallback(function(e){null==e||e.stopPropagation(),tn(function(e){var n=!e;return n&&requestAnimationFrame(function(){tt()}),n})},[tt]);i.useEffect(function(){Oe&&"off"!==hi&&"0:0"!==hi&&(qi.current=null,fn.current=[],requestAnimationFrame(function(){var e;null===(e=vn.current)||void 0===e||e.call(vn)}))},[Oe,hi]);var rt=i.useMemo(function(){var e=new Map,n=new Map,i=1;if(Pe)ui.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),ai.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=ui.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(ui.length,ai.length),o=0;o<t;o++){var r=ui[o],l=ai[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[ui,ai,Pe]),lt=si.analysis,st=s.safeStringify(null===(X=null===(J=null==lt?void 0:lt.rule_difference_comparison)||void 0===J?void 0:J.summary)||void 0===X?void 0:X.overall_summary),ut=!!st.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),at=null!==($=null==pe?void 0:pe.base_root_id)&&void 0!==$?$:"-1";null==pe||pe[at];var ct=Ue?null!==(ae=null!==(le=Ae&&(null===(re=null==Ae?void 0:Ae[at])||void 0===re?void 0:re.evaluation_result))&&void 0!==le?le:null===(ue=null===(se=null==pe?void 0:pe.nodes)||void 0===se?void 0:se[at])||void 0===ue?void 0:ue.evaluation_result)&&void 0!==ae?ae:null:null!==(oe=null!==(ee=Ae&&(null===(Z=null===(Q=null==Ae?void 0:Ae[at])||void 0===Q?void 0:Q.evaluation_result)||void 0===Z?void 0:Z[0]))&&void 0!==ee?ee:null===(te=null===(ie=null===(ne=null==pe?void 0:pe.nodes)||void 0===ne?void 0:ne[at])||void 0===ie?void 0:ie.evaluation_result)||void 0===te?void 0:te[0])&&void 0!==oe?oe:null,dt=s.extractDeviationScore(ct),ft=s.generateColorPalette(null!==(fe=null===(de=null===(ce=null==ct?void 0:ct.evaluation_outputs)||void 0===ce?void 0:ce.metadata)||void 0===de?void 0:de.label_color)&&void 0!==fe?fe:a.DEFAULT_DEVIAION_COLOR);if(Fe){var vt=Fe(dt);vt&&(ft=e.__assign(e.__assign({},ft),{badgeBg:vt.bg,badgeText:vt.text,badgeBorder:vt.border}))}var gt=i.useRef(Ui);i.useEffect(function(){gt.current=Ui},[Ui]);var pt=i.useRef(Wn);i.useEffect(function(){pt.current=Wn},[Wn]);var ht=i.useCallback(function(e,n,i,t,o,r){return _o.current(e,n,i,t,o,r)},[]),mt=i.useCallback(function(e,n,i,t,o){return yo.current(e,n,i,t,o)},[]),St=i.useCallback(function(){return Co.current()},[]),Rt=i.useCallback(function(e,n){return Eo.current(e,n)},[]),xt=i.useCallback(function(e){return Ao.current(e)},[]),_t=i.useCallback(function(e){return Bo.current(e)},[]),bt=i.useCallback(function(){return wo.current()},[]),yt=i.useCallback(function(){var e,n;Ki(),null===(e=gt.current)||void 0===e||e.call(gt),tn(!1),Xe(new Set),Ze([]),fn.current=[],Vt([]),Gt(null),Mn(a.EMPTY_SUMMARY_POPUP_STATE),null===(n=pt.current)||void 0===n||n.call(pt),requestAnimationFrame(function(){var e;null===(e=vn.current)||void 0===e||e.call(vn)})},[]),Ct=i.useRef(yt);i.useEffect(function(){Ct.current=yt},[yt]),i.useEffect(function(){xe&&Ct.current()},[xe]);var Et=i.useMemo(function(){return{documents:null==pe?void 0:pe.documents,input_index_map:null==pe?void 0:pe.input_index_map}},[JSON.stringify(null==pe?void 0:pe.documents),JSON.stringify(null==pe?void 0:pe.input_index_map)]),At=i.useRef(pe);i.useEffect(function(){At.current=pe},[pe]);var Bt=i.useRef(Sn);i.useEffect(function(){Bt.current=Sn},[Sn]);var wt=i.useCallback(function(n,i,t,o,r,l,u){var a,c,d,f,v,g,p,h,m,S,R=s.safeStringify(null==i?void 0:i.id)||s.safeStringify(null==t?void 0:t.id)||"",x=(R?null===(a=Bt.current)||void 0===a?void 0:a[R]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:R,decisioning:[],gap:[],relevance_score:0},_=null!==(d=null===(c=Bi.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null,b=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)))return u(l);var a=o.split(s.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var c=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(n=null==c?void 0:c.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==c?void 0:c.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},c),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==c?void 0:c.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==c?void 0:c.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==c?void 0:c.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==c?void 0:c.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==c?void 0:c.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==c?void 0:c.cognitive_decisioning)}):u(l)}(),y=(null!==(g=null===(v=null===(f=null==b?void 0:b.cognitive_decisioning)||void 0===f?void 0:f.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==g?g:0)>0||(null!==(m=null===(h=null===(p=null==b?void 0:b.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>0;return{isLoading:null!==(S=null==be?void 0:be.isLoading)&&void 0!==S&&S&&!y,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:x,anchorEl:n,sectionAnchorEl:_,badgeStyle:l||null,sectionIdx:o,docData:Et,deviationData:b,isOrphan:!!r}},[Et,null==be?void 0:be.isLoading]),It=i.useCallback(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Fn.open&&Fn.sectionIdx===o)Kn();else{var u=e.currentTarget,a="left";(null===(l=bn.current)||void 0===l?void 0:l.contains(u))&&(a="right");Ki(),Hi.current&&Ui(),Xe(new Set),Ze([]),fn.current=[],Wn(),Ln.open?no():qn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=o.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=yi.current[l])||void 0===e?void 0:e.current:null===(n=bi.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=yi.current[o])||void 0===i?void 0:i.current:null===(t=bi.current[o])||void 0===t?void 0:t.current}()||u;jn(wt(e,n,t,o,i,r))})}},[Fn.open,Fn.sectionIdx,Kn,qn,wt]),Tt=i.useCallback(function(){var e=Fn.sectionIdx;Fn.isOrphan,Kn(),qn(),null!==e&&(it(e),Ki(),Hi.current&&Ui(),Ze([]),fn.current=[],Xe(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){vn.current&&vn.current()},50))},[Fn.sectionIdx,Fn.isOrphan,Kn,qn,Ui]),Dt=i.useCallback(function(){var e=un.current;if(e){un.current=null;var n=ui.findIndex(function(n){return n.id===e}),i=ai.findIndex(function(n){return n.id===e}),t=-1===n?s.findKeyPathByNodeId(ui,e):null,o=-1===i?s.findKeyPathByNodeId(ai,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,s;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(s=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==s?s:null},a=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Wi.current.add(r),s.scrollAndHighlightClause(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Pe)-1!==r&&Bn.current&&a(function(){return u(n,t,xi,Ei)},Bn.current),-1!==l&&bn.current&&a(function(){return u(i,o,_i,Ai)},bn.current);else{var c=xn.current;if(!c)return;a(function(){return-1!==r?u(n,t,xi,Ei):u(i,o,_i,Ai)},c)}}},[ui,ai,Pe,xi,_i,Ei,Ai,Bn,bn,xn]),Ot=i.useCallback(function(n){if(n){Ki(),Ui(),Xe(new Set),Ze([]),fn.current=[],qn(),Wn();var i=ui.findIndex(function(e){return e.id===n}),t=ai.findIndex(function(e){return e.id===n}),o=-1===i?s.findKeyPathByNodeId(ui,n):null,r=-1===t?s.findKeyPathByNodeId(ai,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;un.current=n,$i(function(n){var i,t=e.__assign({},n),o=!1;-1!==l&&(t[i=Pe?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=Pe?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),Zi(function(n){var i=e.__assign({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){un.current===n&&Ft.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[ui,ai,Pe,$i,Zi,Ui,qn,Wn]),Ft=i.useRef(Dt);i.useEffect(function(){Ft.current=Dt},[Dt]);var jt=i.useRef(null);i.useEffect(function(){if(Jn){var e=Un.fields.find(function(e){return e.analysisKey===Jn||e.key===Jn});if(e){var n=Si.current[e.key]||Ri.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Jn,Un.fields]);var kt=i.useCallback(function(e){var n,i,t,o,r,l,s,u,a,c=null===(n=null==lt?void 0:lt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!c||!c[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=c[e],f=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=v.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(u=d.highlights)||void 0===u?void 0:u.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[lt]),Pt=E.useStyleHelpers({proposedSections:ui,existingSections:ai,maintainRelativeOrder:Pe,cognitiveMap:Sn,deviationData:mn,treeData:pe,resolvedComparisonConfig:Un,badgeStyleOverride:Fe}),Nt=Pt.getSectionCompareStyle,Lt=Pt.getSubSectionCompareStyle,Mt=Pt.getDeviationStyleByKey,qt=B.useLinesCalculator({containerRef:rn,leftContainerRef:Bn,rightContainerRef:bn,svgContainerRef:on,pathRefs:dn,leftHeaderRef:ln,rightHeaderRef:sn,proposedSections:ui,existingSections:ai,visibleFields:ci,leftRefs:Si,rightRefs:Ri,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,sectionRowRefs:Bi,expandedSections:Xi,expandedSubSections:Qi,connectedSections:Je,isSideBySide:Oi,activeSideBySideSection:Li,maintainRelativeOrder:Pe,isGuidelineMode:ri,cognitiveMap:Sn,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Lt,getDeviationStyleByKey:Mt,isArrowVisible:Fi,isAnimatingRef:an,isSideBySideRef:Hi,sideBySideCacheRef:qi,sideBySideLineRef:Gi,activeSideBySideSectionRef:zi,activeSideBySideRightSectionRef:Vi,connectedLines:Qe,setConnectedLines:Ze,cachedConnectedPositions:fn,calculateLinesRef:vn,resizeTimerRef:gn,scrollLock:Mi,scrollSyncLocked:nn,handleResizeRef:pn,activeProposed:li,existingRule:si,analysisData:lt,pendingScrollTargetRef:wn,pendingScrollCallbackRef:In,resolvedComparisonConfig:Un,getFieldData:kt}),Ht=qt.lines,Vt=qt.setLines,zt=qt.overallConnector,Gt=qt.setOverallConnector,Wt=qt.svgDimensions,Kt=qt.handleColumnScroll;i.useEffect(function(){Ln.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=vn.current)||void 0===e||e.call(vn)})})},[Ln.anchorEl,nn]);var Ut=i.useCallback(function(){Ki(),tn(!1),$i({}),Zi({}),Ui(),Xe(new Set),Ze([]),fn.current=[],qn(),Wn(),Kn(),requestAnimationFrame(function(){vn.current&&vn.current()})},[$i,Zi,Ui,qn,Wn,Kn]);i.useEffect(function(){Oi||0!==Je.size||tn(!1)},[Oi,Je]);var Yt=i.useMemo(function(){return Object.values(Xi).some(Boolean)||Object.values(Qi).some(Boolean)},[Xi,Qi]),Jt=i.useRef(null),Xt=i.useRef(0),$t=i.useRef(0),Qt=i.useRef(0),Zt=A.useResizeHandler({timerRef:Jt,ruleComponentRef:_n,scrollContainerRef:xn,containerRef:rn,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,isSideBySideRef:Hi,activeSideBySideSectionRef:zi,activeSideBySideRightSectionRef:Vi,sectionRowRefs:Bi,sectionRightRowRefs:Ci,sectionLeftRefs:xi,sectionRightRefs:_i,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,leftContainerRef:Bn,rightContainerRef:bn,calculateLinesRef:vn,handleResizeRef:pn,setIsResizing:Pi,setIsArrowVisible:ji,sideBySideCacheRef:qi,cachedConnectedPositions:fn}).handleResize;i.useEffect(function(){pn.current=Zt},[Zt,pn]),i.useEffect(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,s;i.current=null;var u=e[e.length-1];if(u){var a=null!==(s=null===(l=null===(r=u.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==s?s:u.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return _n.current&&o.push(e(_n.current,Xt,n,function(){return pn.current()},function(){})),xn.current&&o.push(e(xn.current,$t,i,function(){return pn.current()},function(){return vn.current()})),rn.current&&o.push(e(rn.current,Qt,t,function(){return pn.current()},function(){return vn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),i.useEffect(function(){Hi.current=Oi},[Oi]),i.useEffect(function(){zi.current=Li},[Li]);var eo=i.useCallback(function(){var e,n=Fn.sectionIdx,i=Fn.isOrphan;if(qn(),null!=n){var t="left";Fn.anchorEl&&(null===(e=bn.current)||void 0===e?void 0:e.contains(Fn.anchorEl))&&(t="right"),it(n),Yi(n,i,{sourceSide:t})}},[Yi,Fn.isOrphan,Fn.sectionIdx,Fn.anchorEl,qn]),no=i.useCallback(function(){qn(),Ui(),Xe(new Set),Ze([]),fn.current=[]},[qn,Ui]),io=null!==Fn.sectionIdx&&Je.has(Fn.sectionIdx),to=S.useDeviationNavigation({proposedSections:ui,existingSections:ai,parentDeviationRecord:di,expandedSections:Xi,maintainRelativeOrder:!!Pe,scrollContainerRef:xn,leftContainerRef:Bn,rightContainerRef:bn,lhsBadgeRefs:bi,rhsBadgeRefs:yi}),oo=to.showDeviationNavigation,ro=to.showOpenNodeRef,lo=to.adjustScrollForPopup,so=i.useCallback(function(e,n,i,t,o){var r,l="string"==typeof t?s.safeStringify(t).trim():s.safeStringify(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;Wn();var a="left";(null===(r=bn.current)||void 0===r?void 0:r.contains(u))&&(a="right");var c=function(){var e,i,t,o;if("string"==typeof n&&n.includes(s.DEVIATION_BADGE_SEPARATOR)){var r=n.split(s.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(s.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=yi.current[l])||void 0===e?void 0:e.current:null===(i=bi.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=yi.current[n])||void 0===t?void 0:t.current:null===(o=bi.current[n])||void 0===o?void 0:o.current};if(i)return Ui(),Xe(new Set),Ze([]),fn.current=[],void(l&&(it(n),requestAnimationFrame(function(){var e=c()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));Mn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));it(n),l?setTimeout(function(){Yi(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e,n,i,r=c()||u;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var s=l.top-window.innerHeight/2;Pe?(null===(e=Bn.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(n=bn.current)||void 0===n||n.scrollBy({top:s,behavior:"smooth"})):null===(i=xn.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})}}Mn({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){Yi(n,i,{toggleIfSame:!1,sourceSide:a})},350)},[Yi,Wn,Mn,Ui,it]),uo=i.useMemo(function(){var e;if(!Be)return null;var n=null===(e=null==Be?void 0:Be.id)||void 0===e?void 0:e.split(":")[0];for(var i in di){if((di[i]||[]).some(function(e){return e.id===n}))return i}return null},[Be,di]),ao=i.useRef({id:null,triggerMs:null}),co=i.useRef(null);i.useEffect(function(){if(null==Be?void 0:Be.id){var n=Number(Be.trigger),i=ao.current;if((null==i?void 0:i.triggerMs)!==n){if(!(Be.id.includes(":")&&/:\d+$/.test(Be.id)))return ao.current={id:Be.id,triggerMs:n},void Ot(Be.id);var t=Be.id.split(":"),o=t[0],r=t[1],l=null!=r?r:"0";co.current!==Be.id&&(qn(),Wn(),Ui(),Xe(new Set),Ze([]),fn.current=[],co.current=Be.id);var u=!1,a=0,c=null,d=null,f=!1,v=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},g=function(){var i,t,r,p;if(!u){var h=function(){ao.current={id:Be.id,triggerMs:n}},m=null,S=null;for(var R in di){var x=di[R].find(function(e){return e.id===o});if(x){m=R,S=x;break}}if(S&&m){var _=ui.findIndex(function(e){return e.id===m}),b=ai.findIndex(function(e){return e.id===m}),y=-1===_&&-1!==b,C=v(ui,S.id),E=v(ai,S.id);if(C&&!E&&!y){var A=C.split("-"),B=Number(A[0]);if(Pe){var w=null===(t=null===(i=ui[B])||void 0===i?void 0:i.refIndexes)||void 0===t?void 0:t[0],I=ai.findIndex(function(e){return e.selfIndex===w});-1!==I&&(B=I)}E=e.__spreadArray([B],A.slice(1),!0).join("-")}if(C||E){var T=C?Number(C.split("-")[0]):_,D=E?Number(E.split("-")[0]):b,O=D>=0?D:E?Number(E.split("-")[0]):-1,F=ui[T],j=ai[O],k=F&&!F.title&&!F.content,P=j&&!j.title&&!j.content,N=y||(!C&&!!E||k&&!P);if(N){if(!(Pe?!!bo.current["right-".concat(D)]:!!bo.current[String(D)])&&D>=0)return nt(D,"right"),void(c=setTimeout(g,200))}else if(!(Pe?!!bo.current["left-".concat(T)]:!!bo.current[String(T)])&&T>=0)return nt(T,"left"),void(c=setTimeout(g,200));var L=C||"",M=E||"",q="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l).concat(s.DEVIATION_BADGE_SEPARATOR).concat(L).concat(s.DEVIATION_BADGE_SEPARATOR).concat(M),H="".concat(S.id).concat(s.DEVIATION_BADGE_SEPARATOR).concat(l);if(!f){it(q),f=!0,a=0;var V=function(){var e,n,i=null===(e=bi.current[H])||void 0===e?void 0:e.current,t=null===(n=yi.current[H])||void 0===n?void 0:n.current;return N||!i&&!!t?t:i};return null==d||d(),void(c=setTimeout(function(){var e,n,i,t,o,r,l;u||(e=V,n=function(){u||(d=null,g())},t=0,o=null,r=null,l=function(){if(!u){var s=e();if(s&&0!==s.getBoundingClientRect().height){var a=s.getBoundingClientRect(),c=a.top,d=a.height,f=null!==o&&Math.abs(c-o)<.5,v=null!==r&&Math.abs(d-r)<.5;if(f&&v){if(++t>=5)return void n()}else t=0;o=c,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),d=function(){return cancelAnimationFrame(i)})},300))}var z=null===(r=bi.current[H])||void 0===r?void 0:r.current,G=null===(p=yi.current[H])||void 0===p?void 0:p.current;if(z||G){var W=N||!z&&!!G,K=W?G:z,U=Pe?W?bn.current:Bn.current:xn.current;if(K&&U){var Y=K.getBoundingClientRect();if(0!==Y.height){var J=U.getBoundingClientRect(),X=Y.top-J.top+U.scrollTop-J.height/2+Y.height/2,$=(null==C?void 0:C.includes("-"))||(null==E?void 0:E.includes("-")),Q=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,i,t,o,r,a,c,d,f,v;return e.__generator(this,function(g){switch(g.label){case 0:return u?[2]:(h(),n=K instanceof Element?window.getComputedStyle(K).color:"",[z,G].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[z,G].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(a=S.evaluationResult)||void 0===a?void 0:a.deviations)||void 0===c?void 0:c[l])||S,t=(null===(d=S.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||S.evaluation_outputs,!!z&&!!G?(r=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},Pe?[4,Promise.all([Bn.current?r(s.waitForScrollIdle(Bn.current),600):Promise.resolve(),bn.current?r(s.waitForScrollIdle(bn.current),600):Promise.resolve()])]:[3,2]):(o=W?(null===(f=yi.current[$?H:D])||void 0===f?void 0:f.current)||G:(null===(v=bi.current[$?H:T])||void 0===v?void 0:v.current)||z,lo(o,function(){Mn({open:!0,anchorEl:o,displayImpact:Be.displayImpact,summary:e.__assign(e.__assign({},i),{evaluation_outputs:t})})},{skipScroll:!0}),null==we||we(),[2]));case 1:g.sent(),g.label=2;case 2:return Yi(q,!1,{toggleIfSame:!1,sourceSide:y?"right":"left",onReady:function(){var n,t,o,r;h();var l=W?(null===(n=yi.current[H])||void 0===n?void 0:n.current)||G:(null===(t=bi.current[H])||void 0===t?void 0:t.current)||z,s=(null===(o=bi.current[H])||void 0===o?void 0:o.current)||z,u=(null===(r=yi.current[H])||void 0===r?void 0:r.current)||G;s&&(s.style.scrollMarginTop="150px",s.scrollIntoView({behavior:"smooth",block:"start"})),u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),Mn({open:!0,anchorEl:l,displayImpact:Be.displayImpact,summary:e.__assign({},i)}),null==we||we()}}),[2]}})})};Math.abs(U.scrollTop-X)<=2?Q():s.scrollAndWait(U,X,Q)}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}else++a<2?c=setTimeout(g,100):h()}};return c=setTimeout(g,100),function(){u=!0,c&&clearTimeout(c),null==d||d()}}}},[Be,di,ui,ai,Pe,Xi,Yi,Mn,Ot]),i.useEffect(function(){var n,i,t;if(Ln.open){var o=Ln.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(bi.current)||r(yi.current);if(l){var s=(null===(i=yi.current[l])||void 0===i?void 0:i.current)||(null===(t=bi.current[l])||void 0===t?void 0:t.current);s&&s.isConnected&&Mn(function(n){return e.__assign(e.__assign({},n),{anchorEl:s})})}}}},[Ln.open,Ln.anchorEl,nn,Je,Xi]);var fo=Dn.open,vo=Dn.sectionIdx,go=Dn.isOrphan,po=Dn.badgeStyle,ho=Dn.anchorEl,mo=Dn.sectionAnchorEl;i.useEffect(function(){var n;if(be.isStreamingEnabled&&fo&&null!=vo&&vo!==at){var i="string"==typeof vo?vo.split(s.DEVIATION_BADGE_SEPARATOR)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var s=t(l.subsections,n);if(s)return s}}return null},o=i&&"string"==typeof i?t(ui,i):null,r=i&&"string"==typeof i?t(ai,i):null,l="number"==typeof vo?ui[vo]||null:o||i&&((null===(n=null==pe?void 0:pe.nodes)||void 0===n?void 0:n[i])||(null==pe?void 0:pe[i]))||null,u="number"==typeof vo?ai[vo]||null:r,a=wt(ho,l,u,vo,go,po);On(function(n){return n.open?s.safeStringify(n.cognitiveData)===s.safeStringify(a.cognitiveData)&&s.safeStringify(n.deviationData)===s.safeStringify(a.deviationData)&&n.sectionTitle===a.sectionTitle&&n.refSectionTitle===a.refSectionTitle?n:e.__assign(e.__assign(e.__assign({},n),a),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[fo,vo,go,po,ho,mo,ui,ai,wt]);var So=i.useCallback(function(e){var i=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,s=void 0===l?"left":l,u=e.parentNodeId,a=void 0===u?"":u,c=e.sectionOffset;return n.jsx(x.default,{section:i,keyPath:t,depth:r,columnKey:s,parentNodeId:a,sectionOffset:c})},[]),Ro=i.useMemo(function(){return ui.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(_.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(i))})},[ui]),xo=i.useMemo(function(){return ai.map(function(e,i){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Pe?null:n.jsx(b.default,{section:e,idx:i},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(i))})},[ai]),_o=i.useRef(It);i.useEffect(function(){_o.current=It},[It]);var bo=i.useRef(Xi);i.useEffect(function(){bo.current=Xi},[Xi]);var yo=i.useRef(so);i.useEffect(function(){yo.current=so},[so]);var Co=i.useRef(no);i.useEffect(function(){Co.current=no},[no]);var Eo=i.useRef(nt);i.useEffect(function(){Eo.current=nt},[nt]);var Ao=i.useRef(et);i.useEffect(function(){Ao.current=et},[et]);var Bo=i.useRef(So);i.useEffect(function(){Bo.current=So},[So]);var wo=i.useRef(Ui);i.useEffect(function(){wo.current=Ui},[Ui]);var Io=i.useMemo(function(){return{isGuidelineMode:ri,maintainRelativeOrder:!!Pe,showDeviationBadges:qe,isProposingFix:Te,proposingFixNodeId:De,isRedlineFlow:Oe,isSideBySide:Oi,activeSideBySideSection:Li,scrollSyncLocked:nn,toggleScrollSyncLocked:ot,summaryPopupAnchorEl:Ln.anchorEl,connectedSections:Je,proposedSections:ui,existingSections:ai,deviationNumberRegistry:fi,deviationParentRegistry:vi,treeData:pe,displayConfig:be,resolvedMarkdownStyles:Rn,unifiedNumbering:rt,expandedSections:Xi,expandedSubSections:Qi,setExpandedSubSections:Zi,getSectionCompareStyle:Nt,getSubSectionCompareStyle:Lt,getBadgeRef:Ti,getSectionRowRef:wi,getSubSectionRef:Ii,sectionLeftRefs:xi,sectionRightRefs:_i,sectionRowRefs:Bi,sectionRightRowRefs:Ci,subSectionLeftRefs:Ei,subSectionRightRefs:Ai,lhsBadgeRefs:bi,rhsBadgeRefs:yi,openMoreFunctionsPopup:ht,handleOpenSummaryPopup:mt,openSummaryPopup:mt,handleCloseSummaryPopup:St,toggleSection:Rt,handleSubSectionToggle:xt,renderSubSectionAccordion:_t,resetSideBySide:bt,setConnectedSections:Xe,setConnectedLines:Ze,cachedConnectedPositions:fn,showDeviationNavigation:oo,showOpenNodeRef:ro,deviationNodeIdToView:null==Be?void 0:Be.id,deviationTargetParentId:uo}},[ri,Pe,qe,Te,De,Oe,Oi,Li,nn,ot,Ln.anchorEl,Je,ui,ai,fi,be,Rn,rt,Xi,Qi,Zi,Nt,Lt,Ti,wi,Ii,oo,ro,Be,uo]);return n.jsx(C.CompareContextProvider,e.__assign({value:Io},{children:n.jsxs(t.Box,e.__assign({ref:_n,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[Ve&&n.jsx(t.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(f.default,{})})),Ln.open&&n.jsx(y.default,{open:Ln.open,anchorEl:Ln.anchorEl,containerEl:jt.current,clipTopEl:ln.current,scrollContainerEl:xn.current,onClose:no,summary:Ln.summary,displayImpact:Ln.displayImpact,isScrollLocked:nn}),n.jsx(d.default,{open:Fn.open,anchorEl:Fn.anchorEl,maintainRelativeOrder:!!Pe,sectionTitle:Fn.sectionTitle,referenceSectionTitle:Fn.refSectionTitle,onClose:Kn,onOpenCognitiveCompare:zn,onOpenSideBySide:eo,onConnect:Tt,isConnected:io,isOrphan:!ri&&Fn.isOrphan}),Dn.open&&n.jsx(c.default,{open:Dn.open,popupRef:Vn,position:kn,popupConfig:Ce,onClose:function(){Pn(null),On(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Hn(null)},markdownStyles:Re,sectionTitle:ei,referenceSectionTitle:ii,cognitiveData:Dn.cognitiveData,anchorEl:Dn.anchorEl,sectionAnchorEl:Dn.sectionAnchorEl,scrollContainerEl:xn.current,badgeStyle:Dn.badgeStyle,docData:Dn.docData,deviationData:Dn.deviationData,isLoading:Dn.isLoading}),n.jsx(t.Snackbar,e.__assign({open:!!We,autoHideDuration:8e3,onClose:function(){return Ke(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(t.Alert,e.__assign({onClose:function(){return Ke(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:We}))})),n.jsx(R.default,{componentHeaderText:ge,displayConfig:be,maintainRelativeOrder:Pe,onCollapseAll:Ut,showCollapseAll:Yt,onToggleView:function(e){ze(!0),setTimeout(function(){Ne(!e),null==ye||ye(!e),tn(!1),Ui(),qn(),Xe(new Set),Ze([]),fn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ze(!1)},600)})})},50)}}),n.jsx(t.Box,e.__assign({ref:xn,onScroll:Kt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Pe?"visible":"auto",borderTop:st&&ut?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(t.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Pe?{flex:1}:{})},{children:n.jsxs(t.Box,e.__assign({ref:rn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(I.default,{svgContainerRef:on,svgDimensions:Wt,isResizing:ki,overallConnector:zt,rootDeviationStyle:ft,lines:Ht,isSideBySide:Oi,activeSideBySideSection:Li,isArrowVisible:Fi,maintainRelativeOrder:Pe,proposedSections:ui,existingSections:ai,cognitivePopup:Dn,activeBadgeId:Nn,closeCognitivePopup:Wn,setActiveBadgeId:Hn,openCognitivePopupFromState:Gn,buildSectionPopupState:wt,connectedLines:Qe,pathRefs:dn}),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Pe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(t.Box,e.__assign({ref:ln,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(t.Tooltip,e.__assign({title:Qn,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Qn}))}))})),n.jsxs(t.Box,e.__assign({ref:Bn,onScroll:Kt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},Pe?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:En,style:{width:"100%",height:"0px",flexShrink:0}}),pi&&Ro,n.jsx("div",{ref:An,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(t.Box,e.__assign({ref:jt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(t.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(t.Box,e.__assign({onClick:function(n){n.stopPropagation(),Dn.open&&Nn===at?Wn():(Hn(at),Gn(wt(n.currentTarget,{title:"",content:"",evaluationResult:ct,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,at,!0,e.__assign(e.__assign({},ft),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:ft.badgeBg,color:ft.badgeText,border:"1px solid ".concat(ft.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=dt?dt:n.jsx(v.default,{}),n.jsx(t.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:Dn.open&&Nn===at?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(t.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Pe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ni&&n.jsx(l.default,{sections:11}),n.jsx(t.Box,e.__assign({ref:sn,sx:e.__assign({p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},Pe?e.__assign({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},ri?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:n.jsx(t.Tooltip,e.__assign({title:ti,placement:"top"},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ti}))}))})),n.jsxs(t.Box,e.__assign({ref:bn,onScroll:Kt,sx:e.__assign({p:ri?"0px":"12px",display:"flex",flexDirection:"column"},Pe?e.__assign(e.__assign({maxHeight:"calc(100vh - 250px)"},!ri&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[n.jsx("div",{ref:yn,style:{width:"100%",height:"0px",flexShrink:0}}),ri?n.jsx(T.default,{guidelinesData:je,deviationData:Ae,connectedSections:Je,proposedSections:ui}):pi&&xo,n.jsx("div",{ref:Cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),a=require("react-markdown"),o=require("rehype-raw"),l=require("../../CognitiveCompareConfig.js"),n=require("../../CognitiveComparehelpers.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=u(a),s=u(o);exports.default=function(a){var o=a.guidelinesData,u=a.deviationData,c=a.connectedSections,v=a.proposedSections,g=Array.from(c)[0],p=t.useMemo(function(){var r;if(null==g||!u)return{targetHighlights:[],labelColor:""};var t="";"number"==typeof g?t=(null===(r=v[g])||void 0===r?void 0:r.nodeId)||"":"string"==typeof g&&(t=g.includes(n.DEVIATION_BADGE_SEPARATOR)?g.split(n.DEVIATION_BADGE_SEPARATOR)[0]:g.split("::")[0].split(":")[0]);var i=u[t];if(!i)return{targetHighlights:[],labelColor:""};var a=[],o=i.evaluation_result||{},l="";return Object.values(o).forEach(function(r){var t,i,o,u,d;(null===(t=null==r?void 0:r.deviation_highlights)||void 0===t?void 0:t.rulebook_guidelines)&&(a=e.__spreadArray(e.__spreadArray([],a,!0),r.deviation_highlights.rulebook_guidelines,!0),l=(null===(o=null===(i=r.evaluation_outputs)||void 0===i?void 0:i.metadata)||void 0===o?void 0:o.label_color)?n.generateColorPalette(null===(d=null===(u=r.evaluation_outputs)||void 0===u?void 0:u.metadata)||void 0===d?void 0:d.label_color).bg:"")}),{targetHighlights:a.filter(Boolean),labelColor:l}},[g,u,v]),_=p.targetHighlights,f=p.labelColor,h=t.useMemo(function(){var e,r,t=(null===(r=null===(e=null==o?void 0:o.data)||void 0===e?void 0:e.artifactData)||void 0===r?void 0:r.userStorySnapshot)||[],i="";return t.forEach(function(e){var r;e.title&&(i+="# ".concat(e.title,"\n\n")),e.value&&(i+="".concat(e.value,"\n\n")),(null===(r=e.sub_features)||void 0===r?void 0:r.length)&&e.sub_features.forEach(function(e){e.title&&(i+="#### ".concat(e.title,"\n\n")),e.value&&(i+="".concat(e.value,"\n\n"))})}),_.length>0&&_.forEach(function(e,r){var t=e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a=new RegExp("(".concat(t,")"),"g");i=i.replace(a,'<mark id="guideline-target-'.concat(r,'" style="background-color: ').concat(f.length?f:"#FEF08A",'; border-radius: 3px; padding: 2px;">$1</mark>'))}),i},[o,_]);return r.jsx(i.Box,e.__assign({sx:e.__assign(e.__assign({padding:"0px 12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},l.SHARED_MARKDOWN_STYLES),{overflow:"visible"})},{children:r.jsx(d.default,e.__assign({rehypePlugins:[s.default]},{children:h}))}))};
2
+ //# sourceMappingURL=GuidelinePanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuidelinePanel.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CompareContext.js"),r=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function u(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var s=u(i);exports.default=function(u){var c,v,f,p,g,x,h,I,m,_,y,b,A,S=u.section,R=u.idx,w=u.columnKey,E=u.colRef,O=u.mb,B=void 0===O?1:O,j=u.isExpanded,C=u.onToggle,T=u.navigation,D=u.parentNodeId,F=void 0===D?"":D,k=d.useCompareContext(),M=k.showOpenNodeRef,N=k.resolvedMarkdownStyles,P=k.maintainRelativeOrder,V=k.showDeviationBadges,W=void 0!==V&&V,q=k.renderSubSectionAccordion,G=k.treeData,L=k.proposedSections,K=k.existingSections,z=k.deviationNumberRegistry,H=k.deviationParentRegistry,U=k.getBadgeRef,X=k.openSummaryPopup,Y=k.getSectionCompareStyle,J=k.connectedSections,Q=k.openMoreFunctionsPopup,Z=k.isProposingFix,$=k.proposingFixNodeId,nn=k.isRedlineFlow,en=k.isSideBySide,on=k.activeSideBySideSection,tn=k.scrollSyncLocked,ln=k.unifiedNumbering,dn=k.toggleScrollSyncLocked,rn=k.summaryPopupAnchorEl,an="".concat(en?"1":"0","-").concat(String(null!=on?on:"")),un=(null===(c=S.displayTitle)||void 0===c||c)&&r.hasValue(S.title),sn=!(!Z||!$||"left"!==w||S.id!==$&&S.nodeId!==$),cn=r.hasMeaningfulRedlineTags(S.content),vn="boolean"==typeof nn?nn:cn,fn=cn,pn=vn&&cn,gn=pn?r.stripRedlineTags(S.content):S.content,xn=pn?S.content:void 0,hn=(null===(v=S.displayContent)||void 0===v||v||cn)&&r.hasValue(S.content),In=!un&&!hn,mn=S.title;un||(mn=hn?"No Title Found":"No Matching Section Found");var _n=S.evaluationResult;if(!_n&&"right"===w)if(P){var yn=null===(f=S.refIndexes)||void 0===f?void 0:f[0],bn=L.find(function(n){return n.selfIndex===yn});_n=null==bn?void 0:bn.evaluationResult}else _n=null===(p=L[R])||void 0===p?void 0:p.evaluationResult;var An=null===(g=null==G?void 0:G.input_index_map)||void 0===g?void 0:g[0],Sn=null===(x=null==G?void 0:G.input_index_map)||void 0===x?void 0:x[1],Rn="left"===w?Sn:An,wn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var d=wn(l.subsections,e);if(d)return d}}return null},En="left"===w?S:wn(L,S.id),On="right"===w?S:wn(K,S.id),Bn=s.default.useMemo(function(){if(!P)return 0;var n=1/0,e=function(i,o,t,l){var d;if(i){var a=i.nodeId||i.id;if(l&&"right"===w){var u=L.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(i.selfIndex)});u.length>0&&(a=u[0].nodeId||u[0].id)}var s=i.nodeId||i.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id),c=(null===(d=i.evaluationResult)||void 0===d?void 0:d.deviations)||{};Object.keys(c).forEach(function(e){var i="".concat(a).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e),o=null==z?void 0:z[i];null!=o&&o<n&&(n=o);var t="".concat(s).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e),l=null==z?void 0:z[t];null!=l&&l<n&&(n=l)});for(var v=i.subsections||[],f=(null==o?void 0:o.subsections)||[],p=(null==t?void 0:t.subsections)||[],g=Math.max(v.length,f.length,p.length),x=0;x<g;x++)e(v[x],f[x],p[x],!1)}};return e(S,En,On,!0),n!==1/0?n-1:0},[S,En,On,w,z,P,L]);if(P)if("left"===w){var jn=null===(h=S.refIndexes)||void 0===h?void 0:h[0],Cn=K.findIndex(function(n){return n.selfIndex===jn});On=-1!==Cn?K[Cn]:wn(K,S.id)}else{var Tn=null===(I=S.refIndexes)||void 0===I?void 0:I[0],Dn=L.findIndex(function(n){return n.selfIndex===Tn});En=-1!==Dn?L[Dn]:wn(L,S.id)}var Fn="left"===w?!On:!En,kn=_n||(null==En?void 0:En.evaluationResult)||(null==On?void 0:On.evaluationResult),Mn=null!==(y=null===(_=null===(m=null==kn?void 0:kn.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR,Nn=r.generateColorPalette(Mn).highlightBg,Pn=(null==kn?void 0:kn.deviations)||{},Vn=S.nodeId||S.id;if(P&&"left"!==w){var Wn=L.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(S.selfIndex)});Wn.length>0?Vn=Wn[0].nodeId||Wn[0].id:(null==En?void 0:En.id)&&(Vn=En.nodeId||En.id)}var qn=Object.keys(Pn)[0],Gn=qn?"".concat(Vn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(qn):null,Ln=Gn?null==H?void 0:H[Gn]:null,Kn=R+1;if(P&&ln){var zn="left"===w?ln.leftNums.get(null==S?void 0:S.id):ln.rightNums.get(null==S?void 0:S.id);Fn&&void 0!==zn?Kn=zn:null!=Ln&&Ln>=0?Kn=Ln:void 0!==zn&&(Kn=zn)}else null!=Ln&&Ln>=0&&(Kn=Ln);var Hn=Object.entries(Pn).map(function(n){var e=n[0],i=n[1],o="".concat(Vn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:z[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});Hn.sort(function(n,e){return n.currentIndex-e.currentIndex});var Un,Xn=Hn.map(function(e){var i,o,t,l,d,a,u=e.deviationKey,s=e.deviationMap,c=e.refId,v=e.currentIndex;P&&void 0!==Bn&&(v-=Bn);var f=s[F],p=r.isMissingStr(f);if(p)f="";else if(!f)return null;var g=R,x=R;if(P)if("left"===w){var h=null===(i=S.refIndexes)||void 0===i?void 0:i[0],I=K.findIndex(function(n){return n.selfIndex===h});if(-1!==I)x=I;else{var m=K.findIndex(function(n){return n.id===S.id||n.nodeId===S.nodeId||n.contentId===S.contentId});x=-1!==m?m:R}}else{var _=null===(o=S.refIndexes)||void 0===o?void 0:o[0],y=L.findIndex(function(n){return n.selfIndex===_});if(-1!==y)g=y;else g=-1!==(j=L.findIndex(function(n){return n.id===S.id||n.nodeId===S.nodeId||n.contentId===S.contentId}))?j:R}var b="".concat(Vn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(u).concat(r.DEVIATION_BADGE_SEPARATOR).concat(g).concat(r.DEVIATION_BADGE_SEPARATOR).concat(x),A=s[Rn],E=Fn||r.isMissingStr(A),O="".concat(Kn,".").concat(v),B=R;if("right"===w&&P){var j,C=null===(t=S.refIndexes)||void 0===t?void 0:t[0],T=L.findIndex(function(n){return n.selfIndex===C});if(-1!==T)B=T;else-1!==(j=L.findIndex(function(n){return n.id===S.id||n.nodeId===S.nodeId||n.contentId===S.contentId}))&&(B=j)}var D=Y?Y(B):null,k=(null==s?void 0:s.evaluation_outputs)||(null==kn?void 0:kn.evaluation_outputs),M=null!==(l=null==k?void 0:k.output_value)&&void 0!==l?l:null,N=null!==(a=null===(d=null==k?void 0:k.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:Mn,V=r.generateColorPalette(N),W=D?n.__assign(n.__assign({},D),{badgeBg:V.badgeBg,badgeBorder:V.badgeBorder,badgeText:V.badgeText}):n.__assign({},V),q=(null==s?void 0:s.deviation_summary)?{deviation_summary:s.deviation_summary,deviation_title:(null==s?void 0:s.deviation_title)||(null==kn?void 0:kn.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==kn?void 0:kn.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==kn?void 0:kn.deviation_explanation),evaluation_outputs:k,cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==kn?void 0:kn.cognitive_decisioning)}:null,G=0,z=gn||"";if(f&&z){var H=z.split(/\n{2,}/),Z=H.findIndex(function(n){return n.includes(f)});if(-1!==Z){var $=Object.entries(Pn).filter(function(n){n[0];var e=n[1][F];return e&&H[Z].includes(e)}).sort(function(n,e){return H[Z].indexOf(n[1][F])-H[Z].indexOf(e[1][F])}),nn=$.filter(function(n){n[0];var e=n[1][F];return e&&(e.includes(f)||f.includes(e))});nn.length>1&&(G=Math.max(0,nn.findIndex(function(n){return n[0]===u})))}}var ln=U(w,c);return{id:c,actionId:b,label:O,highlight:f,side:w,style:W,stackIndex:G,score:M,isConnected:null==J?void 0:J.has(b),showScrollLockToggle:(null==J?void 0:J.has(b))||en&&on===b||!!rn&&rn===ln.current,scrollSyncLocked:tn,toggleScrollSyncLocked:dn,isOrphan:E,isMissingClause:p,badgeRef:ln,onClick:function(n){n.stopPropagation(),Q&&Q(n,En||{id:"orphan-left",title:"",content:""},E,On||{id:"orphan-right",title:"",content:""},b,W)},onSummaryClick:function(n){n.stopPropagation(),X(n,b,E,q)}}}).filter(Boolean),Yn=W||!vn&&sn?Xn:[],Jn=Xn.map(function(n){return n.highlight}).filter(Boolean),Qn=S.id&&w===(null==T?void 0:T.columnKey)?T:null,Zn=s.default.useRef(!1);return i.useEffect(function(){j||(Zn.current=!1)},[j]),e.jsxs(o.Box,n.__assign({ref:E,sx:{mb:B,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[j&&(null==Qn?void 0:Qn.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==Qn?void 0:Qn.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===w?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===w?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronUp,{color:(null===(b=null==Qn?void 0:Qn.showAboveRef)||void 0===b?void 0:b.current)?window.getComputedStyle(Qn.showAboveRef.current).color:void 0})}))})),e.jsxs(o.Accordion,n.__assign({disableGutters:!0,expanded:!In&&j,onChange:function(){In||(C(),M.current=S.id)},sx:{boxShadow:"none",border:In?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:In?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(o.AccordionSummary,n.__assign({expandIcon:In?null:e.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:In?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:un&&e.jsx(o.Tooltip,n.__assign({title:mn,placement:"top"},{children:e.jsx(o.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:In?"#94A3B8":"#19213D",fontWeight:In?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Un=mn,Un?r.safeStringify(Un).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,i){return n.startsWith("**")&&n.endsWith("**")?e.jsx("strong",{children:n.slice(2,-2)},i):e.jsx(s.default.Fragment,{children:n},i)}):null)}))}))})),!In&&e.jsxs(o.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[hn&&e.jsx(l.MemoizedMarkdown,{content:gn,overlayContent:xn,sxStyles:N,highlights:Jn,maintainRelativeOrder:P,highlightBg:Nn,suppressHighlightBg:fn,deviationBadges:Yn,collisionKey:an}),(S.subsections||[]).map(function(n,e){return q({section:n,keyPath:"".concat(R,"-").concat(e),depth:0,columnKey:w,parentNodeId:F,sectionOffset:Bn})})]}))]})),j&&(null==Qn?void 0:Qn.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==Qn?void 0:Qn.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===w?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===w?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronDown,{color:(null===(A=null==Qn?void 0:Qn.showBelowRef)||void 0===A?void 0:A.current)?window.getComputedStyle(Qn.showBelowRef.current).color:void 0})}))}))]}),"".concat(w,"-sec-").concat(R))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CompareContext.js"),r=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=s(i);exports.default=function(s){var c,v,f,p,g,x,h,I,m,_,y,b,A,S,R,w=s.section,j=s.idx,E=s.columnKey,B=s.colRef,C=s.mb,O=void 0===C?1:C,D=s.isExpanded,F=s.onToggle,T=s.navigation,k=s.parentNodeId,M=void 0===k?"":k,N=d.useCompareContext(),P=N.showOpenNodeRef,V=N.resolvedMarkdownStyles,W=N.maintainRelativeOrder,q=N.showDeviationBadges,G=void 0!==q&&q,L=N.renderSubSectionAccordion,z=N.treeData,K=N.proposedSections,H=N.existingSections,U=N.deviationNumberRegistry,X=N.deviationParentRegistry,Y=N.getBadgeRef,J=N.openSummaryPopup,Q=N.getSectionCompareStyle,Z=N.connectedSections,$=N.openMoreFunctionsPopup,nn=N.isProposingFix,en=N.proposingFixNodeId,on=N.isRedlineFlow,tn=N.isSideBySide,ln=N.activeSideBySideSection,dn=N.scrollSyncLocked,rn=N.unifiedNumbering,an=N.toggleScrollSyncLocked,sn=N.summaryPopupAnchorEl,un="".concat(tn?"1":"0","-").concat(String(null!=ln?ln:"")),cn=(null===(c=w.displayTitle)||void 0===c||c)&&r.hasValue(w.title),vn=!(!nn||!en||"left"!==E||w.id!==en&&w.nodeId!==en),fn=r.hasMeaningfulRedlineTags(w.content),pn="boolean"==typeof on?on:fn,gn=fn,xn=pn&&fn,hn=xn?r.stripRedlineTags(w.content):w.content,In=xn?w.content:void 0,mn=(null===(v=w.displayContent)||void 0===v||v||fn)&&r.hasValue(w.content),_n=!cn&&!mn,yn=w.title;cn||(yn=mn?"No Title Found":"No Matching Section Found");var bn=w.evaluationResult;if(!bn&&"right"===E)if(W){var An=null===(f=w.refIndexes)||void 0===f?void 0:f[0],Sn=K.find(function(n){return n.selfIndex===An});bn=null==Sn?void 0:Sn.evaluationResult}else bn=null===(p=K[j])||void 0===p?void 0:p.evaluationResult;var Rn=null===(g=null==z?void 0:z.input_index_map)||void 0===g?void 0:g[0],wn=null===(x=null==z?void 0:z.input_index_map)||void 0===x?void 0:x[1],jn="left"===E?wn:Rn,En=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var d=En(l.subsections,e);if(d)return d}}return null},Bn="left"===E?w:En(K,w.id),Cn="right"===E?w:En(H,w.id),On=u.default.useMemo(function(){if(!W)return 0;var n=1/0,e=function(i,o,t,l){var d;if(i){var a=i.nodeId||i.id;if(l&&"right"===E){var s=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(i.selfIndex)});s.length>0&&(a=s[0].nodeId||s[0].id)}var u=i.nodeId||i.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id),c=(null===(d=i.evaluationResult)||void 0===d?void 0:d.deviations)||{};Object.keys(c).forEach(function(e){var i="".concat(a).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e),o=null==U?void 0:U[i];null!=o&&o<n&&(n=o);var t="".concat(u).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e),l=null==U?void 0:U[t];null!=l&&l<n&&(n=l)});for(var v=i.subsections||[],f=(null==o?void 0:o.subsections)||[],p=(null==t?void 0:t.subsections)||[],g=Math.max(v.length,f.length,p.length),x=0;x<g;x++)e(v[x],f[x],p[x],!1)}};return e(w,Bn,Cn,!0),n!==1/0?n-1:0},[w,Bn,Cn,E,U,W,K]);if(W)if("left"===E){var Dn=null===(h=w.refIndexes)||void 0===h?void 0:h[0],Fn=H.findIndex(function(n){return n.selfIndex===Dn});Cn=-1!==Fn?H[Fn]:En(H,w.id)}else{var Tn=null===(I=w.refIndexes)||void 0===I?void 0:I[0],kn=K.findIndex(function(n){return n.selfIndex===Tn});Bn=-1!==kn?K[kn]:En(K,w.id)}var Mn="left"===E?!Cn:!Bn,Nn=bn||(null==Bn?void 0:Bn.evaluationResult)||(null==Cn?void 0:Cn.evaluationResult),Pn=null!==(y=null===(_=null===(m=null==Nn?void 0:Nn.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR,Vn=r.generateColorPalette(Pn).highlightBg,Wn=(null==Nn?void 0:Nn.deviations)||{},qn=w.nodeId||w.id;if(W&&"left"!==E){var Gn=K.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(w.selfIndex)});Gn.length>0?qn=Gn[0].nodeId||Gn[0].id:(null==Bn?void 0:Bn.id)&&(qn=Bn.nodeId||Bn.id)}var Ln=Object.keys(Wn)[0],zn=Ln?"".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(Ln):null,Kn=zn?null==X?void 0:X[zn]:null,Hn=j+1;if(W&&rn){var Un="left"===E?rn.leftNums.get(null==w?void 0:w.id):rn.rightNums.get(null==w?void 0:w.id);Mn&&void 0!==Un?Hn=Un:null!=Kn&&Kn>=0?Hn=Kn:void 0!==Un&&(Hn=Un)}else null!=Kn&&Kn>=0&&(Hn=Kn);var Xn=Object.entries(Wn).map(function(n){var e=n[0],i=n[1],o="".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:U[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});Xn.sort(function(n,e){return n.currentIndex-e.currentIndex});var Yn,Jn,Qn=Xn.map(function(e){var i,o,t,l,d,a,s=e.deviationKey,u=e.deviationMap,c=e.refId,v=e.currentIndex;W&&void 0!==On&&(v-=On);var f=u[M],p=r.isMissingStr(f);if(p)f="";else if(!f)return null;var g=j,x=j;if(W)if("left"===E){var h=null===(i=w.refIndexes)||void 0===i?void 0:i[0],I=H.findIndex(function(n){return n.selfIndex===h});if(-1!==I)x=I;else{var m=H.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId});x=-1!==m?m:j}}else{var _=null===(o=w.refIndexes)||void 0===o?void 0:o[0],y=K.findIndex(function(n){return n.selfIndex===_});if(-1!==y)g=y;else g=-1!==(C=K.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId}))?C:j}var b="".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(s).concat(r.DEVIATION_BADGE_SEPARATOR).concat(g).concat(r.DEVIATION_BADGE_SEPARATOR).concat(x),A=u[jn],S=Mn||r.isMissingStr(A),R="".concat(Hn,".").concat(v),B=j;if("right"===E&&W){var C,O=null===(t=w.refIndexes)||void 0===t?void 0:t[0],D=K.findIndex(function(n){return n.selfIndex===O});if(-1!==D)B=D;else-1!==(C=K.findIndex(function(n){return n.id===w.id||n.nodeId===w.nodeId||n.contentId===w.contentId}))&&(B=C)}var F=Q?Q(B):null,T=(null==u?void 0:u.evaluation_outputs)||(null==Nn?void 0:Nn.evaluation_outputs),k=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,N=null!==(a=null===(d=null==T?void 0:T.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:Pn,P=r.generateColorPalette(N),V=F?n.__assign(n.__assign({},F),{badgeBg:P.badgeBg,badgeBorder:P.badgeBorder,badgeText:P.badgeText}):n.__assign({},P),q=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Nn?void 0:Nn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Nn?void 0:Nn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Nn?void 0:Nn.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Nn?void 0:Nn.cognitive_decisioning)}:null,G=0,L=hn||"";if(f&&L){var z=L.split(/\n{2,}/),U=z.findIndex(function(n){return n.includes(f)});if(-1!==U){var X=Object.entries(Wn).filter(function(n){n[0];var e=n[1][M];return e&&z[U].includes(e)}).sort(function(n,e){return z[U].indexOf(n[1][M])-z[U].indexOf(e[1][M])}),nn=X.filter(function(n){n[0];var e=n[1][M];return e&&(e.includes(f)||f.includes(e))});nn.length>1&&(G=Math.max(0,nn.findIndex(function(n){return n[0]===s})))}}var en=Y(E,c);return{id:c,actionId:b,label:R,highlight:f,side:E,style:V,stackIndex:G,score:k,isConnected:null==Z?void 0:Z.has(b),showScrollLockToggle:(null==Z?void 0:Z.has(b))||tn&&ln===b||!!sn&&sn===en.current,scrollSyncLocked:dn,toggleScrollSyncLocked:an,isOrphan:S,isMissingClause:p,badgeRef:en,onClick:function(n){n.stopPropagation(),$&&$(n,Bn||{id:"orphan-left",title:"",content:""},S,Cn||{id:"orphan-right",title:"",content:""},b,V)},onSummaryClick:function(n){n.stopPropagation(),J(n,b,S,q)}}}).filter(Boolean),Zn=G||!pn&&vn?Qn:[],$n=Qn.map(function(n){return n.highlight}).filter(Boolean),ne=w.id&&E===(null==T?void 0:T.columnKey)?T:null,ee=u.default.useRef(!1);return i.useEffect(function(){D||(ee.current=!1)},[D]),e.jsxs(o.Box,n.__assign({ref:B,sx:{mb:O,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==ne?void 0:ne.showAbove)&&e.jsx("div",n.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ne?void 0:ne.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===E?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronUp,{color:(null===(b=null==ne?void 0:ne.showAboveRef)||void 0===b?void 0:b.current)?window.getComputedStyle(ne.showAboveRef.current).color:void 0})}))})),e.jsxs(o.Accordion,n.__assign({disableGutters:!0,expanded:!_n&&D,onChange:function(){_n||(F(),P.current=w.id)},sx:{boxShadow:"none",border:_n?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:_n?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(o.AccordionSummary,n.__assign({expandIcon:_n?null:e.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:_n?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:cn&&e.jsx(o.Tooltip,n.__assign({title:yn,placement:"top"},{children:e.jsx(o.Typography,n.__assign({component:"div",sx:{fontSize:"12px",color:_n?"#94A3B8":"#19213D",fontWeight:_n?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Yn=yn,Jn="left"===E&&(null!==(S=null===(A=null==w?void 0:w.refContentIds)||void 0===A?void 0:A.length)&&void 0!==S?S:1)>1,void 0===Jn&&(Jn=!1),Yn?r.safeStringify(Yn).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,o){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},o):e.jsxs("div",n.__assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[e.jsx("span",{children:i}),Jn&&e.jsx("span",n.__assign({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),o)}):null)}))}))})),!_n&&e.jsxs(o.AccordionDetails,n.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[mn&&e.jsx(l.MemoizedMarkdown,{content:hn,overlayContent:In,sxStyles:V,highlights:$n,maintainRelativeOrder:W,highlightBg:Vn,suppressHighlightBg:gn,deviationBadges:Zn,collisionKey:un}),(w.subsections||[]).map(function(n,e){return L({section:n,keyPath:"".concat(j,"-").concat(e),depth:0,columnKey:E,parentNodeId:M,sectionOffset:On})})]}))]})),D&&(null==ne?void 0:ne.showBelow)&&e.jsx("div",n.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ne?void 0:ne.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",n.__assign({style:n.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===E?{right:"-20px"}:{left:"-20px"})},{children:e.jsx(t.ChevronDown,{color:(null===(R=null==ne?void 0:ne.showBelowRef)||void 0===R?void 0:R.current)?window.getComputedStyle(ne.showBelowRef.current).color:void 0})}))}))]}),"".concat(E,"-sec-").concat(j))};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),t=require("@mui/material"),o=require("./ScrollLockToggle.js"),n=require("../CompareContext.js");exports.default=function(i){var s=i.connectedLines,c=i.pathRefs,a=i.maintainRelativeOrder,l=n.useCompareContext(),d=l.scrollSyncLocked,u=l.toggleScrollSyncLocked;return r.jsx(r.Fragment,{children:s.map(function(n){var i,s,l=n.pathD,x=(null===(i=n.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",f="conn-marker-".concat(n.id),p="".concat(n.id,"-bg"),g="".concat(n.id,"-stroke"),h="".concat(n.id,"-btn"),j=void 0!==n.x1?n.x1+40:0,k=void 0!==n.y1?n.y1:0;return r.jsxs("g",{children:[r.jsx("defs",{children:r.jsx("clipPath",e.__assign({id:"connections-clip"},{children:r.jsx("marker",e.__assign({id:f,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:r.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:x})}))}))}),r.jsx("path",{ref:function(e){c.current[p]=e},d:l,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),r.jsx("path",{ref:function(e){c.current[g]=e},d:l,fill:"none",stroke:x,strokeWidth:"1.75",markerEnd:"url(#".concat(f,")")}),a&&void 0!==n.x1&&r.jsx("foreignObject",e.__assign({ref:function(e){c.current[h]=e},x:j-12,y:k-12,width:"24",height:"24",style:{pointerEvents:"auto",overflow:"visible"}},{children:r.jsx(t.Box,e.__assign({onClick:function(e){e.stopPropagation(),u&&u(e)},sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",bgcolor:"#FFFFFF",borderRadius:"50%",border:"1px solid ".concat(x),cursor:"pointer",transition:"transform 0.2s ease","&:hover":{transform:"scale(1.05)",boxShadow:"0px 2px 4px rgba(0,0,0,0.1)"}}},{children:r.jsx(o.default,{locked:d,onToggle:u,color:(null===(s=n.style)||void 0===s?void 0:s.badgeText)||x,borderColor:"transparent",size:12})}))}))]},n.id)})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("@mui/material"),n=require("./ScrollLockToggle.js"),r=require("../CompareContext.js");exports.default=function(o){var s=o.connectedLines,l=o.pathRefs,d=o.maintainRelativeOrder,a=r.useCompareContext(),c=a.scrollSyncLocked,u=a.toggleScrollSyncLocked,x=a.isGuidelineMode;return t.jsxs(t.Fragment,{children:[s.map(function(r){var o,s,a,f,g=r.pathD,h=(null===(o=r.style)||void 0===o?void 0:o.badgeBorder)||"#6366F1",p="conn-marker-".concat(r.id),y="".concat(r.id,"-bg"),F="".concat(r.id,"-stroke"),j="".concat(r.id,"-btn"),b="".concat(r.id,"-number"),m=void 0!==r.x1?r.x1+40:0,v=void 0!==r.y1?r.y1:0;return t.jsxs("g",{children:[t.jsx("defs",{children:t.jsx("clipPath",e.__assign({id:"connections-clip"},{children:t.jsx("marker",e.__assign({id:p,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:t.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:h})}))}))}),t.jsx("path",{ref:function(e){l.current[y]=e},d:g,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),t.jsx("path",{ref:function(e){l.current[F]=e},d:g,fill:"none",stroke:h,strokeWidth:"1.75",markerEnd:"url(#".concat(p,")")}),r.matchLabel&&t.jsxs("g",e.__assign({ref:function(e){l.current[b]=e},transform:"translate(".concat(r.x2-42,", ").concat(r.y2,")"),style:{pointerEvents:"none",transition:"visibility 0ms"}},{children:[t.jsx("rect",{x:"-22",y:"-8",width:"44",height:"16",rx:"4",fill:"#FFFFFF"}),t.jsx("rect",{x:"-21",y:"-7",width:"42",height:"14",rx:"3",fill:(null===(s=r.style)||void 0===s?void 0:s.badgeBg)||"#FEF08A",stroke:h,strokeWidth:"1"}),t.jsx("text",e.__assign({x:"0",y:"3.5",fontSize:"9px",fontWeight:"bold",fontFamily:'"Plus Jakarta Sans", sans-serif',fill:(null===(a=r.style)||void 0===a?void 0:a.badgeText)||h,textAnchor:"middle"},{children:r.matchLabel}))]})),d&&void 0!==r.x1&&!x&&t.jsx("foreignObject",e.__assign({ref:function(e){l.current[j]=e},x:m-12,y:v-12,width:"24",height:"24",style:{pointerEvents:"auto",overflow:"visible"}},{children:t.jsx(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),u&&u(e)},sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",bgcolor:"#FFFFFF",borderRadius:"50%",border:"1px solid ".concat(h),cursor:"pointer",transition:"transform 0.2s ease","&:hover":{transform:"scale(1.05)",boxShadow:"0px 2px 4px rgba(0,0,0,0.1)"}}},{children:t.jsx(n.default,{locked:c,onToggle:u,color:(null===(f=r.style)||void 0===f?void 0:f.badgeText)||h,borderColor:"transparent",size:12})}))}))]},r.id)}),t.jsxs("g",{children:[t.jsxs("g",e.__assign({style:{transition:"visibility 0ms"}},{children:[t.jsx("path",{ref:function(e){return l.current["guideline-up-stroke"]=e},fill:"none",strokeWidth:"1.75",visibility:"hidden"}),t.jsxs("g",e.__assign({ref:function(e){return l.current["guideline-up-badge"]=e},visibility:"hidden"},{children:[t.jsx("polygon",{ref:function(e){return l.current["guideline-up-arrow"]=e},points:"-4,0 0,-6 4,0"}),t.jsx("rect",{ref:function(e){return l.current["guideline-up-badge-rect"]=e},x:"-12",y:"3",width:"24",height:"15",rx:"4",fill:"#FFFFFF",strokeWidth:"1"}),t.jsx("text",{ref:function(e){return l.current["guideline-up-text"]=e},x:"0",y:"14",fontSize:"10px",fontWeight:"bold",fontFamily:'"Plus Jakarta Sans", sans-serif',textAnchor:"middle"})]}))]})),t.jsxs("g",e.__assign({style:{transition:"visibility 0ms"}},{children:[t.jsx("path",{ref:function(e){return l.current["guideline-down-stroke"]=e},fill:"none",strokeWidth:"1.75",visibility:"hidden"}),t.jsxs("g",e.__assign({ref:function(e){return l.current["guideline-down-badge"]=e},visibility:"hidden"},{children:[t.jsx("polygon",{ref:function(e){return l.current["guideline-down-arrow"]=e},points:"-4,0 0,6 4,0"}),t.jsx("rect",{ref:function(e){return l.current["guideline-down-badge-rect"]=e},x:"-12",y:"-18",width:"24",height:"15",rx:"4",fill:"#FFFFFF",strokeWidth:"1"}),t.jsx("text",{ref:function(e){return l.current["guideline-down-text"]=e},x:"0",y:"-7",fontSize:"10px",fontWeight:"bold",fontFamily:'"Plus Jakarta Sans", sans-serif',textAnchor:"middle"})]}))]}))]})]})};
2
2
  //# sourceMappingURL=connectedLines.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),i={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(o,r,a,s,d){void 0===d&&(d=!0);var l="string"==typeof a?a:JSON.stringify(a||{}),u=e.useMemo(function(){if(!o||0===Object.keys(o).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var e=JSON.parse(l);try{var i=o.nodes||o,a=[],s=[],u=o.base_root_id,v=o.input_index_map||{0:"left",1:"right"},c=o[u]||i[u];if(!c||!1===c.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var f=o.content_mapping||{},p=function(n){return o[n]||i[n]},_=function(e,i,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(d)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),s={},l={},u=null;return a.forEach(function(n){var r,a,d,c,f,p=e[n];if(p&&"object"==typeof p){u||(u=p);var _=!(null==p?void 0:p.status)||"pending"===p.status,I=function(n){var e,t=(null===(e=null==p?void 0:p.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==p?void 0:p.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},g=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var i=0,o=n;i<o.length;i++){var r=o[i];if(Array.isArray(r)&&r.some(function(n){return!t.isMissingStr(n)}))return r}return[]},h=_?g((null===(a=null==p?void 0:p.deviation_highlights)||void 0===a?void 0:a[i])||(null===(d=null==p?void 0:p.deviation_highlights)||void 0===d?void 0:d[v[0]]),I(i),I(v[0])):[],m=_?g((null===(c=null==p?void 0:p.deviation_highlights)||void 0===c?void 0:c[o])||(null===(f=null==p?void 0:p.deviation_highlights)||void 0===f?void 0:f[v[1]]),I(o),I(v[1])):[];s[n]=((r={})[v[0]]=h[0]||"",r[v[1]]=m[0]||"",r.deviation_summary=(null==p?void 0:p.deviation_summary)||"",r.deviation_title=null==p?void 0:p.deviation_title,r.deviation_impact=null==p?void 0:p.deviation_impact,r.deviation_explanation=null==p?void 0:p.deviation_explanation,r.evaluation_outputs=null==p?void 0:p.evaluation_outputs,r.cognitive_decisioning=null==p?void 0:p.cognitive_decisioning,r.deviation_highlights=null==p?void 0:p.deviation_highlights,r),l[n]=p}}),n.__assign(n.__assign({},e),{deviation_title:(null==u?void 0:u.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==u?void 0:u.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==u?void 0:u.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:s,deviation_entries:l})},I=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var s=e.get(a);s.subsections||(s.subsections=[]),s.subsections.some(function(e){return e.id===n.id})||s.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},s=0,d=n;s<d.length;s++){a(d[s])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},g=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=v[0],i=v[1];return e.length>0&&(t=e.includes(v[0])?v[0]:e[0],i=e.includes(v[1])?v[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},h=function(e,i,o,r){var a=i.attributes||{},s=i.data||{},d=!1!==a.display_title,l=!1!==a.display_content,u=d?t.safeStringify(s.title||""):"",v=l?t.safeStringify(s.content||""):"",c=l?t.safeStringify(s.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),_=!(!u.trim()&&!v.trim());return n.__assign(n.__assign({id:"".concat(e,"::").concat(i.contentId),nodeId:e,contentId:i.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:l,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},m=function(e,t){e.refIndexes=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refIndexes||[],!0),t.refIndexes||[],!0))),e.refContentIds=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((e.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(e.subsections=n.__spreadArray(n.__spreadArray([],e.subsections||[],!0),[t],!1),i.add(o))});var o=n.__spreadArray(n.__spreadArray([],e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return e.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},x=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},y=function(i,o){var r,a=p(i);if(!a||!1===a.display_node)return[];var s=g(a),d=s.nodeLeftId,l=s.nodeRightId,u=t.getRationale(a),c=(null===(r=null==e?void 0:e[i])||void 0===r?void 0:r.evaluation_result)||a.evaluation_result||null,I=_(c,d,l),m=I&&"object"==typeof I?n.__assign(n.__assign({},I),{nodeId:i}):I,x=t.resolveComparisonInputItems(a,o,v,f).map(function(n){return h(i,n,m,u)});if(a.next){var b=Object.values(a.next).flatMap(function(n){return y(n,o)});x.forEach(function(n){var e=b.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:b})}return x};if(r){var b=function(i,o){var r;void 0===o&&(o=0);var a=[],s=[];if(!i)return{refSections:a,baseSections:s};var d={},l={},u=-1,c=-1,I=function(a){var s=i[a],I=p(s);if(!I||!1===I.display_node)return"continue";var x=g(I),y=x.nodeLeftId,C=x.nodeRightId,R=t.getRationale(I),E=(null===(r=null==e?void 0:e[s])||void 0===r?void 0:r.evaluation_result)||I.evaluation_result||null,S=_(E,y,C),O=S&&"object"==typeof S?n.__assign(n.__assign({},S),{nodeId:s}):S,N=b(I.next,o+1),j=N.refSections,A=N.baseSections,D=t.resolveComparisonInputItems(I,"1",v,f),P=t.resolveComparisonInputItems(I,"0",v,f),M=D.map(function(n){var e=h(s,n,O,R);return-1===e.selfIndex&&(e.selfIndex=u--),e}),V=P.map(function(n){var e=h(s,n,O,R);return-1===e.selfIndex&&(e.selfIndex=c--),e});V.forEach(function(n){M.forEach(function(e){var t,i,o,r,a,s,d,l;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(s=e.refContentIds)||void 0===s||s.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(l=n.refContentIds)||void 0===l||l.push(e.contentId))})}),M.forEach(function(n){var e=j.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);d[t]=d[t]?m(d[t],n):n}),V.forEach(function(n){var e=A.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);l[t]=l[t]?m(l[t],n):n})};for(var y in i)I(y);return a=Object.values(d),s=Object.values(l),a.sort(x),s.sort(x),{refSections:a,baseSections:s}},C=b(c.next),R=C.refSections,E=C.baseSections;s=I(R),a=E}else c.next&&Object.values(c.next).forEach(function(n){var e=p(n);e&&!1!==e.display_node&&(a.push.apply(a,y(n,"0")),s.push.apply(s,y(n,"1")))}),s=I(s);var S=t.getSideData(c,"0",v,f),O=t.getSideData(c,"1",v,f);return{activeProposed:{title:S.title||"Uploaded Contract",description:c.decision_scope_description||"",sections:a},activeVariants:[{id:"tree-variant-1",title:O.title||"Reference Template",similarity:0,sections:s,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:c.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[o,r,l,d]),v=u.activeProposed,c=u.activeVariants,f=u.parseError,p=(null==c?void 0:c[0])||i,_=e.useMemo(function(){return(null==v?void 0:v.sections)||[]},[null==v?void 0:v.sections]),I=e.useMemo(function(){return p.sections||[]},[p.sections]),g=_.length>0||I.length>0,h=e.useMemo(function(){return s.fields.filter(function(n){var e=n.key;return(!g||"description"!==e)&&(t.hasValue(null==v?void 0:v[e])||t.hasValue(p[e]))})},[v,p,g,s.fields]),m=e.useMemo(function(){var n,e,i={},a={},s={},d=0,l=null===(n=null==o?void 0:o.input_index_map)||void 0===n?void 0:n[0],u=null===(e=null==o?void 0:o.input_index_map)||void 0===e?void 0:e[1],v=function(n,e){if(!r){var t="left"===e?_.indexOf(n):I.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:_.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var a=n.selfIndex,s=_.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(a)});if(s){var d=s.selfIndex,l=void 0!==d&&d>=0?d+1:_.indexOf(s)+1;return{rootKey:"left-root:".concat(s.id),parentNum:l}}var u=void 0!==a&&a>=0?a+1:I.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:u}},c=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},f=function(n,e,o,r,v,p,_){if(e&&function(n,e,i){var o;((null===(o=null==n?void 0:n.evaluationResults)||void 0===o?void 0:o.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(o){var r=(null==o?void 0:o.deviations)||{};Object.keys(r).sort().forEach(function(d){var v=r[d];if(v){var c=!t.isMissingStr(v[l]),f=!t.isMissingStr(v[u]);if(c||f){var p=(null==o?void 0:o.nodeId)||n.nodeId||n.id,_="".concat(p).concat(t.DEVIATION_BADGE_SEPARATOR).concat(d);void 0===a[_]&&(void 0===s[e]&&(s[e]=1),a[_]={index:s[e]++,rootKey:e,parentNum:i})}}})})}(e,r,v),e&&!p){var I=(null==_?void 0:_.id)||"fallback_parent_".concat(d++);i[I]||(i[I]=[]),i[I].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==o?void 0:o.subsections)||[]).forEach(function(t){var i=c(null==n?void 0:n.subsections,t),a=c(null==o?void 0:o.subsections,t);f(t,i,a,r,v,!1,e||_)})};_.forEach(function(n){var e,t=v(n,"left"),i=t.rootKey,o=t.parentNum,a=null;if(r){var s=null===(e=n.refIndexes)||void 0===e?void 0:e[0];a=I.find(function(n){return n.selfIndex===s})}else a=I[_.indexOf(n)];f(n,n,a,i,o,!0,n)}),I.forEach(function(n){var e=v(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&f(n,null,n,t,i,!0,n)});var p=Object.fromEntries(Object.entries(a).map(function(n){return[n[0],n[1].index]})),g=Object.fromEntries(Object.entries(a).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:i,registry:p,deviationParentRegistry:g}},[_,I,r,o]),x=m.parentDeviationRecord,y=m.registry,b=m.deviationParentRegistry;return{activeProposed:v,activeVariants:c,existingRule:p,proposedSections:_,existingSections:I,visibleFields:h,parentDeviationRecord:x,deviationNumberRegistry:y,deviationParentRegistry:b,parseError:f}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react"),t=require("../CognitiveComparehelpers.js"),i={id:"",title:"",similarity:0,sections:[]};exports.useCognitiveTreeData=function(o,r,a,s,d,l){var u,v;void 0===d&&(d=!0);var c="string"==typeof a?a:JSON.stringify(a||{}),f=Boolean(l&&(null===(v=null===(u=l.data)||void 0===u?void 0:u.artifactData)||void 0===v?void 0:v.userStorySnapshot)),p=e.useMemo(function(){var e;if(!o||0===Object.keys(o).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var i=JSON.parse(c);try{var a=o.nodes||o,s=[],u=[],v=o.base_root_id,p=o.input_index_map||{0:"left",1:"right"},_=o[v]||a[v];if(!_||!1===_.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var I=o.content_mapping||{},g=function(n){return o[n]||a[n]},h=function(e,i,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(d)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),s={},l={},u=null;return a.forEach(function(n){var r,a,d,v,c,f=e[n];if(f&&"object"==typeof f){u||(u=f);var _=!(null==f?void 0:f.status)||"pending"===f.status,I=function(n){var e,t=(null===(e=null==f?void 0:f.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==f?void 0:f.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},g=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var i=0,o=n;i<o.length;i++){var r=o[i];if(Array.isArray(r)&&r.some(function(n){return!t.isMissingStr(n)}))return r}return[]},h=_?g((null===(a=null==f?void 0:f.deviation_highlights)||void 0===a?void 0:a[i])||(null===(d=null==f?void 0:f.deviation_highlights)||void 0===d?void 0:d[p[0]]),I(i),I(p[0])):[],m=_?g((null===(v=null==f?void 0:f.deviation_highlights)||void 0===v?void 0:v[o])||(null===(c=null==f?void 0:f.deviation_highlights)||void 0===c?void 0:c[p[1]]),I(o),I(p[1])):[];s[n]=((r={})[p[0]]=h[0]||"",r[p[1]]=m[0]||"",r.deviation_summary=(null==f?void 0:f.deviation_summary)||"",r.deviation_title=null==f?void 0:f.deviation_title,r.deviation_impact=null==f?void 0:f.deviation_impact,r.deviation_explanation=null==f?void 0:f.deviation_explanation,r.evaluation_outputs=null==f?void 0:f.evaluation_outputs,r.cognitive_decisioning=null==f?void 0:f.cognitive_decisioning,r.deviation_highlights=null==f?void 0:f.deviation_highlights,r),l[n]=f}}),n.__assign(n.__assign({},e),{deviation_title:(null==u?void 0:u.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==u?void 0:u.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==u?void 0:u.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:s,deviation_entries:l})},m=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var s=e.get(a);s.subsections||(s.subsections=[]),s.subsections.some(function(e){return e.id===n.id})||s.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},s=0,d=n;s<d.length;s++){a(d[s])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},y=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=p[0],i=p[1];return e.length>0&&(t=e.includes(p[0])?p[0]:e[0],i=e.includes(p[1])?p[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},x=function(e,i,o,r){var a=i.attributes||{},s=i.data||{},d=!1!==a.display_title,l=!1!==a.display_content,u=d?t.safeStringify(s.title||""):"",v=l?t.safeStringify(s.content||""):"",c=l?t.safeStringify(s.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),_=!(!u.trim()&&!v.trim());return n.__assign(n.__assign({id:"".concat(e,"::").concat(i.contentId),nodeId:e,contentId:i.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:d,displayContent:l,subsections:[]},_?r:{score:void 0,relation:"not_defined"}),{evaluationResult:o,evaluationResults:o?[o]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},b=function(e,t){e.refIndexes=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refIndexes||[],!0),t.refIndexes||[],!0))),e.refContentIds=Array.from(new Set(n.__spreadArray(n.__spreadArray([],e.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((e.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(e.subsections=n.__spreadArray(n.__spreadArray([],e.subsections||[],!0),[t],!1),i.add(o))});var o=n.__spreadArray(n.__spreadArray([],e.evaluationResults||(e.evaluationResult?[e.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return e.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!e.evaluationResult&&t.evaluationResult&&(e.evaluationResult=t.evaluationResult),!e.cognitiveData&&t.cognitiveData&&(e.cognitiveData=t.cognitiveData),e},R=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},C=function(e,o){var r,a=g(e);if(!a||!1===a.display_node)return[];if(f&&"1"===o)return[];var s=y(a),d=s.nodeLeftId,l=s.nodeRightId,u=t.getRationale(a),v=(null===(r=null==i?void 0:i[e])||void 0===r?void 0:r.evaluation_result)||a.evaluation_result||null,c=h(v,d,l),_=c&&"object"==typeof c?n.__assign(n.__assign({},c),{nodeId:e}):c,m=t.resolveComparisonInputItems(a,o,p,I).map(function(n){return x(e,n,_,u)});if(a.next){var b=Object.values(a.next).flatMap(function(n){return C(n,o)});m.forEach(function(n){var e=b.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:b})}return m};if(r){var S=function(e,o){var r;void 0===o&&(o=0);var a=[],s=[];if(!e)return{refSections:a,baseSections:s};var d={},l={},u=-1,v=-1,c=function(a){var s=e[a],c=g(s);if(!c||!1===c.display_node)return"continue";var _=y(c),m=_.nodeLeftId,R=_.nodeRightId,C=t.getRationale(c),E=(null===(r=null==i?void 0:i[s])||void 0===r?void 0:r.evaluation_result)||c.evaluation_result||null,O=h(E,m,R),N=O&&"object"==typeof O?n.__assign(n.__assign({},O),{nodeId:s}):O,j=S(c.next,o+1),A=j.refSections,D=j.baseSections,M=t.resolveComparisonInputItems(c,"0",p,I).map(function(n){var e=x(s,n,N,C);return-1===e.selfIndex&&(e.selfIndex=v--),e}),P=[];if(!f){var k=t.resolveComparisonInputItems(c,"1",p,I);P=k.map(function(n){var e=x(s,n,N,C);return-1===e.selfIndex&&(e.selfIndex=u--),e})}M.forEach(function(n){P.forEach(function(e){var t,i,o,r,a,s,d,l;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(s=e.refContentIds)||void 0===s||s.push(n.contentId)),e.contentId&&!(null===(d=n.refContentIds)||void 0===d?void 0:d.includes(e.contentId))&&(null===(l=n.refContentIds)||void 0===l||l.push(e.contentId))})}),P.forEach(function(n){var e=A.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);d[t]=d[t]?b(d[t],n):n}),M.forEach(function(n){var e=D.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===o?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||s);l[t]=l[t]?b(l[t],n):n})};for(var _ in e)c(_);return a=Object.values(d),s=Object.values(l),a.sort(R),s.sort(R),{refSections:a,baseSections:s}},E=S(_.next),O=E.refSections,N=E.baseSections;f||(u=m(O)),s=N}else _.next&&Object.values(_.next).forEach(function(n){var e=g(n);e&&!1!==e.display_node&&(s.push.apply(s,C(n,"0")),f||u.push.apply(u,C(n,"1")))}),f||(u=m(u));var j=t.getSideData(_,"0",p,I),A=t.getSideData(_,"1",p,I);return{activeProposed:{title:j.title||"Uploaded Contract",description:_.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:f?(null===(e=null==l?void 0:l.data)||void 0===e?void 0:e.artifactTitle)||"Rulebook Guidelines":A.title||"Reference Template",similarity:0,sections:u,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:_.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[o,r,c,d,l]),_=p.activeProposed,I=p.activeVariants,g=p.parseError,h=(null==I?void 0:I[0])||i,m=e.useMemo(function(){return(null==_?void 0:_.sections)||[]},[null==_?void 0:_.sections]),y=e.useMemo(function(){return h.sections||[]},[h.sections]),x=m.length>0||y.length>0,b=e.useMemo(function(){return s.fields.filter(function(n){var e=n.key;return(!x||"description"!==e)&&(t.hasValue(null==_?void 0:_[e])||t.hasValue(h[e]))})},[_,h,x,s.fields]),R=e.useMemo(function(){var n,e,i={},a={},s={},d=0,l=null===(n=null==o?void 0:o.input_index_map)||void 0===n?void 0:n[0],u=null===(e=null==o?void 0:o.input_index_map)||void 0===e?void 0:e[1],v=function(n,e){if(!r){var t="left"===e?m.indexOf(n):y.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:m.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var a=n.selfIndex,s=m.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(a)});if(s){var d=s.selfIndex,l=void 0!==d&&d>=0?d+1:m.indexOf(s)+1;return{rootKey:"left-root:".concat(s.id),parentNum:l}}var u=void 0!==a&&a>=0?a+1:y.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:u}},c=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,o,r,v,f,_){if(e&&function(n,e,i){var o;((null===(o=null==n?void 0:n.evaluationResults)||void 0===o?void 0:o.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(o){var r=(null==o?void 0:o.deviations)||{};Object.keys(r).sort().forEach(function(d){var v=r[d];if(v){var c=!t.isMissingStr(v[l]),f=!t.isMissingStr(v[u]);if(c||f){var p=(null==o?void 0:o.nodeId)||n.nodeId||n.id,_="".concat(p).concat(t.DEVIATION_BADGE_SEPARATOR).concat(d);void 0===a[_]&&(void 0===s[e]&&(s[e]=1),a[_]={index:s[e]++,rootKey:e,parentNum:i})}}})})}(e,r,v),e&&!f){var I=(null==_?void 0:_.id)||"fallback_parent_".concat(d++);i[I]||(i[I]=[]),i[I].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==o?void 0:o.subsections)||[]).forEach(function(t){var i=c(null==n?void 0:n.subsections,t),a=c(null==o?void 0:o.subsections,t);p(t,i,a,r,v,!1,e||_)})};m.forEach(function(n){var e,t=v(n,"left"),i=t.rootKey,o=t.parentNum,a=null;if(r){var s=null===(e=n.refIndexes)||void 0===e?void 0:e[0];a=y.find(function(n){return n.selfIndex===s})}else a=y[m.indexOf(n)];p(n,n,a,i,o,!0,n)}),f||y.forEach(function(n){var e=v(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var _=Object.fromEntries(Object.entries(a).map(function(n){return[n[0],n[1].index]})),I=Object.fromEntries(Object.entries(a).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:i,registry:_,deviationParentRegistry:I}},[m,y,r,o,f]),C=R.parentDeviationRecord,S=R.registry,E=R.deviationParentRegistry;return{isGuidelineMode:f,activeProposed:_,activeVariants:I,existingRule:h,proposedSections:m,existingSections:y,visibleFields:b,parentDeviationRecord:C,deviationNumberRegistry:S,deviationParentRegistry:E,parseError:g}};
2
2
  //# sourceMappingURL=useCompareData.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var r=n.containerRef,i=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var o=n.pathRefs,l=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,v=n.visibleFields,s=n.leftRefs,h=n.rightRefs,f=n.sectionLeftRefs,g=n.sectionRightRefs,p=n.subSectionLeftRefs,R=n.subSectionRightRefs,y=n.lhsBadgeRefs,x=n.rhsBadgeRefs,A=n.sectionRowRefs,m=n.expandedSections,B=n.expandedSubSections,S=n.connectedSections,C=n.isSideBySide,b=n.activeSideBySideSection,I=n.maintainRelativeOrder,T=n.cognitiveMap,E=n.getSectionCompareStyle,M=n.getSubSectionCompareStyle,L=n.getDeviationStyleByKey,D=n.isArrowVisible,O=n.isAnimatingRef,H=n.isSideBySideRef,_=n.sideBySideCacheRef,P=n.sideBySideLineRef,N=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,w=n.connectedLines,V=n.setConnectedLines,G=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,F=n.scrollLock,z=n.scrollSyncLocked,q=n.handleResizeRef,K=n.activeProposed,J=n.existingRule,Q=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,X=n.resolvedComparisonConfig,Z=n.getFieldData,$=t.useState([]),tt=$[0],et=$[1],nt=t.useState(null),rt=nt[0],it=nt[1],ct=t.useState([]),ot=ct[0],lt=ct[1],ut=null!=w?w:ot,at=null!=V?V:lt,dt=t.useState({width:0,height:0}),vt=dt[0],st=dt[1],ht=t.useRef(!1),ft=t.useRef(!1),gt=t.useRef(!1),pt=t.useRef(null),Rt=t.useRef([]),yt=null!=G?G:Rt,xt=t.useCallback(function(){var t,n,o,A,D,H,_,P,N,k,w,V,G,Y,j,F,z,q;if(!ht.current&&!O.current){ht.current=!0;try{if(!r.current)return;var K=function(t){var e=t.split("-"),n=e[0];if(!m[n]&&!1===I)return!1;if(I&&!m["left-".concat(n)]&&!m["right-".concat(n)]&&!m[n])return!1;for(var r=n,i=1;i<e.length-1;i++)if(r+="-".concat(e[i]),!B[r])return!1;return!0},J=r.current.getBoundingClientRect();st({width:J.width,height:J.height});var Q=[];if(v.forEach(function(t){var e,n,r=t.key,i=null===(e=s.current[r])||void 0===e?void 0:e.current,c=null===(n=h.current[r])||void 0===n?void 0:n.current;i&&c&&(i.style.height="auto",c.style.height="auto",i.style.minHeight="0px",c.style.minHeight="0px")}),!O.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=f.current[U])||void 0===t?void 0:t.current,X=null===(n=g.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),X&&(X.style.height="auto",X.style.minHeight="0px")}I||Object.keys(p.current).forEach(function(t){var e,n;if(K(t)){var r=null===(e=p.current[t])||void 0===e?void 0:e.current,i=null===(n=R.current[t])||void 0===n?void 0:n.current;r&&i&&(r.style.height="auto",i.style.height="auto",r.style.minHeight="0px",i.style.minHeight="0px")}})}var Z={};v.forEach(function(t){var e,n,r=t.key,i=null===(e=s.current[r])||void 0===e?void 0:e.current,c=null===(n=h.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=i.getBoundingClientRect(),l=c.getBoundingClientRect();Z[r]=Math.max(o.height,l.height)}});var $={left:{},right:{}},tt={};if(!O.current)if(I){if(C&&null!==b)if("number"==typeof b){var nt=b,rt=a[nt],ct=null===(D=f.current[nt])||void 0===D?void 0:D.current;ct&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),r=null===(e=g.current[n])||void 0===e?void 0:e.current;if(r&&(m["left-".concat(nt)]||m["right-".concat(n)])){var i=Math.max(ct.getBoundingClientRect().height,r.getBoundingClientRect().height);$.left[nt]=Math.max($.left[nt]||0,i),$.right[n]=Math.max($.right[n]||0,i)}})}else{var ot=b.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(H=p.current[ot])||void 0===H?void 0:H.current,X=null===(_=R.current[ot])||void 0===_?void 0:_.current;if(W&&X){lt=Math.max(W.getBoundingClientRect().height,X.getBoundingClientRect().height);tt[ot]=Math.max(tt[ot]||0,lt)}}}}else{Object.keys(p.current).forEach(function(t){var e,n;if(K(t)){var r=null===(e=p.current[t])||void 0===e?void 0:e.current,i=null===(n=R.current[t])||void 0===n?void 0:n.current;if(r&&i&&null!==r.offsetParent&&null!==i.offsetParent){var c=r.getBoundingClientRect(),o=i.getBoundingClientRect(),l=Math.max(c.height,o.height);tt[t]=l,r.style.minHeight="".concat(l,"px"),i.style.minHeight="".concat(l,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(o=f.current[U])||void 0===o?void 0:o.current,X=null===(A=g.current[U])||void 0===A?void 0:A.current;if(W&&X){var lt=Math.max(W.getBoundingClientRect().height,X.getBoundingClientRect().height);$.left[U]=lt,$.right[U]=lt}}}v.forEach(function(t){var e,n,r=t.key,i=null===(e=s.current[r])||void 0===e?void 0:e.current,c=null===(n=h.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=Z[r];i.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),O.current||(Object.entries($.left).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),Object.entries($.right).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),I||Object.keys(tt).forEach(function(t){var e,n,r=null===(e=p.current[t])||void 0===e?void 0:e.current,i=null===(n=R.current[t])||void 0===n?void 0:n.current;if(r&&i&&tt[t]){var c=tt[t];r.style.minHeight="".concat(c,"px"),i.style.minHeight="".concat(c,"px")}}));if(a.forEach(function(t,e){var n,r=null===(n=f.current[e])||void 0===n?void 0:n.current;if(r){var o=function(t,e){var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);o.forEach(function(n){var o,l,u,a,v,s,h,f,p,R,y=null===(o=g.current[n])||void 0===o?void 0:o.current;if(y){var x=r.getBoundingClientRect(),A=y.getBoundingClientRect(),m=x.right-J.left,B=A.left-J.left,S=x.top+18-J.top,M=A.top+18-J.top;if(I&&C&&b===e){var L=null!==(u=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,D=null!==(v=null===(a=c.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==v?v:0,O=L+(null!==(h=null===(s=i.current)||void 0===s?void 0:s.clientHeight)&&void 0!==h?h:1/0),H=D+(null!==(p=null===(f=c.current)||void 0===f?void 0:f.clientHeight)&&void 0!==p?p:1/0),_=function(t,e,n){return Math.max(e,Math.min(n,t))};S=_(x.top+18,L,O)-J.top,M=_(A.top+18,D,H)-J.top}var P=E(e);P&&Q.push({id:"line-".concat(e,"-").concat(n),x1:m,y1:S,x2:B,y2:M,style:P,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(R=d[n])||void 0===R?void 0:R.cognitiveData)||(null==t?void 0:t.nodeId)&&T[t.nodeId])})}})}}),C&&"string"==typeof b&&b.includes(e.DEVIATION_BADGE_SEPARATOR)){var ut=b.split(e.DEVIATION_BADGE_SEPARATOR),dt=ut[0],vt=ut[1],ft=ut[2],gt=(ut[3],"".concat(dt).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),pt=null===(P=y.current[gt])||void 0===P?void 0:P.current,Rt=null===(N=x.current[gt])||void 0===N?void 0:N.current;if(pt&&Rt){var xt=pt.getBoundingClientRect(),At=Rt.getBoundingClientRect(),mt=xt.right-J.left,Bt=At.left-J.left,St=xt.top+xt.height/2-J.top,Ct=At.top+At.height/2-J.top;if(I){var bt=null!==(w=null===(k=i.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==w?w:0,It=null!==(G=null===(V=c.current)||void 0===V?void 0:V.getBoundingClientRect().top)&&void 0!==G?G:0,Tt=bt+(null!==(j=null===(Y=i.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Et=It+(null!==(z=null===(F=c.current)||void 0===F?void 0:F.clientHeight)&&void 0!==z?z:1/0),Mt=function(t,e,n){return Math.max(e,Math.min(n,t))};St=Mt(xt.top+xt.height/2,bt,Tt)-J.top,Ct=Mt(At.top+At.height/2,It,Et)-J.top}var Lt=null!==(q=L(dt,vt))&&void 0!==q?q:M(ft);Lt&&Q.push({id:"line-subsec-".concat(gt),x1:mt,y1:St,x2:Bt,y2:Ct,style:Lt,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:b})}}if(et(Q),l.current&&u.current){var Dt=l.current.getBoundingClientRect(),Ot=u.current.getBoundingClientRect(),Ht=(Dt.top+Dt.height/2-J.top+Ot.top+Ot.height/2-J.top)/2;it({x1:Dt.right-J.left,x2:Ot.left-J.left,y:Ht})}else it(null);if(S.size>0){var _t=[],Pt=i.current,Nt=c.current;if(Pt&&Nt){var kt=[],wt=Pt.getBoundingClientRect().top,Vt=Nt.getBoundingClientRect().top,Gt=wt+Pt.clientHeight,Yt=Vt+Nt.clientHeight,jt=Pt.scrollTop,Ft=Nt.scrollTop,zt=J.top,qt=function(t,e,n){return Math.max(e,Math.min(n,t))};S.forEach(function(t){var n,r,i,c,o,l;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var u=t.split(e.DEVIATION_BADGE_SEPARATOR),v=u[0],s=u[1],h=u[2],f=(u[3],"".concat(v).concat(e.DEVIATION_BADGE_SEPARATOR).concat(s)),g=null===(n=y.current[f])||void 0===n?void 0:n.current,p=null===(r=x.current[f])||void 0===r?void 0:r.current;if(!g||!p)return;var R=g.getBoundingClientRect(),A=p.getBoundingClientRect(),m=null!==(i=L(v,s))&&void 0!==i?i:M(h),B=(j=R.right-J.left)+.5*((F=A.left-J.left-0)-j),S=R.top+R.height/2,C=A.top+A.height/2,b=S-wt+jt,T=C-Vt+Ft,D="conn-subsec-".concat(f);kt.push({lhsScrollY:b,rhsScrollY:T,x1:j,x2:F,containerTop:zt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==m?void 0:m.badgeBorder)||"#6366F1",styleId:D});var O=qt(S,wt,Gt),H=qt(C,Vt,Yt),_=O-zt,P=H-zt,N=C>=Vt-4&&C<=Yt+4,k="";k=(z=S>=wt-4&&S<=Gt+4)&&N?e.getBentArrowPath(j,_,F,P):z&&!N?"M ".concat(j,",").concat(_," L ").concat(B,",").concat(_," L ").concat(B,",").concat(P):!z&&N?"M ".concat(B,",").concat(_," L ").concat(B,",").concat(P," L ").concat(F,",").concat(P):"M ".concat(B,",").concat(_," L ").concat(B,",").concat(P),_t.push({id:D,pathD:k,style:m,leftIdx:t,rhsArrayIdx:t,x1:j,x2:F,y1:_,y2:P})}else if(I){var w=t,V=a[w];if(!(null===(l=null==V?void 0:V.refIndexes)||void 0===l?void 0:l.length))return;V.refIndexes.forEach(function(t){var n,r,i=d.findIndex(function(e){return e.selfIndex===t});if(-1!==i){var c=null===(n=y.current[w])||void 0===n?void 0:n.current,o=null===(r=x.current[i])||void 0===r?void 0:r.current;if(c&&o){var l=c.getBoundingClientRect(),u=o.getBoundingClientRect(),a=E(w),v=l.right-J.left,s=u.left-J.left-0,h=v+.5*(s-v),f=l.top+l.height/2,g=u.top+u.height/2,p=f-wt+jt,R=g-Vt+Ft,A="conn-".concat(w,"-").concat(i);kt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:s,containerTop:zt,leftIdx:w,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:A});var m=qt(f,wt,Gt),B=qt(g,Vt,Yt),S=m-zt,C=B-zt,b=f>=wt-4&&f<=Gt+4,I=g>=Vt-4&&g<=Yt+4,T="";T=b&&I?e.getBentArrowPath(v,S,s,C):b&&!I?"M ".concat(v,",").concat(S," L ").concat(h,",").concat(S," L ").concat(h,",").concat(C):!b&&I?"M ".concat(h,",").concat(S," L ").concat(h,",").concat(C," L ").concat(s,",").concat(C):"M ".concat(h,",").concat(S," L ").concat(h,",").concat(C),_t.push({id:A,pathD:T,style:a,leftIdx:w,rhsArrayIdx:i,x1:v,x2:s,y1:S,y2:C})}}})}else{var G=t,Y=G;g=null===(c=y.current[G])||void 0===c?void 0:c.current,p=null===(o=x.current[Y])||void 0===o?void 0:o.current;if(!g||!p)return;var j,F;R=g.getBoundingClientRect(),A=p.getBoundingClientRect(),m=E(G),B=(j=R.right-J.left)+.5*((F=A.left-J.left-0)-j),S=R.top+R.height/2,C=A.top+A.height/2,b=S-wt+jt,T=C-Vt+Ft,D="conn-".concat(G,"-").concat(Y);kt.push({lhsScrollY:b,rhsScrollY:T,x1:j,x2:F,containerTop:zt,leftIdx:G,rhsArrayIdx:Y,styleColor:(null==m?void 0:m.badgeBorder)||"#6366F1",styleId:D});var z;O=qt(S,wt,Gt),H=qt(C,Vt,Yt),_=O-zt,P=H-zt,N=C>=Vt-4&&C<=Yt+4,k="";k=(z=S>=wt-4&&S<=Gt+4)&&N?e.getBentArrowPath(j,_,F,P):z&&!N?"M ".concat(j,",").concat(_," L ").concat(B,",").concat(_," L ").concat(B,",").concat(P):!z&&N?"M ".concat(B,",").concat(_," L ").concat(B,",").concat(P," L ").concat(F,",").concat(P):"M ".concat(B,",").concat(_," L ").concat(B,",").concat(P),_t.push({id:D,pathD:k,style:m,leftIdx:G,rhsArrayIdx:Y,x1:j,x2:F,y1:_,y2:P})}}),yt.current=kt}at(_t)}else at([]),yt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{ht.current=!1}}},[v,a,d,T,X,Z,E,L,I,C,b,S,m,B]),At=t.useCallback(function(){var t,n,l,u,a,d,v,s,h,f,g,p,R,y,x=yt.current;if(x.length&&!O.current){var A=null!==(n=null===(t=i.current)||void 0===t?void 0:t.scrollTop)&&void 0!==n?n:0,m=null!==(u=null===(l=c.current)||void 0===l?void 0:l.scrollTop)&&void 0!==u?u:0,B=null!==(d=null===(a=i.current)||void 0===a?void 0:a.clientHeight)&&void 0!==d?d:1/0,S=null!==(s=null===(v=c.current)||void 0===v?void 0:v.clientHeight)&&void 0!==s?s:1/0,C=null!==(f=null===(h=i.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==f?f:0,b=null!==(p=null===(g=c.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==p?p:0,I=C+B,T=b+S,E=null!==(y=null===(R=r.current)||void 0===R?void 0:R.getBoundingClientRect().top)&&void 0!==y?y:0,M=function(t,e,n){return Math.max(e,Math.min(n,t))};x.forEach(function(t){var n=t.lhsScrollY-A+C,r=t.rhsScrollY-m+b,i=o.current[t.styleId+"-stroke"],c=o.current[t.styleId+"-bg"],l=o.current[t.styleId+"-btn"];if(i||c){var u,a=M(n,C,I),d=M(r,b,T),v=a-E,s=d-E,h=n>=C-4&&n<=I+4,f=r>=b-4&&r<=T+4,g=t.x1+.5*(t.x2-t.x1);u=h&&f?e.getBentArrowPath(t.x1,v,t.x2,s):h&&!f?"M ".concat(t.x1,",").concat(v," L ").concat(g,",").concat(v," L ").concat(g,",").concat(s):!h&&f?"M ".concat(g,",").concat(v," L ").concat(g,",").concat(s," L ").concat(t.x2,",").concat(s):"M ".concat(g,",").concat(v," L ").concat(g,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",u)),c&&(c.setAttribute("visibility","visible"),c.setAttribute("d",u)),l&&(h?(l.setAttribute("visibility","visible"),l.setAttribute("y",String(v-12))):l.setAttribute("visibility","hidden"))}})}},[]),mt=t.useCallback(function(){yt.current.length>0&&!O.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),Bt=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!gt.current&&!F.current){if(I&&z&&(H.current||S.size>0)){var o=t.currentTarget,l=i.current,u=c.current,a=o===l?u:o===u?l:null;if(o&&a){var d=function(){var t,n,r,i,c,o,l,u,a,d,v,s=N.current,h=k.current;if(null===s)return{leftAnchor:null,rightAnchor:null};if("string"==typeof s&&s.includes(e.DEVIATION_BADGE_SEPARATOR)){var m=s.split(e.DEVIATION_BADGE_SEPARATOR),B="".concat(m[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(m[1]);return{leftAnchor:(null===(t=y.current[B])||void 0===t?void 0:t.current)||(null===(n=p.current[m[2]])||void 0===n?void 0:n.current)||(null===(r=f.current[Number(m[2])])||void 0===r?void 0:r.current)||null,rightAnchor:(null===(i=x.current[B])||void 0===i?void 0:i.current)||(null===(c=R.current[m[3]])||void 0===c?void 0:c.current)||(null===(o=g.current[Number(m[3])])||void 0===o?void 0:o.current)||null}}var S=Number(s),C=null!==h?Number(h):S;return{leftAnchor:(null===(l=y.current[S])||void 0===l?void 0:l.current)||(null===(u=A.current[S])||void 0===u?void 0:u.current)||(null===(a=f.current[S])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=x.current[C])||void 0===d?void 0:d.current)||(null===(v=g.current[C])||void 0===v?void 0:v.current)||null}}(),v=d.leftAnchor,s=d.rightAnchor,h=o===l?v:s,m=o===l?s:v,B=null;if(h&&m){var C=h.getBoundingClientRect(),b=m.getBoundingClientRect(),T=a.getBoundingClientRect(),E=C.top+C.height/2;B=b.top-T.top+a.scrollTop+b.height/2-(E-T.top)}else{var M=Math.max(0,o.scrollHeight-o.clientHeight),L=Math.max(0,a.scrollHeight-a.clientHeight);B=M>0?o.scrollTop/M*L:o.scrollTop}var D=Math.max(0,a.scrollHeight-a.clientHeight);B=Math.max(0,Math.min(B,D)),Math.abs(a.scrollTop-B)>1&&(gt.current=!0,a.scrollTop=B,requestAnimationFrame(function(){gt.current=!1}))}}I||mt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,o,l,u,a,d;if(H.current){var v=i.current,s=c.current;if(v&&s&&P.current){if(!_.current){var h=N.current,f=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var g=h.split(e.DEVIATION_BADGE_SEPARATOR),p="".concat(g[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(g[1]);f=null===(t=y.current[p])||void 0===t?void 0:t.current}else f=null===(n=y.current[h])||void 0===n?void 0:n.current;if(f){var R=f.getBoundingClientRect();_.current={badgeScreenY:R.top+R.height/2,initialScrollTop:v.scrollTop,leftTop:v.getBoundingClientRect().top,leftBottom:v.getBoundingClientRect().top+v.clientHeight,cTop:null!==(l=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0}}}if(_.current){var x=_.current,A=v.scrollTop-x.initialScrollTop,m=x.badgeScreenY-A,B=((u=m,a=x.leftTop,d=x.leftBottom,Math.max(a,Math.min(d,u)))-x.cTop).toString(),S=m>=x.leftTop-4&&m<=x.leftBottom+4;P.current.setAttribute("y1",B),P.current.setAttribute("y2",B),P.current.setAttribute("visibility",S?"visible":"hidden")}}}yt.current.length>0&&At(),ft.current=!1}))}},[At,I,z,S,mt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(mt,250),e=function(){return q.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[K,J,Q,v,m,B,a,d,X,mt,C,b,D,S]),{lines:tt,setLines:et,overallConnector:rt,setOverallConnector:it,connectedLines:ut,setConnectedLines:at,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:mt,handleColumnScroll:Bt}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,b=n.subSectionLeftRefs,p=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,T=n.activeSideBySideSection,C=n.maintainRelativeOrder,I=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,G=n.connectedLines,w=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=G?G:ot,dt=null!=w?w:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),bt=t.useRef(!1),pt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,G,w,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===C)return!1;if(C&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!m[i])return!1;return!0},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}C||Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(C){if(S&&null!==T)if("number"==typeof T){var it=T,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=T.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=b.current[ot])||void 0===F?void 0:F.current,Z=null===(N=p.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),C||Object.keys(et).forEach(function(t){var e,n,i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!I){a.forEach(function(t,e){var n,i=null===(n=g.current[e])||void 0===n?void 0:n.current;if(i){var l=function(t,e){var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);l.forEach(function(n){var l,o,u,a,s,v,h,g,b,p,A=null===(l=f.current[n])||void 0===l?void 0:l.current;if(A){var y=i.getBoundingClientRect(),R=A.getBoundingClientRect(),x=y.right-K.left,m=R.left-K.left,B=y.top+18-K.top,I=R.top+18-K.top;if(C&&S&&T===e){var D=null!==(u=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==u?u:0,O=null!==(s=null===(a=c.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,L=D+(null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0),_=O+(null!==(b=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==b?b:1/0),F=function(t,e,n){return Math.max(e,Math.min(n,t))};B=F(y.top+18,D,L)-K.top,I=F(R.top+18,O,_)-K.top}var N=M(e);N&&J.push({id:"line-".concat(e,"-").concat(n),x1:x,y1:B,x2:m,y2:I,style:N,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=d[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&E[t.nodeId])})}})}})}if(!I&&S&&"string"==typeof T&&T.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=T.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],bt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),pt=null===(H=A.current[bt])||void 0===H?void 0:H.current,At=null===(P=y.current[bt])||void 0===P?void 0:P.current;if(pt&&At){var xt=pt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,Tt=Bt.left-K.left,Ct=xt.top+xt.height/2-K.top,It=Bt.top+Bt.height/2-K.top;if(C){var Et=null!==(G=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==G?G:0,Mt=null!==(V=null===(w=c.current)||void 0===w?void 0:w.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ct=Lt(xt.top+xt.height/2,Et,Dt)-K.top,It=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(bt),x1:St,y1:Ct,x2:Tt,y2:It,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:T})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,Gt=c.current;if(kt&&Gt){var wt=[],Vt=kt.getBoundingClientRect().top,Yt=Gt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+Gt.clientHeight,Qt=kt.scrollTop,Xt=Gt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(I){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var b=t.split(e.DEVIATION_BADGE_SEPARATOR),p=b[0],R=b[1],x=b[2],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(p,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;document.querySelectorAll('[id^="guideline-target-"]').forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),b="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?b=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):b=String(Number(t)+1);var p=String.fromCharCode(97+i),A="".concat(b,"(").concat(p,")");wt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,B=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:B,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var B=t.split(e.DEVIATION_BADGE_SEPARATOR),S=(p=B[0],R=B[1],x=B[2],B[3],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),T=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!S||!T)return;var E=S.getBoundingClientRect(),L=T.getBoundingClientRect(),_=null!==(o=O(p,R))&&void 0!==o?o:D(x),F=E.right-K.left,N=L.left-K.left-0,H=F+75,P=E.top+E.height/2,k=L.top+L.height/2,G=P-Vt+Qt,w=k-Yt+Xt,V="conn-subsec-".concat(m),Y=(x||"").split("-").map(function(t){return Number(t)+1}).join("."),j="".concat(Y,"(a)");wt.push({lhsScrollY:G,rhsScrollY:w,x1:F,x2:N,containerTop:qt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==_?void 0:_.badgeBorder)||"#6366F1",styleBg:(null==_?void 0:_.badgeBg)||"#FFFFFF",styleText:(null==_?void 0:_.badgeText)||"#A16207",styleId:V,centerX:H});var z=Kt(P,Vt,jt),Q=Kt(k,Yt,zt),X=Rt(F,Z=z-qt,N,$=Q-qt,H,P>=Vt-4&&P<=jt+4,k>=Yt-4&&k<=zt+4);Pt.push({id:V,pathD:X,style:_,leftIdx:t,rhsArrayIdx:t,x1:F,x2:N,y1:Z,y2:$,matchLabel:j})}else if(C){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,b=a.top+a.height/2,p=f-Vt+Qt,R=b-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S="".concat(m,"(").concat(B,")");wt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var T=Kt(f,Vt,jt),C=Kt(b,Yt,zt),I=T-qt,E=C-qt,D=Rt(v,I,h,E,g,f>=Vt-4&&f<=jt+4,b>=Yt-4&&b<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:I,y2:E,matchLabel:S})}}})}else{var U=t,W=U;S=null===(u=A.current[U])||void 0===u?void 0:u.current,T=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!S||!T)return;E=S.getBoundingClientRect(),L=T.getBoundingClientRect(),_=M(U),F=E.right-K.left,N=L.left-K.left-0,H=F+75,P=E.top+E.height/2,k=L.top+L.height/2,G=P-Vt+Qt,w=k-Yt+Xt,V="conn-".concat(U,"-").concat(W),Y=String(Number(t)+1),j="".concat(Y,"(a)");wt.push({lhsScrollY:G,rhsScrollY:w,x1:F,x2:N,containerTop:qt,leftIdx:U,rhsArrayIdx:W,styleColor:(null==_?void 0:_.badgeBorder)||"#6366F1",styleBg:(null==_?void 0:_.badgeBg)||"#FFFFFF",styleText:(null==_?void 0:_.badgeText)||"#A16207",styleId:V,centerX:H});var Z,$;z=Kt(P,Vt,jt),Q=Kt(k,Yt,zt),X=Rt(F,Z=z-qt,N,$=Q-qt,H,P>=Vt-4&&P<=jt+4,k>=Yt-4&&k<=zt+4);Pt.push({id:V,pathD:X,style:_,leftIdx:U,rhsArrayIdx:W,x1:F,x2:N,y1:Z,y2:$,matchLabel:j})}}),yt.current=wt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,C,S,T,B,x,m,I]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,b,p,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,T=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,C=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,I=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(p=null===(b=r.current)||void 0===b?void 0:b.getBoundingClientRect().top)&&void 0!==p?p:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+C,O=M+I,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,G=0,w=0,V="#6366F1",Y="#A16207",j=!1;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-T+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===G&&(G=t.x1,w=d,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var b=Rt(t.x1,d,t.x2,s,f,v,h);i&&(g&&b?(i.setAttribute("visibility","visible"),i.setAttribute("d",b)):i.setAttribute("visibility","hidden")),r&&(g&&b?(r.setAttribute("visibility","visible"),r.setAttribute("d",b)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),j){var z=l.current["guideline-up-stroke"],Q=l.current["guideline-up-badge"],X=l.current["guideline-up-arrow"],q=l.current["guideline-up-text"],K=l.current["guideline-up-badge-rect"],J=G+75;if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(J-G),Math.max(0,w-U)),Z="M ".concat(G,",").concat(w," L ").concat(J-W,",").concat(w," Q ").concat(J,",").concat(w," ").concat(J,",").concat(w-W," L ").concat(J,",").concat(U);null==z||z.setAttribute("visibility","visible"),null==z||z.setAttribute("d",Z),null==z||z.setAttribute("stroke",V),null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("transform","translate(".concat(J,", ").concat(U,")")),X&&X.setAttribute("fill",V),q&&(q.textContent="+".concat(P),q.setAttribute("fill",Y)),K&&K.setAttribute("stroke",V)}else null==z||z.setAttribute("visibility","hidden"),null==Q||Q.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(J-G),Math.max(0,rt-w)),Z="M ".concat(G,",").concat(w," L ").concat(J-W,",").concat(w," Q ").concat(J,",").concat(w," ").concat(J,",").concat(w+W," L ").concat(J,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(J,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!bt.current&&!z.current){if(C&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=b.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=p.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),T=x.getBoundingClientRect(),I=a.getBoundingClientRect(),E=S.top+S.height/2;m=T.top-I.top+a.scrollTop+T.height/2-(E-I.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(bt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){bt.current=!1}))}}C||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),b="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[b])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var p=g.getBoundingClientRect();N.current={badgeScreenY:p.top+p.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,C,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,T,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
2
2
  //# sourceMappingURL=useLinesCalculator.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),n=require("../CognitiveComparehelpers.js");exports.useSideBySide=function(t){var r=t.maintainRelativeOrder,i=t.proposedSections,l=t.existingSections,u=t.leftContainerRef,o=t.rightContainerRef,c=t.scrollContainerRef,s=t.sectionLeftRefs,d=t.sectionRightRefs,a=t.subSectionLeftRefs,v=t.subSectionRightRefs,p=t.lhsBadgeRefs,f=t.rhsBadgeRefs,g=t.sectionRowRefs,R=t.sectionRightRowRefs,S=t.rhsTopSpacerRef,h=t.rhsBottomSpacerRef,y=t.lhsTopSpacerRef,T=t.lhsBottomSpacerRef,B=t.calculateLinesRef,m=t.setConnectedSections,A=t.setConnectedLines,x=t.cachedConnectedPositions,E=t.closeMoreFunctionsPopup,C=t.setErrorToast;t.moreFunctions,t.closeSummaryPopup;var I=e.useState(!1),b=I[0],O=I[1],_=e.useState(!1),D=_[0],N=_[1],P=e.useState(!1),V=P[0],w=P[1],L=e.useState(!1),q=L[0],F=L[1],G=e.useState(null),H=G[0],k=G[1],M=e.useRef(!1),j=e.useRef(null),z=e.useRef(!1),J=e.useRef(null),K=e.useRef(null),Q=e.useRef(null),U=e.useRef(new Set),W=function(){U.current.forEach(function(e){n.resetClauseHighlight(e)}),U.current.clear()},X=function(e,t,r){var i,l,c,S,h,y,T,B,m,A,x,E,C=null,I=null,b=null,O=null,_=null,D=null,N=function(e,n){if(!e||!n)return!0;var t=e.getBoundingClientRect(),r=n.getBoundingClientRect();return t.bottom>=r.top&&t.top<=r.bottom};if(e){var P=t.split(n.DEVIATION_BADGE_SEPARATOR),V="".concat(P[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(P[1]);C=(null===(i=a.current[P[2]])||void 0===i?void 0:i.current)||(null===(l=s.current[Number(P[2])])||void 0===l?void 0:l.current)||null,I=(null===(c=v.current[P[3]])||void 0===c?void 0:c.current)||(null===(S=d.current[Number(P[3])])||void 0===S?void 0:S.current)||null,b=(null===(h=p.current[V])||void 0===h?void 0:h.current)||C,O=(null===(y=f.current[V])||void 0===y?void 0:y.current)||I}else{var w=Number(t),L=null!==r?Number(r):w;C=(null===(T=s.current[w])||void 0===T?void 0:T.current)||null,I=(null===(B=d.current[L])||void 0===B?void 0:B.current)||null,_=(null===(m=p.current[w])||void 0===m?void 0:m.current)||null,D=(null===(A=f.current[L])||void 0===A?void 0:A.current)||null,b=_||(null===(x=g.current[w])||void 0===x?void 0:x.current)||C,O=D||(null===(E=R.current[L])||void 0===E?void 0:E.current)||I}if(C&&(C.style.paddingTop="0px"),I&&(I.style.paddingTop="0px"),e||(_&&(_.style.marginTop="0px"),D&&(D.style.marginTop="0px")),!e&&_&&D){var q=u.current,F=o.current;if(!N(_,q)||!N(D,F))return;var G=_.getBoundingClientRect(),H=D.getBoundingClientRect(),k=G.top-H.top;if(Math.abs(k)>32)return;k>0&&(D.style.marginTop="".concat(k,"px"))}else if(b&&O&&C&&I){G=b.getBoundingClientRect(),H=O.getBoundingClientRect();(k=G.top-H.top)>0&&(I.style.paddingTop="".concat(k,"px"))}},Y=e.useCallback(function(){var e,t,r,i,l,u,o,c,g=J.current,R=K.current;if(null!==g)if("string"==typeof g&&g.includes(n.DEVIATION_BADGE_SEPARATOR)){var B=g.split(n.DEVIATION_BADGE_SEPARATOR),m=(null===(e=a.current[B[2]])||void 0===e?void 0:e.current)||(null===(t=s.current[Number(B[2])])||void 0===t?void 0:t.current)||null,A=(null===(r=v.current[B[3]])||void 0===r?void 0:r.current)||(null===(i=d.current[Number(B[3])])||void 0===i?void 0:i.current)||null;m&&(m.style.paddingTop="0px"),A&&(A.style.paddingTop="0px")}else{m=(null===(l=s.current[g])||void 0===l?void 0:l.current)||null,A=(null===(u=d.current[null!=R?R:g])||void 0===u?void 0:u.current)||null;m&&(m.style.paddingTop="0px"),A&&(A.style.paddingTop="0px");var x=(null===(o=p.current[g])||void 0===o?void 0:o.current)||null,E=(null===(c=f.current[null!=R?R:g])||void 0===c?void 0:c.current)||null;x&&(x.style.marginTop="0px"),E&&(E.style.marginTop="0px")}S.current&&(S.current.style.height="0px"),h.current&&(h.current.style.height="0px"),y.current&&(y.current.style.height="0px"),T.current&&(T.current.style.height="0px")},[]);e.useEffect(function(){z.current=b},[b]),e.useEffect(function(){J.current=H},[H]);var Z=e.useCallback(function(){W(),O(!1),z.current=!1,j.current=null,Y(),k(null),J.current=null,K.current=null,N(!1),F(!1)},[Y]),$=e.useCallback(function(e,t,a){var v,I,_=null===(v=null==a?void 0:a.toggleIfSame)||void 0===v||v,D=null==a?void 0:a.onReady,P=null!==(I=null==a?void 0:a.sourceSide)&&void 0!==I?I:"left";if(E(),null!=e)if(t)C("No counterpart exists for this section.");else{W();var V=b&&H===e;b&&null!==H&&Y(),V&&_?Z():(m(new Set([e])),A([]),x.current=[],F(!0),M.current=!0,k(e),J.current=e,O(!0),z.current=!0,N(!1),S.current&&(S.current.style.height="0px"),h.current&&(h.current.style.height="0px"),y.current&&(y.current.style.height="0px"),T.current&&(T.current.style.height="0px"),requestAnimationFrame(function(){var t,a,v,y,T,m,A,x,E="string"==typeof e&&e.includes(n.DEVIATION_BADGE_SEPARATOR),C=null,I=null,b=null;if(E){var O=e.split(n.DEVIATION_BADGE_SEPARATOR),_="".concat(O[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(O[1]);C=(null===(t=p.current[_])||void 0===t?void 0:t.current)||null,I=(null===(a=f.current[_])||void 0===a?void 0:a.current)||null,b=I?e:null}else if(C=(null===(v=s.current[e])||void 0===v?void 0:v.current)||(null===(y=g.current[e])||void 0===y?void 0:y.current)||null,r){var V=i[e],w=(null==V?void 0:V.refIndexes)||[];if(w.length>0){var L=w[0],q=l.findIndex(function(e){return e.selfIndex===L});-1!==q&&(I=(null===(A=d.current[q])||void 0===A?void 0:A.current)||(null===(x=R.current[q])||void 0===x?void 0:x.current)||null,b=q)}}else I=(null===(T=d.current[e])||void 0===T?void 0:T.current)||(null===(m=R.current[e])||void 0===m?void 0:m.current)||null,b=I?e:null;K.current=b;var G=u.current,H=o.current,k=function(){X(E,e,b),N(!0),B.current&&B.current(),M.current=!1,"right"===P&&H?H.dispatchEvent(new Event("scroll")):G&&G.dispatchEvent(new Event("scroll")),F(!1),null==D||D()};if(!C||!G)return M.current=!1,F(!1),void(null==D||D());if(I&&H){if(!r){var j=0;j="right"===P?I?I.getBoundingClientRect().top:0:C?C.getBoundingClientRect().top:0;var z=c.current,J=(null==z?void 0:z.getBoundingClientRect().top)||0,Q=z?z.scrollTop+j-J-150:0;return z?void n.smoothScrollTo(z,Q,200,k):void k()}var U=C.getBoundingClientRect().top-G.getBoundingClientRect().top+G.scrollTop,W=I.getBoundingClientRect().top-H.getBoundingClientRect().top+H.scrollTop,Y=200;if("left"===P){var Z=W-(U-G.scrollTop);Z<0&&S.current&&(S.current.style.height="".concat(Math.abs(Z),"px")),requestAnimationFrame(function(){var e,t=H.scrollHeight-H.clientHeight;if(Z<0)e=0;else{if(Z>t){var r=Z-t;return h.current&&(h.current.style.height="".concat(r+150,"px")),void requestAnimationFrame(function(){n.smoothScrollTo(H,Z,Y,k)})}e=Z}n.smoothScrollTo(H,e,Y,k)})}else{var $=U-(W-H.scrollTop);requestAnimationFrame(function(){var e,t=G.scrollHeight-G.clientHeight;if($<0)e=0;else{if($>t)return void requestAnimationFrame(function(){return n.smoothScrollTo(G,t,Y,k)});e=$}n.smoothScrollTo(G,e,Y,k)})}}else k()}))}},[H,E,l,b,r,i,Y,Z]);return{isSideBySide:b,setIsSideBySide:O,isArrowVisible:D,setIsArrowVisible:N,isResizing:V,setIsResizing:w,isSideBySideLoading:q,setIsSideBySideLoading:F,activeSideBySideSection:H,setActiveSideBySideSection:k,scrollLock:M,sideBySideCacheRef:j,isSideBySideRef:z,activeSideBySideSectionRef:J,activeSideBySideRightSectionRef:K,sideBySideLineRef:Q,highlightedClauseRefs:U,clearClauseHighlight:W,applyAlignmentPadding:X,resetSideBySide:Z,activateSideBySide:$}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),n=require("../CognitiveComparehelpers.js");exports.useSideBySide=function(t){var r=t.isGuidelineMode,i=t.maintainRelativeOrder,l=t.proposedSections,u=t.existingSections,o=t.leftContainerRef,c=t.rightContainerRef,s=t.scrollContainerRef,d=t.sectionLeftRefs,a=t.sectionRightRefs,v=t.subSectionLeftRefs,f=t.subSectionRightRefs,p=t.lhsBadgeRefs,g=t.rhsBadgeRefs,R=t.sectionRowRefs,S=t.sectionRightRowRefs,h=t.rhsTopSpacerRef,A=t.rhsBottomSpacerRef,T=t.lhsTopSpacerRef,y=t.lhsBottomSpacerRef,B=t.calculateLinesRef,m=t.setConnectedSections,E=t.setConnectedLines,x=t.cachedConnectedPositions,C=t.closeMoreFunctionsPopup,I=t.setErrorToast;t.moreFunctions,t.closeSummaryPopup;var O=e.useState(!1),_=O[0],b=O[1],D=e.useState(!1),N=D[0],P=D[1],V=e.useState(!1),G=V[0],w=V[1],L=e.useState(!1),q=L[0],F=L[1],H=e.useState(null),M=H[0],k=H[1],j=e.useRef(!1),z=e.useRef(null),J=e.useRef(!1),K=e.useRef(null),Q=e.useRef(null),U=e.useRef(null),W=e.useRef(new Set),X=function(){W.current.forEach(function(e){n.resetClauseHighlight(e)}),W.current.clear()},Y=function(e,t,r){var i,l,u,s,h,A,T,y,B,m,E,x,C=null,I=null,O=null,_=null,b=null,D=null,N=function(e,n){if(!e||!n)return!0;var t=e.getBoundingClientRect(),r=n.getBoundingClientRect();return t.bottom>=r.top&&t.top<=r.bottom};if(e){var P=t.split(n.DEVIATION_BADGE_SEPARATOR),V="".concat(P[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(P[1]);C=(null===(i=v.current[P[2]])||void 0===i?void 0:i.current)||(null===(l=d.current[Number(P[2])])||void 0===l?void 0:l.current)||null,I=(null===(u=f.current[P[3]])||void 0===u?void 0:u.current)||(null===(s=a.current[Number(P[3])])||void 0===s?void 0:s.current)||null,O=(null===(h=p.current[V])||void 0===h?void 0:h.current)||C,_=(null===(A=g.current[V])||void 0===A?void 0:A.current)||I}else{var G=Number(t),w=null!==r?Number(r):G;C=(null===(T=d.current[G])||void 0===T?void 0:T.current)||null,I=(null===(y=a.current[w])||void 0===y?void 0:y.current)||null,b=(null===(B=p.current[G])||void 0===B?void 0:B.current)||null,D=(null===(m=g.current[w])||void 0===m?void 0:m.current)||null,O=b||(null===(E=R.current[G])||void 0===E?void 0:E.current)||C,_=D||(null===(x=S.current[w])||void 0===x?void 0:x.current)||I}if(C&&(C.style.paddingTop="0px"),I&&(I.style.paddingTop="0px"),e||(b&&(b.style.marginTop="0px"),D&&(D.style.marginTop="0px")),!e&&b&&D){var L=o.current,q=c.current;if(!N(b,L)||!N(D,q))return;var F=b.getBoundingClientRect(),H=D.getBoundingClientRect(),M=F.top-H.top;if(Math.abs(M)>32)return;M>0&&(D.style.marginTop="".concat(M,"px"))}else if(O&&_&&C&&I){F=O.getBoundingClientRect(),H=_.getBoundingClientRect();(M=F.top-H.top)>0&&(I.style.paddingTop="".concat(M,"px"))}},Z=e.useCallback(function(){var e,t,r,i,l,u,o,c,s=K.current,R=Q.current;if(null!==s)if("string"==typeof s&&s.includes(n.DEVIATION_BADGE_SEPARATOR)){var S=s.split(n.DEVIATION_BADGE_SEPARATOR),B=(null===(e=v.current[S[2]])||void 0===e?void 0:e.current)||(null===(t=d.current[Number(S[2])])||void 0===t?void 0:t.current)||null,m=(null===(r=f.current[S[3]])||void 0===r?void 0:r.current)||(null===(i=a.current[Number(S[3])])||void 0===i?void 0:i.current)||null;B&&(B.style.paddingTop="0px"),m&&(m.style.paddingTop="0px")}else{B=(null===(l=d.current[s])||void 0===l?void 0:l.current)||null,m=(null===(u=a.current[null!=R?R:s])||void 0===u?void 0:u.current)||null;B&&(B.style.paddingTop="0px"),m&&(m.style.paddingTop="0px");var E=(null===(o=p.current[s])||void 0===o?void 0:o.current)||null,x=(null===(c=g.current[null!=R?R:s])||void 0===c?void 0:c.current)||null;E&&(E.style.marginTop="0px"),x&&(x.style.marginTop="0px")}h.current&&(h.current.style.height="0px"),A.current&&(A.current.style.height="0px"),T.current&&(T.current.style.height="0px"),y.current&&(y.current.style.height="0px")},[]);e.useEffect(function(){J.current=_},[_]),e.useEffect(function(){K.current=M},[M]);var $=e.useCallback(function(){X(),b(!1),J.current=!1,z.current=null,Z(),k(null),K.current=null,Q.current=null,P(!1),F(!1)},[Z]),ee=e.useCallback(function(e,t,v){var f,O,D=null===(f=null==v?void 0:v.toggleIfSame)||void 0===f||f,N=null==v?void 0:v.onReady,V=null!==(O=null==v?void 0:v.sourceSide)&&void 0!==O?O:"left";if(C(),null!=e)if(!t||r){X();var G=_&&M===e;_&&null!==M&&Z(),G&&D?$():(m(new Set([e])),E([]),x.current=[],F(!0),j.current=!0,k(e),K.current=e,b(!0),J.current=!0,P(!1),h.current&&(h.current.style.height="0px"),A.current&&(A.current.style.height="0px"),T.current&&(T.current.style.height="0px"),y.current&&(y.current.style.height="0px"),requestAnimationFrame(function(){var t=function(){var t,v,f,T,y,m,E,x,C,I,O,_="string"==typeof e&&e.includes(n.DEVIATION_BADGE_SEPARATOR),b=null,D=null,G=null;if(r){if(_){var w=e.split(n.DEVIATION_BADGE_SEPARATOR),L="".concat(w[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(w[1]);b=(null===(t=p.current[L])||void 0===t?void 0:t.current)||null}else b=(null===(v=d.current[e])||void 0===v?void 0:v.current)||(null===(f=R.current[e])||void 0===f?void 0:f.current)||null;D=document.getElementById("guideline-target-0"),G=D?e:null}else if(_){w=e.split(n.DEVIATION_BADGE_SEPARATOR),L="".concat(w[0]).concat(n.DEVIATION_BADGE_SEPARATOR).concat(w[1]);b=(null===(T=p.current[L])||void 0===T?void 0:T.current)||null,D=(null===(y=g.current[L])||void 0===y?void 0:y.current)||null,G=D?e:null}else if(b=(null===(m=d.current[e])||void 0===m?void 0:m.current)||(null===(E=R.current[e])||void 0===E?void 0:E.current)||null,i){var q=l[e],H=(null==q?void 0:q.refIndexes)||[];if(H.length>0){var M=H[0],k=u.findIndex(function(e){return e.selfIndex===M});-1!==k&&(D=(null===(I=a.current[k])||void 0===I?void 0:I.current)||(null===(O=S.current[k])||void 0===O?void 0:O.current)||null,G=k)}}else D=(null===(x=a.current[e])||void 0===x?void 0:x.current)||(null===(C=S.current[e])||void 0===C?void 0:C.current)||null,G=D?e:null;Q.current=G;var z=o.current,J=c.current,K=function(){Y(_,e,G),P(!0),B.current&&B.current(),j.current=!1,"right"===V&&J?J.dispatchEvent(new Event("scroll")):z&&z.dispatchEvent(new Event("scroll")),F(!1),null==N||N()};if(!b||!z)return j.current=!1,F(!1),void(null==N||N());if(D&&J){if(!i){var U=0;U="right"===V?D?D.getBoundingClientRect().top:0:b?b.getBoundingClientRect().top:0;var W=s.current,X=(null==W?void 0:W.getBoundingClientRect().top)||0,Z=W?W.scrollTop+U-X-150:0;return W?void n.smoothScrollTo(W,Z,200,K):void K()}var $=b.getBoundingClientRect().top-z.getBoundingClientRect().top+z.scrollTop,ee=D.getBoundingClientRect().top-J.getBoundingClientRect().top+J.scrollTop,ne=200;if("left"===V){var te=ee-($-z.scrollTop);te<0&&h.current&&!r&&(h.current.style.height="".concat(Math.abs(te),"px")),requestAnimationFrame(function(){var e,t=J.scrollHeight-J.clientHeight;if(te<0)e=0;else{if(te>t){var i=te-t;return A.current&&!r&&(A.current.style.height="".concat(i+150,"px")),void requestAnimationFrame(function(){n.smoothScrollTo(J,te,ne,K)})}e=te}n.smoothScrollTo(J,e,ne,K)})}else{var re=$-(ee-J.scrollTop);requestAnimationFrame(function(){var e,t=z.scrollHeight-z.clientHeight;if(re<0)e=0;else{if(re>t)return void requestAnimationFrame(function(){return n.smoothScrollTo(z,t,ne,K)});e=re}n.smoothScrollTo(z,e,ne,K)})}}else K()};r?setTimeout(t,100):t()}))}else I("No counterpart exists for this section.")},[M,C,u,_,i,l,Z,$,r]);return{isSideBySide:_,setIsSideBySide:b,isArrowVisible:N,setIsArrowVisible:P,isResizing:G,setIsResizing:w,isSideBySideLoading:q,setIsSideBySideLoading:F,activeSideBySideSection:M,setActiveSideBySideSection:k,scrollLock:j,sideBySideCacheRef:z,isSideBySideRef:J,activeSideBySideSectionRef:K,activeSideBySideRightSectionRef:Q,sideBySideLineRef:U,highlightedClauseRefs:W,clearClauseHighlight:X,applyAlignmentPadding:Y,resetSideBySide:$,activateSideBySide:ee}};
2
2
  //# sourceMappingURL=useSideBySide.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),n=require("react"),t=require("react-markdown"),i=require("rehype-raw"),l=require("./utils/citationData.utils.js"),c=require("./GptWebCitation.module.css.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=a(t),u=a(i);exports.default=function(t){var i=t.content,a=t.activeHighlightIndex,o=t.onHighlightCountChange,h=n.useRef(null),d=n.useMemo(function(){var e,r=i.match(/id=["']highlighted-\d+["']/g);if(null==r?void 0:r.length)return r.length;var n=i.match(/<a\b[^>]*>/gi);return null!==(e=null==n?void 0:n.length)&&void 0!==e?e:0},[i]),f=n.useMemo(function(){return/id=["']highlighted-\d+["']/.test(i)},[i]);n.useEffect(function(){null==o||o(d)},[d,o]),n.useEffect(function(){var e;if(h.current){var r=h.current.querySelector("#highlighted-".concat(a));if(r)r.scrollIntoView({behavior:"smooth",block:"center"});else null===(e=h.current.querySelectorAll("a[href]")[a])||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})}},[a,i]);var g=n.useMemo(function(){var n=-1;return{span:function(n){n.node;var t=e.__rest(n,["node"]),i=t.id;if(null==i?void 0:i.startsWith("highlighted-")){var l=Number(i.replace("highlighted-",""))===a;return r.jsx("span",e.__assign({},t,{id:i,className:"".concat(c.default.highlight).concat(l?" ".concat(c.default.highlightActive):"")}))}return r.jsx("span",e.__assign({},t))},a:function(t){var i,s=t.children,u=t.href,o=t.title,h=t.className;if(!u)return r.jsx(r.Fragment,{children:s});n+=1;var d=!f&&n===a,g=null!==(i=l.sanitizeExternalUrl(u))&&void 0!==i?i:"#";return r.jsx("a",e.__assign({href:g,title:o,target:"_blank",rel:"noreferrer",className:"".concat(c.default.citationLink).concat(d?" ".concat(c.default.citationLinkActive):"").concat(h?" ".concat(h):"")},{children:s}))},code:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("code",e.__assign({},i,{children:t}))},ol:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("ol",e.__assign({},i,{children:t}))},ul:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("ul",e.__assign({},i,{children:t}))},li:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("li",e.__assign({},i,{children:t}))},p:function(n){var t=n.children,i=e.__rest(n,["children"]);return r.jsx("p",e.__assign({},i,{children:t}))}}},[a,f,i]);return r.jsx("div",e.__assign({ref:h,className:c.default.markdownBody},{children:r.jsx(s.default,e.__assign({rehypePlugins:[u.default],components:g},{children:i}))}))};
2
+ //# sourceMappingURL=GptWebCitationMarkdown.js.map