@viswa-test/test-citation 0.0.96 → 0.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),g=require("./components/ThreeDotsLoader.js"),f=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),_=require("./hooks/useDeviationNavigation.js"),m=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),S=require("./components/CognitiveSummaryPopup.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(b){var A,E,I,T,B,D,C,O,w,N,j,P,F,k,M,V,L,G,H,q,z,W,Y,K,U,X,J=b.componentHeaderText,$=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Q=b.treeData,Z=b.comparisonConfig,ee=b.leftColumnTitleText,ne=b.rightColumnTitleText,te=b.markdownStyles,ie=b.displayConfig,oe=void 0===ie?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:ie,le=b.popupConfig,re=b.deviationData,ue=void 0===re?{}:re,ce=b.deviationNodeIdToView,ae=b.resetDeviationNodeId,se=t.useState(oe.maintainRelativeOrder),de=se[0],ve=se[1],ge=!!de||!!(null==oe?void 0:oe.showDeviationBadges),fe=t.useState(!1),pe=fe[0],he=fe[1],xe=t.useState(!1),_e=xe[0],me=xe[1],Re=t.useState(null),ye=Re[0],Se=Re[1],be=t.useState(!1),Ae=be[0],Ee=be[1],Ie=t.useState(null===(E=null!==(A=null==Q?void 0:Q.newEvaluationResult)&&void 0!==A?A:null==oe?void 0:oe.enableDeviationSchemaBackwardCompatibility)||void 0===E||E)[0],Te=t.useState(!1),Be=Te[0],De=Te[1],Ce=t.useState(!1),Oe=Ce[0],we=Ce[1],Ne=t.useState(null),je=Ne[0],Pe=Ne[1],Fe=t.useRef(!1),ke=t.useState(new Set),Me=ke[0],Ve=ke[1],Le=t.useState([]),Ge=Le[0],He=Le[1],qe=t.useRef(null),ze=t.useRef(!1),We=t.useRef(null),Ye=t.useRef({}),Ke=t.useRef([]),Ue=t.useRef(!1),Xe=t.useRef(!1),Je=t.useRef(null),$e=t.useRef(function(){}),Qe=t.useMemo(function(){return(null==Q?void 0:Q.cognitive_decisioning)||{}},[Q]),Ze=t.useState({width:0,height:0}),en=Ze[0],nn=Ze[1],tn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),te)},[te]),on=t.useRef(null),ln=t.useRef(null),rn=t.useRef(null),un=t.useRef(null),cn=t.useRef(null),an=t.useRef(null),sn=t.useRef(null),dn=t.useRef(null),vn=t.useRef(!1),gn=t.useRef(null),fn=t.useRef(null),pn=p.useComparePopups(on),hn=pn.cognitivePopup,xn=pn.setCognitivePopup,_n=pn.moreFunctions,mn=pn.setMoreFunctions,Rn=pn.position,yn=pn.setPosition,Sn=pn.activeBadgeId,bn=pn.summaryPopup,An=pn.setSummaryPopup,En=pn.closeSummaryPopup,In=pn.setActiveBadgeId,Tn=pn.popupRef,Bn=pn.closeCognitivePopup,Dn=pn.closeMoreFunctionsPopup,Cn=t.useMemo(function(){var e,n,t,i,o,l,r;return{fields:null!==(e=null==Z?void 0:Z.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==Z?void 0:Z.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==Z?void 0:Z.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(r=null===(l=null==Z?void 0:Z.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[Z]),On=t.useState(null),wn=On[0];On[1];var Nn=null===(B=null===(I=null==Q?void 0:Q.documents)||void 0===I?void 0:I[null===(T=null==Q?void 0:Q.input_index_map)||void 0===T?void 0:T[0]])||void 0===B?void 0:B.title,jn=null===(O=null===(D=null==Q?void 0:Q.documents)||void 0===D?void 0:D[null===(C=null==Q?void 0:Q.input_index_map)||void 0===C?void 0:C[1]])||void 0===O?void 0:O.title,Pn=u.safeStringify(ee||Nn||"Uploaded Contract"),Fn=u.safeStringify(ne||jn||"Reference Template"),kn=f.useCognitiveTreeData(Q,de,ue,Cn,Ie),Mn=kn.activeProposed,Vn=kn.existingRule,Ln=kn.proposedSections,Gn=kn.existingSections,Hn=kn.visibleFields,qn=kn.parentDeviationRecord,zn=kn.deviationNumberRegistry,Wn=kn.parseError;t.useEffect(function(){Wn&&Se("Failed to load comparison: ".concat(Wn))},[Wn]);var Yn=Ln.length>0||Gn.length>0,Kn=h.useSectionRefs(Hn.map(function(e){return e.key}),Math.max(Ln.length,Gn.length)),Un=Kn.leftRefs,Xn=Kn.rightRefs,Jn=Kn.sectionLeftRefs,$n=Kn.sectionRightRefs,Qn=Kn.lhsBadgeRefs,Zn=Kn.rhsBadgeRefs,et=Kn.sectionRightRowRefs,nt=Kn.subSectionLeftRefs,tt=Kn.subSectionRightRefs,it=Kn.sectionRowRefs,ot=Kn.getSectionRowRef,lt=Kn.getSubSectionRef,rt=Kn.getBadgeRef,ut=Vn.analysis,ct=u.safeStringify(null===(N=null===(w=null==ut?void 0:ut.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===N?void 0:N.overall_summary),at=!!ct.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),st=null!==(j=null==Q?void 0:Q.base_root_id)&&void 0!==j?j:"-1";null==Q||Q[st];var dt=Ie?null!==(Y=null!==(q=ue&&(null===(H=null==ue?void 0:ue[st])||void 0===H?void 0:H.evaluation_result))&&void 0!==q?q:null===(W=null===(z=null==Q?void 0:Q.nodes)||void 0===z?void 0:z[st])||void 0===W?void 0:W.evaluation_result)&&void 0!==Y?Y:null:null!==(G=null!==(k=ue&&(null===(F=null===(P=null==ue?void 0:ue[st])||void 0===P?void 0:P.evaluation_result)||void 0===F?void 0:F[0]))&&void 0!==k?k:null===(L=null===(V=null===(M=null==Q?void 0:Q.nodes)||void 0===M?void 0:M[st])||void 0===V?void 0:V.evaluation_result)||void 0===L?void 0:L[0])&&void 0!==G?G:null,vt=u.extractDeviationScore(dt),gt=u.generateColorPalette(null!==(X=null===(U=null===(K=null==dt?void 0:dt.evaluation_outputs)||void 0===K?void 0:K.metadata)||void 0===U?void 0:U.label_color)&&void 0!==X?X:""),ft=t.useCallback(function(){var e,n,t,i,o,l;Ee(!1),Xe.current=!1;var r=Je.current,c=Tt.current;if(null!==r)if("string"==typeof r&&r.includes(u.DEVIATION_BADGE_SEPARATOR)){var a=r.split(u.DEVIATION_BADGE_SEPARATOR);(s=(null===(e=nt.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=Jn.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=Jn.current[r])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}if(null!==c)if("string"==typeof c&&c.includes(u.DEVIATION_BADGE_SEPARATOR)){a=c.split(u.DEVIATION_BADGE_SEPARATOR);(d=(null===(i=tt.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=$n.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(l=$n.current[c])||void 0===l?void 0:l.current)&&(d.style.paddingTop="0px")}Pe(null),Je.current=null,Tt.current=null,De(!1),me(!1),un.current&&(un.current.style.height="0px"),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px")},[]),pt=x.useAccordionState({maintainRelativeOrder:!!de,proposedSections:Ln,existingSections:Gn,activeSideBySideSection:je,connectedSections:Me,resetSideBySide:ft,setConnectedSections:Ve,setConnectedLines:He,cachedConnectedPositions:Ke,svgContainerRef:qe,isAnimatingRef:ze,animationTimerRef:We,calculateLinesRef:$e,sectionLeftRefs:Jn,sectionRightRefs:$n,subSectionLeftRefs:nt,subSectionRightRefs:tt}),ht=pt.expandedSections,xt=pt.expandedSubSections,_t=pt.setExpandedSubSections,mt=pt.toggleSection,Rt=t.useCallback(function(n,t,i,o,l,r,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",g=(v?Qe[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},f=null!==(s=null===(a=it.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==oe?void 0:oe.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:g,anchorEl:n,sectionAnchorEl:f,badgeStyle:r||null,sectionIdx:o,docData:{documents:null==Q?void 0:Q.documents,input_index_map:null==Q?void 0:Q.input_index_map},deviationData:function(){var n,l,r=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,c=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var l=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(l&&o[l])return o[l]}return null}(n);return t?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return c(r);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return r;var s=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(n=null==s?void 0:s.deviation_entries)||void 0===n?void 0:n[a])||(null===(l=null==s?void 0:s.deviations)||void 0===l?void 0:l[a])||null;return d?e.__assign(e.__assign(e.__assign({},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)}):c(r)}(),isOrphan:!!l}},[Qe,Q]),yt=t.useCallback(function(e){Dn(),yn(null),xn(e)},[Dn]),St=function(e,n,t,i,o,l){var r;if(e.stopPropagation(),_n.open&&_n.sectionIdx===o)Dn();else{var c=e.currentTarget,a="left";(null===(r=rn.current)||void 0===r?void 0:r.contains(c))&&(a="right");Xe.current&&ft(),Ve(new Set),He([]),Ke.current=[],Bn(),bn.open?Jt():En(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=o.split(u.DEVIATION_BADGE_SEPARATOR),r="".concat(l[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l[1]);return"right"===a?null===(e=Zn.current[r])||void 0===e?void 0:e.current:null===(n=Qn.current[r])||void 0===n?void 0:n.current}return"right"===a?null===(t=Zn.current[o])||void 0===t?void 0:t.current:null===(i=Qn.current[o])||void 0===i?void 0:i.current}()||c;mn(Rt(e,n,i,o,t,l))})}},bt=t.useCallback(function(){null!==_n.sectionIdx&&_n.anchorEl?yt(e.__assign(e.__assign({},_n),{open:!0})):Dn()},[_n,Dn,yt]),At=t.useCallback(function(){var e=_n.sectionIdx,n=_n.isOrphan;Dn(),En(),null!==e&&(n?Se("No counterpart exists to connect to."):(Xe.current&&ft(),He([]),Ke.current=[],Ve(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){$e.current&&$e.current()},50)))},[_n.sectionIdx,_n.isOrphan,Dn,En,ft]),Et=t.useRef(null),It=t.useRef(null),Tt=t.useRef(null),Bt=t.useRef(null),Dt=t.useRef(null),Ct=t.useRef(null),Ot=t.useState([]),wt=Ot[0],Nt=Ot[1];t.useRef(null);var jt=t.useState(null),Pt=jt[0],Ft=jt[1];t.useEffect(function(){if(wn){var e=Cn.fields.find(function(e){return e.analysisKey===wn||e.key===wn});if(e){var n=Un.current[e.key]||Xn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[wn,Cn.fields]);var kt=t.useCallback(function(e){var n,t,i,o,l,r,u,c,a,s=null===(n=null==ut?void 0:ut.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(l=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===l?void 0:l.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var g=d.mappings[0]||{};return{score:d.score,relation:g.relation||"",highlightsA:(null===(r=g.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(u=g.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[ut]),Mt=t.useCallback(function(n,t){var i,o,l,r,c,s,d;void 0===t&&(t="left");var v=null,g=null;if("left"===t)if(v=Ln[n],de&&v){var f=Gn.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});g=f.find(function(e){return e.evaluationResult})||f[0]}else g=Gn[n];else if(g=Gn[n],de&&g){var p=Ln.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(g.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=Ln[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,_=!(!(null==v?void 0:v.cognitiveData)&&!(null==g?void 0:g.cognitiveData));if(!h&&!x&&!_)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var m=null!==(o=null!==(i=null==v?void 0:v.evaluationResult)&&void 0!==i?i:null==g?void 0:g.evaluationResult)&&void 0!==o?o:null,R=null===(l=null==m?void 0:m.evaluation_outputs)||void 0===l?void 0:l.output_value,y=null!==(s=null===(c=null===(r=null==m?void 0:m.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===c?void 0:c.label_color)&&void 0!==s?s:a.DEFAULT_DEVIAION_COLOR;return null!=m?e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null!==(d=R)&&void 0!==d?d:""}):e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null})},[Ln,Gn,Qe,Cn,de]),Vt=t.useCallback(function(n){for(var t,i,o,l,r,c,s,d,v,g=n.split("-").map(Number),f=Ln[g[0]],p=Gn[g[0]],h=1;h<g.length;h++)(null==f?void 0:f.subsections)&&(f=f.subsections[g[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[g[h]]);if(!f&&!p)return null;var x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,_=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,m=u.safeStringify(null==f?void 0:f.id)||u.safeStringify(null==p?void 0:p.id)||"",R=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!x&&!_&&!R)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||m&&(null===(o=Qe[m])||void 0===o||o.relevance_score);var y=null!==(r=null!==(l=null==f?void 0:f.evaluationResult)&&void 0!==l?l:null==p?void 0:p.evaluationResult)&&void 0!==r?r:null,S=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.output_value,b=null!==(v=null===(d=null===(s=null==y?void 0:y.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===d?void 0:d.label_color)&&void 0!==v?v:a.DEFAULT_DEVIAION_COLOR;return null!=y?e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null!=S?S:""}):e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null})},[Ln,Gn,Qe,Cn]),Lt=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,g,f,p,h,x,_,m,R,y,S;if(!vn.current&&!ze.current){vn.current=!0;try{if(!Et.current)return;var b=function(e){var n=e.split("-"),t=n[0];if(!ht[t]&&!1===de)return!1;if(de&&!ht["left-".concat(t)]&&!ht["right-".concat(t)]&&!ht[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!xt[i])return!1;return!0},A=Et.current.getBoundingClientRect();nn({width:A.width,height:A.height});var E=[];if(Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,l=null===(t=Xn.current[i])||void 0===t?void 0:t.current;o&&l&&(o.style.height="auto",l.style.height="auto",o.style.minHeight="0px",l.style.minHeight="0px")}),!ze.current){for(var I=0;I<Math.max(Ln.length,Gn.length);I++){var T=null===(e=Jn.current[I])||void 0===e?void 0:e.current,B=null===(n=$n.current[I])||void 0===n?void 0:n.current;T&&(T.style.height="auto",T.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}de||Object.keys(nt.current).forEach(function(e){var n,t;if(b(e)){var i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.current[e])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var D={};Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,l=null===(t=Xn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),u=l.getBoundingClientRect();D[i]=Math.max(r.height,u.height)}});var C={left:{},right:{}},O={};if(!ze.current)if(de){if(Ae&&null!==je)if("number"==typeof je){var w=je,N=Ln[w],j=null===(o=Jn.current[w])||void 0===o?void 0:o.current;j&&N&&(N.refIndexes||[]).forEach(function(e){var n,t=Gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=$n.current[t])||void 0===n?void 0:n.current;if(i&&(ht["left-".concat(w)]||ht["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);C.left[w]=Math.max(C.left[w]||0,o),C.right[t]=Math.max(C.right[t]||0,o)}})}else{var P=je.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(P){T=null===(l=nt.current[P])||void 0===l?void 0:l.current,B=null===(r=tt.current[P])||void 0===r?void 0:r.current;if(T&&B){F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);O[P]=Math.max(O[P]||0,F)}}}}else{Object.keys(nt.current).forEach(function(e){var n,t;if(b(e)){var i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var l=i.getBoundingClientRect(),r=o.getBoundingClientRect(),u=Math.max(l.height,r.height);O[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(I=0;I<Math.min(Ln.length,Gn.length);I++){var T=null===(t=Jn.current[I])||void 0===t?void 0:t.current,B=null===(i=$n.current[I])||void 0===i?void 0:i.current;if(T&&B){var F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);C.left[I]=F,C.right[I]=F}}}if(Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,l=null===(t=Xn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=D[i];o.style.minHeight="".concat(r,"px"),l.style.minHeight="".concat(r,"px")}}),ze.current||(Object.entries(C.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Jn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(C.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=$n.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),de||Object.keys(O).forEach(function(e){var n,t,i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.current[e])||void 0===t?void 0:t.current;if(i&&o&&O[e]){var l=O[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),de)Ln.forEach(function(e,n){var t;(null===(t=Jn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,l,r,u,c,a,s,d,v=Gn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var g=null===(t=Qn.current[n])||void 0===t?void 0:t.current,f=null===(i=Zn.current[v])||void 0===i?void 0:i.current;if(g&&f){var p=g.getBoundingClientRect(),h=f.getBoundingClientRect(),x=p.right-A.left,_=h.left-A.left,m=p.top+p.height/2-A.top,R=h.top+h.height/2-A.top;if(Ae&&je===n){var y=null!==(l=null===(o=dn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,S=null!==(u=null===(r=rn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==u?u:0,b=y+(null!==(a=null===(c=dn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=S+(null!==(d=null===(s=rn.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),T=p.top+p.height/2,B=h.top+h.height/2,D=function(e,n,t){return Math.max(n,Math.min(t,e))};m=D(T,y,b)-A.top,R=D(B,S,I)-A.top}var C=Mt(n);C&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:R,style:C,sectionIdx:n,targetRightIdx:v})}}})});else{for(I=0;I<Math.min(Ln.length,Gn.length);I++){var k=null===(c=Jn.current[I])||void 0===c?void 0:c.current,M=null===(a=$n.current[I])||void 0===a?void 0:a.current;if(k&&M){var V=k.getBoundingClientRect(),L=M.getBoundingClientRect(),G=Math.max(V.top,L.top)+18-A.top,H=(null===(s=Gn[I])||void 0===s?void 0:s.id)||"sec-".concat(I);(J=Mt(I))&&E.push({id:H,x1:V.right-A.left,y1:G,x2:L.left-A.left,y2:G,style:J,sectionIdx:I,hasCognitive:!!((null===(d=Ln[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=Gn[I])||void 0===v?void 0:v.cognitiveData)||H&&Qe[H]),isSubSection:!1})}}Object.keys(nt.current).forEach(function(e){var n,t,i,o,l,r;if(b(e)){var c=null===(n=nt.current[e])||void 0===n?void 0:n.current,a=null===(t=tt.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Ln[s[0]],v=Gn[s[0]],g=1;g<s.length;g++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[g]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[g]]);var f=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(l=v.displayTitle)||void 0===l||l)&&u.hasValue(v.title)),x=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&u.hasValue(v.content));if(f&&p||h&&x){var _=c.getBoundingClientRect(),m=a.getBoundingClientRect(),R=Math.max(_.top,m.top)+16-A.top,y=Vt(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:_.right-A.left,y1:R,x2:m.left-A.left,y2:R,style:y,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(Ae&&"string"==typeof je&&je.includes(u.DEVIATION_BADGE_SEPARATOR)){var q=je.split(u.DEVIATION_BADGE_SEPARATOR),z=q[0],W=q[1],Y=q[2],K=(q[3],"".concat(z).concat(u.DEVIATION_BADGE_SEPARATOR).concat(W)),U=null===(g=Qn.current[K])||void 0===g?void 0:g.current,X=null===(f=Zn.current[K])||void 0===f?void 0:f.current;if(U&&X){var J,$=U.getBoundingClientRect(),Q=X.getBoundingClientRect(),Z=$.right-A.left,ee=Q.left-A.left,ne=$.top+$.height/2-A.top,te=Q.top+Q.height/2-A.top;if(de){var ie=null!==(h=null===(p=dn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,oe=null!==(_=null===(x=rn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,le=ie+(null!==(R=null===(m=dn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),re=oe+(null!==(S=null===(y=rn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),ue=function(e,n,t){return Math.max(n,Math.min(t,e))};ne=ue($.top+$.height/2,ie,le)-A.top,te=ue(Q.top+Q.height/2,oe,re)-A.top}(J=Vt(Y))&&E.push({id:"line-subsec-".concat(K),x1:Z,y1:ne,x2:ee,y2:te,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:je})}}if(Nt(E),Dt.current&&Ct.current){var ce=Dt.current.getBoundingClientRect(),ae=Ct.current.getBoundingClientRect(),se=(ce.top+ce.height/2-A.top+ae.top+ae.height/2-A.top)/2;Ft({x1:ce.right-A.left,x2:ae.left-A.left,y:se})}else Ft(null);if(Me.size>0){var ve=[],ge=dn.current,fe=rn.current;if(ge&&fe){var pe=[],he=ge.getBoundingClientRect().top,xe=fe.getBoundingClientRect().top,_e=he+ge.clientHeight,me=xe+fe.clientHeight,Re=ge.scrollTop,ye=fe.scrollTop,Se=A.top,be=function(e,n,t){return Math.max(n,Math.min(t,e))};Me.forEach(function(e){var n,t,i,o,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=e.split(u.DEVIATION_BADGE_SEPARATOR),c=r[0],a=r[1],s=r[2],d=(r[3],"".concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(a)),v=null===(n=Qn.current[d])||void 0===n?void 0:n.current,g=null===(t=Zn.current[d])||void 0===t?void 0:t.current;if(!v||!g)return;var f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=Vt(s),x=(j=f.right-A.left)+.5*((P=p.left-A.left-0)-j),_=f.top+f.height/2,m=p.top+p.height/2,R=_-he+Re,y=m-xe+ye,S="conn-subsec-".concat(d);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var b=be(_,he,_e),E=be(m,xe,me),I=b-Se,T=E-Se,B=m>=xe-4&&m<=me+4,D="";D=(F=_>=he-4&&_<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:D,style:h,leftIdx:e,rhsArrayIdx:e})}else if(de){var C=e,O=Ln[C];if(!(null===(l=null==O?void 0:O.refIndexes)||void 0===l?void 0:l.length))return;O.refIndexes.forEach(function(e){var n,t,i=Gn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Qn.current[C])||void 0===n?void 0:n.current,l=null===(t=Zn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),c=l.getBoundingClientRect(),a=Mt(C),s=r.right-A.left,d=c.left-A.left-0,v=s+.5*(d-s),g=r.top+r.height/2,f=c.top+c.height/2,p=g-he+Re,h=f-xe+ye,x="conn-".concat(C,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:C,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=be(g,he,_e),m=be(f,xe,me),R=_-Se,y=m-Se,S=g>=he-4&&g<=_e+4,b=f>=xe-4&&f<=me+4,E="";E=S&&b?u.getBentArrowPath(s,R,d,y):S&&!b?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!S&&b?"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y," L ").concat(d,",").concat(y):"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y),ve.push({id:x,pathD:E,style:a,leftIdx:C,rhsArrayIdx:i})}}})}else{var w=e,N=w;v=null===(i=Qn.current[w])||void 0===i?void 0:i.current,g=null===(o=Zn.current[N])||void 0===o?void 0:o.current;if(!v||!g)return;var j,P;f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=Mt(w),x=(j=f.right-A.left)+.5*((P=p.left-A.left-0)-j),_=f.top+f.height/2,m=p.top+p.height/2,R=_-he+Re,y=m-xe+ye,S="conn-".concat(w,"-").concat(N);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Se,leftIdx:w,rhsArrayIdx:N,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var F;b=be(_,he,_e),E=be(m,xe,me),I=b-Se,T=E-Se,B=m>=xe-4&&m<=me+4,D="";D=(F=_>=he-4&&_<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:D,style:h,leftIdx:w,rhsArrayIdx:N})}}),Ke.current=pe}He(ve)}else He([]),Ke.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{vn.current=!1}}},[Hn,Ln,Gn,Qe,Cn,kt,Mt,de,Ae,je,Me,ht,xt]),Gt=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,g,f,p=Ke.current;if(p.length&&!ze.current){var h=null!==(n=null===(e=dn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=rn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(l=null===(o=dn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,m=null!==(c=null===(r=rn.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=dn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=rn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,b=y+m,A=null!==(f=null===(g=Et.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==f?f:0,E=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+R,t=e.rhsScrollY-x+y,i=Ye.current[e.styleId+"-stroke"],o=Ye.current[e.styleId+"-bg"];if(i||o){var l,r=E(n,R,S),c=E(t,y,b),a=r-A,s=c-A,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=b+4,g=e.x1+.5*(e.x2-e.x1);l=d&&v?u.getBentArrowPath(e.x1,a,e.x2,s):d&&!v?"M ".concat(e.x1,",").concat(a," L ").concat(g,",").concat(a," L ").concat(g,",").concat(s):!d&&v?"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]);t.useEffect(function(){$e.current=Lt},[Lt]);var Ht=t.useRef(null),qt=t.useRef(null),zt=t.useCallback(function(){Ke.current.length>0&&!ze.current||(null!==Ht.current&&clearTimeout(Ht.current),Ht.current=setTimeout(function(){$e.current(),Ht.current=null},50))},[]),Wt=t.useCallback(function(){we(!0),De(!1),null!==qt.current&&clearTimeout(qt.current),null!==Ht.current&&(clearTimeout(Ht.current),Ht.current=null),qt.current=setTimeout(function(){var e,n,t,i,o,l,r,c,a,s;if(Ke.current=[],Xe.current&&null!==Je.current&&null!==Tt.current){var d=Je.current,v=Tt.current,g=null,f=null,p=null,h=null;if("string"==typeof d&&d.includes(u.DEVIATION_BADGE_SEPARATOR)){var x=d.split(u.DEVIATION_BADGE_SEPARATOR),_="".concat(x[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(x[1]);g=(null===(e=Qn.current[_])||void 0===e?void 0:e.current)||null,f=(null===(n=Zn.current[_])||void 0===n?void 0:n.current)||null,p=(null===(t=nt.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=Jn.current[Number(x[2])])||void 0===i?void 0:i.current)||null,h=(null===(o=tt.current[x[3]])||void 0===o?void 0:o.current)||(null===(l=$n.current[Number(x[3])])||void 0===l?void 0:l.current)||null}else g=(null===(r=it.current[d])||void 0===r?void 0:r.current)||null,p=(null===(c=Jn.current[d])||void 0===c?void 0:c.current)||null,f=(null===(a=et.current[v])||void 0===a?void 0:a.current)||null,h=(null===(s=$n.current[v])||void 0===s?void 0:s.current)||null;if(g&&f&&p&&h){if(p.style.paddingTop="0px",h.style.paddingTop="0px",!de){var m=g.getBoundingClientRect(),R=f.getBoundingClientRect(),y=m.top-R.top;y>0?h.style.paddingTop="".concat(y,"px"):y<0&&(p.style.paddingTop="".concat(Math.abs(y),"px"))}var S=dn.current,b=rn.current;if(S&&b){var A=g.getBoundingClientRect().top-S.getBoundingClientRect().top+S.scrollTop,E=f.getBoundingClientRect().top-b.getBoundingClientRect().top+b.scrollTop-(A-S.scrollTop);Math.abs(b.scrollTop-E)>1&&(b.scrollTop=E)}}}$e.current(),Xe.current&&De(!0),we(!1),qt.current=null},150)},[de,Ln,Gn]),Yt=t.useCallback(function(e){var n,t,i,o,l,r,c,a,s,d;if(null!==gn.current&&fn.current&&Math.abs(e.currentTarget.scrollTop-gn.current)<=2){var v=fn.current;gn.current=null,fn.current=null,v()}if(!Fe.current){if(de||zt(),Xe.current){var g=Je.current,f=Tt.current,p=dn.current,h=rn.current;if(null!==g&&null!==f&&p&&h){var x="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Qn.current["".concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=it.current[g])||void 0===t?void 0:t.current,_="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=Zn.current["".concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===i?void 0:i.current:null===(o=et.current[f])||void 0===o?void 0:o.current;if(x&&_&&Bt.current){var m=void 0,R=void 0;if("string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)){var y=g.split(u.DEVIATION_BADGE_SEPARATOR),S="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);m=null===(l=Qn.current[S])||void 0===l?void 0:l.current,R=null===(r=Zn.current[S])||void 0===r?void 0:r.current}else m=null===(c=Qn.current[g])||void 0===c?void 0:c.current,R=null===(a=Zn.current[f])||void 0===a?void 0:a.current;var b=null!==(d=null===(s=Et.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==d?d:0,A=p.getBoundingClientRect().top,E=A+p.clientHeight;h.getBoundingClientRect().top;h.clientHeight;if(m&&R){var I=m.getBoundingClientRect(),T=R.getBoundingClientRect(),B=I.top+I.height/2;T.top,T.height;var D=((O=B,w=A,N=E,Math.max(w,Math.min(N,O)))-b).toString();Bt.current.setAttribute("y1",D),Bt.current.setAttribute("y2",D);var C=B>=A-4&&B<=E+4;Bt.current.setAttribute("visibility",C?"visible":"hidden")}}}}var O,w,N;Ke.current.length>0&&!Ue.current&&(Ue.current=!0,requestAnimationFrame(function(){Gt(),Ue.current=!1}))}},[Gt,de,zt]);t.useEffect(function(){var e=setTimeout(zt,250);window.addEventListener("resize",Wt);var n=null,t=null;return on.current&&(n=new ResizeObserver(zt)).observe(on.current),Et.current&&(t=new ResizeObserver(zt)).observe(Et.current),function(){clearTimeout(e),null!==Ht.current&&clearTimeout(Ht.current),null!==qt.current&&clearTimeout(qt.current),window.removeEventListener("resize",Wt),null==n||n.disconnect(),null==t||t.disconnect()}},[Mn,Vn,ut,Hn,ht,xt,Ln,Gn,Cn,zt,Wt,Ae,je,Be,Me]),t.useEffect(function(){Xe.current=Ae},[Ae]),t.useEffect(function(){Je.current=je},[je]);var Kt=t.useCallback(function(e,n,t){var i,o,l=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,r=null==t?void 0:t.onReady,c=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";Dn(),null!=e&&(n?Se("No counterpart exists for this section."):Ae&&je===e?l?ft():null==r||r():(Ve(new Set([e])),He([]),Ke.current=[],me(!0),Fe.current=!0,Pe(e),Je.current=e,Ee(!0),Xe.current=!0,De(!1),un.current&&(un.current.style.height="0px"),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,l,a="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=null,d=null,v=null;if(a){var g=e.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(g[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g[1]);s=(null===(n=Qn.current[f])||void 0===n?void 0:n.current)||null,d=(null===(t=Zn.current[f])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=it.current[e])||void 0===i?void 0:i.current)||null,de){var p=Ln[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=Gn.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(l=et.current[_])||void 0===l?void 0:l.current)||null,v=_)}}else d=(null===(o=et.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Tt.current=v;var m=dn.current,R=rn.current,y=function(){!function(){var n,t,i,o,l,r,c,s,d,g,f,p,h=null,x=null,_=null,m=null;if(a){var R=e.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(R[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(R[1]);h=(null===(n=nt.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=Jn.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=tt.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=$n.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(l=Qn.current[y])||void 0===l?void 0:l.current)||h,m=(null===(r=Zn.current[y])||void 0===r?void 0:r.current)||x}else{var S=Number(e),b=null!==v?Number(v):S;h=(null===(c=Jn.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=$n.current[b])||void 0===s?void 0:s.current)||null,_=(null===(d=Qn.current[S])||void 0===d?void 0:d.current)||(null===(g=it.current[S])||void 0===g?void 0:g.current)||h,m=(null===(f=Zn.current[b])||void 0===f?void 0:f.current)||(null===(p=et.current[b])||void 0===p?void 0:p.current)||x}if(_&&m&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=_.getBoundingClientRect(),E=m.getBoundingClientRect(),I=A.top-E.top;I>0?x.style.paddingTop="".concat(I,"px"):I<0&&(h.style.paddingTop="".concat(Math.abs(I),"px"))}}(),De(!0),$e.current&&$e.current(),Fe.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),me(!1),null==r||r()};if(!s||!m)return Fe.current=!1,me(!1),void(null==r||r());if(d&&R){if(!de){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var b=on.current,A=(null==b?void 0:b.getBoundingClientRect().top)||0,E=b?b.scrollTop+S-A-150:0;return b?void u.smoothScrollTo(b,E,200,y):void y()}var I=s.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var D=T-(I-m.scrollTop);D<0&&un.current&&(un.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return cn.current&&(cn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,D,B,y)})}e=D}u.smoothScrollTo(R,e,B,y)})}else{var C=I-(T-R.scrollTop);C<0&&an.current&&(an.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=m.scrollHeight-m.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return sn.current&&(sn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(m,C,B,y)})}e=C}u.smoothScrollTo(m,e,B,y)})}}else y()})))},[je,Dn,Gn,Ae,de,Ln,ft]),Ut=t.useCallback(function(e,n,t,i){var o,l="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),r=e.currentTarget;Bn();var c="left";(null===(o=rn.current)||void 0===o?void 0:o.contains(r))&&(c="right");var a=function(){var e,t,i,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=n.split(u.DEVIATION_BADGE_SEPARATOR),r="".concat(l[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l[1]);return"right"===c?null===(e=Zn.current[r])||void 0===e?void 0:e.current:null===(t=Qn.current[r])||void 0===t?void 0:t.current}return"right"===c?null===(i=Zn.current[n])||void 0===i?void 0:i.current:null===(o=Qn.current[n])||void 0===o?void 0:o.current};if(t)return ft(),Ve(new Set),He([]),Ke.current=[],void(l&&requestAnimationFrame(function(){var e=a()||r;An({open:!0,anchorEl:e,summary:i})}));Kt(n,t,l?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||r;An({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[Kt,Bn,An,ft]),Xt=t.useCallback(function(){var e,n=_n.sectionIdx,t=_n.isOrphan;if(En(),null!=n){var i="left";_n.anchorEl&&(null===(e=rn.current)||void 0===e?void 0:e.contains(_n.anchorEl))&&(i="right"),Kt(n,t,{sourceSide:i})}},[Kt,_n.isOrphan,_n.sectionIdx,_n.anchorEl,En]),Jt=t.useCallback(function(){En(),ft(),Ve(new Set),He([]),Ke.current=[]},[En,ft]),$t=null!==_n.sectionIdx&&Me.has(_n.sectionIdx),Qt=_.useDeviationNavigation({proposedSections:Ln,existingSections:Gn,parentDeviationRecord:qn,expandedSections:ht,maintainRelativeOrder:!!de,scrollContainerRef:on,leftContainerRef:dn,lhsBadgeRefs:Qn,rhsBadgeRefs:Zn}),Zt=Qt.showDeviationNavigation,ei=Qt.showOpenNodeRef,ni=t.useMemo(function(){if(!ce)return null;var e=ce.split(":")[0];for(var n in qn){if((qn[n]||[]).some(function(n){return n.id===e}))return n}return null},[ce,qn]),ti=t.useRef(null),ii=t.useRef(null);t.useEffect(function(){if(ce&&ti.current!==ce){var n=ce.split(":"),t=n[0],i=n[1],o=null!=i?i:"0";ii.current!==ce&&(En(),Bn(),ft(),Ve(new Set),He([]),Ke.current=[],ii.current=ce);var l=!1,r=0,c=null,a=150,s=function(e,n){for(var t=function(e,i){if(!e)return null;if(e.id===n)return i;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var l=t(e.subsections[o],"".concat(i,"-").concat(o));if(l)return l}return null},i=0;i<e.length;i++){var o=t(e[i],String(i));if(o)return o}return null},d=function(){var n,i,v,g;if(!l){var f=null,p=null;for(var h in qn){var x=qn[h].find(function(e){return e.id===t});if(x){f=h,p=x;break}}if(p&&f){var _=Ln.findIndex(function(e){return e.id===f}),m=Gn.findIndex(function(e){return e.id===f}),R=-1===_&&-1!==m,y=s(Ln,p.id),S=s(Gn,p.id);if(y&&!S&&!R){var b=y.split("-"),A=Number(b[0]);if(de){var E=null===(i=null===(n=Ln[A])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],I=Gn.findIndex(function(e){return e.selfIndex===E});-1!==I&&(A=I)}S=e.__spreadArray([A],b.slice(1),!0).join("-")}if(y||S){var T=R||!y&&!!S,B=y?Number(y.split("-")[0]):_,D=S?Number(S.split("-")[0]):m;if(T){if(!(de?!!ht["right-".concat(D)]:!!ht[String(D)])&&D>=0)return mt(D,"right"),r+=1,void(c=setTimeout(d,450))}else if(!(de?!!ht["left-".concat(B)]:!!ht[String(B)])&&B>=0)return mt(B,"left"),r+=1,void(c=setTimeout(d,450));var C,O=y||"",w=S||"",N="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(o).concat(u.DEVIATION_BADGE_SEPARATOR).concat(O).concat(u.DEVIATION_BADGE_SEPARATOR).concat(w),j="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(o),P=null===(v=Qn.current[j])||void 0===v?void 0:v.current,F=null===(g=Zn.current[j])||void 0===g?void 0:g.current,k=T||!P&&!!F,M=k?F:P;if(C=de?k?rn.current:dn.current:on.current,M&&C){var V=M.getBoundingClientRect();if(0===V.height)return void((r+=1)<20&&(c=setTimeout(d,a)));var L=C.getBoundingClientRect(),G=V.top-L.top+C.scrollTop-L.height/2+V.height/2,H=function(){var n,t,i,r,u;if(!l){ti.current=ce;var c=window.getComputedStyle(M).color;P&&(P.style.transition="box-shadow 300ms ease-in-out",P.style.boxShadow="0 0 10px ".concat(c)),F&&(F.style.transition="box-shadow 300ms ease-in-out",F.style.boxShadow="0 0 10px ".concat(c)),setTimeout(function(){P&&(P.style.boxShadow=""),F&&(F.style.boxShadow="")},2e3);var a=(null===(t=null===(n=p.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[o])||p,s=(null===(i=p.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||p.evaluation_outputs;if(!(!!P&&!!F)){var d=k?(null===(r=Zn.current[j])||void 0===r?void 0:r.current)||F:(null===(u=Qn.current[j])||void 0===u?void 0:u.current)||P;return An({open:!0,anchorEl:d,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})}),void(null==ae||ae())}Kt(N,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=Qn.current[j])||void 0===n?void 0:n.current)||P;An({open:!0,anchorEl:t,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})})}})}};Math.abs(C.scrollTop-G)<=2?H():(gn.current=G,fn.current=H,C.scrollTo({top:G,behavior:"smooth"}),c&&clearTimeout(c),c=setTimeout(function(){if(fn.current){gn.current=null;var e=fn.current;fn.current=null,e()}},800))}else(r+=1)<20&&(c=setTimeout(d,a))}else(r+=1)<20&&(c=setTimeout(d,a))}else(r+=1)<20&&(c=setTimeout(d,a))}};return c=setTimeout(d,a),function(){l=!0,c&&clearTimeout(c)}}},[ce,qn,Ln,Gn,de,ht,mt,Kt,An]);var oi=function(e){var t=e.section,i=e.keyPath,o=e.depth,l=void 0===o?0:o,r=e.columnKey,u=void 0===r?"left":r,c=e.parentNodeId,a=void 0===c?"":c;return n.jsx(y.default,{section:t,keyPath:i,depth:l,columnKey:u,parentNodeId:a,expandedSubSections:xt,setExpandedSubSections:_t,maintainRelativeOrder:de||!1,proposedSections:Ln,existingSections:Gn,treeData:Q,deviationNumberRegistry:zn,connectedSections:Me,activeSideBySideSection:je,resolvedMarkdownStyles:tn,getSubSectionRef:lt,getSubSectionCompareStyle:Vt,getBadgeRef:rt,openMoreFunctionsPopup:St,openSummaryPopup:Ut,showDeviationBadges:ge,resetSideBySide:ft,setConnectedSections:Ve,setConnectedLines:He,cachedConnectedPositions:Ke})};return n.jsxs(i.Box,e.__assign({ref:ln,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},de?{}:{overflow:"visible"}),{position:"relative"})},{children:[pe&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),bn.open&&n.jsx(S.default,{open:bn.open,anchorEl:bn.anchorEl,containerEl:It.current,clipTopEl:Dt.current,scrollContainerEl:on.current,onClose:Jt,summary:bn.summary}),n.jsx(d.default,{open:_n.open,anchorEl:_n.anchorEl,sectionTitle:_n.sectionTitle,referenceSectionTitle:_n.refSectionTitle,onClose:Dn,onOpenCognitiveCompare:bt,onOpenSideBySide:Xt,onConnect:At,isConnected:$t,isOrphan:_n.isOrphan}),hn.open&&n.jsx(s.default,{open:hn.open,popupRef:Tn,position:Rn,popupConfig:le,onClose:function(){yn(null),xn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),In(null)},markdownStyles:te,sectionTitle:hn.sectionTitle,referenceSectionTitle:hn.refSectionTitle,cognitiveData:hn.cognitiveData,anchorEl:hn.anchorEl,sectionAnchorEl:hn.sectionAnchorEl,scrollContainerEl:on.current,badgeStyle:hn.badgeStyle,docData:hn.docData,deviationData:hn.deviationData,isLoading:hn.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ye,autoHideDuration:8e3,onClose:function(){return Se(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Se(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ye}))})),n.jsx(m.default,{componentHeaderText:$,displayConfig:oe,maintainRelativeOrder:de,onToggleView:function(e){he(!0),setTimeout(function(){ve(!e),ft(),En(),Ve(new Set),He([]),Ke.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){he(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:on,onScroll:Yt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:de?"hidden":"auto",borderTop:ct&&at?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},de?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Et,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},de?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:qe,style:{position:"absolute",top:0,left:0,width:en.width||"100%",height:en.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Oe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Pt&&n.jsx("g",{children:n.jsx("line",{x1:Pt.x1,y1:Pt.y,x2:Pt.x2,y2:Pt.y,stroke:gt.badgeBorder,strokeWidth:"1.5"})}),wt.map(function(t){var r,c,s,d,v,f,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?Ae&&je===t.subSectionKeyPath&&Be:Ae&&je===t.sectionIdx&&Be)return null;if(!de){var x=t.isSubSection?u.getBentArrowPath(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2),_=Ln[t.sectionIdx]||{title:"",content:""},m=Gn[t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",_,m),t.isSubSection&&t.subSectionKeyPath){var R=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],y=R[2]||t.subSectionKeyPath,S=R[3]||y,b=y.split("-").map(Number),A=S.split("-").map(Number),E=null,I=null;b.length>0&&(E=Ln[b[0]]),A.length>0&&(I=Gn[A[0]]);var T=(null==E?void 0:E.title)||"",B=(null==I?void 0:I.title)||"";console.log("Root Parent Titles:",T,B);for(var D=1;D<b.length;D++)(null==E?void 0:E.subsections)&&(E=E.subsections[b[D]]);for(D=1;D<A.length;D++)(null==I?void 0:I.subsections)&&(I=I.subsections[A[D]]);E&&(_=e.__assign(e.__assign({},E),{title:T||E.title})),console.log("Base Section for Subsection Badge:",_),I&&(m=e.__assign(e.__assign({},I),{title:B||I.title})),console.log("Ref Section for Subsection Badge:",m)}var C=!(null===(r=_.cognitiveData)||void 0===r?void 0:r.isMissingRationale)||Boolean(null===(s=null===(c=_.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===s?void 0:s.length),O=(null===(f=null===(v=null===(d=_.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.length)||!1,w=C||O;return n.jsxs("g",{children:[n.jsx("path",{d:x,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:p-100,y:h-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),w&&(hn.open&&Sn===t.id?Bn():(In(t.id),yt(Rt(e.currentTarget,_,m,t.sectionIdx,t.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:w?"pointer":"default"}},{children:[t.style.badgeText===a.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(g.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),w&&n.jsx(o.ChevronDown,{size:11,style:{transform:hn.open&&Sn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ge.map(function(t){var i,o=t.pathD,l=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",r="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),c="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:r,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),n.jsx("path",{ref:function(e){Ye.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Ye.current[c]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(r,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},de?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Dt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(i.Tooltip,e.__assign({title:Pn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Pn}))}))})),n.jsxs(i.Box,e.__assign({ref:dn,onScroll:Yt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},de?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:an,style:{width:"100%",height:"0px",flexShrink:0}}),Yn&&Ln.map(function(t,l){var r,c,a=!t.title&&!t.content;if(de&&a)return null;var s=t,d=Mt(l,"left"),v=de?!(null===(r=s.refIndexes)||void 0===r?void 0:r.length)||s.selfIndex<0:!Gn[l],f=de?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:l+1,p=Me.has(l),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:ot(l),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Jn.current[l],sx:e.__assign({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:l,columnKey:"left",colRef:ot("left-accordion-".concat(l)),mb:0,treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getSectionCompareStyle:Mt,getBadgeRef:rt,connectedSections:Me,openMoreFunctionsPopup:St,openSummaryPopup:Ut,deviationNodeIdToView:ce,deviationTargetParentId:ni,parentNodeId:(null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:de?!!ht["left-".concat(l)]:!!ht[String(l)],onToggle:function(){Jt(),mt(l,"left")},navigation:t.id?Zt[t.id]:null,showOpenNodeRef:ei,resolvedMarkdownStyles:tn,maintainRelativeOrder:de,showDeviationBadges:ge,renderSubSections:oi})})),de&&d&&n.jsxs(i.Box,e.__assign({ref:Qn.current[l],onClick:function(e){var n=de?Gn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Gn[l]||{title:"",content:""};St(e,t,v,n,l,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!oe.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?v?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(g.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(l))}),n.jsx("div",{ref:sn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:It,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){n.stopPropagation(),hn.open&&Sn===st?Bn():(In(st),yt(Rt(n.currentTarget,{title:"",content:"",evaluationResult:dt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,st,!0,e.__assign(e.__assign({},gt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",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!=vt?vt:n.jsx(g.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:hn.open&&Sn===st?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},de?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[_e&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Ct,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:Fn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Fn}))}))})),n.jsxs(i.Box,e.__assign({ref:rn,onScroll:Yt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},de?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:un,style:{width:"100%",height:"0px",flexShrink:0}}),Yn&&Gn.map(function(t,o){var l,r=t,u=[],c=!1,a=null,s=-1;if(de){u=Ln.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=Ln.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0});var d=Ln.findIndex(function(e,n){var t;return Me.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(r.selfIndex))});(c=-1!==d)&&(a=Mt(d))}else u=[o+1],(c=Me.has(o))&&(a=Mt(o));var v=Mt(de&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:et.current[o],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:$n.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:o,columnKey:"right",colRef:ot("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(l=null==Q?void 0:Q.input_index_map)||void 0===l?void 0:l[1])||"",isExpanded:de?!!ht["right-".concat(o)]:!!ht[String(o)],treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getBadgeRef:rt,getSectionCompareStyle:Mt,connectedSections:Me,openMoreFunctionsPopup:St,openSummaryPopup:Ut,deviationNodeIdToView:ce,deviationTargetParentId:ni,onToggle:function(){Jt(),mt(o,"right")},navigation:t.id?Zt[t.id]:null,showOpenNodeRef:ei,resolvedMarkdownStyles:tn,maintainRelativeOrder:de,showDeviationBadges:ge,renderSubSections:oi})})),de&&v&&n.jsx(i.Box,e.__assign({ref:Zn.current[o],"data-section-id":r.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),_=require("./hooks/useDeviationNavigation.js"),m=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),S=require("./components/CognitiveSummaryPopup.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var b,E,I,T,B,D,C,O,w,N,j,P,F,k,M,V,L,G,H,q,z,W,Y,K,U,X,J=A.componentHeaderText,$=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Q=A.treeData,Z=A.comparisonConfig,ee=A.leftColumnTitleText,ne=A.rightColumnTitleText,te=A.markdownStyles,ie=A.displayConfig,oe=void 0===ie?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:ie,re=A.popupConfig,le=A.deviationData,ue=void 0===le?{}:le,ce=A.deviationNodeIdToView,ae=A.resetDeviationNodeId,se=t.useState(oe.maintainRelativeOrder),de=se[0],ve=se[1],fe=!!de||!!(null==oe?void 0:oe.showDeviationBadges),ge=t.useState(!1),pe=ge[0],he=ge[1],xe=t.useState(!1),_e=xe[0],me=xe[1],Re=t.useState(null),ye=Re[0],Se=Re[1],Ae=t.useState(!1),be=Ae[0],Ee=Ae[1],Ie=t.useState(null===(E=null!==(b=null==Q?void 0:Q.newEvaluationResult)&&void 0!==b?b:null==oe?void 0:oe.enableDeviationSchemaBackwardCompatibility)||void 0===E||E)[0],Te=t.useState(!1),Be=Te[0],De=Te[1],Ce=t.useState(!1),Oe=Ce[0],we=Ce[1],Ne=t.useState(null),je=Ne[0],Pe=Ne[1],Fe=t.useRef(!1),ke=t.useState(new Set),Me=ke[0],Ve=ke[1],Le=t.useState([]),Ge=Le[0],He=Le[1],qe=t.useRef(null),ze=t.useRef(!1),We=t.useRef(null),Ye=t.useRef({}),Ke=t.useRef([]),Ue=t.useRef(!1),Xe=t.useRef(!1),Je=t.useRef(null),$e=t.useRef(function(){}),Qe=t.useMemo(function(){return(null==Q?void 0:Q.cognitive_decisioning)||{}},[Q]),Ze=t.useState({width:0,height:0}),en=Ze[0],nn=Ze[1],tn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),te)},[te]),on=t.useRef(null),rn=t.useRef(null),ln=t.useRef(null),un=t.useRef(null),cn=t.useRef(null),an=t.useRef(null),sn=t.useRef(null),dn=t.useRef(null),vn=t.useRef(!1),fn=t.useRef(null),gn=t.useRef(null),pn=p.useComparePopups(on),hn=pn.cognitivePopup,xn=pn.setCognitivePopup,_n=pn.moreFunctions,mn=pn.setMoreFunctions,Rn=pn.position,yn=pn.setPosition,Sn=pn.activeBadgeId,An=pn.summaryPopup,bn=pn.setSummaryPopup,En=pn.closeSummaryPopup,In=pn.setActiveBadgeId,Tn=pn.popupRef,Bn=pn.closeCognitivePopup,Dn=pn.closeMoreFunctionsPopup,Cn=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==Z?void 0:Z.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==Z?void 0:Z.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==Z?void 0:Z.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==Z?void 0:Z.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[Z]),On=t.useState(null),wn=On[0];On[1];var Nn=null===(B=null===(I=null==Q?void 0:Q.documents)||void 0===I?void 0:I[null===(T=null==Q?void 0:Q.input_index_map)||void 0===T?void 0:T[0]])||void 0===B?void 0:B.title,jn=null===(O=null===(D=null==Q?void 0:Q.documents)||void 0===D?void 0:D[null===(C=null==Q?void 0:Q.input_index_map)||void 0===C?void 0:C[1]])||void 0===O?void 0:O.title,Pn=u.safeStringify(ee||Nn||"Uploaded Contract"),Fn=u.safeStringify(ne||jn||"Reference Template"),kn=g.useCognitiveTreeData(Q,de,ue,Cn,Ie),Mn=kn.activeProposed,Vn=kn.existingRule,Ln=kn.proposedSections,Gn=kn.existingSections,Hn=kn.visibleFields,qn=kn.parentDeviationRecord,zn=kn.deviationNumberRegistry,Wn=kn.parseError;t.useEffect(function(){Wn&&Se("Failed to load comparison: ".concat(Wn))},[Wn]);var Yn=Ln.length>0||Gn.length>0,Kn=h.useSectionRefs(Hn.map(function(e){return e.key}),Math.max(Ln.length,Gn.length)),Un=Kn.leftRefs,Xn=Kn.rightRefs,Jn=Kn.sectionLeftRefs,$n=Kn.sectionRightRefs,Qn=Kn.lhsBadgeRefs,Zn=Kn.rhsBadgeRefs,et=Kn.sectionRightRowRefs,nt=Kn.subSectionLeftRefs,tt=Kn.subSectionRightRefs,it=Kn.sectionRowRefs,ot=Kn.getSectionRowRef,rt=Kn.getSubSectionRef,lt=Kn.getBadgeRef,ut=Vn.analysis,ct=u.safeStringify(null===(N=null===(w=null==ut?void 0:ut.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===N?void 0:N.overall_summary),at=!!ct.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),st=null!==(j=null==Q?void 0:Q.base_root_id)&&void 0!==j?j:"-1";null==Q||Q[st];var dt=Ie?null!==(Y=null!==(q=ue&&(null===(H=null==ue?void 0:ue[st])||void 0===H?void 0:H.evaluation_result))&&void 0!==q?q:null===(W=null===(z=null==Q?void 0:Q.nodes)||void 0===z?void 0:z[st])||void 0===W?void 0:W.evaluation_result)&&void 0!==Y?Y:null:null!==(G=null!==(k=ue&&(null===(F=null===(P=null==ue?void 0:ue[st])||void 0===P?void 0:P.evaluation_result)||void 0===F?void 0:F[0]))&&void 0!==k?k:null===(L=null===(V=null===(M=null==Q?void 0:Q.nodes)||void 0===M?void 0:M[st])||void 0===V?void 0:V.evaluation_result)||void 0===L?void 0:L[0])&&void 0!==G?G:null,vt=u.extractDeviationScore(dt),ft=u.generateColorPalette(null!==(X=null===(U=null===(K=null==dt?void 0:dt.evaluation_outputs)||void 0===K?void 0:K.metadata)||void 0===U?void 0:U.label_color)&&void 0!==X?X:""),gt=t.useCallback(function(){var e,n,t,i,o,r;Ee(!1),Xe.current=!1;var l=Je.current,c=Tt.current;if(null!==l)if("string"==typeof l&&l.includes(u.DEVIATION_BADGE_SEPARATOR)){var a=l.split(u.DEVIATION_BADGE_SEPARATOR);(s=(null===(e=nt.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=Jn.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=Jn.current[l])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}if(null!==c)if("string"==typeof c&&c.includes(u.DEVIATION_BADGE_SEPARATOR)){a=c.split(u.DEVIATION_BADGE_SEPARATOR);(d=(null===(i=tt.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=$n.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=$n.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Pe(null),Je.current=null,Tt.current=null,De(!1),me(!1),un.current&&(un.current.style.height="0px"),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px")},[]),pt=x.useAccordionState({maintainRelativeOrder:!!de,proposedSections:Ln,existingSections:Gn,activeSideBySideSection:je,connectedSections:Me,resetSideBySide:gt,setConnectedSections:Ve,setConnectedLines:He,cachedConnectedPositions:Ke,svgContainerRef:qe,isAnimatingRef:ze,animationTimerRef:We,calculateLinesRef:$e,sectionLeftRefs:Jn,sectionRightRefs:$n,subSectionLeftRefs:nt,subSectionRightRefs:tt}),ht=pt.expandedSections,xt=pt.expandedSubSections,_t=pt.setExpandedSubSections,mt=pt.toggleSection,Rt=t.useCallback(function(n,t,i,o,r,l,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",f=(v?Qe[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(a=it.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==oe?void 0:oe.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:f,anchorEl:n,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==Q?void 0:Q.documents,input_index_map:null==Q?void 0:Q.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,c=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[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 t?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return c(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var s=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(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 d?e.__assign(e.__assign(e.__assign({},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)}):c(l)}(),isOrphan:!!r}},[Qe,Q]),yt=t.useCallback(function(e){Dn(),yn(null),xn(e)},[Dn]),St=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),_n.open&&_n.sectionIdx===o)Dn();else{var c=e.currentTarget,a="left";(null===(l=ln.current)||void 0===l?void 0:l.contains(c))&&(a="right");Xe.current&>(),Ve(new Set),He([]),Ke.current=[],Bn(),An.open?ei():En(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=Zn.current[l])||void 0===e?void 0:e.current:null===(n=Qn.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=Zn.current[o])||void 0===t?void 0:t.current:null===(i=Qn.current[o])||void 0===i?void 0:i.current}()||c;mn(Rt(e,n,i,o,t,r))})}},At=t.useCallback(function(){null!==_n.sectionIdx&&_n.anchorEl?yt(e.__assign(e.__assign({},_n),{open:!0})):Dn()},[_n,Dn,yt]),bt=t.useCallback(function(){var e=_n.sectionIdx,n=_n.isOrphan;Dn(),En(),null!==e&&(n?Se("No counterpart exists to connect to."):(Xe.current&>(),He([]),Ke.current=[],Ve(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){$e.current&&$e.current()},50)))},[_n.sectionIdx,_n.isOrphan,Dn,En,gt]),Et=t.useRef(null),It=t.useRef(null),Tt=t.useRef(null),Bt=t.useRef(null),Dt=t.useRef(null),Ct=t.useRef(null),Ot=t.useState([]),wt=Ot[0],Nt=Ot[1];t.useRef(null);var jt=t.useState(null),Pt=jt[0],Ft=jt[1];t.useEffect(function(){if(wn){var e=Cn.fields.find(function(e){return e.analysisKey===wn||e.key===wn});if(e){var n=Un.current[e.key]||Xn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[wn,Cn.fields]);var kt=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==ut?void 0:ut.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.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===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[ut]),Mt=t.useCallback(function(n,t){var i,o,r,l,c,s,d;void 0===t&&(t="left");var v=null,f=null;if("left"===t)if(v=Ln[n],de&&v){var g=Gn.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});f=g.find(function(e){return e.evaluationResult})||g[0]}else f=Gn[n];else if(f=Gn[n],de&&f){var p=Ln.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(f.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=Ln[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,_=!(!(null==v?void 0:v.cognitiveData)&&!(null==f?void 0:f.cognitiveData));if(!h&&!x&&!_)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var m=null!==(o=null!==(i=null==v?void 0:v.evaluationResult)&&void 0!==i?i:null==f?void 0:f.evaluationResult)&&void 0!==o?o:null,R=null===(r=null==m?void 0:m.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(s=null===(c=null===(l=null==m?void 0:m.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===c?void 0:c.label_color)&&void 0!==s?s:a.DEFAULT_DEVIAION_COLOR;return null!=m?e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null!==(d=R)&&void 0!==d?d:""}):e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null})},[Ln,Gn,Qe,Cn,de]),Vt=t.useCallback(function(n){for(var t,i,o,r,l,c,s,d,v,f=n.split("-").map(Number),g=Ln[f[0]],p=Gn[f[0]],h=1;h<f.length;h++)(null==g?void 0:g.subsections)&&(g=g.subsections[f[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[f[h]]);if(!g&&!p)return null;var x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,_=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,m=u.safeStringify(null==g?void 0:g.id)||u.safeStringify(null==p?void 0:p.id)||"",R=!(!(null==g?void 0:g.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!x&&!_&&!R)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==g?void 0:g.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||m&&(null===(o=Qe[m])||void 0===o||o.relevance_score);var y=null!==(l=null!==(r=null==g?void 0:g.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,S=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.output_value,A=null!==(v=null===(d=null===(s=null==y?void 0:y.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===d?void 0:d.label_color)&&void 0!==v?v:a.DEFAULT_DEVIAION_COLOR;return null!=y?e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null!=S?S:""}):e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[Ln,Gn,Qe,Cn]),Lt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p,h,x,_,m,R,y,S;if(!vn.current&&!ze.current){vn.current=!0;try{if(!Et.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!ht[t]&&!1===de)return!1;if(de&&!ht["left-".concat(t)]&&!ht["right-".concat(t)]&&!ht[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!xt[i])return!1;return!0},b=Et.current.getBoundingClientRect();nn({width:b.width,height:b.height});var E=[];if(Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,r=null===(t=Xn.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!ze.current){for(var I=0;I<Math.max(Ln.length,Gn.length);I++){var T=null===(e=Jn.current[I])||void 0===e?void 0:e.current,B=null===(n=$n.current[I])||void 0===n?void 0:n.current;T&&(T.style.height="auto",T.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}de||Object.keys(nt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.current[e])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var D={};Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,r=null===(t=Xn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var C={left:{},right:{}},O={};if(!ze.current)if(de){if(be&&null!==je)if("number"==typeof je){var w=je,N=Ln[w],j=null===(o=Jn.current[w])||void 0===o?void 0:o.current;j&&N&&(N.refIndexes||[]).forEach(function(e){var n,t=Gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=$n.current[t])||void 0===n?void 0:n.current;if(i&&(ht["left-".concat(w)]||ht["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);C.left[w]=Math.max(C.left[w]||0,o),C.right[t]=Math.max(C.right[t]||0,o)}})}else{var P=je.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(P){T=null===(r=nt.current[P])||void 0===r?void 0:r.current,B=null===(l=tt.current[P])||void 0===l?void 0:l.current;if(T&&B){F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);O[P]=Math.max(O[P]||0,F)}}}}else{Object.keys(nt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);O[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(I=0;I<Math.min(Ln.length,Gn.length);I++){var T=null===(t=Jn.current[I])||void 0===t?void 0:t.current,B=null===(i=$n.current[I])||void 0===i?void 0:i.current;if(T&&B){var F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);C.left[I]=F,C.right[I]=F}}}if(Hn.forEach(function(e){var n,t,i=e.key,o=null===(n=Un.current[i])||void 0===n?void 0:n.current,r=null===(t=Xn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),ze.current||(Object.entries(C.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Jn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(C.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=$n.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),de||Object.keys(O).forEach(function(e){var n,t,i=null===(n=nt.current[e])||void 0===n?void 0:n.current,o=null===(t=tt.current[e])||void 0===t?void 0:t.current;if(i&&o&&O[e]){var r=O[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),de)Ln.forEach(function(e,n){var t;(null===(t=Jn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,a,s,d,v=Gn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=Qn.current[n])||void 0===t?void 0:t.current,g=null===(i=Zn.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-b.left,_=h.left-b.left,m=p.top+p.height/2-b.top,R=h.top+h.height/2-b.top;if(be&&je===n){var y=null!==(r=null===(o=dn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=ln.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,A=y+(null!==(a=null===(c=dn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=S+(null!==(d=null===(s=ln.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),T=p.top+p.height/2,B=h.top+h.height/2,D=function(e,n,t){return Math.max(n,Math.min(t,e))};m=D(T,y,A)-b.top,R=D(B,S,I)-b.top}var C=Mt(n);C&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:R,style:C,sectionIdx:n,targetRightIdx:v})}}})});else{for(I=0;I<Math.min(Ln.length,Gn.length);I++){var k=null===(c=Jn.current[I])||void 0===c?void 0:c.current,M=null===(a=$n.current[I])||void 0===a?void 0:a.current;if(k&&M){var V=k.getBoundingClientRect(),L=M.getBoundingClientRect(),G=Math.max(V.top,L.top)+18-b.top,H=(null===(s=Gn[I])||void 0===s?void 0:s.id)||"sec-".concat(I);(J=Mt(I))&&E.push({id:H,x1:V.right-b.left,y1:G,x2:L.left-b.left,y2:G,style:J,sectionIdx:I,hasCognitive:!!((null===(d=Ln[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=Gn[I])||void 0===v?void 0:v.cognitiveData)||H&&Qe[H]),isSubSection:!1})}}Object.keys(nt.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=nt.current[e])||void 0===n?void 0:n.current,a=null===(t=tt.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Ln[s[0]],v=Gn[s[0]],f=1;f<s.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]);var g=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(r=v.displayTitle)||void 0===r||r)&&u.hasValue(v.title)),x=!!v&&((null===(l=v.displayContent)||void 0===l||l)&&u.hasValue(v.content));if(g&&p||h&&x){var _=c.getBoundingClientRect(),m=a.getBoundingClientRect(),R=Math.max(_.top,m.top)+16-b.top,y=Vt(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:_.right-b.left,y1:R,x2:m.left-b.left,y2:R,style:y,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(be&&"string"==typeof je&&je.includes(u.DEVIATION_BADGE_SEPARATOR)){var q=je.split(u.DEVIATION_BADGE_SEPARATOR),z=q[0],W=q[1],Y=q[2],K=(q[3],"".concat(z).concat(u.DEVIATION_BADGE_SEPARATOR).concat(W)),U=null===(f=Qn.current[K])||void 0===f?void 0:f.current,X=null===(g=Zn.current[K])||void 0===g?void 0:g.current;if(U&&X){var J,$=U.getBoundingClientRect(),Q=X.getBoundingClientRect(),Z=$.right-b.left,ee=Q.left-b.left,ne=$.top+$.height/2-b.top,te=Q.top+Q.height/2-b.top;if(de){var ie=null!==(h=null===(p=dn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,oe=null!==(_=null===(x=ln.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,re=ie+(null!==(R=null===(m=dn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),le=oe+(null!==(S=null===(y=ln.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),ue=function(e,n,t){return Math.max(n,Math.min(t,e))};ne=ue($.top+$.height/2,ie,re)-b.top,te=ue(Q.top+Q.height/2,oe,le)-b.top}(J=Vt(Y))&&E.push({id:"line-subsec-".concat(K),x1:Z,y1:ne,x2:ee,y2:te,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:je})}}if(Nt(E),Dt.current&&Ct.current){var ce=Dt.current.getBoundingClientRect(),ae=Ct.current.getBoundingClientRect(),se=(ce.top+ce.height/2-b.top+ae.top+ae.height/2-b.top)/2;Ft({x1:ce.right-b.left,x2:ae.left-b.left,y:se})}else Ft(null);if(Me.size>0){var ve=[],fe=dn.current,ge=ln.current;if(fe&&ge){var pe=[],he=fe.getBoundingClientRect().top,xe=ge.getBoundingClientRect().top,_e=he+fe.clientHeight,me=xe+ge.clientHeight,Re=fe.scrollTop,ye=ge.scrollTop,Se=b.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};Me.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=e.split(u.DEVIATION_BADGE_SEPARATOR),c=l[0],a=l[1],s=l[2],d=(l[3],"".concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(a)),v=null===(n=Qn.current[d])||void 0===n?void 0:n.current,f=null===(t=Zn.current[d])||void 0===t?void 0:t.current;if(!v||!f)return;var g=v.getBoundingClientRect(),p=f.getBoundingClientRect(),h=Vt(s),x=(j=g.right-b.left)+.5*((P=p.left-b.left-0)-j),_=g.top+g.height/2,m=p.top+p.height/2,R=_-he+Re,y=m-xe+ye,S="conn-subsec-".concat(d);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var A=Ae(_,he,_e),E=Ae(m,xe,me),I=A-Se,T=E-Se,B=m>=xe-4&&m<=me+4,D="";D=(F=_>=he-4&&_<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:D,style:h,leftIdx:e,rhsArrayIdx:e})}else if(de){var C=e,O=Ln[C];if(!(null===(r=null==O?void 0:O.refIndexes)||void 0===r?void 0:r.length))return;O.refIndexes.forEach(function(e){var n,t,i=Gn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Qn.current[C])||void 0===n?void 0:n.current,r=null===(t=Zn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Mt(C),s=l.right-b.left,d=c.left-b.left-0,v=s+.5*(d-s),f=l.top+l.height/2,g=c.top+c.height/2,p=f-he+Re,h=g-xe+ye,x="conn-".concat(C,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:C,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=Ae(f,he,_e),m=Ae(g,xe,me),R=_-Se,y=m-Se,S=f>=he-4&&f<=_e+4,A=g>=xe-4&&g<=me+4,E="";E=S&&A?u.getBentArrowPath(s,R,d,y):S&&!A?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!S&&A?"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y," L ").concat(d,",").concat(y):"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y),ve.push({id:x,pathD:E,style:a,leftIdx:C,rhsArrayIdx:i})}}})}else{var w=e,N=w;v=null===(i=Qn.current[w])||void 0===i?void 0:i.current,f=null===(o=Zn.current[N])||void 0===o?void 0:o.current;if(!v||!f)return;var j,P;g=v.getBoundingClientRect(),p=f.getBoundingClientRect(),h=Mt(w),x=(j=g.right-b.left)+.5*((P=p.left-b.left-0)-j),_=g.top+g.height/2,m=p.top+p.height/2,R=_-he+Re,y=m-xe+ye,S="conn-".concat(w,"-").concat(N);pe.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Se,leftIdx:w,rhsArrayIdx:N,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var F;A=Ae(_,he,_e),E=Ae(m,xe,me),I=A-Se,T=E-Se,B=m>=xe-4&&m<=me+4,D="";D=(F=_>=he-4&&_<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:D,style:h,leftIdx:w,rhsArrayIdx:N})}}),Ke.current=pe}He(ve)}else He([]),Ke.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{vn.current=!1}}},[Hn,Ln,Gn,Qe,Cn,kt,Mt,de,be,je,Me,ht,xt]),Gt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p=Ke.current;if(p.length&&!ze.current){var h=null!==(n=null===(e=dn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=ln.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(r=null===(o=dn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=ln.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=dn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=ln.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,A=y+m,b=null!==(g=null===(f=Et.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,E=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+R,t=e.rhsScrollY-x+y,i=Ye.current[e.styleId+"-stroke"],o=Ye.current[e.styleId+"-bg"];if(i||o){var r,l=E(n,R,S),c=E(t,y,A),a=l-b,s=c-b,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=A+4,f=e.x1+.5*(e.x2-e.x1);r=d&&v?u.getBentArrowPath(e.x1,a,e.x2,s):d&&!v?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(s):!d&&v?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){$e.current=Lt},[Lt]);var Ht=t.useRef(null),qt=t.useRef(null),zt=t.useCallback(function(){Ke.current.length>0&&!ze.current||(null!==Ht.current&&clearTimeout(Ht.current),Ht.current=setTimeout(function(){$e.current(),Ht.current=null},50))},[]),Wt=t.useCallback(function(){we(!0),De(!1),null!==qt.current&&clearTimeout(qt.current),null!==Ht.current&&(clearTimeout(Ht.current),Ht.current=null),qt.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s;if(Ke.current=[],Xe.current&&null!==Je.current&&null!==Tt.current){var d=Je.current,v=Tt.current,f=null,g=null,p=null,h=null;if("string"==typeof d&&d.includes(u.DEVIATION_BADGE_SEPARATOR)){var x=d.split(u.DEVIATION_BADGE_SEPARATOR),_="".concat(x[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(x[1]);f=(null===(e=Qn.current[_])||void 0===e?void 0:e.current)||null,g=(null===(n=Zn.current[_])||void 0===n?void 0:n.current)||null,p=(null===(t=nt.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=Jn.current[Number(x[2])])||void 0===i?void 0:i.current)||null,h=(null===(o=tt.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=$n.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else f=(null===(l=it.current[d])||void 0===l?void 0:l.current)||null,p=(null===(c=Jn.current[d])||void 0===c?void 0:c.current)||null,g=(null===(a=et.current[v])||void 0===a?void 0:a.current)||null,h=(null===(s=$n.current[v])||void 0===s?void 0:s.current)||null;if(f&&g&&p&&h){if(p.style.paddingTop="0px",h.style.paddingTop="0px",!de){var m=f.getBoundingClientRect(),R=g.getBoundingClientRect(),y=m.top-R.top;y>0?h.style.paddingTop="".concat(y,"px"):y<0&&(p.style.paddingTop="".concat(Math.abs(y),"px"))}var S=dn.current,A=ln.current;if(S&&A){var b=f.getBoundingClientRect().top-S.getBoundingClientRect().top+S.scrollTop,E=g.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop-(b-S.scrollTop);Math.abs(A.scrollTop-E)>1&&(A.scrollTop=E)}}}$e.current(),Xe.current&&De(!0),we(!1),qt.current=null},150)},[de,Ln,Gn]),Yt=t.useCallback(function(e){var n,t,i,o,r,l,c,a,s,d;if(null!==fn.current&&gn.current&&Math.abs(e.currentTarget.scrollTop-fn.current)<=2){var v=gn.current;fn.current=null,gn.current=null,v()}if(!Fe.current){if(de||zt(),Xe.current){var f=Je.current,g=Tt.current,p=dn.current,h=ln.current;if(null!==f&&null!==g&&p&&h){var x="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Qn.current["".concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=it.current[f])||void 0===t?void 0:t.current,_="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=Zn.current["".concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===i?void 0:i.current:null===(o=et.current[g])||void 0===o?void 0:o.current;if(x&&_&&Bt.current){var m=void 0,R=void 0;if("string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)){var y=f.split(u.DEVIATION_BADGE_SEPARATOR),S="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);m=null===(r=Qn.current[S])||void 0===r?void 0:r.current,R=null===(l=Zn.current[S])||void 0===l?void 0:l.current}else m=null===(c=Qn.current[f])||void 0===c?void 0:c.current,R=null===(a=Zn.current[g])||void 0===a?void 0:a.current;var A=null!==(d=null===(s=Et.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==d?d:0,b=p.getBoundingClientRect().top,E=b+p.clientHeight;h.getBoundingClientRect().top;h.clientHeight;if(m&&R){var I=m.getBoundingClientRect(),T=R.getBoundingClientRect(),B=I.top+I.height/2;T.top,T.height;var D=((O=B,w=b,N=E,Math.max(w,Math.min(N,O)))-A).toString();Bt.current.setAttribute("y1",D),Bt.current.setAttribute("y2",D);var C=B>=b-4&&B<=E+4;Bt.current.setAttribute("visibility",C?"visible":"hidden")}}}}var O,w,N;Ke.current.length>0&&!Ue.current&&(Ue.current=!0,requestAnimationFrame(function(){Gt(),Ue.current=!1}))}},[Gt,de,zt]),Kt=t.useRef(0),Ut=t.useRef(0),Xt=t.useRef(0),Jt=t.useRef(function(){});t.useRef(null),t.useEffect(function(){Jt.current=Wt},[Wt]),t.useEffect(function(){var e=setTimeout(zt,250),n=function(){return Jt.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==Ht.current&&clearTimeout(Ht.current),null!==qt.current&&clearTimeout(qt.current),window.removeEventListener("resize",n)}},[Mn,Vn,ut,Hn,ht,xt,Ln,Gn,Cn,zt,be,je,Be,Me]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return r.observe(e),r},n={current:null},t={current:null},i={current:null},o=[],r=[n,t,i];return rn.current&&o.push(e(rn.current,Kt,n,function(){return Jt.current()},function(){})),on.current&&o.push(e(on.current,Ut,t,function(){return Jt.current()},function(){return $e.current()})),Et.current&&o.push(e(Et.current,Xt,i,function(){return Jt.current()},function(){return $e.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){Xe.current=be},[be]),t.useEffect(function(){Je.current=je},[je]);var $t=t.useCallback(function(e,n,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,c=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";Dn(),null!=e&&(n?Se("No counterpart exists for this section."):be&&je===e?r?gt():null==l||l():(Ve(new Set([e])),He([]),Ke.current=[],me(!0),Fe.current=!0,Pe(e),Je.current=e,Ee(!0),Xe.current=!0,De(!1),un.current&&(un.current.style.height="0px"),cn.current&&(cn.current.style.height="0px"),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,a="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=null,d=null,v=null;if(a){var f=e.split(u.DEVIATION_BADGE_SEPARATOR),g="".concat(f[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f[1]);s=(null===(n=Qn.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=Zn.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=it.current[e])||void 0===i?void 0:i.current)||null,de){var p=Ln[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=Gn.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(r=et.current[_])||void 0===r?void 0:r.current)||null,v=_)}}else d=(null===(o=et.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Tt.current=v;var m=dn.current,R=ln.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,f,g,p,h=null,x=null,_=null,m=null;if(a){var R=e.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(R[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(R[1]);h=(null===(n=nt.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=Jn.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=tt.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=$n.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(r=Qn.current[y])||void 0===r?void 0:r.current)||h,m=(null===(l=Zn.current[y])||void 0===l?void 0:l.current)||x}else{var S=Number(e),A=null!==v?Number(v):S;h=(null===(c=Jn.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=$n.current[A])||void 0===s?void 0:s.current)||null,_=(null===(d=Qn.current[S])||void 0===d?void 0:d.current)||(null===(f=it.current[S])||void 0===f?void 0:f.current)||h,m=(null===(g=Zn.current[A])||void 0===g?void 0:g.current)||(null===(p=et.current[A])||void 0===p?void 0:p.current)||x}if(_&&m&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var b=_.getBoundingClientRect(),E=m.getBoundingClientRect(),I=b.top-E.top;I>0?x.style.paddingTop="".concat(I,"px"):I<0&&(h.style.paddingTop="".concat(Math.abs(I),"px"))}}(),De(!0),$e.current&&$e.current(),Fe.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),me(!1),null==l||l()};if(!s||!m)return Fe.current=!1,me(!1),void(null==l||l());if(d&&R){if(!de){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var A=on.current,b=(null==A?void 0:A.getBoundingClientRect().top)||0,E=A?A.scrollTop+S-b-150:0;return A?void u.smoothScrollTo(A,E,200,y):void y()}var I=s.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var D=T-(I-m.scrollTop);D<0&&un.current&&(un.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return cn.current&&(cn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,D,B,y)})}e=D}u.smoothScrollTo(R,e,B,y)})}else{var C=I-(T-R.scrollTop);C<0&&an.current&&(an.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=m.scrollHeight-m.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return sn.current&&(sn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(m,C,B,y)})}e=C}u.smoothScrollTo(m,e,B,y)})}}else y()})))},[je,Dn,Gn,be,de,Ln,gt]),Qt=t.useCallback(function(e,n,t,i){var o,r="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;Bn();var c="left";(null===(o=ln.current)||void 0===o?void 0:o.contains(l))&&(c="right");var a=function(){var e,t,i,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===c?null===(e=Zn.current[l])||void 0===e?void 0:e.current:null===(t=Qn.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=Zn.current[n])||void 0===i?void 0:i.current:null===(o=Qn.current[n])||void 0===o?void 0:o.current};if(t)return gt(),Ve(new Set),He([]),Ke.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;bn({open:!0,anchorEl:e,summary:i})}));$t(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;bn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[$t,Bn,bn,gt]),Zt=t.useCallback(function(){var e,n=_n.sectionIdx,t=_n.isOrphan;if(En(),null!=n){var i="left";_n.anchorEl&&(null===(e=ln.current)||void 0===e?void 0:e.contains(_n.anchorEl))&&(i="right"),$t(n,t,{sourceSide:i})}},[$t,_n.isOrphan,_n.sectionIdx,_n.anchorEl,En]),ei=t.useCallback(function(){En(),gt(),Ve(new Set),He([]),Ke.current=[]},[En,gt]),ni=null!==_n.sectionIdx&&Me.has(_n.sectionIdx),ti=_.useDeviationNavigation({proposedSections:Ln,existingSections:Gn,parentDeviationRecord:qn,expandedSections:ht,maintainRelativeOrder:!!de,scrollContainerRef:on,leftContainerRef:dn,lhsBadgeRefs:Qn,rhsBadgeRefs:Zn}),ii=ti.showDeviationNavigation,oi=ti.showOpenNodeRef,ri=t.useMemo(function(){if(!ce)return null;var e=ce.split(":")[0];for(var n in qn){if((qn[n]||[]).some(function(n){return n.id===e}))return n}return null},[ce,qn]),li=t.useRef(null),ui=t.useRef(null);t.useEffect(function(){if(ce&&li.current!==ce){var n=ce.split(":"),t=n[0],i=n[1],o=null!=i?i:"0";ui.current!==ce&&(En(),Bn(),gt(),Ve(new Set),He([]),Ke.current=[],ui.current=ce);var r=!1,l=0,c=null,a=150,s=function(e,n){for(var t=function(e,i){if(!e)return null;if(e.id===n)return i;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=t(e.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<e.length;i++){var o=t(e[i],String(i));if(o)return o}return null},d=function(){var n,i,v,f;if(!r){var g=null,p=null;for(var h in qn){var x=qn[h].find(function(e){return e.id===t});if(x){g=h,p=x;break}}if(p&&g){var _=Ln.findIndex(function(e){return e.id===g}),m=Gn.findIndex(function(e){return e.id===g}),R=-1===_&&-1!==m,y=s(Ln,p.id),S=s(Gn,p.id);if(y&&!S&&!R){var A=y.split("-"),b=Number(A[0]);if(de){var E=null===(i=null===(n=Ln[b])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],I=Gn.findIndex(function(e){return e.selfIndex===E});-1!==I&&(b=I)}S=e.__spreadArray([b],A.slice(1),!0).join("-")}if(y||S){var T=R||!y&&!!S,B=y?Number(y.split("-")[0]):_,D=S?Number(S.split("-")[0]):m;if(T){if(!(de?!!ht["right-".concat(D)]:!!ht[String(D)])&&D>=0)return mt(D,"right"),l+=1,void(c=setTimeout(d,450))}else if(!(de?!!ht["left-".concat(B)]:!!ht[String(B)])&&B>=0)return mt(B,"left"),l+=1,void(c=setTimeout(d,450));var C,O=y||"",w=S||"",N="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(o).concat(u.DEVIATION_BADGE_SEPARATOR).concat(O).concat(u.DEVIATION_BADGE_SEPARATOR).concat(w),j="".concat(p.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(o),P=null===(v=Qn.current[j])||void 0===v?void 0:v.current,F=null===(f=Zn.current[j])||void 0===f?void 0:f.current,k=T||!P&&!!F,M=k?F:P;if(C=de?k?ln.current:dn.current:on.current,M&&C){var V=M.getBoundingClientRect();if(0===V.height)return void((l+=1)<20&&(c=setTimeout(d,a)));var L=C.getBoundingClientRect(),G=V.top-L.top+C.scrollTop-L.height/2+V.height/2,H=function(){var n,t,i,l,u;if(!r){li.current=ce;var c=window.getComputedStyle(M).color;P&&(P.style.transition="box-shadow 300ms ease-in-out",P.style.boxShadow="0 0 10px ".concat(c)),F&&(F.style.transition="box-shadow 300ms ease-in-out",F.style.boxShadow="0 0 10px ".concat(c)),setTimeout(function(){P&&(P.style.boxShadow=""),F&&(F.style.boxShadow="")},2e3);var a=(null===(t=null===(n=p.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[o])||p,s=(null===(i=p.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||p.evaluation_outputs;if(!(!!P&&!!F)){var d=k?(null===(l=Zn.current[j])||void 0===l?void 0:l.current)||F:(null===(u=Qn.current[j])||void 0===u?void 0:u.current)||P;return bn({open:!0,anchorEl:d,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})}),void(null==ae||ae())}$t(N,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=Qn.current[j])||void 0===n?void 0:n.current)||P;bn({open:!0,anchorEl:t,summary:e.__assign(e.__assign({},a),{evaluation_outputs:s})})}})}};Math.abs(C.scrollTop-G)<=2?H():(fn.current=G,gn.current=H,C.scrollTo({top:G,behavior:"smooth"}),c&&clearTimeout(c),c=setTimeout(function(){if(gn.current){fn.current=null;var e=gn.current;gn.current=null,e()}},800))}else(l+=1)<20&&(c=setTimeout(d,a))}else(l+=1)<20&&(c=setTimeout(d,a))}else(l+=1)<20&&(c=setTimeout(d,a))}};return c=setTimeout(d,a),function(){r=!0,c&&clearTimeout(c)}}},[ce,qn,Ln,Gn,de,ht,mt,$t,bn]);var ci=function(e){var t=e.section,i=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c;return n.jsx(y.default,{section:t,keyPath:i,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:xt,setExpandedSubSections:_t,maintainRelativeOrder:de||!1,proposedSections:Ln,existingSections:Gn,treeData:Q,deviationNumberRegistry:zn,connectedSections:Me,activeSideBySideSection:je,resolvedMarkdownStyles:tn,getSubSectionRef:rt,getSubSectionCompareStyle:Vt,getBadgeRef:lt,openMoreFunctionsPopup:St,openSummaryPopup:Qt,showDeviationBadges:fe,resetSideBySide:gt,setConnectedSections:Ve,setConnectedLines:He,cachedConnectedPositions:Ke})};return n.jsxs(i.Box,e.__assign({ref:rn,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},de?{}:{overflow:"visible"}),{position:"relative"})},{children:[pe&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),An.open&&n.jsx(S.default,{open:An.open,anchorEl:An.anchorEl,containerEl:It.current,clipTopEl:Dt.current,scrollContainerEl:on.current,onClose:ei,summary:An.summary}),n.jsx(d.default,{open:_n.open,anchorEl:_n.anchorEl,sectionTitle:_n.sectionTitle,referenceSectionTitle:_n.refSectionTitle,onClose:Dn,onOpenCognitiveCompare:At,onOpenSideBySide:Zt,onConnect:bt,isConnected:ni,isOrphan:_n.isOrphan}),hn.open&&n.jsx(s.default,{open:hn.open,popupRef:Tn,position:Rn,popupConfig:re,onClose:function(){yn(null),xn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),In(null)},markdownStyles:te,sectionTitle:hn.sectionTitle,referenceSectionTitle:hn.refSectionTitle,cognitiveData:hn.cognitiveData,anchorEl:hn.anchorEl,sectionAnchorEl:hn.sectionAnchorEl,scrollContainerEl:on.current,badgeStyle:hn.badgeStyle,docData:hn.docData,deviationData:hn.deviationData,isLoading:hn.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ye,autoHideDuration:8e3,onClose:function(){return Se(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Se(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ye}))})),n.jsx(m.default,{componentHeaderText:$,displayConfig:oe,maintainRelativeOrder:de,onToggleView:function(e){he(!0),setTimeout(function(){ve(!e),gt(),En(),Ve(new Set),He([]),Ke.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){he(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:on,onScroll:Yt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:de?"hidden":"auto",borderTop:ct&&at?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},de?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Et,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},de?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:qe,style:{position:"absolute",top:0,left:0,width:en.width||"100%",height:en.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Oe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Pt&&n.jsx("g",{children:n.jsx("line",{x1:Pt.x1,y1:Pt.y,x2:Pt.x2,y2:Pt.y,stroke:ft.badgeBorder,strokeWidth:"1.5"})}),wt.map(function(t){var l,c,s,d,v,g,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?be&&je===t.subSectionKeyPath&&Be:be&&je===t.sectionIdx&&Be)return null;if(!de){var x=t.isSubSection?u.getBentArrowPath(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2),_=Ln[t.sectionIdx]||{title:"",content:""},m=Gn[t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",_,m),t.isSubSection&&t.subSectionKeyPath){var R=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],y=R[2]||t.subSectionKeyPath,S=R[3]||y,A=y.split("-").map(Number),b=S.split("-").map(Number),E=null,I=null;A.length>0&&(E=Ln[A[0]]),b.length>0&&(I=Gn[b[0]]);var T=(null==E?void 0:E.title)||"",B=(null==I?void 0:I.title)||"";console.log("Root Parent Titles:",T,B);for(var D=1;D<A.length;D++)(null==E?void 0:E.subsections)&&(E=E.subsections[A[D]]);for(D=1;D<b.length;D++)(null==I?void 0:I.subsections)&&(I=I.subsections[b[D]]);E&&(_=e.__assign(e.__assign({},E),{title:T||E.title})),console.log("Base Section for Subsection Badge:",_),I&&(m=e.__assign(e.__assign({},I),{title:B||I.title})),console.log("Ref Section for Subsection Badge:",m)}var C=!(null===(l=_.cognitiveData)||void 0===l?void 0:l.isMissingRationale)||Boolean(null===(s=null===(c=_.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===s?void 0:s.length),O=(null===(g=null===(v=null===(d=_.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===g?void 0:g.length)||!1,w=C||O;return n.jsxs("g",{children:[n.jsx("path",{d:x,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:p-100,y:h-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),w&&(hn.open&&Sn===t.id?Bn():(In(t.id),yt(Rt(e.currentTarget,_,m,t.sectionIdx,t.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:w?"pointer":"default"}},{children:[t.style.badgeText===a.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(f.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),w&&n.jsx(o.ChevronDown,{size:11,style:{transform:hn.open&&Sn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ge.map(function(t){var i,o=t.pathD,r=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),c="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:l,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:r})}))}))}),n.jsx("path",{ref:function(e){Ye.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Ye.current[c]=e},d:o,fill:"none",stroke:r,strokeWidth:"1.75",markerEnd:"url(#".concat(l,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},de?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Dt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(i.Tooltip,e.__assign({title:Pn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Pn}))}))})),n.jsxs(i.Box,e.__assign({ref:dn,onScroll:Yt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},de?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:an,style:{width:"100%",height:"0px",flexShrink:0}}),Yn&&Ln.map(function(t,r){var l,c,a=!t.title&&!t.content;if(de&&a)return null;var s=t,d=Mt(r,"left"),v=de?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Gn[r],g=de?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=Me.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:ot(r),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Jn.current[r],sx:e.__assign({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:r,columnKey:"left",colRef:ot("left-accordion-".concat(r)),mb:0,treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getSectionCompareStyle:Mt,getBadgeRef:lt,connectedSections:Me,openMoreFunctionsPopup:St,openSummaryPopup:Qt,deviationNodeIdToView:ce,deviationTargetParentId:ri,parentNodeId:(null===(c=null==Q?void 0:Q.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:de?!!ht["left-".concat(r)]:!!ht[String(r)],onToggle:function(){ei(),mt(r,"left")},navigation:t.id?ii[t.id]:null,showOpenNodeRef:oi,resolvedMarkdownStyles:tn,maintainRelativeOrder:de,showDeviationBadges:fe,renderSubSections:ci})})),de&&d&&n.jsxs(i.Box,e.__assign({ref:Qn.current[r],onClick:function(e){var n=de?Gn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Gn[r]||{title:"",content:""};St(e,t,v,n,r,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==g&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:g})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!oe.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?v?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(f.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:sn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:It,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){n.stopPropagation(),hn.open&&Sn===st?Bn():(In(st),yt(Rt(n.currentTarget,{title:"",content:"",evaluationResult:dt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,st,!0,e.__assign(e.__assign({},ft),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:ft.badgeBg,color:ft.badgeText,border:"1px solid ".concat(ft.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=vt?vt:n.jsx(f.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:hn.open&&Sn===st?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},de?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[_e&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Ct,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:Fn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Fn}))}))})),n.jsxs(i.Box,e.__assign({ref:ln,onScroll:Yt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},de?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:un,style:{width:"100%",height:"0px",flexShrink:0}}),Yn&&Gn.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(de){u=Ln.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=Ln.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=Ln.findIndex(function(e,n){var t;return Me.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=Mt(d))}else u=[o+1],(c=Me.has(o))&&(a=Mt(o));var v=Mt(de&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:et.current[o],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:$n.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:o,columnKey:"right",colRef:ot("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==Q?void 0:Q.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:de?!!ht["right-".concat(o)]:!!ht[String(o)],treeData:Q,proposedSections:Ln,existingSections:Gn,deviationNumberRegistry:zn,getBadgeRef:lt,getSectionCompareStyle:Mt,connectedSections:Me,openMoreFunctionsPopup:St,openSummaryPopup:Qt,deviationNodeIdToView:ce,deviationTargetParentId:ri,onToggle:function(){ei(),mt(o,"right")},navigation:t.id?ii[t.id]:null,showOpenNodeRef:oi,resolvedMarkdownStyles:tn,maintainRelativeOrder:de,showDeviationBadges:fe,renderSubSections:ci})})),de&&v&&n.jsx(i.Box,e.__assign({ref:Zn.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("@mui/material"),i=require("react"),t=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("@mui/material"),i=require("react"),t=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),s=require("react-markdown"),a=require("../CognitiveComparehelpers.js"),l=require("rehype-raw");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(i),p=c(s),u=c(l),g=d.default.memo(function(s){var l=s.content,c=s.sxStyles,g=s.deviationBadges,h=void 0===g?[]:g,_=s.highlights,f=void 0===_?[]:_,x=s.maintainRelativeOrder,v=void 0===x||x,m=s.highlightBg,b=i.useMemo(function(){return h.reduce(function(n,r){var i;return e.__assign(e.__assign({},n),((i={})[r.id]=r,i))},{})},[h]),y=function(n,r){return d.default.Children.map(n,function(n){var i;if(!d.default.isValidElement(n))return n;var t=(null===(i=n.props)||void 0===i?void 0:i.children)?y(n.props.children,r):n.props.children,o=d.default.cloneElement(n,e.__assign(e.__assign({},n.props),{children:t}));return r(o)})},C=i.useMemo(function(){return{mark:function(r){var i=r.children,t=e.__rest(r,["children"]);return n.jsx("span",e.__assign({style:e.__assign(e.__assign({},t.isSuggestedDeviationFix?{}:{backgroundColor:m}),{borderRadius:"2px"})},{children:i}))},span:function(i){var s,a,l,c,d,p,u=i.children,g=e.__rest(i,["children"]),h=g["data-badge-id"];if(!h)return n.jsx("span",e.__assign({},g,{children:u}));var _=b[h];return _?n.jsxs(r.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(r.Box,e.__assign({ref:_.badgeRef,sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(s=_.style)||void 0===s?void 0:s.badgeBg)||"#EEF2FF",color:(null===(a=_.style)||void 0===a?void 0:a.badgeText)||t.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(l=_.style)||void 0===l?void 0:l.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden"},"left"===_.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),_.isConnected&&_.style&&{outline:"2px solid ".concat(_.style.badgeBorder),outlineOffset:"1px"})},{children:[n.jsxs(r.Box,e.__assign({onClick:function(e){e.stopPropagation(),_.onSummaryClick&&_.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:_.label})),("left"===_.side||_.isOrphan)&&n.jsx(r.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(c=_.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE")}},{children:null!=_.score&&"N/A"!==_.score&&"NA"!==_.score&&0!==_.score?"".concat(_.score):"N/A"===_.score||"NA"===_.score?"N/A":"Same"}))]})),("left"===_.side||_.isOrphan)&&n.jsx(r.Box,e.__assign({onClick:function(e){e.stopPropagation(),_.onClick&&_.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(d=_.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:n.jsx(o.EllipsisVertical,{size:12,color:(null===(p=_.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),u]})):n.jsx("span",e.__assign({},g,{children:u}))},updated:function(r){var i=r.children;return e.__rest(r,["children"]),n.jsx(n.Fragment,{children:i})},deleted:function(r){var i=r.children;e.__rest(r,["children"]),console.log("nitish: ",i);var t=y(i,function(e){return d.default.cloneElement(e,{isSuggestedDeviationFix:!0})});return n.jsx("span",e.__assign({style:{borderTop:"1px solid #EF4444",borderBottom:"1px solid #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:t}))},changed:function(r){var i=r.children;e.__rest(r,["children"]);var t=y(i,function(e){return d.default.cloneElement(e,{isSuggestedDeviationFix:!0})});return n.jsx("span",e.__assign({style:{borderTop:"1px solid #2F59FF",borderBottom:"1px solid #2F59FF",backgroundColor:"#D5E8FF"}},{children:t}))}}},[b,v]),E=i.useMemo(function(){var n=function(e){return e?e.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n").split(/(\n{2,})/).map(function(e){return e.startsWith("\n")?e:e.replace(/\n/g," ")}).join(""):""},r=function(e,n,r){void 0===n&&(n=""),void 0===r&&(r="");var i=e.startsWith("\n\n"),t=e.endsWith("\n\n");return n+e.split(/(\n{2,})/).map(function(e,n,r){if(/^\n{2,}$/.test(e))return e;if(!e.trim())return e;var o=0===n||1===n&&/^\n{2,}$/.test(r[0]),s=n===r.length-1||n===r.length-2&&/^\n{2,}$/.test(r[r.length-1]);return i&&o||t&&s?e:"<mark>".concat(e,"</mark>")}).join("").replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")+r},i=n(a.safeStringify(l||"")),t=e.__spreadArray([],h,!0).sort(function(e,n){var r,i;return((null===(r=n.highlight)||void 0===r?void 0:r.length)||0)-((null===(i=e.highlight)||void 0===i?void 0:i.length)||0)}),o={},s=0;t.forEach(function(e){if(e&&e.highlight){var t=n(e.highlight);if(t){var a=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l="__DEV_TOKEN_".concat(s++,"__");o[l]=r(t,'<span data-badge-id="'.concat(e.id,'">'),"</span>"),i=i.replace(t,l);var c="__HIGHLIGHT_TOKEN_".concat(s++,"__");o[c]=r(t),i=i.replace(new RegExp(a,"g"),c)}}});var c=new Set(t.map(function(e){return n(e.highlight)}).filter(Boolean));return f.forEach(function(e){if(e){var t=n(e);if(t&&!c.has(t)){var a=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l="__PLAIN_TOKEN_".concat(s++,"__");o[l]=r(t),i=i.replace(new RegExp(a,"g"),l)}}}),Object.keys(o).forEach(function(e){i=i.split(e).join(o[e])}),i},[l,h,f]);return n.jsx(r.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},c),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}})},{children:n.jsx(p.default,e.__assign({components:C,rehypePlugins:[u.default]},{children:a.safeStringify(E).replace(/\\n/g,"\n")}))}))},a.areMarkdownPropsEqual);exports.MemoizedMarkdown=g;
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as c}from"react";import{Box as d,Snackbar as a,Alert as s,Tooltip as v,Typography as p}from"@mui/material";import{ChevronDown as f,EllipsisVertical as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import x from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as y,generateColorPalette as b,DEVIATION_BADGE_SEPARATOR as S,hasValue as R,getBentArrowPath as C,smoothScrollTo as I}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as w,DEFAULT_FIELD_CONFIG as B,DEFAULT_COMPARISON_CONFIG as T}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as _,DEFAULT_COMPONENT_HEADER_TEXT as E}from"./CognitiveCompareConstants.js";import F from"./CognitivePopup.js";import D from"./MoreFunctionsPopup.js";import k from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as N}from"./hooks/useCompareData.js";import{useComparePopups as A}from"./hooks/useComparePopups.js";import{useSectionRefs as H}from"./hooks/useSectionRefs.js";import{useAccordionState as L}from"./hooks/useAccordionState.js";import{useDeviationNavigation as j}from"./hooks/useDeviationNavigation.js";import O from"./components/CompareHeader.js";import P from"./components/SectionAccordion.js";import z from"./components/SubSectionAccordion.js";import W from"./components/CognitiveSummaryPopup.js";var Y=function(Y){var K,q,V,X,J,U,$,G,Q,Z,ee,ne,te,ie,oe,re,le,ue,ce,de,ae,se,ve,pe,fe,ge,he=Y.componentHeaderText,xe=void 0===he?E:he,me=Y.treeData,ye=Y.comparisonConfig,be=Y.leftColumnTitleText,Se=Y.rightColumnTitleText,Re=Y.markdownStyles,Ce=Y.displayConfig,Ie=void 0===Ce?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:Ce,we=Y.popupConfig,Be=Y.deviationData,Te=void 0===Be?{}:Be,_e=Y.deviationNodeIdToView,Ee=Y.resetDeviationNodeId,Fe=o(Ie.maintainRelativeOrder),De=Fe[0],ke=Fe[1],Me=!!De||!!(null==Ie?void 0:Ie.showDeviationBadges),Ne=o(!1),Ae=Ne[0],He=Ne[1],Le=o(!1),je=Le[0],Oe=Le[1],Pe=o(null),ze=Pe[0],We=Pe[1],Ye=o(!1),Ke=Ye[0],qe=Ye[1],Ve=o(null===(q=null!==(K=null==me?void 0:me.newEvaluationResult)&&void 0!==K?K:null==Ie?void 0:Ie.enableDeviationSchemaBackwardCompatibility)||void 0===q||q)[0],Xe=o(!1),Je=Xe[0],Ue=Xe[1],$e=o(!1),Ge=$e[0],Qe=$e[1],Ze=o(null),en=Ze[0],nn=Ze[1],tn=r(!1),on=o(new Set),rn=on[0],ln=on[1],un=o([]),cn=un[0],dn=un[1],an=r(null),sn=r(!1),vn=r(null),pn=r({}),fn=r([]),gn=r(!1),hn=r(!1),xn=r(null),mn=r(function(){}),yn=l(function(){return(null==me?void 0:me.cognitive_decisioning)||{}},[me]),bn=o({width:0,height:0}),Sn=bn[0],Rn=bn[1],Cn=l(function(){return e(e({},w),Re)},[Re]),In=r(null),wn=r(null),Bn=r(null),Tn=r(null),_n=r(null),En=r(null),Fn=r(null),Dn=r(null),kn=r(!1),Mn=r(null),Nn=r(null),An=A(In),Hn=An.cognitivePopup,Ln=An.setCognitivePopup,jn=An.moreFunctions,On=An.setMoreFunctions,Pn=An.position,zn=An.setPosition,Wn=An.activeBadgeId,Yn=An.summaryPopup,Kn=An.setSummaryPopup,qn=An.closeSummaryPopup,Vn=An.setActiveBadgeId,Xn=An.popupRef,Jn=An.closeCognitivePopup,Un=An.closeMoreFunctionsPopup,$n=l(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==ye?void 0:ye.fields)&&void 0!==e?e:B,thresholds:{high:null!==(t=null===(n=null==ye?void 0:ye.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:T.thresholds.high,medium:null!==(o=null===(i=null==ye?void 0:ye.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:T.thresholds.medium,exact:null!==(l=null===(r=null==ye?void 0:ye.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:T.thresholds.exact}}},[ye]),Gn=o(null),Qn=Gn[0];Gn[1];var Zn=null===(J=null===(V=null==me?void 0:me.documents)||void 0===V?void 0:V[null===(X=null==me?void 0:me.input_index_map)||void 0===X?void 0:X[0]])||void 0===J?void 0:J.title,et=null===(G=null===(U=null==me?void 0:me.documents)||void 0===U?void 0:U[null===($=null==me?void 0:me.input_index_map)||void 0===$?void 0:$[1]])||void 0===G?void 0:G.title,nt=m(be||Zn||"Uploaded Contract"),tt=m(Se||et||"Reference Template"),it=N(me,De,Te,$n,Ve),ot=it.activeProposed,rt=it.existingRule,lt=it.proposedSections,ut=it.existingSections,ct=it.visibleFields,dt=it.parentDeviationRecord,at=it.deviationNumberRegistry,st=it.parseError;u(function(){st&&We("Failed to load comparison: ".concat(st))},[st]);var vt=lt.length>0||ut.length>0,pt=H(ct.map(function(e){return e.key}),Math.max(lt.length,ut.length)),ft=pt.leftRefs,gt=pt.rightRefs,ht=pt.sectionLeftRefs,xt=pt.sectionRightRefs,mt=pt.lhsBadgeRefs,yt=pt.rhsBadgeRefs,bt=pt.sectionRightRowRefs,St=pt.subSectionLeftRefs,Rt=pt.subSectionRightRefs,Ct=pt.sectionRowRefs,It=pt.getSectionRowRef,wt=pt.getSubSectionRef,Bt=pt.getBadgeRef,Tt=rt.analysis,_t=m(null===(Z=null===(Q=null==Tt?void 0:Tt.rule_difference_comparison)||void 0===Q?void 0:Q.summary)||void 0===Z?void 0:Z.overall_summary),Et=!!_t.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Ft=null!==(ee=null==me?void 0:me.base_root_id)&&void 0!==ee?ee:"-1";null==me||me[Ft];var Dt=Ve?null!==(ve=null!==(de=Te&&(null===(ce=null==Te?void 0:Te[Ft])||void 0===ce?void 0:ce.evaluation_result))&&void 0!==de?de:null===(se=null===(ae=null==me?void 0:me.nodes)||void 0===ae?void 0:ae[Ft])||void 0===se?void 0:se.evaluation_result)&&void 0!==ve?ve:null:null!==(ue=null!==(ie=Te&&(null===(te=null===(ne=null==Te?void 0:Te[Ft])||void 0===ne?void 0:ne.evaluation_result)||void 0===te?void 0:te[0]))&&void 0!==ie?ie:null===(le=null===(re=null===(oe=null==me?void 0:me.nodes)||void 0===oe?void 0:oe[Ft])||void 0===re?void 0:re.evaluation_result)||void 0===le?void 0:le[0])&&void 0!==ue?ue:null,kt=y(Dt),Mt=b(null!==(ge=null===(fe=null===(pe=null==Dt?void 0:Dt.evaluation_outputs)||void 0===pe?void 0:pe.metadata)||void 0===fe?void 0:fe.label_color)&&void 0!==ge?ge:""),Nt=c(function(){var e,n,t,i,o,r;qe(!1),hn.current=!1;var l=xn.current,u=Xt.current;if(null!==l)if("string"==typeof l&&l.includes(S)){var c=l.split(S);(d=(null===(e=St.current[c[2]])||void 0===e?void 0:e.current)||(null===(n=ht.current[Number(c[2])])||void 0===n?void 0:n.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(t=ht.current[l])||void 0===t?void 0:t.current)&&(d.style.paddingTop="0px")}if(null!==u)if("string"==typeof u&&u.includes(S)){c=u.split(S);(a=(null===(i=Rt.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=xt.current[Number(c[3])])||void 0===o?void 0:o.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(r=xt.current[u])||void 0===r?void 0:r.current)&&(a.style.paddingTop="0px")}nn(null),xn.current=null,Xt.current=null,Ue(!1),Oe(!1),Tn.current&&(Tn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px"),En.current&&(En.current.style.height="0px"),Fn.current&&(Fn.current.style.height="0px")},[]),At=L({maintainRelativeOrder:!!De,proposedSections:lt,existingSections:ut,activeSideBySideSection:en,connectedSections:rn,resetSideBySide:Nt,setConnectedSections:ln,setConnectedLines:dn,cachedConnectedPositions:fn,svgContainerRef:an,isAnimatingRef:sn,animationTimerRef:vn,calculateLinesRef:mn,sectionLeftRefs:ht,sectionRightRefs:xt,subSectionLeftRefs:St,subSectionRightRefs:Rt}),Ht=At.expandedSections,Lt=At.expandedSubSections,jt=At.setExpandedSubSections,Ot=At.toggleSection,Pt=c(function(n,t,i,o,r,l,u){var c,d,a,s=m(null==t?void 0:t.id)||m(null==i?void 0:i.id)||"",v=(s?yn[s]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:s,decisioning:[],gap:[],relevance_score:0},p=null!==(d=null===(c=Ct.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null;return{isLoading:null!==(a=null==Ie?void 0:Ie.isLoading)&&void 0!==a&&a,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:v,anchorEl:n,sectionAnchorEl:p,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==me?void 0:me.documents,input_index_map:null==me?void 0:me.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,u=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[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 t?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(S)))return u(l);var c=o.split(S)[1];if(!c)return l;var d=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},a=(null===(n=null==d?void 0:d.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==d?void 0:d.deviations)||void 0===r?void 0:r[c])||null;return a?e(e(e({},d),a),{deviation_summary:(null==a?void 0:a.deviation_summary)||(null==d?void 0:d.deviation_summary),deviation_title:(null==a?void 0:a.deviation_title)||(null==d?void 0:d.deviation_title),deviation_impact:(null==a?void 0:a.deviation_impact)||(null==d?void 0:d.deviation_impact),deviation_explanation:(null==a?void 0:a.deviation_explanation)||(null==d?void 0:d.deviation_explanation),evaluation_outputs:(null==a?void 0:a.evaluation_outputs)||(null==d?void 0:d.evaluation_outputs),cognitive_decisioning:(null==a?void 0:a.cognitive_decisioning)||(null==d?void 0:d.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[yn,me]),zt=c(function(e){Un(),zn(null),Ln(e)},[Un]),Wt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),jn.open&&jn.sectionIdx===o)Un();else{var u=e.currentTarget,c="left";(null===(l=Bn.current)||void 0===l?void 0:l.contains(u))&&(c="right");hn.current&&Nt(),ln(new Set),dn([]),fn.current=[],Jn(),Yn.open?hi():qn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(S)){var r=o.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===c?null===(e=yt.current[l])||void 0===e?void 0:e.current:null===(n=mt.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(t=yt.current[o])||void 0===t?void 0:t.current:null===(i=mt.current[o])||void 0===i?void 0:i.current}()||u;On(Pt(e,n,i,o,t,r))})}},Yt=c(function(){null!==jn.sectionIdx&&jn.anchorEl?zt(e(e({},jn),{open:!0})):Un()},[jn,Un,zt]),Kt=c(function(){var e=jn.sectionIdx,n=jn.isOrphan;Un(),qn(),null!==e&&(n?We("No counterpart exists to connect to."):(hn.current&&Nt(),dn([]),fn.current=[],ln(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){mn.current&&mn.current()},50)))},[jn.sectionIdx,jn.isOrphan,Un,qn,Nt]),qt=r(null),Vt=r(null),Xt=r(null),Jt=r(null),Ut=r(null),$t=r(null),Gt=o([]),Qt=Gt[0],Zt=Gt[1];r(null);var ei=o(null),ni=ei[0],ti=ei[1];u(function(){if(Qn){var e=$n.fields.find(function(e){return e.analysisKey===Qn||e.key===Qn});if(e){var n=ft.current[e.key]||gt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Qn,$n.fields]);var ii=c(function(e){var n,t,i,o,r,l,u,c,d,a=null===(n=null==Tt?void 0:Tt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!a||!a[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=a[e],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var p=s.mappings[0]||{};return{score:s.score,relation:p.relation||"",highlightsA:(null===(l=p.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=p.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(c=s.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(d=s.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!v}},[Tt]),oi=c(function(n,t){var i,o,r,l,u,c,d;void 0===t&&(t="left");var a=null,s=null;if("left"===t)if(a=lt[n],De&&a){var v=ut.filter(function(e){var n;return null===(n=a.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});s=v.find(function(e){return e.evaluationResult})||v[0]}else s=ut[n];else if(s=ut[n],De&&s){var p=lt.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex)});a=p.find(function(e){return e.evaluationResult})||p[0]}else a=lt[n];var f=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,g=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,h=!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData));if(!f&&!g&&!h)return e(e({},b(_)),{label:"Not Defined"});var x=null!==(o=null!==(i=null==a?void 0:a.evaluationResult)&&void 0!==i?i:null==s?void 0:s.evaluationResult)&&void 0!==o?o:null,m=null===(r=null==x?void 0:x.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(c=null===(u=null===(l=null==x?void 0:x.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===u?void 0:u.label_color)&&void 0!==c?c:_;return e(e({},b(y)),null!=x?{label:null!==(d=m)&&void 0!==d?d:""}:{label:null})},[lt,ut,yn,$n,De]),ri=c(function(n){for(var t,i,o,r,l,u,c,d,a,s=n.split("-").map(Number),v=lt[s[0]],p=ut[s[0]],f=1;f<s.length;f++)(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]),(null==p?void 0:p.subsections)&&(p=p.subsections[s[f]]);if(!v&&!p)return null;var g=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,h=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,x=m(null==v?void 0:v.id)||m(null==p?void 0:p.id)||"",y=!(!(null==v?void 0:v.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!g&&!h&&!y)return e(e({},b(_)),{label:"Not Defined"});null!==(i=null!==(t=null==v?void 0:v.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||x&&(null===(o=yn[x])||void 0===o||o.relevance_score);var S=null!==(l=null!==(r=null==v?void 0:v.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,R=null===(u=null==S?void 0:S.evaluation_outputs)||void 0===u?void 0:u.output_value,C=null!==(a=null===(d=null===(c=null==S?void 0:S.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:_;return e(e({},b(C)),null!=S?{label:null!=R?R:""}:{label:null})},[lt,ut,yn,$n]),li=c(function(){var e,n,t,i,o,r,l,u,c,d,a,s,v,p,f,g,h,x,m,y,b,I;if(!kn.current&&!sn.current){kn.current=!0;try{if(!qt.current)return;var w=function(e){var n=e.split("-"),t=n[0];if(!Ht[t]&&!1===De)return!1;if(De&&!Ht["left-".concat(t)]&&!Ht["right-".concat(t)]&&!Ht[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!Lt[i])return!1;return!0},B=qt.current.getBoundingClientRect();Rn({width:B.width,height:B.height});var T=[];if(ct.forEach(function(e){var n,t,i=e.key,o=null===(n=ft.current[i])||void 0===n?void 0:n.current,r=null===(t=gt.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!sn.current){for(var _=0;_<Math.max(lt.length,ut.length);_++){var E=null===(e=ht.current[_])||void 0===e?void 0:e.current,F=null===(n=xt.current[_])||void 0===n?void 0:n.current;E&&(E.style.height="auto",E.style.minHeight="0px"),F&&(F.style.height="auto",F.style.minHeight="0px")}De||Object.keys(St.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=St.current[e])||void 0===n?void 0:n.current,o=null===(t=Rt.current[e])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var D={};ct.forEach(function(e){var n,t,i=e.key,o=null===(n=ft.current[i])||void 0===n?void 0:n.current,r=null===(t=gt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var k={left:{},right:{}},M={};if(!sn.current)if(De){if(Ke&&null!==en)if("number"==typeof en){var N=en,A=lt[N],H=null===(o=ht.current[N])||void 0===o?void 0:o.current;H&&A&&(A.refIndexes||[]).forEach(function(e){var n,t=ut.findIndex(function(n){return n.selfIndex===e}),i=null===(n=xt.current[t])||void 0===n?void 0:n.current;if(i&&(Ht["left-".concat(N)]||Ht["right-".concat(t)])){var o=Math.max(H.getBoundingClientRect().height,i.getBoundingClientRect().height);k.left[N]=Math.max(k.left[N]||0,o),k.right[t]=Math.max(k.right[t]||0,o)}})}else{var L=en.split(S)[2];if(L){E=null===(r=St.current[L])||void 0===r?void 0:r.current,F=null===(l=Rt.current[L])||void 0===l?void 0:l.current;if(E&&F){j=Math.max(E.getBoundingClientRect().height,F.getBoundingClientRect().height);M[L]=Math.max(M[L]||0,j)}}}}else{Object.keys(St.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=St.current[e])||void 0===n?void 0:n.current,o=null===(t=Rt.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);M[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(_=0;_<Math.min(lt.length,ut.length);_++){var E=null===(t=ht.current[_])||void 0===t?void 0:t.current,F=null===(i=xt.current[_])||void 0===i?void 0:i.current;if(E&&F){var j=Math.max(E.getBoundingClientRect().height,F.getBoundingClientRect().height);k.left[_]=j,k.right[_]=j}}}if(ct.forEach(function(e){var n,t,i=e.key,o=null===(n=ft.current[i])||void 0===n?void 0:n.current,r=null===(t=gt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),sn.current||(Object.entries(k.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ht.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(k.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=xt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),De||Object.keys(M).forEach(function(e){var n,t,i=null===(n=St.current[e])||void 0===n?void 0:n.current,o=null===(t=Rt.current[e])||void 0===t?void 0:t.current;if(i&&o&&M[e]){var r=M[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),De)lt.forEach(function(e,n){var t;(null===(t=ht.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,d,a,s,v=ut.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var p=null===(t=mt.current[n])||void 0===t?void 0:t.current,f=null===(i=yt.current[v])||void 0===i?void 0:i.current;if(p&&f){var g=p.getBoundingClientRect(),h=f.getBoundingClientRect(),x=g.right-B.left,m=h.left-B.left,y=g.top+g.height/2-B.top,b=h.top+h.height/2-B.top;if(Ke&&en===n){var S=null!==(r=null===(o=Dn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=Bn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(d=null===(c=Dn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==d?d:1/0),I=R+(null!==(s=null===(a=Bn.current)||void 0===a?void 0:a.clientHeight)&&void 0!==s?s:1/0),w=g.top+g.height/2,_=h.top+h.height/2,E=function(e,n,t){return Math.max(n,Math.min(t,e))};y=E(w,S,C)-B.top,b=E(_,R,I)-B.top}var F=oi(n);F&&T.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:F,sectionIdx:n,targetRightIdx:v})}}})});else{for(_=0;_<Math.min(lt.length,ut.length);_++){var O=null===(u=ht.current[_])||void 0===u?void 0:u.current,P=null===(c=xt.current[_])||void 0===c?void 0:c.current;if(O&&P){var z=O.getBoundingClientRect(),W=P.getBoundingClientRect(),Y=Math.max(z.top,W.top)+18-B.top,K=(null===(d=ut[_])||void 0===d?void 0:d.id)||"sec-".concat(_);(Q=oi(_))&&T.push({id:K,x1:z.right-B.left,y1:Y,x2:W.left-B.left,y2:Y,style:Q,sectionIdx:_,hasCognitive:!!((null===(a=lt[_])||void 0===a?void 0:a.cognitiveData)||(null===(s=ut[_])||void 0===s?void 0:s.cognitiveData)||K&&yn[K]),isSubSection:!1})}}Object.keys(St.current).forEach(function(e){var n,t,i,o,r,l;if(w(e)){var u=null===(n=St.current[e])||void 0===n?void 0:n.current,c=null===(t=Rt.current[e])||void 0===t?void 0:t.current;if(u&&c){for(var d=e.split("-").map(Number),a=lt[d[0]],s=ut[d[0]],v=1;v<d.length;v++)(null==a?void 0:a.subsections)&&(a=a.subsections[d[v]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[v]]);var p=!!a&&((null===(i=a.displayTitle)||void 0===i||i)&&R(a.title)),f=!!a&&((null===(o=a.displayContent)||void 0===o||o)&&R(a.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&R(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&R(s.content));if(p&&f||g&&h){var x=u.getBoundingClientRect(),m=c.getBoundingClientRect(),y=Math.max(x.top,m.top)+16-B.top,b=ri(e);b&&"Not Defined"!==b.label&&T.push({id:"subsec-".concat(e),x1:x.right-B.left,y1:y,x2:m.left-B.left,y2:y,style:b,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(Ke&&"string"==typeof en&&en.includes(S)){var q=en.split(S),V=q[0],X=q[1],J=q[2],U=(q[3],"".concat(V).concat(S).concat(X)),$=null===(v=mt.current[U])||void 0===v?void 0:v.current,G=null===(p=yt.current[U])||void 0===p?void 0:p.current;if($&&G){var Q,Z=$.getBoundingClientRect(),ee=G.getBoundingClientRect(),ne=Z.right-B.left,te=ee.left-B.left,ie=Z.top+Z.height/2-B.top,oe=ee.top+ee.height/2-B.top;if(De){var re=null!==(g=null===(f=Dn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,le=null!==(x=null===(h=Bn.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==x?x:0,ue=re+(null!==(y=null===(m=Dn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==y?y:1/0),ce=le+(null!==(I=null===(b=Bn.current)||void 0===b?void 0:b.clientHeight)&&void 0!==I?I:1/0),de=function(e,n,t){return Math.max(n,Math.min(t,e))};ie=de(Z.top+Z.height/2,re,ue)-B.top,oe=de(ee.top+ee.height/2,le,ce)-B.top}(Q=ri(J))&&T.push({id:"line-subsec-".concat(U),x1:ne,y1:ie,x2:te,y2:oe,style:Q,sectionIdx:Number(J.split("-")[0]),isSubSection:!0,subSectionKeyPath:en})}}if(Zt(T),Ut.current&&$t.current){var ae=Ut.current.getBoundingClientRect(),se=$t.current.getBoundingClientRect(),ve=(ae.top+ae.height/2-B.top+se.top+se.height/2-B.top)/2;ti({x1:ae.right-B.left,x2:se.left-B.left,y:ve})}else ti(null);if(rn.size>0){var pe=[],fe=Dn.current,ge=Bn.current;if(fe&&ge){var he=[],xe=fe.getBoundingClientRect().top,me=ge.getBoundingClientRect().top,ye=xe+fe.clientHeight,be=me+ge.clientHeight,Se=fe.scrollTop,Re=ge.scrollTop,Ce=B.top,Ie=function(e,n,t){return Math.max(n,Math.min(t,e))};rn.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(S)){var l=e.split(S),u=l[0],c=l[1],d=l[2],a=(l[3],"".concat(u).concat(S).concat(c)),s=null===(n=mt.current[a])||void 0===n?void 0:n.current,v=null===(t=yt.current[a])||void 0===t?void 0:t.current;if(!s||!v)return;var p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=ri(d),h=(A=p.right-B.left)+.5*((H=f.left-B.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,y=x-xe+Se,b=m-me+Re,R="conn-subsec-".concat(a);he.push({lhsScrollY:y,rhsScrollY:b,x1:A,x2:H,containerTop:Ce,leftIdx:e,rhsArrayIdx:e,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:R});var I=Ie(x,xe,ye),w=Ie(m,me,be),T=I-Ce,_=w-Ce,E=m>=me-4&&m<=be+4,F="";F=(L=x>=xe-4&&x<=ye+4)&&E?C(A,T,H,_):L&&!E?"M ".concat(A,",").concat(T," L ").concat(h,",").concat(T," L ").concat(h,",").concat(_):!L&&E?"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_," L ").concat(H,",").concat(_):"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_),pe.push({id:R,pathD:F,style:g,leftIdx:e,rhsArrayIdx:e})}else if(De){var D=e,k=lt[D];if(!(null===(r=null==k?void 0:k.refIndexes)||void 0===r?void 0:r.length))return;k.refIndexes.forEach(function(e){var n,t,i=ut.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=mt.current[D])||void 0===n?void 0:n.current,r=null===(t=yt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=oi(D),d=l.right-B.left,a=u.left-B.left-0,s=d+.5*(a-d),v=l.top+l.height/2,p=u.top+u.height/2,f=v-xe+Se,g=p-me+Re,h="conn-".concat(D,"-").concat(i);he.push({lhsScrollY:f,rhsScrollY:g,x1:d,x2:a,containerTop:Ce,leftIdx:D,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var x=Ie(v,xe,ye),m=Ie(p,me,be),y=x-Ce,b=m-Ce,S=v>=xe-4&&v<=ye+4,R=p>=me-4&&p<=be+4,I="";I=S&&R?C(d,y,a,b):S&&!R?"M ".concat(d,",").concat(y," L ").concat(s,",").concat(y," L ").concat(s,",").concat(b):!S&&R?"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b," L ").concat(a,",").concat(b):"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b),pe.push({id:h,pathD:I,style:c,leftIdx:D,rhsArrayIdx:i})}}})}else{var M=e,N=M;s=null===(i=mt.current[M])||void 0===i?void 0:i.current,v=null===(o=yt.current[N])||void 0===o?void 0:o.current;if(!s||!v)return;var A,H;p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=oi(M),h=(A=p.right-B.left)+.5*((H=f.left-B.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,y=x-xe+Se,b=m-me+Re,R="conn-".concat(M,"-").concat(N);he.push({lhsScrollY:y,rhsScrollY:b,x1:A,x2:H,containerTop:Ce,leftIdx:M,rhsArrayIdx:N,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:R});var L;I=Ie(x,xe,ye),w=Ie(m,me,be),T=I-Ce,_=w-Ce,E=m>=me-4&&m<=be+4,F="";F=(L=x>=xe-4&&x<=ye+4)&&E?C(A,T,H,_):L&&!E?"M ".concat(A,",").concat(T," L ").concat(h,",").concat(T," L ").concat(h,",").concat(_):!L&&E?"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_," L ").concat(H,",").concat(_):"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_),pe.push({id:R,pathD:F,style:g,leftIdx:M,rhsArrayIdx:N})}}),fn.current=he}dn(pe)}else dn([]),fn.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{kn.current=!1}}},[ct,lt,ut,yn,$n,ii,oi,De,Ke,en,rn,Ht,Lt]),ui=c(function(){var e,n,t,i,o,r,l,u,c,d,a,s,v,p,f=fn.current;if(f.length&&!sn.current){var g=null!==(n=null===(e=Dn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,h=null!==(i=null===(t=Bn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=Dn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(u=null===(l=Bn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(d=null===(c=Dn.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==d?d:0,b=null!==(s=null===(a=Bn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,R=b+m,I=null!==(p=null===(v=qt.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,w=function(e,n,t){return Math.max(n,Math.min(t,e))};f.forEach(function(e){var n=e.lhsScrollY-g+y,t=e.rhsScrollY-h+b,i=pn.current[e.styleId+"-stroke"],o=pn.current[e.styleId+"-bg"];if(i||o){var r,l=w(n,y,S),u=w(t,b,R),c=l-I,d=u-I,a=n>=y-4&&n<=S+4,s=t>=b-4&&t<=R+4,v=e.x1+.5*(e.x2-e.x1);r=a&&s?C(e.x1,c,e.x2,d):a&&!s?"M ".concat(e.x1,",").concat(c," L ").concat(v,",").concat(c," L ").concat(v,",").concat(d):!a&&s?"M ".concat(v,",").concat(c," L ").concat(v,",").concat(d," L ").concat(e.x2,",").concat(d):"M ".concat(v,",").concat(c," L ").concat(v,",").concat(d),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);u(function(){mn.current=li},[li]);var ci=r(null),di=r(null),ai=c(function(){fn.current.length>0&&!sn.current||(null!==ci.current&&clearTimeout(ci.current),ci.current=setTimeout(function(){mn.current(),ci.current=null},50))},[]),si=c(function(){Qe(!0),Ue(!1),null!==di.current&&clearTimeout(di.current),null!==ci.current&&(clearTimeout(ci.current),ci.current=null),di.current=setTimeout(function(){var e,n,t,i,o,r,l,u,c,d;if(fn.current=[],hn.current&&null!==xn.current&&null!==Xt.current){var a=xn.current,s=Xt.current,v=null,p=null,f=null,g=null;if("string"==typeof a&&a.includes(S)){var h=a.split(S),x="".concat(h[0]).concat(S).concat(h[1]);v=(null===(e=mt.current[x])||void 0===e?void 0:e.current)||null,p=(null===(n=yt.current[x])||void 0===n?void 0:n.current)||null,f=(null===(t=St.current[h[2]])||void 0===t?void 0:t.current)||(null===(i=ht.current[Number(h[2])])||void 0===i?void 0:i.current)||null,g=(null===(o=Rt.current[h[3]])||void 0===o?void 0:o.current)||(null===(r=xt.current[Number(h[3])])||void 0===r?void 0:r.current)||null}else v=(null===(l=Ct.current[a])||void 0===l?void 0:l.current)||null,f=(null===(u=ht.current[a])||void 0===u?void 0:u.current)||null,p=(null===(c=bt.current[s])||void 0===c?void 0:c.current)||null,g=(null===(d=xt.current[s])||void 0===d?void 0:d.current)||null;if(v&&p&&f&&g){if(f.style.paddingTop="0px",g.style.paddingTop="0px",!De){var m=v.getBoundingClientRect(),y=p.getBoundingClientRect(),b=m.top-y.top;b>0?g.style.paddingTop="".concat(b,"px"):b<0&&(f.style.paddingTop="".concat(Math.abs(b),"px"))}var R=Dn.current,C=Bn.current;if(R&&C){var I=v.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,w=p.getBoundingClientRect().top-C.getBoundingClientRect().top+C.scrollTop-(I-R.scrollTop);Math.abs(C.scrollTop-w)>1&&(C.scrollTop=w)}}}mn.current(),hn.current&&Ue(!0),Qe(!1),di.current=null},150)},[De,lt,ut]),vi=c(function(e){var n,t,i,o,r,l,u,c,d,a;if(null!==Mn.current&&Nn.current&&Math.abs(e.currentTarget.scrollTop-Mn.current)<=2){var s=Nn.current;Mn.current=null,Nn.current=null,s()}if(!tn.current){if(De||ai(),hn.current){var v=xn.current,p=Xt.current,f=Dn.current,g=Bn.current;if(null!==v&&null!==p&&f&&g){var h="string"==typeof v&&v.includes(S)?null===(n=mt.current["".concat(v.split(S)[0]).concat(S).concat(v.split(S)[1])])||void 0===n?void 0:n.current:null===(t=Ct.current[v])||void 0===t?void 0:t.current,x="string"==typeof p&&p.includes(S)?null===(i=yt.current["".concat(p.split(S)[0]).concat(S).concat(p.split(S)[1])])||void 0===i?void 0:i.current:null===(o=bt.current[p])||void 0===o?void 0:o.current;if(h&&x&&Jt.current){var m=void 0,y=void 0;if("string"==typeof v&&v.includes(S)){var b=v.split(S),R="".concat(b[0]).concat(S).concat(b[1]);m=null===(r=mt.current[R])||void 0===r?void 0:r.current,y=null===(l=yt.current[R])||void 0===l?void 0:l.current}else m=null===(u=mt.current[v])||void 0===u?void 0:u.current,y=null===(c=yt.current[p])||void 0===c?void 0:c.current;var C=null!==(a=null===(d=qt.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==a?a:0,I=f.getBoundingClientRect().top,w=I+f.clientHeight;g.getBoundingClientRect().top;g.clientHeight;if(m&&y){var B=m.getBoundingClientRect(),T=y.getBoundingClientRect(),_=B.top+B.height/2;T.top,T.height;var E=((D=_,k=I,M=w,Math.max(k,Math.min(M,D)))-C).toString();Jt.current.setAttribute("y1",E),Jt.current.setAttribute("y2",E);var F=_>=I-4&&_<=w+4;Jt.current.setAttribute("visibility",F?"visible":"hidden")}}}}var D,k,M;fn.current.length>0&&!gn.current&&(gn.current=!0,requestAnimationFrame(function(){ui(),gn.current=!1}))}},[ui,De,ai]);u(function(){var e=setTimeout(ai,250);window.addEventListener("resize",si);var n=null,t=null;return In.current&&(n=new ResizeObserver(ai)).observe(In.current),qt.current&&(t=new ResizeObserver(ai)).observe(qt.current),function(){clearTimeout(e),null!==ci.current&&clearTimeout(ci.current),null!==di.current&&clearTimeout(di.current),window.removeEventListener("resize",si),null==n||n.disconnect(),null==t||t.disconnect()}},[ot,rt,Tt,ct,Ht,Lt,lt,ut,$n,ai,si,Ke,en,Je,rn]),u(function(){hn.current=Ke},[Ke]),u(function(){xn.current=en},[en]);var pi=c(function(e,n,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,u=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";Un(),null!=e&&(n?We("No counterpart exists for this section."):Ke&&en===e?r?Nt():null==l||l():(ln(new Set([e])),dn([]),fn.current=[],Oe(!0),tn.current=!0,nn(e),xn.current=e,qe(!0),hn.current=!0,Ue(!1),Tn.current&&(Tn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px"),En.current&&(En.current.style.height="0px"),Fn.current&&(Fn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,c="string"==typeof e&&e.includes(S),d=null,a=null,s=null;if(c){var v=e.split(S),p="".concat(v[0]).concat(S).concat(v[1]);d=(null===(n=mt.current[p])||void 0===n?void 0:n.current)||null,a=(null===(t=yt.current[p])||void 0===t?void 0:t.current)||null,s=a?e:null}else if(d=(null===(i=Ct.current[e])||void 0===i?void 0:i.current)||null,De){var f=lt[e],g=(null==f?void 0:f.refIndexes)||[];if(g.length>0){var h=g[0],x=ut.findIndex(function(e){return e.selfIndex===h});-1!==x&&(a=(null===(r=bt.current[x])||void 0===r?void 0:r.current)||null,s=x)}}else a=(null===(o=bt.current[e])||void 0===o?void 0:o.current)||null,s=a?e:null;Xt.current=s;var m=Dn.current,y=Bn.current,b=function(){!function(){var n,t,i,o,r,l,u,d,a,v,p,f,g=null,h=null,x=null,m=null;if(c){var y=e.split(S),b="".concat(y[0]).concat(S).concat(y[1]);g=(null===(n=St.current[y[2]])||void 0===n?void 0:n.current)||(null===(t=ht.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=Rt.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=xt.current[Number(y[3])])||void 0===o?void 0:o.current)||null,x=(null===(r=mt.current[b])||void 0===r?void 0:r.current)||g,m=(null===(l=yt.current[b])||void 0===l?void 0:l.current)||h}else{var R=Number(e),C=null!==s?Number(s):R;g=(null===(u=ht.current[R])||void 0===u?void 0:u.current)||null,h=(null===(d=xt.current[C])||void 0===d?void 0:d.current)||null,x=(null===(a=mt.current[R])||void 0===a?void 0:a.current)||(null===(v=Ct.current[R])||void 0===v?void 0:v.current)||g,m=(null===(p=yt.current[C])||void 0===p?void 0:p.current)||(null===(f=bt.current[C])||void 0===f?void 0:f.current)||h}if(x&&m&&g&&h){g.style.paddingTop="0px",h.style.paddingTop="0px";var I=x.getBoundingClientRect(),w=m.getBoundingClientRect(),B=I.top-w.top;B>0?h.style.paddingTop="".concat(B,"px"):B<0&&(g.style.paddingTop="".concat(Math.abs(B),"px"))}}(),Ue(!0),mn.current&&mn.current(),tn.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),Oe(!1),null==l||l()};if(!d||!m)return tn.current=!1,Oe(!1),void(null==l||l());if(a&&y){if(!De){var R=0;R="right"===u?a?a.getBoundingClientRect().top:0:d?d.getBoundingClientRect().top:0;var C=In.current,w=(null==C?void 0:C.getBoundingClientRect().top)||0,B=C?C.scrollTop+R-w-150:0;return C?void I(C,B,200,b):void b()}var T=d.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,_=a.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,E=200;if("left"===u){var F=_-(T-m.scrollTop);F<0&&Tn.current&&(Tn.current.style.height="".concat(Math.abs(F),"px")),requestAnimationFrame(function(){var e,n=y.scrollHeight-y.clientHeight;if(F<0)e=0;else{if(F>n){var t=F-n;return _n.current&&(_n.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){I(y,F,E,b)})}e=F}I(y,e,E,b)})}else{var D=T-(_-y.scrollTop);D<0&&En.current&&(En.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=m.scrollHeight-m.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return Fn.current&&(Fn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){I(m,D,E,b)})}e=D}I(m,e,E,b)})}}else b()})))},[en,Un,ut,Ke,De,lt,Nt]),fi=c(function(e,n,t,i){var o,r="string"==typeof i?m(i).trim():m(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;Jn();var u="left";(null===(o=Bn.current)||void 0===o?void 0:o.contains(l))&&(u="right");var c=function(){var e,t,i,o;if("string"==typeof n&&n.includes(S)){var r=n.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===u?null===(e=yt.current[l])||void 0===e?void 0:e.current:null===(t=mt.current[l])||void 0===t?void 0:t.current}return"right"===u?null===(i=yt.current[n])||void 0===i?void 0:i.current:null===(o=mt.current[n])||void 0===o?void 0:o.current};if(t)return Nt(),ln(new Set),dn([]),fn.current=[],void(r&&requestAnimationFrame(function(){var e=c()||l;Kn({open:!0,anchorEl:e,summary:i})}));pi(n,t,r?{toggleIfSame:!1,sourceSide:u,onReady:function(){var e=c()||l;Kn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:u})},[pi,Jn,Kn,Nt]),gi=c(function(){var e,n=jn.sectionIdx,t=jn.isOrphan;if(qn(),null!=n){var i="left";jn.anchorEl&&(null===(e=Bn.current)||void 0===e?void 0:e.contains(jn.anchorEl))&&(i="right"),pi(n,t,{sourceSide:i})}},[pi,jn.isOrphan,jn.sectionIdx,jn.anchorEl,qn]),hi=c(function(){qn(),Nt(),ln(new Set),dn([]),fn.current=[]},[qn,Nt]),xi=null!==jn.sectionIdx&&rn.has(jn.sectionIdx),mi=j({proposedSections:lt,existingSections:ut,parentDeviationRecord:dt,expandedSections:Ht,maintainRelativeOrder:!!De,scrollContainerRef:In,leftContainerRef:Dn,lhsBadgeRefs:mt,rhsBadgeRefs:yt}),yi=mi.showDeviationNavigation,bi=mi.showOpenNodeRef,Si=l(function(){if(!_e)return null;var e=_e.split(":")[0];for(var n in dt){if((dt[n]||[]).some(function(n){return n.id===e}))return n}return null},[_e,dt]),Ri=r(null),Ci=r(null);u(function(){if(_e&&Ri.current!==_e){var t=_e.split(":"),i=t[0],o=t[1],r=null!=o?o:"0";Ci.current!==_e&&(qn(),Jn(),Nt(),ln(new Set),dn([]),fn.current=[],Ci.current=_e);var l=!1,u=0,c=null,d=150,a=function(e,n){for(var t=function(e,i){if(!e)return null;if(e.id===n)return i;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=t(e.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<e.length;i++){var o=t(e[i],String(i));if(o)return o}return null},s=function(){var t,o,v,p;if(!l){var f=null,g=null;for(var h in dt){var x=dt[h].find(function(e){return e.id===i});if(x){f=h,g=x;break}}if(g&&f){var m=lt.findIndex(function(e){return e.id===f}),y=ut.findIndex(function(e){return e.id===f}),b=-1===m&&-1!==y,R=a(lt,g.id),C=a(ut,g.id);if(R&&!C&&!b){var I=R.split("-"),w=Number(I[0]);if(De){var B=null===(o=null===(t=lt[w])||void 0===t?void 0:t.refIndexes)||void 0===o?void 0:o[0],T=ut.findIndex(function(e){return e.selfIndex===B});-1!==T&&(w=T)}C=n([w],I.slice(1),!0).join("-")}if(R||C){var _=b||!R&&!!C,E=R?Number(R.split("-")[0]):m,F=C?Number(C.split("-")[0]):y;if(_){if(!(De?!!Ht["right-".concat(F)]:!!Ht[String(F)])&&F>=0)return Ot(F,"right"),u+=1,void(c=setTimeout(s,450))}else if(!(De?!!Ht["left-".concat(E)]:!!Ht[String(E)])&&E>=0)return Ot(E,"left"),u+=1,void(c=setTimeout(s,450));var D,k=R||"",M=C||"",N="".concat(g.id).concat(S).concat(r).concat(S).concat(k).concat(S).concat(M),A="".concat(g.id).concat(S).concat(r),H=null===(v=mt.current[A])||void 0===v?void 0:v.current,L=null===(p=yt.current[A])||void 0===p?void 0:p.current,j=_||!H&&!!L,O=j?L:H;if(D=De?j?Bn.current:Dn.current:In.current,O&&D){var P=O.getBoundingClientRect();if(0===P.height)return void((u+=1)<20&&(c=setTimeout(s,d)));var z=D.getBoundingClientRect(),W=P.top-z.top+D.scrollTop-z.height/2+P.height/2,Y=function(){var n,t,i,o,u;if(!l){Ri.current=_e;var c=window.getComputedStyle(O).color;H&&(H.style.transition="box-shadow 300ms ease-in-out",H.style.boxShadow="0 0 10px ".concat(c)),L&&(L.style.transition="box-shadow 300ms ease-in-out",L.style.boxShadow="0 0 10px ".concat(c)),setTimeout(function(){H&&(H.style.boxShadow=""),L&&(L.style.boxShadow="")},2e3);var d=(null===(t=null===(n=g.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[r])||g,a=(null===(i=g.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||g.evaluation_outputs;if(!(!!H&&!!L)){var s=j?(null===(o=yt.current[A])||void 0===o?void 0:o.current)||L:(null===(u=mt.current[A])||void 0===u?void 0:u.current)||H;return Kn({open:!0,anchorEl:s,summary:e(e({},d),{evaluation_outputs:a})}),void(null==Ee||Ee())}pi(N,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=mt.current[A])||void 0===n?void 0:n.current)||H;Kn({open:!0,anchorEl:t,summary:e(e({},d),{evaluation_outputs:a})})}})}};Math.abs(D.scrollTop-W)<=2?Y():(Mn.current=W,Nn.current=Y,D.scrollTo({top:W,behavior:"smooth"}),c&&clearTimeout(c),c=setTimeout(function(){if(Nn.current){Mn.current=null;var e=Nn.current;Nn.current=null,e()}},800))}else(u+=1)<20&&(c=setTimeout(s,d))}else(u+=1)<20&&(c=setTimeout(s,d))}else(u+=1)<20&&(c=setTimeout(s,d))}};return c=setTimeout(s,d),function(){l=!0,c&&clearTimeout(c)}}},[_e,dt,lt,ut,De,Ht,Ot,pi,Kn]);var Ii=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,c=e.parentNodeId;return i(z,{section:n,keyPath:t,depth:r,columnKey:u,parentNodeId:void 0===c?"":c,expandedSubSections:Lt,setExpandedSubSections:jt,maintainRelativeOrder:De||!1,proposedSections:lt,existingSections:ut,treeData:me,deviationNumberRegistry:at,connectedSections:rn,activeSideBySideSection:en,resolvedMarkdownStyles:Cn,getSubSectionRef:wt,getSubSectionCompareStyle:ri,getBadgeRef:Bt,openMoreFunctionsPopup:Wt,openSummaryPopup:fi,showDeviationBadges:Me,resetSideBySide:Nt,setConnectedSections:ln,setConnectedLines:dn,cachedConnectedPositions:fn})};return t(d,e({ref:wn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},De?{}:{overflow:"visible"}),{position:"relative"})},{children:[Ae&&i(d,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(k,{})})),Yn.open&&i(W,{open:Yn.open,anchorEl:Yn.anchorEl,containerEl:Vt.current,clipTopEl:Ut.current,scrollContainerEl:In.current,onClose:hi,summary:Yn.summary}),i(D,{open:jn.open,anchorEl:jn.anchorEl,sectionTitle:jn.sectionTitle,referenceSectionTitle:jn.refSectionTitle,onClose:Un,onOpenCognitiveCompare:Yt,onOpenSideBySide:gi,onConnect:Kt,isConnected:xi,isOrphan:jn.isOrphan}),Hn.open&&i(F,{open:Hn.open,popupRef:Xn,position:Pn,popupConfig:we,onClose:function(){zn(null),Ln(function(n){return e(e({},n),{open:!1})}),Vn(null)},markdownStyles:Re,sectionTitle:Hn.sectionTitle,referenceSectionTitle:Hn.refSectionTitle,cognitiveData:Hn.cognitiveData,anchorEl:Hn.anchorEl,sectionAnchorEl:Hn.sectionAnchorEl,scrollContainerEl:In.current,badgeStyle:Hn.badgeStyle,docData:Hn.docData,deviationData:Hn.deviationData,isLoading:Hn.isLoading}),i(a,e({open:!!ze,autoHideDuration:8e3,onClose:function(){return We(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,e({onClose:function(){return We(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ze}))})),i(O,{componentHeaderText:xe,displayConfig:Ie,maintainRelativeOrder:De,onToggleView:function(e){He(!0),setTimeout(function(){ke(!e),Nt(),qn(),ln(new Set),dn([]),fn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){He(!1)},600)})})},50)}}),i(d,e({ref:In,onScroll:vi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:De?"hidden":"auto",borderTop:_t&&Et?"none":"1.5px solid #EEF0F4"}},{children:i(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},De?{flex:1,minHeight:0}:{})},{children:t(d,e({ref:qt,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},De?{flex:1,overflow:"visible"}:{})},{children:[t("svg",e({ref:an,style:{position:"absolute",top:0,left:0,width:Sn.width||"100%",height:Sn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Ge?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[ni&&i("g",{children:i("line",{x1:ni.x1,y1:ni.y,x2:ni.x2,y2:ni.y,stroke:Mt.badgeBorder,strokeWidth:"1.5"})}),Qt.map(function(n){var o,r,l,u,c,a,s=n.x1+.5*(n.x2-n.x1),v=(n.y1+n.y2)/2;if("Not Defined"===n.style.label&&!n.hasCognitive)return null;if(n.isSubSection?Ke&&en===n.subSectionKeyPath&&Je:Ke&&en===n.sectionIdx&&Je)return null;if(!De){var p=n.isSubSection?C(n.x1,n.y1,n.x2,n.y2):"M ".concat(n.x1," ").concat(n.y1," L ").concat(n.x2," ").concat(n.y2),g=lt[n.sectionIdx]||{title:"",content:""},x=ut[n.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",g,x),n.isSubSection&&n.subSectionKeyPath){var m=n.subSectionKeyPath.includes(S)?n.subSectionKeyPath.split(S):[],y=m[2]||n.subSectionKeyPath,b=m[3]||y,R=y.split("-").map(Number),I=b.split("-").map(Number),w=null,B=null;R.length>0&&(w=lt[R[0]]),I.length>0&&(B=ut[I[0]]);var T=(null==w?void 0:w.title)||"",E=(null==B?void 0:B.title)||"";console.log("Root Parent Titles:",T,E);for(var F=1;F<R.length;F++)(null==w?void 0:w.subsections)&&(w=w.subsections[R[F]]);for(F=1;F<I.length;F++)(null==B?void 0:B.subsections)&&(B=B.subsections[I[F]]);w&&(g=e(e({},w),{title:T||w.title})),console.log("Base Section for Subsection Badge:",g),B&&(x=e(e({},B),{title:E||B.title})),console.log("Ref Section for Subsection Badge:",x)}var D=!(null===(o=g.cognitiveData)||void 0===o?void 0:o.isMissingRationale)||Boolean(null===(l=null===(r=g.cognitiveData)||void 0===r?void 0:r.decisioning)||void 0===l?void 0:l.length),k=(null===(a=null===(c=null===(u=g.evaluationResult)||void 0===u?void 0:u.cognitive_decisioning)||void 0===c?void 0:c.decisioning_factors)||void 0===a?void 0:a.length)||!1,N=D||k;return t("g",{children:[i("path",{d:p,fill:"none",stroke:n.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",e({x:s-100,y:v-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,e({onClick:function(e){e.stopPropagation(),N&&(Hn.open&&Wn===n.id?Jn():(Vn(n.id),zt(Pt(e.currentTarget,g,x,n.sectionIdx,n.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:N?"pointer":"default"}},{children:[n.style.badgeText===_&&null==n.style.label?i(M,{color:n.style.badgeText}):0===n.style.label?"Same":n.style.label,i(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),N&&i(f,{size:11,style:{transform:Hn.open&&Wn===n.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},n.id)}return null}),cn.map(function(n){var o,r=n.pathD,l=(null===(o=n.style)||void 0===o?void 0:o.badgeBorder)||"#6366F1",u="conn-marker-".concat(n.id),c="".concat(n.id,"-bg"),d="".concat(n.id,"-stroke");return t("g",{children:[i("defs",{children:i("clipPath",e({id:"connections-clip"},{children:i("marker",e({id:u,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:i("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),i("path",{ref:function(e){pn.current[c]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(e){pn.current[d]=e},d:r,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(u,")")})]},n.id)})]})),t(d,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)"},De?{flex:1,overflow:"visible"}:{})},{children:[i(d,e({ref:Ut,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:nt,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:nt}))}))})),t(d,e({ref:Dn,onScroll:vi,sx:e({p:"12px",display:"flex",flexDirection:"column"},De?{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:En,style:{width:"100%",height:"0px",flexShrink:0}}),vt&<.map(function(n,o){var r,l,u=!n.title&&!n.content;if(De&&u)return null;var c=n,a=oi(o,"left"),s=De?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!ut[o],v=De?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:o+1,p=rn.has(o),f=y(c.evaluationResult,null==a?void 0:a.deviationLabel);return i(d,e({ref:It(o),sx:{mb:1,width:"100%"}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[i(d,e({ref:ht.current[o],sx:e({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(P,{section:n,idx:o,columnKey:"left",colRef:It("left-accordion-".concat(o)),mb:0,treeData:me,proposedSections:lt,existingSections:ut,deviationNumberRegistry:at,getSectionCompareStyle:oi,getBadgeRef:Bt,connectedSections:rn,openMoreFunctionsPopup:Wt,openSummaryPopup:fi,deviationNodeIdToView:_e,deviationTargetParentId:Si,parentNodeId:(null===(l=null==me?void 0:me.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:De?!!Ht["left-".concat(o)]:!!Ht[String(o)],onToggle:function(){hi(),Ot(o,"left")},navigation:n.id?yi[n.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:Cn,maintainRelativeOrder:De,showDeviationBadges:Me,renderSubSections:Ii})})),De&&a&&t(d,e({ref:mt.current[o],onClick:function(e){var t=De?ut.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:ut[o]||{title:"",content:""};Wt(e,n,s,t,o,a)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&i(d,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:v})),i(d,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!Ie.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?s?"No Deviation Found":"N/A"===f||"NA"===f?"N/A":0==f||null==f?"Same":"".concat(f):i(M,{color:a.badgeText})})),i(g,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))}),i("div",{ref:Fn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,e({ref:Vt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,e({onClick:function(n){n.stopPropagation(),Hn.open&&Wn===Ft?Jn():(Vn(Ft),zt(Pt(n.currentTarget,{title:"",content:"",evaluationResult:Dt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Ft,!0,e(e({},Mt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:Mt.badgeBg,color:Mt.badgeText,border:"1px solid ".concat(Mt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=kt?kt:i(M,{}),i(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(f,{size:11,style:{transform:Hn.open&&Wn===Ft?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(d,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},De?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[je&&i(x,{sections:11}),i(d,e({ref:$t,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:tt,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:tt}))}))})),t(d,e({ref:Bn,onScroll:vi,sx:e({p:"12px",display:"flex",flexDirection:"column"},De?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:Tn,style:{width:"100%",height:"0px",flexShrink:0}}),vt&&ut.map(function(n,o){var r,l=n,u=[],c=!1,a=null,s=-1;if(De){u=lt.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=lt.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var v=lt.findIndex(function(e,n){var t;return rn.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==v)&&(a=oi(v))}else u=[o+1],(c=rn.has(o))&&(a=oi(o));var p=oi(De&&-1!==s?s:o);return i(d,e({ref:bt.current[o],sx:{mb:1,width:"100%"}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[i(d,e({ref:xt.current[o],sx:e({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:i(P,{section:n,idx:o,columnKey:"right",colRef:It("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==me?void 0:me.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:De?!!Ht["right-".concat(o)]:!!Ht[String(o)],treeData:me,proposedSections:lt,existingSections:ut,deviationNumberRegistry:at,getBadgeRef:Bt,getSectionCompareStyle:oi,connectedSections:rn,openMoreFunctionsPopup:Wt,openSummaryPopup:fi,deviationNodeIdToView:_e,deviationTargetParentId:Si,onToggle:function(){hi(),Ot(o,"right")},navigation:n.id?yi[n.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:Cn,maintainRelativeOrder:De,showDeviationBadges:Me,renderSubSections:Ii})})),De&&p&&i(d,e({ref:yt.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:p.badgeBg,color:p.badgeText,border:"1px solid ".concat(p.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),i("div",{ref:_n,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Y as default};
|
|
1
|
+
import{__assign as n,__spreadArray as e}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as c}from"react";import{Box as d,Snackbar as a,Alert as s,Tooltip as v,Typography as p}from"@mui/material";import{ChevronDown as f,EllipsisVertical as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import x from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as y,generateColorPalette as b,DEVIATION_BADGE_SEPARATOR as S,hasValue as R,getBentArrowPath as C,smoothScrollTo as B}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as w,DEFAULT_FIELD_CONFIG as I,DEFAULT_COMPARISON_CONFIG as T}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as _,DEFAULT_COMPONENT_HEADER_TEXT as E}from"./CognitiveCompareConstants.js";import F from"./CognitivePopup.js";import D from"./MoreFunctionsPopup.js";import k from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as A}from"./hooks/useCompareData.js";import{useComparePopups as N}from"./hooks/useComparePopups.js";import{useSectionRefs as H}from"./hooks/useSectionRefs.js";import{useAccordionState as L}from"./hooks/useAccordionState.js";import{useDeviationNavigation as j}from"./hooks/useDeviationNavigation.js";import P from"./components/CompareHeader.js";import O from"./components/SectionAccordion.js";import z from"./components/SubSectionAccordion.js";import W from"./components/CognitiveSummaryPopup.js";var Y=function(Y){var K,q,V,X,J,U,$,G,Q,Z,nn,en,tn,on,rn,ln,un,cn,dn,an,sn,vn,pn,fn,gn,hn,xn=Y.componentHeaderText,mn=void 0===xn?E:xn,yn=Y.treeData,bn=Y.comparisonConfig,Sn=Y.leftColumnTitleText,Rn=Y.rightColumnTitleText,Cn=Y.markdownStyles,Bn=Y.displayConfig,wn=void 0===Bn?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:Bn,In=Y.popupConfig,Tn=Y.deviationData,_n=void 0===Tn?{}:Tn,En=Y.deviationNodeIdToView,Fn=Y.resetDeviationNodeId,Dn=o(wn.maintainRelativeOrder),kn=Dn[0],Mn=Dn[1],An=!!kn||!!(null==wn?void 0:wn.showDeviationBadges),Nn=o(!1),Hn=Nn[0],Ln=Nn[1],jn=o(!1),Pn=jn[0],On=jn[1],zn=o(null),Wn=zn[0],Yn=zn[1],Kn=o(!1),qn=Kn[0],Vn=Kn[1],Xn=o(null===(q=null!==(K=null==yn?void 0:yn.newEvaluationResult)&&void 0!==K?K:null==wn?void 0:wn.enableDeviationSchemaBackwardCompatibility)||void 0===q||q)[0],Jn=o(!1),Un=Jn[0],$n=Jn[1],Gn=o(!1),Qn=Gn[0],Zn=Gn[1],ne=o(null),ee=ne[0],te=ne[1],ie=r(!1),oe=o(new Set),re=oe[0],le=oe[1],ue=o([]),ce=ue[0],de=ue[1],ae=r(null),se=r(!1),ve=r(null),pe=r({}),fe=r([]),ge=r(!1),he=r(!1),xe=r(null),me=r(function(){}),ye=l(function(){return(null==yn?void 0:yn.cognitive_decisioning)||{}},[yn]),be=o({width:0,height:0}),Se=be[0],Re=be[1],Ce=l(function(){return n(n({},w),Cn)},[Cn]),Be=r(null),we=r(null),Ie=r(null),Te=r(null),_e=r(null),Ee=r(null),Fe=r(null),De=r(null),ke=r(!1),Me=r(null),Ae=r(null),Ne=N(Be),He=Ne.cognitivePopup,Le=Ne.setCognitivePopup,je=Ne.moreFunctions,Pe=Ne.setMoreFunctions,Oe=Ne.position,ze=Ne.setPosition,We=Ne.activeBadgeId,Ye=Ne.summaryPopup,Ke=Ne.setSummaryPopup,qe=Ne.closeSummaryPopup,Ve=Ne.setActiveBadgeId,Xe=Ne.popupRef,Je=Ne.closeCognitivePopup,Ue=Ne.closeMoreFunctionsPopup,$e=l(function(){var n,e,t,i,o,r,l;return{fields:null!==(n=null==bn?void 0:bn.fields)&&void 0!==n?n:I,thresholds:{high:null!==(t=null===(e=null==bn?void 0:bn.thresholds)||void 0===e?void 0:e.high)&&void 0!==t?t:T.thresholds.high,medium:null!==(o=null===(i=null==bn?void 0:bn.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:T.thresholds.medium,exact:null!==(l=null===(r=null==bn?void 0:bn.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:T.thresholds.exact}}},[bn]),Ge=o(null),Qe=Ge[0];Ge[1];var Ze=null===(J=null===(V=null==yn?void 0:yn.documents)||void 0===V?void 0:V[null===(X=null==yn?void 0:yn.input_index_map)||void 0===X?void 0:X[0]])||void 0===J?void 0:J.title,nt=null===(G=null===(U=null==yn?void 0:yn.documents)||void 0===U?void 0:U[null===($=null==yn?void 0:yn.input_index_map)||void 0===$?void 0:$[1]])||void 0===G?void 0:G.title,et=m(Sn||Ze||"Uploaded Contract"),tt=m(Rn||nt||"Reference Template"),it=A(yn,kn,_n,$e,Xn),ot=it.activeProposed,rt=it.existingRule,lt=it.proposedSections,ut=it.existingSections,ct=it.visibleFields,dt=it.parentDeviationRecord,at=it.deviationNumberRegistry,st=it.parseError;u(function(){st&&Yn("Failed to load comparison: ".concat(st))},[st]);var vt=lt.length>0||ut.length>0,pt=H(ct.map(function(n){return n.key}),Math.max(lt.length,ut.length)),ft=pt.leftRefs,gt=pt.rightRefs,ht=pt.sectionLeftRefs,xt=pt.sectionRightRefs,mt=pt.lhsBadgeRefs,yt=pt.rhsBadgeRefs,bt=pt.sectionRightRowRefs,St=pt.subSectionLeftRefs,Rt=pt.subSectionRightRefs,Ct=pt.sectionRowRefs,Bt=pt.getSectionRowRef,wt=pt.getSubSectionRef,It=pt.getBadgeRef,Tt=rt.analysis,_t=m(null===(Z=null===(Q=null==Tt?void 0:Tt.rule_difference_comparison)||void 0===Q?void 0:Q.summary)||void 0===Z?void 0:Z.overall_summary),Et=!!_t.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Ft=null!==(nn=null==yn?void 0:yn.base_root_id)&&void 0!==nn?nn:"-1";null==yn||yn[Ft];var Dt=Xn?null!==(pn=null!==(an=_n&&(null===(dn=null==_n?void 0:_n[Ft])||void 0===dn?void 0:dn.evaluation_result))&&void 0!==an?an:null===(vn=null===(sn=null==yn?void 0:yn.nodes)||void 0===sn?void 0:sn[Ft])||void 0===vn?void 0:vn.evaluation_result)&&void 0!==pn?pn:null:null!==(cn=null!==(on=_n&&(null===(tn=null===(en=null==_n?void 0:_n[Ft])||void 0===en?void 0:en.evaluation_result)||void 0===tn?void 0:tn[0]))&&void 0!==on?on:null===(un=null===(ln=null===(rn=null==yn?void 0:yn.nodes)||void 0===rn?void 0:rn[Ft])||void 0===ln?void 0:ln.evaluation_result)||void 0===un?void 0:un[0])&&void 0!==cn?cn:null,kt=y(Dt),Mt=b(null!==(hn=null===(gn=null===(fn=null==Dt?void 0:Dt.evaluation_outputs)||void 0===fn?void 0:fn.metadata)||void 0===gn?void 0:gn.label_color)&&void 0!==hn?hn:""),At=c(function(){var n,e,t,i,o,r;Vn(!1),he.current=!1;var l=xe.current,u=Xt.current;if(null!==l)if("string"==typeof l&&l.includes(S)){var c=l.split(S);(d=(null===(n=St.current[c[2]])||void 0===n?void 0:n.current)||(null===(e=ht.current[Number(c[2])])||void 0===e?void 0:e.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(t=ht.current[l])||void 0===t?void 0:t.current)&&(d.style.paddingTop="0px")}if(null!==u)if("string"==typeof u&&u.includes(S)){c=u.split(S);(a=(null===(i=Rt.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=xt.current[Number(c[3])])||void 0===o?void 0:o.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(r=xt.current[u])||void 0===r?void 0:r.current)&&(a.style.paddingTop="0px")}te(null),xe.current=null,Xt.current=null,$n(!1),On(!1),Te.current&&(Te.current.style.height="0px"),_e.current&&(_e.current.style.height="0px"),Ee.current&&(Ee.current.style.height="0px"),Fe.current&&(Fe.current.style.height="0px")},[]),Nt=L({maintainRelativeOrder:!!kn,proposedSections:lt,existingSections:ut,activeSideBySideSection:ee,connectedSections:re,resetSideBySide:At,setConnectedSections:le,setConnectedLines:de,cachedConnectedPositions:fe,svgContainerRef:ae,isAnimatingRef:se,animationTimerRef:ve,calculateLinesRef:me,sectionLeftRefs:ht,sectionRightRefs:xt,subSectionLeftRefs:St,subSectionRightRefs:Rt}),Ht=Nt.expandedSections,Lt=Nt.expandedSubSections,jt=Nt.setExpandedSubSections,Pt=Nt.toggleSection,Ot=c(function(e,t,i,o,r,l,u){var c,d,a,s=m(null==t?void 0:t.id)||m(null==i?void 0:i.id)||"",v=(s?ye[s]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:s,decisioning:[],gap:[],relevance_score:0},p=null!==(d=null===(c=Ct.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null;return{isLoading:null!==(a=null==wn?void 0:wn.isLoading)&&void 0!==a&&a,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:p,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==yn?void 0:yn.documents,input_index_map:null==yn?void 0:yn.input_index_map},deviationData:function(){var e,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,u=function(e){var t=function(n){if(!n||"object"!=typeof n)return null;var e=null==n?void 0:n.deviation_entries;if(e&&"object"==typeof e){var t=Object.keys(e).sort(function(n,e){return Number(n)-Number(e)})[0];if(t&&e[t])return e[t]}var i=Object.keys(n).filter(function(n){return/^\d+$/.test(n)}).sort(function(n,e){return Number(n)-Number(e)});if(i.length&&n[i[0]])return n[i[0]];var o=null==n?void 0:n.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(n,e){return Number(n)-Number(e)})[0];if(r&&o[r])return o[r]}return null}(e);return t?n(n({},e),{deviation_summary:(null==e?void 0:e.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==e?void 0:e.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==e?void 0:e.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==e?void 0:e.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==e?void 0:e.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==e?void 0:e.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):e};if(!("string"==typeof o&&o.includes(S)))return u(l);var c=o.split(S)[1];if(!c)return l;var d=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},a=(null===(e=null==d?void 0:d.deviation_entries)||void 0===e?void 0:e[c])||(null===(r=null==d?void 0:d.deviations)||void 0===r?void 0:r[c])||null;return a?n(n(n({},d),a),{deviation_summary:(null==a?void 0:a.deviation_summary)||(null==d?void 0:d.deviation_summary),deviation_title:(null==a?void 0:a.deviation_title)||(null==d?void 0:d.deviation_title),deviation_impact:(null==a?void 0:a.deviation_impact)||(null==d?void 0:d.deviation_impact),deviation_explanation:(null==a?void 0:a.deviation_explanation)||(null==d?void 0:d.deviation_explanation),evaluation_outputs:(null==a?void 0:a.evaluation_outputs)||(null==d?void 0:d.evaluation_outputs),cognitive_decisioning:(null==a?void 0:a.cognitive_decisioning)||(null==d?void 0:d.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[ye,yn]),zt=c(function(n){Ue(),ze(null),Le(n)},[Ue]),Wt=function(n,e,t,i,o,r){var l;if(n.stopPropagation(),je.open&&je.sectionIdx===o)Ue();else{var u=n.currentTarget,c="left";(null===(l=Ie.current)||void 0===l?void 0:l.contains(u))&&(c="right");he.current&&At(),le(new Set),de([]),fe.current=[],Je(),Ye.open?bi():qe(),requestAnimationFrame(function(){var n=function(){var n,e,t,i;if("string"==typeof o&&o.includes(S)){var r=o.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===c?null===(n=yt.current[l])||void 0===n?void 0:n.current:null===(e=mt.current[l])||void 0===e?void 0:e.current}return"right"===c?null===(t=yt.current[o])||void 0===t?void 0:t.current:null===(i=mt.current[o])||void 0===i?void 0:i.current}()||u;Pe(Ot(n,e,i,o,t,r))})}},Yt=c(function(){null!==je.sectionIdx&&je.anchorEl?zt(n(n({},je),{open:!0})):Ue()},[je,Ue,zt]),Kt=c(function(){var n=je.sectionIdx,e=je.isOrphan;Ue(),qe(),null!==n&&(e?Yn("No counterpart exists to connect to."):(he.current&&At(),de([]),fe.current=[],le(function(e){return e.has(n)?new Set:new Set([n])}),setTimeout(function(){me.current&&me.current()},50)))},[je.sectionIdx,je.isOrphan,Ue,qe,At]),qt=r(null),Vt=r(null),Xt=r(null),Jt=r(null),Ut=r(null),$t=r(null),Gt=o([]),Qt=Gt[0],Zt=Gt[1];r(null);var ni=o(null),ei=ni[0],ti=ni[1];u(function(){if(Qe){var n=$e.fields.find(function(n){return n.analysisKey===Qe||n.key===Qe});if(n){var e=ft.current[n.key]||gt.current[n.key];(null==e?void 0:e.current)&&setTimeout(function(){return e.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Qe,$e.fields]);var ii=c(function(n){var e,t,i,o,r,l,u,c,d,a=null===(e=null==Tt?void 0:Tt.rule_difference_comparison)||void 0===e?void 0:e.fields;if(!a||!a[n])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=a[n],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var p=s.mappings[0]||{};return{score:s.score,relation:p.relation||"",highlightsA:(null===(l=p.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=p.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(c=s.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(d=s.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!v}},[Tt]),oi=c(function(e,t){var i,o,r,l,u,c,d;void 0===t&&(t="left");var a=null,s=null;if("left"===t)if(a=lt[e],kn&&a){var v=ut.filter(function(n){var e;return null===(e=a.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});s=v.find(function(n){return n.evaluationResult})||v[0]}else s=ut[e];else if(s=ut[e],kn&&s){var p=lt.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(s.selfIndex)});a=p.find(function(n){return n.evaluationResult})||p[0]}else a=lt[e];var f=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,g=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,h=!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData));if(!f&&!g&&!h)return n(n({},b(_)),{label:"Not Defined"});var x=null!==(o=null!==(i=null==a?void 0:a.evaluationResult)&&void 0!==i?i:null==s?void 0:s.evaluationResult)&&void 0!==o?o:null,m=null===(r=null==x?void 0:x.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(c=null===(u=null===(l=null==x?void 0:x.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===u?void 0:u.label_color)&&void 0!==c?c:_;return n(n({},b(y)),null!=x?{label:null!==(d=m)&&void 0!==d?d:""}:{label:null})},[lt,ut,ye,$e,kn]),ri=c(function(e){for(var t,i,o,r,l,u,c,d,a,s=e.split("-").map(Number),v=lt[s[0]],p=ut[s[0]],f=1;f<s.length;f++)(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]),(null==p?void 0:p.subsections)&&(p=p.subsections[s[f]]);if(!v&&!p)return null;var g=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,h=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,x=m(null==v?void 0:v.id)||m(null==p?void 0:p.id)||"",y=!(!(null==v?void 0:v.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!g&&!h&&!y)return n(n({},b(_)),{label:"Not Defined"});null!==(i=null!==(t=null==v?void 0:v.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||x&&(null===(o=ye[x])||void 0===o||o.relevance_score);var S=null!==(l=null!==(r=null==v?void 0:v.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,R=null===(u=null==S?void 0:S.evaluation_outputs)||void 0===u?void 0:u.output_value,C=null!==(a=null===(d=null===(c=null==S?void 0:S.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:_;return n(n({},b(C)),null!=S?{label:null!=R?R:""}:{label:null})},[lt,ut,ye,$e]),li=c(function(){var n,e,t,i,o,r,l,u,c,d,a,s,v,p,f,g,h,x,m,y,b,B;if(!ke.current&&!se.current){ke.current=!0;try{if(!qt.current)return;var w=function(n){var e=n.split("-"),t=e[0];if(!Ht[t]&&!1===kn)return!1;if(kn&&!Ht["left-".concat(t)]&&!Ht["right-".concat(t)]&&!Ht[t])return!1;for(var i=t,o=1;o<e.length-1;o++)if(i+="-".concat(e[o]),!Lt[i])return!1;return!0},I=qt.current.getBoundingClientRect();Re({width:I.width,height:I.height});var T=[];if(ct.forEach(function(n){var e,t,i=n.key,o=null===(e=ft.current[i])||void 0===e?void 0:e.current,r=null===(t=gt.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!se.current){for(var _=0;_<Math.max(lt.length,ut.length);_++){var E=null===(n=ht.current[_])||void 0===n?void 0:n.current,F=null===(e=xt.current[_])||void 0===e?void 0:e.current;E&&(E.style.height="auto",E.style.minHeight="0px"),F&&(F.style.height="auto",F.style.minHeight="0px")}kn||Object.keys(St.current).forEach(function(n){var e,t;if(w(n)){var i=null===(e=St.current[n])||void 0===e?void 0:e.current,o=null===(t=Rt.current[n])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var D={};ct.forEach(function(n){var e,t,i=n.key,o=null===(e=ft.current[i])||void 0===e?void 0:e.current,r=null===(t=gt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var k={left:{},right:{}},M={};if(!se.current)if(kn){if(qn&&null!==ee)if("number"==typeof ee){var A=ee,N=lt[A],H=null===(o=ht.current[A])||void 0===o?void 0:o.current;H&&N&&(N.refIndexes||[]).forEach(function(n){var e,t=ut.findIndex(function(e){return e.selfIndex===n}),i=null===(e=xt.current[t])||void 0===e?void 0:e.current;if(i&&(Ht["left-".concat(A)]||Ht["right-".concat(t)])){var o=Math.max(H.getBoundingClientRect().height,i.getBoundingClientRect().height);k.left[A]=Math.max(k.left[A]||0,o),k.right[t]=Math.max(k.right[t]||0,o)}})}else{var L=ee.split(S)[2];if(L){E=null===(r=St.current[L])||void 0===r?void 0:r.current,F=null===(l=Rt.current[L])||void 0===l?void 0:l.current;if(E&&F){j=Math.max(E.getBoundingClientRect().height,F.getBoundingClientRect().height);M[L]=Math.max(M[L]||0,j)}}}}else{Object.keys(St.current).forEach(function(n){var e,t;if(w(n)){var i=null===(e=St.current[n])||void 0===e?void 0:e.current,o=null===(t=Rt.current[n])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);M[n]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(_=0;_<Math.min(lt.length,ut.length);_++){var E=null===(t=ht.current[_])||void 0===t?void 0:t.current,F=null===(i=xt.current[_])||void 0===i?void 0:i.current;if(E&&F){var j=Math.max(E.getBoundingClientRect().height,F.getBoundingClientRect().height);k.left[_]=j,k.right[_]=j}}}if(ct.forEach(function(n){var e,t,i=n.key,o=null===(e=ft.current[i])||void 0===e?void 0:e.current,r=null===(t=gt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),se.current||(Object.entries(k.left).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=ht.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(k.right).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=xt.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),kn||Object.keys(M).forEach(function(n){var e,t,i=null===(e=St.current[n])||void 0===e?void 0:e.current,o=null===(t=Rt.current[n])||void 0===t?void 0:t.current;if(i&&o&&M[n]){var r=M[n];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),kn)lt.forEach(function(n,e){var t;(null===(t=ht.current[e])||void 0===t?void 0:t.current)&&(n.refIndexes||[]).forEach(function(n){var t,i,o,r,l,u,c,d,a,s,v=ut.findIndex(function(e){return e.selfIndex===n});if(-1!==v){var p=null===(t=mt.current[e])||void 0===t?void 0:t.current,f=null===(i=yt.current[v])||void 0===i?void 0:i.current;if(p&&f){var g=p.getBoundingClientRect(),h=f.getBoundingClientRect(),x=g.right-I.left,m=h.left-I.left,y=g.top+g.height/2-I.top,b=h.top+h.height/2-I.top;if(qn&&ee===e){var S=null!==(r=null===(o=De.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=Ie.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(d=null===(c=De.current)||void 0===c?void 0:c.clientHeight)&&void 0!==d?d:1/0),B=R+(null!==(s=null===(a=Ie.current)||void 0===a?void 0:a.clientHeight)&&void 0!==s?s:1/0),w=g.top+g.height/2,_=h.top+h.height/2,E=function(n,e,t){return Math.max(e,Math.min(t,n))};y=E(w,S,C)-I.top,b=E(_,R,B)-I.top}var F=oi(e);F&&T.push({id:"line-".concat(e,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:F,sectionIdx:e,targetRightIdx:v})}}})});else{for(_=0;_<Math.min(lt.length,ut.length);_++){var P=null===(u=ht.current[_])||void 0===u?void 0:u.current,O=null===(c=xt.current[_])||void 0===c?void 0:c.current;if(P&&O){var z=P.getBoundingClientRect(),W=O.getBoundingClientRect(),Y=Math.max(z.top,W.top)+18-I.top,K=(null===(d=ut[_])||void 0===d?void 0:d.id)||"sec-".concat(_);(Q=oi(_))&&T.push({id:K,x1:z.right-I.left,y1:Y,x2:W.left-I.left,y2:Y,style:Q,sectionIdx:_,hasCognitive:!!((null===(a=lt[_])||void 0===a?void 0:a.cognitiveData)||(null===(s=ut[_])||void 0===s?void 0:s.cognitiveData)||K&&ye[K]),isSubSection:!1})}}Object.keys(St.current).forEach(function(n){var e,t,i,o,r,l;if(w(n)){var u=null===(e=St.current[n])||void 0===e?void 0:e.current,c=null===(t=Rt.current[n])||void 0===t?void 0:t.current;if(u&&c){for(var d=n.split("-").map(Number),a=lt[d[0]],s=ut[d[0]],v=1;v<d.length;v++)(null==a?void 0:a.subsections)&&(a=a.subsections[d[v]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[v]]);var p=!!a&&((null===(i=a.displayTitle)||void 0===i||i)&&R(a.title)),f=!!a&&((null===(o=a.displayContent)||void 0===o||o)&&R(a.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&R(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&R(s.content));if(p&&f||g&&h){var x=u.getBoundingClientRect(),m=c.getBoundingClientRect(),y=Math.max(x.top,m.top)+16-I.top,b=ri(n);b&&"Not Defined"!==b.label&&T.push({id:"subsec-".concat(n),x1:x.right-I.left,y1:y,x2:m.left-I.left,y2:y,style:b,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(qn&&"string"==typeof ee&&ee.includes(S)){var q=ee.split(S),V=q[0],X=q[1],J=q[2],U=(q[3],"".concat(V).concat(S).concat(X)),$=null===(v=mt.current[U])||void 0===v?void 0:v.current,G=null===(p=yt.current[U])||void 0===p?void 0:p.current;if($&&G){var Q,Z=$.getBoundingClientRect(),nn=G.getBoundingClientRect(),en=Z.right-I.left,tn=nn.left-I.left,on=Z.top+Z.height/2-I.top,rn=nn.top+nn.height/2-I.top;if(kn){var ln=null!==(g=null===(f=De.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,un=null!==(x=null===(h=Ie.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==x?x:0,cn=ln+(null!==(y=null===(m=De.current)||void 0===m?void 0:m.clientHeight)&&void 0!==y?y:1/0),dn=un+(null!==(B=null===(b=Ie.current)||void 0===b?void 0:b.clientHeight)&&void 0!==B?B:1/0),an=function(n,e,t){return Math.max(e,Math.min(t,n))};on=an(Z.top+Z.height/2,ln,cn)-I.top,rn=an(nn.top+nn.height/2,un,dn)-I.top}(Q=ri(J))&&T.push({id:"line-subsec-".concat(U),x1:en,y1:on,x2:tn,y2:rn,style:Q,sectionIdx:Number(J.split("-")[0]),isSubSection:!0,subSectionKeyPath:ee})}}if(Zt(T),Ut.current&&$t.current){var sn=Ut.current.getBoundingClientRect(),vn=$t.current.getBoundingClientRect(),pn=(sn.top+sn.height/2-I.top+vn.top+vn.height/2-I.top)/2;ti({x1:sn.right-I.left,x2:vn.left-I.left,y:pn})}else ti(null);if(re.size>0){var fn=[],gn=De.current,hn=Ie.current;if(gn&&hn){var xn=[],mn=gn.getBoundingClientRect().top,yn=hn.getBoundingClientRect().top,bn=mn+gn.clientHeight,Sn=yn+hn.clientHeight,Rn=gn.scrollTop,Cn=hn.scrollTop,Bn=I.top,wn=function(n,e,t){return Math.max(e,Math.min(t,n))};re.forEach(function(n){var e,t,i,o,r;if("string"==typeof n&&n.includes(S)){var l=n.split(S),u=l[0],c=l[1],d=l[2],a=(l[3],"".concat(u).concat(S).concat(c)),s=null===(e=mt.current[a])||void 0===e?void 0:e.current,v=null===(t=yt.current[a])||void 0===t?void 0:t.current;if(!s||!v)return;var p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=ri(d),h=(N=p.right-I.left)+.5*((H=f.left-I.left-0)-N),x=p.top+p.height/2,m=f.top+f.height/2,y=x-mn+Rn,b=m-yn+Cn,R="conn-subsec-".concat(a);xn.push({lhsScrollY:y,rhsScrollY:b,x1:N,x2:H,containerTop:Bn,leftIdx:n,rhsArrayIdx:n,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:R});var B=wn(x,mn,bn),w=wn(m,yn,Sn),T=B-Bn,_=w-Bn,E=m>=yn-4&&m<=Sn+4,F="";F=(L=x>=mn-4&&x<=bn+4)&&E?C(N,T,H,_):L&&!E?"M ".concat(N,",").concat(T," L ").concat(h,",").concat(T," L ").concat(h,",").concat(_):!L&&E?"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_," L ").concat(H,",").concat(_):"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_),fn.push({id:R,pathD:F,style:g,leftIdx:n,rhsArrayIdx:n})}else if(kn){var D=n,k=lt[D];if(!(null===(r=null==k?void 0:k.refIndexes)||void 0===r?void 0:r.length))return;k.refIndexes.forEach(function(n){var e,t,i=ut.findIndex(function(e){return e.selfIndex===n});if(-1!==i){var o=null===(e=mt.current[D])||void 0===e?void 0:e.current,r=null===(t=yt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=oi(D),d=l.right-I.left,a=u.left-I.left-0,s=d+.5*(a-d),v=l.top+l.height/2,p=u.top+u.height/2,f=v-mn+Rn,g=p-yn+Cn,h="conn-".concat(D,"-").concat(i);xn.push({lhsScrollY:f,rhsScrollY:g,x1:d,x2:a,containerTop:Bn,leftIdx:D,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var x=wn(v,mn,bn),m=wn(p,yn,Sn),y=x-Bn,b=m-Bn,S=v>=mn-4&&v<=bn+4,R=p>=yn-4&&p<=Sn+4,B="";B=S&&R?C(d,y,a,b):S&&!R?"M ".concat(d,",").concat(y," L ").concat(s,",").concat(y," L ").concat(s,",").concat(b):!S&&R?"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b," L ").concat(a,",").concat(b):"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b),fn.push({id:h,pathD:B,style:c,leftIdx:D,rhsArrayIdx:i})}}})}else{var M=n,A=M;s=null===(i=mt.current[M])||void 0===i?void 0:i.current,v=null===(o=yt.current[A])||void 0===o?void 0:o.current;if(!s||!v)return;var N,H;p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=oi(M),h=(N=p.right-I.left)+.5*((H=f.left-I.left-0)-N),x=p.top+p.height/2,m=f.top+f.height/2,y=x-mn+Rn,b=m-yn+Cn,R="conn-".concat(M,"-").concat(A);xn.push({lhsScrollY:y,rhsScrollY:b,x1:N,x2:H,containerTop:Bn,leftIdx:M,rhsArrayIdx:A,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:R});var L;B=wn(x,mn,bn),w=wn(m,yn,Sn),T=B-Bn,_=w-Bn,E=m>=yn-4&&m<=Sn+4,F="";F=(L=x>=mn-4&&x<=bn+4)&&E?C(N,T,H,_):L&&!E?"M ".concat(N,",").concat(T," L ").concat(h,",").concat(T," L ").concat(h,",").concat(_):!L&&E?"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_," L ").concat(H,",").concat(_):"M ".concat(h,",").concat(T," L ").concat(h,",").concat(_),fn.push({id:R,pathD:F,style:g,leftIdx:M,rhsArrayIdx:A})}}),fe.current=xn}de(fn)}else de([]),fe.current=[]}catch(n){console.error("Line render safe fail: ",n)}finally{ke.current=!1}}},[ct,lt,ut,ye,$e,ii,oi,kn,qn,ee,re,Ht,Lt]),ui=c(function(){var n,e,t,i,o,r,l,u,c,d,a,s,v,p,f=fe.current;if(f.length&&!se.current){var g=null!==(e=null===(n=De.current)||void 0===n?void 0:n.scrollTop)&&void 0!==e?e:0,h=null!==(i=null===(t=Ie.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=De.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(u=null===(l=Ie.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(d=null===(c=De.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==d?d:0,b=null!==(s=null===(a=Ie.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,R=b+m,B=null!==(p=null===(v=qt.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,w=function(n,e,t){return Math.max(e,Math.min(t,n))};f.forEach(function(n){var e=n.lhsScrollY-g+y,t=n.rhsScrollY-h+b,i=pe.current[n.styleId+"-stroke"],o=pe.current[n.styleId+"-bg"];if(i||o){var r,l=w(e,y,S),u=w(t,b,R),c=l-B,d=u-B,a=e>=y-4&&e<=S+4,s=t>=b-4&&t<=R+4,v=n.x1+.5*(n.x2-n.x1);r=a&&s?C(n.x1,c,n.x2,d):a&&!s?"M ".concat(n.x1,",").concat(c," L ").concat(v,",").concat(c," L ").concat(v,",").concat(d):!a&&s?"M ".concat(v,",").concat(c," L ").concat(v,",").concat(d," L ").concat(n.x2,",").concat(d):"M ".concat(v,",").concat(c," L ").concat(v,",").concat(d),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);u(function(){me.current=li},[li]);var ci=r(null),di=r(null),ai=c(function(){fe.current.length>0&&!se.current||(null!==ci.current&&clearTimeout(ci.current),ci.current=setTimeout(function(){me.current(),ci.current=null},50))},[]),si=c(function(){Zn(!0),$n(!1),null!==di.current&&clearTimeout(di.current),null!==ci.current&&(clearTimeout(ci.current),ci.current=null),di.current=setTimeout(function(){var n,e,t,i,o,r,l,u,c,d;if(fe.current=[],he.current&&null!==xe.current&&null!==Xt.current){var a=xe.current,s=Xt.current,v=null,p=null,f=null,g=null;if("string"==typeof a&&a.includes(S)){var h=a.split(S),x="".concat(h[0]).concat(S).concat(h[1]);v=(null===(n=mt.current[x])||void 0===n?void 0:n.current)||null,p=(null===(e=yt.current[x])||void 0===e?void 0:e.current)||null,f=(null===(t=St.current[h[2]])||void 0===t?void 0:t.current)||(null===(i=ht.current[Number(h[2])])||void 0===i?void 0:i.current)||null,g=(null===(o=Rt.current[h[3]])||void 0===o?void 0:o.current)||(null===(r=xt.current[Number(h[3])])||void 0===r?void 0:r.current)||null}else v=(null===(l=Ct.current[a])||void 0===l?void 0:l.current)||null,f=(null===(u=ht.current[a])||void 0===u?void 0:u.current)||null,p=(null===(c=bt.current[s])||void 0===c?void 0:c.current)||null,g=(null===(d=xt.current[s])||void 0===d?void 0:d.current)||null;if(v&&p&&f&&g){if(f.style.paddingTop="0px",g.style.paddingTop="0px",!kn){var m=v.getBoundingClientRect(),y=p.getBoundingClientRect(),b=m.top-y.top;b>0?g.style.paddingTop="".concat(b,"px"):b<0&&(f.style.paddingTop="".concat(Math.abs(b),"px"))}var R=De.current,C=Ie.current;if(R&&C){var B=v.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,w=p.getBoundingClientRect().top-C.getBoundingClientRect().top+C.scrollTop-(B-R.scrollTop);Math.abs(C.scrollTop-w)>1&&(C.scrollTop=w)}}}me.current(),he.current&&$n(!0),Zn(!1),di.current=null},150)},[kn,lt,ut]),vi=c(function(n){var e,t,i,o,r,l,u,c,d,a;if(null!==Me.current&&Ae.current&&Math.abs(n.currentTarget.scrollTop-Me.current)<=2){var s=Ae.current;Me.current=null,Ae.current=null,s()}if(!ie.current){if(kn||ai(),he.current){var v=xe.current,p=Xt.current,f=De.current,g=Ie.current;if(null!==v&&null!==p&&f&&g){var h="string"==typeof v&&v.includes(S)?null===(e=mt.current["".concat(v.split(S)[0]).concat(S).concat(v.split(S)[1])])||void 0===e?void 0:e.current:null===(t=Ct.current[v])||void 0===t?void 0:t.current,x="string"==typeof p&&p.includes(S)?null===(i=yt.current["".concat(p.split(S)[0]).concat(S).concat(p.split(S)[1])])||void 0===i?void 0:i.current:null===(o=bt.current[p])||void 0===o?void 0:o.current;if(h&&x&&Jt.current){var m=void 0,y=void 0;if("string"==typeof v&&v.includes(S)){var b=v.split(S),R="".concat(b[0]).concat(S).concat(b[1]);m=null===(r=mt.current[R])||void 0===r?void 0:r.current,y=null===(l=yt.current[R])||void 0===l?void 0:l.current}else m=null===(u=mt.current[v])||void 0===u?void 0:u.current,y=null===(c=yt.current[p])||void 0===c?void 0:c.current;var C=null!==(a=null===(d=qt.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==a?a:0,B=f.getBoundingClientRect().top,w=B+f.clientHeight;g.getBoundingClientRect().top;g.clientHeight;if(m&&y){var I=m.getBoundingClientRect(),T=y.getBoundingClientRect(),_=I.top+I.height/2;T.top,T.height;var E=((D=_,k=B,M=w,Math.max(k,Math.min(M,D)))-C).toString();Jt.current.setAttribute("y1",E),Jt.current.setAttribute("y2",E);var F=_>=B-4&&_<=w+4;Jt.current.setAttribute("visibility",F?"visible":"hidden")}}}}var D,k,M;fe.current.length>0&&!ge.current&&(ge.current=!0,requestAnimationFrame(function(){ui(),ge.current=!1}))}},[ui,kn,ai]),pi=r(0),fi=r(0),gi=r(0),hi=r(function(){});r(null),u(function(){hi.current=si},[si]),u(function(){var n=setTimeout(ai,250),e=function(){return hi.current()};return window.addEventListener("resize",e),function(){clearTimeout(n),null!==ci.current&&clearTimeout(ci.current),null!==di.current&&clearTimeout(di.current),window.removeEventListener("resize",e)}},[ot,rt,Tt,ct,Ht,Lt,lt,ut,$e,ai,qn,ee,Un,re]),u(function(){var n=function(n,e,t,i,o){e.current=n.getBoundingClientRect().width;var r=new ResizeObserver(function(n){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=n[n.length-1];if(c){var d=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(d-e.current)<1?o():(e.current=d,i())}})});return r.observe(n),r},e={current:null},t={current:null},i={current:null},o=[],r=[e,t,i];return we.current&&o.push(n(we.current,pi,e,function(){return hi.current()},function(){})),Be.current&&o.push(n(Be.current,fi,t,function(){return hi.current()},function(){return me.current()})),qt.current&&o.push(n(qt.current,gi,i,function(){return hi.current()},function(){return me.current()})),function(){o.forEach(function(n){return n.disconnect()}),r.forEach(function(n){null!==n.current&&(cancelAnimationFrame(n.current),n.current=null)})}},[]),u(function(){he.current=qn},[qn]),u(function(){xe.current=ee},[ee]);var xi=c(function(n,e,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,u=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";Ue(),null!=n&&(e?Yn("No counterpart exists for this section."):qn&&ee===n?r?At():null==l||l():(le(new Set([n])),de([]),fe.current=[],On(!0),ie.current=!0,te(n),xe.current=n,Vn(!0),he.current=!0,$n(!1),Te.current&&(Te.current.style.height="0px"),_e.current&&(_e.current.style.height="0px"),Ee.current&&(Ee.current.style.height="0px"),Fe.current&&(Fe.current.style.height="0px"),requestAnimationFrame(function(){var e,t,i,o,r,c="string"==typeof n&&n.includes(S),d=null,a=null,s=null;if(c){var v=n.split(S),p="".concat(v[0]).concat(S).concat(v[1]);d=(null===(e=mt.current[p])||void 0===e?void 0:e.current)||null,a=(null===(t=yt.current[p])||void 0===t?void 0:t.current)||null,s=a?n:null}else if(d=(null===(i=Ct.current[n])||void 0===i?void 0:i.current)||null,kn){var f=lt[n],g=(null==f?void 0:f.refIndexes)||[];if(g.length>0){var h=g[0],x=ut.findIndex(function(n){return n.selfIndex===h});-1!==x&&(a=(null===(r=bt.current[x])||void 0===r?void 0:r.current)||null,s=x)}}else a=(null===(o=bt.current[n])||void 0===o?void 0:o.current)||null,s=a?n:null;Xt.current=s;var m=De.current,y=Ie.current,b=function(){!function(){var e,t,i,o,r,l,u,d,a,v,p,f,g=null,h=null,x=null,m=null;if(c){var y=n.split(S),b="".concat(y[0]).concat(S).concat(y[1]);g=(null===(e=St.current[y[2]])||void 0===e?void 0:e.current)||(null===(t=ht.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=Rt.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=xt.current[Number(y[3])])||void 0===o?void 0:o.current)||null,x=(null===(r=mt.current[b])||void 0===r?void 0:r.current)||g,m=(null===(l=yt.current[b])||void 0===l?void 0:l.current)||h}else{var R=Number(n),C=null!==s?Number(s):R;g=(null===(u=ht.current[R])||void 0===u?void 0:u.current)||null,h=(null===(d=xt.current[C])||void 0===d?void 0:d.current)||null,x=(null===(a=mt.current[R])||void 0===a?void 0:a.current)||(null===(v=Ct.current[R])||void 0===v?void 0:v.current)||g,m=(null===(p=yt.current[C])||void 0===p?void 0:p.current)||(null===(f=bt.current[C])||void 0===f?void 0:f.current)||h}if(x&&m&&g&&h){g.style.paddingTop="0px",h.style.paddingTop="0px";var B=x.getBoundingClientRect(),w=m.getBoundingClientRect(),I=B.top-w.top;I>0?h.style.paddingTop="".concat(I,"px"):I<0&&(g.style.paddingTop="".concat(Math.abs(I),"px"))}}(),$n(!0),me.current&&me.current(),ie.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),On(!1),null==l||l()};if(!d||!m)return ie.current=!1,On(!1),void(null==l||l());if(a&&y){if(!kn){var R=0;R="right"===u?a?a.getBoundingClientRect().top:0:d?d.getBoundingClientRect().top:0;var C=Be.current,w=(null==C?void 0:C.getBoundingClientRect().top)||0,I=C?C.scrollTop+R-w-150:0;return C?void B(C,I,200,b):void b()}var T=d.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,_=a.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,E=200;if("left"===u){var F=_-(T-m.scrollTop);F<0&&Te.current&&(Te.current.style.height="".concat(Math.abs(F),"px")),requestAnimationFrame(function(){var n,e=y.scrollHeight-y.clientHeight;if(F<0)n=0;else{if(F>e){var t=F-e;return _e.current&&(_e.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){B(y,F,E,b)})}n=F}B(y,n,E,b)})}else{var D=T-(_-y.scrollTop);D<0&&Ee.current&&(Ee.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var n,e=m.scrollHeight-m.clientHeight;if(D<0)n=0;else{if(D>e){var t=D-e;return Fe.current&&(Fe.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){B(m,D,E,b)})}n=D}B(m,n,E,b)})}}else b()})))},[ee,Ue,ut,qn,kn,lt,At]),mi=c(function(n,e,t,i){var o,r="string"==typeof i?m(i).trim():m(null==i?void 0:i.deviation_summary).trim(),l=n.currentTarget;Je();var u="left";(null===(o=Ie.current)||void 0===o?void 0:o.contains(l))&&(u="right");var c=function(){var n,t,i,o;if("string"==typeof e&&e.includes(S)){var r=e.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===u?null===(n=yt.current[l])||void 0===n?void 0:n.current:null===(t=mt.current[l])||void 0===t?void 0:t.current}return"right"===u?null===(i=yt.current[e])||void 0===i?void 0:i.current:null===(o=mt.current[e])||void 0===o?void 0:o.current};if(t)return At(),le(new Set),de([]),fe.current=[],void(r&&requestAnimationFrame(function(){var n=c()||l;Ke({open:!0,anchorEl:n,summary:i})}));xi(e,t,r?{toggleIfSame:!1,sourceSide:u,onReady:function(){var n=c()||l;Ke({open:!0,anchorEl:n,summary:i})}}:{toggleIfSame:!1,sourceSide:u})},[xi,Je,Ke,At]),yi=c(function(){var n,e=je.sectionIdx,t=je.isOrphan;if(qe(),null!=e){var i="left";je.anchorEl&&(null===(n=Ie.current)||void 0===n?void 0:n.contains(je.anchorEl))&&(i="right"),xi(e,t,{sourceSide:i})}},[xi,je.isOrphan,je.sectionIdx,je.anchorEl,qe]),bi=c(function(){qe(),At(),le(new Set),de([]),fe.current=[]},[qe,At]),Si=null!==je.sectionIdx&&re.has(je.sectionIdx),Ri=j({proposedSections:lt,existingSections:ut,parentDeviationRecord:dt,expandedSections:Ht,maintainRelativeOrder:!!kn,scrollContainerRef:Be,leftContainerRef:De,lhsBadgeRefs:mt,rhsBadgeRefs:yt}),Ci=Ri.showDeviationNavigation,Bi=Ri.showOpenNodeRef,wi=l(function(){if(!En)return null;var n=En.split(":")[0];for(var e in dt){if((dt[e]||[]).some(function(e){return e.id===n}))return e}return null},[En,dt]),Ii=r(null),Ti=r(null);u(function(){if(En&&Ii.current!==En){var t=En.split(":"),i=t[0],o=t[1],r=null!=o?o:"0";Ti.current!==En&&(qe(),Je(),At(),le(new Set),de([]),fe.current=[],Ti.current=En);var l=!1,u=0,c=null,d=150,a=function(n,e){for(var t=function(n,i){if(!n)return null;if(n.id===e)return i;if(!Array.isArray(n.subsections))return null;for(var o=0;o<n.subsections.length;o++){var r=t(n.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<n.length;i++){var o=t(n[i],String(i));if(o)return o}return null},s=function(){var t,o,v,p;if(!l){var f=null,g=null;for(var h in dt){var x=dt[h].find(function(n){return n.id===i});if(x){f=h,g=x;break}}if(g&&f){var m=lt.findIndex(function(n){return n.id===f}),y=ut.findIndex(function(n){return n.id===f}),b=-1===m&&-1!==y,R=a(lt,g.id),C=a(ut,g.id);if(R&&!C&&!b){var B=R.split("-"),w=Number(B[0]);if(kn){var I=null===(o=null===(t=lt[w])||void 0===t?void 0:t.refIndexes)||void 0===o?void 0:o[0],T=ut.findIndex(function(n){return n.selfIndex===I});-1!==T&&(w=T)}C=e([w],B.slice(1),!0).join("-")}if(R||C){var _=b||!R&&!!C,E=R?Number(R.split("-")[0]):m,F=C?Number(C.split("-")[0]):y;if(_){if(!(kn?!!Ht["right-".concat(F)]:!!Ht[String(F)])&&F>=0)return Pt(F,"right"),u+=1,void(c=setTimeout(s,450))}else if(!(kn?!!Ht["left-".concat(E)]:!!Ht[String(E)])&&E>=0)return Pt(E,"left"),u+=1,void(c=setTimeout(s,450));var D,k=R||"",M=C||"",A="".concat(g.id).concat(S).concat(r).concat(S).concat(k).concat(S).concat(M),N="".concat(g.id).concat(S).concat(r),H=null===(v=mt.current[N])||void 0===v?void 0:v.current,L=null===(p=yt.current[N])||void 0===p?void 0:p.current,j=_||!H&&!!L,P=j?L:H;if(D=kn?j?Ie.current:De.current:Be.current,P&&D){var O=P.getBoundingClientRect();if(0===O.height)return void((u+=1)<20&&(c=setTimeout(s,d)));var z=D.getBoundingClientRect(),W=O.top-z.top+D.scrollTop-z.height/2+O.height/2,Y=function(){var e,t,i,o,u;if(!l){Ii.current=En;var c=window.getComputedStyle(P).color;H&&(H.style.transition="box-shadow 300ms ease-in-out",H.style.boxShadow="0 0 10px ".concat(c)),L&&(L.style.transition="box-shadow 300ms ease-in-out",L.style.boxShadow="0 0 10px ".concat(c)),setTimeout(function(){H&&(H.style.boxShadow=""),L&&(L.style.boxShadow="")},2e3);var d=(null===(t=null===(e=g.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[r])||g,a=(null===(i=g.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||g.evaluation_outputs;if(!(!!H&&!!L)){var s=j?(null===(o=yt.current[N])||void 0===o?void 0:o.current)||L:(null===(u=mt.current[N])||void 0===u?void 0:u.current)||H;return Ke({open:!0,anchorEl:s,summary:n(n({},d),{evaluation_outputs:a})}),void(null==Fn||Fn())}xi(A,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,t=(null===(e=mt.current[N])||void 0===e?void 0:e.current)||H;Ke({open:!0,anchorEl:t,summary:n(n({},d),{evaluation_outputs:a})})}})}};Math.abs(D.scrollTop-W)<=2?Y():(Me.current=W,Ae.current=Y,D.scrollTo({top:W,behavior:"smooth"}),c&&clearTimeout(c),c=setTimeout(function(){if(Ae.current){Me.current=null;var n=Ae.current;Ae.current=null,n()}},800))}else(u+=1)<20&&(c=setTimeout(s,d))}else(u+=1)<20&&(c=setTimeout(s,d))}else(u+=1)<20&&(c=setTimeout(s,d))}};return c=setTimeout(s,d),function(){l=!0,c&&clearTimeout(c)}}},[En,dt,lt,ut,kn,Ht,Pt,xi,Ke]);var _i=function(n){var e=n.section,t=n.keyPath,o=n.depth,r=void 0===o?0:o,l=n.columnKey,u=void 0===l?"left":l,c=n.parentNodeId;return i(z,{section:e,keyPath:t,depth:r,columnKey:u,parentNodeId:void 0===c?"":c,expandedSubSections:Lt,setExpandedSubSections:jt,maintainRelativeOrder:kn||!1,proposedSections:lt,existingSections:ut,treeData:yn,deviationNumberRegistry:at,connectedSections:re,activeSideBySideSection:ee,resolvedMarkdownStyles:Ce,getSubSectionRef:wt,getSubSectionCompareStyle:ri,getBadgeRef:It,openMoreFunctionsPopup:Wt,openSummaryPopup:mi,showDeviationBadges:An,resetSideBySide:At,setConnectedSections:le,setConnectedLines:de,cachedConnectedPositions:fe})};return t(d,n({ref:we,sx:n(n({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},kn?{}:{overflow:"visible"}),{position:"relative"})},{children:[Hn&&i(d,n({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(k,{})})),Ye.open&&i(W,{open:Ye.open,anchorEl:Ye.anchorEl,containerEl:Vt.current,clipTopEl:Ut.current,scrollContainerEl:Be.current,onClose:bi,summary:Ye.summary}),i(D,{open:je.open,anchorEl:je.anchorEl,sectionTitle:je.sectionTitle,referenceSectionTitle:je.refSectionTitle,onClose:Ue,onOpenCognitiveCompare:Yt,onOpenSideBySide:yi,onConnect:Kt,isConnected:Si,isOrphan:je.isOrphan}),He.open&&i(F,{open:He.open,popupRef:Xe,position:Oe,popupConfig:In,onClose:function(){ze(null),Le(function(e){return n(n({},e),{open:!1})}),Ve(null)},markdownStyles:Cn,sectionTitle:He.sectionTitle,referenceSectionTitle:He.refSectionTitle,cognitiveData:He.cognitiveData,anchorEl:He.anchorEl,sectionAnchorEl:He.sectionAnchorEl,scrollContainerEl:Be.current,badgeStyle:He.badgeStyle,docData:He.docData,deviationData:He.deviationData,isLoading:He.isLoading}),i(a,n({open:!!Wn,autoHideDuration:8e3,onClose:function(){return Yn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,n({onClose:function(){return Yn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Wn}))})),i(P,{componentHeaderText:mn,displayConfig:wn,maintainRelativeOrder:kn,onToggleView:function(n){Ln(!0),setTimeout(function(){Mn(!n),At(),qe(),le(new Set),de([]),fe.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Ln(!1)},600)})})},50)}}),i(d,n({ref:Be,onScroll:vi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:kn?"hidden":"auto",borderTop:_t&&Et?"none":"1.5px solid #EEF0F4"}},{children:i(d,n({sx:n({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},kn?{flex:1,minHeight:0}:{})},{children:t(d,n({ref:qt,sx:n({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},kn?{flex:1,overflow:"visible"}:{})},{children:[t("svg",n({ref:ae,style:{position:"absolute",top:0,left:0,width:Se.width||"100%",height:Se.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Qn?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[ei&&i("g",{children:i("line",{x1:ei.x1,y1:ei.y,x2:ei.x2,y2:ei.y,stroke:Mt.badgeBorder,strokeWidth:"1.5"})}),Qt.map(function(e){var o,r,l,u,c,a,s=e.x1+.5*(e.x2-e.x1),v=(e.y1+e.y2)/2;if("Not Defined"===e.style.label&&!e.hasCognitive)return null;if(e.isSubSection?qn&&ee===e.subSectionKeyPath&&Un:qn&&ee===e.sectionIdx&&Un)return null;if(!kn){var p=e.isSubSection?C(e.x1,e.y1,e.x2,e.y2):"M ".concat(e.x1," ").concat(e.y1," L ").concat(e.x2," ").concat(e.y2),g=lt[e.sectionIdx]||{title:"",content:""},x=ut[e.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",g,x),e.isSubSection&&e.subSectionKeyPath){var m=e.subSectionKeyPath.includes(S)?e.subSectionKeyPath.split(S):[],y=m[2]||e.subSectionKeyPath,b=m[3]||y,R=y.split("-").map(Number),B=b.split("-").map(Number),w=null,I=null;R.length>0&&(w=lt[R[0]]),B.length>0&&(I=ut[B[0]]);var T=(null==w?void 0:w.title)||"",E=(null==I?void 0:I.title)||"";console.log("Root Parent Titles:",T,E);for(var F=1;F<R.length;F++)(null==w?void 0:w.subsections)&&(w=w.subsections[R[F]]);for(F=1;F<B.length;F++)(null==I?void 0:I.subsections)&&(I=I.subsections[B[F]]);w&&(g=n(n({},w),{title:T||w.title})),console.log("Base Section for Subsection Badge:",g),I&&(x=n(n({},I),{title:E||I.title})),console.log("Ref Section for Subsection Badge:",x)}var D=!(null===(o=g.cognitiveData)||void 0===o?void 0:o.isMissingRationale)||Boolean(null===(l=null===(r=g.cognitiveData)||void 0===r?void 0:r.decisioning)||void 0===l?void 0:l.length),k=(null===(a=null===(c=null===(u=g.evaluationResult)||void 0===u?void 0:u.cognitive_decisioning)||void 0===c?void 0:c.decisioning_factors)||void 0===a?void 0:a.length)||!1,A=D||k;return t("g",{children:[i("path",{d:p,fill:"none",stroke:e.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",n({x:s-100,y:v-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(d,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,n({onClick:function(n){n.stopPropagation(),A&&(He.open&&We===e.id?Je():(Ve(e.id),zt(Ot(n.currentTarget,g,x,e.sectionIdx,e.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:e.style.badgeBg,color:e.style.badgeText,border:"1px solid ".concat(e.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:A?"pointer":"default"}},{children:[e.style.badgeText===_&&null==e.style.label?i(M,{color:e.style.badgeText}):0===e.style.label?"Same":e.style.label,i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),A&&i(f,{size:11,style:{transform:He.open&&We===e.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},e.id)}return null}),ce.map(function(e){var o,r=e.pathD,l=(null===(o=e.style)||void 0===o?void 0:o.badgeBorder)||"#6366F1",u="conn-marker-".concat(e.id),c="".concat(e.id,"-bg"),d="".concat(e.id,"-stroke");return t("g",{children:[i("defs",{children:i("clipPath",n({id:"connections-clip"},{children:i("marker",n({id:u,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:i("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),i("path",{ref:function(n){pe.current[c]=n},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(n){pe.current[d]=n},d:r,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(u,")")})]},e.id)})]})),t(d,n({sx:n({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},kn?{flex:1,overflow:"visible"}:{})},{children:[i(d,n({ref:Ut,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,n({title:et,placement:"top"},{children:i(p,n({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:et}))}))})),t(d,n({ref:De,onScroll:vi,sx:n({p:"12px",display:"flex",flexDirection:"column"},kn?{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:Ee,style:{width:"100%",height:"0px",flexShrink:0}}),vt&<.map(function(e,o){var r,l,u=!e.title&&!e.content;if(kn&&u)return null;var c=e,a=oi(o,"left"),s=kn?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!ut[o],v=kn?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:o+1,p=re.has(o),f=y(c.evaluationResult,null==a?void 0:a.deviationLabel);return i(d,n({ref:Bt(o),sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:ht.current[o],sx:n({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(O,{section:e,idx:o,columnKey:"left",colRef:Bt("left-accordion-".concat(o)),mb:0,treeData:yn,proposedSections:lt,existingSections:ut,deviationNumberRegistry:at,getSectionCompareStyle:oi,getBadgeRef:It,connectedSections:re,openMoreFunctionsPopup:Wt,openSummaryPopup:mi,deviationNodeIdToView:En,deviationTargetParentId:wi,parentNodeId:(null===(l=null==yn?void 0:yn.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:kn?!!Ht["left-".concat(o)]:!!Ht[String(o)],onToggle:function(){bi(),Pt(o,"left")},navigation:e.id?Ci[e.id]:null,showOpenNodeRef:Bi,resolvedMarkdownStyles:Ce,maintainRelativeOrder:kn,showDeviationBadges:An,renderSubSections:_i})})),kn&&a&&t(d,n({ref:mt.current[o],onClick:function(n){var t=kn?ut.find(function(n){var e;return null===(e=c.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)})||{title:"",content:""}:ut[o]||{title:"",content:""};Wt(n,e,s,t,o,a)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&i(d,n({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:v})),i(d,n({component:"span",sx:{fontSize:"11px",px:.25}},{children:!wn.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?s?"No Deviation Found":"N/A"===f||"NA"===f?"N/A":0==f||null==f?"Same":"".concat(f):i(M,{color:a.badgeText})})),i(g,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))}),i("div",{ref:Fe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,n({ref:Vt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(d,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,n({onClick:function(e){e.stopPropagation(),He.open&&We===Ft?Je():(Ve(Ft),zt(Ot(e.currentTarget,{title:"",content:"",evaluationResult:Dt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Ft,!0,n(n({},Mt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:Mt.badgeBg,color:Mt.badgeText,border:"1px solid ".concat(Mt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=kt?kt:i(M,{}),i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(f,{size:11,style:{transform:He.open&&We===Ft?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(d,n({sx:n({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},kn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Pn&&i(x,{sections:11}),i(d,n({ref:$t,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,n({title:tt,placement:"top"},{children:i(p,n({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:tt}))}))})),t(d,n({ref:Ie,onScroll:vi,sx:n({p:"12px",display:"flex",flexDirection:"column"},kn?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:Te,style:{width:"100%",height:"0px",flexShrink:0}}),vt&&ut.map(function(e,o){var r,l=e,u=[],c=!1,a=null,s=-1;if(kn){u=lt.filter(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(l.selfIndex))&&n.selfIndex>=0}).map(function(n){return n.selfIndex+1}),s=lt.findIndex(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(l.selfIndex))&&n.selfIndex>=0});var v=lt.findIndex(function(n,e){var t;return re.has(e)&&(null===(t=n.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==v)&&(a=oi(v))}else u=[o+1],(c=re.has(o))&&(a=oi(o));var p=oi(kn&&-1!==s?s:o);return i(d,n({ref:bt.current[o],sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:xt.current[o],sx:n({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:i(O,{section:e,idx:o,columnKey:"right",colRef:Bt("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==yn?void 0:yn.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:kn?!!Ht["right-".concat(o)]:!!Ht[String(o)],treeData:yn,proposedSections:lt,existingSections:ut,deviationNumberRegistry:at,getBadgeRef:It,getSectionCompareStyle:oi,connectedSections:re,openMoreFunctionsPopup:Wt,openSummaryPopup:mi,deviationNodeIdToView:En,deviationTargetParentId:wi,onToggle:function(){bi(),Pt(o,"right")},navigation:e.id?Ci[e.id]:null,showOpenNodeRef:Bi,resolvedMarkdownStyles:Ce,maintainRelativeOrder:kn,showDeviationBadges:An,renderSubSections:_i})})),kn&&p&&i(d,n({ref:yt.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:p.badgeBg,color:p.badgeText,border:"1px solid ".concat(p.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),i("div",{ref:_e,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Y as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__rest as n,__spreadArray as r}from"tslib";import{jsx as
|
|
1
|
+
import{__assign as e,__rest as n,__spreadArray as r}from"tslib";import{jsx as i,jsxs as o,Fragment as t}from"react/jsx-runtime";import{Box as l,Typography as a}from"@mui/material";import c,{useMemo as d}from"react";import{DEFAULT_DEVIAION_COLOR as s}from"../CognitiveCompareConstants.js";import{EllipsisVertical as p}from"lucide-react";import h from"react-markdown";import{safeStringify as u,areMarkdownPropsEqual as g}from"../CognitiveComparehelpers.js";import f from"rehype-raw";var v=c.memo(function(g){var v=g.content,m=g.sxStyles,x=g.deviationBadges,b=void 0===x?[]:x,C=g.highlights,y=void 0===C?[]:C,E=g.maintainRelativeOrder,F=void 0===E||E,_=g.highlightBg,S=d(function(){return b.reduce(function(n,r){var i;return e(e({},n),((i={})[r.id]=r,i))},{})},[b]),w=function(n,r){return c.Children.map(n,function(n){var i;if(!c.isValidElement(n))return n;var o=(null===(i=n.props)||void 0===i?void 0:i.children)?w(n.props.children,r):n.props.children,t=c.cloneElement(n,e(e({},n.props),{children:o}));return r(t)})},k=d(function(){return{mark:function(r){var o=r.children,t=n(r,["children"]);return i("span",e({style:e(e({},t.isSuggestedDeviationFix?{}:{backgroundColor:_}),{borderRadius:"2px"})},{children:o}))},span:function(r){var t,a,c,d,h,u,g=r.children,f=n(r,["children"]),v=f["data-badge-id"];if(!v)return i("span",e({},f,{children:g}));var m=S[v];return m?o(l,e({component:"span",sx:{position:"static",display:"inline"}},{children:[o(l,e({ref:m.badgeRef,sx:e(e({fontStyle:"normal",position:"absolute",zIndex:30,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(t=m.style)||void 0===t?void 0:t.badgeBg)||"#EEF2FF",color:(null===(a=m.style)||void 0===a?void 0:a.badgeText)||s,border:"1px solid ".concat((null===(c=m.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden"},"left"===m.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),m.isConnected&&m.style&&{outline:"2px solid ".concat(m.style.badgeBorder),outlineOffset:"1px"})},{children:[o(l,e({onClick:function(e){e.stopPropagation(),m.onSummaryClick&&m.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[i(l,e({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:m.label})),("left"===m.side||m.isOrphan)&&i(l,e({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=m.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=m.score&&"N/A"!==m.score&&"NA"!==m.score&&0!==m.score?"".concat(m.score):"N/A"===m.score||"NA"===m.score?"N/A":"Same"}))]})),("left"===m.side||m.isOrphan)&&i(l,e({onClick:function(e){e.stopPropagation(),m.onClick&&m.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(h=m.style)||void 0===h?void 0:h.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:i(p,{size:12,color:(null===(u=m.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),g]})):i("span",e({},f,{children:g}))},updated:function(e){var r=e.children;return n(e,["children"]),i(t,{children:r})},deleted:function(r){var o=r.children;n(r,["children"]),console.log("nitish: ",o);var t=w(o,function(e){return c.cloneElement(e,{isSuggestedDeviationFix:!0})});return i("span",e({style:{borderTop:"1px solid #EF4444",borderBottom:"1px solid #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:t}))},changed:function(r){var o=r.children;n(r,["children"]);var t=w(o,function(e){return c.cloneElement(e,{isSuggestedDeviationFix:!0})});return i("span",e({style:{borderTop:"1px solid #2F59FF",borderBottom:"1px solid #2F59FF",backgroundColor:"#D5E8FF"}},{children:t}))}}},[S,F]),B=d(function(){var e=function(e){return e?e.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n").split(/(\n{2,})/).map(function(e){return e.startsWith("\n")?e:e.replace(/\n/g," ")}).join(""):""},n=function(e,n,r){void 0===n&&(n=""),void 0===r&&(r="");var i=e.startsWith("\n\n"),o=e.endsWith("\n\n");return n+e.split(/(\n{2,})/).map(function(e,n,r){if(/^\n{2,}$/.test(e))return e;if(!e.trim())return e;var t=0===n||1===n&&/^\n{2,}$/.test(r[0]),l=n===r.length-1||n===r.length-2&&/^\n{2,}$/.test(r[r.length-1]);return i&&t||o&&l?e:"<mark>".concat(e,"</mark>")}).join("").replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")+r},i=e(u(v||"")),o=r([],b,!0).sort(function(e,n){var r,i;return((null===(r=n.highlight)||void 0===r?void 0:r.length)||0)-((null===(i=e.highlight)||void 0===i?void 0:i.length)||0)}),t={},l=0;o.forEach(function(r){if(r&&r.highlight){var o=e(r.highlight);if(o){var a=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c="__DEV_TOKEN_".concat(l++,"__");t[c]=n(o,'<span data-badge-id="'.concat(r.id,'">'),"</span>"),i=i.replace(o,c);var d="__HIGHLIGHT_TOKEN_".concat(l++,"__");t[d]=n(o),i=i.replace(new RegExp(a,"g"),d)}}});var a=new Set(o.map(function(n){return e(n.highlight)}).filter(Boolean));return y.forEach(function(r){if(r){var o=e(r);if(o&&!a.has(o)){var c=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d="__PLAIN_TOKEN_".concat(l++,"__");t[d]=n(o),i=i.replace(new RegExp(c,"g"),d)}}}),Object.keys(t).forEach(function(e){i=i.split(e).join(t[e])}),i},[v,b,y]);return i(a,e({component:"div",sx:e(e({},m),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}})},{children:i(h,e({components:k,rehypePlugins:[f]},{children:u(B).replace(/\\n/g,"\n")}))}))},g);export{v as MemoizedMarkdown};
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAyC,CAAA;AAEnF,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAyC,CAAA;AAEnF,eAAO,MAAM,iBAAiB,EAAE,GA61F/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAiBlC,QAAA,MAAM,gBAAgB,4MAmBnB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAiBlC,QAAA,MAAM,gBAAgB,4MAmBnB,qBAAqB,4CA6tGvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoizedMarkdown.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/memoizedMarkdown.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"memoizedMarkdown.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/memoizedMarkdown.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAQhE,eAAO,MAAM,gBAAgB;aAQlB,MAAM;cACL,GAAG;;;;iBAIA,MAAM;8CA4SI,CAAC"}
|