@viswa-test/test-citation 0.0.105 → 0.0.107
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/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/CognitiveSummaryPopup.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/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/types/src/CognitiveCompareTest.d.ts.map +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/CognitiveComparehelpers.d.ts +7 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.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"),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"),b=require("./components/connectedLines.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var E,T,I,B,C,D,O,w,N,j,P,F,M,k,V,L,G,H,q,z,W,Y,K,U,X,J,$=A.componentHeaderText,Q=void 0===$?a.DEFAULT_COMPONENT_HEADER_TEXT:$,Z=A.treeData,ee=A.comparisonConfig,ne=A.leftColumnTitleText,te=A.rightColumnTitleText,ie=A.markdownStyles,oe=A.resetTrigger,le=A.displayConfig,re=void 0===le?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:le,ue=A.popupConfig,ce=A.deviationData,ae=void 0===ce?{}:ce,se=A.deviationNodeIdToView,de=A.resetDeviationNodeId,ve=t.useState(re.maintainRelativeOrder),fe=ve[0],ge=ve[1],pe=!!fe||!!(null==re?void 0:re.showDeviationBadges),he=t.useState(!1),xe=he[0],_e=he[1],me=t.useState(!1),Re=me[0],ye=me[1],Se=t.useState(null),be=Se[0],Ae=Se[1],Ee=t.useState(!1),Te=Ee[0],Ie=Ee[1],Be=t.useState(null===(T=null!==(E=null==Z?void 0:Z.newEvaluationResult)&&void 0!==E?E:null==re?void 0:re.enableDeviationSchemaBackwardCompatibility)||void 0===T||T)[0],Ce=t.useState(!1),De=Ce[0],Oe=Ce[1],we=t.useState(!1),Ne=we[0],je=we[1],Pe=t.useState(null),Fe=Pe[0],Me=Pe[1],ke=t.useRef(!1),Ve=t.useState(new Set),Le=Ve[0],Ge=Ve[1],He=t.useState([]),qe=He[0],ze=He[1],We=t.useRef(null),Ye=t.useRef(!1),Ke=t.useRef(null),Ue=t.useRef({}),Xe=t.useRef([]),Je=t.useRef(!1),$e=t.useRef(!1),Qe=t.useRef(null),Ze=t.useRef(function(){}),en=t.useMemo(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),nn=t.useState({width:0,height:0}),tn=nn[0],on=nn[1],ln=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),ie)},[ie]),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(null),fn=t.useRef(null),gn=t.useRef(!1),pn=t.useRef(null),hn=t.useRef(null),xn=p.useComparePopups(rn),_n=xn.cognitivePopup,mn=xn.setCognitivePopup,Rn=xn.moreFunctions,yn=xn.setMoreFunctions,Sn=xn.position,bn=xn.setPosition,An=xn.activeBadgeId,En=xn.summaryPopup,Tn=xn.setSummaryPopup,In=xn.closeSummaryPopup,Bn=xn.setActiveBadgeId,Cn=xn.popupRef,Dn=xn.closeCognitivePopup,On=xn.closeMoreFunctionsPopup,wn=t.useMemo(function(){var e,n,t,i,o,l,r;return{fields:null!==(e=null==ee?void 0:ee.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==ee?void 0:ee.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==ee?void 0:ee.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(r=null===(l=null==ee?void 0:ee.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[ee]),Nn=t.useState(null),jn=Nn[0];Nn[1];var Pn=null===(C=null===(I=null==Z?void 0:Z.documents)||void 0===I?void 0:I[null===(B=null==Z?void 0:Z.input_index_map)||void 0===B?void 0:B[0]])||void 0===C?void 0:C.title,Fn=null===(w=null===(D=null==Z?void 0:Z.documents)||void 0===D?void 0:D[null===(O=null==Z?void 0:Z.input_index_map)||void 0===O?void 0:O[1]])||void 0===w?void 0:w.title,Mn=u.safeStringify(ne||Pn||"Uploaded Contract"),kn=u.safeStringify(te||Fn||"Reference Template"),Vn=g.useCognitiveTreeData(Z,fe,ae,wn,Be),Ln=Vn.activeProposed,Gn=Vn.existingRule,Hn=Vn.proposedSections,qn=Vn.existingSections,zn=Vn.visibleFields,Wn=Vn.parentDeviationRecord,Yn=Vn.deviationNumberRegistry,Kn=Vn.parseError;t.useEffect(function(){Kn&&Ae("Failed to load comparison: ".concat(Kn))},[Kn]);var Un=Hn.length>0||qn.length>0,Xn=h.useSectionRefs(zn.map(function(e){return e.key}),Math.max(Hn.length,qn.length)),Jn=Xn.leftRefs,$n=Xn.rightRefs,Qn=Xn.sectionLeftRefs,Zn=Xn.sectionRightRefs,et=Xn.lhsBadgeRefs,nt=Xn.rhsBadgeRefs,tt=Xn.sectionRightRowRefs,it=Xn.subSectionLeftRefs,ot=Xn.subSectionRightRefs,lt=Xn.sectionRowRefs,rt=Xn.getSectionRowRef,ut=Xn.getSubSectionRef,ct=Xn.getBadgeRef,at=Gn.analysis,st=u.safeStringify(null===(j=null===(N=null==at?void 0:at.rule_difference_comparison)||void 0===N?void 0:N.summary)||void 0===j?void 0:j.overall_summary),dt=!!st.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),vt=null!==(P=null==Z?void 0:Z.base_root_id)&&void 0!==P?P:"-1";null==Z||Z[vt];var ft=Be?null!==(K=null!==(z=ae&&(null===(q=null==ae?void 0:ae[vt])||void 0===q?void 0:q.evaluation_result))&&void 0!==z?z:null===(Y=null===(W=null==Z?void 0:Z.nodes)||void 0===W?void 0:W[vt])||void 0===Y?void 0:Y.evaluation_result)&&void 0!==K?K:null:null!==(H=null!==(k=ae&&(null===(M=null===(F=null==ae?void 0:ae[vt])||void 0===F?void 0:F.evaluation_result)||void 0===M?void 0:M[0]))&&void 0!==k?k:null===(G=null===(L=null===(V=null==Z?void 0:Z.nodes)||void 0===V?void 0:V[vt])||void 0===L?void 0:L.evaluation_result)||void 0===G?void 0:G[0])&&void 0!==H?H:null,gt=u.extractDeviationScore(ft),pt=u.generateColorPalette(null!==(J=null===(X=null===(U=null==ft?void 0:ft.evaluation_outputs)||void 0===U?void 0:U.metadata)||void 0===X?void 0:X.label_color)&&void 0!==J?J:""),ht=t.useCallback(function(){var e,n,t,i,o,l;Ie(!1),$e.current=!1;var r=Qe.current,c=wt.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=it.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=Qn.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=Qn.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=ot.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=Zn.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(l=Zn.current[c])||void 0===l?void 0:l.current)&&(d.style.paddingTop="0px")}Me(null),Qe.current=null,wt.current=null,Oe(!1),ye(!1),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),dn.current&&(dn.current.style.height="0px"),vn.current&&(vn.current.style.height="0px")},[]),xt=t.useCallback(function(){ht(),Ge(new Set),ze([]),Xe.current=[],kt([]),Gt(null),Tn(a.EMPTY_SUMMARY_POPUP_STATE),Dn(),requestAnimationFrame(function(){var e;null===(e=Ze.current)||void 0===e||e.call(Ze)})},[]),_t=t.useRef(xt);t.useEffect(function(){_t.current=xt},[xt]),t.useEffect(function(){oe&&_t.current()},[oe]);var mt=x.useAccordionState({maintainRelativeOrder:!!fe,proposedSections:Hn,existingSections:qn,activeSideBySideSection:Fe,connectedSections:Le,resetSideBySide:ht,setConnectedSections:Ge,setConnectedLines:ze,cachedConnectedPositions:Xe,svgContainerRef:We,isAnimatingRef:Ye,animationTimerRef:Ke,calculateLinesRef:Ze,sectionLeftRefs:Qn,sectionRightRefs:Zn,subSectionLeftRefs:it,subSectionRightRefs:ot}),Rt=mt.expandedSections,yt=mt.setExpandedSections,St=mt.expandedSubSections,bt=mt.setExpandedSubSections,At=mt.toggleSection,Et=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)||"",f=(v?en[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=lt.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==re?void 0:re.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:r||null,sectionIdx:o,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.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}},[en,Z]),Tt=t.useCallback(function(e){On(),bn(null),mn(e)},[On]),It=function(e,n,t,i,o,l){var r;if(e.stopPropagation(),Rn.open&&Rn.sectionIdx===o)On();else{var c=e.currentTarget,a="left";(null===(r=cn.current)||void 0===r?void 0:r.contains(c))&&(a="right");$e.current&&ht(),Ge(new Set),ze([]),Xe.current=[],Dn(),En.open?ci():In(),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=nt.current[r])||void 0===e?void 0:e.current:null===(n=et.current[r])||void 0===n?void 0:n.current}return"right"===a?null===(t=nt.current[o])||void 0===t?void 0:t.current:null===(i=et.current[o])||void 0===i?void 0:i.current}()||c;yn(Et(e,n,i,o,t,l))})}},Bt=t.useCallback(function(){null!==Rn.sectionIdx&&Rn.anchorEl?Tt(e.__assign(e.__assign({},Rn),{open:!0})):On()},[Rn,On,Tt]),Ct=t.useCallback(function(){var e=Rn.sectionIdx,n=Rn.isOrphan;On(),In(),null!==e&&(n?Ae("No counterpart exists to connect to."):($e.current&&ht(),ze([]),Xe.current=[],Ge(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Ze.current&&Ze.current()},50)))},[Rn.sectionIdx,Rn.isOrphan,On,In,ht]),Dt=t.useRef(null),Ot=t.useRef(null),wt=t.useRef(null),Nt=t.useRef(null),jt=t.useRef(null),Pt=t.useRef(null),Ft=t.useState([]),Mt=Ft[0],kt=Ft[1];t.useRef(null);var Vt=t.useState(null),Lt=Vt[0],Gt=Vt[1];t.useEffect(function(){if(jn){var e=wn.fields.find(function(e){return e.analysisKey===jn||e.key===jn});if(e){var n=Jn.current[e.key]||$n.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[jn,wn.fields]);var Ht=t.useCallback(function(e){var n,t,i,o,l,r,u,c,a,s=null===(n=null==at?void 0:at.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 f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(r=f.highlights)||void 0===r?void 0:r.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}},[at]),qt=t.useCallback(function(n,t){var i,o,l;void 0===t&&(t="left");var r=null,c=null;if("left"===t)if(r=Hn[n],fe&&r){var s=qn.filter(function(e){var n;return null===(n=r.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});c=s.find(function(e){return e.evaluationResult})||s[0]}else c=qn[n];else if(c=qn[n],fe&&c){var d=Hn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)});r=d.find(function(e){return e.evaluationResult})||d[0]}else r=Hn[n];var v=(null==r?void 0:r.relation)&&"not_defined"!==r.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,g=!(!(null==r?void 0:r.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!v&&!f&&!g)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==r?void 0:r.evaluationResult)&&void 0!==i?i:null==c?void 0:c.evaluationResult)&&void 0!==o?o:null,h=u.getFirstDeviationOutputValue(p),x=u.getFirstDeviationColor(p);return null!=p?e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null!==(l=h)&&void 0!==l?l:""}):e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null})},[Hn,qn,en,wn,fe]),zt=t.useCallback(function(n){for(var t,i,o,l,r,c=n.split("-").map(Number),s=Hn[c[0]],d=qn[c[0]],v=1;v<c.length;v++)(null==s?void 0:s.subsections)&&(s=s.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!s&&!d)return null;var f=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,g=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=u.safeStringify(null==s?void 0:s.id)||u.safeStringify(null==d?void 0:d.id)||"",h=!(!(null==s?void 0:s.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!f&&!g&&!h)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=en[p])||void 0===o||o.relevance_score);var x=null!==(r=null!==(l=null==s?void 0:s.evaluationResult)&&void 0!==l?l:null==d?void 0:d.evaluationResult)&&void 0!==r?r:null,_=u.getFirstDeviationOutputValue(x),m=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(m)),{label:null!=_?_:""}):e.__assign(e.__assign({},u.generateColorPalette(m)),{label:null})},[Hn,qn,en,wn]),Wt=t.useCallback(function(n,t){var i,o,l,r,c,s,d,v,f,g,p,h,x,_,m,R,y;if(!n||null==t)return null;var S=null!==(d=null!==(c=null!==(o=null===(i=null==ae?void 0:ae[n])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(r=null===(l=null==Z?void 0:Z.nodes)||void 0===l?void 0:l[n])||void 0===r?void 0:r.evaluation_result)&&void 0!==c?c:null===(s=null==Z?void 0:Z[n])||void 0===s?void 0:s.evaluation_result)&&void 0!==d?d:null;if(!S||"object"!=typeof S)return null;var b=null!==(p=null!==(f=null===(v=null==S?void 0:S.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==S?void 0:S.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==S?void 0:S[t],A=null!==(y=null!==(_=null===(x=null===(h=null==b?void 0:b.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==_?_:null===(R=null===(m=null==S?void 0:S.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===R?void 0:R.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR;return e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[ae,Z]),Yt=t.useCallback(function(){yt({}),bt({}),ht(),Ge(new Set),ze([]),Xe.current=[],In(),Dn(),On(),requestAnimationFrame(function(){Ze.current&&Ze.current()})},[yt,bt,ht,In,Dn,On]),Kt=t.useMemo(function(){return Object.values(Rt).some(Boolean)||Object.values(St).some(Boolean)},[Rt,St]),Ut=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,f,g,p,h,x,_,m,R,y,S,b;if(!gn.current&&!Ye.current){gn.current=!0;try{if(!Dt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!Rt[t]&&!1===fe)return!1;if(fe&&!Rt["left-".concat(t)]&&!Rt["right-".concat(t)]&&!Rt[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!St[i])return!1;return!0},E=Dt.current.getBoundingClientRect();on({width:E.width,height:E.height});var T=[];if(zn.forEach(function(e){var n,t,i=e.key,o=null===(n=Jn.current[i])||void 0===n?void 0:n.current,l=null===(t=$n.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")}),!Ye.current){for(var I=0;I<Math.max(Hn.length,qn.length);I++){var B=null===(e=Qn.current[I])||void 0===e?void 0:e.current,C=null===(n=Zn.current[I])||void 0===n?void 0:n.current;B&&(B.style.height="auto",B.style.minHeight="0px"),C&&(C.style.height="auto",C.style.minHeight="0px")}fe||Object.keys(it.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=it.current[e])||void 0===n?void 0:n.current,o=null===(t=ot.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={};zn.forEach(function(e){var n,t,i=e.key,o=null===(n=Jn.current[i])||void 0===n?void 0:n.current,l=null===(t=$n.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 O={left:{},right:{}},w={};if(!Ye.current)if(fe){if(Te&&null!==Fe)if("number"==typeof Fe){var N=Fe,j=Hn[N],P=null===(o=Qn.current[N])||void 0===o?void 0:o.current;P&&j&&(j.refIndexes||[]).forEach(function(e){var n,t=qn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Zn.current[t])||void 0===n?void 0:n.current;if(i&&(Rt["left-".concat(N)]||Rt["right-".concat(t)])){var o=Math.max(P.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[N]=Math.max(O.left[N]||0,o),O.right[t]=Math.max(O.right[t]||0,o)}})}else{var F=Fe.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(l=it.current[F])||void 0===l?void 0:l.current,C=null===(r=ot.current[F])||void 0===r?void 0:r.current;if(B&&C){M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);w[F]=Math.max(w[F]||0,M)}}}}else{Object.keys(it.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=it.current[e])||void 0===n?void 0:n.current,o=null===(t=ot.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);w[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(I=0;I<Math.min(Hn.length,qn.length);I++){var B=null===(t=Qn.current[I])||void 0===t?void 0:t.current,C=null===(i=Zn.current[I])||void 0===i?void 0:i.current;if(B&&C){var M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);O.left[I]=M,O.right[I]=M}}}if(zn.forEach(function(e){var n,t,i=e.key,o=null===(n=Jn.current[i])||void 0===n?void 0:n.current,l=null===(t=$n.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")}}),Ye.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Qn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(O.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Zn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),fe||Object.keys(w).forEach(function(e){var n,t,i=null===(n=it.current[e])||void 0===n?void 0:n.current,o=null===(t=ot.current[e])||void 0===t?void 0:t.current;if(i&&o&&w[e]){var l=w[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),fe)Hn.forEach(function(e,n){var t;(null===(t=Qn.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=qn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=et.current[n])||void 0===t?void 0:t.current,g=null===(i=nt.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-E.left,_=h.left-E.left,m=p.top+p.height/2-E.top,R=h.top+h.height/2-E.top;if(Te&&Fe===n){var y=null!==(l=null===(o=fn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,S=null!==(u=null===(r=cn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==u?u:0,b=y+(null!==(a=null===(c=fn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=S+(null!==(d=null===(s=cn.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),I=p.top+p.height/2,B=h.top+h.height/2,C=function(e,n,t){return Math.max(n,Math.min(t,e))};m=C(I,y,b)-E.top,R=C(B,S,A)-E.top}var D=qt(n);D&&T.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(I=0;I<Math.min(Hn.length,qn.length);I++){var k=null===(c=Qn.current[I])||void 0===c?void 0:c.current,V=null===(a=Zn.current[I])||void 0===a?void 0:a.current;if(k&&V){var L=k.getBoundingClientRect(),G=V.getBoundingClientRect(),H=Math.max(L.top,G.top)+18-E.top,q=(null===(s=qn[I])||void 0===s?void 0:s.id)||"sec-".concat(I);($=qt(I))&&T.push({id:q,x1:L.right-E.left,y1:H,x2:G.left-E.left,y2:H,style:$,sectionIdx:I,hasCognitive:!!((null===(d=Hn[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=qn[I])||void 0===v?void 0:v.cognitiveData)||q&&en[q]),isSubSection:!1})}}Object.keys(it.current).forEach(function(e){var n,t,i,o,l,r;if(A(e)){var c=null===(n=it.current[e])||void 0===n?void 0:n.current,a=null===(t=ot.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Hn[s[0]],v=qn[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===(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(g&&p||h&&x){var _=c.getBoundingClientRect(),m=a.getBoundingClientRect(),R=Math.max(_.top,m.top)+16-E.top,y=zt(e);y&&"Not Defined"!==y.label&&T.push({id:"subsec-".concat(e),x1:_.right-E.left,y1:R,x2:m.left-E.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(Te&&"string"==typeof Fe&&Fe.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Fe.split(u.DEVIATION_BADGE_SEPARATOR),W=z[0],Y=z[1],K=z[2],U=(z[3],"".concat(W).concat(u.DEVIATION_BADGE_SEPARATOR).concat(Y)),X=null===(f=et.current[U])||void 0===f?void 0:f.current,J=null===(g=nt.current[U])||void 0===g?void 0:g.current;if(X&&J){var $,Q=X.getBoundingClientRect(),Z=J.getBoundingClientRect(),ee=Q.right-E.left,ne=Z.left-E.left,te=Q.top+Q.height/2-E.top,ie=Z.top+Z.height/2-E.top;if(fe){var oe=null!==(h=null===(p=fn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,le=null!==(_=null===(x=cn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,re=oe+(null!==(R=null===(m=fn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),ue=le+(null!==(S=null===(y=cn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,re)-E.top,ie=ce(Z.top+Z.height/2,le,ue)-E.top}($=null!==(b=Wt(W,Y))&&void 0!==b?b:zt(K))&&T.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:$,sectionIdx:Number(K.split("-")[0]),isSubSection:!0,subSectionKeyPath:Fe})}}if(kt(T),jt.current&&Pt.current){var ae=jt.current.getBoundingClientRect(),se=Pt.current.getBoundingClientRect(),de=(ae.top+ae.height/2-E.top+se.top+se.height/2-E.top)/2;Gt({x1:ae.right-E.left,x2:se.left-E.left,y:de})}else Gt(null);if(Le.size>0){var ve=[],ge=fn.current,pe=cn.current;if(ge&&pe){var he=[],xe=ge.getBoundingClientRect().top,_e=pe.getBoundingClientRect().top,me=xe+ge.clientHeight,Re=_e+pe.clientHeight,ye=ge.scrollTop,Se=pe.scrollTop,be=E.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};Le.forEach(function(e){var n,t,i,o,l,r;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var c=e.split(u.DEVIATION_BADGE_SEPARATOR),a=c[0],s=c[1],d=c[2],v=(c[3],"".concat(a).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=et.current[v])||void 0===n?void 0:n.current,g=null===(t=nt.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=Wt(a,s))&&void 0!==i?i:zt(d),_=(P=p.right-E.left)+.5*((F=h.left-E.left-0)-P),m=p.top+p.height/2,R=h.top+h.height/2,y=m-xe+ye,S=R-_e+Se,b="conn-subsec-".concat(v);he.push({lhsScrollY:y,rhsScrollY:S,x1:P,x2:F,containerTop:be,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:b});var A=Ae(m,xe,me),T=Ae(R,_e,Re),I=A-be,B=T-be,C=R>=_e-4&&R<=Re+4,D="";D=(M=m>=xe-4&&m<=me+4)&&C?u.getBentArrowPath(P,I,F,B):M&&!C?"M ".concat(P,",").concat(I," L ").concat(_,",").concat(I," L ").concat(_,",").concat(B):!M&&C?"M ".concat(_,",").concat(I," L ").concat(_,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(_,",").concat(I," L ").concat(_,",").concat(B),ve.push({id:b,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(fe){var O=e,w=Hn[O];if(!(null===(r=null==w?void 0:w.refIndexes)||void 0===r?void 0:r.length))return;w.refIndexes.forEach(function(e){var n,t,i=qn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=et.current[O])||void 0===n?void 0:n.current,l=null===(t=nt.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),c=l.getBoundingClientRect(),a=qt(O),s=r.right-E.left,d=c.left-E.left-0,v=s+.5*(d-s),f=r.top+r.height/2,g=c.top+c.height/2,p=f-xe+ye,h=g-_e+Se,x="conn-".concat(O,"-").concat(i);he.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:be,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=Ae(f,xe,me),m=Ae(g,_e,Re),R=_-be,y=m-be,S=f>=xe-4&&f<=me+4,b=g>=_e-4&&g<=Re+4,A="";A=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:A,style:a,leftIdx:O,rhsArrayIdx:i})}}})}else{var N=e,j=N;f=null===(o=et.current[N])||void 0===o?void 0:o.current,g=null===(l=nt.current[j])||void 0===l?void 0:l.current;if(!f||!g)return;var P,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=qt(N),_=(P=p.right-E.left)+.5*((F=h.left-E.left-0)-P),m=p.top+p.height/2,R=h.top+h.height/2,y=m-xe+ye,S=R-_e+Se,b="conn-".concat(N,"-").concat(j);he.push({lhsScrollY:y,rhsScrollY:S,x1:P,x2:F,containerTop:be,leftIdx:N,rhsArrayIdx:j,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:b});var M;A=Ae(m,xe,me),T=Ae(R,_e,Re),I=A-be,B=T-be,C=R>=_e-4&&R<=Re+4,D="";D=(M=m>=xe-4&&m<=me+4)&&C?u.getBentArrowPath(P,I,F,B):M&&!C?"M ".concat(P,",").concat(I," L ").concat(_,",").concat(I," L ").concat(_,",").concat(B):!M&&C?"M ".concat(_,",").concat(I," L ").concat(_,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(_,",").concat(I," L ").concat(_,",").concat(B),ve.push({id:b,pathD:D,style:x,leftIdx:N,rhsArrayIdx:j})}}),Xe.current=he}ze(ve)}else ze([]),Xe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{gn.current=!1}}},[zn,Hn,qn,en,wn,Ht,qt,Wt,fe,Te,Fe,Le,Rt,St]),Xt=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,f,g,p=Xe.current;if(p.length&&!Ye.current){var h=null!==(n=null===(e=fn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=cn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(l=null===(o=fn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,m=null!==(c=null===(r=cn.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=fn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=cn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,b=y+m,A=null!==(g=null===(f=Dt.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=Ue.current[e.styleId+"-stroke"],o=Ue.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,f=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(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",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]);t.useEffect(function(){Ze.current=Ut},[Ut]);var Jt=t.useRef(null),$t=t.useRef(null),Qt=t.useCallback(function(){Xe.current.length>0&&!Ye.current||(null!==Jt.current&&clearTimeout(Jt.current),Jt.current=setTimeout(function(){Ze.current(),Jt.current=null},50))},[]),Zt=t.useCallback(function(){je(!0),Oe(!1),null!==$t.current&&clearTimeout($t.current),null!==Jt.current&&(clearTimeout(Jt.current),Jt.current=null),$t.current=setTimeout(function(){var e,n,t,i,o,l,r,c,a,s,d;try{if(Xe.current=[],$e.current&&null!==Qe.current&&null!==wt.current){var v=Qe.current,f=wt.current,g="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR),p=null,h=null,x=null,_=null;if(g){var m=v.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(m[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(m[1]);p=(null===(e=et.current[R])||void 0===e?void 0:e.current)||null,h=(null===(n=nt.current[R])||void 0===n?void 0:n.current)||null,x=(null===(t=it.current[m[2]])||void 0===t?void 0:t.current)||(null===(i=Qn.current[Number(m[2])])||void 0===i?void 0:i.current)||null,_=(null===(o=ot.current[m[3]])||void 0===o?void 0:o.current)||(null===(l=Zn.current[Number(m[3])])||void 0===l?void 0:l.current)||null}else p=(null===(r=lt.current[v])||void 0===r?void 0:r.current)||null,x=(null===(c=Qn.current[v])||void 0===c?void 0:c.current)||null,h=(null===(a=tt.current[f])||void 0===a?void 0:a.current)||null,_=(null===(s=Zn.current[f])||void 0===s?void 0:s.current)||null;if(p&&h&&x&&_){if(x.style.paddingTop="0px",_.style.paddingTop="0px",!fe){var y=p.getBoundingClientRect(),S=h.getBoundingClientRect(),b=y.top-S.top;b>0?_.style.paddingTop="".concat(b,"px"):b<0&&(x.style.paddingTop="".concat(Math.abs(b),"px"))}var A=fn.current,E=cn.current;if(A&&E){var T=p.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop,I=h.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop-(T-A.scrollTop);Math.abs(E.scrollTop-I)>1&&(E.scrollTop=I)}}}null===(d=Ze.current)||void 0===d||d.call(Ze),$e.current&&Oe(!0)}catch(e){console.error("Safely caught error during resize calculation:",e)}finally{je(!1),$t.current=null}},150)},[fe,Hn,qn]),ei=t.useCallback(function(e){var n,t,i,o,l,r,c,a,s,d;if(null!==pn.current&&hn.current&&Math.abs(e.currentTarget.scrollTop-pn.current)<=2){var v=hn.current;pn.current=null,hn.current=null,v()}if(!ke.current){if(fe||Qt(),$e.current){var f=Qe.current,g=wt.current,p=fn.current,h=cn.current;if(null!==f&&null!==g&&p&&h){var x="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=et.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=lt.current[f])||void 0===t?void 0:t.current,_="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=nt.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=tt.current[g])||void 0===o?void 0:o.current;if(x&&_&&Nt.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===(l=et.current[S])||void 0===l?void 0:l.current,R=null===(r=nt.current[S])||void 0===r?void 0:r.current}else m=null===(c=et.current[f])||void 0===c?void 0:c.current,R=null===(a=nt.current[g])||void 0===a?void 0:a.current;var b=null!==(d=null===(s=Dt.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 T=m.getBoundingClientRect(),I=R.getBoundingClientRect(),B=T.top+T.height/2;I.top,I.height;var C=((O=B,w=A,N=E,Math.max(w,Math.min(N,O)))-b).toString();Nt.current.setAttribute("y1",C),Nt.current.setAttribute("y2",C);var D=B>=A-4&&B<=E+4;Nt.current.setAttribute("visibility",D?"visible":"hidden")}}}}var O,w,N;Xe.current.length>0&&!Je.current&&(Je.current=!0,requestAnimationFrame(function(){Xt(),Je.current=!1}))}},[Xt,fe,Qt]),ni=t.useRef(0),ti=t.useRef(0),ii=t.useRef(0),oi=t.useRef(function(){});t.useRef(null),t.useEffect(function(){oi.current=Zt},[Zt]),t.useEffect(function(){var e=setTimeout(Qt,250),n=function(){return oi.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==Jt.current&&clearTimeout(Jt.current),null!==$t.current&&clearTimeout($t.current),window.removeEventListener("resize",n)}},[Ln,Gn,at,zn,Rt,St,Hn,qn,wn,Qt,Te,Fe,De,Le]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var l=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var l,r,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(r=null===(l=c.borderBoxSize)||void 0===l?void 0:l[0])||void 0===r?void 0:r.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return l.observe(e),l},n={current:null},t={current:null},i={current:null},o=[],l=[n,t,i];return un.current&&o.push(e(un.current,ni,n,function(){return oi.current()},function(){})),rn.current&&o.push(e(rn.current,ti,t,function(){return oi.current()},function(){return Ze.current()})),Dt.current&&o.push(e(Dt.current,ii,i,function(){return oi.current()},function(){return Ze.current()})),function(){o.forEach(function(e){return e.disconnect()}),l.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){$e.current=Te},[Te]),t.useEffect(function(){Qe.current=Fe},[Fe]);var li=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";On(),null!=e&&(n?Ae("No counterpart exists for this section."):Te&&Fe===e?l?ht():null==r||r():(Ge(new Set([e])),ze([]),Xe.current=[],ye(!0),ke.current=!0,Me(e),Qe.current=e,Ie(!0),$e.current=!0,Oe(!1),an.current&&(an.current.style.height="0px"),sn.current&&(sn.current.style.height="0px"),dn.current&&(dn.current.style.height="0px"),vn.current&&(vn.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 f=e.split(u.DEVIATION_BADGE_SEPARATOR),g="".concat(f[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f[1]);s=(null===(n=et.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=nt.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=lt.current[e])||void 0===i?void 0:i.current)||null,fe){var p=Hn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=qn.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(l=tt.current[_])||void 0===l?void 0:l.current)||null,v=_)}}else d=(null===(o=tt.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;wt.current=v;var m=fn.current,R=cn.current,y=function(){!function(){var n,t,i,o,l,r,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=it.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=Qn.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=ot.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=Zn.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(l=et.current[y])||void 0===l?void 0:l.current)||h,m=(null===(r=nt.current[y])||void 0===r?void 0:r.current)||x}else{var S=Number(e),b=null!==v?Number(v):S;h=(null===(c=Qn.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=Zn.current[b])||void 0===s?void 0:s.current)||null,_=(null===(d=et.current[S])||void 0===d?void 0:d.current)||(null===(f=lt.current[S])||void 0===f?void 0:f.current)||h,m=(null===(g=nt.current[b])||void 0===g?void 0:g.current)||(null===(p=tt.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(),T=A.top-E.top;T>0?x.style.paddingTop="".concat(T,"px"):T<0&&(h.style.paddingTop="".concat(Math.abs(T),"px"))}}(),Oe(!0),Ze.current&&Ze.current(),ke.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),ye(!1),null==r||r()};if(!s||!m)return ke.current=!1,ye(!1),void(null==r||r());if(d&&R){if(!fe){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var b=rn.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 T=s.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,I=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=I-(T-m.scrollTop);C<0&&an.current&&(an.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.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(R,C,B,y)})}e=C}u.smoothScrollTo(R,e,B,y)})}else{var D=T-(I-R.scrollTop);D<0&&dn.current&&(dn.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 vn.current&&(vn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(m,D,B,y)})}e=D}u.smoothScrollTo(m,e,B,y)})}}else y()})))},[Fe,On,qn,Te,fe,Hn,ht]),ri=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;Dn();var c="left";(null===(o=cn.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=nt.current[r])||void 0===e?void 0:e.current:null===(t=et.current[r])||void 0===t?void 0:t.current}return"right"===c?null===(i=nt.current[n])||void 0===i?void 0:i.current:null===(o=et.current[n])||void 0===o?void 0:o.current};if(t)return ht(),Ge(new Set),ze([]),Xe.current=[],void(l&&requestAnimationFrame(function(){var e=a()||r;Tn({open:!0,anchorEl:e,summary:i})}));li(n,t,l?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||r;Tn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[li,Dn,Tn,ht]),ui=t.useCallback(function(){var e,n=Rn.sectionIdx,t=Rn.isOrphan;if(In(),null!=n){var i="left";Rn.anchorEl&&(null===(e=cn.current)||void 0===e?void 0:e.contains(Rn.anchorEl))&&(i="right"),li(n,t,{sourceSide:i})}},[li,Rn.isOrphan,Rn.sectionIdx,Rn.anchorEl,In]),ci=t.useCallback(function(){In(),ht(),Ge(new Set),ze([]),Xe.current=[]},[In,ht]),ai=null!==Rn.sectionIdx&&Le.has(Rn.sectionIdx),si=_.useDeviationNavigation({proposedSections:Hn,existingSections:qn,parentDeviationRecord:Wn,expandedSections:Rt,maintainRelativeOrder:!!fe,scrollContainerRef:rn,leftContainerRef:fn,lhsBadgeRefs:et,rhsBadgeRefs:nt}),di=si.showDeviationNavigation,vi=si.showOpenNodeRef,fi=t.useMemo(function(){var e;if(!se)return null;var n=null===(e=null==se?void 0:se.id)||void 0===e?void 0:e.split(":")[0];for(var t in Wn){if((Wn[t]||[]).some(function(e){return e.id===n}))return t}return null},[se,Wn]),gi=t.useRef({id:null,triggerMs:null}),pi=t.useRef(null);t.useEffect(function(){var n;if(null==se?void 0:se.id){var t=Number(se.trigger),i=gi.current;if((null==i?void 0:i.triggerMs)!==t){var o=null===(n=null==se?void 0:se.id)||void 0===n?void 0:n.split(":"),l=o[0],r=o[1],c=null!=r?r:"0";pi.current!==se.id&&(In(),Dn(),ht(),Ge(new Set),ze([]),Xe.current=[],pi.current=se.id);var a=!1,s=0,d=null,v=150,f=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},g=function(){var n,i,o,r;if(!a){var p=function(){gi.current={id:se.id,triggerMs:t}},h=null,x=null;for(var _ in Wn){var m=Wn[_].find(function(e){return e.id===l});if(m){h=_,x=m;break}}if(x&&h){var R=Hn.findIndex(function(e){return e.id===h}),y=qn.findIndex(function(e){return e.id===h}),S=-1===R&&-1!==y,b=f(Hn,x.id),A=f(qn,x.id);if(b&&!A&&!S){var E=b.split("-"),T=Number(E[0]);if(fe){var I=null===(i=null===(n=Hn[T])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],B=qn.findIndex(function(e){return e.selfIndex===I});-1!==B&&(T=B)}A=e.__spreadArray([T],E.slice(1),!0).join("-")}if(b||A){var C=S||!b&&!!A,D=b?Number(b.split("-")[0]):R,O=A?Number(A.split("-")[0]):y;if(C){if(!(fe?!!Rt["right-".concat(O)]:!!Rt[String(O)])&&O>=0)return At(O,"right"),s+=1,void(d=setTimeout(g,450))}else if(!(fe?!!Rt["left-".concat(D)]:!!Rt[String(D)])&&D>=0)return At(D,"left"),s+=1,void(d=setTimeout(g,450));var w,N=b||"",j=A||"",P="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(N).concat(u.DEVIATION_BADGE_SEPARATOR).concat(j),F="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c),M=null===(o=et.current[F])||void 0===o?void 0:o.current,k=null===(r=nt.current[F])||void 0===r?void 0:r.current,V=C||!M&&!!k,L=V?k:M;if(w=fe?V?cn.current:fn.current:rn.current,L&&w){var G=L.getBoundingClientRect();if(0===G.height)return void((s+=1)<2?d=setTimeout(g,v):p());var H=w.getBoundingClientRect(),q=G.top-H.top+w.scrollTop-H.height/2+G.height/2,z=function(){var n,t,i,o,l;if(!a){p();var r=window.getComputedStyle(L).color;M&&(M.style.transition="box-shadow 300ms ease-in-out",M.style.boxShadow="0 0 10px ".concat(r)),k&&(k.style.transition="box-shadow 300ms ease-in-out",k.style.boxShadow="0 0 10px ".concat(r)),setTimeout(function(){M&&(M.style.boxShadow=""),k&&(k.style.boxShadow="")},2e3);var u=(null===(t=null===(n=x.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[c])||x,s=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!M&&!!k)){var d=V?(null===(o=nt.current[F])||void 0===o?void 0:o.current)||k:(null===(l=et.current[F])||void 0===l?void 0:l.current)||M;return Tn({open:!0,anchorEl:d,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})}),void(null==de||de())}li(P,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=et.current[F])||void 0===n?void 0:n.current)||M;Tn({open:!0,anchorEl:t,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})})}})}};Math.abs(w.scrollTop-q)<=2?z():(pn.current=q,hn.current=z,w.scrollTo({top:q,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(hn.current){pn.current=null;var e=hn.current;hn.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}};return d=setTimeout(g,v),function(){a=!0,d&&clearTimeout(d)}}}},[se,Wn,Hn,qn,fe,Rt,At,li,Tn]);var hi=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:St,setExpandedSubSections:bt,maintainRelativeOrder:fe||!1,proposedSections:Hn,existingSections:qn,treeData:Z,deviationNumberRegistry:Yn,connectedSections:Le,activeSideBySideSection:Fe,resolvedMarkdownStyles:ln,getSubSectionRef:ut,getSubSectionCompareStyle:zt,getBadgeRef:ct,openMoreFunctionsPopup:It,openSummaryPopup:ri,showDeviationBadges:pe,resetSideBySide:ht,setConnectedSections:Ge,setConnectedLines:ze,cachedConnectedPositions:Xe})};return n.jsxs(i.Box,e.__assign({ref:un,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},fe?{}:{overflow:"visible"}),{position:"relative"})},{children:[xe&&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,{})})),En.open&&n.jsx(S.default,{open:En.open,anchorEl:En.anchorEl,containerEl:Ot.current,clipTopEl:jt.current,scrollContainerEl:rn.current,onClose:ci,summary:En.summary}),n.jsx(d.default,{open:Rn.open,anchorEl:Rn.anchorEl,sectionTitle:Rn.sectionTitle,referenceSectionTitle:Rn.refSectionTitle,onClose:On,onOpenCognitiveCompare:Bt,onOpenSideBySide:ui,onConnect:Ct,isConnected:ai,isOrphan:Rn.isOrphan}),_n.open&&n.jsx(s.default,{open:_n.open,popupRef:Cn,position:Sn,popupConfig:ue,onClose:function(){bn(null),mn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Bn(null)},markdownStyles:ie,sectionTitle:_n.sectionTitle,referenceSectionTitle:_n.refSectionTitle,cognitiveData:_n.cognitiveData,anchorEl:_n.anchorEl,sectionAnchorEl:_n.sectionAnchorEl,scrollContainerEl:rn.current,badgeStyle:_n.badgeStyle,docData:_n.docData,deviationData:_n.deviationData,isLoading:_n.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!be,autoHideDuration:8e3,onClose:function(){return Ae(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Ae(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:be}))})),n.jsx(m.default,{componentHeaderText:Q,displayConfig:re,maintainRelativeOrder:fe,onCollapseAll:Yt,showCollapseAll:Kt,onToggleView:function(e){_e(!0),setTimeout(function(){ge(!e),ht(),In(),Ge(new Set),ze([]),Xe.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){_e(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:rn,onScroll:ei,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:fe?"hidden":"auto",borderTop:st&&dt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},fe?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Dt,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},fe?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:We,style:{position:"absolute",top:0,left:0,width:tn.width||"100%",height:tn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Ne?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Lt&&n.jsx("g",{children:n.jsx("line",{x1:Lt.x1,y1:Lt.y,x2:Lt.x2,y2:Lt.y,stroke:pt.badgeBorder,strokeWidth:"1.5"})}),Mt.map(function(t){var r,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?Te&&Fe===t.subSectionKeyPath&&De:Te&&Fe===t.sectionIdx&&De)return null;if(!fe){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),_=Hn[t.sectionIdx]||{title:"",content:""},m=qn[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,T=null;b.length>0&&(E=Hn[b[0]]),A.length>0&&(T=qn[A[0]]);var I=(null==E?void 0:E.title)||"",B=(null==T?void 0:T.title)||"";console.log("Root Parent Titles:",I,B);for(var C=1;C<b.length;C++)(null==E?void 0:E.subsections)&&(E=E.subsections[b[C]]);for(C=1;C<A.length;C++)(null==T?void 0:T.subsections)&&(T=T.subsections[A[C]]);E&&(_=e.__assign(e.__assign({},E),{title:I||E.title})),console.log("Base Section for Subsection Badge:",_),T&&(m=e.__assign(e.__assign({},T),{title:B||T.title})),console.log("Ref Section for Subsection Badge:",m)}var D=!(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===(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=D||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&&(_n.open&&An===t.id?Dn():(Bn(t.id),Tt(Et(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(l.ButtonCognitiveIcon,{})})),w&&n.jsx(o.ChevronDown,{size:11,style:{transform:_n.open&&An===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),n.jsx(b.default,{connectedLines:qe,pathRefs:Ue})]})),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)"},fe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:jt,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:Mn,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:Mn}))}))})),n.jsxs(i.Box,e.__assign({ref:fn,onScroll:ei,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},fe?{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:dn,style:{width:"100%",height:"0px",flexShrink:0}}),Un&&Hn.map(function(t,l){var r,c,a=!t.title&&!t.content;if(fe&&a)return null;var s=t,d=qt(l,"left"),v=fe?!(null===(r=s.refIndexes)||void 0===r?void 0:r.length)||s.selfIndex<0:!qn[l],g=fe?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:l+1,p=Le.has(l),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:rt(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:Qn.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:rt("left-accordion-".concat(l)),mb:0,treeData:Z,proposedSections:Hn,existingSections:qn,deviationNumberRegistry:Yn,getSectionCompareStyle:qt,getBadgeRef:ct,connectedSections:Le,openMoreFunctionsPopup:It,openSummaryPopup:ri,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:fi,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:fe?!!Rt["left-".concat(l)]:!!Rt[String(l)],onToggle:function(){ci(),At(l,"left")},navigation:t.id?di[t.id]:null,showOpenNodeRef:vi,resolvedMarkdownStyles:ln,maintainRelativeOrder:fe,showDeviationBadges:pe,renderSubSections:hi})})),fe&&d&&n.jsxs(i.Box,e.__assign({ref:et.current[l],onClick:function(e){var n=fe?qn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:qn[l]||{title:"",content:""};It(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!==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:!re.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(l))}),n.jsx("div",{ref:vn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:Ot,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(),_n.open&&An===vt?Dn():(Bn(vt),Tt(Et(n.currentTarget,{title:"",content:"",evaluationResult:ft,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,vt,!0,e.__assign(e.__assign({},pt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:pt.badgeBg,color:pt.badgeText,border:"1px solid ".concat(pt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=gt?gt: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(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:_n.open&&An===vt?"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},fe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Re&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Pt,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:kn,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:kn}))}))})),n.jsxs(i.Box,e.__assign({ref:cn,onScroll:ei,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},fe?{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:an,style:{width:"100%",height:"0px",flexShrink:0}}),Un&&qn.map(function(t,o){var l,r=t,u=[],c=!1,a=null,s=-1;if(fe){u=Hn.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=Hn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0});var d=Hn.findIndex(function(e,n){var t;return Le.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(r.selfIndex))});(c=-1!==d)&&(a=qt(d))}else u=[o+1],(c=Le.has(o))&&(a=qt(o));var v=qt(fe&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:tt.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:Zn.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:rt("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(l=null==Z?void 0:Z.input_index_map)||void 0===l?void 0:l[1])||"",isExpanded:fe?!!Rt["right-".concat(o)]:!!Rt[String(o)],treeData:Z,proposedSections:Hn,existingSections:qn,deviationNumberRegistry:Yn,getBadgeRef:ct,getSectionCompareStyle:qt,connectedSections:Le,openMoreFunctionsPopup:It,openSummaryPopup:ri,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:fi,onToggle:function(){ci(),At(o,"right")},navigation:t.id?di[t.id]:null,showOpenNodeRef:vi,resolvedMarkdownStyles:ln,maintainRelativeOrder:fe,showDeviationBadges:pe,renderSubSections:hi})})),fe&&v&&n.jsx(i.Box,e.__assign({ref:nt.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:sn,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"),b=require("./components/connectedLines.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var E,I,T,B,C,D,O,w,N,P,j,F,M,k,V,L,H,G,q,z,W,K,Y,U,X,$,J=A.componentHeaderText,Q=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Z=A.treeData,ee=A.comparisonConfig,ne=A.leftColumnTitleText,te=A.rightColumnTitleText,ie=A.markdownStyles,oe=A.resetTrigger,re=A.displayConfig,le=void 0===re?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:re,ue=A.popupConfig,ce=A.deviationData,ae=void 0===ce?{}:ce,se=A.deviationNodeIdToView,de=A.resetDeviationNodeId,ve=t.useState(le.maintainRelativeOrder),fe=ve[0],ge=ve[1],pe=!!fe||!!(null==le?void 0:le.showDeviationBadges),he=t.useState(!1),xe=he[0],_e=he[1],me=t.useState(!1),Re=me[0],ye=me[1],Se=t.useState(null),be=Se[0],Ae=Se[1],Ee=t.useState(!1),Ie=Ee[0],Te=Ee[1],Be=t.useState(null===(I=null!==(E=null==Z?void 0:Z.newEvaluationResult)&&void 0!==E?E:null==le?void 0:le.enableDeviationSchemaBackwardCompatibility)||void 0===I||I)[0],Ce=t.useState(!1),De=Ce[0],Oe=Ce[1],we=t.useState(!1),Ne=we[0],Pe=we[1],je=t.useState(null),Fe=je[0],Me=je[1],ke=t.useRef(!1),Ve=t.useState(new Set),Le=Ve[0],He=Ve[1],Ge=t.useState([]),qe=Ge[0],ze=Ge[1],We=t.useRef(null),Ke=t.useRef(null),Ye=t.useRef(new Set),Ue=t.useRef(!1),Xe=t.useRef(null),$e=t.useRef({}),Je=t.useRef([]),Qe=t.useRef(!1),Ze=t.useRef(!1),en=t.useRef(null),nn=t.useRef(function(){}),tn=t.useMemo(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),on=t.useState({width:0,height:0}),rn=on[0],ln=on[1],un=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),ie)},[ie]),cn=t.useRef(null),an=t.useRef(null),sn=t.useRef(null),dn=t.useRef(null),vn=t.useRef(null),fn=t.useRef(null),gn=t.useRef(null),pn=t.useRef(null),hn=t.useRef(!1),xn=t.useRef(null),_n=t.useRef(null),mn=p.useComparePopups(cn),Rn=mn.cognitivePopup,yn=mn.setCognitivePopup,Sn=mn.moreFunctions,bn=mn.setMoreFunctions,An=mn.position,En=mn.setPosition,In=mn.activeBadgeId,Tn=mn.summaryPopup,Bn=mn.setSummaryPopup,Cn=mn.closeSummaryPopup,Dn=mn.setActiveBadgeId,On=mn.popupRef,wn=mn.closeCognitivePopup,Nn=mn.closeMoreFunctionsPopup,Pn=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==ee?void 0:ee.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==ee?void 0:ee.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==ee?void 0:ee.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==ee?void 0:ee.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[ee]),jn=t.useState(null),Fn=jn[0];jn[1];var Mn=null===(C=null===(T=null==Z?void 0:Z.documents)||void 0===T?void 0:T[null===(B=null==Z?void 0:Z.input_index_map)||void 0===B?void 0:B[0]])||void 0===C?void 0:C.title,kn=null===(w=null===(D=null==Z?void 0:Z.documents)||void 0===D?void 0:D[null===(O=null==Z?void 0:Z.input_index_map)||void 0===O?void 0:O[1]])||void 0===w?void 0:w.title,Vn=u.safeStringify(ne||Mn||"Uploaded Contract"),Ln=u.safeStringify(te||kn||"Reference Template"),Hn=g.useCognitiveTreeData(Z,fe,ae,Pn,Be),Gn=Hn.activeProposed,qn=Hn.existingRule,zn=Hn.proposedSections,Wn=Hn.existingSections,Kn=Hn.visibleFields,Yn=Hn.parentDeviationRecord,Un=Hn.deviationNumberRegistry,Xn=Hn.parseError;t.useEffect(function(){Xn&&Ae("Failed to load comparison: ".concat(Xn))},[Xn]);var $n=zn.length>0||Wn.length>0,Jn=h.useSectionRefs(Kn.map(function(e){return e.key}),Math.max(zn.length,Wn.length)),Qn=Jn.leftRefs,Zn=Jn.rightRefs,et=Jn.sectionLeftRefs,nt=Jn.sectionRightRefs,tt=Jn.lhsBadgeRefs,it=Jn.rhsBadgeRefs,ot=Jn.sectionRightRowRefs,rt=Jn.subSectionLeftRefs,lt=Jn.subSectionRightRefs,ut=Jn.sectionRowRefs,ct=Jn.getSectionRowRef,at=Jn.getSubSectionRef,st=Jn.getBadgeRef,dt=qn.analysis,vt=u.safeStringify(null===(P=null===(N=null==dt?void 0:dt.rule_difference_comparison)||void 0===N?void 0:N.summary)||void 0===P?void 0:P.overall_summary),ft=!!vt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),gt=null!==(j=null==Z?void 0:Z.base_root_id)&&void 0!==j?j:"-1";null==Z||Z[gt];var pt=Be?null!==(Y=null!==(z=ae&&(null===(q=null==ae?void 0:ae[gt])||void 0===q?void 0:q.evaluation_result))&&void 0!==z?z:null===(K=null===(W=null==Z?void 0:Z.nodes)||void 0===W?void 0:W[gt])||void 0===K?void 0:K.evaluation_result)&&void 0!==Y?Y:null:null!==(G=null!==(k=ae&&(null===(M=null===(F=null==ae?void 0:ae[gt])||void 0===F?void 0:F.evaluation_result)||void 0===M?void 0:M[0]))&&void 0!==k?k:null===(H=null===(L=null===(V=null==Z?void 0:Z.nodes)||void 0===V?void 0:V[gt])||void 0===L?void 0:L.evaluation_result)||void 0===H?void 0:H[0])&&void 0!==G?G:null,ht=u.extractDeviationScore(pt),xt=u.generateColorPalette(null!==($=null===(X=null===(U=null==pt?void 0:pt.evaluation_outputs)||void 0===U?void 0:U.metadata)||void 0===X?void 0:X.label_color)&&void 0!==$?$:""),_t=function(){Ye.current.forEach(function(e){u.resetClauseHighlight(e)}),Ye.current.clear()},mt=t.useCallback(function(){var e,n,t,i,o,r;_t(),Te(!1),Ze.current=!1;var l=en.current,c=kt.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=rt.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=et.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=et.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=lt.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=nt.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=nt.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Me(null),en.current=null,kt.current=null,Oe(!1),ye(!1),dn.current&&(dn.current.style.height="0px"),vn.current&&(vn.current.style.height="0px"),fn.current&&(fn.current.style.height="0px"),gn.current&&(gn.current.style.height="0px")},[]),Rt=t.useCallback(function(){_t(),mt(),He(new Set),ze([]),Je.current=[],zt([]),Yt(null),Bn(a.EMPTY_SUMMARY_POPUP_STATE),wn(),requestAnimationFrame(function(){var e;null===(e=nn.current)||void 0===e||e.call(nn)})},[]),yt=t.useRef(Rt);t.useEffect(function(){yt.current=Rt},[Rt]),t.useEffect(function(){oe&&yt.current()},[oe]);var St=x.useAccordionState({maintainRelativeOrder:!!fe,proposedSections:zn,existingSections:Wn,activeSideBySideSection:Fe,connectedSections:Le,resetSideBySide:mt,setConnectedSections:He,setConnectedLines:ze,cachedConnectedPositions:Je,svgContainerRef:We,isAnimatingRef:Ue,animationTimerRef:Xe,calculateLinesRef:nn,sectionLeftRefs:et,sectionRightRefs:nt,subSectionLeftRefs:rt,subSectionRightRefs:lt}),bt=St.expandedSections,At=St.setExpandedSections,Et=St.expandedSubSections,It=St.setExpandedSubSections,Tt=St.toggleSection,Bt=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?tn[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=ut.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==le?void 0:le.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==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.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}},[tn,Z]),Ct=t.useCallback(function(e){Nn(),En(null),yn(e)},[Nn]),Dt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),Sn.open&&Sn.sectionIdx===o)Nn();else{var c=e.currentTarget,a="left";(null===(l=sn.current)||void 0===l?void 0:l.contains(c))&&(a="right");_t(),Ze.current&&mt(),He(new Set),ze([]),Je.current=[],wn(),Tn.open?gi():Cn(),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=it.current[l])||void 0===e?void 0:e.current:null===(n=tt.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=it.current[o])||void 0===t?void 0:t.current:null===(i=tt.current[o])||void 0===i?void 0:i.current}()||c;bn(Bt(e,n,i,o,t,r))})}},Ot=t.useCallback(function(){null!==Sn.sectionIdx&&Sn.anchorEl?Ct(e.__assign(e.__assign({},Sn),{open:!0})):Nn()},[Sn,Nn,Ct]),wt=t.useCallback(function(){var e=Sn.sectionIdx,n=Sn.isOrphan;Nn(),Cn(),null!==e&&(n?Ae("No counterpart exists to connect to."):(_t(),Ze.current&&mt(),ze([]),Je.current=[],He(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){nn.current&&nn.current()},50)))},[Sn.sectionIdx,Sn.isOrphan,Nn,Cn,mt]),Nt=t.useCallback(function(){var e=Ke.current;if(e){Ke.current=null;var n=zn.findIndex(function(n){return n.id===e}),t=Wn.findIndex(function(n){return n.id===e}),i=-1===n?u.findKeyPathByNodeId(zn,e):null,o=-1===t?u.findKeyPathByNodeId(Wn,e):null,r=-1!==n?n:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=function(e,n,t,i){var o,r,l,u;return-1!==e?null!==(r=null===(o=t.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=i.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,t){void 0===t&&(t=30);var i=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Ye.current.add(r),u.scrollAndHighlightClause(r,n)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(fe)-1!==r&&pn.current&&a(function(){return c(n,i,et,rt)},pn.current),-1!==l&&sn.current&&a(function(){return c(t,o,nt,lt)},sn.current);else{var s=cn.current;if(!s)return;a(function(){return-1!==r?c(n,i,et,rt):c(t,o,nt,lt)},s)}}},[zn,Wn,fe,et,nt,rt,lt,pn,sn,cn]),Pt=t.useCallback(function(n){if(n){_t(),mt(),He(new Set),ze([]),Je.current=[],Cn(),wn();var t=zn.findIndex(function(e){return e.id===n}),i=Wn.findIndex(function(e){return e.id===n}),o=-1===t?u.findKeyPathByNodeId(zn,n):null,r=-1===i?u.findKeyPathByNodeId(Wn,n):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=-1!==i?i:r?Number(r.split("-")[0]):-1;Ke.current=n,At(function(n){var t,i=e.__assign({},n),o=!1;-1!==l&&(i[t=fe?"left-".concat(l):String(l)]||(i[t]=!0,o=!0));-1!==c&&(i[t=fe?"right-".concat(c):String(c)]||(i[t]=!0,o=!0));return o?i:n}),It(function(n){var t=e.__assign({},n),i=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:n}),setTimeout(function(){requestAnimationFrame(function(){Ke.current===n&&jt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[zn,Wn,fe,At,It,mt,Cn,wn]),jt=t.useRef(Nt);t.useEffect(function(){jt.current=Nt},[Nt]);var Ft=t.useRef(null),Mt=t.useRef(null),kt=t.useRef(null),Vt=t.useRef(null),Lt=t.useRef(null),Ht=t.useRef(null),Gt=t.useState([]),qt=Gt[0],zt=Gt[1];t.useRef(null);var Wt=t.useState(null),Kt=Wt[0],Yt=Wt[1];t.useEffect(function(){if(Fn){var e=Pn.fields.find(function(e){return e.analysisKey===Fn||e.key===Fn});if(e){var n=Qn.current[e.key]||Zn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Fn,Pn.fields]);var Ut=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==dt?void 0:dt.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}},[dt]),Xt=t.useCallback(function(n,t){var i,o,r;void 0===t&&(t="left");var l=null,c=null;if("left"===t)if(l=zn[n],fe&&l){var s=Wn.filter(function(e){var n;return null===(n=l.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});c=s.find(function(e){return e.evaluationResult})||s[0]}else c=Wn[n];else if(c=Wn[n],fe&&c){var d=zn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)});l=d.find(function(e){return e.evaluationResult})||d[0]}else l=zn[n];var v=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,g=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!v&&!f&&!g)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==c?void 0:c.evaluationResult)&&void 0!==o?o:null,h=u.getFirstDeviationOutputValue(p),x=u.getFirstDeviationColor(p);return null!=p?e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null!==(r=h)&&void 0!==r?r:""}):e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null})},[zn,Wn,tn,Pn,fe]),$t=t.useCallback(function(n){for(var t,i,o,r,l,c=n.split("-").map(Number),s=zn[c[0]],d=Wn[c[0]],v=1;v<c.length;v++)(null==s?void 0:s.subsections)&&(s=s.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!s&&!d)return null;var f=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,g=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=u.safeStringify(null==s?void 0:s.id)||u.safeStringify(null==d?void 0:d.id)||"",h=!(!(null==s?void 0:s.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!f&&!g&&!h)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=tn[p])||void 0===o||o.relevance_score);var x=null!==(l=null!==(r=null==s?void 0:s.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,_=u.getFirstDeviationOutputValue(x),m=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(m)),{label:null!=_?_:""}):e.__assign(e.__assign({},u.generateColorPalette(m)),{label:null})},[zn,Wn,tn,Pn]),Jt=t.useCallback(function(n,t){var i,o,r,l,c,s,d,v,f,g,p,h,x,_,m,R,y;if(!n||null==t)return null;var S=null!==(d=null!==(c=null!==(o=null===(i=null==ae?void 0:ae[n])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==Z?void 0:Z.nodes)||void 0===r?void 0:r[n])||void 0===l?void 0:l.evaluation_result)&&void 0!==c?c:null===(s=null==Z?void 0:Z[n])||void 0===s?void 0:s.evaluation_result)&&void 0!==d?d:null;if(!S||"object"!=typeof S)return null;var b=null!==(p=null!==(f=null===(v=null==S?void 0:S.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==S?void 0:S.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==S?void 0:S[t],A=null!==(y=null!==(_=null===(x=null===(h=null==b?void 0:b.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==_?_:null===(R=null===(m=null==S?void 0:S.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===R?void 0:R.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR;return e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[ae,Z]),Qt=t.useCallback(function(){_t(),At({}),It({}),mt(),He(new Set),ze([]),Je.current=[],Cn(),wn(),Nn(),requestAnimationFrame(function(){nn.current&&nn.current()})},[At,It,mt,Cn,wn,Nn]),Zt=t.useMemo(function(){return Object.values(bt).some(Boolean)||Object.values(Et).some(Boolean)},[bt,Et]),ei=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,b;if(!hn.current&&!Ue.current){hn.current=!0;try{if(!Ft.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!bt[t]&&!1===fe)return!1;if(fe&&!bt["left-".concat(t)]&&!bt["right-".concat(t)]&&!bt[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!Et[i])return!1;return!0},E=Ft.current.getBoundingClientRect();ln({width:E.width,height:E.height});var I=[];if(Kn.forEach(function(e){var n,t,i=e.key,o=null===(n=Qn.current[i])||void 0===n?void 0:n.current,r=null===(t=Zn.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")}),!Ue.current){for(var T=0;T<Math.max(zn.length,Wn.length);T++){var B=null===(e=et.current[T])||void 0===e?void 0:e.current,C=null===(n=nt.current[T])||void 0===n?void 0:n.current;B&&(B.style.height="auto",B.style.minHeight="0px"),C&&(C.style.height="auto",C.style.minHeight="0px")}fe||Object.keys(rt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=rt.current[e])||void 0===n?void 0:n.current,o=null===(t=lt.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={};Kn.forEach(function(e){var n,t,i=e.key,o=null===(n=Qn.current[i])||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(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var O={left:{},right:{}},w={};if(!Ue.current)if(fe){if(Ie&&null!==Fe)if("number"==typeof Fe){var N=Fe,P=zn[N],j=null===(o=et.current[N])||void 0===o?void 0:o.current;j&&P&&(P.refIndexes||[]).forEach(function(e){var n,t=Wn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=nt.current[t])||void 0===n?void 0:n.current;if(i&&(bt["left-".concat(N)]||bt["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[N]=Math.max(O.left[N]||0,o),O.right[t]=Math.max(O.right[t]||0,o)}})}else{var F=Fe.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(r=rt.current[F])||void 0===r?void 0:r.current,C=null===(l=lt.current[F])||void 0===l?void 0:l.current;if(B&&C){M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);w[F]=Math.max(w[F]||0,M)}}}}else{Object.keys(rt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=rt.current[e])||void 0===n?void 0:n.current,o=null===(t=lt.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);w[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(T=0;T<Math.min(zn.length,Wn.length);T++){var B=null===(t=et.current[T])||void 0===t?void 0:t.current,C=null===(i=nt.current[T])||void 0===i?void 0:i.current;if(B&&C){var M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);O.left[T]=M,O.right[T]=M}}}if(Kn.forEach(function(e){var n,t,i=e.key,o=null===(n=Qn.current[i])||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=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Ue.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=et.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(O.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=nt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),fe||Object.keys(w).forEach(function(e){var n,t,i=null===(n=rt.current[e])||void 0===n?void 0:n.current,o=null===(t=lt.current[e])||void 0===t?void 0:t.current;if(i&&o&&w[e]){var r=w[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),fe)zn.forEach(function(e,n){var t;(null===(t=et.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=Wn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=tt.current[n])||void 0===t?void 0:t.current,g=null===(i=it.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-E.left,_=h.left-E.left,m=p.top+p.height/2-E.top,R=h.top+h.height/2-E.top;if(Ie&&Fe===n){var y=null!==(r=null===(o=pn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=sn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,b=y+(null!==(a=null===(c=pn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=S+(null!==(d=null===(s=sn.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,C=function(e,n,t){return Math.max(n,Math.min(t,e))};m=C(T,y,b)-E.top,R=C(B,S,A)-E.top}var D=Xt(n);D&&I.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(T=0;T<Math.min(zn.length,Wn.length);T++){var k=null===(c=et.current[T])||void 0===c?void 0:c.current,V=null===(a=nt.current[T])||void 0===a?void 0:a.current;if(k&&V){var L=k.getBoundingClientRect(),H=V.getBoundingClientRect(),G=Math.max(L.top,H.top)+18-E.top,q=(null===(s=Wn[T])||void 0===s?void 0:s.id)||"sec-".concat(T);(J=Xt(T))&&I.push({id:q,x1:L.right-E.left,y1:G,x2:H.left-E.left,y2:G,style:J,sectionIdx:T,hasCognitive:!!((null===(d=zn[T])||void 0===d?void 0:d.cognitiveData)||(null===(v=Wn[T])||void 0===v?void 0:v.cognitiveData)||q&&tn[q]),isSubSection:!1})}}Object.keys(rt.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=rt.current[e])||void 0===n?void 0:n.current,a=null===(t=lt.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=zn[s[0]],v=Wn[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-E.top,y=$t(e);y&&"Not Defined"!==y.label&&I.push({id:"subsec-".concat(e),x1:_.right-E.left,y1:R,x2:m.left-E.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(Ie&&"string"==typeof Fe&&Fe.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Fe.split(u.DEVIATION_BADGE_SEPARATOR),W=z[0],K=z[1],Y=z[2],U=(z[3],"".concat(W).concat(u.DEVIATION_BADGE_SEPARATOR).concat(K)),X=null===(f=tt.current[U])||void 0===f?void 0:f.current,$=null===(g=it.current[U])||void 0===g?void 0:g.current;if(X&&$){var J,Q=X.getBoundingClientRect(),Z=$.getBoundingClientRect(),ee=Q.right-E.left,ne=Z.left-E.left,te=Q.top+Q.height/2-E.top,ie=Z.top+Z.height/2-E.top;if(fe){var oe=null!==(h=null===(p=pn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(_=null===(x=sn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,le=oe+(null!==(R=null===(m=pn.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(S=null===(y=sn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,le)-E.top,ie=ce(Z.top+Z.height/2,re,ue)-E.top}(J=null!==(b=Jt(W,K))&&void 0!==b?b:$t(Y))&&I.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:Fe})}}if(zt(I),Lt.current&&Ht.current){var ae=Lt.current.getBoundingClientRect(),se=Ht.current.getBoundingClientRect(),de=(ae.top+ae.height/2-E.top+se.top+se.height/2-E.top)/2;Yt({x1:ae.right-E.left,x2:se.left-E.left,y:de})}else Yt(null);if(Le.size>0){var ve=[],ge=pn.current,pe=sn.current;if(ge&&pe){var he=[],xe=ge.getBoundingClientRect().top,_e=pe.getBoundingClientRect().top,me=xe+ge.clientHeight,Re=_e+pe.clientHeight,ye=ge.scrollTop,Se=pe.scrollTop,be=E.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};Le.forEach(function(e){var n,t,i,o,r,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var c=e.split(u.DEVIATION_BADGE_SEPARATOR),a=c[0],s=c[1],d=c[2],v=(c[3],"".concat(a).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=tt.current[v])||void 0===n?void 0:n.current,g=null===(t=it.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=Jt(a,s))&&void 0!==i?i:$t(d),_=(j=p.right-E.left)+.5*((F=h.left-E.left-0)-j),m=p.top+p.height/2,R=h.top+h.height/2,y=m-xe+ye,S=R-_e+Se,b="conn-subsec-".concat(v);he.push({lhsScrollY:y,rhsScrollY:S,x1:j,x2:F,containerTop:be,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:b});var A=Ae(m,xe,me),I=Ae(R,_e,Re),T=A-be,B=I-be,C=R>=_e-4&&R<=Re+4,D="";D=(M=m>=xe-4&&m<=me+4)&&C?u.getBentArrowPath(j,T,F,B):M&&!C?"M ".concat(j,",").concat(T," L ").concat(_,",").concat(T," L ").concat(_,",").concat(B):!M&&C?"M ".concat(_,",").concat(T," L ").concat(_,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(_,",").concat(T," L ").concat(_,",").concat(B),ve.push({id:b,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(fe){var O=e,w=zn[O];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(e){var n,t,i=Wn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=tt.current[O])||void 0===n?void 0:n.current,r=null===(t=it.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Xt(O),s=l.right-E.left,d=c.left-E.left-0,v=s+.5*(d-s),f=l.top+l.height/2,g=c.top+c.height/2,p=f-xe+ye,h=g-_e+Se,x="conn-".concat(O,"-").concat(i);he.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:be,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=Ae(f,xe,me),m=Ae(g,_e,Re),R=_-be,y=m-be,S=f>=xe-4&&f<=me+4,b=g>=_e-4&&g<=Re+4,A="";A=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:A,style:a,leftIdx:O,rhsArrayIdx:i})}}})}else{var N=e,P=N;f=null===(o=tt.current[N])||void 0===o?void 0:o.current,g=null===(r=it.current[P])||void 0===r?void 0:r.current;if(!f||!g)return;var j,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=Xt(N),_=(j=p.right-E.left)+.5*((F=h.left-E.left-0)-j),m=p.top+p.height/2,R=h.top+h.height/2,y=m-xe+ye,S=R-_e+Se,b="conn-".concat(N,"-").concat(P);he.push({lhsScrollY:y,rhsScrollY:S,x1:j,x2:F,containerTop:be,leftIdx:N,rhsArrayIdx:P,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:b});var M;A=Ae(m,xe,me),I=Ae(R,_e,Re),T=A-be,B=I-be,C=R>=_e-4&&R<=Re+4,D="";D=(M=m>=xe-4&&m<=me+4)&&C?u.getBentArrowPath(j,T,F,B):M&&!C?"M ".concat(j,",").concat(T," L ").concat(_,",").concat(T," L ").concat(_,",").concat(B):!M&&C?"M ".concat(_,",").concat(T," L ").concat(_,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(_,",").concat(T," L ").concat(_,",").concat(B),ve.push({id:b,pathD:D,style:x,leftIdx:N,rhsArrayIdx:P})}}),Je.current=he}ze(ve)}else ze([]),Je.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{hn.current=!1}}},[Kn,zn,Wn,tn,Pn,Ut,Xt,Jt,fe,Ie,Fe,Le,bt,Et]),ni=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p=Je.current;if(p.length&&!Ue.current){var h=null!==(n=null===(e=pn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=sn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(r=null===(o=pn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=sn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=pn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=sn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,b=y+m,A=null!==(g=null===(f=Ft.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=$e.current[e.styleId+"-stroke"],o=$e.current[e.styleId+"-bg"];if(i||o){var r,l=E(n,R,S),c=E(t,y,b),a=l-A,s=c-A,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=b+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(){nn.current=ei},[ei]);var ti=t.useRef(null),ii=t.useRef(null),oi=t.useCallback(function(){Je.current.length>0&&!Ue.current||(null!==ti.current&&clearTimeout(ti.current),ti.current=setTimeout(function(){nn.current(),ti.current=null},50))},[]),ri=t.useCallback(function(){Pe(!0),Oe(!1),null!==ii.current&&clearTimeout(ii.current),null!==ti.current&&(clearTimeout(ti.current),ti.current=null),ii.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s,d;try{if(Je.current=[],Ze.current&&null!==en.current&&null!==kt.current){var v=en.current,f=kt.current,g="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR),p=null,h=null,x=null,_=null;if(g){var m=v.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(m[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(m[1]);p=(null===(e=tt.current[R])||void 0===e?void 0:e.current)||null,h=(null===(n=it.current[R])||void 0===n?void 0:n.current)||null,x=(null===(t=rt.current[m[2]])||void 0===t?void 0:t.current)||(null===(i=et.current[Number(m[2])])||void 0===i?void 0:i.current)||null,_=(null===(o=lt.current[m[3]])||void 0===o?void 0:o.current)||(null===(r=nt.current[Number(m[3])])||void 0===r?void 0:r.current)||null}else p=(null===(l=ut.current[v])||void 0===l?void 0:l.current)||null,x=(null===(c=et.current[v])||void 0===c?void 0:c.current)||null,h=(null===(a=ot.current[f])||void 0===a?void 0:a.current)||null,_=(null===(s=nt.current[f])||void 0===s?void 0:s.current)||null;if(p&&h&&x&&_){if(x.style.paddingTop="0px",_.style.paddingTop="0px",!fe){var y=p.getBoundingClientRect(),S=h.getBoundingClientRect(),b=y.top-S.top;b>0?_.style.paddingTop="".concat(b,"px"):b<0&&(x.style.paddingTop="".concat(Math.abs(b),"px"))}var A=pn.current,E=sn.current;if(A&&E){var I=p.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop,T=h.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop-(I-A.scrollTop);Math.abs(E.scrollTop-T)>1&&(E.scrollTop=T)}}}null===(d=nn.current)||void 0===d||d.call(nn),Ze.current&&Oe(!0)}catch(e){console.error("Safely caught error during resize calculation:",e)}finally{Pe(!1),ii.current=null}},150)},[fe,zn,Wn]),li=t.useCallback(function(e){var n,t,i,o,r,l,c,a,s,d;if(null!==xn.current&&_n.current&&Math.abs(e.currentTarget.scrollTop-xn.current)<=2){var v=_n.current;xn.current=null,_n.current=null,v()}if(!ke.current){if(fe||oi(),Ze.current){var f=en.current,g=kt.current,p=pn.current,h=sn.current;if(null!==f&&null!==g&&p&&h){var x="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=tt.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=ut.current[f])||void 0===t?void 0:t.current,_="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=it.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=ot.current[g])||void 0===o?void 0:o.current;if(x&&_&&Vt.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=tt.current[S])||void 0===r?void 0:r.current,R=null===(l=it.current[S])||void 0===l?void 0:l.current}else m=null===(c=tt.current[f])||void 0===c?void 0:c.current,R=null===(a=it.current[g])||void 0===a?void 0:a.current;var b=null!==(d=null===(s=Ft.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 C=((O=B,w=A,N=E,Math.max(w,Math.min(N,O)))-b).toString();Vt.current.setAttribute("y1",C),Vt.current.setAttribute("y2",C);var D=B>=A-4&&B<=E+4;Vt.current.setAttribute("visibility",D?"visible":"hidden")}}}}var O,w,N;Je.current.length>0&&!Qe.current&&(Qe.current=!0,requestAnimationFrame(function(){ni(),Qe.current=!1}))}},[ni,fe,oi]),ui=t.useRef(0),ci=t.useRef(0),ai=t.useRef(0),si=t.useRef(function(){});t.useRef(null),t.useEffect(function(){si.current=ri},[ri]),t.useEffect(function(){var e=setTimeout(oi,250),n=function(){return si.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==ti.current&&clearTimeout(ti.current),null!==ii.current&&clearTimeout(ii.current),window.removeEventListener("resize",n)}},[Gn,qn,dt,Kn,bt,Et,zn,Wn,Pn,oi,Ie,Fe,De,Le]),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 an.current&&o.push(e(an.current,ui,n,function(){return si.current()},function(){})),cn.current&&o.push(e(cn.current,ci,t,function(){return si.current()},function(){return nn.current()})),Ft.current&&o.push(e(Ft.current,ai,i,function(){return si.current()},function(){return nn.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(){Ze.current=Ie},[Ie]),t.useEffect(function(){en.current=Fe},[Fe]);var di=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";Nn(),null!=e&&(n?Ae("No counterpart exists for this section."):(_t(),Ie&&Fe===e?r?mt():null==l||l():(He(new Set([e])),ze([]),Je.current=[],ye(!0),ke.current=!0,Me(e),en.current=e,Te(!0),Ze.current=!0,Oe(!1),dn.current&&(dn.current.style.height="0px"),vn.current&&(vn.current.style.height="0px"),fn.current&&(fn.current.style.height="0px"),gn.current&&(gn.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=tt.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=it.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=ut.current[e])||void 0===i?void 0:i.current)||null,fe){var p=zn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=Wn.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(r=ot.current[_])||void 0===r?void 0:r.current)||null,v=_)}}else d=(null===(o=ot.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;kt.current=v;var m=pn.current,R=sn.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=rt.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=et.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=lt.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=nt.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(r=tt.current[y])||void 0===r?void 0:r.current)||h,m=(null===(l=it.current[y])||void 0===l?void 0:l.current)||x}else{var S=Number(e),b=null!==v?Number(v):S;h=(null===(c=et.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=nt.current[b])||void 0===s?void 0:s.current)||null,_=(null===(d=tt.current[S])||void 0===d?void 0:d.current)||(null===(f=ut.current[S])||void 0===f?void 0:f.current)||h,m=(null===(g=it.current[b])||void 0===g?void 0:g.current)||(null===(p=ot.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"))}}(),Oe(!0),nn.current&&nn.current(),ke.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),ye(!1),null==l||l()};if(!s||!m)return ke.current=!1,ye(!1),void(null==l||l());if(d&&R){if(!fe){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var b=cn.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 C=T-(I-m.scrollTop);C<0&&dn.current&&(dn.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return vn.current&&(vn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,C,B,y)})}e=C}u.smoothScrollTo(R,e,B,y)})}else{var D=I-(T-R.scrollTop);D<0&&fn.current&&(fn.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 gn.current&&(gn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(m,D,B,y)})}e=D}u.smoothScrollTo(m,e,B,y)})}}else y()}))))},[Fe,Nn,Wn,Ie,fe,zn,mt]),vi=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;wn();var c="left";(null===(o=sn.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=it.current[l])||void 0===e?void 0:e.current:null===(t=tt.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=it.current[n])||void 0===i?void 0:i.current:null===(o=tt.current[n])||void 0===o?void 0:o.current};if(t)return mt(),He(new Set),ze([]),Je.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;Bn({open:!0,anchorEl:e,summary:i})}));di(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;Bn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[di,wn,Bn,mt]),fi=t.useCallback(function(){var e,n=Sn.sectionIdx,t=Sn.isOrphan;if(Cn(),null!=n){var i="left";Sn.anchorEl&&(null===(e=sn.current)||void 0===e?void 0:e.contains(Sn.anchorEl))&&(i="right"),di(n,t,{sourceSide:i})}},[di,Sn.isOrphan,Sn.sectionIdx,Sn.anchorEl,Cn]),gi=t.useCallback(function(){Cn(),mt(),He(new Set),ze([]),Je.current=[]},[Cn,mt]),pi=null!==Sn.sectionIdx&&Le.has(Sn.sectionIdx),hi=_.useDeviationNavigation({proposedSections:zn,existingSections:Wn,parentDeviationRecord:Yn,expandedSections:bt,maintainRelativeOrder:!!fe,scrollContainerRef:cn,leftContainerRef:pn,lhsBadgeRefs:tt,rhsBadgeRefs:it}),xi=hi.showDeviationNavigation,_i=hi.showOpenNodeRef,mi=t.useMemo(function(){var e;if(!se)return null;var n=null===(e=null==se?void 0:se.id)||void 0===e?void 0:e.split(":")[0];for(var t in Yn){if((Yn[t]||[]).some(function(e){return e.id===n}))return t}return null},[se,Yn]),Ri=t.useRef({id:null,triggerMs:null}),yi=t.useRef(null);t.useEffect(function(){var n;if(null==se?void 0:se.id){var t=Number(se.trigger),i=Ri.current;if((null==i?void 0:i.triggerMs)!==t){if(!(se.id.includes(":")&&/:\d+$/.test(se.id)))return Ri.current={id:se.id,triggerMs:t},void Pt(se.id);var o=null===(n=null==se?void 0:se.id)||void 0===n?void 0:n.split(":"),r=o[0],l=o[1],c=null!=l?l:"0";yi.current!==se.id&&(Cn(),wn(),mt(),He(new Set),ze([]),Je.current=[],yi.current=se.id);var a=!1,s=0,d=null,v=150,f=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},g=function(){var n,i,o,l;if(!a){var p=function(){Ri.current={id:se.id,triggerMs:t}},h=null,x=null;for(var _ in Yn){var m=Yn[_].find(function(e){return e.id===r});if(m){h=_,x=m;break}}if(x&&h){var R=zn.findIndex(function(e){return e.id===h}),y=Wn.findIndex(function(e){return e.id===h}),S=-1===R&&-1!==y,b=f(zn,x.id),A=f(Wn,x.id);if(b&&!A&&!S){var E=b.split("-"),I=Number(E[0]);if(fe){var T=null===(i=null===(n=zn[I])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],B=Wn.findIndex(function(e){return e.selfIndex===T});-1!==B&&(I=B)}A=e.__spreadArray([I],E.slice(1),!0).join("-")}if(b||A){var C=S||!b&&!!A,D=b?Number(b.split("-")[0]):R,O=A?Number(A.split("-")[0]):y;if(C){if(!(fe?!!bt["right-".concat(O)]:!!bt[String(O)])&&O>=0)return Tt(O,"right"),s+=1,void(d=setTimeout(g,450))}else if(!(fe?!!bt["left-".concat(D)]:!!bt[String(D)])&&D>=0)return Tt(D,"left"),s+=1,void(d=setTimeout(g,450));var w,N=b||"",P=A||"",j="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(N).concat(u.DEVIATION_BADGE_SEPARATOR).concat(P),F="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c),M=null===(o=tt.current[F])||void 0===o?void 0:o.current,k=null===(l=it.current[F])||void 0===l?void 0:l.current,V=C||!M&&!!k,L=V?k:M;if(w=fe?V?sn.current:pn.current:cn.current,L&&w){var H=L.getBoundingClientRect();if(0===H.height)return void((s+=1)<2?d=setTimeout(g,v):p());var G=w.getBoundingClientRect(),q=H.top-G.top+w.scrollTop-G.height/2+H.height/2+150,z=function(){var n,t,i,o,r;if(!a){p();var l=window.getComputedStyle(L).color;M&&(M.style.transition="box-shadow 300ms ease-in-out",M.style.boxShadow="0 0 10px ".concat(l)),k&&(k.style.transition="box-shadow 300ms ease-in-out",k.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){M&&(M.style.boxShadow=""),k&&(k.style.boxShadow="")},2e3);var u=(null===(t=null===(n=x.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[c])||x,s=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!M&&!!k)){var d=V?(null===(o=it.current[F])||void 0===o?void 0:o.current)||k:(null===(r=tt.current[F])||void 0===r?void 0:r.current)||M;return Bn({open:!0,anchorEl:d,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})}),void(null==de||de())}di(j,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=tt.current[F])||void 0===n?void 0:n.current)||M;Bn({open:!0,anchorEl:t,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})})}})}};Math.abs(w.scrollTop-q)<=2?z():(xn.current=q,_n.current=z,w.scrollTo({top:q,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(_n.current){xn.current=null;var e=_n.current;_n.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}};return d=setTimeout(g,v),function(){a=!0,d&&clearTimeout(d)}}}},[se,Yn,zn,Wn,fe,bt,Tt,di,Bn,Pt]);var Si=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:Et,setExpandedSubSections:It,maintainRelativeOrder:fe||!1,proposedSections:zn,existingSections:Wn,treeData:Z,deviationNumberRegistry:Un,connectedSections:Le,activeSideBySideSection:Fe,resolvedMarkdownStyles:un,getSubSectionRef:at,getSubSectionCompareStyle:$t,getBadgeRef:st,openMoreFunctionsPopup:Dt,openSummaryPopup:vi,showDeviationBadges:pe,resetSideBySide:mt,setConnectedSections:He,setConnectedLines:ze,cachedConnectedPositions:Je})};return n.jsxs(i.Box,e.__assign({ref:an,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},fe?{}:{overflow:"visible"}),{position:"relative"})},{children:[xe&&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,{})})),Tn.open&&n.jsx(S.default,{open:Tn.open,anchorEl:Tn.anchorEl,containerEl:Mt.current,clipTopEl:Lt.current,scrollContainerEl:cn.current,onClose:gi,summary:Tn.summary}),n.jsx(d.default,{open:Sn.open,anchorEl:Sn.anchorEl,sectionTitle:Sn.sectionTitle,referenceSectionTitle:Sn.refSectionTitle,onClose:Nn,onOpenCognitiveCompare:Ot,onOpenSideBySide:fi,onConnect:wt,isConnected:pi,isOrphan:Sn.isOrphan}),Rn.open&&n.jsx(s.default,{open:Rn.open,popupRef:On,position:An,popupConfig:ue,onClose:function(){En(null),yn(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Dn(null)},markdownStyles:ie,sectionTitle:Rn.sectionTitle,referenceSectionTitle:Rn.refSectionTitle,cognitiveData:Rn.cognitiveData,anchorEl:Rn.anchorEl,sectionAnchorEl:Rn.sectionAnchorEl,scrollContainerEl:cn.current,badgeStyle:Rn.badgeStyle,docData:Rn.docData,deviationData:Rn.deviationData,isLoading:Rn.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!be,autoHideDuration:8e3,onClose:function(){return Ae(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Ae(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:be}))})),n.jsx(m.default,{componentHeaderText:Q,displayConfig:le,maintainRelativeOrder:fe,onCollapseAll:Qt,showCollapseAll:Zt,onToggleView:function(e){_e(!0),setTimeout(function(){ge(!e),mt(),Cn(),He(new Set),ze([]),Je.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){_e(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:cn,onScroll:li,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:fe?"hidden":"auto",borderTop:vt&&ft?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},fe?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Ft,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},fe?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:We,style:{position:"absolute",top:0,left:0,width:rn.width||"100%",height:rn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Ne?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Kt&&n.jsx("g",{children:n.jsx("line",{x1:Kt.x1,y1:Kt.y,x2:Kt.x2,y2:Kt.y,stroke:xt.badgeBorder,strokeWidth:"1.5"})}),qt.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?Ie&&Fe===t.subSectionKeyPath&&De:Ie&&Fe===t.sectionIdx&&De)return null;if(!fe){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),_=zn[t.sectionIdx]||{title:"",content:""},m=Wn[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=zn[b[0]]),A.length>0&&(I=Wn[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 C=1;C<b.length;C++)(null==E?void 0:E.subsections)&&(E=E.subsections[b[C]]);for(C=1;C<A.length;C++)(null==I?void 0:I.subsections)&&(I=I.subsections[A[C]]);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 D=!(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=D||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&&(Rn.open&&In===t.id?wn():(Dn(t.id),Ct(Bt(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:Rn.open&&In===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),n.jsx(b.default,{connectedLines:qe,pathRefs:$e})]})),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)"},fe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Lt,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:Vn,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:Vn}))}))})),n.jsxs(i.Box,e.__assign({ref:pn,onScroll:li,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},fe?{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:fn,style:{width:"100%",height:"0px",flexShrink:0}}),$n&&zn.map(function(t,r){var l,c,a=!t.title&&!t.content;if(fe&&a)return null;var s=t,d=Xt(r,"left"),v=fe?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Wn[r],g=fe?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=Le.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:ct(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:et.current[r],sx:e.__assign({width:"100%",display:"flex",flexDirection:"column",minWidth:0},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:ct("left-accordion-".concat(r)),mb:0,treeData:Z,proposedSections:zn,existingSections:Wn,deviationNumberRegistry:Un,getSectionCompareStyle:Xt,getBadgeRef:st,connectedSections:Le,openMoreFunctionsPopup:Dt,openSummaryPopup:vi,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:mi,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:fe?!!bt["left-".concat(r)]:!!bt[String(r)],onToggle:function(){gi(),Tt(r,"left")},navigation:t.id?xi[t.id]:null,showOpenNodeRef:_i,resolvedMarkdownStyles:un,maintainRelativeOrder:fe,showDeviationBadges:pe,renderSubSections:Si})})),fe&&d&&n.jsxs(i.Box,e.__assign({ref:tt.current[r],onClick:function(e){var n=fe?Wn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Wn[r]||{title:"",content:""};Dt(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:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,t,i;e.stopPropagation();var o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=s.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=s.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;console.log("LOG: Printing evaluationResult",o,s),vi(e,String(r),v,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:v?"default":"pointer",borderRight:"1px solid ".concat(d.badgeBorder),"&:hover":v?{}:{bgColor:"".concat(d.badgeBorder,"22")}}},{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:!le.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(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=fe?Wn.find(function(e){var n;return(null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e))||{title:"",content:""}}):Wn[r]||{title:"",content:""};Dt(e,t,v,n,r,d)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(d.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})}))]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:gn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:Mt,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(),Rn.open&&In===gt?wn():(Dn(gt),Ct(Bt(n.currentTarget,{title:"",content:"",evaluationResult:pt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,gt,!0,e.__assign(e.__assign({},xt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:xt.badgeBg,color:xt.badgeText,border:"1px solid ".concat(xt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=ht?ht: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:Rn.open&&In===gt?"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},fe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Re&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Ht,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:Ln,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:Ln}))}))})),n.jsxs(i.Box,e.__assign({ref:sn,onScroll:li,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},fe?{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:dn,style:{width:"100%",height:"0px",flexShrink:0}}),$n&&Wn.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(fe){u=zn.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=zn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=zn.findIndex(function(e,n){var t;return Le.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=Xt(d))}else u=[o+1],(c=Le.has(o))&&(a=Xt(o));var v=Xt(fe&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:ot.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:nt.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:ct("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==Z?void 0:Z.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:fe?!!bt["right-".concat(o)]:!!bt[String(o)],treeData:Z,proposedSections:zn,existingSections:Wn,deviationNumberRegistry:Un,getBadgeRef:st,getSectionCompareStyle:Xt,connectedSections:Le,openMoreFunctionsPopup:Dt,openSummaryPopup:vi,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:mi,onToggle:function(){gi(),Tt(o,"right")},navigation:t.id?xi[t.id]:null,showOpenNodeRef:_i,resolvedMarkdownStyles:un,maintainRelativeOrder:fe,showDeviationBadges:pe,renderSubSections:Si})})),fe&&v&&n.jsx(i.Box,e.__assign({ref:it.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:vn,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 t=require("./CognitiveCompareConstants.js"),n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./CognitiveCompareConstants.js"),n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},e=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return e(t)}))};var o=["#B91C1C","#A16207","#1D4ED8","#000000"],r=function(t){var n=o.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?o.length:n},i=function(t,n,e){if(!t)return null;if(t.id===e)return n;if(!Array.isArray(t.subsections))return null;for(var o=0;o<t.subsections.length;o++){var r=i(t.subsections[o],"".concat(n,"-").concat(o),e);if(r)return r}return null},u=new WeakMap,l=function(t){if(t){var n=u.get(t);null!=n&&(clearTimeout(n),u.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},a=function(t){if(t){var n=u.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var e=window.setTimeout(function(){l(t)},3e3);u.set(t,e)}};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var e,o,r,i,u,l;if(t.content!==n.content)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var v=0;v<a.length;v++)if(a[v]!==s[v])return!1;var d=t.deviationBadges||[],c=n.deviationBadges||[];if(d.length!==c.length)return!1;for(v=0;v<d.length;v++){if(d[v].id!==c[v].id)return!1;if(d[v].actionId!==c[v].actionId)return!1;if(d[v].label!==c[v].label)return!1;if(d[v].score!==c[v].score)return!1;if(d[v].isOrphan!==c[v].isOrphan)return!1;if(d[v].isConnected!==c[v].isConnected)return!1;if((null===(e=d[v].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=c[v].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=d[v].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=c[v].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(u=d[v].style)||void 0===u?void 0:u.badgeText)!==(null===(l=c[v].style)||void 0===l?void 0:l.badgeText))return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,o)},n)}},exports.extractDeviationScore=function(t,n){var e,o,r,i,u,l,a;if(!t)return n;var s=null!==(l=null!==(i=null!==(o=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==o?o:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(u=t.evaluation_outputs)||void 0===u?void 0:u.output_value)&&void 0!==l?l:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},exports.findKeyPathByNodeId=function(t,n){for(var e=0;e<t.length;e++){var o=i(t[e],String(e),n);if(o)return o}return null},exports.generateColorPalette=function(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),o=e.r,r=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(o+(255-o)*n),Math.round(r+(255-r)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}},exports.getBentArrowPath=function(t,n,e,o,r){void 0===r&&(r=14);var i=t+.5*(e-t),u=o-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var l=u>0?1:-1,a=Math.min(r,Math.abs(u)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-a),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+l*a),"V ".concat(o-l*a),"Q ".concat(i," ").concat(o," ").concat(i+a," ").concat(o),"H ".concat(e)].join(" ")},exports.getFirstDeviationColor=function(n){for(var e,o,i,u,l,a,s,v,d,c,f,g,p,h=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var _=m[b];(C=null===(u=null===(i=null===(o=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[_])||void 0===o?void 0:o.evaluation_outputs)||void 0===i?void 0:i.metadata)||void 0===u?void 0:u.label_color)&&h.push(C)}for(var y=0,x=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});y<x.length;y++){_=x[y];(C=null===(v=null===(s=null===(a=null===(l=null==n?void 0:n.deviation_entries)||void 0===l?void 0:l[_])||void 0===a?void 0:a.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===v?void 0:v.label_color)&&h.push(C)}for(var A=0,B=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});A<B.length;A++){var C;_=B[A];(C=null===(f=null===(c=null===(d=null==n?void 0:n[_])||void 0===d?void 0:d.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===f?void 0:f.label_color)&&h.push(C)}return 0===h.length?(null===(p=null===(g=null==n?void 0:n.evaluation_outputs)||void 0===g?void 0:g.metadata)||void 0===p?void 0:p.label_color)?n.evaluation_outputs.metadata.label_color:t.DEFAULT_DEVIAION_COLOR:h.sort(function(t,n){return r(t)-r(n)})[0]},exports.getFirstDeviationOutputValue=function(t){for(var n,e,o,r,i,u,l,a,s,v=0,d=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});v<d.length;v++){var c=d[v];if(b=null===(o=null===(e=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[c])||void 0===e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var f=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<g.length;f++){c=g[f];if(b=null===(u=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[c])||void 0===i?void 0:i.evaluation_outputs)||void 0===u?void 0:u.output_value)return b}for(var p=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});p<h.length;p++){var b;c=h[p];if(b=null===(a=null===(l=null==t?void 0:t[c])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}},exports.getSideData=function(t,e,o){var r,i=o[e],u=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return{title:n((null==u?void 0:u.title)||""),content:n((null==u?void 0:u.content)||""),attributes:(null==u?void 0:u.additional_attributes)||null,subsections:(null==u?void 0:u.subsections)||[]}},exports.hasValue=e,exports.highlightClause=a,exports.isMissingStr=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},exports.mixHexColors=function(t,n){var e=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},o=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var r=e(t),i=e(n),u=(r[0]+i[0])/2*.95,l=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(o(u)).concat(o(l)).concat(o(a))}catch(t){return"#FDE68A"}},exports.recursivelyFindSubSectionIdxById=i,exports.resetClauseHighlight=l,exports.safeStringify=n,exports.scrollAndHighlightClause=function(t,n){var e=n.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.scrollTop+o.top-e.top-e.height/2+o.height/2;n.scrollTo({top:r,behavior:"smooth"});var i=function(){return a(t)};if("onscrollend"in n)n.addEventListener("scrollend",i,{once:!0});else{var u=n.scrollTop,l=function(){n.scrollTop===u?i():(u=n.scrollTop,requestAnimationFrame(l))};requestAnimationFrame(l)}},exports.smoothScrollTo=function(t,n,e,o,r){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var u=t.scrollTop,l=n-u,a=null,s=function(v){null===a&&(a=v);var d,c=v-a;c<e?(t.scrollTop=(d=c,d/=e,l*(--d*d*d+1)+u),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)};
|
|
2
2
|
//# sourceMappingURL=CognitiveComparehelpers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("@mui/material"),i=require("lucide-react"),o=require("react");exports.default=function(r){var l,a,s,c=r.open,d=r.anchorEl,u=r.containerEl,p=r.clipTopEl,x=r.scrollContainerEl,f=r.onClose,m=r.summary;r.markdownStyles,r.isLoading;var g=o.useRef(null),h=o.useRef(null),v=o.useState(null),_=v[0],y=v[1],b=o.useState(null),w=b[0],S=b[1],j=o.useState(null),C=j[0],B=j[1],I=o.useState(0),R=I[0],z=I[1],E="string"==typeof m?{deviation_summary:m}:null!=m?m:{},F=E.deviation_title,W=E.deviation_summary,A=E.deviation_impact,T=E.evaluation_outputs,H=!!String(A||"").trim(),M=(null===(l=null==T?void 0:T.metadata)||void 0===l?void 0:l.label_color)||"#6366F1",k=null!==(a=null==u?void 0:u.getBoundingClientRect().width)&&void 0!==a?a:180,q=Math.max(148,k+
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("@mui/material"),i=require("lucide-react"),o=require("react");exports.default=function(r){var l,a,s,c=r.open,d=r.anchorEl,u=r.containerEl,p=r.clipTopEl,x=r.scrollContainerEl,f=r.onClose,m=r.summary;r.markdownStyles,r.isLoading;var g=o.useRef(null),h=o.useRef(null),v=o.useState(null),_=v[0],y=v[1],b=o.useState(null),w=b[0],S=b[1],j=o.useState(null),C=j[0],B=j[1],I=o.useState(0),R=I[0],z=I[1],E="string"==typeof m?{deviation_summary:m}:null!=m?m:{},F=E.deviation_title,W=E.deviation_summary,A=E.deviation_impact,T=E.evaluation_outputs,H=!!String(A||"").trim(),M=(null===(l=null==T?void 0:T.metadata)||void 0===l?void 0:l.label_color)||"#6366F1",k=null!==(a=null==u?void 0:u.getBoundingClientRect().width)&&void 0!==a?a:180,q=Math.max(148,k+120),L=d&&u?{top:d.getBoundingClientRect().top,bottom:d.getBoundingClientRect().bottom,left:u.getBoundingClientRect().left+u.getBoundingClientRect().width/2}:null;o.useEffect(function(){if(!c||!d||!u)return y(null),S(null),void B(null);var e=function(){null!==g.current&&cancelAnimationFrame(g.current),g.current=requestAnimationFrame(function(){var e,n,t=d.getBoundingClientRect(),i=u.getBoundingClientRect(),o=null==p?void 0:p.getBoundingClientRect(),r=null==x?void 0:x.getBoundingClientRect();y({top:t.top,bottom:t.bottom,left:i.left+i.width/2}),S(null!==(e=null==o?void 0:o.bottom)&&void 0!==e?e:null),B(null!==(n=null==r?void 0:r.bottom)&&void 0!==n?n:null),h.current&&z(h.current.offsetHeight)})};e();var n=!0;return window.addEventListener("scroll",e,{passive:!0,capture:n}),window.addEventListener("resize",e),function(){null!==g.current&&cancelAnimationFrame(g.current),window.removeEventListener("scroll",e,n),window.removeEventListener("resize",e)}},[c,d,u,p,x]);var P=null!==(s=null!=_?_:L)&&void 0!==s?s:{top:0,bottom:0,left:0},D=P.bottom+20,O=D+R,N=null!=w?Math.max(0,w-D):0,G=null!=C?Math.max(0,O-C):0,J=N>0||G>0;return m?n.jsx(t.Popper,e.__assign({open:c,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:P.bottom-P.top,top:P.top,bottom:P.bottom,left:P.left,right:P.left,x:P.left,y:P.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:21}},{children:n.jsxs(t.Paper,e.__assign({ref:h,sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:q,maxWidth:q},J&&{clipPath:"inset(".concat(N,"px 0 ").concat(G-150,"px 0 round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(M,"26"),borderTop:"3px solid ".concat(M),overflow:"hidden",bgcolor:"#fff"})},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[n.jsx(i.Info,{size:14,color:M}),n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:M,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),n.jsx(t.IconButton,e.__assign({size:"small",onClick:f,sx:{p:.25,ml:.5,color:"#64748B"}},{children:n.jsx(i.X,{size:14})}))]})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[n.jsxs(t.Box,{children:[F&&n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#334155",fontFamily:'"Inter", sans-serif',lineHeight:1.6,fontWeight:700,overflowWrap:"anywhere"}},{children:F})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",color:"#334155",lineHeight:1.6,fontFamily:'"Inter", sans-serif',fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:W||"No summary available."}))]}),H&&n.jsxs(t.Accordion,e.__assign({disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(M,"0A"),border:"1px solid ".concat(M,"33"),borderRadius:"4px",fontFamily:'"Inter", sans-serif',overflow:"hidden",flexShrink:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:n.jsx(i.ChevronDown,{size:16,color:M}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(M,"1A")}}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:M,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),n.jsx(t.AccordionDetails,e.__assign({sx:{p:1.5,backgroundColor:"#fff"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",color:"#475569",lineHeight:1.6,fontWeight:400,fontFamily:'"Inter", sans-serif',overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(A).replace("Impact -","").trim()}))}))]}))]}))]}))})):null};
|
|
2
2
|
//# sourceMappingURL=CognitiveSummaryPopup.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("@mui/material"),r=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"),i=require("@mui/material"),r=require("react"),t=require("../CognitiveCompareConstants.js"),o=require("lucide-react"),a=require("react-markdown"),l=require("../CognitiveComparehelpers.js"),s=require("rehype-raw");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(r),u=c(a),g=c(s),h=d.default.memo(function(a){var s=a.content,c=a.sxStyles,h=a.deviationBadges,p=void 0===h?[]:h,f=a.highlights,v=void 0===f?[]:f,x=a.maintainRelativeOrder,_=void 0===x||x,m=a.highlightBg,b=r.useRef(null),y=r.useMemo(function(){return p.reduce(function(n,i){var r;return e.__assign(e.__assign({},n),((r={})[i.id]=i,r))},{})},[p]),C=function(n,i){return d.default.Children.map(n,function(n){var r;if(!d.default.isValidElement(n))return n;var t=(null===(r=n.props)||void 0===r?void 0:r.children)?C(n.props.children,i):n.props.children,o=d.default.cloneElement(n,e.__assign(e.__assign({},n.props),{children:t}));return i(o)})},E=r.useMemo(function(){return{mark:function(i){var r,t,o,a,l=i.children,s=e.__rest(i,["children"]),c=s["data-badge-id"],d=c?y[c]:null,u=s["data-highlight-color"],g=null!==(a=null!==(t=null!=u?u:null===(r=null==d?void 0:d.style)||void 0===r?void 0:r.highlightBg)&&void 0!==t?t:null===(o=null==d?void 0:d.style)||void 0===o?void 0:o.badgeBg)&&void 0!==a?a:m;return n.jsx("span",e.__assign({style:e.__assign(e.__assign({},s.isSuggestedDeviationFix?{}:{backgroundColor:g}),{borderRadius:"2px"})},{children:l}))},span:function(r){var a,l,s,c,d,u,g=r.children,h=e.__rest(r,["children"]),p=h["data-badge-id"];if(!p)return n.jsx("span",e.__assign({},h,{children:g}));var f=y[p];if(!f)return n.jsx("span",e.__assign({},h,{children:g}));var v="number"==typeof f.stackIndex?f.stackIndex:0,x="translateY(calc(-20% + ".concat(24*v,"px))");return n.jsxs(i.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[n.jsxs(i.Box,e.__assign({ref:f.badgeRef,className:"deviation-badge","data-side":f.side||"right",sx:e.__assign(e.__assign({fontStyle:"normal",position:"absolute",zIndex:30+v,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=f.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=f.style)||void 0===l?void 0:l.badgeText)||t.DEFAULT_DEVIAION_COLOR,border:"1px solid ".concat((null===(s=f.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"margin-top 0.2s ease-out"},"left"===f.side?{right:"-16px",transform:"".concat(x," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(x," translateX(calc(-100% - 8px))")}),f.isConnected&&f.style&&{outline:"2px solid ".concat(f.style.badgeBorder),outlineOffset:"1px"})},{children:[n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),f.onSummaryClick&&f.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:f.label})),("left"===f.side||f.isOrphan)&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(c=f.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE")}},{children:null!=f.score&&"N/A"!==f.score&&"NA"!==f.score&&0!==f.score?"".concat(f.score):"N/A"===f.score||"NA"===f.score?"N/A":"Same"}))]})),("left"===f.side||f.isOrphan)&&n.jsx(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),f.onClick&&f.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(d=f.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===(u=f.style)||void 0===u?void 0:u.badgeText)||"#3730A3"})}))]})),g]}))},updated:function(i){var r=i.children;return e.__rest(i,["children"]),n.jsx(n.Fragment,{children:r})},deleted:function(i){var r=i.children;e.__rest(i,["children"]),console.log("nitish: ",r);var t=C(r,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(i){var r=i.children;e.__rest(i,["children"]);var t=C(r,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}))}}},[y,_,m]),j=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(""):""},F=r.useMemo(function(){var e=j(l.safeStringify(s||"")),n=(p||[]).map(function(e){var n,i;return{id:null==e?void 0:e.id,highlight:j((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(i=null==e?void 0:e.style)||void 0===i?void 0:i.badgeBg)||m}}).filter(function(e){return e.id&&e.highlight}),i={};n.forEach(function(e){i[e.highlight]||(i[e.highlight]=[]),i[e.highlight].push(e)});var r=Object.keys(i).sort(function(e,n){return n.length-e.length}),t=new Set,o=function(e,n,i,r,t){void 0===n&&(n=""),void 0===i&&(i=""),void 0===r&&(r="");var o=e.startsWith("\n\n"),a=e.endsWith("\n\n"),l=t?' data-highlight-color="'.concat(t,'"'):"";return i+e.split(/(\n{2,})/).map(function(e,i,r){if(/^\n{2,}$/.test(e))return e;if(!e.trim())return e;var t=0===i||1===i&&/^\n{2,}$/.test(r[0]),s=i===r.length-1||i===r.length-2&&/^\n{2,}$/.test(r[r.length-1]);return o&&t||a&&s?e:'<mark data-badge-id="'.concat(n,'"').concat(l,">").concat(e,"</mark>")}).join("").replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")+r},a={},c=0;r.forEach(function(n){for(var s=i[n],d=s[0],u=d.highlightColor,g=1;g<s.length;g++)u=l.mixHexColors(u,s[g].highlightColor);var h=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),p=r.filter(function(e){return n.length>e.length&&n.includes(e)}).sort(function(e,n){return n.length-e.length}),f=function(e){var r=n;return p.forEach(function(n){for(var a=i[n],s=a[0].highlightColor,c=1;c<a.length;c++)s=l.mixHexColors(s,a[c].highlightColor);var d=l.mixHexColors(u,s),g="",h="";e&&a.forEach(function(e){g+='<span data-badge-id="'.concat(e.id,'">'),h="</span>"+h,t.add(e.id)});var p=o(n,a[0].id,g,h,d);r=r.split(n).join(p)}),r},v=e.includes(n),x=f(v),_=f(!1),m=s.every(function(e){return t.has(e.id)});if(v&&!m){var b="__DEV_TOKEN_".concat(c++,"__"),y="",C="";s.forEach(function(e){y+='<span data-badge-id="'.concat(e.id,'">'),C="</span>"+C,t.add(e.id)}),a[b]=o(x,d.id,y,C,u),e=e.replace(n,b)}var E="__HIGHLIGHT_TOKEN_".concat(c++,"__");a[E]=o(_,d.id,"","",u),e=e.replace(new RegExp(h,"g"),E)});var d=new Set(r);return v.forEach(function(n){if(n){var i=j(n);if(i&&!d.has(i)){var r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),t="__PLAIN_TOKEN_".concat(c++,"__");a[t]=o(i),e=e.replace(new RegExp(r,"g"),t)}}}),Object.keys(a).forEach(function(n){e=e.split(n).join(a[n])}),e},[s,p,v,m]);return r.useLayoutEffect(function(){if(b.current){var e=function(){var e=Array.from(b.current.querySelectorAll(".deviation-badge"));if(0!==e.length){e.forEach(function(e){e.style.marginTop="0px"});var n=e.filter(function(e){return"left"===e.dataset.side}),i=e.filter(function(e){return"left"!==e.dataset.side}),r=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,top:n.top,bottom:n.bottom}});n.sort(function(e,n){return e.top-n.top});var i=-1/0;n.forEach(function(e){if(e.top<i+6){var n=i+6-e.top;e.el.style.marginTop="".concat(n,"px"),i=e.bottom+n}else i=e.bottom})}};r(n),r(i)}};e();var n=new ResizeObserver(function(){return e()});return n.observe(b.current),function(){return n.disconnect()}}},[F]),n.jsx(i.Typography,e.__assign({component:"div",ref:b,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(u.default,e.__assign({components:E,rehypePlugins:[g.default]},{children:l.safeStringify(F).replace(/\\n/g,"\n")}))}))},l.areMarkdownPropsEqual);exports.MemoizedMarkdown=h;
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
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 f}from"@mui/material";import{ChevronDown as p,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,getFirstDeviationOutputValue as R,getFirstDeviationColor as C,hasValue as w,getBentArrowPath as B,smoothScrollTo as I}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as T,DEFAULT_FIELD_CONFIG as _,DEFAULT_COMPARISON_CONFIG as E}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{EMPTY_SUMMARY_POPUP_STATE as F,DEFAULT_DEVIAION_COLOR as D,DEFAULT_COMPONENT_HEADER_TEXT as M}from"./CognitiveCompareConstants.js";import A from"./CognitivePopup.js";import N from"./MoreFunctionsPopup.js";import k from"./LoaderComponent.js";import j from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as L}from"./hooks/useComparePopups.js";import{useSectionRefs as O}from"./hooks/useSectionRefs.js";import{useAccordionState as P}from"./hooks/useAccordionState.js";import{useDeviationNavigation as z}from"./hooks/useDeviationNavigation.js";import W from"./components/CompareHeader.js";import Y from"./components/SectionAccordion.js";import q from"./components/SubSectionAccordion.js";import K from"./components/CognitiveSummaryPopup.js";import V from"./components/connectedLines.js";var X=function(X){var J,U,$,G,Q,Z,nn,en,tn,on,rn,ln,un,cn,dn,an,sn,vn,fn,pn,gn,hn,xn,mn,yn,bn,Sn=X.componentHeaderText,Rn=void 0===Sn?M:Sn,Cn=X.treeData,wn=X.comparisonConfig,Bn=X.leftColumnTitleText,In=X.rightColumnTitleText,Tn=X.markdownStyles,_n=X.resetTrigger,En=X.displayConfig,Fn=void 0===En?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:En,Dn=X.popupConfig,Mn=X.deviationData,An=void 0===Mn?{}:Mn,Nn=X.deviationNodeIdToView,kn=X.resetDeviationNodeId,jn=o(Fn.maintainRelativeOrder),Hn=jn[0],Ln=jn[1],On=!!Hn||!!(null==Fn?void 0:Fn.showDeviationBadges),Pn=o(!1),zn=Pn[0],Wn=Pn[1],Yn=o(!1),qn=Yn[0],Kn=Yn[1],Vn=o(null),Xn=Vn[0],Jn=Vn[1],Un=o(!1),$n=Un[0],Gn=Un[1],Qn=o(null===(U=null!==(J=null==Cn?void 0:Cn.newEvaluationResult)&&void 0!==J?J:null==Fn?void 0:Fn.enableDeviationSchemaBackwardCompatibility)||void 0===U||U)[0],Zn=o(!1),ne=Zn[0],ee=Zn[1],te=o(!1),ie=te[0],oe=te[1],re=o(null),le=re[0],ue=re[1],ce=r(!1),de=o(new Set),ae=de[0],se=de[1],ve=o([]),fe=ve[0],pe=ve[1],ge=r(null),he=r(!1),xe=r(null),me=r({}),ye=r([]),be=r(!1),Se=r(!1),Re=r(null),Ce=r(function(){}),we=l(function(){return(null==Cn?void 0:Cn.cognitive_decisioning)||{}},[Cn]),Be=o({width:0,height:0}),Ie=Be[0],Te=Be[1],_e=l(function(){return n(n({},T),Tn)},[Tn]),Ee=r(null),Fe=r(null),De=r(null),Me=r(null),Ae=r(null),Ne=r(null),ke=r(null),je=r(null),He=r(!1),Le=r(null),Oe=r(null),Pe=L(Ee),ze=Pe.cognitivePopup,We=Pe.setCognitivePopup,Ye=Pe.moreFunctions,qe=Pe.setMoreFunctions,Ke=Pe.position,Ve=Pe.setPosition,Xe=Pe.activeBadgeId,Je=Pe.summaryPopup,Ue=Pe.setSummaryPopup,$e=Pe.closeSummaryPopup,Ge=Pe.setActiveBadgeId,Qe=Pe.popupRef,Ze=Pe.closeCognitivePopup,nt=Pe.closeMoreFunctionsPopup,et=l(function(){var n,e,t,i,o,r,l;return{fields:null!==(n=null==wn?void 0:wn.fields)&&void 0!==n?n:_,thresholds:{high:null!==(t=null===(e=null==wn?void 0:wn.thresholds)||void 0===e?void 0:e.high)&&void 0!==t?t:E.thresholds.high,medium:null!==(o=null===(i=null==wn?void 0:wn.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:E.thresholds.medium,exact:null!==(l=null===(r=null==wn?void 0:wn.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:E.thresholds.exact}}},[wn]),tt=o(null),it=tt[0];tt[1];var ot=null===(Q=null===($=null==Cn?void 0:Cn.documents)||void 0===$?void 0:$[null===(G=null==Cn?void 0:Cn.input_index_map)||void 0===G?void 0:G[0]])||void 0===Q?void 0:Q.title,rt=null===(en=null===(Z=null==Cn?void 0:Cn.documents)||void 0===Z?void 0:Z[null===(nn=null==Cn?void 0:Cn.input_index_map)||void 0===nn?void 0:nn[1]])||void 0===en?void 0:en.title,lt=m(Bn||ot||"Uploaded Contract"),ut=m(In||rt||"Reference Template"),ct=H(Cn,Hn,An,et,Qn),dt=ct.activeProposed,at=ct.existingRule,st=ct.proposedSections,vt=ct.existingSections,ft=ct.visibleFields,pt=ct.parentDeviationRecord,gt=ct.deviationNumberRegistry,ht=ct.parseError;u(function(){ht&&Jn("Failed to load comparison: ".concat(ht))},[ht]);var xt=st.length>0||vt.length>0,mt=O(ft.map(function(n){return n.key}),Math.max(st.length,vt.length)),yt=mt.leftRefs,bt=mt.rightRefs,St=mt.sectionLeftRefs,Rt=mt.sectionRightRefs,Ct=mt.lhsBadgeRefs,wt=mt.rhsBadgeRefs,Bt=mt.sectionRightRowRefs,It=mt.subSectionLeftRefs,Tt=mt.subSectionRightRefs,_t=mt.sectionRowRefs,Et=mt.getSectionRowRef,Ft=mt.getSubSectionRef,Dt=mt.getBadgeRef,Mt=at.analysis,At=m(null===(on=null===(tn=null==Mt?void 0:Mt.rule_difference_comparison)||void 0===tn?void 0:tn.summary)||void 0===on?void 0:on.overall_summary),Nt=!!At.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),kt=null!==(rn=null==Cn?void 0:Cn.base_root_id)&&void 0!==rn?rn:"-1";null==Cn||Cn[kt];var jt=Qn?null!==(xn=null!==(pn=An&&(null===(fn=null==An?void 0:An[kt])||void 0===fn?void 0:fn.evaluation_result))&&void 0!==pn?pn:null===(hn=null===(gn=null==Cn?void 0:Cn.nodes)||void 0===gn?void 0:gn[kt])||void 0===hn?void 0:hn.evaluation_result)&&void 0!==xn?xn:null:null!==(vn=null!==(cn=An&&(null===(un=null===(ln=null==An?void 0:An[kt])||void 0===ln?void 0:ln.evaluation_result)||void 0===un?void 0:un[0]))&&void 0!==cn?cn:null===(sn=null===(an=null===(dn=null==Cn?void 0:Cn.nodes)||void 0===dn?void 0:dn[kt])||void 0===an?void 0:an.evaluation_result)||void 0===sn?void 0:sn[0])&&void 0!==vn?vn:null,Ht=y(jt),Lt=b(null!==(bn=null===(yn=null===(mn=null==jt?void 0:jt.evaluation_outputs)||void 0===mn?void 0:mn.metadata)||void 0===yn?void 0:yn.label_color)&&void 0!==bn?bn:""),Ot=c(function(){var n,e,t,i,o,r;Gn(!1),Se.current=!1;var l=Re.current,u=ei.current;if(null!==l)if("string"==typeof l&&l.includes(S)){var c=l.split(S);(d=(null===(n=It.current[c[2]])||void 0===n?void 0:n.current)||(null===(e=St.current[Number(c[2])])||void 0===e?void 0:e.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(t=St.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=Tt.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=Rt.current[Number(c[3])])||void 0===o?void 0:o.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(r=Rt.current[u])||void 0===r?void 0:r.current)&&(a.style.paddingTop="0px")}ue(null),Re.current=null,ei.current=null,ee(!1),Kn(!1),Me.current&&(Me.current.style.height="0px"),Ae.current&&(Ae.current.style.height="0px"),Ne.current&&(Ne.current.style.height="0px"),ke.current&&(ke.current.style.height="0px")},[]),Pt=c(function(){Ot(),se(new Set),pe([]),ye.current=[],ui([]),ai(null),Ue(F),Ze(),requestAnimationFrame(function(){var n;null===(n=Ce.current)||void 0===n||n.call(Ce)})},[]),zt=r(Pt);u(function(){zt.current=Pt},[Pt]),u(function(){_n&&zt.current()},[_n]);var Wt=P({maintainRelativeOrder:!!Hn,proposedSections:st,existingSections:vt,activeSideBySideSection:le,connectedSections:ae,resetSideBySide:Ot,setConnectedSections:se,setConnectedLines:pe,cachedConnectedPositions:ye,svgContainerRef:ge,isAnimatingRef:he,animationTimerRef:xe,calculateLinesRef:Ce,sectionLeftRefs:St,sectionRightRefs:Rt,subSectionLeftRefs:It,subSectionRightRefs:Tt}),Yt=Wt.expandedSections,qt=Wt.setExpandedSections,Kt=Wt.expandedSubSections,Vt=Wt.setExpandedSubSections,Xt=Wt.toggleSection,Jt=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?we[s]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:s,decisioning:[],gap:[],relevance_score:0},f=null!==(d=null===(c=_t.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null;return{isLoading:null!==(a=null==Fn?void 0:Fn.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:f,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==Cn?void 0:Cn.documents,input_index_map:null==Cn?void 0:Cn.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}},[we,Cn]),Ut=c(function(n){nt(),Ve(null),We(n)},[nt]),$t=function(n,e,t,i,o,r){var l;if(n.stopPropagation(),Ye.open&&Ye.sectionIdx===o)nt();else{var u=n.currentTarget,c="left";(null===(l=De.current)||void 0===l?void 0:l.contains(u))&&(c="right");Se.current&&Ot(),se(new Set),pe([]),ye.current=[],Ze(),Je.open?Di():$e(),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=wt.current[l])||void 0===n?void 0:n.current:null===(e=Ct.current[l])||void 0===e?void 0:e.current}return"right"===c?null===(t=wt.current[o])||void 0===t?void 0:t.current:null===(i=Ct.current[o])||void 0===i?void 0:i.current}()||u;qe(Jt(n,e,i,o,t,r))})}},Gt=c(function(){null!==Ye.sectionIdx&&Ye.anchorEl?Ut(n(n({},Ye),{open:!0})):nt()},[Ye,nt,Ut]),Qt=c(function(){var n=Ye.sectionIdx,e=Ye.isOrphan;nt(),$e(),null!==n&&(e?Jn("No counterpart exists to connect to."):(Se.current&&Ot(),pe([]),ye.current=[],se(function(e){return e.has(n)?new Set:new Set([n])}),setTimeout(function(){Ce.current&&Ce.current()},50)))},[Ye.sectionIdx,Ye.isOrphan,nt,$e,Ot]),Zt=r(null),ni=r(null),ei=r(null),ti=r(null),ii=r(null),oi=r(null),ri=o([]),li=ri[0],ui=ri[1];r(null);var ci=o(null),di=ci[0],ai=ci[1];u(function(){if(it){var n=et.fields.find(function(n){return n.analysisKey===it||n.key===it});if(n){var e=yt.current[n.key]||bt.current[n.key];(null==e?void 0:e.current)&&setTimeout(function(){return e.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[it,et.fields]);var si=c(function(n){var e,t,i,o,r,l,u,c,d,a=null===(e=null==Mt?void 0:Mt.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 f=s.mappings[0]||{};return{score:s.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: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}},[Mt]),vi=c(function(e,t){var i,o,r;void 0===t&&(t="left");var l=null,u=null;if("left"===t)if(l=st[e],Hn&&l){var c=vt.filter(function(n){var e;return null===(e=l.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});u=c.find(function(n){return n.evaluationResult})||c[0]}else u=vt[e];else if(u=vt[e],Hn&&u){var d=st.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(u.selfIndex)});l=d.find(function(n){return n.evaluationResult})||d[0]}else l=st[e];var a=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,s=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,v=!(!(null==l?void 0:l.cognitiveData)&&!(null==u?void 0:u.cognitiveData));if(!a&&!s&&!v)return n(n({},b(D)),{label:"Not Defined"});var f=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==u?void 0:u.evaluationResult)&&void 0!==o?o:null,p=R(f),g=C(f);return n(n({},b(g)),null!=f?{label:null!==(r=p)&&void 0!==r?r:""}:{label:null})},[st,vt,we,et,Hn]),fi=c(function(e){for(var t,i,o,r,l,u=e.split("-").map(Number),c=st[u[0]],d=vt[u[0]],a=1;a<u.length;a++)(null==c?void 0:c.subsections)&&(c=c.subsections[u[a]]),(null==d?void 0:d.subsections)&&(d=d.subsections[u[a]]);if(!c&&!d)return null;var s=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,v=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,f=m(null==c?void 0:c.id)||m(null==d?void 0:d.id)||"",p=!(!(null==c?void 0:c.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!s&&!v&&!p)return n(n({},b(D)),{label:"Not Defined"});null!==(i=null!==(t=null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||f&&(null===(o=we[f])||void 0===o||o.relevance_score);var g=null!==(l=null!==(r=null==c?void 0:c.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,h=R(g),x=C(g);return n(n({},b(x)),null!=g?{label:null!=h?h:""}:{label:null})},[st,vt,we,et]),pi=c(function(e,t){var i,o,r,l,u,c,d,a,s,v,f,p,g,h,x,m,y;if(!e||null==t)return null;var S=null!==(d=null!==(u=null!==(o=null===(i=null==An?void 0:An[e])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==Cn?void 0:Cn.nodes)||void 0===r?void 0:r[e])||void 0===l?void 0:l.evaluation_result)&&void 0!==u?u:null===(c=null==Cn?void 0:Cn[e])||void 0===c?void 0:c.evaluation_result)&&void 0!==d?d:null;if(!S||"object"!=typeof S)return null;var R=null!==(f=null!==(s=null===(a=null==S?void 0:S.deviations)||void 0===a?void 0:a[t])&&void 0!==s?s:null===(v=null==S?void 0:S.deviation_entries)||void 0===v?void 0:v[t])&&void 0!==f?f:null==S?void 0:S[t],C=null!==(y=null!==(h=null===(g=null===(p=null==R?void 0:R.evaluation_outputs)||void 0===p?void 0:p.metadata)||void 0===g?void 0:g.label_color)&&void 0!==h?h:null===(m=null===(x=null==S?void 0:S.evaluation_outputs)||void 0===x?void 0:x.metadata)||void 0===m?void 0:m.label_color)&&void 0!==y?y:D;return n(n({},b(C)),{label:null})},[An,Cn]),gi=c(function(){qt({}),Vt({}),Ot(),se(new Set),pe([]),ye.current=[],$e(),Ze(),nt(),requestAnimationFrame(function(){Ce.current&&Ce.current()})},[qt,Vt,Ot,$e,Ze,nt]),hi=l(function(){return Object.values(Yt).some(Boolean)||Object.values(Kt).some(Boolean)},[Yt,Kt]),xi=c(function(){var n,e,t,i,o,r,l,u,c,d,a,s,v,f,p,g,h,x,m,y,b,R,C;if(!He.current&&!he.current){He.current=!0;try{if(!Zt.current)return;var I=function(n){var e=n.split("-"),t=e[0];if(!Yt[t]&&!1===Hn)return!1;if(Hn&&!Yt["left-".concat(t)]&&!Yt["right-".concat(t)]&&!Yt[t])return!1;for(var i=t,o=1;o<e.length-1;o++)if(i+="-".concat(e[o]),!Kt[i])return!1;return!0},T=Zt.current.getBoundingClientRect();Te({width:T.width,height:T.height});var _=[];if(ft.forEach(function(n){var e,t,i=n.key,o=null===(e=yt.current[i])||void 0===e?void 0:e.current,r=null===(t=bt.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")}),!he.current){for(var E=0;E<Math.max(st.length,vt.length);E++){var F=null===(n=St.current[E])||void 0===n?void 0:n.current,D=null===(e=Rt.current[E])||void 0===e?void 0:e.current;F&&(F.style.height="auto",F.style.minHeight="0px"),D&&(D.style.height="auto",D.style.minHeight="0px")}Hn||Object.keys(It.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=It.current[n])||void 0===e?void 0:e.current,o=null===(t=Tt.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 M={};ft.forEach(function(n){var e,t,i=n.key,o=null===(e=yt.current[i])||void 0===e?void 0:e.current,r=null===(t=bt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();M[i]=Math.max(l.height,u.height)}});var A={left:{},right:{}},N={};if(!he.current)if(Hn){if($n&&null!==le)if("number"==typeof le){var k=le,j=st[k],H=null===(o=St.current[k])||void 0===o?void 0:o.current;H&&j&&(j.refIndexes||[]).forEach(function(n){var e,t=vt.findIndex(function(e){return e.selfIndex===n}),i=null===(e=Rt.current[t])||void 0===e?void 0:e.current;if(i&&(Yt["left-".concat(k)]||Yt["right-".concat(t)])){var o=Math.max(H.getBoundingClientRect().height,i.getBoundingClientRect().height);A.left[k]=Math.max(A.left[k]||0,o),A.right[t]=Math.max(A.right[t]||0,o)}})}else{var L=le.split(S)[2];if(L){F=null===(r=It.current[L])||void 0===r?void 0:r.current,D=null===(l=Tt.current[L])||void 0===l?void 0:l.current;if(F&&D){O=Math.max(F.getBoundingClientRect().height,D.getBoundingClientRect().height);N[L]=Math.max(N[L]||0,O)}}}}else{Object.keys(It.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=It.current[n])||void 0===e?void 0:e.current,o=null===(t=Tt.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);N[n]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(E=0;E<Math.min(st.length,vt.length);E++){var F=null===(t=St.current[E])||void 0===t?void 0:t.current,D=null===(i=Rt.current[E])||void 0===i?void 0:i.current;if(F&&D){var O=Math.max(F.getBoundingClientRect().height,D.getBoundingClientRect().height);A.left[E]=O,A.right[E]=O}}}if(ft.forEach(function(n){var e,t,i=n.key,o=null===(e=yt.current[i])||void 0===e?void 0:e.current,r=null===(t=bt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=M[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),he.current||(Object.entries(A.left).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=St.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(A.right).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=Rt.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Hn||Object.keys(N).forEach(function(n){var e,t,i=null===(e=It.current[n])||void 0===e?void 0:e.current,o=null===(t=Tt.current[n])||void 0===t?void 0:t.current;if(i&&o&&N[n]){var r=N[n];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),Hn)st.forEach(function(n,e){var t;(null===(t=St.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=vt.findIndex(function(e){return e.selfIndex===n});if(-1!==v){var f=null===(t=Ct.current[e])||void 0===t?void 0:t.current,p=null===(i=wt.current[v])||void 0===i?void 0:i.current;if(f&&p){var g=f.getBoundingClientRect(),h=p.getBoundingClientRect(),x=g.right-T.left,m=h.left-T.left,y=g.top+g.height/2-T.top,b=h.top+h.height/2-T.top;if($n&&le===e){var S=null!==(r=null===(o=je.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=De.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(d=null===(c=je.current)||void 0===c?void 0:c.clientHeight)&&void 0!==d?d:1/0),w=R+(null!==(s=null===(a=De.current)||void 0===a?void 0:a.clientHeight)&&void 0!==s?s:1/0),B=g.top+g.height/2,I=h.top+h.height/2,E=function(n,e,t){return Math.max(e,Math.min(t,n))};y=E(B,S,C)-T.top,b=E(I,R,w)-T.top}var F=vi(e);F&&_.push({id:"line-".concat(e,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:F,sectionIdx:e,targetRightIdx:v})}}})});else{for(E=0;E<Math.min(st.length,vt.length);E++){var P=null===(u=St.current[E])||void 0===u?void 0:u.current,z=null===(c=Rt.current[E])||void 0===c?void 0:c.current;if(P&&z){var W=P.getBoundingClientRect(),Y=z.getBoundingClientRect(),q=Math.max(W.top,Y.top)+18-T.top,K=(null===(d=vt[E])||void 0===d?void 0:d.id)||"sec-".concat(E);(Z=vi(E))&&_.push({id:K,x1:W.right-T.left,y1:q,x2:Y.left-T.left,y2:q,style:Z,sectionIdx:E,hasCognitive:!!((null===(a=st[E])||void 0===a?void 0:a.cognitiveData)||(null===(s=vt[E])||void 0===s?void 0:s.cognitiveData)||K&&we[K]),isSubSection:!1})}}Object.keys(It.current).forEach(function(n){var e,t,i,o,r,l;if(I(n)){var u=null===(e=It.current[n])||void 0===e?void 0:e.current,c=null===(t=Tt.current[n])||void 0===t?void 0:t.current;if(u&&c){for(var d=n.split("-").map(Number),a=st[d[0]],s=vt[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 f=!!a&&((null===(i=a.displayTitle)||void 0===i||i)&&w(a.title)),p=!!a&&((null===(o=a.displayContent)||void 0===o||o)&&w(a.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&w(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&w(s.content));if(f&&p||g&&h){var x=u.getBoundingClientRect(),m=c.getBoundingClientRect(),y=Math.max(x.top,m.top)+16-T.top,b=fi(n);b&&"Not Defined"!==b.label&&_.push({id:"subsec-".concat(n),x1:x.right-T.left,y1:y,x2:m.left-T.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($n&&"string"==typeof le&&le.includes(S)){var V=le.split(S),X=V[0],J=V[1],U=V[2],$=(V[3],"".concat(X).concat(S).concat(J)),G=null===(v=Ct.current[$])||void 0===v?void 0:v.current,Q=null===(f=wt.current[$])||void 0===f?void 0:f.current;if(G&&Q){var Z,nn=G.getBoundingClientRect(),en=Q.getBoundingClientRect(),tn=nn.right-T.left,on=en.left-T.left,rn=nn.top+nn.height/2-T.top,ln=en.top+en.height/2-T.top;if(Hn){var un=null!==(g=null===(p=je.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==g?g:0,cn=null!==(x=null===(h=De.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==x?x:0,dn=un+(null!==(y=null===(m=je.current)||void 0===m?void 0:m.clientHeight)&&void 0!==y?y:1/0),an=cn+(null!==(R=null===(b=De.current)||void 0===b?void 0:b.clientHeight)&&void 0!==R?R:1/0),sn=function(n,e,t){return Math.max(e,Math.min(t,n))};rn=sn(nn.top+nn.height/2,un,dn)-T.top,ln=sn(en.top+en.height/2,cn,an)-T.top}(Z=null!==(C=pi(X,J))&&void 0!==C?C:fi(U))&&_.push({id:"line-subsec-".concat($),x1:tn,y1:rn,x2:on,y2:ln,style:Z,sectionIdx:Number(U.split("-")[0]),isSubSection:!0,subSectionKeyPath:le})}}if(ui(_),ii.current&&oi.current){var vn=ii.current.getBoundingClientRect(),fn=oi.current.getBoundingClientRect(),pn=(vn.top+vn.height/2-T.top+fn.top+fn.height/2-T.top)/2;ai({x1:vn.right-T.left,x2:fn.left-T.left,y:pn})}else ai(null);if(ae.size>0){var gn=[],hn=je.current,xn=De.current;if(hn&&xn){var mn=[],yn=hn.getBoundingClientRect().top,bn=xn.getBoundingClientRect().top,Sn=yn+hn.clientHeight,Rn=bn+xn.clientHeight,Cn=hn.scrollTop,wn=xn.scrollTop,Bn=T.top,In=function(n,e,t){return Math.max(e,Math.min(t,n))};ae.forEach(function(n){var e,t,i,o,r,l;if("string"==typeof n&&n.includes(S)){var u=n.split(S),c=u[0],d=u[1],a=u[2],s=(u[3],"".concat(c).concat(S).concat(d)),v=null===(e=Ct.current[s])||void 0===e?void 0:e.current,f=null===(t=wt.current[s])||void 0===t?void 0:t.current;if(!v||!f)return;var p=v.getBoundingClientRect(),g=f.getBoundingClientRect(),h=null!==(i=pi(c,d))&&void 0!==i?i:fi(a),x=(j=p.right-T.left)+.5*((H=g.left-T.left-0)-j),m=p.top+p.height/2,y=g.top+g.height/2,b=m-yn+Cn,R=y-bn+wn,C="conn-subsec-".concat(s);mn.push({lhsScrollY:b,rhsScrollY:R,x1:j,x2:H,containerTop:Bn,leftIdx:n,rhsArrayIdx:n,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var w=In(m,yn,Sn),I=In(y,bn,Rn),_=w-Bn,E=I-Bn,F=y>=bn-4&&y<=Rn+4,D="";D=(L=m>=yn-4&&m<=Sn+4)&&F?B(j,_,H,E):L&&!F?"M ".concat(j,",").concat(_," L ").concat(x,",").concat(_," L ").concat(x,",").concat(E):!L&&F?"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E," L ").concat(H,",").concat(E):"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E),gn.push({id:C,pathD:D,style:h,leftIdx:n,rhsArrayIdx:n})}else if(Hn){var M=n,A=st[M];if(!(null===(l=null==A?void 0:A.refIndexes)||void 0===l?void 0:l.length))return;A.refIndexes.forEach(function(n){var e,t,i=vt.findIndex(function(e){return e.selfIndex===n});if(-1!==i){var o=null===(e=Ct.current[M])||void 0===e?void 0:e.current,r=null===(t=wt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=vi(M),d=l.right-T.left,a=u.left-T.left-0,s=d+.5*(a-d),v=l.top+l.height/2,f=u.top+u.height/2,p=v-yn+Cn,g=f-bn+wn,h="conn-".concat(M,"-").concat(i);mn.push({lhsScrollY:p,rhsScrollY:g,x1:d,x2:a,containerTop:Bn,leftIdx:M,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var x=In(v,yn,Sn),m=In(f,bn,Rn),y=x-Bn,b=m-Bn,S=v>=yn-4&&v<=Sn+4,R=f>=bn-4&&f<=Rn+4,C="";C=S&&R?B(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),gn.push({id:h,pathD:C,style:c,leftIdx:M,rhsArrayIdx:i})}}})}else{var N=n,k=N;v=null===(o=Ct.current[N])||void 0===o?void 0:o.current,f=null===(r=wt.current[k])||void 0===r?void 0:r.current;if(!v||!f)return;var j,H;p=v.getBoundingClientRect(),g=f.getBoundingClientRect(),h=vi(N),x=(j=p.right-T.left)+.5*((H=g.left-T.left-0)-j),m=p.top+p.height/2,y=g.top+g.height/2,b=m-yn+Cn,R=y-bn+wn,C="conn-".concat(N,"-").concat(k);mn.push({lhsScrollY:b,rhsScrollY:R,x1:j,x2:H,containerTop:Bn,leftIdx:N,rhsArrayIdx:k,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var L;w=In(m,yn,Sn),I=In(y,bn,Rn),_=w-Bn,E=I-Bn,F=y>=bn-4&&y<=Rn+4,D="";D=(L=m>=yn-4&&m<=Sn+4)&&F?B(j,_,H,E):L&&!F?"M ".concat(j,",").concat(_," L ").concat(x,",").concat(_," L ").concat(x,",").concat(E):!L&&F?"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E," L ").concat(H,",").concat(E):"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E),gn.push({id:C,pathD:D,style:h,leftIdx:N,rhsArrayIdx:k})}}),ye.current=mn}pe(gn)}else pe([]),ye.current=[]}catch(n){console.error("Line render safe fail: ",n)}finally{He.current=!1}}},[ft,st,vt,we,et,si,vi,pi,Hn,$n,le,ae,Yt,Kt]),mi=c(function(){var n,e,t,i,o,r,l,u,c,d,a,s,v,f,p=ye.current;if(p.length&&!he.current){var g=null!==(e=null===(n=je.current)||void 0===n?void 0:n.scrollTop)&&void 0!==e?e:0,h=null!==(i=null===(t=De.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=je.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(u=null===(l=De.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(d=null===(c=je.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==d?d:0,b=null!==(s=null===(a=De.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,R=b+m,C=null!==(f=null===(v=Zt.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,w=function(n,e,t){return Math.max(e,Math.min(t,n))};p.forEach(function(n){var e=n.lhsScrollY-g+y,t=n.rhsScrollY-h+b,i=me.current[n.styleId+"-stroke"],o=me.current[n.styleId+"-bg"];if(i||o){var r,l=w(e,y,S),u=w(t,b,R),c=l-C,d=u-C,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?B(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(){Ce.current=xi},[xi]);var yi=r(null),bi=r(null),Si=c(function(){ye.current.length>0&&!he.current||(null!==yi.current&&clearTimeout(yi.current),yi.current=setTimeout(function(){Ce.current(),yi.current=null},50))},[]),Ri=c(function(){oe(!0),ee(!1),null!==bi.current&&clearTimeout(bi.current),null!==yi.current&&(clearTimeout(yi.current),yi.current=null),bi.current=setTimeout(function(){var n,e,t,i,o,r,l,u,c,d,a;try{if(ye.current=[],Se.current&&null!==Re.current&&null!==ei.current){var s=Re.current,v=ei.current,f="string"==typeof s&&s.includes(S),p=null,g=null,h=null,x=null;if(f){var m=s.split(S),y="".concat(m[0]).concat(S).concat(m[1]);p=(null===(n=Ct.current[y])||void 0===n?void 0:n.current)||null,g=(null===(e=wt.current[y])||void 0===e?void 0:e.current)||null,h=(null===(t=It.current[m[2]])||void 0===t?void 0:t.current)||(null===(i=St.current[Number(m[2])])||void 0===i?void 0:i.current)||null,x=(null===(o=Tt.current[m[3]])||void 0===o?void 0:o.current)||(null===(r=Rt.current[Number(m[3])])||void 0===r?void 0:r.current)||null}else p=(null===(l=_t.current[s])||void 0===l?void 0:l.current)||null,h=(null===(u=St.current[s])||void 0===u?void 0:u.current)||null,g=(null===(c=Bt.current[v])||void 0===c?void 0:c.current)||null,x=(null===(d=Rt.current[v])||void 0===d?void 0:d.current)||null;if(p&&g&&h&&x){if(h.style.paddingTop="0px",x.style.paddingTop="0px",!Hn){var b=p.getBoundingClientRect(),R=g.getBoundingClientRect(),C=b.top-R.top;C>0?x.style.paddingTop="".concat(C,"px"):C<0&&(h.style.paddingTop="".concat(Math.abs(C),"px"))}var w=je.current,B=De.current;if(w&&B){var I=p.getBoundingClientRect().top-w.getBoundingClientRect().top+w.scrollTop,T=g.getBoundingClientRect().top-B.getBoundingClientRect().top+B.scrollTop-(I-w.scrollTop);Math.abs(B.scrollTop-T)>1&&(B.scrollTop=T)}}}null===(a=Ce.current)||void 0===a||a.call(Ce),Se.current&&ee(!0)}catch(n){console.error("Safely caught error during resize calculation:",n)}finally{oe(!1),bi.current=null}},150)},[Hn,st,vt]),Ci=c(function(n){var e,t,i,o,r,l,u,c,d,a;if(null!==Le.current&&Oe.current&&Math.abs(n.currentTarget.scrollTop-Le.current)<=2){var s=Oe.current;Le.current=null,Oe.current=null,s()}if(!ce.current){if(Hn||Si(),Se.current){var v=Re.current,f=ei.current,p=je.current,g=De.current;if(null!==v&&null!==f&&p&&g){var h="string"==typeof v&&v.includes(S)?null===(e=Ct.current["".concat(v.split(S)[0]).concat(S).concat(v.split(S)[1])])||void 0===e?void 0:e.current:null===(t=_t.current[v])||void 0===t?void 0:t.current,x="string"==typeof f&&f.includes(S)?null===(i=wt.current["".concat(f.split(S)[0]).concat(S).concat(f.split(S)[1])])||void 0===i?void 0:i.current:null===(o=Bt.current[f])||void 0===o?void 0:o.current;if(h&&x&&ti.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=Ct.current[R])||void 0===r?void 0:r.current,y=null===(l=wt.current[R])||void 0===l?void 0:l.current}else m=null===(u=Ct.current[v])||void 0===u?void 0:u.current,y=null===(c=wt.current[f])||void 0===c?void 0:c.current;var C=null!==(a=null===(d=Zt.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==a?a:0,w=p.getBoundingClientRect().top,B=w+p.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=_,M=w,A=B,Math.max(M,Math.min(A,D)))-C).toString();ti.current.setAttribute("y1",E),ti.current.setAttribute("y2",E);var F=_>=w-4&&_<=B+4;ti.current.setAttribute("visibility",F?"visible":"hidden")}}}}var D,M,A;ye.current.length>0&&!be.current&&(be.current=!0,requestAnimationFrame(function(){mi(),be.current=!1}))}},[mi,Hn,Si]),wi=r(0),Bi=r(0),Ii=r(0),Ti=r(function(){});r(null),u(function(){Ti.current=Ri},[Ri]),u(function(){var n=setTimeout(Si,250),e=function(){return Ti.current()};return window.addEventListener("resize",e),function(){clearTimeout(n),null!==yi.current&&clearTimeout(yi.current),null!==bi.current&&clearTimeout(bi.current),window.removeEventListener("resize",e)}},[dt,at,Mt,ft,Yt,Kt,st,vt,et,Si,$n,le,ne,ae]),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 Fe.current&&o.push(n(Fe.current,wi,e,function(){return Ti.current()},function(){})),Ee.current&&o.push(n(Ee.current,Bi,t,function(){return Ti.current()},function(){return Ce.current()})),Zt.current&&o.push(n(Zt.current,Ii,i,function(){return Ti.current()},function(){return Ce.current()})),function(){o.forEach(function(n){return n.disconnect()}),r.forEach(function(n){null!==n.current&&(cancelAnimationFrame(n.current),n.current=null)})}},[]),u(function(){Se.current=$n},[$n]),u(function(){Re.current=le},[le]);var _i=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";nt(),null!=n&&(e?Jn("No counterpart exists for this section."):$n&&le===n?r?Ot():null==l||l():(se(new Set([n])),pe([]),ye.current=[],Kn(!0),ce.current=!0,ue(n),Re.current=n,Gn(!0),Se.current=!0,ee(!1),Me.current&&(Me.current.style.height="0px"),Ae.current&&(Ae.current.style.height="0px"),Ne.current&&(Ne.current.style.height="0px"),ke.current&&(ke.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),f="".concat(v[0]).concat(S).concat(v[1]);d=(null===(e=Ct.current[f])||void 0===e?void 0:e.current)||null,a=(null===(t=wt.current[f])||void 0===t?void 0:t.current)||null,s=a?n:null}else if(d=(null===(i=_t.current[n])||void 0===i?void 0:i.current)||null,Hn){var p=st[n],g=(null==p?void 0:p.refIndexes)||[];if(g.length>0){var h=g[0],x=vt.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;ei.current=s;var m=je.current,y=De.current,b=function(){!function(){var e,t,i,o,r,l,u,d,a,v,f,p,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=It.current[y[2]])||void 0===e?void 0:e.current)||(null===(t=St.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=Tt.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=Rt.current[Number(y[3])])||void 0===o?void 0:o.current)||null,x=(null===(r=Ct.current[b])||void 0===r?void 0:r.current)||g,m=(null===(l=wt.current[b])||void 0===l?void 0:l.current)||h}else{var R=Number(n),C=null!==s?Number(s):R;g=(null===(u=St.current[R])||void 0===u?void 0:u.current)||null,h=(null===(d=Rt.current[C])||void 0===d?void 0:d.current)||null,x=(null===(a=Ct.current[R])||void 0===a?void 0:a.current)||(null===(v=_t.current[R])||void 0===v?void 0:v.current)||g,m=(null===(f=wt.current[C])||void 0===f?void 0:f.current)||(null===(p=Bt.current[C])||void 0===p?void 0:p.current)||h}if(x&&m&&g&&h){g.style.paddingTop="0px",h.style.paddingTop="0px";var w=x.getBoundingClientRect(),B=m.getBoundingClientRect(),I=w.top-B.top;I>0?h.style.paddingTop="".concat(I,"px"):I<0&&(g.style.paddingTop="".concat(Math.abs(I),"px"))}}(),ee(!0),Ce.current&&Ce.current(),ce.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),Kn(!1),null==l||l()};if(!d||!m)return ce.current=!1,Kn(!1),void(null==l||l());if(a&&y){if(!Hn){var R=0;R="right"===u?a?a.getBoundingClientRect().top:0:d?d.getBoundingClientRect().top:0;var C=Ee.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&&Me.current&&(Me.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 Ae.current&&(Ae.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){I(y,F,E,b)})}n=F}I(y,n,E,b)})}else{var D=T-(_-y.scrollTop);D<0&&Ne.current&&(Ne.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 ke.current&&(ke.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){I(m,D,E,b)})}n=D}I(m,n,E,b)})}}else b()})))},[le,nt,vt,$n,Hn,st,Ot]),Ei=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;Ze();var u="left";(null===(o=De.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=wt.current[l])||void 0===n?void 0:n.current:null===(t=Ct.current[l])||void 0===t?void 0:t.current}return"right"===u?null===(i=wt.current[e])||void 0===i?void 0:i.current:null===(o=Ct.current[e])||void 0===o?void 0:o.current};if(t)return Ot(),se(new Set),pe([]),ye.current=[],void(r&&requestAnimationFrame(function(){var n=c()||l;Ue({open:!0,anchorEl:n,summary:i})}));_i(e,t,r?{toggleIfSame:!1,sourceSide:u,onReady:function(){var n=c()||l;Ue({open:!0,anchorEl:n,summary:i})}}:{toggleIfSame:!1,sourceSide:u})},[_i,Ze,Ue,Ot]),Fi=c(function(){var n,e=Ye.sectionIdx,t=Ye.isOrphan;if($e(),null!=e){var i="left";Ye.anchorEl&&(null===(n=De.current)||void 0===n?void 0:n.contains(Ye.anchorEl))&&(i="right"),_i(e,t,{sourceSide:i})}},[_i,Ye.isOrphan,Ye.sectionIdx,Ye.anchorEl,$e]),Di=c(function(){$e(),Ot(),se(new Set),pe([]),ye.current=[]},[$e,Ot]),Mi=null!==Ye.sectionIdx&&ae.has(Ye.sectionIdx),Ai=z({proposedSections:st,existingSections:vt,parentDeviationRecord:pt,expandedSections:Yt,maintainRelativeOrder:!!Hn,scrollContainerRef:Ee,leftContainerRef:je,lhsBadgeRefs:Ct,rhsBadgeRefs:wt}),Ni=Ai.showDeviationNavigation,ki=Ai.showOpenNodeRef,ji=l(function(){var n;if(!Nn)return null;var e=null===(n=null==Nn?void 0:Nn.id)||void 0===n?void 0:n.split(":")[0];for(var t in pt){if((pt[t]||[]).some(function(n){return n.id===e}))return t}return null},[Nn,pt]),Hi=r({id:null,triggerMs:null}),Li=r(null);u(function(){var t;if(null==Nn?void 0:Nn.id){var i=Number(Nn.trigger),o=Hi.current;if((null==o?void 0:o.triggerMs)!==i){var r=null===(t=null==Nn?void 0:Nn.id)||void 0===t?void 0:t.split(":"),l=r[0],u=r[1],c=null!=u?u:"0";Li.current!==Nn.id&&($e(),Ze(),Ot(),se(new Set),pe([]),ye.current=[],Li.current=Nn.id);var d=!1,a=0,s=null,v=150,f=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},p=function(){var t,o,r,u;if(!d){var g=function(){Hi.current={id:Nn.id,triggerMs:i}},h=null,x=null;for(var m in pt){var y=pt[m].find(function(n){return n.id===l});if(y){h=m,x=y;break}}if(x&&h){var b=st.findIndex(function(n){return n.id===h}),R=vt.findIndex(function(n){return n.id===h}),C=-1===b&&-1!==R,w=f(st,x.id),B=f(vt,x.id);if(w&&!B&&!C){var I=w.split("-"),T=Number(I[0]);if(Hn){var _=null===(o=null===(t=st[T])||void 0===t?void 0:t.refIndexes)||void 0===o?void 0:o[0],E=vt.findIndex(function(n){return n.selfIndex===_});-1!==E&&(T=E)}B=e([T],I.slice(1),!0).join("-")}if(w||B){var F=C||!w&&!!B,D=w?Number(w.split("-")[0]):b,M=B?Number(B.split("-")[0]):R;if(F){if(!(Hn?!!Yt["right-".concat(M)]:!!Yt[String(M)])&&M>=0)return Xt(M,"right"),a+=1,void(s=setTimeout(p,450))}else if(!(Hn?!!Yt["left-".concat(D)]:!!Yt[String(D)])&&D>=0)return Xt(D,"left"),a+=1,void(s=setTimeout(p,450));var A,N=w||"",k=B||"",j="".concat(x.id).concat(S).concat(c).concat(S).concat(N).concat(S).concat(k),H="".concat(x.id).concat(S).concat(c),L=null===(r=Ct.current[H])||void 0===r?void 0:r.current,O=null===(u=wt.current[H])||void 0===u?void 0:u.current,P=F||!L&&!!O,z=P?O:L;if(A=Hn?P?De.current:je.current:Ee.current,z&&A){var W=z.getBoundingClientRect();if(0===W.height)return void((a+=1)<2?s=setTimeout(p,v):g());var Y=A.getBoundingClientRect(),q=W.top-Y.top+A.scrollTop-Y.height/2+W.height/2,K=function(){var e,t,i,o,r;if(!d){g();var l=window.getComputedStyle(z).color;L&&(L.style.transition="box-shadow 300ms ease-in-out",L.style.boxShadow="0 0 10px ".concat(l)),O&&(O.style.transition="box-shadow 300ms ease-in-out",O.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){L&&(L.style.boxShadow=""),O&&(O.style.boxShadow="")},2e3);var u=(null===(t=null===(e=x.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[c])||x,a=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!L&&!!O)){var s=P?(null===(o=wt.current[H])||void 0===o?void 0:o.current)||O:(null===(r=Ct.current[H])||void 0===r?void 0:r.current)||L;return Ue({open:!0,anchorEl:s,summary:n(n({},u),{evaluation_outputs:a})}),void(null==kn||kn())}_i(j,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,t=(null===(e=Ct.current[H])||void 0===e?void 0:e.current)||L;Ue({open:!0,anchorEl:t,summary:n(n({},u),{evaluation_outputs:a})})}})}};Math.abs(A.scrollTop-q)<=2?K():(Le.current=q,Oe.current=K,A.scrollTo({top:q,behavior:"smooth"}),s&&clearTimeout(s),s=setTimeout(function(){if(Oe.current){Le.current=null;var n=Oe.current;Oe.current=null,n()}},800))}else(a+=1)<2?s=setTimeout(p,v):g()}else(a+=1)<2?s=setTimeout(p,v):g()}else(a+=1)<2?s=setTimeout(p,v):g()}};return s=setTimeout(p,v),function(){d=!0,s&&clearTimeout(s)}}}},[Nn,pt,st,vt,Hn,Yt,Xt,_i,Ue]);var Oi=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(q,{section:e,keyPath:t,depth:r,columnKey:u,parentNodeId:void 0===c?"":c,expandedSubSections:Kt,setExpandedSubSections:Vt,maintainRelativeOrder:Hn||!1,proposedSections:st,existingSections:vt,treeData:Cn,deviationNumberRegistry:gt,connectedSections:ae,activeSideBySideSection:le,resolvedMarkdownStyles:_e,getSubSectionRef:Ft,getSubSectionCompareStyle:fi,getBadgeRef:Dt,openMoreFunctionsPopup:$t,openSummaryPopup:Ei,showDeviationBadges:On,resetSideBySide:Ot,setConnectedSections:se,setConnectedLines:pe,cachedConnectedPositions:ye})};return t(d,n({ref:Fe,sx:n(n({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},Hn?{}:{overflow:"visible"}),{position:"relative"})},{children:[zn&&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,{})})),Je.open&&i(K,{open:Je.open,anchorEl:Je.anchorEl,containerEl:ni.current,clipTopEl:ii.current,scrollContainerEl:Ee.current,onClose:Di,summary:Je.summary}),i(N,{open:Ye.open,anchorEl:Ye.anchorEl,sectionTitle:Ye.sectionTitle,referenceSectionTitle:Ye.refSectionTitle,onClose:nt,onOpenCognitiveCompare:Gt,onOpenSideBySide:Fi,onConnect:Qt,isConnected:Mi,isOrphan:Ye.isOrphan}),ze.open&&i(A,{open:ze.open,popupRef:Qe,position:Ke,popupConfig:Dn,onClose:function(){Ve(null),We(function(e){return n(n({},e),{open:!1})}),Ge(null)},markdownStyles:Tn,sectionTitle:ze.sectionTitle,referenceSectionTitle:ze.refSectionTitle,cognitiveData:ze.cognitiveData,anchorEl:ze.anchorEl,sectionAnchorEl:ze.sectionAnchorEl,scrollContainerEl:Ee.current,badgeStyle:ze.badgeStyle,docData:ze.docData,deviationData:ze.deviationData,isLoading:ze.isLoading}),i(a,n({open:!!Xn,autoHideDuration:8e3,onClose:function(){return Jn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,n({onClose:function(){return Jn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Xn}))})),i(W,{componentHeaderText:Rn,displayConfig:Fn,maintainRelativeOrder:Hn,onCollapseAll:gi,showCollapseAll:hi,onToggleView:function(n){Wn(!0),setTimeout(function(){Ln(!n),Ot(),$e(),se(new Set),pe([]),ye.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Wn(!1)},600)})})},50)}}),i(d,n({ref:Ee,onScroll:Ci,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Hn?"hidden":"auto",borderTop:At&&Nt?"none":"1.5px solid #EEF0F4"}},{children:i(d,n({sx:n({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Hn?{flex:1,minHeight:0}:{})},{children:t(d,n({ref:Zt,sx:n({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Hn?{flex:1,overflow:"visible"}:{})},{children:[t("svg",n({ref:ge,style:{position:"absolute",top:0,left:0,width:Ie.width||"100%",height:Ie.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:ie?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[di&&i("g",{children:i("line",{x1:di.x1,y1:di.y,x2:di.x2,y2:di.y,stroke:Lt.badgeBorder,strokeWidth:"1.5"})}),li.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?$n&&le===e.subSectionKeyPath&&ne:$n&&le===e.sectionIdx&&ne)return null;if(!Hn){var f=e.isSubSection?B(e.x1,e.y1,e.x2,e.y2):"M ".concat(e.x1," ").concat(e.y1," L ").concat(e.x2," ").concat(e.y2),g=st[e.sectionIdx]||{title:"",content:""},x=vt[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),C=b.split("-").map(Number),w=null,I=null;R.length>0&&(w=st[R[0]]),C.length>0&&(I=vt[C[0]]);var T=(null==w?void 0:w.title)||"",_=(null==I?void 0:I.title)||"";console.log("Root Parent Titles:",T,_);for(var E=1;E<R.length;E++)(null==w?void 0:w.subsections)&&(w=w.subsections[R[E]]);for(E=1;E<C.length;E++)(null==I?void 0:I.subsections)&&(I=I.subsections[C[E]]);w&&(g=n(n({},w),{title:T||w.title})),console.log("Base Section for Subsection Badge:",g),I&&(x=n(n({},I),{title:_||I.title})),console.log("Ref Section for Subsection Badge:",x)}var F=!(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),M=(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=F||M;return t("g",{children:[i("path",{d:f,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&&(ze.open&&Xe===e.id?Ze():(Ge(e.id),Ut(Jt(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===D&&null==e.style.label?i(j,{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(p,{size:11,style:{transform:ze.open&&Xe===e.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},e.id)}return null}),i(V,{connectedLines:fe,pathRefs:me})]})),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)"},Hn?{flex:1,overflow:"visible"}:{})},{children:[i(d,n({ref:ii,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:lt,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:lt}))}))})),t(d,n({ref:je,onScroll:Ci,sx:n({p:"12px",display:"flex",flexDirection:"column"},Hn?{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:Ne,style:{width:"100%",height:"0px",flexShrink:0}}),xt&&st.map(function(e,o){var r,l,u=!e.title&&!e.content;if(Hn&&u)return null;var c=e,a=vi(o,"left"),s=Hn?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!vt[o],v=Hn?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:o+1,f=ae.has(o),p=y(c.evaluationResult,null==a?void 0:a.deviationLabel);return i(d,n({ref:Et(o),sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:St.current[o],sx:n({width:"100%",display:"flex"},f&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(Y,{section:e,idx:o,columnKey:"left",colRef:Et("left-accordion-".concat(o)),mb:0,treeData:Cn,proposedSections:st,existingSections:vt,deviationNumberRegistry:gt,getSectionCompareStyle:vi,getBadgeRef:Dt,connectedSections:ae,openMoreFunctionsPopup:$t,openSummaryPopup:Ei,deviationNodeIdToView:null==Nn?void 0:Nn.id,deviationTargetParentId:ji,parentNodeId:(null===(l=null==Cn?void 0:Cn.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:Hn?!!Yt["left-".concat(o)]:!!Yt[String(o)],onToggle:function(){Di(),Xt(o,"left")},navigation:e.id?Ni[e.id]:null,showOpenNodeRef:ki,resolvedMarkdownStyles:_e,maintainRelativeOrder:Hn,showDeviationBadges:On,renderSubSections:Oi})})),Hn&&a&&t(d,n({ref:Ct.current[o],onClick:function(n){var t=Hn?vt.find(function(n){var e;return null===(e=c.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)})||{title:"",content:""}:vt[o]||{title:"",content:""};$t(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:!Fn.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?s?"No Deviation Found":"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p):i(j,{color:a.badgeText})})),i(g,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))}),i("div",{ref:ke,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,n({ref:ni,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(),ze.open&&Xe===kt?Ze():(Ge(kt),Ut(Jt(e.currentTarget,{title:"",content:"",evaluationResult:jt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,kt,!0,n(n({},Lt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Lt.badgeBg,color:Lt.badgeText,border:"1px solid ".concat(Lt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Ht?Ht:i(j,{}),i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(p,{size:11,style:{transform:ze.open&&Xe===kt?"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},Hn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[qn&&i(x,{sections:11}),i(d,n({ref:oi,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:ut,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ut}))}))})),t(d,n({ref:De,onScroll:Ci,sx:n({p:"12px",display:"flex",flexDirection:"column"},Hn?{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:Me,style:{width:"100%",height:"0px",flexShrink:0}}),xt&&vt.map(function(e,o){var r,l=e,u=[],c=!1,a=null,s=-1;if(Hn){u=st.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=st.findIndex(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(l.selfIndex))&&n.selfIndex>=0});var v=st.findIndex(function(n,e){var t;return ae.has(e)&&(null===(t=n.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==v)&&(a=vi(v))}else u=[o+1],(c=ae.has(o))&&(a=vi(o));var f=vi(Hn&&-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:Rt.current[o],sx:n({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:i(Y,{section:e,idx:o,columnKey:"right",colRef:Et("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==Cn?void 0:Cn.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:Hn?!!Yt["right-".concat(o)]:!!Yt[String(o)],treeData:Cn,proposedSections:st,existingSections:vt,deviationNumberRegistry:gt,getBadgeRef:Dt,getSectionCompareStyle:vi,connectedSections:ae,openMoreFunctionsPopup:$t,openSummaryPopup:Ei,deviationNodeIdToView:null==Nn?void 0:Nn.id,deviationTargetParentId:ji,onToggle:function(){Di(),Xt(o,"right")},navigation:e.id?Ni[e.id]:null,showOpenNodeRef:ki,resolvedMarkdownStyles:_e,maintainRelativeOrder:Hn,showDeviationBadges:On,renderSubSections:Oi})})),Hn&&f&&i(d,n({ref:wt.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:f.badgeBg,color:f.badgeText,border:"1px solid ".concat(f.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:Ae,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{X 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 f}from"@mui/material";import{ChevronDown as p,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,findKeyPathByNodeId as R,getFirstDeviationOutputValue as C,getFirstDeviationColor as I,hasValue as w,getBentArrowPath as B,smoothScrollTo as T,resetClauseHighlight as _,scrollAndHighlightClause as E}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as F,DEFAULT_FIELD_CONFIG as D,DEFAULT_COMPARISON_CONFIG as A}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{EMPTY_SUMMARY_POPUP_STATE as M,DEFAULT_DEVIAION_COLOR as N,DEFAULT_COMPONENT_HEADER_TEXT as k}from"./CognitiveCompareConstants.js";import H from"./CognitivePopup.js";import j from"./MoreFunctionsPopup.js";import L from"./LoaderComponent.js";import P from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as O}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as q}from"./hooks/useAccordionState.js";import{useDeviationNavigation as Y}from"./hooks/useDeviationNavigation.js";import K from"./components/CompareHeader.js";import V from"./components/SectionAccordion.js";import X from"./components/SubSectionAccordion.js";import $ from"./components/CognitiveSummaryPopup.js";import G from"./components/connectedLines.js";var J=function(J){var U,Q,Z,nn,en,tn,on,rn,ln,un,cn,dn,an,sn,vn,fn,pn,gn,hn,xn,mn,yn,bn,Sn,Rn,Cn,In=J.componentHeaderText,wn=void 0===In?k:In,Bn=J.treeData,Tn=J.comparisonConfig,_n=J.leftColumnTitleText,En=J.rightColumnTitleText,Fn=J.markdownStyles,Dn=J.resetTrigger,An=J.displayConfig,Mn=void 0===An?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!0}:An,Nn=J.popupConfig,kn=J.deviationData,Hn=void 0===kn?{}:kn,jn=J.deviationNodeIdToView,Ln=J.resetDeviationNodeId,Pn=o(Mn.maintainRelativeOrder),On=Pn[0],zn=Pn[1],Wn=!!On||!!(null==Mn?void 0:Mn.showDeviationBadges),qn=o(!1),Yn=qn[0],Kn=qn[1],Vn=o(!1),Xn=Vn[0],$n=Vn[1],Gn=o(null),Jn=Gn[0],Un=Gn[1],Qn=o(!1),Zn=Qn[0],ne=Qn[1],ee=o(null===(Q=null!==(U=null==Bn?void 0:Bn.newEvaluationResult)&&void 0!==U?U:null==Mn?void 0:Mn.enableDeviationSchemaBackwardCompatibility)||void 0===Q||Q)[0],te=o(!1),ie=te[0],oe=te[1],re=o(!1),le=re[0],ue=re[1],ce=o(null),de=ce[0],ae=ce[1],se=r(!1),ve=o(new Set),fe=ve[0],pe=ve[1],ge=o([]),he=ge[0],xe=ge[1],me=r(null),ye=r(null),be=r(new Set),Se=r(!1),Re=r(null),Ce=r({}),Ie=r([]),we=r(!1),Be=r(!1),Te=r(null),_e=r(function(){}),Ee=l(function(){return(null==Bn?void 0:Bn.cognitive_decisioning)||{}},[Bn]),Fe=o({width:0,height:0}),De=Fe[0],Ae=Fe[1],Me=l(function(){return n(n({},F),Fn)},[Fn]),Ne=r(null),ke=r(null),He=r(null),je=r(null),Le=r(null),Pe=r(null),Oe=r(null),ze=r(null),We=r(!1),qe=r(null),Ye=r(null),Ke=z(Ne),Ve=Ke.cognitivePopup,Xe=Ke.setCognitivePopup,$e=Ke.moreFunctions,Ge=Ke.setMoreFunctions,Je=Ke.position,Ue=Ke.setPosition,Qe=Ke.activeBadgeId,Ze=Ke.summaryPopup,nt=Ke.setSummaryPopup,et=Ke.closeSummaryPopup,tt=Ke.setActiveBadgeId,it=Ke.popupRef,ot=Ke.closeCognitivePopup,rt=Ke.closeMoreFunctionsPopup,lt=l(function(){var n,e,t,i,o,r,l;return{fields:null!==(n=null==Tn?void 0:Tn.fields)&&void 0!==n?n:D,thresholds:{high:null!==(t=null===(e=null==Tn?void 0:Tn.thresholds)||void 0===e?void 0:e.high)&&void 0!==t?t:A.thresholds.high,medium:null!==(o=null===(i=null==Tn?void 0:Tn.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:A.thresholds.medium,exact:null!==(l=null===(r=null==Tn?void 0:Tn.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:A.thresholds.exact}}},[Tn]),ut=o(null),ct=ut[0];ut[1];var dt=null===(en=null===(Z=null==Bn?void 0:Bn.documents)||void 0===Z?void 0:Z[null===(nn=null==Bn?void 0:Bn.input_index_map)||void 0===nn?void 0:nn[0]])||void 0===en?void 0:en.title,at=null===(rn=null===(tn=null==Bn?void 0:Bn.documents)||void 0===tn?void 0:tn[null===(on=null==Bn?void 0:Bn.input_index_map)||void 0===on?void 0:on[1]])||void 0===rn?void 0:rn.title,st=m(_n||dt||"Uploaded Contract"),vt=m(En||at||"Reference Template"),ft=O(Bn,On,Hn,lt,ee),pt=ft.activeProposed,gt=ft.existingRule,ht=ft.proposedSections,xt=ft.existingSections,mt=ft.visibleFields,yt=ft.parentDeviationRecord,bt=ft.deviationNumberRegistry,St=ft.parseError;u(function(){St&&Un("Failed to load comparison: ".concat(St))},[St]);var Rt=ht.length>0||xt.length>0,Ct=W(mt.map(function(n){return n.key}),Math.max(ht.length,xt.length)),It=Ct.leftRefs,wt=Ct.rightRefs,Bt=Ct.sectionLeftRefs,Tt=Ct.sectionRightRefs,_t=Ct.lhsBadgeRefs,Et=Ct.rhsBadgeRefs,Ft=Ct.sectionRightRowRefs,Dt=Ct.subSectionLeftRefs,At=Ct.subSectionRightRefs,Mt=Ct.sectionRowRefs,Nt=Ct.getSectionRowRef,kt=Ct.getSubSectionRef,Ht=Ct.getBadgeRef,jt=gt.analysis,Lt=m(null===(un=null===(ln=null==jt?void 0:jt.rule_difference_comparison)||void 0===ln?void 0:ln.summary)||void 0===un?void 0:un.overall_summary),Pt=!!Lt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Ot=null!==(cn=null==Bn?void 0:Bn.base_root_id)&&void 0!==cn?cn:"-1";null==Bn||Bn[Ot];var zt=ee?null!==(bn=null!==(xn=Hn&&(null===(hn=null==Hn?void 0:Hn[Ot])||void 0===hn?void 0:hn.evaluation_result))&&void 0!==xn?xn:null===(yn=null===(mn=null==Bn?void 0:Bn.nodes)||void 0===mn?void 0:mn[Ot])||void 0===yn?void 0:yn.evaluation_result)&&void 0!==bn?bn:null:null!==(gn=null!==(sn=Hn&&(null===(an=null===(dn=null==Hn?void 0:Hn[Ot])||void 0===dn?void 0:dn.evaluation_result)||void 0===an?void 0:an[0]))&&void 0!==sn?sn:null===(pn=null===(fn=null===(vn=null==Bn?void 0:Bn.nodes)||void 0===vn?void 0:vn[Ot])||void 0===fn?void 0:fn.evaluation_result)||void 0===pn?void 0:pn[0])&&void 0!==gn?gn:null,Wt=y(zt),qt=b(null!==(Cn=null===(Rn=null===(Sn=null==zt?void 0:zt.evaluation_outputs)||void 0===Sn?void 0:Sn.metadata)||void 0===Rn?void 0:Rn.label_color)&&void 0!==Cn?Cn:""),Yt=function(){be.current.forEach(function(n){_(n)}),be.current.clear()},Kt=c(function(){var n,e,t,i,o,r;Yt(),ne(!1),Be.current=!1;var l=Te.current,u=ai.current;if(null!==l)if("string"==typeof l&&l.includes(S)){var c=l.split(S);(d=(null===(n=Dt.current[c[2]])||void 0===n?void 0:n.current)||(null===(e=Bt.current[Number(c[2])])||void 0===e?void 0:e.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(t=Bt.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=At.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=Tt.current[Number(c[3])])||void 0===o?void 0:o.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(r=Tt.current[u])||void 0===r?void 0:r.current)&&(a.style.paddingTop="0px")}ae(null),Te.current=null,ai.current=null,oe(!1),$n(!1),je.current&&(je.current.style.height="0px"),Le.current&&(Le.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),Oe.current&&(Oe.current.style.height="0px")},[]),Vt=c(function(){Yt(),Kt(),pe(new Set),xe([]),Ie.current=[],hi([]),yi(null),nt(M),ot(),requestAnimationFrame(function(){var n;null===(n=_e.current)||void 0===n||n.call(_e)})},[]),Xt=r(Vt);u(function(){Xt.current=Vt},[Vt]),u(function(){Dn&&Xt.current()},[Dn]);var $t=q({maintainRelativeOrder:!!On,proposedSections:ht,existingSections:xt,activeSideBySideSection:de,connectedSections:fe,resetSideBySide:Kt,setConnectedSections:pe,setConnectedLines:xe,cachedConnectedPositions:Ie,svgContainerRef:me,isAnimatingRef:Se,animationTimerRef:Re,calculateLinesRef:_e,sectionLeftRefs:Bt,sectionRightRefs:Tt,subSectionLeftRefs:Dt,subSectionRightRefs:At}),Gt=$t.expandedSections,Jt=$t.setExpandedSections,Ut=$t.expandedSubSections,Qt=$t.setExpandedSubSections,Zt=$t.toggleSection,ni=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?Ee[s]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:s,decisioning:[],gap:[],relevance_score:0},f=null!==(d=null===(c=Mt.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null;return{isLoading:null!==(a=null==Mn?void 0:Mn.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:f,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==Bn?void 0:Bn.documents,input_index_map:null==Bn?void 0:Bn.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}},[Ee,Bn]),ei=c(function(n){rt(),Ue(null),Xe(n)},[rt]),ti=function(n,e,t,i,o,r){var l;if(n.stopPropagation(),$e.open&&$e.sectionIdx===o)rt();else{var u=n.currentTarget,c="left";(null===(l=He.current)||void 0===l?void 0:l.contains(u))&&(c="right");Yt(),Be.current&&Kt(),pe(new Set),xe([]),Ie.current=[],ot(),Ze.open?Oi():et(),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=Et.current[l])||void 0===n?void 0:n.current:null===(e=_t.current[l])||void 0===e?void 0:e.current}return"right"===c?null===(t=Et.current[o])||void 0===t?void 0:t.current:null===(i=_t.current[o])||void 0===i?void 0:i.current}()||u;Ge(ni(n,e,i,o,t,r))})}},ii=c(function(){null!==$e.sectionIdx&&$e.anchorEl?ei(n(n({},$e),{open:!0})):rt()},[$e,rt,ei]),oi=c(function(){var n=$e.sectionIdx,e=$e.isOrphan;rt(),et(),null!==n&&(e?Un("No counterpart exists to connect to."):(Yt(),Be.current&&Kt(),xe([]),Ie.current=[],pe(function(e){return e.has(n)?new Set:new Set([n])}),setTimeout(function(){_e.current&&_e.current()},50)))},[$e.sectionIdx,$e.isOrphan,rt,et,Kt]),ri=c(function(){var n=ye.current;if(n){ye.current=null;var e=ht.findIndex(function(e){return e.id===n}),t=xt.findIndex(function(e){return e.id===n}),i=-1===e?R(ht,n):null,o=-1===t?R(xt,n):null,r=-1!==e?e:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=function(n,e,t,i){var o,r,l,u;return-1!==n?null!==(r=null===(o=t.current[n])||void 0===o?void 0:o.current)&&void 0!==r?r:null:e&&null!==(u=null===(l=i.current[e])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(n,e,t){void 0===t&&(t=30);var i=0,o=function(){var r=n();r&&0!==r.getBoundingClientRect().height?(be.current.add(r),E(r,e)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(On)-1!==r&&ze.current&&c(function(){return u(e,i,Bt,Dt)},ze.current),-1!==l&&He.current&&c(function(){return u(t,o,Tt,At)},He.current);else{var d=Ne.current;if(!d)return;c(function(){return-1!==r?u(e,i,Bt,Dt):u(t,o,Tt,At)},d)}}},[ht,xt,On,Bt,Tt,Dt,At,ze,He,Ne]),li=c(function(e){if(e){Yt(),Kt(),pe(new Set),xe([]),Ie.current=[],et(),ot();var t=ht.findIndex(function(n){return n.id===e}),i=xt.findIndex(function(n){return n.id===e}),o=-1===t?R(ht,e):null,r=-1===i?R(xt,e):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=-1!==i?i:r?Number(r.split("-")[0]):-1;ye.current=e,Jt(function(e){var t,i=n({},e),o=!1;-1!==l&&(i[t=On?"left-".concat(l):String(l)]||(i[t]=!0,o=!0));-1!==u&&(i[t=On?"right-".concat(u):String(u)]||(i[t]=!0,o=!0));return o?i:e}),Qt(function(e){var t=n({},e),i=!1,l=function(n){for(var e=n.split("-"),o=e[0],r=1;r<e.length;r++)o+="-".concat(e[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:e}),setTimeout(function(){requestAnimationFrame(function(){ye.current===e&&ui.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(e,'" not found'))}},[ht,xt,On,Jt,Qt,Kt,et,ot]),ui=r(ri);u(function(){ui.current=ri},[ri]);var ci=r(null),di=r(null),ai=r(null),si=r(null),vi=r(null),fi=r(null),pi=o([]),gi=pi[0],hi=pi[1];r(null);var xi=o(null),mi=xi[0],yi=xi[1];u(function(){if(ct){var n=lt.fields.find(function(n){return n.analysisKey===ct||n.key===ct});if(n){var e=It.current[n.key]||wt.current[n.key];(null==e?void 0:e.current)&&setTimeout(function(){return e.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[ct,lt.fields]);var bi=c(function(n){var e,t,i,o,r,l,u,c,d,a=null===(e=null==jt?void 0:jt.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 f=s.mappings[0]||{};return{score:s.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: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}},[jt]),Si=c(function(e,t){var i,o,r;void 0===t&&(t="left");var l=null,u=null;if("left"===t)if(l=ht[e],On&&l){var c=xt.filter(function(n){var e;return null===(e=l.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});u=c.find(function(n){return n.evaluationResult})||c[0]}else u=xt[e];else if(u=xt[e],On&&u){var d=ht.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(u.selfIndex)});l=d.find(function(n){return n.evaluationResult})||d[0]}else l=ht[e];var a=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,s=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,v=!(!(null==l?void 0:l.cognitiveData)&&!(null==u?void 0:u.cognitiveData));if(!a&&!s&&!v)return n(n({},b(N)),{label:"Not Defined"});var f=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==u?void 0:u.evaluationResult)&&void 0!==o?o:null,p=C(f),g=I(f);return n(n({},b(g)),null!=f?{label:null!==(r=p)&&void 0!==r?r:""}:{label:null})},[ht,xt,Ee,lt,On]),Ri=c(function(e){for(var t,i,o,r,l,u=e.split("-").map(Number),c=ht[u[0]],d=xt[u[0]],a=1;a<u.length;a++)(null==c?void 0:c.subsections)&&(c=c.subsections[u[a]]),(null==d?void 0:d.subsections)&&(d=d.subsections[u[a]]);if(!c&&!d)return null;var s=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,v=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,f=m(null==c?void 0:c.id)||m(null==d?void 0:d.id)||"",p=!(!(null==c?void 0:c.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!s&&!v&&!p)return n(n({},b(N)),{label:"Not Defined"});null!==(i=null!==(t=null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||f&&(null===(o=Ee[f])||void 0===o||o.relevance_score);var g=null!==(l=null!==(r=null==c?void 0:c.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,h=C(g),x=I(g);return n(n({},b(x)),null!=g?{label:null!=h?h:""}:{label:null})},[ht,xt,Ee,lt]),Ci=c(function(e,t){var i,o,r,l,u,c,d,a,s,v,f,p,g,h,x,m,y;if(!e||null==t)return null;var S=null!==(d=null!==(u=null!==(o=null===(i=null==Hn?void 0:Hn[e])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==Bn?void 0:Bn.nodes)||void 0===r?void 0:r[e])||void 0===l?void 0:l.evaluation_result)&&void 0!==u?u:null===(c=null==Bn?void 0:Bn[e])||void 0===c?void 0:c.evaluation_result)&&void 0!==d?d:null;if(!S||"object"!=typeof S)return null;var R=null!==(f=null!==(s=null===(a=null==S?void 0:S.deviations)||void 0===a?void 0:a[t])&&void 0!==s?s:null===(v=null==S?void 0:S.deviation_entries)||void 0===v?void 0:v[t])&&void 0!==f?f:null==S?void 0:S[t],C=null!==(y=null!==(h=null===(g=null===(p=null==R?void 0:R.evaluation_outputs)||void 0===p?void 0:p.metadata)||void 0===g?void 0:g.label_color)&&void 0!==h?h:null===(m=null===(x=null==S?void 0:S.evaluation_outputs)||void 0===x?void 0:x.metadata)||void 0===m?void 0:m.label_color)&&void 0!==y?y:N;return n(n({},b(C)),{label:null})},[Hn,Bn]),Ii=c(function(){Yt(),Jt({}),Qt({}),Kt(),pe(new Set),xe([]),Ie.current=[],et(),ot(),rt(),requestAnimationFrame(function(){_e.current&&_e.current()})},[Jt,Qt,Kt,et,ot,rt]),wi=l(function(){return Object.values(Gt).some(Boolean)||Object.values(Ut).some(Boolean)},[Gt,Ut]),Bi=c(function(){var n,e,t,i,o,r,l,u,c,d,a,s,v,f,p,g,h,x,m,y,b,R,C;if(!We.current&&!Se.current){We.current=!0;try{if(!ci.current)return;var I=function(n){var e=n.split("-"),t=e[0];if(!Gt[t]&&!1===On)return!1;if(On&&!Gt["left-".concat(t)]&&!Gt["right-".concat(t)]&&!Gt[t])return!1;for(var i=t,o=1;o<e.length-1;o++)if(i+="-".concat(e[o]),!Ut[i])return!1;return!0},T=ci.current.getBoundingClientRect();Ae({width:T.width,height:T.height});var _=[];if(mt.forEach(function(n){var e,t,i=n.key,o=null===(e=It.current[i])||void 0===e?void 0:e.current,r=null===(t=wt.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 E=0;E<Math.max(ht.length,xt.length);E++){var F=null===(n=Bt.current[E])||void 0===n?void 0:n.current,D=null===(e=Tt.current[E])||void 0===e?void 0:e.current;F&&(F.style.height="auto",F.style.minHeight="0px"),D&&(D.style.height="auto",D.style.minHeight="0px")}On||Object.keys(Dt.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=Dt.current[n])||void 0===e?void 0:e.current,o=null===(t=At.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 A={};mt.forEach(function(n){var e,t,i=n.key,o=null===(e=It.current[i])||void 0===e?void 0:e.current,r=null===(t=wt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();A[i]=Math.max(l.height,u.height)}});var M={left:{},right:{}},N={};if(!Se.current)if(On){if(Zn&&null!==de)if("number"==typeof de){var k=de,H=ht[k],j=null===(o=Bt.current[k])||void 0===o?void 0:o.current;j&&H&&(H.refIndexes||[]).forEach(function(n){var e,t=xt.findIndex(function(e){return e.selfIndex===n}),i=null===(e=Tt.current[t])||void 0===e?void 0:e.current;if(i&&(Gt["left-".concat(k)]||Gt["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);M.left[k]=Math.max(M.left[k]||0,o),M.right[t]=Math.max(M.right[t]||0,o)}})}else{var L=de.split(S)[2];if(L){F=null===(r=Dt.current[L])||void 0===r?void 0:r.current,D=null===(l=At.current[L])||void 0===l?void 0:l.current;if(F&&D){P=Math.max(F.getBoundingClientRect().height,D.getBoundingClientRect().height);N[L]=Math.max(N[L]||0,P)}}}}else{Object.keys(Dt.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=Dt.current[n])||void 0===e?void 0:e.current,o=null===(t=At.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);N[n]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(E=0;E<Math.min(ht.length,xt.length);E++){var F=null===(t=Bt.current[E])||void 0===t?void 0:t.current,D=null===(i=Tt.current[E])||void 0===i?void 0:i.current;if(F&&D){var P=Math.max(F.getBoundingClientRect().height,D.getBoundingClientRect().height);M.left[E]=P,M.right[E]=P}}}if(mt.forEach(function(n){var e,t,i=n.key,o=null===(e=It.current[i])||void 0===e?void 0:e.current,r=null===(t=wt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=A[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Se.current||(Object.entries(M.left).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=Bt.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(M.right).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=Tt.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),On||Object.keys(N).forEach(function(n){var e,t,i=null===(e=Dt.current[n])||void 0===e?void 0:e.current,o=null===(t=At.current[n])||void 0===t?void 0:t.current;if(i&&o&&N[n]){var r=N[n];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),On)ht.forEach(function(n,e){var t;(null===(t=Bt.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=xt.findIndex(function(e){return e.selfIndex===n});if(-1!==v){var f=null===(t=_t.current[e])||void 0===t?void 0:t.current,p=null===(i=Et.current[v])||void 0===i?void 0:i.current;if(f&&p){var g=f.getBoundingClientRect(),h=p.getBoundingClientRect(),x=g.right-T.left,m=h.left-T.left,y=g.top+g.height/2-T.top,b=h.top+h.height/2-T.top;if(Zn&&de===e){var S=null!==(r=null===(o=ze.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=He.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(d=null===(c=ze.current)||void 0===c?void 0:c.clientHeight)&&void 0!==d?d:1/0),I=R+(null!==(s=null===(a=He.current)||void 0===a?void 0:a.clientHeight)&&void 0!==s?s:1/0),w=g.top+g.height/2,B=h.top+h.height/2,E=function(n,e,t){return Math.max(e,Math.min(t,n))};y=E(w,S,C)-T.top,b=E(B,R,I)-T.top}var F=Si(e);F&&_.push({id:"line-".concat(e,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:F,sectionIdx:e,targetRightIdx:v})}}})});else{for(E=0;E<Math.min(ht.length,xt.length);E++){var O=null===(u=Bt.current[E])||void 0===u?void 0:u.current,z=null===(c=Tt.current[E])||void 0===c?void 0:c.current;if(O&&z){var W=O.getBoundingClientRect(),q=z.getBoundingClientRect(),Y=Math.max(W.top,q.top)+18-T.top,K=(null===(d=xt[E])||void 0===d?void 0:d.id)||"sec-".concat(E);(Z=Si(E))&&_.push({id:K,x1:W.right-T.left,y1:Y,x2:q.left-T.left,y2:Y,style:Z,sectionIdx:E,hasCognitive:!!((null===(a=ht[E])||void 0===a?void 0:a.cognitiveData)||(null===(s=xt[E])||void 0===s?void 0:s.cognitiveData)||K&&Ee[K]),isSubSection:!1})}}Object.keys(Dt.current).forEach(function(n){var e,t,i,o,r,l;if(I(n)){var u=null===(e=Dt.current[n])||void 0===e?void 0:e.current,c=null===(t=At.current[n])||void 0===t?void 0:t.current;if(u&&c){for(var d=n.split("-").map(Number),a=ht[d[0]],s=xt[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 f=!!a&&((null===(i=a.displayTitle)||void 0===i||i)&&w(a.title)),p=!!a&&((null===(o=a.displayContent)||void 0===o||o)&&w(a.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&w(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&w(s.content));if(f&&p||g&&h){var x=u.getBoundingClientRect(),m=c.getBoundingClientRect(),y=Math.max(x.top,m.top)+16-T.top,b=Ri(n);b&&"Not Defined"!==b.label&&_.push({id:"subsec-".concat(n),x1:x.right-T.left,y1:y,x2:m.left-T.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(Zn&&"string"==typeof de&&de.includes(S)){var V=de.split(S),X=V[0],$=V[1],G=V[2],J=(V[3],"".concat(X).concat(S).concat($)),U=null===(v=_t.current[J])||void 0===v?void 0:v.current,Q=null===(f=Et.current[J])||void 0===f?void 0:f.current;if(U&&Q){var Z,nn=U.getBoundingClientRect(),en=Q.getBoundingClientRect(),tn=nn.right-T.left,on=en.left-T.left,rn=nn.top+nn.height/2-T.top,ln=en.top+en.height/2-T.top;if(On){var un=null!==(g=null===(p=ze.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==g?g:0,cn=null!==(x=null===(h=He.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==x?x:0,dn=un+(null!==(y=null===(m=ze.current)||void 0===m?void 0:m.clientHeight)&&void 0!==y?y:1/0),an=cn+(null!==(R=null===(b=He.current)||void 0===b?void 0:b.clientHeight)&&void 0!==R?R:1/0),sn=function(n,e,t){return Math.max(e,Math.min(t,n))};rn=sn(nn.top+nn.height/2,un,dn)-T.top,ln=sn(en.top+en.height/2,cn,an)-T.top}(Z=null!==(C=Ci(X,$))&&void 0!==C?C:Ri(G))&&_.push({id:"line-subsec-".concat(J),x1:tn,y1:rn,x2:on,y2:ln,style:Z,sectionIdx:Number(G.split("-")[0]),isSubSection:!0,subSectionKeyPath:de})}}if(hi(_),vi.current&&fi.current){var vn=vi.current.getBoundingClientRect(),fn=fi.current.getBoundingClientRect(),pn=(vn.top+vn.height/2-T.top+fn.top+fn.height/2-T.top)/2;yi({x1:vn.right-T.left,x2:fn.left-T.left,y:pn})}else yi(null);if(fe.size>0){var gn=[],hn=ze.current,xn=He.current;if(hn&&xn){var mn=[],yn=hn.getBoundingClientRect().top,bn=xn.getBoundingClientRect().top,Sn=yn+hn.clientHeight,Rn=bn+xn.clientHeight,Cn=hn.scrollTop,In=xn.scrollTop,wn=T.top,Bn=function(n,e,t){return Math.max(e,Math.min(t,n))};fe.forEach(function(n){var e,t,i,o,r,l;if("string"==typeof n&&n.includes(S)){var u=n.split(S),c=u[0],d=u[1],a=u[2],s=(u[3],"".concat(c).concat(S).concat(d)),v=null===(e=_t.current[s])||void 0===e?void 0:e.current,f=null===(t=Et.current[s])||void 0===t?void 0:t.current;if(!v||!f)return;var p=v.getBoundingClientRect(),g=f.getBoundingClientRect(),h=null!==(i=Ci(c,d))&&void 0!==i?i:Ri(a),x=(H=p.right-T.left)+.5*((j=g.left-T.left-0)-H),m=p.top+p.height/2,y=g.top+g.height/2,b=m-yn+Cn,R=y-bn+In,C="conn-subsec-".concat(s);mn.push({lhsScrollY:b,rhsScrollY:R,x1:H,x2:j,containerTop:wn,leftIdx:n,rhsArrayIdx:n,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var I=Bn(m,yn,Sn),w=Bn(y,bn,Rn),_=I-wn,E=w-wn,F=y>=bn-4&&y<=Rn+4,D="";D=(L=m>=yn-4&&m<=Sn+4)&&F?B(H,_,j,E):L&&!F?"M ".concat(H,",").concat(_," L ").concat(x,",").concat(_," L ").concat(x,",").concat(E):!L&&F?"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E," L ").concat(j,",").concat(E):"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E),gn.push({id:C,pathD:D,style:h,leftIdx:n,rhsArrayIdx:n})}else if(On){var A=n,M=ht[A];if(!(null===(l=null==M?void 0:M.refIndexes)||void 0===l?void 0:l.length))return;M.refIndexes.forEach(function(n){var e,t,i=xt.findIndex(function(e){return e.selfIndex===n});if(-1!==i){var o=null===(e=_t.current[A])||void 0===e?void 0:e.current,r=null===(t=Et.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=Si(A),d=l.right-T.left,a=u.left-T.left-0,s=d+.5*(a-d),v=l.top+l.height/2,f=u.top+u.height/2,p=v-yn+Cn,g=f-bn+In,h="conn-".concat(A,"-").concat(i);mn.push({lhsScrollY:p,rhsScrollY:g,x1:d,x2:a,containerTop:wn,leftIdx:A,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var x=Bn(v,yn,Sn),m=Bn(f,bn,Rn),y=x-wn,b=m-wn,S=v>=yn-4&&v<=Sn+4,R=f>=bn-4&&f<=Rn+4,C="";C=S&&R?B(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),gn.push({id:h,pathD:C,style:c,leftIdx:A,rhsArrayIdx:i})}}})}else{var N=n,k=N;v=null===(o=_t.current[N])||void 0===o?void 0:o.current,f=null===(r=Et.current[k])||void 0===r?void 0:r.current;if(!v||!f)return;var H,j;p=v.getBoundingClientRect(),g=f.getBoundingClientRect(),h=Si(N),x=(H=p.right-T.left)+.5*((j=g.left-T.left-0)-H),m=p.top+p.height/2,y=g.top+g.height/2,b=m-yn+Cn,R=y-bn+In,C="conn-".concat(N,"-").concat(k);mn.push({lhsScrollY:b,rhsScrollY:R,x1:H,x2:j,containerTop:wn,leftIdx:N,rhsArrayIdx:k,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var L;I=Bn(m,yn,Sn),w=Bn(y,bn,Rn),_=I-wn,E=w-wn,F=y>=bn-4&&y<=Rn+4,D="";D=(L=m>=yn-4&&m<=Sn+4)&&F?B(H,_,j,E):L&&!F?"M ".concat(H,",").concat(_," L ").concat(x,",").concat(_," L ").concat(x,",").concat(E):!L&&F?"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E," L ").concat(j,",").concat(E):"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E),gn.push({id:C,pathD:D,style:h,leftIdx:N,rhsArrayIdx:k})}}),Ie.current=mn}xe(gn)}else xe([]),Ie.current=[]}catch(n){console.error("Line render safe fail: ",n)}finally{We.current=!1}}},[mt,ht,xt,Ee,lt,bi,Si,Ci,On,Zn,de,fe,Gt,Ut]),Ti=c(function(){var n,e,t,i,o,r,l,u,c,d,a,s,v,f,p=Ie.current;if(p.length&&!Se.current){var g=null!==(e=null===(n=ze.current)||void 0===n?void 0:n.scrollTop)&&void 0!==e?e:0,h=null!==(i=null===(t=He.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=ze.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(u=null===(l=He.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(d=null===(c=ze.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==d?d:0,b=null!==(s=null===(a=He.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,R=b+m,C=null!==(f=null===(v=ci.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,I=function(n,e,t){return Math.max(e,Math.min(t,n))};p.forEach(function(n){var e=n.lhsScrollY-g+y,t=n.rhsScrollY-h+b,i=Ce.current[n.styleId+"-stroke"],o=Ce.current[n.styleId+"-bg"];if(i||o){var r,l=I(e,y,S),u=I(t,b,R),c=l-C,d=u-C,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?B(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(){_e.current=Bi},[Bi]);var _i=r(null),Ei=r(null),Fi=c(function(){Ie.current.length>0&&!Se.current||(null!==_i.current&&clearTimeout(_i.current),_i.current=setTimeout(function(){_e.current(),_i.current=null},50))},[]),Di=c(function(){ue(!0),oe(!1),null!==Ei.current&&clearTimeout(Ei.current),null!==_i.current&&(clearTimeout(_i.current),_i.current=null),Ei.current=setTimeout(function(){var n,e,t,i,o,r,l,u,c,d,a;try{if(Ie.current=[],Be.current&&null!==Te.current&&null!==ai.current){var s=Te.current,v=ai.current,f="string"==typeof s&&s.includes(S),p=null,g=null,h=null,x=null;if(f){var m=s.split(S),y="".concat(m[0]).concat(S).concat(m[1]);p=(null===(n=_t.current[y])||void 0===n?void 0:n.current)||null,g=(null===(e=Et.current[y])||void 0===e?void 0:e.current)||null,h=(null===(t=Dt.current[m[2]])||void 0===t?void 0:t.current)||(null===(i=Bt.current[Number(m[2])])||void 0===i?void 0:i.current)||null,x=(null===(o=At.current[m[3]])||void 0===o?void 0:o.current)||(null===(r=Tt.current[Number(m[3])])||void 0===r?void 0:r.current)||null}else p=(null===(l=Mt.current[s])||void 0===l?void 0:l.current)||null,h=(null===(u=Bt.current[s])||void 0===u?void 0:u.current)||null,g=(null===(c=Ft.current[v])||void 0===c?void 0:c.current)||null,x=(null===(d=Tt.current[v])||void 0===d?void 0:d.current)||null;if(p&&g&&h&&x){if(h.style.paddingTop="0px",x.style.paddingTop="0px",!On){var b=p.getBoundingClientRect(),R=g.getBoundingClientRect(),C=b.top-R.top;C>0?x.style.paddingTop="".concat(C,"px"):C<0&&(h.style.paddingTop="".concat(Math.abs(C),"px"))}var I=ze.current,w=He.current;if(I&&w){var B=p.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop,T=g.getBoundingClientRect().top-w.getBoundingClientRect().top+w.scrollTop-(B-I.scrollTop);Math.abs(w.scrollTop-T)>1&&(w.scrollTop=T)}}}null===(a=_e.current)||void 0===a||a.call(_e),Be.current&&oe(!0)}catch(n){console.error("Safely caught error during resize calculation:",n)}finally{ue(!1),Ei.current=null}},150)},[On,ht,xt]),Ai=c(function(n){var e,t,i,o,r,l,u,c,d,a;if(null!==qe.current&&Ye.current&&Math.abs(n.currentTarget.scrollTop-qe.current)<=2){var s=Ye.current;qe.current=null,Ye.current=null,s()}if(!se.current){if(On||Fi(),Be.current){var v=Te.current,f=ai.current,p=ze.current,g=He.current;if(null!==v&&null!==f&&p&&g){var h="string"==typeof v&&v.includes(S)?null===(e=_t.current["".concat(v.split(S)[0]).concat(S).concat(v.split(S)[1])])||void 0===e?void 0:e.current:null===(t=Mt.current[v])||void 0===t?void 0:t.current,x="string"==typeof f&&f.includes(S)?null===(i=Et.current["".concat(f.split(S)[0]).concat(S).concat(f.split(S)[1])])||void 0===i?void 0:i.current:null===(o=Ft.current[f])||void 0===o?void 0:o.current;if(h&&x&&si.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=_t.current[R])||void 0===r?void 0:r.current,y=null===(l=Et.current[R])||void 0===l?void 0:l.current}else m=null===(u=_t.current[v])||void 0===u?void 0:u.current,y=null===(c=Et.current[f])||void 0===c?void 0:c.current;var C=null!==(a=null===(d=ci.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==a?a:0,I=p.getBoundingClientRect().top,w=I+p.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=_,A=I,M=w,Math.max(A,Math.min(M,D)))-C).toString();si.current.setAttribute("y1",E),si.current.setAttribute("y2",E);var F=_>=I-4&&_<=w+4;si.current.setAttribute("visibility",F?"visible":"hidden")}}}}var D,A,M;Ie.current.length>0&&!we.current&&(we.current=!0,requestAnimationFrame(function(){Ti(),we.current=!1}))}},[Ti,On,Fi]),Mi=r(0),Ni=r(0),ki=r(0),Hi=r(function(){});r(null),u(function(){Hi.current=Di},[Di]),u(function(){var n=setTimeout(Fi,250),e=function(){return Hi.current()};return window.addEventListener("resize",e),function(){clearTimeout(n),null!==_i.current&&clearTimeout(_i.current),null!==Ei.current&&clearTimeout(Ei.current),window.removeEventListener("resize",e)}},[pt,gt,jt,mt,Gt,Ut,ht,xt,lt,Fi,Zn,de,ie,fe]),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 ke.current&&o.push(n(ke.current,Mi,e,function(){return Hi.current()},function(){})),Ne.current&&o.push(n(Ne.current,Ni,t,function(){return Hi.current()},function(){return _e.current()})),ci.current&&o.push(n(ci.current,ki,i,function(){return Hi.current()},function(){return _e.current()})),function(){o.forEach(function(n){return n.disconnect()}),r.forEach(function(n){null!==n.current&&(cancelAnimationFrame(n.current),n.current=null)})}},[]),u(function(){Be.current=Zn},[Zn]),u(function(){Te.current=de},[de]);var ji=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";rt(),null!=n&&(e?Un("No counterpart exists for this section."):(Yt(),Zn&&de===n?r?Kt():null==l||l():(pe(new Set([n])),xe([]),Ie.current=[],$n(!0),se.current=!0,ae(n),Te.current=n,ne(!0),Be.current=!0,oe(!1),je.current&&(je.current.style.height="0px"),Le.current&&(Le.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),Oe.current&&(Oe.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),f="".concat(v[0]).concat(S).concat(v[1]);d=(null===(e=_t.current[f])||void 0===e?void 0:e.current)||null,a=(null===(t=Et.current[f])||void 0===t?void 0:t.current)||null,s=a?n:null}else if(d=(null===(i=Mt.current[n])||void 0===i?void 0:i.current)||null,On){var p=ht[n],g=(null==p?void 0:p.refIndexes)||[];if(g.length>0){var h=g[0],x=xt.findIndex(function(n){return n.selfIndex===h});-1!==x&&(a=(null===(r=Ft.current[x])||void 0===r?void 0:r.current)||null,s=x)}}else a=(null===(o=Ft.current[n])||void 0===o?void 0:o.current)||null,s=a?n:null;ai.current=s;var m=ze.current,y=He.current,b=function(){!function(){var e,t,i,o,r,l,u,d,a,v,f,p,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=Dt.current[y[2]])||void 0===e?void 0:e.current)||(null===(t=Bt.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=At.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=Tt.current[Number(y[3])])||void 0===o?void 0:o.current)||null,x=(null===(r=_t.current[b])||void 0===r?void 0:r.current)||g,m=(null===(l=Et.current[b])||void 0===l?void 0:l.current)||h}else{var R=Number(n),C=null!==s?Number(s):R;g=(null===(u=Bt.current[R])||void 0===u?void 0:u.current)||null,h=(null===(d=Tt.current[C])||void 0===d?void 0:d.current)||null,x=(null===(a=_t.current[R])||void 0===a?void 0:a.current)||(null===(v=Mt.current[R])||void 0===v?void 0:v.current)||g,m=(null===(f=Et.current[C])||void 0===f?void 0:f.current)||(null===(p=Ft.current[C])||void 0===p?void 0:p.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"))}}(),oe(!0),_e.current&&_e.current(),se.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),$n(!1),null==l||l()};if(!d||!m)return se.current=!1,$n(!1),void(null==l||l());if(a&&y){if(!On){var R=0;R="right"===u?a?a.getBoundingClientRect().top:0:d?d.getBoundingClientRect().top:0;var C=Ne.current,I=(null==C?void 0:C.getBoundingClientRect().top)||0,w=C?C.scrollTop+R-I-150:0;return C?void T(C,w,200,b):void b()}var B=d.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,_=a.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,E=200;if("left"===u){var F=_-(B-m.scrollTop);F<0&&je.current&&(je.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 Le.current&&(Le.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(y,F,E,b)})}n=F}T(y,n,E,b)})}else{var D=B-(_-y.scrollTop);D<0&&Pe.current&&(Pe.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 Oe.current&&(Oe.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(m,D,E,b)})}n=D}T(m,n,E,b)})}}else b()}))))},[de,rt,xt,Zn,On,ht,Kt]),Li=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;ot();var u="left";(null===(o=He.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=Et.current[l])||void 0===n?void 0:n.current:null===(t=_t.current[l])||void 0===t?void 0:t.current}return"right"===u?null===(i=Et.current[e])||void 0===i?void 0:i.current:null===(o=_t.current[e])||void 0===o?void 0:o.current};if(t)return Kt(),pe(new Set),xe([]),Ie.current=[],void(r&&requestAnimationFrame(function(){var n=c()||l;nt({open:!0,anchorEl:n,summary:i})}));ji(e,t,r?{toggleIfSame:!1,sourceSide:u,onReady:function(){var n=c()||l;nt({open:!0,anchorEl:n,summary:i})}}:{toggleIfSame:!1,sourceSide:u})},[ji,ot,nt,Kt]),Pi=c(function(){var n,e=$e.sectionIdx,t=$e.isOrphan;if(et(),null!=e){var i="left";$e.anchorEl&&(null===(n=He.current)||void 0===n?void 0:n.contains($e.anchorEl))&&(i="right"),ji(e,t,{sourceSide:i})}},[ji,$e.isOrphan,$e.sectionIdx,$e.anchorEl,et]),Oi=c(function(){et(),Kt(),pe(new Set),xe([]),Ie.current=[]},[et,Kt]),zi=null!==$e.sectionIdx&&fe.has($e.sectionIdx),Wi=Y({proposedSections:ht,existingSections:xt,parentDeviationRecord:yt,expandedSections:Gt,maintainRelativeOrder:!!On,scrollContainerRef:Ne,leftContainerRef:ze,lhsBadgeRefs:_t,rhsBadgeRefs:Et}),qi=Wi.showDeviationNavigation,Yi=Wi.showOpenNodeRef,Ki=l(function(){var n;if(!jn)return null;var e=null===(n=null==jn?void 0:jn.id)||void 0===n?void 0:n.split(":")[0];for(var t in yt){if((yt[t]||[]).some(function(n){return n.id===e}))return t}return null},[jn,yt]),Vi=r({id:null,triggerMs:null}),Xi=r(null);u(function(){var t;if(null==jn?void 0:jn.id){var i=Number(jn.trigger),o=Vi.current;if((null==o?void 0:o.triggerMs)!==i){if(!(jn.id.includes(":")&&/:\d+$/.test(jn.id)))return Vi.current={id:jn.id,triggerMs:i},void li(jn.id);var r=null===(t=null==jn?void 0:jn.id)||void 0===t?void 0:t.split(":"),l=r[0],u=r[1],c=null!=u?u:"0";Xi.current!==jn.id&&(et(),ot(),Kt(),pe(new Set),xe([]),Ie.current=[],Xi.current=jn.id);var d=!1,a=0,s=null,v=150,f=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},p=function(){var t,o,r,u;if(!d){var g=function(){Vi.current={id:jn.id,triggerMs:i}},h=null,x=null;for(var m in yt){var y=yt[m].find(function(n){return n.id===l});if(y){h=m,x=y;break}}if(x&&h){var b=ht.findIndex(function(n){return n.id===h}),R=xt.findIndex(function(n){return n.id===h}),C=-1===b&&-1!==R,I=f(ht,x.id),w=f(xt,x.id);if(I&&!w&&!C){var B=I.split("-"),T=Number(B[0]);if(On){var _=null===(o=null===(t=ht[T])||void 0===t?void 0:t.refIndexes)||void 0===o?void 0:o[0],E=xt.findIndex(function(n){return n.selfIndex===_});-1!==E&&(T=E)}w=e([T],B.slice(1),!0).join("-")}if(I||w){var F=C||!I&&!!w,D=I?Number(I.split("-")[0]):b,A=w?Number(w.split("-")[0]):R;if(F){if(!(On?!!Gt["right-".concat(A)]:!!Gt[String(A)])&&A>=0)return Zt(A,"right"),a+=1,void(s=setTimeout(p,450))}else if(!(On?!!Gt["left-".concat(D)]:!!Gt[String(D)])&&D>=0)return Zt(D,"left"),a+=1,void(s=setTimeout(p,450));var M,N=I||"",k=w||"",H="".concat(x.id).concat(S).concat(c).concat(S).concat(N).concat(S).concat(k),j="".concat(x.id).concat(S).concat(c),L=null===(r=_t.current[j])||void 0===r?void 0:r.current,P=null===(u=Et.current[j])||void 0===u?void 0:u.current,O=F||!L&&!!P,z=O?P:L;if(M=On?O?He.current:ze.current:Ne.current,z&&M){var W=z.getBoundingClientRect();if(0===W.height)return void((a+=1)<2?s=setTimeout(p,v):g());var q=M.getBoundingClientRect(),Y=W.top-q.top+M.scrollTop-q.height/2+W.height/2+150,K=function(){var e,t,i,o,r;if(!d){g();var l=window.getComputedStyle(z).color;L&&(L.style.transition="box-shadow 300ms ease-in-out",L.style.boxShadow="0 0 10px ".concat(l)),P&&(P.style.transition="box-shadow 300ms ease-in-out",P.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){L&&(L.style.boxShadow=""),P&&(P.style.boxShadow="")},2e3);var u=(null===(t=null===(e=x.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[c])||x,a=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!L&&!!P)){var s=O?(null===(o=Et.current[j])||void 0===o?void 0:o.current)||P:(null===(r=_t.current[j])||void 0===r?void 0:r.current)||L;return nt({open:!0,anchorEl:s,summary:n(n({},u),{evaluation_outputs:a})}),void(null==Ln||Ln())}ji(H,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,t=(null===(e=_t.current[j])||void 0===e?void 0:e.current)||L;nt({open:!0,anchorEl:t,summary:n(n({},u),{evaluation_outputs:a})})}})}};Math.abs(M.scrollTop-Y)<=2?K():(qe.current=Y,Ye.current=K,M.scrollTo({top:Y,behavior:"smooth"}),s&&clearTimeout(s),s=setTimeout(function(){if(Ye.current){qe.current=null;var n=Ye.current;Ye.current=null,n()}},800))}else(a+=1)<2?s=setTimeout(p,v):g()}else(a+=1)<2?s=setTimeout(p,v):g()}else(a+=1)<2?s=setTimeout(p,v):g()}};return s=setTimeout(p,v),function(){d=!0,s&&clearTimeout(s)}}}},[jn,yt,ht,xt,On,Gt,Zt,ji,nt,li]);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(X,{section:e,keyPath:t,depth:r,columnKey:u,parentNodeId:void 0===c?"":c,expandedSubSections:Ut,setExpandedSubSections:Qt,maintainRelativeOrder:On||!1,proposedSections:ht,existingSections:xt,treeData:Bn,deviationNumberRegistry:bt,connectedSections:fe,activeSideBySideSection:de,resolvedMarkdownStyles:Me,getSubSectionRef:kt,getSubSectionCompareStyle:Ri,getBadgeRef:Ht,openMoreFunctionsPopup:ti,openSummaryPopup:Li,showDeviationBadges:Wn,resetSideBySide:Kt,setConnectedSections:pe,setConnectedLines:xe,cachedConnectedPositions:Ie})};return t(d,n({ref:ke,sx:n(n({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},On?{}:{overflow:"visible"}),{position:"relative"})},{children:[Yn&&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(L,{})})),Ze.open&&i($,{open:Ze.open,anchorEl:Ze.anchorEl,containerEl:di.current,clipTopEl:vi.current,scrollContainerEl:Ne.current,onClose:Oi,summary:Ze.summary}),i(j,{open:$e.open,anchorEl:$e.anchorEl,sectionTitle:$e.sectionTitle,referenceSectionTitle:$e.refSectionTitle,onClose:rt,onOpenCognitiveCompare:ii,onOpenSideBySide:Pi,onConnect:oi,isConnected:zi,isOrphan:$e.isOrphan}),Ve.open&&i(H,{open:Ve.open,popupRef:it,position:Je,popupConfig:Nn,onClose:function(){Ue(null),Xe(function(e){return n(n({},e),{open:!1})}),tt(null)},markdownStyles:Fn,sectionTitle:Ve.sectionTitle,referenceSectionTitle:Ve.refSectionTitle,cognitiveData:Ve.cognitiveData,anchorEl:Ve.anchorEl,sectionAnchorEl:Ve.sectionAnchorEl,scrollContainerEl:Ne.current,badgeStyle:Ve.badgeStyle,docData:Ve.docData,deviationData:Ve.deviationData,isLoading:Ve.isLoading}),i(a,n({open:!!Jn,autoHideDuration:8e3,onClose:function(){return Un(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,n({onClose:function(){return Un(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Jn}))})),i(K,{componentHeaderText:wn,displayConfig:Mn,maintainRelativeOrder:On,onCollapseAll:Ii,showCollapseAll:wi,onToggleView:function(n){Kn(!0),setTimeout(function(){zn(!n),Kt(),et(),pe(new Set),xe([]),Ie.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Kn(!1)},600)})})},50)}}),i(d,n({ref:Ne,onScroll:Ai,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:On?"hidden":"auto",borderTop:Lt&&Pt?"none":"1.5px solid #EEF0F4"}},{children:i(d,n({sx:n({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},On?{flex:1,minHeight:0}:{})},{children:t(d,n({ref:ci,sx:n({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},On?{flex:1,overflow:"visible"}:{})},{children:[t("svg",n({ref:me,style:{position:"absolute",top:0,left:0,width:De.width||"100%",height:De.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:le?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[mi&&i("g",{children:i("line",{x1:mi.x1,y1:mi.y,x2:mi.x2,y2:mi.y,stroke:qt.badgeBorder,strokeWidth:"1.5"})}),gi.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?Zn&&de===e.subSectionKeyPath&&ie:Zn&&de===e.sectionIdx&&ie)return null;if(!On){var f=e.isSubSection?B(e.x1,e.y1,e.x2,e.y2):"M ".concat(e.x1," ").concat(e.y1," L ").concat(e.x2," ").concat(e.y2),g=ht[e.sectionIdx]||{title:"",content:""},x=xt[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),C=b.split("-").map(Number),I=null,w=null;R.length>0&&(I=ht[R[0]]),C.length>0&&(w=xt[C[0]]);var T=(null==I?void 0:I.title)||"",_=(null==w?void 0:w.title)||"";console.log("Root Parent Titles:",T,_);for(var E=1;E<R.length;E++)(null==I?void 0:I.subsections)&&(I=I.subsections[R[E]]);for(E=1;E<C.length;E++)(null==w?void 0:w.subsections)&&(w=w.subsections[C[E]]);I&&(g=n(n({},I),{title:T||I.title})),console.log("Base Section for Subsection Badge:",g),w&&(x=n(n({},w),{title:_||w.title})),console.log("Ref Section for Subsection Badge:",x)}var F=!(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),D=(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=F||D;return t("g",{children:[i("path",{d:f,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&&(Ve.open&&Qe===e.id?ot():(tt(e.id),ei(ni(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===N&&null==e.style.label?i(P,{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(p,{size:11,style:{transform:Ve.open&&Qe===e.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},e.id)}return null}),i(G,{connectedLines:he,pathRefs:Ce})]})),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)"},On?{flex:1,overflow:"visible"}:{})},{children:[i(d,n({ref:vi,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:st,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:st}))}))})),t(d,n({ref:ze,onScroll:Ai,sx:n({p:"12px",display:"flex",flexDirection:"column"},On?{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:Pe,style:{width:"100%",height:"0px",flexShrink:0}}),Rt&&ht.map(function(e,o){var r,l,u=!e.title&&!e.content;if(On&&u)return null;var c=e,a=Si(o,"left"),s=On?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!xt[o],v=On?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:o+1,f=fe.has(o),p=y(c.evaluationResult,null==a?void 0:a.deviationLabel);return i(d,n({ref:Nt(o),sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:Bt.current[o],sx:n({width:"100%",display:"flex",flexDirection:"column",minWidth:0},f&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(V,{section:e,idx:o,columnKey:"left",colRef:Nt("left-accordion-".concat(o)),mb:0,treeData:Bn,proposedSections:ht,existingSections:xt,deviationNumberRegistry:bt,getSectionCompareStyle:Si,getBadgeRef:Ht,connectedSections:fe,openMoreFunctionsPopup:ti,openSummaryPopup:Li,deviationNodeIdToView:null==jn?void 0:jn.id,deviationTargetParentId:Ki,parentNodeId:(null===(l=null==Bn?void 0:Bn.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:On?!!Gt["left-".concat(o)]:!!Gt[String(o)],onToggle:function(){Oi(),Zt(o,"left")},navigation:e.id?qi[e.id]:null,showOpenNodeRef:Yi,resolvedMarkdownStyles:Me,maintainRelativeOrder:On,showDeviationBadges:Wn,renderSubSections:$i})})),On&&a&&t(d,n({ref:_t.current[o],onClick:function(n){var t=On?xt.find(function(n){var e;return null===(e=c.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)})||{title:"",content:""}:xt[o]||{title:"",content:""};ti(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:[t(d,n({component:"span",onClick:function(n){var e,t,i;n.stopPropagation();var r=Mn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;console.log("LOG: Printing evaluationResult",r,c),Li(n,String(o),s,r)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:s?"default":"pointer",borderRight:"1px solid ".concat(a.badgeBorder),"&:hover":s?{}:{bgColor:"".concat(a.badgeBorder,"22")}}},{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:!Mn.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?s?"No Deviation Found":"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p):i(P,{color:a.badgeText})}))]})),i(d,n({component:"span",onClick:function(n){n.stopPropagation();var t=On?xt.find(function(n){var e;return(null===(e=c.refIndexes)||void 0===e?void 0:e.includes(n))||{title:"",content:""}}):xt[o]||{title:"",content:""};ti(n,e,s,t,o,a)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(a.badgeBorder,"22")}}},{children:i(g,{size:11,color:a.badgeText})}))]}))]}))}),"left-row-".concat(o))}),i("div",{ref:Oe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,n({ref:di,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(),Ve.open&&Qe===Ot?ot():(tt(Ot),ei(ni(e.currentTarget,{title:"",content:"",evaluationResult:zt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Ot,!0,n(n({},qt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:qt.badgeBg,color:qt.badgeText,border:"1px solid ".concat(qt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Wt?Wt:i(P,{}),i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(p,{size:11,style:{transform:Ve.open&&Qe===Ot?"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},On?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Xn&&i(x,{sections:11}),i(d,n({ref:fi,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:vt,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:vt}))}))})),t(d,n({ref:He,onScroll:Ai,sx:n({p:"12px",display:"flex",flexDirection:"column"},On?{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:je,style:{width:"100%",height:"0px",flexShrink:0}}),Rt&&xt.map(function(e,o){var r,l=e,u=[],c=!1,a=null,s=-1;if(On){u=ht.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=ht.findIndex(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(l.selfIndex))&&n.selfIndex>=0});var v=ht.findIndex(function(n,e){var t;return fe.has(e)&&(null===(t=n.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==v)&&(a=Si(v))}else u=[o+1],(c=fe.has(o))&&(a=Si(o));var f=Si(On&&-1!==s?s:o);return i(d,n({ref:Ft.current[o],sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:Tt.current[o],sx:n({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:i(V,{section:e,idx:o,columnKey:"right",colRef:Nt("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==Bn?void 0:Bn.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:On?!!Gt["right-".concat(o)]:!!Gt[String(o)],treeData:Bn,proposedSections:ht,existingSections:xt,deviationNumberRegistry:bt,getBadgeRef:Ht,getSectionCompareStyle:Si,connectedSections:fe,openMoreFunctionsPopup:ti,openSummaryPopup:Li,deviationNodeIdToView:null==jn?void 0:jn.id,deviationTargetParentId:Ki,onToggle:function(){Oi(),Zt(o,"right")},navigation:e.id?qi[e.id]:null,showOpenNodeRef:Yi,resolvedMarkdownStyles:Me,maintainRelativeOrder:On,showDeviationBadges:Wn,renderSubSections:$i})})),On&&f&&i(d,n({ref:Et.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:f.badgeBg,color:f.badgeText,border:"1px solid ".concat(f.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:Le,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{J as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DEFAULT_DEVIAION_COLOR as t}from"./CognitiveCompareConstants.js";var n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},o=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return o(t)}))},
|
|
1
|
+
import{DEFAULT_DEVIAION_COLOR as t}from"./CognitiveCompareConstants.js";var n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},o=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return o(t)}))},e=function(t,o,e){var i,r=e[o],u=null===(i=null==t?void 0:t.comparison_inputs)||void 0===i?void 0:i[r];return{title:n((null==u?void 0:u.title)||""),content:n((null==u?void 0:u.content)||""),attributes:(null==u?void 0:u.additional_attributes)||null,subsections:(null==u?void 0:u.subsections)||[]}},i=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,o=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:o,citations:n.citations},score:0,relation:"N/A"}};function r(t){var n=function(t,n){var o=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),o=parseInt(n,16);return{r:o>>16&255,g:o>>8&255,b:255&o}}(t),e=o.r,i=o.g,r=o.b;return function(t,n,o){return"#"+[t,n,o].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(e+(255-e)*n),Math.round(i+(255-i)*n),Math.round(r+(255-r)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}}function u(t,n){var o;return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var r=this;clearTimeout(o),o=setTimeout(function(){return t.apply(r,e)},n)}}var l=function(t,n){var o,e,i,r,u,l;if(t.content!==n.content)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var v=0;v<a.length;v++)if(a[v]!==s[v])return!1;var d=t.deviationBadges||[],c=n.deviationBadges||[];if(d.length!==c.length)return!1;for(v=0;v<d.length;v++){if(d[v].id!==c[v].id)return!1;if(d[v].actionId!==c[v].actionId)return!1;if(d[v].label!==c[v].label)return!1;if(d[v].score!==c[v].score)return!1;if(d[v].isOrphan!==c[v].isOrphan)return!1;if(d[v].isConnected!==c[v].isConnected)return!1;if((null===(o=d[v].style)||void 0===o?void 0:o.badgeBg)!==(null===(e=c[v].style)||void 0===e?void 0:e.badgeBg))return!1;if((null===(i=d[v].style)||void 0===i?void 0:i.badgeBorder)!==(null===(r=c[v].style)||void 0===r?void 0:r.badgeBorder))return!1;if((null===(u=d[v].style)||void 0===u?void 0:u.badgeText)!==(null===(l=c[v].style)||void 0===l?void 0:l.badgeText))return!1}return!0},a="::",s=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},v=function(t,n){var o,e,i,r,u,l,a;if(!t)return n;var s=null!==(l=null!==(r=null!==(e=null===(o=t.evaluation_output)||void 0===o?void 0:o.output_score)&&void 0!==e?e:null===(i=t.evaluation_outputs)||void 0===i?void 0:i.output_score)&&void 0!==r?r:null===(u=t.evaluation_outputs)||void 0===u?void 0:u.output_value)&&void 0!==l?l:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},d=function(t,n,o,e,i){void 0===i&&(i=14);var r=t+.5*(o-t),u=e-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(o);var l=u>0?1:-1,a=Math.min(i,Math.abs(u)/2,Math.abs(r-t)/2,Math.abs(o-r)/2);return["M ".concat(t," ").concat(n),"H ".concat(r-a),"Q ".concat(r," ").concat(n," ").concat(r," ").concat(n+l*a),"V ".concat(e-l*a),"Q ".concat(r," ").concat(e," ").concat(r+a," ").concat(e),"H ".concat(o)].join(" ")},c=function(t,n,o,e,i){void 0===o&&(o=300);var r=t.style.scrollBehavior;t.style.scrollBehavior="auto";var u=t.scrollTop,l=n-u,a=null,s=function(v){null===a&&(a=v);var d,c=v-a;c<o?(t.scrollTop=(d=c,d/=o,l*(--d*d*d+1)+u),i&&i(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=r,i&&i(),e&&e())};requestAnimationFrame(s)},f=["#B91C1C","#A16207","#1D4ED8","#000000"],g=function(t){var n=f.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?f.length:n},p=function(n){for(var o,e,i,r,u,l,a,s,v,d,c,f,p,h=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var _=m[b];(A=null===(r=null===(i=null===(e=null===(o=null==n?void 0:n.deviations)||void 0===o?void 0:o[_])||void 0===e?void 0:e.evaluation_outputs)||void 0===i?void 0:i.metadata)||void 0===r?void 0:r.label_color)&&h.push(A)}for(var y=0,B=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});y<B.length;y++){_=B[y];(A=null===(s=null===(a=null===(l=null===(u=null==n?void 0:n.deviation_entries)||void 0===u?void 0:u[_])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===s?void 0:s.label_color)&&h.push(A)}for(var T=0,x=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});T<x.length;T++){var A;_=x[T];(A=null===(c=null===(d=null===(v=null==n?void 0:n[_])||void 0===v?void 0:v.evaluation_outputs)||void 0===d?void 0:d.metadata)||void 0===c?void 0:c.label_color)&&h.push(A)}return 0===h.length?(null===(p=null===(f=null==n?void 0:n.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===p?void 0:p.label_color)?n.evaluation_outputs.metadata.label_color:t:h.sort(function(t,n){return g(t)-g(n)})[0]},h=function(t){for(var n,o,e,i,r,u,l,a,s,v=0,d=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});v<d.length;v++){var c=d[v];if(b=null===(e=null===(o=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[c])||void 0===o?void 0:o.evaluation_outputs)||void 0===e?void 0:e.output_value)return b}for(var f=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<g.length;f++){c=g[f];if(b=null===(u=null===(r=null===(i=null==t?void 0:t.deviation_entries)||void 0===i?void 0:i[c])||void 0===r?void 0:r.evaluation_outputs)||void 0===u?void 0:u.output_value)return b}for(var p=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});p<h.length;p++){var b;c=h[p];if(b=null===(a=null===(l=null==t?void 0:t[c])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},b=function(t,n){var o=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},e=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var i=o(t),r=o(n),u=(i[0]+r[0])/2*.95,l=(i[1]+r[1])/2*.95,a=(i[2]+r[2])/2*.95;return"#".concat(e(u)).concat(e(l)).concat(e(a))}catch(t){return"#FDE68A"}},m=function(t,n,o){if(!t)return null;if(t.id===o)return n;if(!Array.isArray(t.subsections))return null;for(var e=0;e<t.subsections.length;e++){var i=m(t.subsections[e],"".concat(n,"-").concat(e),o);if(i)return i}return null},_=function(t,n){for(var o=0;o<t.length;o++){var e=m(t[o],String(o),n);if(e)return e}return null},y=new WeakMap,B=function(t){if(t){var n=y.get(t);null!=n&&(clearTimeout(n),y.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},T=function(t){if(t){var n=y.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var o=window.setTimeout(function(){B(t)},3e3);y.set(t,o)}},x=function(t,n){var o=n.getBoundingClientRect(),e=t.getBoundingClientRect(),i=n.scrollTop+e.top-o.top-o.height/2+e.height/2;n.scrollTo({top:i,behavior:"smooth"});var r=function(){return T(t)};if("onscrollend"in n)n.addEventListener("scrollend",r,{once:!0});else{var u=n.scrollTop,l=function(){n.scrollTop===u?r():(u=n.scrollTop,requestAnimationFrame(l))};requestAnimationFrame(l)}};export{a as DEVIATION_BADGE_SEPARATOR,l as areMarkdownPropsEqual,u as debounce,v as extractDeviationScore,_ as findKeyPathByNodeId,r as generateColorPalette,d as getBentArrowPath,p as getFirstDeviationColor,h as getFirstDeviationOutputValue,i as getRationale,e as getSideData,o as hasValue,T as highlightClause,s as isMissingStr,b as mixHexColors,m as recursivelyFindSubSectionIdxById,B as resetClauseHighlight,n as safeStringify,x as scrollAndHighlightClause,c as smoothScrollTo};
|
|
2
2
|
//# sourceMappingURL=CognitiveComparehelpers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Popper as o,Paper as i,Box as l,Typography as r,IconButton as a,Accordion as c,AccordionSummary as d,AccordionDetails as s}from"@mui/material";import{Info as p,X as u,ChevronDown as m}from"lucide-react";import{useRef as f,useState as x,useEffect as h}from"react";function g(g){var v,b,w,y=g.open,C=g.anchorEl,S=g.containerEl,z=g.clipTopEl,B=g.scrollContainerEl,I=g.onClose,R=g.summary;g.markdownStyles,g.isLoading;var F=f(null),W=f(null),E=x(null),H=E[0],k=E[1],A=x(null),M=A[0],_=A[1],L=x(null),T=L[0],j=L[1],N=x(0),O=N[0],P=N[1],q="string"==typeof R?{deviation_summary:R}:null!=R?R:{},D=q.deviation_title,G=q.deviation_summary,J=q.deviation_impact,V=q.evaluation_outputs,Y=!!String(J||"").trim(),Z=(null===(v=null==V?void 0:V.metadata)||void 0===v?void 0:v.label_color)||"#6366F1",K=null!==(b=null==S?void 0:S.getBoundingClientRect().width)&&void 0!==b?b:180,Q=Math.max(148,K+
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Popper as o,Paper as i,Box as l,Typography as r,IconButton as a,Accordion as c,AccordionSummary as d,AccordionDetails as s}from"@mui/material";import{Info as p,X as u,ChevronDown as m}from"lucide-react";import{useRef as f,useState as x,useEffect as h}from"react";function g(g){var v,b,w,y=g.open,C=g.anchorEl,S=g.containerEl,z=g.clipTopEl,B=g.scrollContainerEl,I=g.onClose,R=g.summary;g.markdownStyles,g.isLoading;var F=f(null),W=f(null),E=x(null),H=E[0],k=E[1],A=x(null),M=A[0],_=A[1],L=x(null),T=L[0],j=L[1],N=x(0),O=N[0],P=N[1],q="string"==typeof R?{deviation_summary:R}:null!=R?R:{},D=q.deviation_title,G=q.deviation_summary,J=q.deviation_impact,V=q.evaluation_outputs,Y=!!String(J||"").trim(),Z=(null===(v=null==V?void 0:V.metadata)||void 0===v?void 0:v.label_color)||"#6366F1",K=null!==(b=null==S?void 0:S.getBoundingClientRect().width)&&void 0!==b?b:180,Q=Math.max(148,K+120),U=C&&S?{top:C.getBoundingClientRect().top,bottom:C.getBoundingClientRect().bottom,left:S.getBoundingClientRect().left+S.getBoundingClientRect().width/2}:null;h(function(){if(!y||!C||!S)return k(null),_(null),void j(null);var e=function(){null!==F.current&&cancelAnimationFrame(F.current),F.current=requestAnimationFrame(function(){var e,t,n=C.getBoundingClientRect(),o=S.getBoundingClientRect(),i=null==z?void 0:z.getBoundingClientRect(),l=null==B?void 0:B.getBoundingClientRect();k({top:n.top,bottom:n.bottom,left:o.left+o.width/2}),_(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),j(null!==(t=null==l?void 0:l.bottom)&&void 0!==t?t:null),W.current&&P(W.current.offsetHeight)})};e();var t=!0;return window.addEventListener("scroll",e,{passive:!0,capture:t}),window.addEventListener("resize",e),function(){null!==F.current&&cancelAnimationFrame(F.current),window.removeEventListener("scroll",e,t),window.removeEventListener("resize",e)}},[y,C,S,z,B]);var X=null!==(w=null!=H?H:U)&&void 0!==w?w:{top:0,bottom:0,left:0},$=X.bottom+20,ee=$+O,te=null!=M?Math.max(0,M-$):0,ne=null!=T?Math.max(0,ee-T):0;return R?t(o,e({open:y,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:X.bottom-X.top,top:X.top,bottom:X.bottom,left:X.left,right:X.left,x:X.left,y:X.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:21}},{children:n(i,e({ref:W,sx:e(e({p:1.5,borderRadius:"12px",width:Q,maxWidth:Q},(te>0||ne>0)&&{clipPath:"inset(".concat(te,"px 0 ").concat(ne-150,"px 0 round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(Z,"26"),borderTop:"3px solid ".concat(Z),overflow:"hidden",bgcolor:"#fff"})},{children:[n(l,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[n(l,e({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[t(p,{size:14,color:Z}),t(r,e({sx:{fontSize:"11px",fontWeight:700,color:Z,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),t(a,e({size:"small",onClick:I,sx:{p:.25,ml:.5,color:"#64748B"}},{children:t(u,{size:14})}))]})),n(l,e({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[n(l,{children:[D&&t(r,e({sx:{fontSize:"12px",color:"#334155",fontFamily:'"Inter", sans-serif',lineHeight:1.6,fontWeight:700,overflowWrap:"anywhere"}},{children:D})),t(r,e({sx:{fontSize:"11px",color:"#334155",lineHeight:1.6,fontFamily:'"Inter", sans-serif',fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:G||"No summary available."}))]}),Y&&n(c,e({disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(Z,"0A"),border:"1px solid ".concat(Z,"33"),borderRadius:"4px",fontFamily:'"Inter", sans-serif',overflow:"hidden",flexShrink:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[t(d,e({expandIcon:t(m,{size:16,color:Z}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(Z,"1A")}}},{children:t(r,e({sx:{fontSize:"11px",fontWeight:700,color:Z,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),t(s,e({sx:{p:1.5,backgroundColor:"#fff"}},{children:t(r,e({sx:{fontSize:"11px",color:"#475569",lineHeight:1.6,fontWeight:400,fontFamily:'"Inter", sans-serif',overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(J).replace("Impact -","").trim()}))}))]}))]}))]}))})):null}export{g as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveSummaryPopup.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n,__rest as e}from"tslib";import{jsx as r,jsxs as
|
|
1
|
+
import{__assign as n,__rest as e}from"tslib";import{jsx as r,jsxs as t,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as l}from"@mui/material";import a,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as p}from"lucide-react";import h from"react-markdown";import{safeStringify as g,mixHexColors as f,areMarkdownPropsEqual as v}from"../CognitiveComparehelpers.js";import m from"rehype-raw";var b=a.memo(function(v){var b=v.content,x=v.sxStyles,y=v.deviationBadges,C=void 0===y?[]:y,E=v.highlights,F=void 0===E?[]:E,S=v.maintainRelativeOrder,_=void 0===S||S,k=v.highlightBg,w=c(null),B=d(function(){return C.reduce(function(e,r){var t;return n(n({},e),((t={})[r.id]=r,t))},{})},[C]),N=function(e,r){return a.Children.map(e,function(e){var t;if(!a.isValidElement(e))return e;var i=(null===(t=e.props)||void 0===t?void 0:t.children)?N(e.props.children,r):e.props.children,o=a.cloneElement(e,n(n({},e.props),{children:i}));return r(o)})},O=d(function(){return{mark:function(t){var i,o,l,a,c=t.children,d=e(t,["children"]),s=d["data-badge-id"],u=s?B[s]:null,p=d["data-highlight-color"],h=null!==(a=null!==(o=null!=p?p:null===(i=null==u?void 0:u.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(l=null==u?void 0:u.style)||void 0===l?void 0:l.badgeBg)&&void 0!==a?a:k;return r("span",n({style:n(n({},d.isSuggestedDeviationFix?{}:{backgroundColor:h}),{borderRadius:"2px"})},{children:c}))},span:function(i){var l,a,c,d,s,h,g=i.children,f=e(i,["children"]),v=f["data-badge-id"];if(!v)return r("span",n({},f,{children:g}));var m=B[v];if(!m)return r("span",n({},f,{children:g}));var b="number"==typeof m.stackIndex?m.stackIndex:0,x="translateY(calc(-20% + ".concat(24*b,"px))");return t(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[t(o,n({ref:m.badgeRef,className:"deviation-badge","data-side":m.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+b,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(l=m.style)||void 0===l?void 0:l.badgeBg)||"#EEF2FF",color:(null===(a=m.style)||void 0===a?void 0:a.badgeText)||u,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",transition:"margin-top 0.2s ease-out"},"left"===m.side?{right:"-16px",transform:"".concat(x," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(x," translateX(calc(-100% - 8px))")}),m.isConnected&&m.style&&{outline:"2px solid ".concat(m.style.badgeBorder),outlineOffset:"1px"})},{children:[t(o,n({onClick:function(n){n.stopPropagation(),m.onSummaryClick&&m.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[r(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:m.label})),("left"===m.side||m.isOrphan)&&r(o,n({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)&&r(o,n({onClick:function(n){n.stopPropagation(),m.onClick&&m.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=m.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:r(p,{size:12,color:(null===(h=m.style)||void 0===h?void 0:h.badgeText)||"#3730A3"})}))]})),g]}))},updated:function(n){var t=n.children;return e(n,["children"]),r(i,{children:t})},deleted:function(t){var i=t.children;e(t,["children"]),console.log("nitish: ",i);var o=N(i,function(n){return a.cloneElement(n,{isSuggestedDeviationFix:!0})});return r("span",n({style:{borderTop:"1px solid #EF4444",borderBottom:"1px solid #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:o}))},changed:function(t){var i=t.children;e(t,["children"]);var o=N(i,function(n){return a.cloneElement(n,{isSuggestedDeviationFix:!0})});return r("span",n({style:{borderTop:"1px solid #2F59FF",borderBottom:"1px solid #2F59FF",backgroundColor:"#D5E8FF"}},{children:o}))}}},[B,_,k]),T=function(n){return n?n.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n").split(/(\n{2,})/).map(function(n){return n.startsWith("\n")?n:n.replace(/\n/g," ")}).join(""):""},j=d(function(){var n=T(g(b||"")),e=(C||[]).map(function(n){var e,r;return{id:null==n?void 0:n.id,highlight:T((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(r=null==n?void 0:n.style)||void 0===r?void 0:r.badgeBg)||k}}).filter(function(n){return n.id&&n.highlight}),r={};e.forEach(function(n){r[n.highlight]||(r[n.highlight]=[]),r[n.highlight].push(n)});var t=Object.keys(r).sort(function(n,e){return e.length-n.length}),i=new Set,o=function(n,e,r,t,i){void 0===e&&(e=""),void 0===r&&(r=""),void 0===t&&(t="");var o=n.startsWith("\n\n"),l=n.endsWith("\n\n"),a=i?' data-highlight-color="'.concat(i,'"'):"";return r+n.split(/(\n{2,})/).map(function(n,r,t){if(/^\n{2,}$/.test(n))return n;if(!n.trim())return n;var i=0===r||1===r&&/^\n{2,}$/.test(t[0]),c=r===t.length-1||r===t.length-2&&/^\n{2,}$/.test(t[t.length-1]);return o&&i||l&&c?n:'<mark data-badge-id="'.concat(e,'"').concat(a,">").concat(n,"</mark>")}).join("").replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")+t},l={},a=0;t.forEach(function(e){for(var c=r[e],d=c[0],s=d.highlightColor,u=1;u<c.length;u++)s=f(s,c[u].highlightColor);var p=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=t.filter(function(n){return e.length>n.length&&e.includes(n)}).sort(function(n,e){return e.length-n.length}),g=function(n){var t=e;return h.forEach(function(e){for(var l=r[e],a=l[0].highlightColor,c=1;c<l.length;c++)a=f(a,l[c].highlightColor);var d=f(s,a),u="",p="";n&&l.forEach(function(n){u+='<span data-badge-id="'.concat(n.id,'">'),p="</span>"+p,i.add(n.id)});var h=o(e,l[0].id,u,p,d);t=t.split(e).join(h)}),t},v=n.includes(e),m=g(v),b=g(!1),x=c.every(function(n){return i.has(n.id)});if(v&&!x){var y="__DEV_TOKEN_".concat(a++,"__"),C="",E="";c.forEach(function(n){C+='<span data-badge-id="'.concat(n.id,'">'),E="</span>"+E,i.add(n.id)}),l[y]=o(m,d.id,C,E,s),n=n.replace(e,y)}var F="__HIGHLIGHT_TOKEN_".concat(a++,"__");l[F]=o(b,d.id,"","",s),n=n.replace(new RegExp(p,"g"),F)});var c=new Set(t);return F.forEach(function(e){if(e){var r=T(e);if(r&&!c.has(r)){var t=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i="__PLAIN_TOKEN_".concat(a++,"__");l[i]=o(r),n=n.replace(new RegExp(t,"g"),i)}}}),Object.keys(l).forEach(function(e){n=n.split(e).join(l[e])}),n},[b,C,F,k]);return s(function(){if(w.current){var n=function(){var n=Array.from(w.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.marginTop="0px"});var e=n.filter(function(n){return"left"===n.dataset.side}),r=n.filter(function(n){return"left"!==n.dataset.side}),t=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,top:e.top,bottom:e.bottom}});e.sort(function(n,e){return n.top-e.top});var r=-1/0;e.forEach(function(n){if(n.top<r+6){var e=r+6-n.top;n.el.style.marginTop="".concat(e,"px"),r=n.bottom+e}else r=n.bottom})}};t(e),t(r)}};n();var e=new ResizeObserver(function(){return n()});return e.observe(w.current),function(){return e.disconnect()}}},[j]),r(l,n({component:"div",ref:w,sx:n(n({},x),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}})},{children:r(h,n({components:O,rehypePlugins:[m]},{children:g(j).replace(/\\n/g,"\n")}))}))},v);export{b as MemoizedMarkdown};
|
|
2
2
|
//# sourceMappingURL=memoizedMarkdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAKA,QAAA,MAAM,oBAAoB,+CA6KzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -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,GAw9Y/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAuCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAkBlC,QAAA,MAAM,gBAAgB,0NAoBnB,qBAAqB,4CAujHvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SectionBlock } from "./CognitiveCompareTypes";
|
|
1
2
|
export declare const safeStringify: (val: unknown) => string;
|
|
2
3
|
export declare const hasValue: (val: unknown) => boolean;
|
|
3
4
|
export declare const getSideData: (node: any, sideIndex: "0" | "1", indexMap: Record<string, string>) => {
|
|
@@ -49,5 +50,11 @@ export declare const escapeRegExp: (string: string) => string;
|
|
|
49
50
|
export declare const getFirstDeviationColor: (evaluationResult: any) => string;
|
|
50
51
|
export declare const getFirstDeviationOutputValue: (evaluationResult: any) => string | null;
|
|
51
52
|
export declare const mixHexColors: (hex1: string, hex2: string) => string;
|
|
53
|
+
export declare const recursivelyFindSubSectionIdxById: (node: any, path: string, targetId: string) => string | null;
|
|
54
|
+
export declare const findKeyPathByNodeId: (sections: SectionBlock[], nodeId: string) => string | null;
|
|
55
|
+
export declare const resetClauseHighlight: (element: HTMLElement) => void;
|
|
56
|
+
export declare const highlightClause: (element: HTMLElement) => void;
|
|
57
|
+
export declare const scrollAndHighlightClause: (element: HTMLElement, scrollContainer: HTMLElement) => void;
|
|
58
|
+
export declare const waitForElementVisible: (element: HTMLElement, onVisible: () => void) => void;
|
|
52
59
|
export {};
|
|
53
60
|
//# sourceMappingURL=CognitiveComparehelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveComparehelpers.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveComparehelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CognitiveComparehelpers.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveComparehelpers.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EAEb,MAAM,yBAAyB,CAAC;AAGjC,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,MAM5C,CAAC;AAGF,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAKvC,CAAC;AAGF,eAAO,MAAM,WAAW,SAChB,GAAG,aACE,GAAG,GAAG,GAAG,YACV,OAAO,MAAM,EAAE,MAAM,CAAC;;;;;CAUjC,CAAC;AAGF,eAAO,MAAM,YAAY,SAAU,GAAG;;;;;;;;;;;;;;;;;;;;CA2BrC,CAAC;AAGF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAOxD,CAAC;AAqDF,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAuD9D;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,GACZ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAQlC;AAED,eAAO,MAAM,mBAAmB,YAAa,MAAM,OAAO,MAAM,YAG/D,CAAA;AACD,eAAO,MAAM,qBAAqB,cAAe,GAAG,aAAa,GAAG,YAgCnE,CAAC;AAEF,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,eAAO,MAAM,YAAY,QAAS,MAAM,GAAG,SAAS,GAAG,IAAI,YAS1D,CAAC;AAEF,eAAO,MAAM,qBAAqB,qBAAsB,GAAG,kBAAkB,GAAG,QAO/E,CAAC;AAEF,eAAO,MAAM,gBAAgB,OACvB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,WACF,MAAM,KACb,MAyBF,CAAC;AAEF,eAAO,MAAM,cAAc,YAChB,WAAW,kBACJ,MAAM,aACZ,MAAM,eACH,MAAM,IAAI,eACV,MAAM,IAAI,SAgCxB,CAAC;AAEF,eAAO,MAAM,YAAY,WAAY,MAAM,WAQ1C,CAAC;AAWF,eAAO,MAAM,sBAAsB,qBAAsB,GAAG,KAAG,MAmC9D,CAAC;AAEF,eAAO,MAAM,4BAA4B,qBAAsB,GAAG,KAAG,MAAM,GAAG,IA4B7E,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,QAAQ,MAAM,KAAG,MA8BzD,CAAC;AAIF,eAAO,MAAM,gCAAgC,SACrC,GAAG,QACH,MAAM,YACF,MAAM,KACf,MAAM,GAAG,IAcX,CAAC;AAEF,eAAO,MAAM,mBAAmB,aACpB,YAAY,EAAE,UAChB,MAAM,KACb,MAAM,GAAG,IAUX,CAAC;AAIF,eAAO,MAAM,oBAAoB,YAAa,WAAW,SAkBxD,CAAC;AAEF,eAAO,MAAM,eAAe,YAAa,WAAW,SAiBnD,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAC1B,WAAW,mBACH,WAAW,SAiC7B,CAAC;AAGF,eAAO,MAAM,qBAAqB,YACvB,WAAW,aACT,MAAM,IAAI,SAkBtB,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,KAAoE,MAAM,OAAO,CAAC;AAQzF,eAAO,MAAM,gBAAgB;aAQlB,MAAM;cACL,GAAG;;;;iBAIA,MAAM;8CA4ZI,CAAC"}
|