@viswa-test/test-citation 0.0.159 → 0.0.161

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 (46) hide show
  1. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/components/ScrollLockToggle.js +2 -0
  7. package/dist/cjs/features/CognitiveCompare/components/ScrollLockToggle.js.map +1 -0
  8. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  9. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  10. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  11. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  12. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  13. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  14. package/dist/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
  15. package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
  16. package/dist/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
  17. package/dist/features/CognitiveCompare/components/ScrollLockToggle.js +2 -0
  18. package/dist/features/CognitiveCompare/components/ScrollLockToggle.js.map +1 -0
  19. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  20. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  21. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  22. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  23. package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
  24. package/dist/types/src/CommonConstants/CommonConstants.d.ts +488 -6574
  25. package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
  26. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  27. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -0
  28. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  29. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  30. package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts +3 -0
  31. package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
  32. package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts +1 -1
  33. package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts.map +1 -1
  34. package/dist/types/src/features/CognitiveCompare/components/LHSSectionRow.d.ts.map +1 -1
  35. package/dist/types/src/features/CognitiveCompare/components/RHSSectionRow.d.ts.map +1 -1
  36. package/dist/types/src/features/CognitiveCompare/components/ScrollLockToggle.d.ts +11 -0
  37. package/dist/types/src/features/CognitiveCompare/components/ScrollLockToggle.d.ts.map +1 -0
  38. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  39. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  40. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  41. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  42. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts +1 -1
  43. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  44. package/package.json +7 -7
  45. package/dist/types/src/AutopilotStyle.d.ts +0 -2
  46. package/dist/types/src/AutopilotStyle.d.ts.map +0 -1
@@ -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 i=n.containerRef,r=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;n.sectionRowRefs;var B=n.expandedSections,C=n.expandedSubSections,S=n.connectedSections,m=n.isSideBySide,A=n.activeSideBySideSection,b=n.maintainRelativeOrder,I=n.cognitiveMap,E=n.getSectionCompareStyle,T=n.getSubSectionCompareStyle,M=n.getDeviationStyleByKey,L=n.isArrowVisible,D=n.isAnimatingRef,O=n.isSideBySideRef,H=n.sideBySideCacheRef,P=n.sideBySideLineRef,_=n.activeSideBySideSectionRef;n.activeSideBySideRightSectionRef;var N=n.connectedLines,V=n.setConnectedLines,k=n.cachedConnectedPositions,w=n.calculateLinesRef,G=n.resizeTimerRef,Y=n.scrollLock,j=n.handleResizeRef,F=n.activeProposed,z=n.existingRule,q=n.analysisData,K=n.pendingScrollTargetRef,J=n.pendingScrollCallbackRef,Q=n.resolvedComparisonConfig,U=n.getFieldData,W=t.useState([]),X=W[0],Z=W[1],$=t.useState(null),tt=$[0],et=$[1],nt=t.useState([]),it=nt[0],rt=nt[1],ct=null!=N?N:it,ot=null!=V?V:rt,lt=t.useState({width:0,height:0}),ut=lt[0],at=lt[1],dt=t.useRef(!1),vt=t.useRef(!1),st=t.useRef(null),ht=t.useRef([]),ft=null!=k?k:ht,gt=t.useCallback(function(){var t,n,o,L,O,H,P,_,N,V,k,w,G,Y,j,F,z,q,K,J,Q,U,W;if(!dt.current&&!D.current){dt.current=!0;try{if(!i.current)return;var X=function(t){var e=t.split("-"),n=e[0];if(!B[n]&&!1===b)return!1;if(b&&!B["left-".concat(n)]&&!B["right-".concat(n)]&&!B[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!C[i])return!1;return!0},$=i.current.getBoundingClientRect();at({width:$.width,height:$.height});var tt=[];if(v.forEach(function(t){var e,n,i=t.key,r=null===(e=s.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")}),!D.current){for(var nt=0;nt<Math.max(a.length,d.length);nt++){var it=null===(t=f.current[nt])||void 0===t?void 0:t.current,rt=null===(n=g.current[nt])||void 0===n?void 0:n.current;it&&(it.style.height="auto",it.style.minHeight="0px"),rt&&(rt.style.height="auto",rt.style.minHeight="0px")}b||Object.keys(p.current).forEach(function(t){var e,n;if(X(t)){var i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=R.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 ct={};v.forEach(function(t){var e,n,i=t.key,r=null===(e=s.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 o=r.getBoundingClientRect(),l=c.getBoundingClientRect();ct[i]=Math.max(o.height,l.height)}});var lt={left:{},right:{}},ut={};if(!D.current)if(b){if(m&&null!==A)if("number"==typeof A){var vt=A,st=a[vt],ht=null===(O=f.current[vt])||void 0===O?void 0:O.current;ht&&st&&(st.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=g.current[n])||void 0===e?void 0:e.current;if(i&&(B["left-".concat(vt)]||B["right-".concat(n)])){var r=Math.max(ht.getBoundingClientRect().height,i.getBoundingClientRect().height);lt.left[vt]=Math.max(lt.left[vt]||0,r),lt.right[n]=Math.max(lt.right[n]||0,r)}})}else{var gt=A.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(gt){it=null===(H=p.current[gt])||void 0===H?void 0:H.current,rt=null===(P=R.current[gt])||void 0===P?void 0:P.current;if(it&&rt){pt=Math.max(it.getBoundingClientRect().height,rt.getBoundingClientRect().height);ut[gt]=Math.max(ut[gt]||0,pt)}}}}else{Object.keys(p.current).forEach(function(t){var e,n;if(X(t)){var i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=R.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),o=r.getBoundingClientRect(),l=Math.max(c.height,o.height);ut[t]=l,i.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}});for(nt=0;nt<Math.min(a.length,d.length);nt++){var it=null===(o=f.current[nt])||void 0===o?void 0:o.current,rt=null===(L=g.current[nt])||void 0===L?void 0:L.current;if(it&&rt){var pt=Math.max(it.getBoundingClientRect().height,rt.getBoundingClientRect().height);lt.left[nt]=pt,lt.right[nt]=pt}}}if(v.forEach(function(t){var e,n,i=t.key,r=null===(e=s.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 o=ct[i];r.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),D.current||(Object.entries(lt.left).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"))}),Object.entries(lt.right).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"))}),b||Object.keys(ut).forEach(function(t){var e,n,i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=R.current[t])||void 0===n?void 0:n.current;if(i&&r&&ut[t]){var c=ut[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),b)a.forEach(function(t,e){var n;(null===(n=f.current[e])||void 0===n?void 0:n.current)&&(t.refIndexes||[]).forEach(function(t){var n,i,o,l,u,a,v,s,h,f,g=d.findIndex(function(e){return e.selfIndex===t});if(-1!==g){var p=null===(n=y.current[e])||void 0===n?void 0:n.current,R=null===(i=x.current[g])||void 0===i?void 0:i.current;if(p&&R){var B=p.getBoundingClientRect(),C=R.getBoundingClientRect(),S=B.right-$.left,b=C.left-$.left,I=B.top+B.height/2-$.top,T=C.top+C.height/2-$.top;if(m&&A===e){var M=null!==(l=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,L=null!==(a=null===(u=c.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,D=M+(null!==(s=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==s?s:1/0),O=L+(null!==(f=null===(h=c.current)||void 0===h?void 0:h.clientHeight)&&void 0!==f?f:1/0),H=B.top+B.height/2,P=C.top+C.height/2,_=function(t,e,n){return Math.max(e,Math.min(n,t))};I=_(H,M,D)-$.top,T=_(P,L,O)-$.top}var N=E(e);N&&tt.push({id:"line-".concat(e,"-").concat(g),x1:S,y1:I,x2:b,y2:T,style:N,sectionIdx:e,targetRightIdx:g})}}})});else{for(nt=0;nt<Math.min(a.length,d.length);nt++){var Rt=null===(_=f.current[nt])||void 0===_?void 0:_.current,yt=null===(N=g.current[nt])||void 0===N?void 0:N.current;if(Rt&&yt){var xt=Rt.getBoundingClientRect(),Bt=yt.getBoundingClientRect(),Ct=Math.max(xt.top,Bt.top)+18-$.top,St=(null===(V=d[nt])||void 0===V?void 0:V.id)||"sec-".concat(nt);(Lt=E(nt))&&tt.push({id:St,x1:xt.right-$.left,y1:Ct,x2:Bt.left-$.left,y2:Ct,style:Lt,sectionIdx:nt,hasCognitive:!!((null===(k=a[nt])||void 0===k?void 0:k.cognitiveData)||(null===(w=d[nt])||void 0===w?void 0:w.cognitiveData)||St&&I[St]),isSubSection:!1})}}Object.keys(p.current).forEach(function(t){var n,i,r,c,o,l;if(X(t)){var u=null===(n=p.current[t])||void 0===n?void 0:n.current,v=null===(i=R.current[t])||void 0===i?void 0:i.current;if(u&&v){for(var s=t.split("-").map(Number),h=a[s[0]],f=d[s[0]],g=1;g<s.length;g++)(null==h?void 0:h.subsections)&&(h=h.subsections[s[g]]),(null==f?void 0:f.subsections)&&(f=f.subsections[s[g]]);var y=!!h&&((null===(r=h.displayTitle)||void 0===r||r)&&e.hasValue(h.title)),x=!!h&&((null===(c=h.displayContent)||void 0===c||c)&&e.hasValue(h.content)),B=!!f&&((null===(o=f.displayTitle)||void 0===o||o)&&e.hasValue(f.title)),C=!!f&&((null===(l=f.displayContent)||void 0===l||l)&&e.hasValue(f.content));if(y&&x||B&&C){var S=u.getBoundingClientRect(),m=v.getBoundingClientRect(),A=Math.max(S.top,m.top)+16-$.top,b=T(t);b&&"Not Defined"!==b.label&&tt.push({id:"subsec-".concat(t),x1:S.right-$.left,y1:A,x2:m.left-$.left,y2:A,style:b,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:!(!(null==h?void 0:h.cognitiveData)&&!(null==f?void 0:f.cognitiveData))})}}}})}if(m&&"string"==typeof A&&A.includes(e.DEVIATION_BADGE_SEPARATOR)){var mt=A.split(e.DEVIATION_BADGE_SEPARATOR),At=mt[0],bt=mt[1],It=mt[2],Et=(mt[3],"".concat(At).concat(e.DEVIATION_BADGE_SEPARATOR).concat(bt)),Tt=null===(G=y.current[Et])||void 0===G?void 0:G.current,Mt=null===(Y=x.current[Et])||void 0===Y?void 0:Y.current;if(Tt&&Mt){var Lt,Dt=Tt.getBoundingClientRect(),Ot=Mt.getBoundingClientRect(),Ht=Dt.right-$.left,Pt=Ot.left-$.left,_t=Dt.top+Dt.height/2-$.top,Nt=Ot.top+Ot.height/2-$.top;if(b){var Vt=null!==(F=null===(j=r.current)||void 0===j?void 0:j.getBoundingClientRect().top)&&void 0!==F?F:0,kt=null!==(q=null===(z=c.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==q?q:0,wt=Vt+(null!==(J=null===(K=r.current)||void 0===K?void 0:K.clientHeight)&&void 0!==J?J:1/0),Gt=kt+(null!==(U=null===(Q=c.current)||void 0===Q?void 0:Q.clientHeight)&&void 0!==U?U:1/0),Yt=function(t,e,n){return Math.max(e,Math.min(n,t))};_t=Yt(Dt.top+Dt.height/2,Vt,wt)-$.top,Nt=Yt(Ot.top+Ot.height/2,kt,Gt)-$.top}(Lt=null!==(W=M(At,bt))&&void 0!==W?W:T(It))&&tt.push({id:"line-subsec-".concat(Et),x1:Ht,y1:_t,x2:Pt,y2:Nt,style:Lt,sectionIdx:Number(It.split("-")[0]),isSubSection:!0,subSectionKeyPath:A})}}if(Z(tt),l.current&&u.current){var jt=l.current.getBoundingClientRect(),Ft=u.current.getBoundingClientRect(),zt=(jt.top+jt.height/2-$.top+Ft.top+Ft.height/2-$.top)/2;et({x1:jt.right-$.left,x2:Ft.left-$.left,y:zt})}else et(null);if(S.size>0){var qt=[],Kt=r.current,Jt=c.current;if(Kt&&Jt){var Qt=[],Ut=Kt.getBoundingClientRect().top,Wt=Jt.getBoundingClientRect().top,Xt=Ut+Kt.clientHeight,Zt=Wt+Jt.clientHeight,$t=Kt.scrollTop,te=Jt.scrollTop,ee=$.top,ne=function(t,e,n){return Math.max(e,Math.min(n,t))};S.forEach(function(t){var n,i,r,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===(i=x.current[f])||void 0===i?void 0:i.current;if(!g||!p)return;var R=g.getBoundingClientRect(),B=p.getBoundingClientRect(),C=null!==(r=M(v,s))&&void 0!==r?r:T(h),S=(j=R.right-$.left)+.5*((F=B.left-$.left-0)-j),m=R.top+R.height/2,A=B.top+B.height/2,I=m-Ut+$t,L=A-Wt+te,D="conn-subsec-".concat(f);Qt.push({lhsScrollY:I,rhsScrollY:L,x1:j,x2:F,containerTop:ee,leftIdx:t,rhsArrayIdx:t,styleColor:(null==C?void 0:C.badgeBorder)||"#6366F1",styleId:D});var O=ne(m,Ut,Xt),H=ne(A,Wt,Zt),P=O-ee,_=H-ee,N=A>=Wt-4&&A<=Zt+4,V="";V=(z=m>=Ut-4&&m<=Xt+4)&&N?e.getBentArrowPath(j,P,F,_):z&&!N?"M ".concat(j,",").concat(P," L ").concat(S,",").concat(P," L ").concat(S,",").concat(_):!z&&N?"M ".concat(S,",").concat(P," L ").concat(S,",").concat(_," L ").concat(F,",").concat(_):"M ".concat(S,",").concat(P," L ").concat(S,",").concat(_),qt.push({id:D,pathD:V,style:C,leftIdx:t,rhsArrayIdx:t})}else if(b){var k=t,w=a[k];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(t){var n,i,r=d.findIndex(function(e){return e.selfIndex===t});if(-1!==r){var c=null===(n=y.current[k])||void 0===n?void 0:n.current,o=null===(i=x.current[r])||void 0===i?void 0:i.current;if(c&&o){var l=c.getBoundingClientRect(),u=o.getBoundingClientRect(),a=E(k),v=l.right-$.left,s=u.left-$.left-0,h=v+.5*(s-v),f=l.top+l.height/2,g=u.top+u.height/2,p=f-Ut+$t,R=g-Wt+te,B="conn-".concat(k,"-").concat(r);Qt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:s,containerTop:ee,leftIdx:k,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:B});var C=ne(f,Ut,Xt),S=ne(g,Wt,Zt),m=C-ee,A=S-ee,b=f>=Ut-4&&f<=Xt+4,I=g>=Wt-4&&g<=Zt+4,T="";T=b&&I?e.getBentArrowPath(v,m,s,A):b&&!I?"M ".concat(v,",").concat(m," L ").concat(h,",").concat(m," L ").concat(h,",").concat(A):!b&&I?"M ".concat(h,",").concat(m," L ").concat(h,",").concat(A," L ").concat(s,",").concat(A):"M ".concat(h,",").concat(m," L ").concat(h,",").concat(A),qt.push({id:B,pathD:T,style:a,leftIdx:k,rhsArrayIdx:r})}}})}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(),B=p.getBoundingClientRect(),C=E(G),S=(j=R.right-$.left)+.5*((F=B.left-$.left-0)-j),m=R.top+R.height/2,A=B.top+B.height/2,I=m-Ut+$t,L=A-Wt+te,D="conn-".concat(G,"-").concat(Y);Qt.push({lhsScrollY:I,rhsScrollY:L,x1:j,x2:F,containerTop:ee,leftIdx:G,rhsArrayIdx:Y,styleColor:(null==C?void 0:C.badgeBorder)||"#6366F1",styleId:D});var z;O=ne(m,Ut,Xt),H=ne(A,Wt,Zt),P=O-ee,_=H-ee,N=A>=Wt-4&&A<=Zt+4,V="";V=(z=m>=Ut-4&&m<=Xt+4)&&N?e.getBentArrowPath(j,P,F,_):z&&!N?"M ".concat(j,",").concat(P," L ").concat(S,",").concat(P," L ").concat(S,",").concat(_):!z&&N?"M ".concat(S,",").concat(P," L ").concat(S,",").concat(_," L ").concat(F,",").concat(_):"M ".concat(S,",").concat(P," L ").concat(S,",").concat(_),qt.push({id:D,pathD:V,style:C,leftIdx:G,rhsArrayIdx:Y})}}),ft.current=Qt}ot(qt)}else ot([]),ft.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{dt.current=!1}}},[v,a,d,I,Q,U,E,M,b,m,A,S,B,C]),pt=t.useCallback(function(){var t,n,l,u,a,d,v,s,h,f,g,p,R,y,x=ft.current;if(x.length&&!D.current){var B=null!==(n=null===(t=r.current)||void 0===t?void 0:t.scrollTop)&&void 0!==n?n:0,C=null!==(u=null===(l=c.current)||void 0===l?void 0:l.scrollTop)&&void 0!==u?u:0,S=null!==(d=null===(a=r.current)||void 0===a?void 0:a.clientHeight)&&void 0!==d?d:1/0,m=null!==(s=null===(v=c.current)||void 0===v?void 0:v.clientHeight)&&void 0!==s?s:1/0,A=null!==(f=null===(h=r.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=A+S,E=b+m,T=null!==(y=null===(R=i.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-B+A,i=t.rhsScrollY-C+b,r=o.current[t.styleId+"-stroke"],c=o.current[t.styleId+"-bg"];if(r||c){var l,u=M(n,A,I),a=M(i,b,E),d=u-T,v=a-T,s=n>=A-4&&n<=I+4,h=i>=b-4&&i<=E+4,f=t.x1+.5*(t.x2-t.x1);l=s&&h?e.getBentArrowPath(t.x1,d,t.x2,v):s&&!h?"M ".concat(t.x1,",").concat(d," L ").concat(f,",").concat(d," L ").concat(f,",").concat(v):!s&&h?"M ".concat(f,",").concat(d," L ").concat(f,",").concat(v," L ").concat(t.x2,",").concat(v):"M ".concat(f,",").concat(d," L ").concat(f,",").concat(v),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",l)),c&&(c.setAttribute("visibility","visible"),c.setAttribute("d",l))}})}},[]),Rt=t.useCallback(function(){ft.current.length>0&&!D.current||(null!==st.current&&clearTimeout(st.current),st.current=setTimeout(function(){w.current(),st.current=null},50))},[]),yt=t.useCallback(function(t){if(null!==K.current&&J.current&&Math.abs(t.currentTarget.scrollTop-K.current)<=2){var n=J.current;K.current=null,J.current=null,n()}Y.current||(b||Rt(),vt.current||(vt.current=!0,requestAnimationFrame(function(){var t,n,o,l,u,a,d;if(O.current){var v=r.current,s=c.current;if(v&&s&&P.current){if(!H.current){var h=_.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();H.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=i.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0}}}if(H.current){var x=H.current,B=v.scrollTop-x.initialScrollTop,C=x.badgeScreenY-B,S=((u=C,a=x.leftTop,d=x.leftBottom,Math.max(a,Math.min(d,u)))-x.cTop).toString(),m=C>=x.leftTop-4&&C<=x.leftBottom+4;P.current.setAttribute("y1",S),P.current.setAttribute("y2",S),P.current.setAttribute("visibility",m?"visible":"hidden")}}}ft.current.length>0&&pt(),vt.current=!1})))},[pt,b,Rt]);return t.useEffect(function(){w.current=gt},[gt]),t.useEffect(function(){var t=setTimeout(Rt,250),e=function(){return j.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==st.current&&clearTimeout(st.current),null!==G.current&&clearTimeout(G.current),window.removeEventListener("resize",e)}},[F,z,q,v,B,C,a,d,Q,Rt,m,A,L,S]),{lines:X,setLines:Z,overallConnector:tt,setOverallConnector:et,connectedLines:ct,setConnectedLines:ot,svgDimensions:ut,cachedConnectedPositions:ft,calculateLines:gt,calculateLinesRef:w,calculateLinesDebounced:Rt,handleColumnScroll:yt}};
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,g=n.sectionLeftRefs,f=n.sectionRightRefs,p=n.subSectionLeftRefs,R=n.subSectionRightRefs,x=n.lhsBadgeRefs,y=n.rhsBadgeRefs,A=n.sectionRowRefs,B=n.expandedSections,m=n.expandedSubSections,C=n.connectedSections,S=n.isSideBySide,b=n.activeSideBySideSection,T=n.maintainRelativeOrder,E=n.cognitiveMap,I=n.getSectionCompareStyle,M=n.getSubSectionCompareStyle,D=n.getDeviationStyleByKey,L=n.isArrowVisible,O=n.isAnimatingRef,H=n.isSideBySideRef,_=n.sideBySideCacheRef,P=n.sideBySideLineRef,N=n.activeSideBySideSectionRef,V=n.activeSideBySideRightSectionRef,k=n.connectedLines,w=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!=k?k:ot,at=null!=w?w:lt,dt=t.useState({width:0,height:0}),vt=dt[0],st=dt[1],ht=t.useRef(!1),gt=t.useRef(!1),ft=t.useRef(!1),pt=t.useRef(null),Rt=t.useRef([]),xt=null!=G?G:Rt,yt=t.useCallback(function(){var t,n,o,A,L,H,_,P,N,V,k,w,G,Y,j,F,z,q,K,J,Q,U,W;if(!ht.current&&!O.current){ht.current=!0;try{if(!r.current)return;var X=function(t){var e=t.split("-"),n=e[0];if(!B[n]&&!1===T)return!1;if(T&&!B["left-".concat(n)]&&!B["right-".concat(n)]&&!B[n])return!1;for(var r=n,i=1;i<e.length-1;i++)if(r+="-".concat(e[i]),!m[r])return!1;return!0},Z=r.current.getBoundingClientRect();st({width:Z.width,height:Z.height});var $=[];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 tt=0;tt<Math.max(a.length,d.length);tt++){var nt=null===(t=g.current[tt])||void 0===t?void 0:t.current,rt=null===(n=f.current[tt])||void 0===n?void 0:n.current;nt&&(nt.style.height="auto",nt.style.minHeight="0px"),rt&&(rt.style.height="auto",rt.style.minHeight="0px")}T||Object.keys(p.current).forEach(function(t){var e,n;if(X(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 ct={};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();ct[r]=Math.max(o.height,l.height)}});var ot={left:{},right:{}},lt={};if(!O.current)if(T){if(S&&null!==b)if("number"==typeof b){var ut=b,dt=a[ut],vt=null===(L=g.current[ut])||void 0===L?void 0:L.current;vt&&dt&&(dt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),r=null===(e=f.current[n])||void 0===e?void 0:e.current;if(r&&(B["left-".concat(ut)]||B["right-".concat(n)])){var i=Math.max(vt.getBoundingClientRect().height,r.getBoundingClientRect().height);ot.left[ut]=Math.max(ot.left[ut]||0,i),ot.right[n]=Math.max(ot.right[n]||0,i)}})}else{var gt=b.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(gt){nt=null===(H=p.current[gt])||void 0===H?void 0:H.current,rt=null===(_=R.current[gt])||void 0===_?void 0:_.current;if(nt&&rt){ft=Math.max(nt.getBoundingClientRect().height,rt.getBoundingClientRect().height);lt[gt]=Math.max(lt[gt]||0,ft)}}}}else{Object.keys(p.current).forEach(function(t){var e,n;if(X(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);lt[t]=l,r.style.minHeight="".concat(l,"px"),i.style.minHeight="".concat(l,"px")}}});for(tt=0;tt<Math.min(a.length,d.length);tt++){var nt=null===(o=g.current[tt])||void 0===o?void 0:o.current,rt=null===(A=f.current[tt])||void 0===A?void 0:A.current;if(nt&&rt){var ft=Math.max(nt.getBoundingClientRect().height,rt.getBoundingClientRect().height);ot.left[tt]=ft,ot.right[tt]=ft}}}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;if(i&&c){var o=ct[r];i.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),O.current||(Object.entries(ot.left).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"))}),Object.entries(ot.right).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"))}),T||Object.keys(lt).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&&lt[t]){var c=lt[t];r.style.minHeight="".concat(c,"px"),i.style.minHeight="".concat(c,"px")}})),T)a.forEach(function(t,e){var n;(null===(n=g.current[e])||void 0===n?void 0:n.current)&&(t.refIndexes||[]).forEach(function(t){var n,r,o,l,u,a,v,s,h,g,f=d.findIndex(function(e){return e.selfIndex===t});if(-1!==f){var p=null===(n=x.current[e])||void 0===n?void 0:n.current,R=null===(r=y.current[f])||void 0===r?void 0:r.current;if(p&&R){var A=p.getBoundingClientRect(),B=R.getBoundingClientRect(),m=A.right-Z.left,C=B.left-Z.left,T=A.top+A.height/2-Z.top,E=B.top+B.height/2-Z.top;if(S&&b===e){var M=null!==(l=null===(o=i.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,D=null!==(a=null===(u=c.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,L=M+(null!==(s=null===(v=i.current)||void 0===v?void 0:v.clientHeight)&&void 0!==s?s:1/0),O=D+(null!==(g=null===(h=c.current)||void 0===h?void 0:h.clientHeight)&&void 0!==g?g:1/0),H=A.top+A.height/2,_=B.top+B.height/2,P=function(t,e,n){return Math.max(e,Math.min(n,t))};T=P(H,M,L)-Z.top,E=P(_,D,O)-Z.top}var N=I(e);N&&$.push({id:"line-".concat(e,"-").concat(f),x1:m,y1:T,x2:C,y2:E,style:N,sectionIdx:e,targetRightIdx:f})}}})});else{for(tt=0;tt<Math.min(a.length,d.length);tt++){var pt=null===(P=g.current[tt])||void 0===P?void 0:P.current,Rt=null===(N=f.current[tt])||void 0===N?void 0:N.current;if(pt&&Rt){var yt=pt.getBoundingClientRect(),At=Rt.getBoundingClientRect(),Bt=Math.max(yt.top,At.top)+18-Z.top,mt=(null===(V=d[tt])||void 0===V?void 0:V.id)||"sec-".concat(tt);(Dt=I(tt))&&$.push({id:mt,x1:yt.right-Z.left,y1:Bt,x2:At.left-Z.left,y2:Bt,style:Dt,sectionIdx:tt,hasCognitive:!!((null===(k=a[tt])||void 0===k?void 0:k.cognitiveData)||(null===(w=d[tt])||void 0===w?void 0:w.cognitiveData)||mt&&E[mt]),isSubSection:!1})}}Object.keys(p.current).forEach(function(t){var n,r,i,c,o,l;if(X(t)){var u=null===(n=p.current[t])||void 0===n?void 0:n.current,v=null===(r=R.current[t])||void 0===r?void 0:r.current;if(u&&v){for(var s=t.split("-").map(Number),h=a[s[0]],g=d[s[0]],f=1;f<s.length;f++)(null==h?void 0:h.subsections)&&(h=h.subsections[s[f]]),(null==g?void 0:g.subsections)&&(g=g.subsections[s[f]]);var x=!!h&&((null===(i=h.displayTitle)||void 0===i||i)&&e.hasValue(h.title)),y=!!h&&((null===(c=h.displayContent)||void 0===c||c)&&e.hasValue(h.content)),A=!!g&&((null===(o=g.displayTitle)||void 0===o||o)&&e.hasValue(g.title)),B=!!g&&((null===(l=g.displayContent)||void 0===l||l)&&e.hasValue(g.content));if(x&&y||A&&B){var m=u.getBoundingClientRect(),C=v.getBoundingClientRect(),S=Math.max(m.top,C.top)+16-Z.top,b=M(t);b&&"Not Defined"!==b.label&&$.push({id:"subsec-".concat(t),x1:m.right-Z.left,y1:S,x2:C.left-Z.left,y2:S,style:b,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:!(!(null==h?void 0:h.cognitiveData)&&!(null==g?void 0:g.cognitiveData))})}}}})}if(S&&"string"==typeof b&&b.includes(e.DEVIATION_BADGE_SEPARATOR)){var Ct=b.split(e.DEVIATION_BADGE_SEPARATOR),St=Ct[0],bt=Ct[1],Tt=Ct[2],Et=(Ct[3],"".concat(St).concat(e.DEVIATION_BADGE_SEPARATOR).concat(bt)),It=null===(G=x.current[Et])||void 0===G?void 0:G.current,Mt=null===(Y=y.current[Et])||void 0===Y?void 0:Y.current;if(It&&Mt){var Dt,Lt=It.getBoundingClientRect(),Ot=Mt.getBoundingClientRect(),Ht=Lt.right-Z.left,_t=Ot.left-Z.left,Pt=Lt.top+Lt.height/2-Z.top,Nt=Ot.top+Ot.height/2-Z.top;if(T){var Vt=null!==(F=null===(j=i.current)||void 0===j?void 0:j.getBoundingClientRect().top)&&void 0!==F?F:0,kt=null!==(q=null===(z=c.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==q?q:0,wt=Vt+(null!==(J=null===(K=i.current)||void 0===K?void 0:K.clientHeight)&&void 0!==J?J:1/0),Gt=kt+(null!==(U=null===(Q=c.current)||void 0===Q?void 0:Q.clientHeight)&&void 0!==U?U:1/0),Yt=function(t,e,n){return Math.max(e,Math.min(n,t))};Pt=Yt(Lt.top+Lt.height/2,Vt,wt)-Z.top,Nt=Yt(Ot.top+Ot.height/2,kt,Gt)-Z.top}(Dt=null!==(W=D(St,bt))&&void 0!==W?W:M(Tt))&&$.push({id:"line-subsec-".concat(Et),x1:Ht,y1:Pt,x2:_t,y2:Nt,style:Dt,sectionIdx:Number(Tt.split("-")[0]),isSubSection:!0,subSectionKeyPath:b})}}if(et($),l.current&&u.current){var jt=l.current.getBoundingClientRect(),Ft=u.current.getBoundingClientRect(),zt=(jt.top+jt.height/2-Z.top+Ft.top+Ft.height/2-Z.top)/2;it({x1:jt.right-Z.left,x2:Ft.left-Z.left,y:zt})}else it(null);if(C.size>0){var qt=[],Kt=i.current,Jt=c.current;if(Kt&&Jt){var Qt=[],Ut=Kt.getBoundingClientRect().top,Wt=Jt.getBoundingClientRect().top,Xt=Ut+Kt.clientHeight,Zt=Wt+Jt.clientHeight,$t=Kt.scrollTop,te=Jt.scrollTop,ee=Z.top,ne=function(t,e,n){return Math.max(e,Math.min(n,t))};C.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],g=(u[3],"".concat(v).concat(e.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=x.current[g])||void 0===n?void 0:n.current,p=null===(r=y.current[g])||void 0===r?void 0:r.current;if(!f||!p)return;var R=f.getBoundingClientRect(),A=p.getBoundingClientRect(),B=null!==(i=D(v,s))&&void 0!==i?i:M(h),m=(j=R.right-Z.left)+.5*((F=A.left-Z.left-0)-j),C=R.top+R.height/2,S=A.top+A.height/2,b=C-Ut+$t,E=S-Wt+te,L="conn-subsec-".concat(g);Qt.push({lhsScrollY:b,rhsScrollY:E,x1:j,x2:F,containerTop:ee,leftIdx:t,rhsArrayIdx:t,styleColor:(null==B?void 0:B.badgeBorder)||"#6366F1",styleId:L});var O=ne(C,Ut,Xt),H=ne(S,Wt,Zt),_=O-ee,P=H-ee,N=S>=Wt-4&&S<=Zt+4,V="";V=(z=C>=Ut-4&&C<=Xt+4)&&N?e.getBentArrowPath(j,_,F,P):z&&!N?"M ".concat(j,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(P):!z&&N?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P," L ").concat(F,",").concat(P):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P),qt.push({id:L,pathD:V,style:B,leftIdx:t,rhsArrayIdx:t})}else if(T){var k=t,w=a[k];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(t){var n,r,i=d.findIndex(function(e){return e.selfIndex===t});if(-1!==i){var c=null===(n=x.current[k])||void 0===n?void 0:n.current,o=null===(r=y.current[i])||void 0===r?void 0:r.current;if(c&&o){var l=c.getBoundingClientRect(),u=o.getBoundingClientRect(),a=I(k),v=l.right-Z.left,s=u.left-Z.left-0,h=v+.5*(s-v),g=l.top+l.height/2,f=u.top+u.height/2,p=g-Ut+$t,R=f-Wt+te,A="conn-".concat(k,"-").concat(i);Qt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:s,containerTop:ee,leftIdx:k,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:A});var B=ne(g,Ut,Xt),m=ne(f,Wt,Zt),C=B-ee,S=m-ee,b=g>=Ut-4&&g<=Xt+4,T=f>=Wt-4&&f<=Zt+4,E="";E=b&&T?e.getBentArrowPath(v,C,s,S):b&&!T?"M ".concat(v,",").concat(C," L ").concat(h,",").concat(C," L ").concat(h,",").concat(S):!b&&T?"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S," L ").concat(s,",").concat(S):"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S),qt.push({id:A,pathD:E,style:a,leftIdx:k,rhsArrayIdx:i})}}})}else{var G=t,Y=G;f=null===(c=x.current[G])||void 0===c?void 0:c.current,p=null===(o=y.current[Y])||void 0===o?void 0:o.current;if(!f||!p)return;var j,F;R=f.getBoundingClientRect(),A=p.getBoundingClientRect(),B=I(G),m=(j=R.right-Z.left)+.5*((F=A.left-Z.left-0)-j),C=R.top+R.height/2,S=A.top+A.height/2,b=C-Ut+$t,E=S-Wt+te,L="conn-".concat(G,"-").concat(Y);Qt.push({lhsScrollY:b,rhsScrollY:E,x1:j,x2:F,containerTop:ee,leftIdx:G,rhsArrayIdx:Y,styleColor:(null==B?void 0:B.badgeBorder)||"#6366F1",styleId:L});var z;O=ne(C,Ut,Xt),H=ne(S,Wt,Zt),_=O-ee,P=H-ee,N=S>=Wt-4&&S<=Zt+4,V="";V=(z=C>=Ut-4&&C<=Xt+4)&&N?e.getBentArrowPath(j,_,F,P):z&&!N?"M ".concat(j,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(P):!z&&N?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P," L ").concat(F,",").concat(P):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(P),qt.push({id:L,pathD:V,style:B,leftIdx:G,rhsArrayIdx:Y})}}),xt.current=Qt}at(qt)}else at([]),xt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{ht.current=!1}}},[v,a,d,E,X,Z,I,D,T,S,b,C,B,m]),At=t.useCallback(function(){var t,n,l,u,a,d,v,s,h,g,f,p,R,x,y=xt.current;if(y.length&&!O.current){var A=null!==(n=null===(t=i.current)||void 0===t?void 0:t.scrollTop)&&void 0!==n?n:0,B=null!==(u=null===(l=c.current)||void 0===l?void 0:l.scrollTop)&&void 0!==u?u:0,m=null!==(d=null===(a=i.current)||void 0===a?void 0:a.clientHeight)&&void 0!==d?d:1/0,C=null!==(s=null===(v=c.current)||void 0===v?void 0:v.clientHeight)&&void 0!==s?s:1/0,S=null!==(g=null===(h=i.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==g?g:0,b=null!==(p=null===(f=c.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==p?p:0,T=S+m,E=b+C,I=null!==(x=null===(R=r.current)||void 0===R?void 0:R.getBoundingClientRect().top)&&void 0!==x?x:0,M=function(t,e,n){return Math.max(e,Math.min(n,t))};y.forEach(function(t){var n=t.lhsScrollY-A+S,r=t.rhsScrollY-B+b,i=o.current[t.styleId+"-stroke"],c=o.current[t.styleId+"-bg"];if(i||c){var l,u=M(n,S,T),a=M(r,b,E),d=u-I,v=a-I,s=n>=S-4&&n<=T+4,h=r>=b-4&&r<=E+4,g=t.x1+.5*(t.x2-t.x1);l=s&&h?e.getBentArrowPath(t.x1,d,t.x2,v):s&&!h?"M ".concat(t.x1,",").concat(d," L ").concat(g,",").concat(d," L ").concat(g,",").concat(v):!s&&h?"M ".concat(g,",").concat(d," L ").concat(g,",").concat(v," L ").concat(t.x2,",").concat(v):"M ".concat(g,",").concat(d," L ").concat(g,",").concat(v),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),c&&(c.setAttribute("visibility","visible"),c.setAttribute("d",l))}})}},[]),Bt=t.useCallback(function(){xt.current.length>0&&!O.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),mt=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(!ft.current&&!F.current){if(T&&z&&(H.current||C.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=V.current;if(null===s)return{leftAnchor:null,rightAnchor:null};if("string"==typeof s&&s.includes(e.DEVIATION_BADGE_SEPARATOR)){var B=s.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(B[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(B[1]);return{leftAnchor:(null===(t=x.current[m])||void 0===t?void 0:t.current)||(null===(n=p.current[B[2]])||void 0===n?void 0:n.current)||(null===(r=g.current[Number(B[2])])||void 0===r?void 0:r.current)||null,rightAnchor:(null===(i=y.current[m])||void 0===i?void 0:i.current)||(null===(c=R.current[B[3]])||void 0===c?void 0:c.current)||(null===(o=f.current[Number(B[3])])||void 0===o?void 0:o.current)||null}}var C=Number(s),S=null!==h?Number(h):C;return{leftAnchor:(null===(l=x.current[C])||void 0===l?void 0:l.current)||(null===(u=A.current[C])||void 0===u?void 0:u.current)||(null===(a=g.current[C])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(v=f.current[S])||void 0===v?void 0:v.current)||null}}(),v=d.leftAnchor,s=d.rightAnchor,h=o===l?v:s,B=o===l?s:v,m=null;if(h&&B){var S=h.getBoundingClientRect(),b=B.getBoundingClientRect(),E=a.getBoundingClientRect(),I=S.top+S.height/2;m=b.top-E.top+a.scrollTop+b.height/2-(I-E.top)}else{var M=Math.max(0,o.scrollHeight-o.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?o.scrollTop/M*D:o.scrollTop}var L=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,L)),Math.abs(a.scrollTop-m)>1&&(ft.current=!0,a.scrollTop=m,requestAnimationFrame(function(){ft.current=!1}))}}T||Bt(),gt.current||(gt.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,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),p="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=x.current[p])||void 0===t?void 0:t.current}else g=null===(n=x.current[h])||void 0===n?void 0:n.current;if(g){var R=g.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 y=_.current,A=v.scrollTop-y.initialScrollTop,B=y.badgeScreenY-A,m=((u=B,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),C=B>=y.leftTop-4&&B<=y.leftBottom+4;P.current.setAttribute("y1",m),P.current.setAttribute("y2",m),P.current.setAttribute("visibility",C?"visible":"hidden")}}}xt.current.length>0&&At(),gt.current=!1}))}},[At,T,z,C,Bt]);return t.useEffect(function(){Y.current=yt},[yt]),t.useEffect(function(){var t=setTimeout(Bt,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,B,m,a,d,X,Bt,S,b,L,C]),{lines:tt,setLines:et,overallConnector:rt,setOverallConnector:it,connectedLines:ut,setConnectedLines:at,svgDimensions:vt,cachedConnectedPositions:xt,calculateLines:yt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:mt}};
2
2
  //# sourceMappingURL=useLinesCalculator.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as i}from"tslib";import{jsx as n,jsxs as t}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as a}from"react";import{Box as s,Snackbar as d,Alert as c,Tooltip as v,Typography as f}from"@mui/material";import{ChevronDown as p}from"lucide-react";import{ButtonCognitiveIcon as m}from"../../assests/svg/ButtonCognitiveIcon.js";import g from"./OverlayComponent.js";import{safeStringify as h,extractDeviationScore as S,generateColorPalette as x,findKeyPathByNodeId as R,hasMeaningfulRedlineTags as y,DEVIATION_BADGE_SEPARATOR as b,scrollAndHighlightClause as C}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as w,DEFAULT_FIELD_CONFIG as _,DEFAULT_COMPARISON_CONFIG as B}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as F,EMPTY_SUMMARY_POPUP_STATE as I,DEFAULT_COMPONENT_HEADER_TEXT as T}from"./CognitiveCompareConstants.js";import E from"./CognitivePopup.js";import A from"./MoreFunctionsPopup.js";import D from"./LoaderComponent.js";import j from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as k}from"./hooks/useCompareData.js";import{useComparePopups as P}from"./hooks/useComparePopups.js";import{useSectionRefs as L}from"./hooks/useSectionRefs.js";import{useAccordionState as O}from"./hooks/useAccordionState.js";import{useDeviationNavigation as N}from"./hooks/useDeviationNavigation.js";import H from"./components/CompareHeader.js";import z from"./components/SubSectionAccordion.js";import M from"./components/LHSSectionRow.js";import q from"./components/RHSSectionRow.js";import W from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as V}from"./CompareContext.js";import{useStyleHelpers as K}from"./hooks/useStyles.js";import{useResizeHandler as Y}from"./hooks/useResizeHandler.js";import{useLinesCalculator as X}from"./hooks/useLinesCalculator.js";import{useSideBySide as $}from"./hooks/useSideBySide.js";import J from"./components/SvgConnectors.js";var U=function(U){var G,Q,Z,ee,ie,ne,te,oe,re,le,ue,ae,se,de,ce,ve,fe,pe,me,ge,he,Se,xe,Re,ye,be,Ce,we,_e,Be,Fe,Ie,Te,Ee,Ae=U.componentHeaderText,De=void 0===Ae?T:Ae,je=U.treeData,ke=U.comparisonConfig,Pe=U.leftColumnTitleText,Le=U.rightColumnTitleText,Oe=U.markdownStyles,Ne=U.resetTrigger,He=U.displayConfig,ze=void 0===He?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0}:He,Me=U.popupConfig,qe=U.deviationData,We=void 0===qe?{}:qe,Ve=U.deviationNodeIdToView,Ke=U.resetDeviationNodeId,Ye=U.isProposingFix,Xe=void 0!==Ye&&Ye,$e=U.proposingFixNodeId,Je=U.isRedlineFlow,Ue=o(ze.maintainRelativeOrder),Ge=Ue[0],Qe=Ue[1],Ze=!!Ge||!!(null==ze?void 0:ze.showDeviationBadges),ei=o(!1),ii=ei[0],ni=ei[1],ti=o(null),oi=ti[0],ri=ti[1],li=o(null===(Q=null!==(G=null==je?void 0:je.newEvaluationResult)&&void 0!==G?G:null==ze?void 0:ze.enableDeviationSchemaBackwardCompatibility)||void 0===Q||Q)[0],ui=o(new Set),ai=ui[0],si=ui[1],di=o([]),ci=di[0],vi=di[1],fi=r(null),pi=r(null),mi=r(null),gi=r(null),hi=r(null),Si=r(!1),xi=r(null),Ri=r({}),yi=r([]),bi=r(function(){}),Ci=r(null),wi=r(function(){}),_i=l(function(){return(null==je?void 0:je.cognitive_decisioning)||{}},[je]),Bi=l(function(){return e(e({},w),Oe)},[Oe]),Fi=r(null),Ii=r(null),Ti=r(null),Ei=r(null),Ai=r(null),Di=r(null),ji=r(null),ki=r(null),Pi=r(null),Li=r(null),Oi=P(Fi),Ni=Oi.cognitivePopup,Hi=Oi.setCognitivePopup,zi=Oi.moreFunctions,Mi=Oi.setMoreFunctions,qi=Oi.position,Wi=Oi.setPosition,Vi=Oi.activeBadgeId,Ki=Oi.summaryPopup,Yi=Oi.setSummaryPopup,Xi=Oi.closeSummaryPopup,$i=Oi.setActiveBadgeId,Ji=Oi.popupRef,Ui=Oi.handleOpenCognitiveCompare,Gi=Oi.openCognitivePopupFromState,Qi=Oi.closeCognitivePopup,Zi=Oi.closeMoreFunctionsPopup,en=l(function(){var e,i,n,t,o,r,l;return{fields:null!==(e=null==ke?void 0:ke.fields)&&void 0!==e?e:_,thresholds:{high:null!==(n=null===(i=null==ke?void 0:ke.thresholds)||void 0===i?void 0:i.high)&&void 0!==n?n:B.thresholds.high,medium:null!==(o=null===(t=null==ke?void 0:ke.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:B.thresholds.medium,exact:null!==(l=null===(r=null==ke?void 0:ke.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:B.thresholds.exact}}},[ke]),nn=o(null),tn=nn[0];nn[1];var on=null===(ie=null===(Z=null==je?void 0:je.documents)||void 0===Z?void 0:Z[null===(ee=null==je?void 0:je.input_index_map)||void 0===ee?void 0:ee[0]])||void 0===ie?void 0:ie.title,rn=null===(oe=null===(ne=null==je?void 0:je.documents)||void 0===ne?void 0:ne[null===(te=null==je?void 0:je.input_index_map)||void 0===te?void 0:te[1]])||void 0===oe?void 0:oe.title,ln=h(Pe||on||"Uploaded Contract"),un=null===(ae=null===(ue=null===(re=null==je?void 0:je.documents)||void 0===re?void 0:re[null===(le=null==je?void 0:je.input_index_map)||void 0===le?void 0:le[0]])||void 0===ue?void 0:ue.metadata)||void 0===ae?void 0:ae.file_name,an=h(un),sn=null===(ve=null===(ce=null===(se=null==je?void 0:je.documents)||void 0===se?void 0:se[null===(de=null==je?void 0:je.input_index_map)||void 0===de?void 0:de[1]])||void 0===ce?void 0:ce.metadata)||void 0===ve?void 0:ve.file_name,dn=h(sn),cn=h(Le||rn||"Reference Template"),vn=k(je,Ge,We,en,li),fn=vn.activeProposed,pn=vn.existingRule,mn=vn.proposedSections,gn=vn.existingSections,hn=vn.visibleFields,Sn=vn.parentDeviationRecord,xn=vn.deviationNumberRegistry,Rn=vn.parseError;u(function(){Rn&&ri("Failed to load comparison: ".concat(Rn))},[Rn]);var yn=mn.length>0||gn.length>0,bn=l(function(){if(!Je)return"off";var e=0,i=0,n=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";y(r)&&(e+=1,i+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&n(t.subsections)})};return n(mn),n(gn),"".concat(e,":").concat(i)},[Je,mn,gn]),Cn=L(hn.map(function(e){return e.key}),Math.max(mn.length,gn.length)),wn=Cn.leftRefs,_n=Cn.rightRefs,Bn=Cn.sectionLeftRefs,Fn=Cn.sectionRightRefs,In=Cn.lhsBadgeRefs,Tn=Cn.rhsBadgeRefs,En=Cn.sectionRightRowRefs,An=Cn.subSectionLeftRefs,Dn=Cn.subSectionRightRefs,jn=Cn.sectionRowRefs,kn=Cn.getSectionRowRef,Pn=Cn.getSubSectionRef,Ln=Cn.getBadgeRef,On=$({maintainRelativeOrder:Ge,proposedSections:mn,existingSections:gn,leftContainerRef:ki,rightContainerRef:Ti,scrollContainerRef:Fi,sectionLeftRefs:Bn,sectionRightRefs:Fn,subSectionLeftRefs:An,subSectionRightRefs:Dn,lhsBadgeRefs:In,rhsBadgeRefs:Tn,sectionRowRefs:jn,sectionRightRowRefs:En,rhsTopSpacerRef:Ei,rhsBottomSpacerRef:Ai,lhsTopSpacerRef:Di,lhsBottomSpacerRef:ji,calculateLinesRef:bi,setConnectedSections:si,setConnectedLines:vi,cachedConnectedPositions:yi,closeMoreFunctionsPopup:Zi,setErrorToast:ri,moreFunctions:zi,closeSummaryPopup:Xi}),Nn=On.isSideBySide,Hn=On.isArrowVisible,zn=On.setIsArrowVisible,Mn=On.isResizing,qn=On.setIsResizing,Wn=On.isSideBySideLoading,Vn=On.activeSideBySideSection,Kn=On.scrollLock,Yn=On.sideBySideCacheRef,Xn=On.isSideBySideRef,$n=On.activeSideBySideRightSectionRef,Jn=On.activeSideBySideSectionRef,Un=On.sideBySideLineRef,Gn=On.highlightedClauseRefs,Qn=On.clearClauseHighlight,Zn=On.resetSideBySide,et=On.activateSideBySide,it=O({maintainRelativeOrder:!!Ge,proposedSections:mn,existingSections:gn,activeSideBySideSection:Vn,connectedSections:ai,resetSideBySide:Zn,setConnectedSections:si,setConnectedLines:vi,cachedConnectedPositions:yi,svgContainerRef:fi,isAnimatingRef:Si,animationTimerRef:xi,calculateLinesRef:bi,sectionLeftRefs:Bn,sectionRightRefs:Fn,subSectionLeftRefs:An,subSectionRightRefs:Dn}),nt=it.expandedSections,tt=it.setExpandedSections,ot=it.expandedSubSections,rt=it.setExpandedSubSections,lt=it.handleSubSectionToggle,ut=it.toggleSection,at=it.forceExpandCrossWiredSections;u(function(){Je&&"off"!==bn&&"0:0"!==bn&&(Yn.current=null,yi.current=[],requestAnimationFrame(function(){var e;null===(e=bi.current)||void 0===e||e.call(bi)}))},[Je,bn]);var st=l(function(){var e=new Map,i=new Map,n=1;if(Ge)mn.forEach(function(i){!i.title&&!i.content||i.id&&e.set(i.id,n++)}),gn.forEach(function(t){if(t.id){var o=mn.filter(function(e){var i;return null===(i=e.refIndexes)||void 0===i?void 0:i.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(i){return e.get(i.id)}).filter(Boolean);i.set(t.id,r.join(", "))}else i.set(t.id,String(n++))}});else for(var t=Math.max(mn.length,gn.length),o=0;o<t;o++){var r=mn[o],l=gn[o];r?(e.set(r.id,n),l&&i.set(l.id,String(n)),n++):l&&i.set(l.id,String(n++))}return{leftNums:e,rightNums:i}},[mn,gn,Ge]),dt=pn.analysis,ct=h(null===(pe=null===(fe=null==dt?void 0:dt.rule_difference_comparison)||void 0===fe?void 0:fe.summary)||void 0===pe?void 0:pe.overall_summary),vt=!!ct.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),ft=null!==(me=null==je?void 0:je.base_root_id)&&void 0!==me?me:"-1";null==je||je[ft];var pt=li?null!==(Fe=null!==(we=We&&(null===(Ce=null==We?void 0:We[ft])||void 0===Ce?void 0:Ce.evaluation_result))&&void 0!==we?we:null===(Be=null===(_e=null==je?void 0:je.nodes)||void 0===_e?void 0:_e[ft])||void 0===Be?void 0:Be.evaluation_result)&&void 0!==Fe?Fe:null:null!==(be=null!==(Se=We&&(null===(he=null===(ge=null==We?void 0:We[ft])||void 0===ge?void 0:ge.evaluation_result)||void 0===he?void 0:he[0]))&&void 0!==Se?Se:null===(ye=null===(Re=null===(xe=null==je?void 0:je.nodes)||void 0===xe?void 0:xe[ft])||void 0===Re?void 0:Re.evaluation_result)||void 0===ye?void 0:ye[0])&&void 0!==be?be:null,mt=S(pt),gt=x(null!==(Ee=null===(Te=null===(Ie=null==pt?void 0:pt.evaluation_outputs)||void 0===Ie?void 0:Ie.metadata)||void 0===Te?void 0:Te.label_color)&&void 0!==Ee?Ee:F),ht=a(function(){Qn(),Zn(),si(new Set),vi([]),yi.current=[],Dt([]),kt(null),Yi(I),Qi(),requestAnimationFrame(function(){var e;null===(e=bi.current)||void 0===e||e.call(bi)})},[]),St=r(ht);u(function(){St.current=ht},[ht]),u(function(){Ne&&St.current()},[Ne]);var xt=a(function(i,n,t,o,r,l,u){var a,s,d,c=h(null==n?void 0:n.id)||h(null==t?void 0:t.id)||"",v=(c?_i[c]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:c,decisioning:[],gap:[],relevance_score:0},f=null!==(s=null===(a=jn.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==ze?void 0:ze.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==n?void 0:n.title)?null==n?void 0:n.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:v,anchorEl:i,sectionAnchorEl:f,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==je?void 0:je.documents,input_index_map:null==je?void 0:je.input_index_map},deviationData:function(){var i,r,l=(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(i){var n=function(e){if(!e||"object"!=typeof e)return null;var i=null==e?void 0:e.deviation_entries;if(i&&"object"==typeof i){var n=Object.keys(i).sort(function(e,i){return Number(e)-Number(i)})[0];if(n&&i[n])return i[n]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,i){return Number(e)-Number(i)});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,i){return Number(e)-Number(i)})[0];if(r&&o[r])return o[r]}return null}(i);return n?e(e({},i),{deviation_summary:(null==i?void 0:i.deviation_summary)||(null==n?void 0:n.deviation_summary),deviation_title:(null==i?void 0:i.deviation_title)||(null==n?void 0:n.deviation_title),deviation_impact:(null==i?void 0:i.deviation_impact)||(null==n?void 0:n.deviation_impact),deviation_explanation:(null==i?void 0:i.deviation_explanation)||(null==n?void 0:n.deviation_explanation),evaluation_outputs:(null==i?void 0:i.evaluation_outputs)||(null==n?void 0:n.evaluation_outputs),cognitive_decisioning:(null==i?void 0:i.cognitive_decisioning)||(null==n?void 0:n.cognitive_decisioning)}):i};if(!("string"==typeof o&&o.includes(b)))return u(l);var a=o.split(b)[1];if(!a)return l;var s=(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},d=(null===(i=null==s?void 0:s.deviation_entries)||void 0===i?void 0:i[a])||(null===(r=null==s?void 0:s.deviations)||void 0===r?void 0:r[a])||null;return d?e(e(e({},s),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==s?void 0:s.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==s?void 0:s.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==s?void 0:s.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==s?void 0:s.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==s?void 0:s.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==s?void 0:s.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[_i,je]),Rt=a(function(){var e=zi.sectionIdx,i=zi.isOrphan;Zi(),Xi(),null!==e&&(i?ri("No counterpart exists to connect to."):(at(e),Qn(),Xn.current&&Zn(),vi([]),yi.current=[],si(function(i){return i.has(e)?new Set:new Set([e])}),setTimeout(function(){bi.current&&bi.current()},50)))},[zi.sectionIdx,zi.isOrphan,Zi,Xi,Zn]),yt=a(function(){var e=hi.current;if(e){hi.current=null;var i=mn.findIndex(function(i){return i.id===e}),n=gn.findIndex(function(i){return i.id===e}),t=-1===i?R(mn,e):null,o=-1===n?R(gn,e):null,r=-1!==i?i:t?Number(t.split("-")[0]):-1,l=-1!==n?n:o?Number(o.split("-")[0]):-1,u=function(e,i,n,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=n.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:i&&null!==(u=null===(l=t.current[i])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,i,n){void 0===n&&(n=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Gn.current.add(r),C(r,i)):t++<n&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Ge)-1!==r&&ki.current&&a(function(){return u(i,t,Bn,An)},ki.current),-1!==l&&Ti.current&&a(function(){return u(n,o,Fn,Dn)},Ti.current);else{var s=Fi.current;if(!s)return;a(function(){return-1!==r?u(i,t,Bn,An):u(n,o,Fn,Dn)},s)}}},[mn,gn,Ge,Bn,Fn,An,Dn,ki,Ti,Fi]),bt=a(function(i){if(i){Qn(),Zn(),si(new Set),vi([]),yi.current=[],Xi(),Qi();var n=mn.findIndex(function(e){return e.id===i}),t=gn.findIndex(function(e){return e.id===i}),o=-1===n?R(mn,i):null,r=-1===t?R(gn,i):null;if(-1!==n||o||-1!==t||r){var l=-1!==n?n:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;hi.current=i,tt(function(i){var n,t=e({},i),o=!1;-1!==l&&(t[n=Ge?"left-".concat(l):String(l)]||(t[n]=!0,o=!0));-1!==u&&(t[n=Ge?"right-".concat(u):String(u)]||(t[n]=!0,o=!0));return o?t:i}),rt(function(i){var n=e({},i),t=!1,l=function(e){for(var i=e.split("-"),o=i[0],r=1;r<i.length;r++)o+="-".concat(i[r]),n[o]||(n[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?n:i}),setTimeout(function(){requestAnimationFrame(function(){hi.current===i&&Ct.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(i,'" not found'))}},[mn,gn,Ge,tt,rt,Zn,Xi,Qi]),Ct=r(yt);u(function(){Ct.current=yt},[yt]);var wt=r(null);u(function(){if(tn){var e=en.fields.find(function(e){return e.analysisKey===tn||e.key===tn});if(e){var i=wn.current[e.key]||_n.current[e.key];(null==i?void 0:i.current)&&setTimeout(function(){return i.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[tn,en.fields]);var _t=a(function(e){var i,n,t,o,r,l,u,a,s,d=null===(i=null==dt?void 0:dt.rule_difference_comparison)||void 0===i?void 0:i.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var c=d[e],v=(null==c?void 0:c.relation)||(null===(t=null===(n=null==c?void 0:c.highlights)||void 0===n?void 0:n.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==c?void 0:c.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==c?void 0:c.mappings)&&c.mappings.length>0;if(c.mappings){var f=c.mappings[0]||{};return{score:c.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:c.score,relation:c.relation||"",highlightsA:(null===(a=c.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(s=c.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}},[dt]),Bt=K({proposedSections:mn,existingSections:gn,maintainRelativeOrder:Ge,cognitiveMap:_i,deviationData:We,treeData:je,resolvedComparisonConfig:en}),Ft=Bt.getSectionCompareStyle,It=Bt.getSubSectionCompareStyle,Tt=Bt.getDeviationStyleByKey,Et=X({containerRef:pi,leftContainerRef:ki,rightContainerRef:Ti,svgContainerRef:fi,pathRefs:Ri,leftHeaderRef:mi,rightHeaderRef:gi,proposedSections:mn,existingSections:gn,visibleFields:hn,leftRefs:wn,rightRefs:_n,sectionLeftRefs:Bn,sectionRightRefs:Fn,subSectionLeftRefs:An,subSectionRightRefs:Dn,lhsBadgeRefs:In,rhsBadgeRefs:Tn,sectionRowRefs:jn,expandedSections:nt,expandedSubSections:ot,connectedSections:ai,isSideBySide:Nn,activeSideBySideSection:Vn,maintainRelativeOrder:Ge,cognitiveMap:_i,getSectionCompareStyle:Ft,getSubSectionCompareStyle:It,getDeviationStyleByKey:Tt,isArrowVisible:Hn,isAnimatingRef:Si,isSideBySideRef:Xn,sideBySideCacheRef:Yn,sideBySideLineRef:Un,activeSideBySideSectionRef:Jn,activeSideBySideRightSectionRef:$n,connectedLines:ci,setConnectedLines:vi,cachedConnectedPositions:yi,calculateLinesRef:bi,resizeTimerRef:Ci,scrollLock:Kn,handleResizeRef:wi,activeProposed:fn,existingRule:pn,analysisData:dt,pendingScrollTargetRef:Pi,pendingScrollCallbackRef:Li,resolvedComparisonConfig:en,getFieldData:_t}),At=Et.lines,Dt=Et.setLines,jt=Et.overallConnector,kt=Et.setOverallConnector,Pt=Et.svgDimensions,Lt=Et.handleColumnScroll,Ot=a(function(){Qn(),tt({}),rt({}),Zn(),si(new Set),vi([]),yi.current=[],Xi(),Qi(),Zi(),requestAnimationFrame(function(){bi.current&&bi.current()})},[tt,rt,Zn,Xi,Qi,Zi]),Nt=l(function(){return Object.values(nt).some(Boolean)||Object.values(ot).some(Boolean)},[nt,ot]),Ht=r(null),zt=r(0),Mt=r(0),qt=r(0),Wt=Y({timerRef:Ht,ruleComponentRef:Ii,scrollContainerRef:Fi,containerRef:pi,maintainRelativeOrder:Ge,proposedSections:mn,existingSections:gn,isSideBySideRef:Xn,activeSideBySideSectionRef:Jn,activeSideBySideRightSectionRef:$n,sectionRowRefs:jn,sectionRightRowRefs:En,sectionLeftRefs:Bn,sectionRightRefs:Fn,subSectionLeftRefs:An,subSectionRightRefs:Dn,lhsBadgeRefs:In,rhsBadgeRefs:Tn,leftContainerRef:ki,rightContainerRef:Ti,calculateLinesRef:bi,handleResizeRef:wi,setIsResizing:qn,setIsArrowVisible:zn,sideBySideCacheRef:Yn,cachedConnectedPositions:yi}).handleResize;u(function(){wi.current=Wt},[Wt,wi]),u(function(){var e=function(e,i,n,t,o){i.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(function(){var r,l,u;n.current=null;var a=e[e.length-1];if(a){var s=null!==(u=null===(l=null===(r=a.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:a.contentRect.width;Math.abs(s-i.current)<1?o():(i.current=s,t())}})});return r.observe(e),r},i={current:null},n={current:null},t={current:null},o=[],r=[i,n,t];return Ii.current&&o.push(e(Ii.current,zt,i,function(){return wi.current()},function(){})),Fi.current&&o.push(e(Fi.current,Mt,n,function(){return wi.current()},function(){return bi.current()})),pi.current&&o.push(e(pi.current,qt,t,function(){return wi.current()},function(){return bi.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),u(function(){Xn.current=Nn},[Nn]),u(function(){Jn.current=Vn},[Vn]);var Vt=a(function(){var e,i=zi.sectionIdx,n=zi.isOrphan;if(Xi(),null!=i){var t="left";zi.anchorEl&&(null===(e=Ti.current)||void 0===e?void 0:e.contains(zi.anchorEl))&&(t="right"),at(i),et(i,n,{sourceSide:t})}},[et,zi.isOrphan,zi.sectionIdx,zi.anchorEl,Xi]),Kt=a(function(){Xi(),Zn(),si(new Set),vi([]),yi.current=[]},[Xi,Zn]),Yt=null!==zi.sectionIdx&&ai.has(zi.sectionIdx),Xt=N({proposedSections:mn,existingSections:gn,parentDeviationRecord:Sn,expandedSections:nt,maintainRelativeOrder:!!Ge,scrollContainerRef:Fi,leftContainerRef:ki,rightContainerRef:Ti,lhsBadgeRefs:In,rhsBadgeRefs:Tn}),$t=Xt.showDeviationNavigation,Jt=Xt.showOpenNodeRef,Ut=Xt.adjustScrollForPopup,Gt=a(function(e,i,n,t,o){var r,l="string"==typeof t?h(t).trim():h(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;Qi();var a="left";(null===(r=Ti.current)||void 0===r?void 0:r.contains(u))&&(a="right");var s=function(){var e,n,t,o;if("string"==typeof i&&i.includes(b)){var r=i.split(b),l="".concat(r[0]).concat(b).concat(r[1]);return"right"===a?null===(e=Tn.current[l])||void 0===e?void 0:e.current:null===(n=In.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=Tn.current[i])||void 0===t?void 0:t.current:null===(o=In.current[i])||void 0===o?void 0:o.current};if(n)return Zn(),si(new Set),vi([]),yi.current=[],void(l&&(at(i),requestAnimationFrame(function(){var e=s()||u;Yi({open:!0,anchorEl:e,summary:t,displayImpact:o})})));at(i),l?requestAnimationFrame(function(){et(i,n,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e=s()||u;Yi({open:!0,anchorEl:e,summary:t,displayImpact:o})}})}):requestAnimationFrame(function(){et(i,n,{toggleIfSame:!1,sourceSide:a})})},[et,Qi,Yi,Zn,at]),Qt=l(function(){var e;if(!Ve)return null;var i=null===(e=null==Ve?void 0:Ve.id)||void 0===e?void 0:e.split(":")[0];for(var n in Sn){if((Sn[n]||[]).some(function(e){return e.id===i}))return n}return null},[Ve,Sn]),Zt=r({id:null,triggerMs:null}),eo=r(null);u(function(){var n;if(null==Ve?void 0:Ve.id){var t=Number(Ve.trigger),o=Zt.current;if((null==o?void 0:o.triggerMs)!==t){if(!(Ve.id.includes(":")&&/:\d+$/.test(Ve.id)))return Zt.current={id:Ve.id,triggerMs:t},void bt(Ve.id);var r=null===(n=null==Ve?void 0:Ve.id)||void 0===n?void 0:n.split(":"),l=r[0],u=r[1],a=null!=u?u:"0";eo.current!==Ve.id&&(Xi(),Qi(),Zn(),si(new Set),vi([]),yi.current=[],eo.current=Ve.id);var s=!1,d=0,c=null,v=150,f=function(e,i){for(var n=function(e,t){if(!e)return null;if(e.id===i)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=n(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=n(e[t],String(t));if(o)return o}return null},p=function(){var n,o,r,u;if(!s){var m=function(){Zt.current={id:Ve.id,triggerMs:t}},g=null,h=null;for(var S in Sn){var x=Sn[S].find(function(e){return e.id===l});if(x){g=S,h=x;break}}if(h&&g){var R=mn.findIndex(function(e){return e.id===g}),y=gn.findIndex(function(e){return e.id===g}),C=-1===R&&-1!==y,w=f(mn,h.id),_=f(gn,h.id);if(w&&!_&&!C){var B=w.split("-"),F=Number(B[0]);if(Ge){var I=null===(o=null===(n=mn[F])||void 0===n?void 0:n.refIndexes)||void 0===o?void 0:o[0],T=gn.findIndex(function(e){return e.selfIndex===I});-1!==T&&(F=T)}_=i([F],B.slice(1),!0).join("-")}if(w||_){var E=w?Number(w.split("-")[0]):R,A=_?Number(_.split("-")[0]):y,D=mn[E],j=gn[A],k=D&&!D.title&&!D.content,P=j&&!j.title&&!j.content,L=C||(!w&&!!_||k&&!P);if(L){if(!(Ge?!!nt["right-".concat(A)]:!!nt[String(A)])&&A>=0)return ut(A,"right"),d+=1,void(c=setTimeout(p,450))}else if(!(Ge?!!nt["left-".concat(E)]:!!nt[String(E)])&&E>=0)return ut(E,"left"),d+=1,void(c=setTimeout(p,450));var O,N=w||"",H=_||"",z="".concat(h.id).concat(b).concat(a).concat(b).concat(N).concat(b).concat(H),M="".concat(h.id).concat(b).concat(a),q=null===(r=In.current[M])||void 0===r?void 0:r.current,W=null===(u=Tn.current[M])||void 0===u?void 0:u.current,V=L||!q&&!!W,K=V?W:q;if(O=Ge?V?Ti.current:ki.current:Fi.current,K&&O){var Y=K.getBoundingClientRect();if(0===Y.height)return void((d+=1)<2?c=setTimeout(p,v):m());var X=O.getBoundingClientRect(),$=Y.top-X.top+O.scrollTop-X.height/2+Y.height/2,J=w&&w.includes("-")||_&&_.includes("-"),U=function(){var i,n,t,o,r;if(!s){m();var l=K instanceof Element?window.getComputedStyle(K).color:"";q&&(q.style.transition="box-shadow 300ms ease-in-out",q.style.boxShadow="0 0 10px ".concat(l)),W&&(W.style.transition="box-shadow 300ms ease-in-out",W.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){q&&(q.style.boxShadow=""),W&&(W.style.boxShadow="")},2e3);var u=(null===(n=null===(i=h.evaluationResult)||void 0===i?void 0:i.deviations)||void 0===n?void 0:n[a])||h,d=(null===(t=h.evaluationResult)||void 0===t?void 0:t.evaluation_outputs)||h.evaluation_outputs;if(!(!!q&&!!W)){var c=V?(null===(o=Tn.current[J?M:A])||void 0===o?void 0:o.current)||W:(null===(r=In.current[J?M:E])||void 0===r?void 0:r.current)||q;return Ut(c,function(){Yi({open:!0,anchorEl:c,displayImpact:Ve.displayImpact,summary:e(e({},u),{evaluation_outputs:d})})},{skipScroll:!0}),void(null==Ke||Ke())}et(z,!1,{toggleIfSame:!1,sourceSide:C?"right":"left",onReady:function(){var i,n;m();var t=V?(null===(i=Tn.current[M])||void 0===i?void 0:i.current)||W:(null===(n=In.current[M])||void 0===n?void 0:n.current)||q;Yi({open:!0,anchorEl:t,displayImpact:Ve.displayImpact,summary:e({},u)}),null==Ke||Ke()}})}};Math.abs(O.scrollTop-$)<=2?U():(Pi.current=$,Li.current=U,O.scrollTo({top:$,behavior:"smooth"}),c&&clearTimeout(c),c=setTimeout(function(){if(Li.current){Pi.current=null;var e=Li.current;Li.current=null,e()}},800))}else(d+=1)<2?c=setTimeout(p,v):m()}else(d+=1)<2?c=setTimeout(p,v):m()}else(d+=1)<2?c=setTimeout(p,v):m()}};return c=setTimeout(p,v),function(){s=!0,c&&clearTimeout(c)}}}},[Ve,Sn,mn,gn,Ge,nt,ut,et,Yi,bt]);var io={maintainRelativeOrder:!!Ge,showDeviationBadges:Ze,isProposingFix:Xe,proposingFixNodeId:$e,isRedlineFlow:Je,isSideBySide:Nn,activeSideBySideSection:Vn,connectedSections:ai,proposedSections:mn,existingSections:gn,deviationNumberRegistry:xn,treeData:je,displayConfig:ze,resolvedMarkdownStyles:Bi,unifiedNumbering:st,expandedSections:nt,expandedSubSections:ot,setExpandedSubSections:rt,getSectionCompareStyle:Ft,getSubSectionCompareStyle:It,getBadgeRef:Ln,getSectionRowRef:kn,getSubSectionRef:Pn,sectionLeftRefs:Bn,sectionRightRefs:Fn,sectionRowRefs:jn,sectionRightRowRefs:En,subSectionLeftRefs:An,subSectionRightRefs:Dn,lhsBadgeRefs:In,rhsBadgeRefs:Tn,openMoreFunctionsPopup:function(e,i,n,t,o,r){var l;if(e.stopPropagation(),zi.open&&zi.sectionIdx===o)Zi();else{var u=e.currentTarget,a="left";(null===(l=Ti.current)||void 0===l?void 0:l.contains(u))&&(a="right");Qn(),Xn.current&&Zn(),si(new Set),vi([]),yi.current=[],Qi(),Ki.open?Kt():Xi(),requestAnimationFrame(function(){var e=function(){var e,i,n,t;if("string"==typeof o&&o.includes(b)){var r=o.split(b),l="".concat(r[0]).concat(b).concat(r[1]);return"right"===a?null===(e=Tn.current[l])||void 0===e?void 0:e.current:null===(i=In.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(n=Tn.current[o])||void 0===n?void 0:n.current:null===(t=In.current[o])||void 0===t?void 0:t.current}()||u;Mi(xt(e,i,t,o,n,r))})}},handleOpenSummaryPopup:Gt,openSummaryPopup:Gt,handleCloseSummaryPopup:Kt,toggleSection:ut,handleSubSectionToggle:lt,renderSubSectionAccordion: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,a=e.parentNodeId,s=void 0===a?"":a,d=e.sectionOffset;return n(z,{section:i,keyPath:t,depth:r,columnKey:u,parentNodeId:s,sectionOffset:d})},resetSideBySide:Zn,setConnectedSections:si,setConnectedLines:vi,cachedConnectedPositions:yi,showDeviationNavigation:$t,showOpenNodeRef:Jt,deviationNodeIdToView:null==Ve?void 0:Ve.id,deviationTargetParentId:Qt};return n(V,e({value:io},{children:t(s,e({ref:Ii,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},Ge?{}:{overflow:"visible"}),{position:"relative"})},{children:[ii&&n(s,e({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(D,{})})),Ki.open&&n(W,{open:Ki.open,anchorEl:Ki.anchorEl,containerEl:wt.current,clipTopEl:mi.current,scrollContainerEl:Fi.current,onClose:Kt,summary:Ki.summary,displayImpact:Ki.displayImpact}),n(A,{open:zi.open,anchorEl:zi.anchorEl,sectionTitle:zi.sectionTitle,referenceSectionTitle:zi.refSectionTitle,onClose:Zi,onOpenCognitiveCompare:Ui,onOpenSideBySide:Vt,onConnect:Rt,isConnected:Yt,isOrphan:zi.isOrphan}),Ni.open&&n(E,{open:Ni.open,popupRef:Ji,position:qi,popupConfig:Me,onClose:function(){Wi(null),Hi(function(i){return e(e({},i),{open:!1})}),$i(null)},markdownStyles:Oe,sectionTitle:an,referenceSectionTitle:dn,cognitiveData:Ni.cognitiveData,anchorEl:Ni.anchorEl,sectionAnchorEl:Ni.sectionAnchorEl,scrollContainerEl:Fi.current,badgeStyle:Ni.badgeStyle,docData:Ni.docData,deviationData:Ni.deviationData,isLoading:Ni.isLoading}),n(d,e({open:!!oi,autoHideDuration:8e3,onClose:function(){return ri(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n(c,e({onClose:function(){return ri(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:oi}))})),n(H,{componentHeaderText:De,displayConfig:ze,maintainRelativeOrder:Ge,onCollapseAll:Ot,showCollapseAll:Nt,onToggleView:function(e){ni(!0),setTimeout(function(){Qe(!e),Zn(),Xi(),si(new Set),vi([]),yi.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ni(!1)},600)})})},50)}}),n(s,e({ref:Fi,onScroll:Lt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Ge?"hidden":"auto",borderTop:ct&&vt?"none":"1.5px solid #EEF0F4"}},{children:n(s,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Ge?{flex:1,minHeight:0}:{})},{children:t(s,e({ref:pi,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Ge?{flex:1,overflow:"visible"}:{})},{children:[n(J,{svgContainerRef:fi,svgDimensions:Pt,isResizing:Mn,overallConnector:jt,rootDeviationStyle:gt,lines:At,isSideBySide:Nn,activeSideBySideSection:Vn,isArrowVisible:Hn,maintainRelativeOrder:Ge,proposedSections:mn,existingSections:gn,cognitivePopup:Ni,activeBadgeId:Vi,closeCognitivePopup:Qi,setActiveBadgeId:$i,openCognitivePopupFromState:Gi,buildSectionPopupState:xt,connectedLines:ci,pathRefs:Ri}),t(s,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Ge?{flex:1,overflow:"visible"}:{})},{children:[n(s,e({ref:mi,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(v,e({title:ln,placement:"top"},{children:n(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ln}))}))})),t(s,e({ref:ki,onScroll:Lt,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ge?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n("div",{ref:Di,style:{width:"100%",height:"0px",flexShrink:0}}),yn&&mn.map(function(e,i){return n(M,{section:e,idx:i},"left-row-".concat(i))}),n("div",{ref:ji,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n(s,e({ref:wt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(s,e({onClick:function(i){i.stopPropagation(),Ni.open&&Vi===ft?Qi():($i(ft),Gi(xt(i.currentTarget,{title:"",content:"",evaluationResult:pt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,ft,!0,e(e({},gt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:gt.badgeBg,color:gt.badgeText,border:"1px solid ".concat(gt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=mt?mt:n(j,{}),n(s,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n(m,{})})),n(p,{size:11,style:{transform:Ni.open&&Vi===ft?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(s,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Ge?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Wn&&n(g,{sections:11}),n(s,e({ref:gi,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n(v,e({title:cn,placement:"top"},{children:n(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:cn}))}))})),t(s,e({ref:Ti,onScroll:Lt,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ge?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n("div",{ref:Ei,style:{width:"100%",height:"0px",flexShrink:0}}),yn&&gn.map(function(e,i){return n(q,{section:e,idx:i},"right-row-".concat(i))}),n("div",{ref:Ai,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{U as default};
1
+ import{__assign as e,__spreadArray as n}from"tslib";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useCallback as u,useEffect as a}from"react";import{Box as s,Snackbar as c,Alert as d,Tooltip as v,Typography as f}from"@mui/material";import{ChevronDown as p}from"lucide-react";import{ButtonCognitiveIcon as m}from"../../assests/svg/ButtonCognitiveIcon.js";import g from"./OverlayComponent.js";import{safeStringify as h,extractDeviationScore as S,generateColorPalette as x,findKeyPathByNodeId as R,hasMeaningfulRedlineTags as y,DEVIATION_BADGE_SEPARATOR as b,scrollAndHighlightClause as C}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as w,DEFAULT_FIELD_CONFIG as _,DEFAULT_COMPARISON_CONFIG as B}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as F,EMPTY_SUMMARY_POPUP_STATE as I,DEFAULT_COMPONENT_HEADER_TEXT as E}from"./CognitiveCompareConstants.js";import T from"./CognitivePopup.js";import A from"./MoreFunctionsPopup.js";import D from"./LoaderComponent.js";import k from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as L}from"./hooks/useCompareData.js";import{useComparePopups as j}from"./hooks/useComparePopups.js";import{useSectionRefs as P}from"./hooks/useSectionRefs.js";import{useAccordionState as O}from"./hooks/useAccordionState.js";import{useDeviationNavigation as N}from"./hooks/useDeviationNavigation.js";import z from"./components/CompareHeader.js";import H from"./components/SubSectionAccordion.js";import M from"./components/LHSSectionRow.js";import q from"./components/RHSSectionRow.js";import W from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as V}from"./CompareContext.js";import{useStyleHelpers as K}from"./hooks/useStyles.js";import{useResizeHandler as Y}from"./hooks/useResizeHandler.js";import{useLinesCalculator as X}from"./hooks/useLinesCalculator.js";import{useSideBySide as $}from"./hooks/useSideBySide.js";import J from"./components/SvgConnectors.js";var U=function(U){var G,Q,Z,ee,ne,ie,te,oe,re,le,ue,ae,se,ce,de,ve,fe,pe,me,ge,he,Se,xe,Re,ye,be,Ce,we,_e,Be,Fe,Ie,Ee,Te,Ae=U.componentHeaderText,De=void 0===Ae?E:Ae,ke=U.treeData,Le=U.comparisonConfig,je=U.leftColumnTitleText,Pe=U.rightColumnTitleText,Oe=U.markdownStyles,Ne=U.resetTrigger,ze=U.displayConfig,He=void 0===ze?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0}:ze,Me=U.popupConfig,qe=U.deviationData,We=void 0===qe?{}:qe,Ve=U.deviationNodeIdToView,Ke=U.resetDeviationNodeId,Ye=U.isProposingFix,Xe=void 0!==Ye&&Ye,$e=U.proposingFixNodeId,Je=U.isRedlineFlow,Ue=o(He.maintainRelativeOrder),Ge=Ue[0],Qe=Ue[1],Ze=!!Ge||!!(null==He?void 0:He.showDeviationBadges),en=o(!1),nn=en[0],tn=en[1],on=o(null),rn=on[0],ln=on[1],un=o(null===(Q=null!==(G=null==ke?void 0:ke.newEvaluationResult)&&void 0!==G?G:null==He?void 0:He.enableDeviationSchemaBackwardCompatibility)||void 0===Q||Q)[0],an=o(new Set),sn=an[0],cn=an[1],dn=o([]),vn=dn[0],fn=dn[1],pn=o(!1),mn=pn[0],gn=pn[1],hn=r(null),Sn=r(null),xn=r(null),Rn=r(null),yn=r(null),bn=r(!1),Cn=r(null),wn=r({}),_n=r([]),Bn=r(function(){}),Fn=r(null),In=r(function(){}),En=l(function(){return(null==ke?void 0:ke.cognitive_decisioning)||{}},[ke]),Tn=l(function(){return e(e({},w),Oe)},[Oe]),An=r(null),Dn=r(null),kn=r(null),Ln=r(null),jn=r(null),Pn=r(null),On=r(null),Nn=r(null),zn=r(null),Hn=r(null),Mn=u(function(e){null==e||e.stopPropagation(),gn(function(e){return!e})},[]),qn=j(An),Wn=qn.cognitivePopup,Vn=qn.setCognitivePopup,Kn=qn.moreFunctions,Yn=qn.setMoreFunctions,Xn=qn.position,$n=qn.setPosition,Jn=qn.activeBadgeId,Un=qn.summaryPopup,Gn=qn.setSummaryPopup,Qn=qn.closeSummaryPopup,Zn=qn.setActiveBadgeId,ei=qn.popupRef,ni=qn.handleOpenCognitiveCompare,ii=qn.openCognitivePopupFromState,ti=qn.closeCognitivePopup,oi=qn.closeMoreFunctionsPopup,ri=l(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==Le?void 0:Le.fields)&&void 0!==e?e:_,thresholds:{high:null!==(i=null===(n=null==Le?void 0:Le.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:B.thresholds.high,medium:null!==(o=null===(t=null==Le?void 0:Le.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:B.thresholds.medium,exact:null!==(l=null===(r=null==Le?void 0:Le.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:B.thresholds.exact}}},[Le]),li=o(null),ui=li[0];li[1];var ai=null===(ne=null===(Z=null==ke?void 0:ke.documents)||void 0===Z?void 0:Z[null===(ee=null==ke?void 0:ke.input_index_map)||void 0===ee?void 0:ee[0]])||void 0===ne?void 0:ne.title,si=null===(oe=null===(ie=null==ke?void 0:ke.documents)||void 0===ie?void 0:ie[null===(te=null==ke?void 0:ke.input_index_map)||void 0===te?void 0:te[1]])||void 0===oe?void 0:oe.title,ci=h(je||ai||"Uploaded Contract"),di=null===(ae=null===(ue=null===(re=null==ke?void 0:ke.documents)||void 0===re?void 0:re[null===(le=null==ke?void 0:ke.input_index_map)||void 0===le?void 0:le[0]])||void 0===ue?void 0:ue.metadata)||void 0===ae?void 0:ae.file_name,vi=h(di),fi=null===(ve=null===(de=null===(se=null==ke?void 0:ke.documents)||void 0===se?void 0:se[null===(ce=null==ke?void 0:ke.input_index_map)||void 0===ce?void 0:ce[1]])||void 0===de?void 0:de.metadata)||void 0===ve?void 0:ve.file_name,pi=h(fi),mi=h(Pe||si||"Reference Template"),gi=L(ke,Ge,We,ri,un),hi=gi.activeProposed,Si=gi.existingRule,xi=gi.proposedSections,Ri=gi.existingSections,yi=gi.visibleFields,bi=gi.parentDeviationRecord,Ci=gi.deviationNumberRegistry,wi=gi.parseError;a(function(){wi&&ln("Failed to load comparison: ".concat(wi))},[wi]);var _i=xi.length>0||Ri.length>0,Bi=l(function(){if(!Je)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)||"";y(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(xi),i(Ri),"".concat(e,":").concat(n)},[Je,xi,Ri]),Fi=P(yi.map(function(e){return e.key}),Math.max(xi.length,Ri.length)),Ii=Fi.leftRefs,Ei=Fi.rightRefs,Ti=Fi.sectionLeftRefs,Ai=Fi.sectionRightRefs,Di=Fi.lhsBadgeRefs,ki=Fi.rhsBadgeRefs,Li=Fi.sectionRightRowRefs,ji=Fi.subSectionLeftRefs,Pi=Fi.subSectionRightRefs,Oi=Fi.sectionRowRefs,Ni=Fi.getSectionRowRef,zi=Fi.getSubSectionRef,Hi=Fi.getBadgeRef,Mi=$({maintainRelativeOrder:Ge,proposedSections:xi,existingSections:Ri,leftContainerRef:Nn,rightContainerRef:kn,scrollContainerRef:An,sectionLeftRefs:Ti,sectionRightRefs:Ai,subSectionLeftRefs:ji,subSectionRightRefs:Pi,lhsBadgeRefs:Di,rhsBadgeRefs:ki,sectionRowRefs:Oi,sectionRightRowRefs:Li,rhsTopSpacerRef:Ln,rhsBottomSpacerRef:jn,lhsTopSpacerRef:Pn,lhsBottomSpacerRef:On,calculateLinesRef:Bn,setConnectedSections:cn,setConnectedLines:fn,cachedConnectedPositions:_n,closeMoreFunctionsPopup:oi,setErrorToast:ln,moreFunctions:Kn,closeSummaryPopup:Qn}),qi=Mi.isSideBySide,Wi=Mi.isArrowVisible,Vi=Mi.setIsArrowVisible,Ki=Mi.isResizing,Yi=Mi.setIsResizing,Xi=Mi.isSideBySideLoading,$i=Mi.activeSideBySideSection,Ji=Mi.scrollLock,Ui=Mi.sideBySideCacheRef,Gi=Mi.isSideBySideRef,Qi=Mi.activeSideBySideRightSectionRef,Zi=Mi.activeSideBySideSectionRef,et=Mi.sideBySideLineRef,nt=Mi.highlightedClauseRefs,it=Mi.clearClauseHighlight,tt=Mi.resetSideBySide,ot=Mi.activateSideBySide,rt=O({maintainRelativeOrder:!!Ge,proposedSections:xi,existingSections:Ri,activeSideBySideSection:$i,connectedSections:sn,resetSideBySide:tt,setConnectedSections:cn,setConnectedLines:fn,cachedConnectedPositions:_n,svgContainerRef:hn,isAnimatingRef:bn,animationTimerRef:Cn,calculateLinesRef:Bn,sectionLeftRefs:Ti,sectionRightRefs:Ai,subSectionLeftRefs:ji,subSectionRightRefs:Pi}),lt=rt.expandedSections,ut=rt.setExpandedSections,at=rt.expandedSubSections,st=rt.setExpandedSubSections,ct=rt.handleSubSectionToggle,dt=rt.toggleSection,vt=rt.forceExpandCrossWiredSections;a(function(){Je&&"off"!==Bi&&"0:0"!==Bi&&(Ui.current=null,_n.current=[],requestAnimationFrame(function(){var e;null===(e=Bn.current)||void 0===e||e.call(Bn)}))},[Je,Bi]);var ft=l(function(){var e=new Map,n=new Map,i=1;if(Ge)xi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Ri.forEach(function(t){if(t.id){var o=xi.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(xi.length,Ri.length),o=0;o<t;o++){var r=xi[o],l=Ri[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}},[xi,Ri,Ge]),pt=Si.analysis,mt=h(null===(pe=null===(fe=null==pt?void 0:pt.rule_difference_comparison)||void 0===fe?void 0:fe.summary)||void 0===pe?void 0:pe.overall_summary),gt=!!mt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),ht=null!==(me=null==ke?void 0:ke.base_root_id)&&void 0!==me?me:"-1";null==ke||ke[ht];var St=un?null!==(Fe=null!==(we=We&&(null===(Ce=null==We?void 0:We[ht])||void 0===Ce?void 0:Ce.evaluation_result))&&void 0!==we?we:null===(Be=null===(_e=null==ke?void 0:ke.nodes)||void 0===_e?void 0:_e[ht])||void 0===Be?void 0:Be.evaluation_result)&&void 0!==Fe?Fe:null:null!==(be=null!==(Se=We&&(null===(he=null===(ge=null==We?void 0:We[ht])||void 0===ge?void 0:ge.evaluation_result)||void 0===he?void 0:he[0]))&&void 0!==Se?Se:null===(ye=null===(Re=null===(xe=null==ke?void 0:ke.nodes)||void 0===xe?void 0:xe[ht])||void 0===Re?void 0:Re.evaluation_result)||void 0===ye?void 0:ye[0])&&void 0!==be?be:null,xt=S(St),Rt=x(null!==(Te=null===(Ee=null===(Ie=null==St?void 0:St.evaluation_outputs)||void 0===Ie?void 0:Ie.metadata)||void 0===Ee?void 0:Ee.label_color)&&void 0!==Te?Te:F),yt=u(function(){it(),tt(),gn(!1),cn(new Set),fn([]),_n.current=[],Pt([]),Nt(null),Gn(I),ti(),requestAnimationFrame(function(){var e;null===(e=Bn.current)||void 0===e||e.call(Bn)})},[]),bt=r(yt);a(function(){bt.current=yt},[yt]),a(function(){Ne&&bt.current()},[Ne]);var Ct=u(function(n,i,t,o,r,l,u){var a,s,c,d=h(null==i?void 0:i.id)||h(null==t?void 0:t.id)||"",v=(d?En[d]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:d,decisioning:[],gap:[],relevance_score:0},f=null!==(s=null===(a=Oi.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(c=null==He?void 0:He.isLoading)&&void 0!==c&&c,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:v,anchorEl:n,sectionAnchorEl:f,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==ke?void 0:ke.documents,input_index_map:null==ke?void 0:ke.input_index_map},deviationData: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(e({},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(b)))return u(l);var a=o.split(b)[1];if(!a)return l;var s=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},c=(null===(n=null==s?void 0:s.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==s?void 0:s.deviations)||void 0===r?void 0:r[a])||null;return c?e(e(e({},s),c),{deviation_summary:(null==c?void 0:c.deviation_summary)||(null==s?void 0:s.deviation_summary),deviation_title:(null==c?void 0:c.deviation_title)||(null==s?void 0:s.deviation_title),deviation_impact:(null==c?void 0:c.deviation_impact)||(null==s?void 0:s.deviation_impact),deviation_explanation:(null==c?void 0:c.deviation_explanation)||(null==s?void 0:s.deviation_explanation),evaluation_outputs:(null==c?void 0:c.evaluation_outputs)||(null==s?void 0:s.evaluation_outputs),cognitive_decisioning:(null==c?void 0:c.cognitive_decisioning)||(null==s?void 0:s.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[En,ke]),wt=u(function(){var e=Kn.sectionIdx,n=Kn.isOrphan;oi(),Qn(),null!==e&&(n?ln("No counterpart exists to connect to."):(vt(e),it(),Gi.current&&tt(),fn([]),_n.current=[],cn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Bn.current&&Bn.current()},50)))},[Kn.sectionIdx,Kn.isOrphan,oi,Qn,tt]),_t=u(function(){var e=yn.current;if(e){yn.current=null;var n=xi.findIndex(function(n){return n.id===e}),i=Ri.findIndex(function(n){return n.id===e}),t=-1===n?R(xi,e):null,o=-1===i?R(Ri,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,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?(nt.current.add(r),C(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Ge)-1!==r&&Nn.current&&a(function(){return u(n,t,Ti,ji)},Nn.current),-1!==l&&kn.current&&a(function(){return u(i,o,Ai,Pi)},kn.current);else{var s=An.current;if(!s)return;a(function(){return-1!==r?u(n,t,Ti,ji):u(i,o,Ai,Pi)},s)}}},[xi,Ri,Ge,Ti,Ai,ji,Pi,Nn,kn,An]),Bt=u(function(n){if(n){it(),tt(),cn(new Set),fn([]),_n.current=[],Qn(),ti();var i=xi.findIndex(function(e){return e.id===n}),t=Ri.findIndex(function(e){return e.id===n}),o=-1===i?R(xi,n):null,r=-1===t?R(Ri,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;yn.current=n,ut(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=Ge?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=Ge?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),st(function(n){var i=e({},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(){yn.current===n&&Ft.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[xi,Ri,Ge,ut,st,tt,Qn,ti]),Ft=r(_t);a(function(){Ft.current=_t},[_t]);var It=r(null);a(function(){if(ui){var e=ri.fields.find(function(e){return e.analysisKey===ui||e.key===ui});if(e){var n=Ii.current[e.key]||Ei.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[ui,ri.fields]);var Et=u(function(e){var n,i,t,o,r,l,u,a,s,c=null===(n=null==pt?void 0:pt.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],v=(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 f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(s=d.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}},[pt]),Tt=K({proposedSections:xi,existingSections:Ri,maintainRelativeOrder:Ge,cognitiveMap:En,deviationData:We,treeData:ke,resolvedComparisonConfig:ri}),At=Tt.getSectionCompareStyle,Dt=Tt.getSubSectionCompareStyle,kt=Tt.getDeviationStyleByKey,Lt=X({containerRef:Sn,leftContainerRef:Nn,rightContainerRef:kn,svgContainerRef:hn,pathRefs:wn,leftHeaderRef:xn,rightHeaderRef:Rn,proposedSections:xi,existingSections:Ri,visibleFields:yi,leftRefs:Ii,rightRefs:Ei,sectionLeftRefs:Ti,sectionRightRefs:Ai,subSectionLeftRefs:ji,subSectionRightRefs:Pi,lhsBadgeRefs:Di,rhsBadgeRefs:ki,sectionRowRefs:Oi,expandedSections:lt,expandedSubSections:at,connectedSections:sn,isSideBySide:qi,activeSideBySideSection:$i,maintainRelativeOrder:Ge,cognitiveMap:En,getSectionCompareStyle:At,getSubSectionCompareStyle:Dt,getDeviationStyleByKey:kt,isArrowVisible:Wi,isAnimatingRef:bn,isSideBySideRef:Gi,sideBySideCacheRef:Ui,sideBySideLineRef:et,activeSideBySideSectionRef:Zi,activeSideBySideRightSectionRef:Qi,connectedLines:vn,setConnectedLines:fn,cachedConnectedPositions:_n,calculateLinesRef:Bn,resizeTimerRef:Fn,scrollLock:Ji,scrollSyncLocked:mn,handleResizeRef:In,activeProposed:hi,existingRule:Si,analysisData:pt,pendingScrollTargetRef:zn,pendingScrollCallbackRef:Hn,resolvedComparisonConfig:ri,getFieldData:Et}),jt=Lt.lines,Pt=Lt.setLines,Ot=Lt.overallConnector,Nt=Lt.setOverallConnector,zt=Lt.svgDimensions,Ht=Lt.handleColumnScroll;a(function(){Un.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Bn.current)||void 0===e||e.call(Bn)})})},[Un.anchorEl,mn]);var Mt=u(function(){it(),gn(!1),ut({}),st({}),tt(),cn(new Set),fn([]),_n.current=[],Qn(),ti(),oi(),requestAnimationFrame(function(){Bn.current&&Bn.current()})},[ut,st,tt,Qn,ti,oi]);a(function(){qi||0!==sn.size||gn(!1)},[qi,sn]);var qt=l(function(){return Object.values(lt).some(Boolean)||Object.values(at).some(Boolean)},[lt,at]),Wt=r(null),Vt=r(0),Kt=r(0),Yt=r(0),Xt=Y({timerRef:Wt,ruleComponentRef:Dn,scrollContainerRef:An,containerRef:Sn,maintainRelativeOrder:Ge,proposedSections:xi,existingSections:Ri,isSideBySideRef:Gi,activeSideBySideSectionRef:Zi,activeSideBySideRightSectionRef:Qi,sectionRowRefs:Oi,sectionRightRowRefs:Li,sectionLeftRefs:Ti,sectionRightRefs:Ai,subSectionLeftRefs:ji,subSectionRightRefs:Pi,lhsBadgeRefs:Di,rhsBadgeRefs:ki,leftContainerRef:Nn,rightContainerRef:kn,calculateLinesRef:Bn,handleResizeRef:In,setIsResizing:Yi,setIsArrowVisible:Vi,sideBySideCacheRef:Ui,cachedConnectedPositions:_n}).handleResize;a(function(){In.current=Xt},[Xt,In]),a(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 a=e[e.length-1];if(a){var s=null!==(u=null===(l=null===(r=a.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:a.contentRect.width;Math.abs(s-n.current)<1?o():(n.current=s,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Dn.current&&o.push(e(Dn.current,Vt,n,function(){return In.current()},function(){})),An.current&&o.push(e(An.current,Kt,i,function(){return In.current()},function(){return Bn.current()})),Sn.current&&o.push(e(Sn.current,Yt,t,function(){return In.current()},function(){return Bn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){Gi.current=qi},[qi]),a(function(){Zi.current=$i},[$i]);var $t=u(function(){var e,n=Kn.sectionIdx,i=Kn.isOrphan;if(Qn(),null!=n){var t="left";Kn.anchorEl&&(null===(e=kn.current)||void 0===e?void 0:e.contains(Kn.anchorEl))&&(t="right"),vt(n),ot(n,i,{sourceSide:t})}},[ot,Kn.isOrphan,Kn.sectionIdx,Kn.anchorEl,Qn]),Jt=u(function(){Qn(),tt(),cn(new Set),fn([]),_n.current=[]},[Qn,tt]),Ut=null!==Kn.sectionIdx&&sn.has(Kn.sectionIdx),Gt=N({proposedSections:xi,existingSections:Ri,parentDeviationRecord:bi,expandedSections:lt,maintainRelativeOrder:!!Ge,scrollContainerRef:An,leftContainerRef:Nn,rightContainerRef:kn,lhsBadgeRefs:Di,rhsBadgeRefs:ki}),Qt=Gt.showDeviationNavigation,Zt=Gt.showOpenNodeRef,eo=Gt.adjustScrollForPopup,no=u(function(e,n,i,t,o){var r,l="string"==typeof t?h(t).trim():h(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;ti();var a="left";(null===(r=kn.current)||void 0===r?void 0:r.contains(u))&&(a="right");var s=function(){var e,i,t,o;if("string"==typeof n&&n.includes(b)){var r=n.split(b),l="".concat(r[0]).concat(b).concat(r[1]);return"right"===a?null===(e=ki.current[l])||void 0===e?void 0:e.current:null===(i=Di.current[l])||void 0===i?void 0:i.current}return"right"===a?null===(t=ki.current[n])||void 0===t?void 0:t.current:null===(o=Di.current[n])||void 0===o?void 0:o.current};if(i)return tt(),cn(new Set),fn([]),_n.current=[],void(l&&(vt(n),requestAnimationFrame(function(){var e=s()||u;Gn({open:!0,anchorEl:e,summary:t,displayImpact:o})})));vt(n),l?requestAnimationFrame(function(){ot(n,i,{toggleIfSame:!1,sourceSide:a,onReady:function(){var e=s()||u;Gn({open:!0,anchorEl:e,summary:t,displayImpact:o})}})}):requestAnimationFrame(function(){ot(n,i,{toggleIfSame:!1,sourceSide:a})})},[ot,ti,Gn,tt,vt]),io=l(function(){var e;if(!Ve)return null;var n=null===(e=null==Ve?void 0:Ve.id)||void 0===e?void 0:e.split(":")[0];for(var i in bi){if((bi[i]||[]).some(function(e){return e.id===n}))return i}return null},[Ve,bi]),to=r({id:null,triggerMs:null}),oo=r(null);a(function(){var i;if(null==Ve?void 0:Ve.id){var t=Number(Ve.trigger),o=to.current;if((null==o?void 0:o.triggerMs)!==t){if(!(Ve.id.includes(":")&&/:\d+$/.test(Ve.id)))return to.current={id:Ve.id,triggerMs:t},void Bt(Ve.id);var r=null===(i=null==Ve?void 0:Ve.id)||void 0===i?void 0:i.split(":"),l=r[0],u=r[1],a=null!=u?u:"0";oo.current!==Ve.id&&(Qn(),ti(),tt(),cn(new Set),fn([]),_n.current=[],oo.current=Ve.id);var s=!1,c=0,d=null,v=150,f=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},p=function(){var i,o,r,u;if(!s){var m=function(){to.current={id:Ve.id,triggerMs:t}},g=null,h=null;for(var S in bi){var x=bi[S].find(function(e){return e.id===l});if(x){g=S,h=x;break}}if(h&&g){var R=xi.findIndex(function(e){return e.id===g}),y=Ri.findIndex(function(e){return e.id===g}),C=-1===R&&-1!==y,w=f(xi,h.id),_=f(Ri,h.id);if(w&&!_&&!C){var B=w.split("-"),F=Number(B[0]);if(Ge){var I=null===(o=null===(i=xi[F])||void 0===i?void 0:i.refIndexes)||void 0===o?void 0:o[0],E=Ri.findIndex(function(e){return e.selfIndex===I});-1!==E&&(F=E)}_=n([F],B.slice(1),!0).join("-")}if(w||_){var T=w?Number(w.split("-")[0]):R,A=_?Number(_.split("-")[0]):y,D=xi[T],k=Ri[A],L=D&&!D.title&&!D.content,j=k&&!k.title&&!k.content,P=C||(!w&&!!_||L&&!j);if(P){if(!(Ge?!!lt["right-".concat(A)]:!!lt[String(A)])&&A>=0)return dt(A,"right"),c+=1,void(d=setTimeout(p,450))}else if(!(Ge?!!lt["left-".concat(T)]:!!lt[String(T)])&&T>=0)return dt(T,"left"),c+=1,void(d=setTimeout(p,450));var O,N=w||"",z=_||"",H="".concat(h.id).concat(b).concat(a).concat(b).concat(N).concat(b).concat(z),M="".concat(h.id).concat(b).concat(a),q=null===(r=Di.current[M])||void 0===r?void 0:r.current,W=null===(u=ki.current[M])||void 0===u?void 0:u.current,V=P||!q&&!!W,K=V?W:q;if(O=Ge?V?kn.current:Nn.current:An.current,K&&O){var Y=K.getBoundingClientRect();if(0===Y.height)return void((c+=1)<2?d=setTimeout(p,v):m());var X=O.getBoundingClientRect(),$=Y.top-X.top+O.scrollTop-X.height/2+Y.height/2,J=w&&w.includes("-")||_&&_.includes("-"),U=function(){var n,i,t,o,r;if(!s){m();var l=K instanceof Element?window.getComputedStyle(K).color:"";q&&(q.style.transition="box-shadow 300ms ease-in-out",q.style.boxShadow="0 0 10px ".concat(l)),W&&(W.style.transition="box-shadow 300ms ease-in-out",W.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){q&&(q.style.boxShadow=""),W&&(W.style.boxShadow="")},2e3);var u=(null===(i=null===(n=h.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===i?void 0:i[a])||h,c=(null===(t=h.evaluationResult)||void 0===t?void 0:t.evaluation_outputs)||h.evaluation_outputs;if(!(!!q&&!!W)){var d=V?(null===(o=ki.current[J?M:A])||void 0===o?void 0:o.current)||W:(null===(r=Di.current[J?M:T])||void 0===r?void 0:r.current)||q;return eo(d,function(){Gn({open:!0,anchorEl:d,displayImpact:Ve.displayImpact,summary:e(e({},u),{evaluation_outputs:c})})},{skipScroll:!0}),void(null==Ke||Ke())}ot(H,!1,{toggleIfSame:!1,sourceSide:C?"right":"left",onReady:function(){var n,i;m();var t=V?(null===(n=ki.current[M])||void 0===n?void 0:n.current)||W:(null===(i=Di.current[M])||void 0===i?void 0:i.current)||q;Gn({open:!0,anchorEl:t,displayImpact:Ve.displayImpact,summary:e({},u)}),null==Ke||Ke()}})}};Math.abs(O.scrollTop-$)<=2?U():(zn.current=$,Hn.current=U,O.scrollTo({top:$,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(Hn.current){zn.current=null;var e=Hn.current;Hn.current=null,e()}},800))}else(c+=1)<2?d=setTimeout(p,v):m()}else(c+=1)<2?d=setTimeout(p,v):m()}else(c+=1)<2?d=setTimeout(p,v):m()}};return d=setTimeout(p,v),function(){s=!0,d&&clearTimeout(d)}}}},[Ve,bi,xi,Ri,Ge,lt,dt,ot,Gn,Bt]),a(function(){var n,i;if(Un.open){var t=Un.anchorEl;if(t&&!t.isConnected){var o=t.dataset.deviationRefId;if(o){var r=(null===(n=ki.current[o])||void 0===n?void 0:n.current)||(null===(i=Di.current[o])||void 0===i?void 0:i.current);r&&Gn(function(n){return e(e({},n),{anchorEl:r})})}}}},[mn,sn,lt]);var ro={maintainRelativeOrder:!!Ge,showDeviationBadges:Ze,isProposingFix:Xe,proposingFixNodeId:$e,isRedlineFlow:Je,isSideBySide:qi,activeSideBySideSection:$i,scrollSyncLocked:mn,toggleScrollSyncLocked:Mn,summaryPopupAnchorEl:Un.anchorEl,connectedSections:sn,proposedSections:xi,existingSections:Ri,deviationNumberRegistry:Ci,treeData:ke,displayConfig:He,resolvedMarkdownStyles:Tn,unifiedNumbering:ft,expandedSections:lt,expandedSubSections:at,setExpandedSubSections:st,getSectionCompareStyle:At,getSubSectionCompareStyle:Dt,getBadgeRef:Hi,getSectionRowRef:Ni,getSubSectionRef:zi,sectionLeftRefs:Ti,sectionRightRefs:Ai,sectionRowRefs:Oi,sectionRightRowRefs:Li,subSectionLeftRefs:ji,subSectionRightRefs:Pi,lhsBadgeRefs:Di,rhsBadgeRefs:ki,openMoreFunctionsPopup:function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Kn.open&&Kn.sectionIdx===o)oi();else{var u=e.currentTarget,a="left";(null===(l=kn.current)||void 0===l?void 0:l.contains(u))&&(a="right");it(),Gi.current&&tt(),cn(new Set),fn([]),_n.current=[],ti(),Un.open?Jt():Qn(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(b)){var r=o.split(b),l="".concat(r[0]).concat(b).concat(r[1]);return"right"===a?null===(e=ki.current[l])||void 0===e?void 0:e.current:null===(n=Di.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(i=ki.current[o])||void 0===i?void 0:i.current:null===(t=Di.current[o])||void 0===t?void 0:t.current}()||u;Yn(Ct(e,n,t,o,i,r))})}},handleOpenSummaryPopup:no,openSummaryPopup:no,handleCloseSummaryPopup:Jt,toggleSection:dt,handleSubSectionToggle:ct,renderSubSectionAccordion:function(e){var n=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,a=e.parentNodeId,s=void 0===a?"":a,c=e.sectionOffset;return i(H,{section:n,keyPath:t,depth:r,columnKey:u,parentNodeId:s,sectionOffset:c})},resetSideBySide:tt,setConnectedSections:cn,setConnectedLines:fn,cachedConnectedPositions:_n,showDeviationNavigation:Qt,showOpenNodeRef:Zt,deviationNodeIdToView:null==Ve?void 0:Ve.id,deviationTargetParentId:io};return i(V,e({value:ro},{children:t(s,e({ref:Dn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},Ge?{}:{overflow:"visible"}),{position:"relative"})},{children:[nn&&i(s,e({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:i(D,{})})),Un.open&&i(W,{open:Un.open,anchorEl:Un.anchorEl,containerEl:It.current,clipTopEl:xn.current,scrollContainerEl:An.current,onClose:Jt,summary:Un.summary,displayImpact:Un.displayImpact,isScrollLocked:mn}),i(A,{open:Kn.open,anchorEl:Kn.anchorEl,sectionTitle:Kn.sectionTitle,referenceSectionTitle:Kn.refSectionTitle,onClose:oi,onOpenCognitiveCompare:ni,onOpenSideBySide:$t,onConnect:wt,isConnected:Ut,isOrphan:Kn.isOrphan}),Wn.open&&i(T,{open:Wn.open,popupRef:ei,position:Xn,popupConfig:Me,onClose:function(){$n(null),Vn(function(n){return e(e({},n),{open:!1})}),Zn(null)},markdownStyles:Oe,sectionTitle:vi,referenceSectionTitle:pi,cognitiveData:Wn.cognitiveData,anchorEl:Wn.anchorEl,sectionAnchorEl:Wn.sectionAnchorEl,scrollContainerEl:An.current,badgeStyle:Wn.badgeStyle,docData:Wn.docData,deviationData:Wn.deviationData,isLoading:Wn.isLoading}),i(c,e({open:!!rn,autoHideDuration:8e3,onClose:function(){return ln(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(d,e({onClose:function(){return ln(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:rn}))})),i(z,{componentHeaderText:De,displayConfig:He,maintainRelativeOrder:Ge,onCollapseAll:Mt,showCollapseAll:qt,onToggleView:function(e){tn(!0),setTimeout(function(){Qe(!e),gn(!1),tt(),Qn(),cn(new Set),fn([]),_n.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){tn(!1)},600)})})},50)}}),i(s,e({ref:An,onScroll:Ht,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Ge?"hidden":"auto",borderTop:mt&&gt?"none":"1.5px solid #EEF0F4"}},{children:i(s,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Ge?{flex:1,minHeight:0}:{})},{children:t(s,e({ref:Sn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Ge?{flex:1,overflow:"visible"}:{})},{children:[i(J,{svgContainerRef:hn,svgDimensions:zt,isResizing:Ki,overallConnector:Ot,rootDeviationStyle:Rt,lines:jt,isSideBySide:qi,activeSideBySideSection:$i,isArrowVisible:Wi,maintainRelativeOrder:Ge,proposedSections:xi,existingSections:Ri,cognitivePopup:Wn,activeBadgeId:Jn,closeCognitivePopup:ti,setActiveBadgeId:Zn,openCognitivePopupFromState:ii,buildSectionPopupState:Ct,connectedLines:vn,pathRefs:wn}),t(s,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Ge?{flex:1,overflow:"visible"}:{})},{children:[i(s,e({ref:xn,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:i(v,e({title:ci,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ci}))}))})),t(s,e({ref:Nn,onScroll:Ht,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ge?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:Pn,style:{width:"100%",height:"0px",flexShrink:0}}),_i&&xi.map(function(e,n){return i(M,{section:e,idx:n},"left-row-".concat(n))}),i("div",{ref:On,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(s,e({ref:It,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(s,e({onClick:function(n){n.stopPropagation(),Wn.open&&Jn===ht?ti():(Zn(ht),ii(Ct(n.currentTarget,{title:"",content:"",evaluationResult:St,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,ht,!0,e(e({},Rt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Rt.badgeBg,color:Rt.badgeText,border:"1px solid ".concat(Rt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=xt?xt:i(k,{}),i(s,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(m,{})})),i(p,{size:11,style:{transform:Wn.open&&Jn===ht?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(s,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Ge?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Xi&&i(g,{sections:11}),i(s,e({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:i(v,e({title:mi,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:mi}))}))})),t(s,e({ref:kn,onScroll:Ht,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ge?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:Ln,style:{width:"100%",height:"0px",flexShrink:0}}),_i&&Ri.map(function(e,n){return i(q,{section:e,idx:n},"right-row-".concat(n))}),i("div",{ref:jn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{U as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{DEFAULT_DEVIAION_COLOR as t}from"./CognitiveCompareConstants.js";var n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},e=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return e(t)}))},o=function(t,e,o){var i,r=o[e],u=null===(i=null==t?void 0:t.comparison_inputs)||void 0===i?void 0:i[r];return{title:n((null==u?void 0:u.title)||""),content:n((null==u?void 0:u.content)||""),change_history:n((null==u?void 0:u.change_history)||""),attributes:(null==u?void 0:u.additional_attributes)||null,subsections:(null==u?void 0:u.subsections)||[]}},i=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}};function r(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),o=e.r,i=e.g,r=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(o+(255-o)*n),Math.round(i+(255-i)*n),Math.round(r+(255-r)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}}function u(t,n){var e;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];var r=this;clearTimeout(e),e=setTimeout(function(){return t.apply(r,o)},n)}}var l=function(t,n){var e,o,i,r,u,l;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.suppressHighlightBg!==n.suppressHighlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var v=0;v<a.length;v++)if(a[v]!==s[v])return!1;var c=t.deviationBadges||[],d=n.deviationBadges||[];if(c.length!==d.length)return!1;for(v=0;v<c.length;v++){if(c[v].id!==d[v].id)return!1;if(c[v].actionId!==d[v].actionId)return!1;if(c[v].label!==d[v].label)return!1;if(c[v].score!==d[v].score)return!1;if(c[v].isOrphan!==d[v].isOrphan)return!1;if(c[v].isConnected!==d[v].isConnected)return!1;if((null===(e=c[v].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=d[v].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(i=c[v].style)||void 0===i?void 0:i.badgeBorder)!==(null===(r=d[v].style)||void 0===r?void 0:r.badgeBorder))return!1;if((null===(u=c[v].style)||void 0===u?void 0:u.badgeText)!==(null===(l=d[v].style)||void 0===l?void 0:l.badgeText))return!1}return!0},a="::",s=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},v=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,o=null;null!==(o=e.exec(t));){if((null!==(n=o[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},c=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},d=function(t,n){var e,o,i,r,u,l,a;if(!t)return n;var s=null!==(l=null!==(r=null!==(o=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==o?o:null===(i=t.evaluation_outputs)||void 0===i?void 0:i.output_score)&&void 0!==r?r:null===(u=t.evaluation_outputs)||void 0===u?void 0:u.output_value)&&void 0!==l?l:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},f=function(t,n,e,o,i){void 0===i&&(i=14);var r=t+.5*(e-t),u=o-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var l=u>0?1:-1,a=Math.min(i,Math.abs(u)/2,Math.abs(r-t)/2,Math.abs(e-r)/2);return["M ".concat(t," ").concat(n),"H ".concat(r-a),"Q ".concat(r," ").concat(n," ").concat(r," ").concat(n+l*a),"V ".concat(o-l*a),"Q ".concat(r," ").concat(o," ").concat(r+a," ").concat(o),"H ".concat(e)].join(" ")},g=function(t,n,e,o,i){void 0===e&&(e=300);var r=t.style.scrollBehavior;t.style.scrollBehavior="auto";var u=t.scrollTop,l=n-u,a=null,s=function(v){null===a&&(a=v);var c,d=v-a;d<e?(t.scrollTop=(c=d,c/=e,l*(--c*c*c+1)+u),i&&i(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=r,i&&i(),o&&o())};requestAnimationFrame(s)},p=["#B91C1C","#A16207","#1D4ED8","#000000"],h=function(t){var n=p.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?p.length:n},b=function(n){for(var e,o,i,r,u,l,a,s,v,c,d,f,g,p=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var y=m[b];(C=null===(r=null===(i=null===(o=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[y])||void 0===o?void 0:o.evaluation_outputs)||void 0===i?void 0:i.metadata)||void 0===r?void 0:r.label_color)&&p.push(C)}for(var _=0,B=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});_<B.length;_++){y=B[_];(C=null===(s=null===(a=null===(l=null===(u=null==n?void 0:n.deviation_entries)||void 0===u?void 0:u[y])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===s?void 0:s.label_color)&&p.push(C)}for(var T=0,x=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});T<x.length;T++){var C;y=x[T];(C=null===(d=null===(c=null===(v=null==n?void 0:n[y])||void 0===v?void 0:v.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===d?void 0:d.label_color)&&p.push(C)}return 0===p.length?(null===(g=null===(f=null==n?void 0:n.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===g?void 0:g.label_color)?n.evaluation_outputs.metadata.label_color:t:p.sort(function(t,n){return h(t)-h(n)})[0]},m=function(t){for(var n,e,o,i,r,u,l,a,s,v=0,c=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});v<c.length;v++){var d=c[v];if(b=null===(o=null===(e=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[d])||void 0===e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var f=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<g.length;f++){d=g[f];if(b=null===(u=null===(r=null===(i=null==t?void 0:t.deviation_entries)||void 0===i?void 0:i[d])||void 0===r?void 0:r.evaluation_outputs)||void 0===u?void 0:u.output_value)return b}for(var p=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});p<h.length;p++){var b;d=h[p];if(b=null===(a=null===(l=null==t?void 0:t[d])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},y=function(t,n){var e=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},o=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var i=e(t),r=e(n),u=(i[0]+r[0])/2*.95,l=(i[1]+r[1])/2*.95,a=(i[2]+r[2])/2*.95;return"#".concat(o(u)).concat(o(l)).concat(o(a))}catch(t){return"#FDE68A"}},_=function(t,n,e){if(!t)return null;if(t.id===e)return n;if(!Array.isArray(t.subsections))return null;for(var o=0;o<t.subsections.length;o++){var i=_(t.subsections[o],"".concat(n,"-").concat(o),e);if(i)return i}return null},B=function(t,n){for(var e=0;e<t.length;e++){var o=_(t[e],String(e),n);if(o)return o}return null},T=new WeakMap,x=function(t){if(t){var n=T.get(t);null!=n&&(clearTimeout(n),T.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},C=function(t){if(t){var n=T.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var e=window.setTimeout(function(){x(t)},3e3);T.set(t,e)}},A=function(t,n){var e=n.getBoundingClientRect(),o=t.getBoundingClientRect(),i=n.scrollTop+o.top-e.top-e.height/2+o.height/2;n.scrollTo({top:i,behavior:"smooth"});var r=function(){return C(t)};if("onscrollend"in n)n.addEventListener("scrollend",r,{once:!0});else{var u=n.scrollTop,l=function(){n.scrollTop===u?r():(u=n.scrollTop,requestAnimationFrame(l))};requestAnimationFrame(l)}};export{a as DEVIATION_BADGE_SEPARATOR,l as areMarkdownPropsEqual,u as debounce,d as extractDeviationScore,B as findKeyPathByNodeId,r as generateColorPalette,f as getBentArrowPath,b as getFirstDeviationColor,m as getFirstDeviationOutputValue,i as getRationale,o as getSideData,v as hasMeaningfulRedlineTags,e as hasValue,C as highlightClause,s as isMissingStr,y as mixHexColors,_ as recursivelyFindSubSectionIdxById,x as resetClauseHighlight,n as safeStringify,A as scrollAndHighlightClause,g as smoothScrollTo,c as stripRedlineTags};
1
+ import{DEFAULT_DEVIAION_COLOR as t}from"./CognitiveCompareConstants.js";var n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},o=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return o(t)}))},e=function(t,o,e){var r,i=e[o],u=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return{title:n((null==u?void 0:u.title)||""),content:n((null==u?void 0:u.content)||""),change_history:n((null==u?void 0:u.change_history)||""),attributes:(null==u?void 0:u.additional_attributes)||null,subsections:(null==u?void 0:u.subsections)||[]}},r=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,o=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:o,citations:n.citations},score:0,relation:"N/A"}};function i(t){var n=function(t,n){var o=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),o=parseInt(n,16);return{r:o>>16&255,g:o>>8&255,b:255&o}}(t),e=o.r,r=o.g,i=o.b;return function(t,n,o){return"#"+[t,n,o].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(e+(255-e)*n),Math.round(r+(255-r)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}}function u(t,n){var o;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var i=this;clearTimeout(o),o=setTimeout(function(){return t.apply(i,e)},n)}}var l=function(t,n){var o,e,r,i,u,l;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.suppressHighlightBg!==n.suppressHighlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==s[c])return!1;var v=t.deviationBadges||[],d=n.deviationBadges||[];if(v.length!==d.length)return!1;for(c=0;c<v.length;c++){if(v[c].id!==d[c].id)return!1;if(v[c].actionId!==d[c].actionId)return!1;if(v[c].label!==d[c].label)return!1;if(v[c].score!==d[c].score)return!1;if(v[c].isOrphan!==d[c].isOrphan)return!1;if(v[c].isConnected!==d[c].isConnected)return!1;if(v[c].showScrollLockToggle!==d[c].showScrollLockToggle)return!1;if(v[c].scrollSyncLocked!==d[c].scrollSyncLocked)return!1;if((null===(o=v[c].style)||void 0===o?void 0:o.badgeBg)!==(null===(e=d[c].style)||void 0===e?void 0:e.badgeBg))return!1;if((null===(r=v[c].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=d[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(u=v[c].style)||void 0===u?void 0:u.badgeText)!==(null===(l=d[c].style)||void 0===l?void 0:l.badgeText))return!1}return!0},a="::",s=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},c=function(t){var n;if("string"!=typeof t||!t)return!1;for(var o=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,e=null;null!==(e=o.exec(t));){if((null!==(n=e[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},v=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},d=function(t,n){var o,e,r,i,u,l,a;if(!t)return n;var s=null!==(l=null!==(i=null!==(e=null===(o=t.evaluation_output)||void 0===o?void 0:o.output_score)&&void 0!==e?e:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(u=t.evaluation_outputs)||void 0===u?void 0:u.output_value)&&void 0!==l?l:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},f=function(t,n,o,e,r){void 0===r&&(r=14);var i=t+.5*(o-t),u=e-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(o);var l=u>0?1:-1,a=Math.min(r,Math.abs(u)/2,Math.abs(i-t)/2,Math.abs(o-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-a),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+l*a),"V ".concat(e-l*a),"Q ".concat(i," ").concat(e," ").concat(i+a," ").concat(e),"H ".concat(o)].join(" ")},g=function(t,n,o,e,r){void 0===o&&(o=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var u=t.scrollTop,l=n-u,a=null,s=function(c){null===a&&(a=c);var v,d=c-a;d<o?(t.scrollTop=(v=d,v/=o,l*(--v*v*v+1)+u),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),e&&e())};requestAnimationFrame(s)},p=["#B91C1C","#A16207","#1D4ED8","#000000"],h=function(t){var n=p.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?p.length:n},b=function(n){for(var o,e,r,i,u,l,a,s,c,v,d,f,g,p=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var y=m[b];(C=null===(i=null===(r=null===(e=null===(o=null==n?void 0:n.deviations)||void 0===o?void 0:o[y])||void 0===e?void 0:e.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===i?void 0:i.label_color)&&p.push(C)}for(var _=0,B=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});_<B.length;_++){y=B[_];(C=null===(s=null===(a=null===(l=null===(u=null==n?void 0:n.deviation_entries)||void 0===u?void 0:u[y])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===s?void 0:s.label_color)&&p.push(C)}for(var T=0,x=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});T<x.length;T++){var C;y=x[T];(C=null===(d=null===(v=null===(c=null==n?void 0:n[y])||void 0===c?void 0:c.evaluation_outputs)||void 0===v?void 0:v.metadata)||void 0===d?void 0:d.label_color)&&p.push(C)}return 0===p.length?(null===(g=null===(f=null==n?void 0:n.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===g?void 0:g.label_color)?n.evaluation_outputs.metadata.label_color:t:p.sort(function(t,n){return h(t)-h(n)})[0]},m=function(t){for(var n,o,e,r,i,u,l,a,s,c=0,v=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});c<v.length;c++){var d=v[c];if(b=null===(e=null===(o=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[d])||void 0===o?void 0:o.evaluation_outputs)||void 0===e?void 0:e.output_value)return b}for(var f=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<g.length;f++){d=g[f];if(b=null===(u=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[d])||void 0===i?void 0:i.evaluation_outputs)||void 0===u?void 0:u.output_value)return b}for(var p=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});p<h.length;p++){var b;d=h[p];if(b=null===(a=null===(l=null==t?void 0:t[d])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},y=function(t,n){var o=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},e=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var r=o(t),i=o(n),u=(r[0]+i[0])/2*.95,l=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(e(u)).concat(e(l)).concat(e(a))}catch(t){return"#FDE68A"}},_=function(t,n,o){if(!t)return null;if(t.id===o)return n;if(!Array.isArray(t.subsections))return null;for(var e=0;e<t.subsections.length;e++){var r=_(t.subsections[e],"".concat(n,"-").concat(e),o);if(r)return r}return null},B=function(t,n){for(var o=0;o<t.length;o++){var e=_(t[o],String(o),n);if(e)return e}return null},T=new WeakMap,x=function(t){if(t){var n=T.get(t);null!=n&&(clearTimeout(n),T.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},C=function(t){if(t){var n=T.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var o=window.setTimeout(function(){x(t)},3e3);T.set(t,o)}},A=function(t,n){var o=n.getBoundingClientRect(),e=t.getBoundingClientRect(),r=n.scrollTop+e.top-o.top-o.height/2+e.height/2;n.scrollTo({top:r,behavior:"smooth"});var i=function(){return C(t)};if("onscrollend"in n)n.addEventListener("scrollend",i,{once:!0});else{var u=n.scrollTop,l=function(){n.scrollTop===u?i():(u=n.scrollTop,requestAnimationFrame(l))};requestAnimationFrame(l)}};export{a as DEVIATION_BADGE_SEPARATOR,l as areMarkdownPropsEqual,u as debounce,d as extractDeviationScore,B as findKeyPathByNodeId,i as generateColorPalette,f as getBentArrowPath,b as getFirstDeviationColor,m as getFirstDeviationOutputValue,r as getRationale,e as getSideData,c as hasMeaningfulRedlineTags,o as hasValue,C as highlightClause,s as isMissingStr,y as mixHexColors,_ as recursivelyFindSubSectionIdxById,x as resetClauseHighlight,n as safeStringify,A as scrollAndHighlightClause,g as smoothScrollTo,v as stripRedlineTags};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsx as n,jsxs as t}from"react/jsx-runtime";import{Popper as i,Paper as o,Box as r,Typography as l,IconButton as a,Accordion as d,AccordionSummary as c,AccordionDetails as s}from"@mui/material";import{Info as p,X as u,ChevronDown as f}from"lucide-react";import{useRef as m,useState as h,useEffect as x,useMemo as g}from"react";function v(v){var b,y,w,S=v.open,C=v.anchorEl,I=v.containerEl,z=v.clipTopEl,B=v.scrollContainerEl,R=v.onClose,F=v.summary;v.markdownStyles,v.isLoading;var W=v.displayImpact,E=m(null),H=m(null),k=h(null),A=k[0],_=k[1],L=h(null),M=L[0],P=L[1],O=h(null);O[0];var T=O[1],N=h(0),j=N[0],J=N[1],q="string"==typeof F?{deviation_summary:F}:null!=F?F:{},D=q.deviation_title,G=q.deviation_summary,V=q.deviation_impact,Y=q.evaluation_outputs,Z=!!String(V||"").trim(),K=h(!!W),Q=K[0],U=K[1];x(function(){Z&&U(!!W)},[W,Z,F]);var X=(null===(b=null==Y?void 0:Y.metadata)||void 0===b?void 0:b.label_color)||"#6366F1",$=null!==(y=null==I?void 0:I.getBoundingClientRect().width)&&void 0!==y?y:180,ee=Math.max(148,$+120),ne=g(function(){if(!C||!I)return null;var e=C.getBoundingClientRect();if(0===e.width&&0===e.height)return null;var n=I.getBoundingClientRect();return{top:e.top,bottom:e.bottom,left:n.left+n.width/2}},[C,I]);x(function(){if(!S||!C||!I)return _(null),P(null),void T(null);var e=function(){null!==E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame(function(){var e,n,t=C.getBoundingClientRect(),i=null==z?void 0:z.getBoundingClientRect(),o=null==B?void 0:B.getBoundingClientRect();if(0===t.width&&0===t.height)_(null);else{var r=I.getBoundingClientRect();_({top:t.top,bottom:t.bottom,left:r.left+r.width/2})}P(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),T(null!==(n=null==o?void 0:o.bottom)&&void 0!==n?n:null),H.current&&J(H.current.offsetHeight)})};return e(),window.addEventListener("scroll",e,{passive:!0,capture:!0}),window.addEventListener("resize",e),function(){null!==E.current&&cancelAnimationFrame(E.current),window.removeEventListener("scroll",e,{capture:!0}),window.removeEventListener("resize",e)}},[S,C,I,z,B]);var te=null!==(w=null!=A?A:ne)&&void 0!==w?w:"hidden",ie="hidden"===te?"hidden":te.bottom+20,oe=null!=M&&"number"==typeof ie&&ie<M?Math.min(j,M-ie):0,re=g(function(){return"hidden"===te?{getBoundingClientRect:function(){return{width:0,height:0,top:0,bottom:0,left:0,right:0,x:0,y:0,toJSON:function(){}}}}:{getBoundingClientRect:function(){return{width:0,height:te.bottom-te.top,top:te.top,bottom:te.bottom,left:te.left,right:te.left,x:te.left,y:te.top,toJSON:function(){}}}}},[te]);return F?n(i,e({open:S,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:re,placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}},{name:"preventOverflow",enabled:!0,options:{boundary:B||"clippingParents",tether:!1}},{name:"flip",enabled:!0,options:{boundary:B||"clippingParents",fallbackPlacements:["top"]}}],sx:{zIndex:21,visibility:"hidden"===te?"hidden":"visible",opacity:"hidden"===te?0:1,transition:"opacity 0.15s ease-in-out"}},{children:t(o,e({ref:H,sx:e(e({p:1.5,borderRadius:"12px",width:ee,maxWidth:ee},oe>0&&{clipPath:"inset(".concat(oe,"px 0px 0px 0px round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(X,"26"),borderTop:"3px solid ".concat(X),overflow:"hidden",bgcolor:"#fff"})},{children:[t(r,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[t(r,e({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[n(p,{size:14,color:X}),n(l,e({sx:{fontSize:"11px",fontWeight:700,color:X,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),n(a,e({size:"small",onClick:R,sx:{p:.25,ml:.5,color:"#64748B"}},{children:n(u,{size:14})}))]})),t(r,e({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[t(r,{children:[D&&n(l,e({sx:{fontSize:"12px",color:"#334155",fontFamily:'"Inter", sans-serif',lineHeight:1.6,fontWeight:700,overflowWrap:"anywhere"}},{children:D})),n(l,e({sx:{fontSize:"11px",color:"#334155",lineHeight:1.6,fontFamily:'"Inter", sans-serif',fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:G||"No summary available."}))]}),Z&&t(d,e({expanded:Q,onChange:function(e,n){return U(n)},disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(X,"0A"),border:"1px solid ".concat(X,"33"),borderRadius:"4px",fontFamily:'"Inter", sans-serif',overflow:"hidden",flexShrink:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[n(c,e({expandIcon:n(f,{size:16,color:X}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(X,"1A")}}},{children:n(l,e({sx:{fontSize:"11px",fontWeight:700,color:X,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),n(s,e({sx:{p:1.5,backgroundColor:"#fff"}},{children:n(l,e({sx:{fontSize:"11px",color:"#475569",lineHeight:1.6,fontWeight:400,fontFamily:'"Inter", sans-serif',overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(V).replace("Impact -","").trim()}))}))]}))]}))]}))})):null}export{v as default};
1
+ import{__assign as e}from"tslib";import{jsx as n,jsxs as t}from"react/jsx-runtime";import{Popper as i,Paper as o,Box as r,Typography as l,IconButton as a,Accordion as d,AccordionSummary as c,AccordionDetails as s}from"@mui/material";import{Info as u,X as p,ChevronDown as f}from"lucide-react";import{useRef as m,useState as h,useEffect as v,useMemo as x}from"react";function g(g){var w,b,y,S=g.open,E=g.anchorEl,C=g.containerEl,I=g.clipTopEl,z=g.scrollContainerEl,L=g.onClose,B=g.summary;g.markdownStyles,g.isLoading;var R=g.displayImpact,F=g.isScrollLocked,H=m(null),W=m(null),k=h(null),A=k[0],_=k[1],M=h(null),P=M[0],O=M[1],T=h(null);T[0];var N=T[1],Y=h(0),j=Y[0],J=Y[1],q="string"==typeof B?{deviation_summary:B}:null!=B?B:{},D=h(!1),G=D[0],V=D[1];v(function(){S&&V(!1)},[S]),v(function(){if(S&&F){var e=function(){V(!0)};return window.addEventListener("wheel",e,{passive:!0}),window.addEventListener("touchmove",e,{passive:!0}),function(){window.removeEventListener("wheel",e),window.removeEventListener("touchmove",e)}}},[S,F]);var Z=q.deviation_title,K=q.deviation_summary,Q=q.deviation_impact,U=q.evaluation_outputs,X=!!String(Q||"").trim(),$=h(!!R),ee=$[0],ne=$[1];v(function(){X&&ne(!!R)},[R,X,B]);var te=(null===(w=null==U?void 0:U.metadata)||void 0===w?void 0:w.label_color)||"#6366F1",ie=null!==(b=null==C?void 0:C.getBoundingClientRect().width)&&void 0!==b?b:180,oe=Math.max(148,ie+120),re=x(function(){if(!E||!C)return null;var e=E.getBoundingClientRect();if(0===e.width&&0===e.height)return null;var n=C.getBoundingClientRect();return{top:e.top,bottom:e.bottom,left:n.left+n.width/2}},[E,C]);v(function(){if(!S||!E||!C)return _(null),O(null),void N(null);var e=function(){null!==H.current&&cancelAnimationFrame(H.current),H.current=requestAnimationFrame(function(){var e,n,t=null==E?void 0:E.getBoundingClientRect(),i=null==I?void 0:I.getBoundingClientRect(),o=null==z?void 0:z.getBoundingClientRect();if(0!==t.width||0!==t.height){var r=C.getBoundingClientRect();_({top:t.top,bottom:t.bottom,left:r.left+r.width/2}),O(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),N(null!==(n=null==o?void 0:o.bottom)&&void 0!==n?n:null),W.current&&J(W.current.offsetHeight)}})};e();var n=function(e){for(var n=[],t=(null==e?void 0:e.parentElement)||null;t;){var i=window.getComputedStyle(t);("auto"===i.overflowY||"scroll"===i.overflowY)&&t.scrollHeight>t.clientHeight&&n.push(t),t=t.parentElement}return n}(E);return window.addEventListener("scroll",e,{passive:!0,capture:!0}),window.addEventListener("resize",e),n.forEach(function(n){n.addEventListener("scroll",e,{passive:!0})}),function(){null!==H.current&&cancelAnimationFrame(H.current),window.removeEventListener("scroll",e,{capture:!0}),window.removeEventListener("resize",e),n.forEach(function(n){n.removeEventListener("scroll",e)})}},[S,E,C,I,z,F]);var le=null!==(y=null!=A?A:re)&&void 0!==y?y:"hidden",ae="hidden"===le?"hidden":le.bottom+20,de=null!=P&&"number"==typeof ae&&ae<P?Math.min(j,P-ae):0,ce=x(function(){return"hidden"===le?{getBoundingClientRect:function(){return{width:0,height:0,top:0,bottom:0,left:0,right:0,x:0,y:0,toJSON:function(){}}}}:{getBoundingClientRect:function(){return{width:0,height:le.bottom-le.top,top:le.top,bottom:le.bottom,left:le.left,right:le.left,x:le.left,y:le.top,toJSON:function(){}}}}},[le]);return B?n(i,e({open:S&&!G,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:ce,placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}},{name:"preventOverflow",enabled:!0,options:{boundary:z||"clippingParents",tether:!1}},{name:"flip",enabled:!0,options:{boundary:z||"clippingParents",fallbackPlacements:["top"]}}],sx:{zIndex:21,visibility:"hidden"===le?"hidden":"visible",opacity:"hidden"===le?0:1,transition:"opacity 0.15s ease-in-out"}},{children:t(o,e({ref:W,sx:e(e({p:1.5,borderRadius:"12px",width:oe,maxWidth:oe},de>0&&{clipPath:"inset(".concat(de,"px 0px 0px 0px round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(te,"26"),borderTop:"3px solid ".concat(te),overflow:"hidden",bgcolor:"#fff"})},{children:[t(r,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[t(r,e({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[n(u,{size:14,color:te}),n(l,e({sx:{fontSize:"11px",fontWeight:700,color:te,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),n(a,e({size:"small",onClick:L,sx:{p:.25,ml:.5,color:"#64748B"}},{children:n(p,{size:14})}))]})),t(r,e({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[t(r,{children:[Z&&n(l,e({sx:{fontSize:"12px",color:"#334155",fontFamily:'"Inter", sans-serif',lineHeight:1.6,fontWeight:700,overflowWrap:"anywhere"}},{children:Z})),n(l,e({sx:{fontSize:"11px",color:"#334155",lineHeight:1.6,fontFamily:'"Inter", sans-serif',fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:K||"No summary available."}))]}),X&&t(d,e({expanded:ee,onChange:function(e,n){return ne(n)},disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(te,"0A"),border:"1px solid ".concat(te,"33"),borderRadius:"4px",fontFamily:'"Inter", sans-serif',overflow:"hidden",flexShrink:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[n(c,e({expandIcon:n(f,{size:16,color:te}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(te,"1A")}}},{children:n(l,e({sx:{fontSize:"11px",fontWeight:700,color:te,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),n(s,e({sx:{p:1.5,backgroundColor:"#fff"}},{children:n(l,e({sx:{fontSize:"11px",color:"#475569",lineHeight:1.6,fontWeight:400,fontFamily:'"Inter", sans-serif',overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(Q).replace("Impact -","").trim()}))}))]}))]}))]}))})):null}export{g as default};
2
2
  //# sourceMappingURL=CognitiveSummaryPopup.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsx as o,jsxs as i}from"react/jsx-runtime";import n from"react";import{Box as t}from"@mui/material";import{EllipsisVertical as r}from"lucide-react";import l from"./SectionAccordion.js";import a from"./ThreeDotsLoader.js";import{extractDeviationScore as d}from"../CognitiveComparehelpers.js";import{useCompareContext as c}from"../CompareContext.js";var s=n.memo(function(n){var s,p,u=n.section,f=n.idx,v=c(),g=v.maintainRelativeOrder,m=v.existingSections;v.proposedSections;var x=v.connectedSections,h=v.expandedSections,b=v.displayConfig,S=v.treeData;v.deviationNumberRegistry;var R=v.getSectionCompareStyle;v.getBadgeRef;var w=v.getSectionRowRef,y=v.sectionLeftRefs,B=v.lhsBadgeRefs,C=v.openMoreFunctionsPopup,I=v.handleOpenSummaryPopup,N=v.handleCloseSummaryPopup,D=v.toggleSection;v.showDeviationBadges,v.renderSubSectionAccordion,v.isProposingFix,v.proposingFixNodeId,v.isRedlineFlow,v.isSideBySide,v.activeSideBySideSection,v.deviationNodeIdToView,v.deviationTargetParentId;var P=v.showDeviationNavigation;v.showOpenNodeRef,v.resolvedMarkdownStyles;var T=v.unifiedNumbering,k=!u.title&&!u.content;if(g&&k)return null;var j=u,z=R(f,"left"),A=g?!(null===(s=j.refIndexes)||void 0===s?void 0:s.length)||j.selfIndex<0:!m[f],F=x.has(f),L=d(j.evaluationResult,null==z?void 0:z.deviationLabel),O=T.leftNums.get(j.id);return o(t,e({ref:w(f),sx:{mb:1,width:"100%"}},{children:o(t,e({ref:y.current[f],sx:e({width:"100%",display:"flex",flexDirection:"column",minWidth:0},F&&{borderRadius:"6px",outline:"2px solid ".concat((null==z?void 0:z.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(t,e({sx:{position:"relative",width:"100%"}},{children:[o(l,{section:u,idx:f,columnKey:"left",colRef:w("left-accordion-".concat(f)),mb:0,parentNodeId:(null===(p=null==S?void 0:S.input_index_map)||void 0===p?void 0:p[0])||"",isExpanded:g?!!h["left-".concat(f)]:!!h[String(f)],onToggle:function(){N(),D(f,"left")},navigation:u.id?P[u.id]:null}),g&&z&&i(t,e({ref:B.current[f],onClick:function(e){var o,i,n,t=b.enableDeviationSchemaBackwardCompatibility?null!==(o=j.evaluationResult)&&void 0!==o?o:null:null!==(n=null===(i=j.evaluationResult)||void 0===i?void 0:i[0])&&void 0!==n?n:null;I(e,String(f),A,t)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:z.badgeBg,color:z.badgeText,border:"1px solid ".concat(z.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[i(t,e({component:"span",onClick:function(e){var o,i,n;e.stopPropagation();var t=b.enableDeviationSchemaBackwardCompatibility?null!==(o=j.evaluationResult)&&void 0!==o?o:null:null!==(n=null===(i=j.evaluationResult)||void 0===i?void 0:i[0])&&void 0!==n?n:null;I(e,String(f),A,t)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:A?"default":"pointer",borderRight:"1px solid ".concat(z.badgeBorder),"&:hover":A?{}:{bgColor:"".concat(z.badgeBorder,"22")}}},{children:[null!=O&&o(t,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(z.badgeBorder)}},{children:O})),o(t,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!b.isLoading||null!=j.evaluationResult&&void 0!==j.evaluationResult?"N/A"===L||"NA"===L?"N/A":0==L||null==L?"Same":"".concat(L):o(a,{color:z.badgeText})}))]})),o(t,e({component:"span",onClick:function(e){e.stopPropagation();var o=g?m.find(function(e){var o;return null===(o=j.refIndexes)||void 0===o?void 0:o.includes(e.selfIndex)})||{title:"",content:""}:m[f]||{title:"",content:""};C(e,u,A,o,f,z)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(z.badgeBorder,"22")}}},{children:o(r,{size:11,color:z.badgeText})}))]}))]}))}))}),"left-row-".concat(f))});export{s as default};
1
+ import{__assign as e}from"tslib";import{jsx as o,jsxs as i}from"react/jsx-runtime";import n from"react";import{Box as t}from"@mui/material";import{EllipsisVertical as r}from"lucide-react";import l from"./SectionAccordion.js";import a from"./ThreeDotsLoader.js";import d from"./ScrollLockToggle.js";import{extractDeviationScore as c}from"../CognitiveComparehelpers.js";import{useCompareContext as s}from"../CompareContext.js";var p=n.memo(function(n){var p,u,g,v=n.section,m=n.idx,f=s(),x=f.maintainRelativeOrder,b=f.existingSections;f.proposedSections;var h=f.connectedSections,S=f.expandedSections,R=f.displayConfig,y=f.treeData;f.deviationNumberRegistry;var w=f.getSectionCompareStyle;f.getBadgeRef;var B=f.getSectionRowRef,C=f.sectionLeftRefs,I=f.lhsBadgeRefs,N=f.openMoreFunctionsPopup,k=f.handleOpenSummaryPopup,T=f.handleCloseSummaryPopup,P=f.toggleSection;f.showDeviationBadges,f.renderSubSectionAccordion,f.isProposingFix,f.proposingFixNodeId,f.isRedlineFlow;var D=f.isSideBySide,L=f.activeSideBySideSection,j=f.scrollSyncLocked,z=f.toggleScrollSyncLocked,A=f.summaryPopupAnchorEl;f.deviationNodeIdToView,f.deviationTargetParentId;var F=f.showDeviationNavigation;f.showOpenNodeRef,f.resolvedMarkdownStyles;var O=f.unifiedNumbering,W=!v.title&&!v.content;if(x&&W)return null;var E=v,M=w(m,"left"),_=x?!(null===(p=E.refIndexes)||void 0===p?void 0:p.length)||E.selfIndex<0:!b[m],K=h.has(m),V=null===(u=I.current[m])||void 0===u?void 0:u.current,X=K||D&&L===m||!!A&&A===V,Y=c(E.evaluationResult,null==M?void 0:M.deviationLabel),q=O.leftNums.get(E.id);return o(t,e({ref:B(m),sx:{mb:1,width:"100%"}},{children:o(t,e({ref:C.current[m],sx:e({width:"100%",display:"flex",flexDirection:"column",minWidth:0},K&&{borderRadius:"6px",outline:"2px solid ".concat((null==M?void 0:M.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(t,e({sx:{position:"relative",width:"100%"}},{children:[o(l,{section:v,idx:m,columnKey:"left",colRef:B("left-accordion-".concat(m)),mb:0,parentNodeId:(null===(g=null==y?void 0:y.input_index_map)||void 0===g?void 0:g[0])||"",isExpanded:x?!!S["left-".concat(m)]:!!S[String(m)],onToggle:function(){T(),P(m,"left")},navigation:v.id?F[v.id]:null}),x&&M&&i(t,e({ref:I.current[m],onClick:function(e){var o,i,n,t=R.enableDeviationSchemaBackwardCompatibility?null!==(o=E.evaluationResult)&&void 0!==o?o:null:null!==(n=null===(i=E.evaluationResult)||void 0===i?void 0:i[0])&&void 0!==n?n:null;k(e,String(m),_,t)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:M.badgeBg,color:M.badgeText,border:"1px solid ".concat(M.badgeBorder),borderRadius:"12px",px:1.2,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[i(t,e({component:"span",onClick:function(e){var o,i,n;e.stopPropagation();var t=R.enableDeviationSchemaBackwardCompatibility?null!==(o=E.evaluationResult)&&void 0!==o?o:null:null!==(n=null===(i=E.evaluationResult)||void 0===i?void 0:i[0])&&void 0!==n?n:null;k(e,String(m),_,t)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:_?"default":"pointer",borderRight:"1px solid ".concat(M.badgeBorder),"&:hover":_?{}:{bgColor:"".concat(M.badgeBorder,"22")}}},{children:[null!=q&&o(t,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(M.badgeBorder)}},{children:q})),o(t,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!R.isLoading||null!=E.evaluationResult&&void 0!==E.evaluationResult?"N/A"===Y||"NA"===Y?"N/A":0==Y||null==Y?"Same":"".concat(Y):o(a,{color:M.badgeText})}))]})),o(t,e({component:"span",onClick:function(e){e.stopPropagation();var o=x?b.find(function(e){var o;return null===(o=E.refIndexes)||void 0===o?void 0:o.includes(e.selfIndex)})||{title:"",content:""}:b[m]||{title:"",content:""};N(e,v,_,o,m,M)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(M.badgeBorder,"22")}}},{children:o(r,{size:11,color:M.badgeText})})),X&&o(d,{locked:j,onToggle:z,color:M.badgeText,borderColor:M.badgeBorder,size:11})]}))]}))}))}),"left-row-".concat(m))});export{p as default};
2
2
  //# sourceMappingURL=LHSSectionRow.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsx as i,jsxs as o,Fragment as n}from"react/jsx-runtime";import t from"react";import{Box as r}from"@mui/material";import{EllipsisVertical as a}from"lucide-react";import l from"./SectionAccordion.js";import d from"./ThreeDotsLoader.js";import{useCompareContext as c}from"../CompareContext.js";var s=t.memo(function(t){var s,p,u=t.section,x=t.idx,f=c(),g=f.maintainRelativeOrder;f.existingSections;var v=f.proposedSections,m=f.connectedSections,h=f.expandedSections,b=f.displayConfig,S=f.treeData;f.deviationNumberRegistry;var R=f.getSectionCompareStyle;f.getBadgeRef;var I=f.getSectionRowRef,y=f.sectionRightRefs,w=f.rhsBadgeRefs,B=f.openMoreFunctionsPopup,C=f.handleOpenSummaryPopup,N=f.handleCloseSummaryPopup,D=f.toggleSection;f.showDeviationBadges,f.renderSubSectionAccordion,f.isProposingFix,f.proposingFixNodeId,f.isRedlineFlow,f.isSideBySide,f.activeSideBySideSection,f.deviationNodeIdToView,f.deviationTargetParentId;var P=f.showDeviationNavigation;f.showOpenNodeRef,f.resolvedMarkdownStyles;var T=f.unifiedNumbering,k=u,j=!1,z=null,F=-1;if(g){F=v.findIndex(function(e){var i;return(null===(i=e.refIndexes)||void 0===i?void 0:i.includes(k.selfIndex))&&e.selfIndex>=0});var O=v.findIndex(function(e,i){var o;return m.has(i)&&(null===(o=e.refIndexes)||void 0===o?void 0:o.includes(k.selfIndex))});(j=-1!==O)&&(z=R(O,"left"))}else(j=m.has(x))&&(z=R(x,"right"));var A=g&&-1!==F?R(F,"left"):R(x,"right"),L=g?-1!==F||!(null===(s=k.refIndexes)||void 0===s?void 0:s.length)&&v.some(function(e){return e.id&&e.id===k.id}):Boolean(v[x]),M=g?k.selfIndex<0||!L:!v[x],W=T.rightNums.get(k.id);return i(r,e({ref:I(x),sx:{mb:1,width:"100%"}},{children:i(r,e({ref:y.current[x],sx:e({width:"100%",display:"flex"},j&&z&&{borderRadius:"6px",outline:"2px solid ".concat(z.badgeBorder),outlineOffset:"1px"})},{children:o(r,e({sx:{position:"relative",width:"100%"}},{children:[i(l,{section:u,idx:x,columnKey:"right",colRef:I("right-accordion-".concat(x)),mb:0,parentNodeId:(null===(p=null==S?void 0:S.input_index_map)||void 0===p?void 0:p[1])||"",isExpanded:g?!!h["right-".concat(x)]:!!h[String(x)],onToggle:function(){N(),D(x,"right")},navigation:u.id?P[u.id]:null}),g&&A&&i(r,e({ref:w.current[x],"data-section-id":k.id,onClick:function(e){var i,o,n;if(M){var t=b.enableDeviationSchemaBackwardCompatibility?null!==(i=k.evaluationResult)&&void 0!==i?i:null:null!==(n=null===(o=k.evaluationResult)||void 0===o?void 0:o[0])&&void 0!==n?n:null;C(e,String(x),M,t)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:M?"4px":"0px",fontSize:"11px",bgcolor:A.badgeBg,color:A.badgeText,border:"1px solid ".concat(A.badgeBorder),borderRadius:M?"12px":"10px",px:M?1.2:1,py:.3,fontWeight:M?600:700,cursor:M?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:M?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:M?o(n,{children:[o(r,e({component:"span",onClick:function(e){var i,o,n;e.stopPropagation();var t=b.enableDeviationSchemaBackwardCompatibility?null!==(i=k.evaluationResult)&&void 0!==i?i:null:null!==(n=null===(o=k.evaluationResult)||void 0===o?void 0:o[0])&&void 0!==n?n:null;C(e,String(x),M,t)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:"1px solid ".concat(A.badgeBorder),"&:hover":{bgcolor:"".concat(A.badgeBorder,"22")}}},{children:[null!=W&&i(r,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(A.badgeBorder)}},{children:W})),i(r,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!b.isLoading||null!=k.evaluationResult&&void 0!==k.evaluationResult?A.label?"".concat(A.label):"100% Deviation":i(d,{color:A.badgeText})}))]})),i(r,e({component:"span",onClick:function(e){e.stopPropagation();var i=g?v.find(function(e){var i;return null===(i=e.refIndexes)||void 0===i?void 0:i.includes(k.selfIndex)})||{title:"",content:""}:v[x]||{title:"",content:""};B(e,i,M,k,x,A)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(A.badgeBorder,"22")}}},{children:i(a,{size:11,color:A.badgeText})}))]}):null!=W?W:""}))]}))}))}),"right-row-".concat(x))});export{s as default};
1
+ import{__assign as e}from"tslib";import{jsx as o,jsxs as n,Fragment as i}from"react/jsx-runtime";import r from"react";import{Box as t}from"@mui/material";import{EllipsisVertical as l}from"lucide-react";import d from"./SectionAccordion.js";import a from"./ThreeDotsLoader.js";import c from"./ScrollLockToggle.js";import{useCompareContext as s}from"../CompareContext.js";var p=r.memo(function(r){var p,u,g,x=r.section,v=r.idx,f=s(),m=f.maintainRelativeOrder;f.existingSections;var h=f.proposedSections,b=f.connectedSections,S=f.expandedSections,R=f.displayConfig,y=f.treeData;f.deviationNumberRegistry;var I=f.getSectionCompareStyle;f.getBadgeRef;var B=f.getSectionRowRef,w=f.sectionRightRefs,C=f.rhsBadgeRefs,T=f.openMoreFunctionsPopup,k=f.handleOpenSummaryPopup,N=f.handleCloseSummaryPopup,P=f.toggleSection;f.showDeviationBadges,f.renderSubSectionAccordion,f.isProposingFix,f.proposingFixNodeId,f.isRedlineFlow;var z=f.isSideBySide,D=f.activeSideBySideSection,j=f.scrollSyncLocked,L=f.toggleScrollSyncLocked,F=f.summaryPopupAnchorEl;f.deviationNodeIdToView,f.deviationTargetParentId;var O=f.showDeviationNavigation;f.showOpenNodeRef,f.resolvedMarkdownStyles;var A=f.unifiedNumbering,E=x,M=!1,W=null,_=-1;if(m){_=h.findIndex(function(e){var o;return(null===(o=e.refIndexes)||void 0===o?void 0:o.includes(E.selfIndex))&&e.selfIndex>=0});var K=h.findIndex(function(e,o){var n;return b.has(o)&&(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(E.selfIndex))});(M=-1!==K)&&(W=I(K,"left"))}else(M=b.has(v))&&(W=I(v,"right"));var V=m&&-1!==_?I(_,"left"):I(v,"right"),X=m?-1!==_||!(null===(p=E.refIndexes)||void 0===p?void 0:p.length)&&h.some(function(e){return e.id&&e.id===E.id}):Boolean(h[v]),Y=m?E.selfIndex<0||!X:!h[v],q=A.rightNums.get(E.id),G=null===(u=C.current[v])||void 0===u?void 0:u.current,H=M||z&&(D===v||D===_)||!!F&&F===G;return o(t,e({ref:B(v),sx:{mb:1,width:"100%"}},{children:o(t,e({ref:w.current[v],sx:e({width:"100%",display:"flex"},M&&W&&{borderRadius:"6px",outline:"2px solid ".concat(W.badgeBorder),outlineOffset:"1px"})},{children:n(t,e({sx:{position:"relative",width:"100%"}},{children:[o(d,{section:x,idx:v,columnKey:"right",colRef:B("right-accordion-".concat(v)),mb:0,parentNodeId:(null===(g=null==y?void 0:y.input_index_map)||void 0===g?void 0:g[1])||"",isExpanded:m?!!S["right-".concat(v)]:!!S[String(v)],onToggle:function(){N(),P(v,"right")},navigation:x.id?O[x.id]:null}),m&&V&&o(t,e({ref:C.current[v],"data-section-id":E.id,onClick:function(e){var o,n,i;if(Y){var r=R.enableDeviationSchemaBackwardCompatibility?null!==(o=E.evaluationResult)&&void 0!==o?o:null:null!==(i=null===(n=E.evaluationResult)||void 0===n?void 0:n[0])&&void 0!==i?i:null;k(e,String(v),Y,r)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:Y?"4px":"0px",fontSize:"11px",bgcolor:V.badgeBg,color:V.badgeText,border:"1px solid ".concat(V.badgeBorder),borderRadius:Y?"12px":"10px",px:Y?1.2:1,py:.3,fontWeight:Y?600:700,cursor:Y?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:Y?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:n(i,Y?{children:[n(t,e({component:"span",onClick:function(e){var o,n,i;e.stopPropagation();var r=R.enableDeviationSchemaBackwardCompatibility?null!==(o=E.evaluationResult)&&void 0!==o?o:null:null!==(i=null===(n=E.evaluationResult)||void 0===n?void 0:n[0])&&void 0!==i?i:null;k(e,String(v),Y,r)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:"1px solid ".concat(V.badgeBorder),"&:hover":{bgcolor:"".concat(V.badgeBorder,"22")}}},{children:[null!=q&&o(t,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(V.badgeBorder)}},{children:q})),o(t,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!R.isLoading||null!=E.evaluationResult&&void 0!==E.evaluationResult?V.label?"".concat(V.label):"100% Deviation":o(a,{color:V.badgeText})}))]})),o(t,e({component:"span",onClick:function(e){e.stopPropagation();var o=m?h.find(function(e){var o;return null===(o=e.refIndexes)||void 0===o?void 0:o.includes(E.selfIndex)})||{title:"",content:""}:h[v]||{title:"",content:""};T(e,o,Y,E,v,V)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(V.badgeBorder,"22")}}},{children:o(l,{size:11,color:V.badgeText})})),H&&o(c,{locked:j,onToggle:L,color:V.badgeText,borderColor:V.badgeBorder,size:11})]}:{children:[o(t,e({component:"span",sx:{px:.2}},{children:null!=q?q:""})),H&&o(c,{locked:j,onToggle:L,color:V.badgeText,borderColor:V.badgeBorder,size:11})]})}))]}))}))}),"right-row-".concat(v))});export{p as default};
2
2
  //# sourceMappingURL=RHSSectionRow.js.map
@@ -0,0 +1,2 @@
1
+ import{__assign as o}from"tslib";import{jsx as r}from"react/jsx-runtime";import{Tooltip as e,Box as t}from"@mui/material";import{Lock as i,Unlock as l}from"lucide-react";var c=function(c){var n=c.locked,a=c.onToggle,m=c.color,s=void 0===m?"#3730A3":m,p=c.borderColor,d=void 0===p?"#C7D2FE":p,f=c.size,u=void 0===f?12:f,v=n?i:l;return r(e,o({title:n?"Unlock scroll":"Lock scroll",placement:"top"},{children:r(t,o({component:"span",onClick:a,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",px:.5,borderLeft:"1px solid ".concat(d),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:r(v,{size:u,color:s})}))}))};export{c as default};
2
+ //# sourceMappingURL=ScrollLockToggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLockToggle.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{__assign as n}from"tslib";import{jsxs as i,jsx as e}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as r,AccordionSummary as d,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{useCompareContext as p}from"../CompareContext.js";import{hasValue as h,hasMeaningfulRedlineTags as x,stripRedlineTags as m,generateColorPalette as g,isMissingStr as I,safeStringify as b,DEVIATION_BADGE_SEPARATOR as y}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";var S=function(S){var _,F,R,k,B,C,M,A,O,W,j,N,T,E=S.section,P=S.idx,D=S.columnKey,K=S.colRef,z=S.mb,V=void 0===z?1:z,G=S.isExpanded,H=S.onToggle,X=S.navigation,Y=S.parentNodeId,q=void 0===Y?"":Y,J=p(),L=J.showOpenNodeRef,Q=J.resolvedMarkdownStyles,U=J.maintainRelativeOrder,Z=J.showDeviationBadges,$=void 0!==Z&&Z,nn=J.renderSubSectionAccordion,en=J.treeData,on=J.proposedSections,tn=J.existingSections,ln=J.deviationNumberRegistry,rn=J.getBadgeRef,dn=J.openSummaryPopup,an=J.getSectionCompareStyle,un=J.connectedSections,cn=J.openMoreFunctionsPopup;J.deviationNodeIdToView,J.deviationTargetParentId;var sn=J.isProposingFix,vn=J.proposingFixNodeId,fn=J.isRedlineFlow,pn=J.isSideBySide,hn=J.activeSideBySideSection,xn="".concat(pn?"1":"0","-").concat(String(null!=hn?hn:"")),mn=(null===(_=E.displayTitle)||void 0===_||_)&&h(E.title),gn=!!sn&&!!vn&&"left"===D&&E.id===vn,In=x(E.content),bn="boolean"==typeof fn?fn:In,yn=In,wn=bn&&In,Sn=wn?m(E.content):E.content,_n=wn?E.content:void 0,Fn=(null===(F=E.displayContent)||void 0===F||F||In)&&h(E.content),Rn=!mn&&!Fn,kn=E.title;mn||(kn=Fn?"No Title Found":"No Matching Section Found");var Bn=E.evaluationResult;if(!Bn&&"right"===D)if(U){var Cn=null===(R=E.refIndexes)||void 0===R?void 0:R[0],Mn=on.find(function(n){return n.selfIndex===Cn});Bn=null==Mn?void 0:Mn.evaluationResult}else Bn=null===(k=on[P])||void 0===k?void 0:k.evaluationResult;var An=null===(B=null==en?void 0:en.input_index_map)||void 0===B?void 0:B[0],On=null===(C=null==en?void 0:en.input_index_map)||void 0===C?void 0:C[1],Wn="left"===D?On:An,jn=function(n,i){return n.find(function(n){return(null==n?void 0:n.id)&&i&&n.id===i})},Nn="left"===D?E:on[P],Tn="right"===D?E:tn[P],En=o.useMemo(function(){if(!U)return 0;var n=1/0,i=function(e,o,t,l){var r;if(e){var d=e.id;if(l&&"right"===D){var a=on.filter(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(e.selfIndex)});a.length>0&&(d=a[0].id)}var u=e.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),c=(null===(r=e.evaluationResult)||void 0===r?void 0:r.deviations)||{};Object.keys(c).forEach(function(i){var e="".concat(d).concat(y).concat(i),o=null==ln?void 0:ln[e];null!=o&&o<n&&(n=o);var t="".concat(u).concat(y).concat(i),l=null==ln?void 0:ln[t];null!=l&&l<n&&(n=l)});for(var s=e.subsections||[],v=(null==o?void 0:o.subsections)||[],f=(null==t?void 0:t.subsections)||[],p=Math.max(s.length,v.length,f.length),h=0;h<p;h++)i(s[h],v[h],f[h],!1)}};return i(E,Nn,Tn,!0),n!==1/0?n-1:0},[E,Nn,Tn,D,ln,U,on]);if(U)if("left"===D){var Pn=null===(M=E.refIndexes)||void 0===M?void 0:M[0],Dn=tn.findIndex(function(n){return n.selfIndex===Pn});Tn=-1!==Dn?tn[Dn]:jn(tn,E.id)}else{var Kn=null===(A=E.refIndexes)||void 0===A?void 0:A[0],zn=on.findIndex(function(n){return n.selfIndex===Kn});Nn=-1!==zn?on[zn]:jn(on,E.id)}var Vn="left"===D?!Tn:!Nn,Gn=Bn||(null==Nn?void 0:Nn.evaluationResult)||(null==Tn?void 0:Tn.evaluationResult),Hn=null!==(j=null===(W=null===(O=null==Gn?void 0:Gn.evaluation_outputs)||void 0===O?void 0:O.metadata)||void 0===W?void 0:W.label_color)&&void 0!==j?j:w,Xn=g(Hn).highlightBg,Yn=(null==Gn?void 0:Gn.deviations)||{},qn=P+1,Jn=E.id;if(U){var Ln=1,Qn=new Map;if(on.forEach(function(n){!n.title&&!n.content||n.id&&Qn.set(n.id,Ln++)}),"left"===D)qn=Qn.get(E.id)||P+1;else{var Un=on.filter(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(E.selfIndex)});if(Un.length>0)qn=Qn.get(Un[0].id)||P+1,Jn=Un[0].id;else for(var Zn=Ln,$n=function(n){if(!n.title&&!n.content)return"continue";var i=on.some(function(i){var e;return null===(e=i.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});if(!i){if(n.id===E.id)return qn=Zn,"break";Zn++}},ni=0,ii=tn;ni<ii.length;ni++){if("break"===$n(ii[ni]))break}}}var ei=Object.entries(Yn).map(function(n){var i=n[0],e=n[1],o="".concat(Jn).concat(y).concat(i);return{deviationKey:i,deviationMap:e,refId:o,currentIndex:ln[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});ei.sort(function(n,i){return n.currentIndex-i.currentIndex});var oi,ti=ei.map(function(i){var e,o,t,l,r,d,a=i.deviationKey,u=i.deviationMap,c=i.refId,s=i.currentIndex;U&&void 0!==En&&(s-=En);var v=u[q],f=I(v);if(f)v="";else if(!v)return null;var p=P,h=P;if(U)if("left"===D){var x=null===(e=E.refIndexes)||void 0===e?void 0:e[0],m=tn.findIndex(function(n){return n.selfIndex===x});if(-1!==m)h=m;else{var b=tn.findIndex(function(n){return n.id===E.id});h=-1!==b?b:P}}else{var w=null===(o=E.refIndexes)||void 0===o?void 0:o[0],S=on.findIndex(function(n){return n.selfIndex===w});if(-1!==S)p=S;else{var _=on.findIndex(function(n){return n.id===E.id});p=-1!==_?_:P}}var F="".concat(Jn).concat(y).concat(a).concat(y).concat(p).concat(y).concat(h),R=u[Wn],k=Vn||I(R),B="".concat(qn,".").concat(s),C=P;if("right"===D&&U){var M=null===(t=E.refIndexes)||void 0===t?void 0:t[0],A=on.findIndex(function(n){return n.selfIndex===M});if(-1!==A)C=A;else{_=on.findIndex(function(n){return n.id===E.id});-1!==_&&(C=_)}}var O=an?an(C):null,W=(null==u?void 0:u.evaluation_outputs)||(null==Gn?void 0:Gn.evaluation_outputs),j=null!==(l=null==W?void 0:W.output_value)&&void 0!==l?l:null,N=null!==(d=null===(r=null==W?void 0:W.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:Hn,T=g(N),K=O?n(n({},O),{badgeBg:T.badgeBg,badgeBorder:T.badgeBorder,badgeText:T.badgeText}):n({},T),z=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Gn?void 0:Gn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Gn?void 0:Gn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Gn?void 0:Gn.deviation_explanation),evaluation_outputs:W,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Gn?void 0:Gn.cognitive_decisioning)}:null,V=0,G=Sn||"";if(v&&G){var H=G.split(/\n{2,}/),X=H.findIndex(function(n){return n.includes(v)});if(-1!==X){var Y=Object.entries(Yn).filter(function(n){n[0];var i=n[1][q];return i&&H[X].includes(i)}).sort(function(n,i){return H[X].indexOf(n[1][q])-H[X].indexOf(i[1][q])}),J=Y.filter(function(n){n[0];var i=n[1][q];return i&&(i.includes(v)||v.includes(i))});J.length>1&&(V=Math.max(0,J.findIndex(function(n){return n[0]===a})))}}return{id:c,actionId:F,label:B,highlight:v,side:D,style:K,stackIndex:V,score:j,isConnected:null==un?void 0:un.has(F),isOrphan:k,isMissingClause:f,badgeRef:rn(D,c),onClick:function(n){n.stopPropagation(),cn&&cn(n,Nn||{id:"orphan-left",title:"",content:""},k,Tn||{id:"orphan-right",title:"",content:""},F,K)},onSummaryClick:function(n){n.stopPropagation(),dn(n,F,k,z)}}}).filter(Boolean),li=$||!bn&&gn,ri=li?ti:[],di=li?ri.map(function(n){return n.highlight}).filter(Boolean):[],ai=E.id&&D===(null==X?void 0:X.columnKey)?X:null,ui=o.useRef(!1);return t(function(){G||(ui.current=!1)},[G]),i(l,n({ref:K,sx:{mb:V,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[G&&(null==ai?void 0:ai.showAbove)&&e("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,i;return null===(i=null===(n=null==ai?void 0:ai.showAboveRef)||void 0===n?void 0:n.current)||void 0===i?void 0:i.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===D?{right:"0px"}:{left:"0px"})},{children:e(s,{color:(null===(N=null==ai?void 0:ai.showAboveRef)||void 0===N?void 0:N.current)?window.getComputedStyle(ai.showAboveRef.current).color:void 0})}))})),i(r,n({disableGutters:!0,expanded:!Rn&&G,onChange:function(){Rn||(H(),L.current=E.id)},sx:{boxShadow:"none",border:Rn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Rn?"#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(d,n({expandIcon:Rn?null:e(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Rn?"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:mn&&e(a,n({title:kn,placement:"top"},{children:e(u,n({component:"div",sx:{fontSize:"12px",color:Rn?"#94A3B8":"#19213D",fontWeight:Rn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(oi=kn,oi?b(oi).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,i){return n.startsWith("**")&&n.endsWith("**")?e("strong",{children:n.slice(2,-2)},i):e(o.Fragment,{children:n},i)}):null)}))}))})),!Rn&&i(c,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Fn&&e(f,{content:Sn,overlayContent:_n,sxStyles:Q,highlights:di,maintainRelativeOrder:U,highlightBg:Xn,suppressHighlightBg:yn,deviationBadges:ri,collisionKey:xn}),(E.subsections||[]).map(function(n,i){return nn({section:n,keyPath:"".concat(P,"-").concat(i),depth:0,columnKey:D,parentNodeId:q,sectionOffset:En})})]}))]})),G&&(null==ai?void 0:ai.showBelow)&&e("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,i;return null===(i=null===(n=null==ai?void 0:ai.showBelowRef)||void 0===n?void 0:n.current)||void 0===i?void 0:i.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===D?{right:"0px"}:{left:"0px"})},{children:e(v,{color:(null===(T=null==ai?void 0:ai.showBelowRef)||void 0===T?void 0:T.current)?window.getComputedStyle(ai.showBelowRef.current).color:void 0})}))}))]}),"".concat(D,"-sec-").concat(P))};export{S as default};
1
+ import{__assign as n}from"tslib";import{jsxs as e,jsx as i}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as r,AccordionSummary as d,Tooltip as a,Typography as c,AccordionDetails as u}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{useCompareContext as p}from"../CompareContext.js";import{hasValue as h,hasMeaningfulRedlineTags as m,stripRedlineTags as g,generateColorPalette as x,isMissingStr as I,safeStringify as y,DEVIATION_BADGE_SEPARATOR as b}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";var S=function(S){var _,k,F,R,B,C,M,A,O,W,T,j,E,N=S.section,P=S.idx,D=S.columnKey,K=S.colRef,L=S.mb,z=void 0===L?1:L,V=S.isExpanded,G=S.onToggle,H=S.navigation,X=S.parentNodeId,Y=void 0===X?"":X,q=p(),J=q.showOpenNodeRef,Q=q.resolvedMarkdownStyles,U=q.maintainRelativeOrder,Z=q.showDeviationBadges,$=void 0!==Z&&Z,nn=q.renderSubSectionAccordion,en=q.treeData,on=q.proposedSections,tn=q.existingSections,ln=q.deviationNumberRegistry,rn=q.getBadgeRef,dn=q.openSummaryPopup,an=q.getSectionCompareStyle,cn=q.connectedSections,un=q.openMoreFunctionsPopup;q.deviationNodeIdToView,q.deviationTargetParentId;var sn=q.isProposingFix,vn=q.proposingFixNodeId,fn=q.isRedlineFlow,pn=q.isSideBySide,hn=q.activeSideBySideSection,mn=q.scrollSyncLocked,gn=q.toggleScrollSyncLocked,xn=q.summaryPopupAnchorEl,In="".concat(pn?"1":"0","-").concat(String(null!=hn?hn:"")),yn=(null===(_=N.displayTitle)||void 0===_||_)&&h(N.title),bn=!!sn&&!!vn&&"left"===D&&N.id===vn,wn=m(N.content),Sn="boolean"==typeof fn?fn:wn,_n=wn,kn=Sn&&wn,Fn=kn?g(N.content):N.content,Rn=kn?N.content:void 0,Bn=(null===(k=N.displayContent)||void 0===k||k||wn)&&h(N.content),Cn=!yn&&!Bn,Mn=N.title;yn||(Mn=Bn?"No Title Found":"No Matching Section Found");var An=N.evaluationResult;if(!An&&"right"===D)if(U){var On=null===(F=N.refIndexes)||void 0===F?void 0:F[0],Wn=on.find(function(n){return n.selfIndex===On});An=null==Wn?void 0:Wn.evaluationResult}else An=null===(R=on[P])||void 0===R?void 0:R.evaluationResult;var Tn=null===(B=null==en?void 0:en.input_index_map)||void 0===B?void 0:B[0],jn=null===(C=null==en?void 0:en.input_index_map)||void 0===C?void 0:C[1],En="left"===D?jn:Tn,Nn=function(n,e){return n.find(function(n){return(null==n?void 0:n.id)&&e&&n.id===e})},Pn="left"===D?N:on[P],Dn="right"===D?N:tn[P],Kn=o.useMemo(function(){if(!U)return 0;var n=1/0,e=function(i,o,t,l){var r;if(i){var d=i.id;if(l&&"right"===D){var a=on.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(i.selfIndex)});a.length>0&&(d=a[0].id)}var c=i.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),u=(null===(r=i.evaluationResult)||void 0===r?void 0:r.deviations)||{};Object.keys(u).forEach(function(e){var i="".concat(d).concat(b).concat(e),o=null==ln?void 0:ln[i];null!=o&&o<n&&(n=o);var t="".concat(c).concat(b).concat(e),l=null==ln?void 0:ln[t];null!=l&&l<n&&(n=l)});for(var s=i.subsections||[],v=(null==o?void 0:o.subsections)||[],f=(null==t?void 0:t.subsections)||[],p=Math.max(s.length,v.length,f.length),h=0;h<p;h++)e(s[h],v[h],f[h],!1)}};return e(N,Pn,Dn,!0),n!==1/0?n-1:0},[N,Pn,Dn,D,ln,U,on]);if(U)if("left"===D){var Ln=null===(M=N.refIndexes)||void 0===M?void 0:M[0],zn=tn.findIndex(function(n){return n.selfIndex===Ln});Dn=-1!==zn?tn[zn]:Nn(tn,N.id)}else{var Vn=null===(A=N.refIndexes)||void 0===A?void 0:A[0],Gn=on.findIndex(function(n){return n.selfIndex===Vn});Pn=-1!==Gn?on[Gn]:Nn(on,N.id)}var Hn="left"===D?!Dn:!Pn,Xn=An||(null==Pn?void 0:Pn.evaluationResult)||(null==Dn?void 0:Dn.evaluationResult),Yn=null!==(T=null===(W=null===(O=null==Xn?void 0:Xn.evaluation_outputs)||void 0===O?void 0:O.metadata)||void 0===W?void 0:W.label_color)&&void 0!==T?T:w,qn=x(Yn).highlightBg,Jn=(null==Xn?void 0:Xn.deviations)||{},Qn=P+1,Un=N.id;if(U){var Zn=1,$n=new Map;if(on.forEach(function(n){!n.title&&!n.content||n.id&&$n.set(n.id,Zn++)}),"left"===D)Qn=$n.get(N.id)||P+1;else{var ne=on.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(N.selfIndex)});if(ne.length>0)Qn=$n.get(ne[0].id)||P+1,Un=ne[0].id;else for(var ee=Zn,ie=function(n){if(!n.title&&!n.content)return"continue";var e=on.some(function(e){var i;return null===(i=e.refIndexes)||void 0===i?void 0:i.includes(n.selfIndex)});if(!e){if(n.id===N.id)return Qn=ee,"break";ee++}},oe=0,te=tn;oe<te.length;oe++){if("break"===ie(te[oe]))break}}}var le=Object.entries(Jn).map(function(n){var e=n[0],i=n[1],o="".concat(Un).concat(b).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:ln[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});le.sort(function(n,e){return n.currentIndex-e.currentIndex});var re,de=le.map(function(e){var i,o,t,l,r,d,a=e.deviationKey,c=e.deviationMap,u=e.refId,s=e.currentIndex;U&&void 0!==Kn&&(s-=Kn);var v=c[Y],f=I(v);if(f)v="";else if(!v)return null;var p=P,h=P;if(U)if("left"===D){var m=null===(i=N.refIndexes)||void 0===i?void 0:i[0],g=tn.findIndex(function(n){return n.selfIndex===m});if(-1!==g)h=g;else{var y=tn.findIndex(function(n){return n.id===N.id});h=-1!==y?y:P}}else{var w=null===(o=N.refIndexes)||void 0===o?void 0:o[0],S=on.findIndex(function(n){return n.selfIndex===w});if(-1!==S)p=S;else{var _=on.findIndex(function(n){return n.id===N.id});p=-1!==_?_:P}}var k="".concat(Un).concat(b).concat(a).concat(b).concat(p).concat(b).concat(h),F=c[En],R=Hn||I(F),B="".concat(Qn,".").concat(s),C=P;if("right"===D&&U){var M=null===(t=N.refIndexes)||void 0===t?void 0:t[0],A=on.findIndex(function(n){return n.selfIndex===M});if(-1!==A)C=A;else{_=on.findIndex(function(n){return n.id===N.id});-1!==_&&(C=_)}}var O=an?an(C):null,W=(null==c?void 0:c.evaluation_outputs)||(null==Xn?void 0:Xn.evaluation_outputs),T=null!==(l=null==W?void 0:W.output_value)&&void 0!==l?l:null,j=null!==(d=null===(r=null==W?void 0:W.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:Yn,E=x(j),K=O?n(n({},O),{badgeBg:E.badgeBg,badgeBorder:E.badgeBorder,badgeText:E.badgeText}):n({},E),L=(null==c?void 0:c.deviation_summary)?{deviation_summary:c.deviation_summary,deviation_title:(null==c?void 0:c.deviation_title)||(null==Xn?void 0:Xn.deviation_title),deviation_impact:(null==c?void 0:c.deviation_impact)||(null==Xn?void 0:Xn.deviation_impact),deviation_explanation:(null==c?void 0:c.deviation_explanation)||(null==Xn?void 0:Xn.deviation_explanation),evaluation_outputs:W,cognitive_decisioning:(null==c?void 0:c.cognitive_decisioning)||(null==Xn?void 0:Xn.cognitive_decisioning)}:null,z=0,V=Fn||"";if(v&&V){var G=V.split(/\n{2,}/),H=G.findIndex(function(n){return n.includes(v)});if(-1!==H){var X=Object.entries(Jn).filter(function(n){n[0];var e=n[1][Y];return e&&G[H].includes(e)}).sort(function(n,e){return G[H].indexOf(n[1][Y])-G[H].indexOf(e[1][Y])}),q=X.filter(function(n){n[0];var e=n[1][Y];return e&&(e.includes(v)||v.includes(e))});q.length>1&&(z=Math.max(0,q.findIndex(function(n){return n[0]===a})))}}var J=rn(D,u);return{id:u,actionId:k,label:B,highlight:v,side:D,style:K,stackIndex:z,score:T,isConnected:null==cn?void 0:cn.has(k),showScrollLockToggle:(null==cn?void 0:cn.has(k))||pn&&hn===k||!!xn&&xn===J.current,scrollSyncLocked:mn,toggleScrollSyncLocked:gn,isOrphan:R,isMissingClause:f,badgeRef:J,onClick:function(n){n.stopPropagation(),un&&un(n,Pn||{id:"orphan-left",title:"",content:""},R,Dn||{id:"orphan-right",title:"",content:""},k,K)},onSummaryClick:function(n){n.stopPropagation(),dn(n,k,R,L)}}}).filter(Boolean),ae=$||!Sn&&bn,ce=ae?de:[],ue=ae?ce.map(function(n){return n.highlight}).filter(Boolean):[],se=N.id&&D===(null==H?void 0:H.columnKey)?H:null,ve=o.useRef(!1);return t(function(){V||(ve.current=!1)},[V]),e(l,n({ref:K,sx:{mb:z,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[V&&(null==se?void 0:se.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==se?void 0:se.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===D?{right:"0px"}:{left:"0px"})},{children:i(s,{color:(null===(j=null==se?void 0:se.showAboveRef)||void 0===j?void 0:j.current)?window.getComputedStyle(se.showAboveRef.current).color:void 0})}))})),e(r,n({disableGutters:!0,expanded:!Cn&&V,onChange:function(){Cn||(G(),J.current=N.id)},sx:{boxShadow:"none",border:Cn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Cn?"#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:[i(d,n({expandIcon:Cn?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Cn?"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:yn&&i(a,n({title:Mn,placement:"top"},{children:i(c,n({component:"div",sx:{fontSize:"12px",color:Cn?"#94A3B8":"#19213D",fontWeight:Cn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(re=Mn,re?y(re).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,e){return n.startsWith("**")&&n.endsWith("**")?i("strong",{children:n.slice(2,-2)},e):i(o.Fragment,{children:n},e)}):null)}))}))})),!Cn&&e(u,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Bn&&i(f,{content:Fn,overlayContent:Rn,sxStyles:Q,highlights:ue,maintainRelativeOrder:U,highlightBg:qn,suppressHighlightBg:_n,deviationBadges:ce,collisionKey:In}),(N.subsections||[]).map(function(n,e){return nn({section:n,keyPath:"".concat(P,"-").concat(e),depth:0,columnKey:D,parentNodeId:Y,sectionOffset:Kn})})]}))]})),V&&(null==se?void 0:se.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==se?void 0:se.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===D?{right:"0px"}:{left:"0px"})},{children:i(v,{color:(null===(E=null==se?void 0:se.showBelowRef)||void 0===E?void 0:E.current)?window.getComputedStyle(se.showBelowRef.current).color:void 0})}))}))]}),"".concat(D,"-sec-").concat(P))};export{S as default};
2
2
  //# sourceMappingURL=SectionAccordion.js.map