@viswa-test/test-citation 0.0.72 → 0.0.73

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.
@@ -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"),s=require("./CognitiveCompareConstants.js"),a=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),g=require("./components/ThreeDotsLoader.js"),f=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),_=require("./hooks/useDeviationNavigation.js"),m=require("./components/CompareHeader.js"),y=require("./components/SectionAccordion.js"),R=require("./components/SubSectionAccordion.js"),S=require("./components/CognitiveSummaryPopup.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(b){var A,T,E,I,B,C,D,O,j,w,P,N,F,k,M,L=b.componentHeaderText,V=void 0===L?s.DEFAULT_COMPONENT_HEADER_TEXT:L,H=b.treeData,G=b.comparisonConfig,q=b.leftColumnTitleText,z=b.rightColumnTitleText,W=b.markdownStyles,Y=b.displayConfig,K=void 0===Y?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0}:Y,U=b.popupConfig,X=b.deviationData,J=void 0===X?{}:X,Q=b.deviationNodeIdToView,Z=t.useState(K.maintainRelativeOrder),$=Z[0],ee=Z[1],ne=t.useState(!1),te=ne[0],ie=ne[1],oe=t.useState(!1),le=oe[0],re=oe[1],ue=t.useState(null),ce=ue[0],se=ue[1],ae=t.useState(!1),de=ae[0],ve=ae[1],ge=t.useState(!1),fe=ge[0],pe=ge[1],he=t.useState(!1),xe=he[0],_e=he[1],me=t.useState(null),ye=me[0],Re=me[1],Se=t.useRef(!1),be=t.useState(new Set),Ae=be[0],Te=be[1],Ee=t.useState([]),Ie=Ee[0],Be=Ee[1],Ce=t.useRef(null),De=t.useRef(!1),Oe=t.useRef(null),je=t.useRef({}),we=t.useRef([]),Pe=t.useRef(!1),Ne=t.useRef(!1),Fe=t.useRef(null),ke=t.useRef(function(){}),Me=t.useMemo(function(){return(null==H?void 0:H.cognitive_decisioning)||{}},[H]),Le=t.useState({width:0,height:0}),Ve=Le[0],He=Le[1],Ge=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),W)},[W]),qe=t.useRef(null),ze=t.useRef(null),We=t.useRef(null),Ye=t.useRef(null),Ke=t.useRef(null),Ue=t.useRef(null),Xe=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(!1),Ze=p.useComparePopups(qe),$e=Ze.cognitivePopup,en=Ze.setCognitivePopup,nn=Ze.moreFunctions,tn=Ze.setMoreFunctions,on=Ze.position,ln=Ze.setPosition,rn=Ze.activeBadgeId,un=Ze.summaryPopup,cn=Ze.setSummaryPopup,sn=Ze.closeSummaryPopup,an=Ze.setActiveBadgeId,dn=Ze.popupRef,vn=Ze.closeCognitivePopup,gn=Ze.closeMoreFunctionsPopup,fn=t.useMemo(function(){var e,n,t,i,o,l,r;return{fields:null!==(e=null==G?void 0:G.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==G?void 0:G.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==G?void 0:G.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(r=null===(l=null==G?void 0:G.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[G]),pn=t.useState(null),hn=pn[0];pn[1];var xn=null===(E=null===(A=null==H?void 0:H.documents)||void 0===A?void 0:A[null===(T=null==H?void 0:H.input_index_map)||void 0===T?void 0:T[0]])||void 0===E?void 0:E.title,_n=null===(C=null===(I=null==H?void 0:H.documents)||void 0===I?void 0:I[null===(B=null==H?void 0:H.input_index_map)||void 0===B?void 0:B[1]])||void 0===C?void 0:C.title,mn=u.safeStringify(q||xn||"Uploaded Contract"),yn=u.safeStringify(z||_n||"Reference Template"),Rn=f.useCognitiveTreeData(H,$,J,fn),Sn=Rn.activeProposed,bn=Rn.existingRule,An=Rn.proposedSections,Tn=Rn.existingSections,En=Rn.visibleFields,In=Rn.parentDeviationRecord,Bn=Rn.deviationNumberRegistry,Cn=Rn.parseError;t.useEffect(function(){Cn&&se("Failed to load comparison: ".concat(Cn))},[Cn]);var Dn=An.length>0||Tn.length>0,On=h.useSectionRefs(En.map(function(e){return e.key}),Math.max(An.length,Tn.length)),jn=On.leftRefs,wn=On.rightRefs,Pn=On.sectionLeftRefs,Nn=On.sectionRightRefs,Fn=On.lhsBadgeRefs,kn=On.rhsBadgeRefs,Mn=On.sectionRightRowRefs,Ln=On.subSectionLeftRefs,Vn=On.subSectionRightRefs,Hn=On.sectionRowRefs,Gn=On.getSectionRowRef,qn=On.getSubSectionRef,zn=On.getBadgeRef,Wn=bn.analysis,Yn=u.safeStringify(null===(O=null===(D=null==Wn?void 0:Wn.rule_difference_comparison)||void 0===D?void 0:D.summary)||void 0===O?void 0:O.overall_summary),Kn=!!Yn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Un=null!==(j=null==H?void 0:H.base_root_id)&&void 0!==j?j:"-1";null==H||H[Un];var Xn=(null===(w=null==J?void 0:J[Un])||void 0===w?void 0:w.evaluation_result)||(null===(N=null===(P=null==H?void 0:H.nodes)||void 0===P?void 0:P[Un])||void 0===N?void 0:N.evaluation_result)||null,Jn=u.extractDeviationScore(Xn),Qn=u.generateColorPalette(null!==(M=null===(k=null===(F=null==Xn?void 0:Xn.evaluation_outputs)||void 0===F?void 0:F.metadata)||void 0===k?void 0:k.label_color)&&void 0!==M?M:""),Zn=t.useCallback(function(){var e,n,t,i;ve(!1),Ne.current=!1;var o=Fe.current,l=dt.current;if(null!==o)if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR);(c=null===(e=Ln.current[r[2]])||void 0===e?void 0:e.current)&&(c.style.paddingTop="0px")}else{var c;(c=null===(n=Pn.current[o])||void 0===n?void 0:n.current)&&(c.style.paddingTop="0px")}if(null!==l)if("string"==typeof l&&l.includes(u.DEVIATION_BADGE_SEPARATOR)){r=l.split(u.DEVIATION_BADGE_SEPARATOR);(s=null===(t=Vn.current[r[3]])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}else{var s;(s=null===(i=Nn.current[l])||void 0===i?void 0:i.current)&&(s.style.paddingTop="0px")}Re(null),Fe.current=null,dt.current=null,pe(!1),re(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ue.current&&(Ue.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px")},[]),$n=x.useAccordionState({maintainRelativeOrder:!!$,proposedSections:An,existingSections:Tn,activeSideBySideSection:ye,connectedSections:Ae,resetSideBySide:Zn,setConnectedSections:Te,setConnectedLines:Be,cachedConnectedPositions:we,svgContainerRef:Ce,isAnimatingRef:De,animationTimerRef:Oe,calculateLinesRef:ke,sectionLeftRefs:Pn,sectionRightRefs:Nn,subSectionLeftRefs:Ln,subSectionRightRefs:Vn}),et=$n.expandedSections,nt=$n.expandedSubSections,tt=$n.setExpandedSubSections,it=$n.toggleSection,ot=t.useCallback(function(e,n,t,i,o,l,r){var c,s,a,d=u.safeStringify(null==n?void 0:n.id)||u.safeStringify(null==t?void 0:t.id)||"",v=(d?Me[d]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:d,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(c=Hn.current[i])||void 0===c?void 0:c.current)&&void 0!==s?s:null;return{isLoading:null!==(a=null==K?void 0:K.isLoading)&&void 0!==a&&a,open:!0,sectionTitle:(null==n?void 0:n.displayTitle)?null==n?void 0:n.title:"no title",refSectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:i,docData:{documents:null==H?void 0:H.documents,input_index_map:null==H?void 0:H.input_index_map},deviationData:(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,isOrphan:!!o}},[Me,H]),lt=t.useCallback(function(e){gn(),ln(null),en(e)},[gn]),rt=function(e,n,t,i,o,l){e.stopPropagation(),nn.open&&nn.sectionIdx===o?gn():(vn(),tn(ot(e.currentTarget,n,i,o,t,l)))},ut=t.useCallback(function(){null!==nn.sectionIdx&&nn.anchorEl?lt(e.__assign(e.__assign({},nn),{open:!0})):gn()},[nn,gn,lt]),ct=t.useCallback(function(){var e=nn.sectionIdx,n=nn.isOrphan;gn(),sn(),null!==e&&(n?se("No counterpart exists to connect to."):(Ne.current&&Zn(),Be([]),we.current=[],Te(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){ke.current&&ke.current()},50)))},[nn.sectionIdx,nn.isOrphan,gn,sn,Zn]),st=t.useRef(null),at=t.useRef(null),dt=t.useRef(null),vt=t.useRef(null),gt=t.useRef(null),ft=t.useRef(null),pt=t.useState([]),ht=pt[0],xt=pt[1];t.useRef(null);var _t=t.useState(null),mt=_t[0],yt=_t[1];t.useEffect(function(){if(hn){var e=fn.fields.find(function(e){return e.analysisKey===hn||e.key===hn});if(e){var n=jn.current[e.key]||wn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[hn,fn.fields]);var Rt=t.useCallback(function(e){var n,t,i,o,l,r,u,c,s,a=null===(n=null==Wn?void 0:Wn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!a||!a[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=a[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(l=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===l?void 0:l.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var g=d.mappings[0]||{};return{score:d.score,relation:g.relation||"",highlightsA:(null===(r=g.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(u=g.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(s=d.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}},[Wn]),St=t.useCallback(function(n,t){var i,o,l,r,c,a,d;void 0===t&&(t="left");var v=null,g=null;if("left"===t)if(v=An[n],$&&v){var f=Tn.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});g=f.find(function(e){return e.evaluationResult})||f[0]}else g=Tn[n];else if(g=Tn[n],$&&g){var p=An.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(g.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=An[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,_=!(!(null==v?void 0:v.cognitiveData)&&!(null==g?void 0:g.cognitiveData));if(!h&&!x&&!_)return e.__assign(e.__assign({},u.generateColorPalette(s.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var m=null!==(o=null!==(i=null==v?void 0:v.evaluationResult)&&void 0!==i?i:null==g?void 0:g.evaluationResult)&&void 0!==o?o:null,y=null===(l=null==m?void 0:m.evaluation_outputs)||void 0===l?void 0:l.output_value,R=null!==(a=null===(c=null===(r=null==m?void 0:m.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===c?void 0:c.label_color)&&void 0!==a?a:s.DEFAULT_DEVIAION_COLOR;return null!=m?e.__assign(e.__assign({},u.generateColorPalette(R)),{label:null!==(d=y)&&void 0!==d?d:""}):e.__assign(e.__assign({},u.generateColorPalette(R)),{label:null})},[An,Tn,Me,fn,$]),bt=t.useCallback(function(n){for(var t,i,o,l,r,c,a,d,v,g=n.split("-").map(Number),f=An[g[0]],p=Tn[g[0]],h=1;h<g.length;h++)(null==f?void 0:f.subsections)&&(f=f.subsections[g[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[g[h]]);if(!f&&!p)return null;var x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,_=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,m=u.safeStringify(null==f?void 0:f.id)||u.safeStringify(null==p?void 0:p.id)||"",y=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!x&&!_&&!y)return e.__assign(e.__assign({},u.generateColorPalette(s.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||m&&(null===(o=Me[m])||void 0===o||o.relevance_score);var R=null!==(r=null!==(l=null==f?void 0:f.evaluationResult)&&void 0!==l?l:null==p?void 0:p.evaluationResult)&&void 0!==r?r:null,S=null===(c=null==R?void 0:R.evaluation_outputs)||void 0===c?void 0:c.output_value,b=null!==(v=null===(d=null===(a=null==R?void 0:R.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===d?void 0:d.label_color)&&void 0!==v?v:s.DEFAULT_DEVIAION_COLOR;return null!=R?e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null!=S?S:""}):e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null})},[An,Tn,Me,fn]),At=t.useCallback(function(){var e,n,t,i,o,l,r,c,s,a,d,v,g,f,p,h,x,_;if(!Qe.current&&!De.current){Qe.current=!0;try{if(!st.current)return;var m=function(e){var n=e.split("-"),t=n[0];if(!et[t]&&!1===$)return!1;if($&&!et["left-".concat(t)]&&!et["right-".concat(t)]&&!et[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!nt[i])return!1;return!0},y=st.current.getBoundingClientRect();He({width:y.width,height:y.height});var R=[];if(En.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=wn.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")}),!De.current){for(var S=0;S<Math.max(An.length,Tn.length);S++){var b=null===(e=Pn.current[S])||void 0===e?void 0:e.current,A=null===(n=Nn.current[S])||void 0===n?void 0:n.current;b&&(b.style.height="auto",b.style.minHeight="0px"),A&&(A.style.height="auto",A.style.minHeight="0px")}$||Object.keys(Ln.current).forEach(function(e){var n,t;if(m(e)){var i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,o=null===(t=Vn.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 T={};En.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=wn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),u=l.getBoundingClientRect();T[i]=Math.max(r.height,u.height)}});var E={left:{},right:{}},I={};if(!De.current)if($){if(de&&null!==ye)if("number"==typeof ye){var B=ye,C=An[B],D=null===(o=Pn.current[B])||void 0===o?void 0:o.current;D&&C&&(C.refIndexes||[]).forEach(function(e){var n,t=Tn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Nn.current[t])||void 0===n?void 0:n.current;if(i&&(et["left-".concat(B)]||et["right-".concat(t)])){var o=Math.max(D.getBoundingClientRect().height,i.getBoundingClientRect().height);E.left[B]=Math.max(E.left[B]||0,o),E.right[t]=Math.max(E.right[t]||0,o)}})}else{var O=ye.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(O){b=null===(l=Ln.current[O])||void 0===l?void 0:l.current,A=null===(r=Vn.current[O])||void 0===r?void 0:r.current;if(b&&A){j=Math.max(b.getBoundingClientRect().height,A.getBoundingClientRect().height);I[O]=Math.max(I[O]||0,j)}}}}else{Object.keys(Ln.current).forEach(function(e){var n,t;if(m(e)){var i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,o=null===(t=Vn.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);I[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(S=0;S<Math.min(An.length,Tn.length);S++){var b=null===(t=Pn.current[S])||void 0===t?void 0:t.current,A=null===(i=Nn.current[S])||void 0===i?void 0:i.current;if(b&&A){var j=Math.max(b.getBoundingClientRect().height,A.getBoundingClientRect().height);E.left[S]=j,E.right[S]=j}}}if(En.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=wn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=T[i];o.style.minHeight="".concat(r,"px"),l.style.minHeight="".concat(r,"px")}}),De.current||(Object.entries(E.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Pn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(E.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Nn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),$||Object.keys(I).forEach(function(e){var n,t,i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,o=null===(t=Vn.current[e])||void 0===t?void 0:t.current;if(i&&o&&I[e]){var l=I[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),$)An.forEach(function(e,n){var t;(null===(t=Pn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,l,r,u,c=Tn.findIndex(function(n){return n.selfIndex===e});if(-1!==c){var s=null===(t=Fn.current[n])||void 0===t?void 0:t.current,a=null===(i=kn.current[c])||void 0===i?void 0:i.current;if(s&&a){var d,v,g,f=s.getBoundingClientRect(),p=a.getBoundingClientRect(),h=f.right-y.left,x=p.left-y.left,_=f.top+f.height/2-y.top,m=p.top+p.height/2-y.top;if(de&&ye===n){var S=null!==(l=null===(o=Je.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,b=S+(null!==(u=null===(r=Je.current)||void 0===r?void 0:r.clientHeight)&&void 0!==u?u:1/0),A=f.top+f.height/2;d=A,v=S,g=b,m=_=Math.max(v,Math.min(g,d))-y.top}var T=St(n);T&&R.push({id:"line-".concat(n,"-").concat(c),x1:h,y1:_,x2:x,y2:m,style:T,sectionIdx:n,targetRightIdx:c})}}})});else{for(S=0;S<Math.min(An.length,Tn.length);S++){var w=null===(c=Pn.current[S])||void 0===c?void 0:c.current,P=null===(s=Nn.current[S])||void 0===s?void 0:s.current;if(w&&P){var N=w.getBoundingClientRect(),F=P.getBoundingClientRect(),k=Math.max(N.top,F.top)+18-y.top,M=(null===(a=Tn[S])||void 0===a?void 0:a.id)||"sec-".concat(S);(Y=St(S))&&R.push({id:M,x1:N.right-y.left,y1:k,x2:F.left-y.left,y2:k,style:Y,sectionIdx:S,hasCognitive:!!((null===(d=An[S])||void 0===d?void 0:d.cognitiveData)||(null===(v=Tn[S])||void 0===v?void 0:v.cognitiveData)||M&&Me[M]),isSubSection:!1})}}Object.keys(Ln.current).forEach(function(e){var n,t,i,o,l,r;if(m(e)){var c=null===(n=Ln.current[e])||void 0===n?void 0:n.current,s=null===(t=Vn.current[e])||void 0===t?void 0:t.current;if(c&&s){for(var a=e.split("-").map(Number),d=An[a[0]],v=Tn[a[0]],g=1;g<a.length;g++)(null==d?void 0:d.subsections)&&(d=d.subsections[a[g]]),(null==v?void 0:v.subsections)&&(v=v.subsections[a[g]]);var f=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(l=v.displayTitle)||void 0===l||l)&&u.hasValue(v.title)),x=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&u.hasValue(v.content));if(f&&p||h&&x){var _=c.getBoundingClientRect(),S=s.getBoundingClientRect(),b=Math.max(_.top,S.top)+16-y.top,A=bt(e);A&&"Not Defined"!==A.label&&R.push({id:"subsec-".concat(e),x1:_.right-y.left,y1:b,x2:S.left-y.left,y2:b,style:A,sectionIdx:a[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(de&&"string"==typeof ye&&ye.includes(u.DEVIATION_BADGE_SEPARATOR)){var L=ye.split(u.DEVIATION_BADGE_SEPARATOR),V=L[0],H=L[1],G=L[2],q=(L[3],"".concat(V).concat(u.DEVIATION_BADGE_SEPARATOR).concat(H)),z=null===(g=Fn.current[q])||void 0===g?void 0:g.current,W=null===(f=kn.current[q])||void 0===f?void 0:f.current;if(z&&W){var Y,K=z.getBoundingClientRect(),U=W.getBoundingClientRect(),X=K.right-y.left,J=U.left-y.left,Q=K.top+K.height/2-y.top,Z=(U.top,U.height,y.top);if($){var ee=null!==(h=null===(p=Je.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,ne=ee+(null!==(_=null===(x=Je.current)||void 0===x?void 0:x.clientHeight)&&void 0!==_?_:1/0);_e=K.top+K.height/2,me=ee,Re=ne,Q=Math.max(me,Math.min(Re,_e))-y.top}Z=Q,(Y=bt(G))&&R.push({id:"line-subsec-".concat(q),x1:X,y1:Q,x2:J,y2:Z,style:Y,sectionIdx:Number(G.split("-")[0]),isSubSection:!0,subSectionKeyPath:ye})}}if(xt(R),gt.current&&ft.current){var te=gt.current.getBoundingClientRect(),ie=ft.current.getBoundingClientRect(),oe=(te.top+te.height/2-y.top+ie.top+ie.height/2-y.top)/2;yt({x1:te.right-y.left,x2:ie.left-y.left,y:oe})}else yt(null);if(Ae.size>0){var le=[],re=Je.current,ue=We.current;if(re&&ue){var ce=[],se=re.getBoundingClientRect().top,ae=ue.getBoundingClientRect().top,ve=se+re.clientHeight,ge=ae+ue.clientHeight,fe=re.scrollTop,pe=ue.scrollTop,he=y.top,xe=function(e,n,t){return Math.max(n,Math.min(t,e))};Ae.forEach(function(e){var n,t,i,o,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=e.split(u.DEVIATION_BADGE_SEPARATOR),c=r[0],s=r[1],a=r[2],d=(r[3],"".concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),v=null===(n=Fn.current[d])||void 0===n?void 0:n.current,g=null===(t=kn.current[d])||void 0===t?void 0:t.current;if(!v||!g)return;var f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=bt(a),x=(P=f.right-y.left)+.5*((N=p.left-y.left-0)-P),_=f.top+f.height/2,m=p.top+p.height/2,R=_-se+fe,S=m-ae+pe,b="conn-subsec-".concat(d);ce.push({lhsScrollY:R,rhsScrollY:S,x1:P,x2:N,containerTop:he,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:b});var A=xe(_,se,ve),T=xe(m,ae,ge),E=A-he,I=T-he,B=m>=ae-4&&m<=ge+4,C="";C=(F=_>=se-4&&_<=ve+4)&&B?u.getBentArrowPath(P,E,N,I):F&&!B?"M ".concat(P,",").concat(E," L ").concat(x,",").concat(E," L ").concat(x,",").concat(I):!F&&B?"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I," L ").concat(N,",").concat(I):"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I),le.push({id:b,pathD:C,style:h,leftIdx:e,rhsArrayIdx:e})}else if($){var D=e,O=An[D];if(!(null===(l=null==O?void 0:O.refIndexes)||void 0===l?void 0:l.length))return;O.refIndexes.forEach(function(e){var n,t,i=Tn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Fn.current[D])||void 0===n?void 0:n.current,l=null===(t=kn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),c=l.getBoundingClientRect(),s=St(D),a=r.right-y.left,d=c.left-y.left-0,v=a+.5*(d-a),g=r.top+r.height/2,f=c.top+c.height/2,p=g-se+fe,h=f-ae+pe,x="conn-".concat(D,"-").concat(i);ce.push({lhsScrollY:p,rhsScrollY:h,x1:a,x2:d,containerTop:he,leftIdx:D,rhsArrayIdx:i,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleId:x});var _=xe(g,se,ve),m=xe(f,ae,ge),R=_-he,S=m-he,b=g>=se-4&&g<=ve+4,A=f>=ae-4&&f<=ge+4,T="";T=b&&A?u.getBentArrowPath(a,R,d,S):b&&!A?"M ".concat(a,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(S):!b&&A?"M ".concat(v,",").concat(R," L ").concat(v,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(v,",").concat(R," L ").concat(v,",").concat(S),le.push({id:x,pathD:T,style:s,leftIdx:D,rhsArrayIdx:i})}}})}else{var j=e,w=j;v=null===(i=Fn.current[j])||void 0===i?void 0:i.current,g=null===(o=kn.current[w])||void 0===o?void 0:o.current;if(!v||!g)return;var P,N;f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=St(j),x=(P=f.right-y.left)+.5*((N=p.left-y.left-0)-P),_=f.top+f.height/2,m=p.top+p.height/2,R=_-se+fe,S=m-ae+pe,b="conn-".concat(j,"-").concat(w);ce.push({lhsScrollY:R,rhsScrollY:S,x1:P,x2:N,containerTop:he,leftIdx:j,rhsArrayIdx:w,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:b});var F;A=xe(_,se,ve),T=xe(m,ae,ge),E=A-he,I=T-he,B=m>=ae-4&&m<=ge+4,C="";C=(F=_>=se-4&&_<=ve+4)&&B?u.getBentArrowPath(P,E,N,I):F&&!B?"M ".concat(P,",").concat(E," L ").concat(x,",").concat(E," L ").concat(x,",").concat(I):!F&&B?"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I," L ").concat(N,",").concat(I):"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I),le.push({id:b,pathD:C,style:h,leftIdx:j,rhsArrayIdx:w})}}),we.current=ce}Be(le)}else Be([]),we.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Qe.current=!1}var _e,me,Re}},[En,An,Tn,Me,fn,Rt,St,$,de,ye,Ae,et,nt]),Tt=t.useCallback(function(){var e,n,t,i,o,l,r,c,s,a,d,v,g,f,p=we.current;if(p.length&&!De.current){var h=null!==(n=null===(e=Je.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=We.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(l=null===(o=Je.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,m=null!==(c=null===(r=We.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,y=null!==(a=null===(s=Je.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==a?a:0,R=null!==(v=null===(d=We.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=y+_,b=R+m,A=null!==(f=null===(g=st.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==f?f:0,T=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+y,t=e.rhsScrollY-x+R,i=je.current[e.styleId+"-stroke"],o=je.current[e.styleId+"-bg"];if(i||o){var l,r=T(n,y,S),c=T(t,R,b),s=r-A,a=c-A,d=n>=y-4&&n<=S+4,v=t>=R-4&&t<=b+4,g=e.x1+.5*(e.x2-e.x1);l=d&&v?u.getBentArrowPath(e.x1,s,e.x2,a):d&&!v?"M ".concat(e.x1,",").concat(s," L ").concat(g,",").concat(s," L ").concat(g,",").concat(a):!d&&v?"M ".concat(g,",").concat(s," L ").concat(g,",").concat(a," L ").concat(e.x2,",").concat(a):"M ".concat(g,",").concat(s," L ").concat(g,",").concat(a),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]);t.useEffect(function(){ke.current=At},[At]);var Et=t.useRef(null),It=t.useRef(null),Bt=t.useCallback(function(){we.current.length>0&&!De.current||(null!==Et.current&&clearTimeout(Et.current),Et.current=setTimeout(function(){ke.current(),Et.current=null},50))},[]),Ct=t.useCallback(function(){_e(!0),pe(!1),null!==It.current&&clearTimeout(It.current),null!==Et.current&&(clearTimeout(Et.current),Et.current=null),It.current=setTimeout(function(){var e,n,t,i,o,l,r,c;if(we.current=[],Ne.current&&null!==Fe.current&&null!==dt.current){var s=Fe.current,a=dt.current,d=null,v=null,g=null,f=null;if("string"==typeof s&&s.includes(u.DEVIATION_BADGE_SEPARATOR)){var p=s.split(u.DEVIATION_BADGE_SEPARATOR),h="".concat(p[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(p[1]);d=(null===(e=Fn.current[h])||void 0===e?void 0:e.current)||null,v=(null===(n=kn.current[h])||void 0===n?void 0:n.current)||null,g=(null===(t=Ln.current[p[2]])||void 0===t?void 0:t.current)||null,f=(null===(i=Vn.current[p[3]])||void 0===i?void 0:i.current)||null}else d=(null===(o=Hn.current[s])||void 0===o?void 0:o.current)||null,g=(null===(l=Pn.current[s])||void 0===l?void 0:l.current)||null,v=(null===(r=Mn.current[a])||void 0===r?void 0:r.current)||null,f=(null===(c=Nn.current[a])||void 0===c?void 0:c.current)||null;if(d&&v&&g&&f){if(g.style.paddingTop="0px",f.style.paddingTop="0px",!$){var x=d.getBoundingClientRect(),_=v.getBoundingClientRect(),m=x.top-_.top;m>0?f.style.paddingTop="".concat(m,"px"):m<0&&(g.style.paddingTop="".concat(Math.abs(m),"px"))}var y=Je.current,R=We.current;if(y&&R){var S=d.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,b=v.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop-(S-y.scrollTop);Math.abs(R.scrollTop-b)>1&&(R.scrollTop=b)}}}ke.current(),Ne.current&&pe(!0),_e(!1),It.current=null},150)},[$,An,Tn]),Dt=t.useCallback(function(e){var n,t,i,o,l,r,c,s,a,d;if(!Se.current){if($||Bt(),Ne.current){var v=Fe.current,g=dt.current,f=Je.current,p=We.current;if(null!==v&&null!==g&&f&&p){var h="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Fn.current["".concat(v.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(v.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=Hn.current[v])||void 0===t?void 0:t.current,x="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=kn.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=Mn.current[g])||void 0===o?void 0:o.current;if(h&&x){var _=h.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop,m=x.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop;if(e.currentTarget===f){var y=m-(_-f.scrollTop),R=p.scrollHeight-p.clientHeight,S=Math.max(0,Math.min(y,R));Math.abs(p.scrollTop-S)>1&&(p.scrollTop=S)}else if(e.currentTarget===p){var b=_-(m-p.scrollTop),A=f.scrollHeight-f.clientHeight,T=Math.max(0,Math.min(b,A));Math.abs(f.scrollTop-T)>1&&(f.scrollTop=T)}if(vt.current){var E=void 0,I=void 0;if("string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR)){var B=v.split(u.DEVIATION_BADGE_SEPARATOR),C="".concat(B[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(B[1]);E=null===(l=Fn.current[C])||void 0===l?void 0:l.current,I=null===(r=kn.current[C])||void 0===r?void 0:r.current}else E=null===(c=Fn.current[v])||void 0===c?void 0:c.current,I=null===(s=kn.current[g])||void 0===s?void 0:s.current;var D=null!==(d=null===(a=st.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==d?d:0,O=f.getBoundingClientRect().top,j=O+f.clientHeight;p.getBoundingClientRect().top;p.clientHeight;if(E&&I){var w=E.getBoundingClientRect(),P=I.getBoundingClientRect(),N=w.top+w.height/2;P.top,P.height;var F=((M=N,L=O,V=j,Math.max(L,Math.min(V,M)))-D).toString();vt.current.setAttribute("y1",F),vt.current.setAttribute("y2",F);var k=N>=O-4&&N<=j+4;vt.current.setAttribute("visibility",k?"visible":"hidden")}}}}}var M,L,V;we.current.length>0&&!Pe.current&&(Pe.current=!0,requestAnimationFrame(function(){Tt(),Pe.current=!1}))}},[Tt,$,Bt]);t.useEffect(function(){var e=setTimeout(Bt,250);window.addEventListener("resize",Ct);var n=null,t=null;return qe.current&&(n=new ResizeObserver(Bt)).observe(qe.current),st.current&&(t=new ResizeObserver(Bt)).observe(st.current),function(){clearTimeout(e),null!==Et.current&&clearTimeout(Et.current),null!==It.current&&clearTimeout(It.current),window.removeEventListener("resize",Ct),null==n||n.disconnect(),null==t||t.disconnect()}},[Sn,bn,Wn,En,et,nt,An,Tn,fn,Bt,Ct,de,ye,fe,Ae]),t.useEffect(function(){Ne.current=de},[de]),t.useEffect(function(){Fe.current=ye},[ye]);var Ot=t.useCallback(function(e,n,t){var i,o,l,r,c,s,a=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,d=null==t?void 0:t.onReady,v=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";if(gn(),null!=e)if(n)se("No counterpart exists for this section.");else if(de&&ye===e)a?Zn():null==d||d();else{if(!$){var g=Fe.current,f=dt.current;if(null!==g)if("string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)){var p=g.split(u.DEVIATION_BADGE_SEPARATOR);(h=null===(l=Ln.current[p[2]])||void 0===l?void 0:l.current)&&(h.style.paddingTop="0px")}else{var h;(h=null===(r=Pn.current[g])||void 0===r?void 0:r.current)&&(h.style.paddingTop="0px")}if(null!==f)if("string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)){p=f.split(u.DEVIATION_BADGE_SEPARATOR);(x=null===(c=Vn.current[p[3]])||void 0===c?void 0:c.current)&&(x.style.paddingTop="0px")}else{var x;(x=null===(s=Nn.current[f])||void 0===s?void 0:s.current)&&(x.style.paddingTop="0px")}}Te(new Set),Be([]),we.current=[],re(!0),Se.current=!0,Re(e),Fe.current=e,ve(!0),Ne.current=!0,pe(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ue.current&&(Ue.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,l,r,c,s,a,g,f=null,p=null,h=null,x=null,_=null;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var m=e.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(m[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(m[1]);f=(null===(n=Fn.current[y])||void 0===n?void 0:n.current)||null,_=(p=(null===(t=kn.current[y])||void 0===t?void 0:t.current)||null)?e:null,h=(null===(i=Ln.current[m[2]])||void 0===i?void 0:i.current)||null,x=(null===(o=Vn.current[m[3]])||void 0===o?void 0:o.current)||null}else if(f=(null===(l=Hn.current[e])||void 0===l?void 0:l.current)||null,h=(null===(r=Pn.current[e])||void 0===r?void 0:r.current)||null,$){var R=An[e],S=(null==R?void 0:R.refIndexes)||[];if(S.length>0){var b=S[0],A=Tn.findIndex(function(e){return e.selfIndex===b});-1!==A&&(p=(null===(a=Mn.current[A])||void 0===a?void 0:a.current)||null,x=(null===(g=Nn.current[A])||void 0===g?void 0:g.current)||null,_=A)}}else p=(null===(c=Mn.current[e])||void 0===c?void 0:c.current)||null,x=(null===(s=Nn.current[e])||void 0===s?void 0:s.current)||null,_=p?e:null;dt.current=_;var T=Je.current,E=We.current;if(!f||!T)return Se.current=!1,re(!1),void(null==d||d());if(!p||!E)return pe(!0),ke.current(),Se.current=!1,re(!1),void(null==d||d());if(!$){var I=f.getBoundingClientRect(),B=p.getBoundingClientRect(),C=I.top-B.top;h&&x&&(h.style.paddingTop="0px",x.style.paddingTop="0px",C>0?x.style.paddingTop="".concat(C,"px"):C<0&&(h.style.paddingTop="".concat(Math.abs(C),"px")));var D=0;D="right"===v?p?p.getBoundingClientRect().top:(null==x?void 0:x.getBoundingClientRect().top)||0:f?f.getBoundingClientRect().top:(null==h?void 0:h.getBoundingClientRect().top)||0;var O=qe.current,j=O?O.scrollTop+D-150:0;return O?void u.smoothScrollTo(O,j,200,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()}):(pe(!0),ke.current(),Se.current=!1,re(!1),void(null==d||d()))}var w=f.getBoundingClientRect().top-T.getBoundingClientRect().top+T.scrollTop,P=p.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop,N=200;if("left"===v){var F=P-(w-T.scrollTop);F<0&&Ye.current&&(Ye.current.style.height="".concat(Math.abs(F),"px")),requestAnimationFrame(function(){var e,n=E.scrollHeight-E.clientHeight;if(F<0)e=0;else{if(F>n){var t=F-n;return Ke.current&&(Ke.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(E,F,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}e=F}u.smoothScrollTo(E,e,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}else{var k=w-(P-E.scrollTop);k<0&&Ue.current&&(Ue.current.style.height="".concat(Math.abs(k),"px")),requestAnimationFrame(function(){var e,n=T.scrollHeight-T.clientHeight;if(k<0)e=0;else{if(k>n){var t=k-n;return Xe.current&&(Xe.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(T,k,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}e=k}u.smoothScrollTo(T,e,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}})}},[ye,gn,Tn,de,$,An,Zn]),jt=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;vn();var c="left";(null===(o=We.current)||void 0===o?void 0:o.contains(r))&&(c="right"),t?l&&cn({open:!0,anchorEl:r,summary:i}):Ot(n,t,l?{toggleIfSame:!1,sourceSide:c,onReady:function(){cn({open:!0,anchorEl:r,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[Ot,vn,cn]),wt=t.useCallback(function(){var e,n=nn.sectionIdx,t=nn.isOrphan;if(sn(),null!=n){var i="left";nn.anchorEl&&(null===(e=We.current)||void 0===e?void 0:e.contains(nn.anchorEl))&&(i="right"),Ot(n,t,{sourceSide:i})}},[Ot,nn.isOrphan,nn.sectionIdx,nn.anchorEl,sn]),Pt=t.useCallback(function(){sn(),Zn()},[sn,Zn]),Nt=null!==nn.sectionIdx&&Ae.has(nn.sectionIdx),Ft=_.useDeviationNavigation({proposedSections:An,existingSections:Tn,parentDeviationRecord:In,expandedSections:et,maintainRelativeOrder:!!$,scrollContainerRef:qe,leftContainerRef:Je,lhsBadgeRefs:Fn,rhsBadgeRefs:kn}),kt=Ft.showDeviationNavigation,Mt=Ft.showOpenNodeRef,Lt=t.useMemo(function(){if(!Q)return null;for(var e in In){if((In[e]||[]).some(function(e){return e.id===Q}))return e}return null},[Q,In]),Vt=t.useRef(null);t.useEffect(function(){if(Q&&Vt.current!==Q){var n=!1,t=0,i=null,o=150,l=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},r=function(){var c,s,a,d;if(!n){var v=null,g=null;for(var f in In){var p=In[f].find(function(e){return e.id===Q});if(p){v=f,g=p;break}}if(g&&v){var h=An.findIndex(function(e){return e.id===v});if(!($?!!et["left-".concat(h)]:!!et[String(h)])&&h>=0)return it(h,"left"),t+=1,void(i=setTimeout(r,450));var x=l(An,g.id),_=l(Tn,g.id);if(x&&!_){var m=x.split("-"),y=Number(m[0]);if($){var R=null===(s=null===(c=An[y])||void 0===c?void 0:c.refIndexes)||void 0===s?void 0:s[0],S=Tn.findIndex(function(e){return e.selfIndex===R});-1!==S&&(y=S)}_=e.__spreadArray([y],m.slice(1),!0).join("-")}if(x&&_){var b="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0").concat(u.DEVIATION_BADGE_SEPARATOR).concat(x).concat(u.DEVIATION_BADGE_SEPARATOR).concat(_),A="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0"),T=null===(a=Fn.current[A])||void 0===a?void 0:a.current,E=null===(d=kn.current[A])||void 0===d?void 0:d.current,I=$?Je.current:qe.current;if(T&&I){var B=T.getBoundingClientRect();if(0===B.height)return void((t+=1)<20&&(i=setTimeout(r,o)));var C=I.getBoundingClientRect(),D=B.top-C.top+I.scrollTop-C.height/2+B.height/2,O=function(){var e=window.getComputedStyle(T).color;T.style.transition="box-shadow 300ms ease-in-out",T.style.boxShadow="0 0 10px ".concat(e),E&&(E.style.transition="box-shadow 300ms ease-in-out",E.style.boxShadow="0 0 10px ".concat(e)),setTimeout(function(){T&&(T.style.boxShadow=""),E&&(E.style.boxShadow="")},2e3)},j=function(){var e,n,t,i=(null==g?void 0:g.evaluationResult)||(null===(e=null==J?void 0:J[null==g?void 0:g.id])||void 0===e?void 0:e.evaluation_result)||(null===(t=null===(n=null==H?void 0:H.nodes)||void 0===n?void 0:n[null==g?void 0:g.id])||void 0===t?void 0:t.evaluation_result)||null,o=(null==i?void 0:i.deviations)||{},l=Object.keys(o).sort()[0]||null,r=l?o[l]:null,u=(null==r?void 0:r.deviation_summary)||"";cn({open:!0,anchorEl:T,summary:{deviation_summary:u,deviation_title:null==i?void 0:i.deviation_title,evaluation_outputs:null==i?void 0:i.evaluation_outputs}})};Vt.current=Q,$?(I.scrollTo({top:D,behavior:"smooth"}),Ot(b,!1,{toggleIfSame:!1}),j(),setTimeout(function(){ke.current()},0),O()):u.smoothScrollTo(I,D,300,function(){n||(Ot(b,!1,{toggleIfSame:!1}),j(),setTimeout(function(){ke.current()},0),O())})}else(t+=1)<20&&(i=setTimeout(r,o))}else(t+=1)<20&&(i=setTimeout(r,o))}else(t+=1)<20&&(i=setTimeout(r,o))}};return i=setTimeout(r,o),function(){n=!0,i&&clearTimeout(i)}}},[Q,In,An,Tn,$,et,it,J,H,cn,Ot]);var Ht=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,s=void 0===c?"":c;return n.jsx(R.default,{section:t,keyPath:i,depth:l,columnKey:u,parentNodeId:s,expandedSubSections:nt,setExpandedSubSections:tt,maintainRelativeOrder:$||!1,proposedSections:An,existingSections:Tn,treeData:H,deviationNumberRegistry:Bn,connectedSections:Ae,activeSideBySideSection:ye,resolvedMarkdownStyles:Ge,getSubSectionRef:qn,getSubSectionCompareStyle:bt,getBadgeRef:zn,openMoreFunctionsPopup:rt,openSummaryPopup:jt,resetSideBySide:Zn,setConnectedSections:Te,setConnectedLines:Be,cachedConnectedPositions:we})};return n.jsxs(i.Box,e.__assign({ref:ze,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},$?{}:{overflow:"visible"}),{position:"relative"})},{children:[te&&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,{})})),un.open&&n.jsx(S.default,{open:un.open,anchorEl:un.anchorEl,containerEl:at.current,clipTopEl:gt.current,onClose:Pt,summary:un.summary}),n.jsx(d.default,{open:nn.open,anchorEl:nn.anchorEl,sectionTitle:nn.sectionTitle,referenceSectionTitle:nn.refSectionTitle,onClose:gn,onOpenCognitiveCompare:ut,onOpenSideBySide:wt,onConnect:ct,isConnected:Nt,isOrphan:nn.isOrphan}),$e.open&&n.jsx(a.default,{open:$e.open,popupRef:dn,position:on,popupConfig:U,onClose:function(){ln(null),en(function(n){return e.__assign(e.__assign({},n),{open:!1})}),an(null)},markdownStyles:W,sectionTitle:$e.sectionTitle,referenceSectionTitle:$e.refSectionTitle,cognitiveData:$e.cognitiveData,anchorEl:$e.anchorEl,sectionAnchorEl:$e.sectionAnchorEl,scrollContainerEl:qe.current,badgeStyle:$e.badgeStyle,docData:$e.docData,deviationData:$e.deviationData,isLoading:$e.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ce,autoHideDuration:8e3,onClose:function(){return se(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return se(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ce}))})),n.jsx(m.default,{componentHeaderText:V,displayConfig:K,maintainRelativeOrder:$,onToggleView:function(e){ie(!0),setTimeout(function(){ee(!e),Zn(),Te(new Set),Be([]),we.current=[],setTimeout(function(){ie(!1)},400)},50)}}),n.jsx(i.Box,e.__assign({ref:qe,onScroll:Dt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:$?"hidden":"auto",borderTop:Yn&&Kn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},$?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:st,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},$?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Ce,style:{position:"absolute",top:0,left:0,width:Ve.width||"100%",height:Ve.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:xe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[mt&&n.jsx("g",{children:n.jsx("line",{x1:mt.x1,y1:mt.y,x2:mt.x2,y2:mt.y,stroke:Qn.badgeBorder,strokeWidth:"1.5"})}),ht.map(function(t){var r,c,a,d,v,f,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?de&&ye===t.subSectionKeyPath&&fe:de&&ye===t.sectionIdx&&fe)return n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{ref:vt,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id);if(!$){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),_=An[t.sectionIdx]||{title:"",content:""},m=Tn[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var y=t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR)[2].split("-").map(Number),R=An[y[0]],S=Tn[y[0]],b=(null==R?void 0:R.title)||"",A=(null==S?void 0:S.title)||"",T=1;T<y.length;T++)(null==R?void 0:R.subsections)&&(R=R.subsections[y[T]]),(null==S?void 0:S.subsections)&&(S=S.subsections[y[T]]);R&&(_=e.__assign(e.__assign({},R),{title:b||R.title})),S&&(m=e.__assign(e.__assign({},S),{title:A||S.title}))}var E=!(null===(r=_.cognitiveData)||void 0===r?void 0:r.isMissingRationale)||Boolean(null===(a=null===(c=_.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===a?void 0:a.length),I=(null===(f=null===(v=null===(d=_.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.length)||!1,B=E||I;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(),B&&($e.open&&rn===t.id?vn():(an(t.id),lt(ot(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:B?"pointer":"default"}},{children:[t.style.badgeText===s.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(g.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),B&&n.jsx(o.ChevronDown,{size:11,style:{transform:$e.open&&rn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ie.map(function(t){var i,o=t.pathD,l=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",r="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),c="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:r,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),n.jsx("path",{ref:function(e){je.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){je.current[c]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(r,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},$?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:gt,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:Je,onScroll:Dt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},$?{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:Ue,style:{width:"100%",height:"0px",flexShrink:0}}),Dn&&An.map(function(t,l){var r,c,s=!t.title&&!t.content;if($&&s)return null;var a=t,d=St(l,"left"),v=$?!(null===(r=a.refIndexes)||void 0===r?void 0:r.length)||a.selfIndex<0:!Tn[l],f=$?"number"==typeof a.selfIndex&&a.selfIndex>=0?a.selfIndex+1:null:l+1,p=Ae.has(l),h=u.extractDeviationScore(a.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:Gn(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:Pn.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(y.default,{section:t,idx:l,columnKey:"left",colRef:Gn("left-accordion-".concat(l)),mb:0,treeData:H,proposedSections:An,existingSections:Tn,deviationNumberRegistry:Bn,getSectionCompareStyle:St,getBadgeRef:zn,connectedSections:Ae,openMoreFunctionsPopup:rt,openSummaryPopup:jt,deviationNodeIdToView:Q,deviationTargetParentId:Lt,parentNodeId:(null===(c=null==H?void 0:H.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:$?!!et["left-".concat(l)]:!!et[String(l)],onToggle:function(){et[$?"left-".concat(l):String(l)]&&sn(),it(l,"left")},navigation:t.id?kt[t.id]:null,showOpenNodeRef:Mt,resolvedMarkdownStyles:Ge,maintainRelativeOrder:$,renderSubSections:Ht})})),$&&d&&n.jsxs(i.Box,e.__assign({ref:Fn.current[l],onClick:function(e){var n=$?Tn.find(function(e){var n;return null===(n=a.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Tn[l]||{title:"",content:""};rt(e,t,v,n,l,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!K.isLoading||null!=a.evaluationResult&&null!=a.evaluationResult?v?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(g.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(l))}),n.jsx("div",{ref:Xe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:at,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(),$e.open&&rn===Un?vn():(an(Un),lt(ot(n.currentTarget,{title:"",content:"",evaluationResult:Xn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Un,!0,e.__assign(e.__assign({},Qn),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:Qn.badgeBg,color:Qn.badgeText,border:"1px solid ".concat(Qn.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Jn?Jn:n.jsx(g.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:$e.open&&rn===Un?"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},$?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[le&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:ft,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:yn,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:yn}))}))})),n.jsxs(i.Box,e.__assign({ref:We,onScroll:Dt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},$?{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:Ye,style:{width:"100%",height:"0px",flexShrink:0}}),Dn&&Tn.map(function(t,o){var l,r=t,u=[],c=!1,s=null,a=-1;if($){u=An.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}),a=An.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0});var d=An.findIndex(function(e,n){var t;return Ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(r.selfIndex))});(c=-1!==d)&&(s=St(d))}else u=[o+1],(c=Ae.has(o))&&(s=St(o));var v=St($&&-1!==a?a:o);return n.jsx(i.Box,e.__assign({ref:Mn.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:Nn.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(y.default,{section:t,idx:o,columnKey:"right",colRef:Gn("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(l=null==H?void 0:H.input_index_map)||void 0===l?void 0:l[1])||"",isExpanded:$?!!et["right-".concat(o)]:!!et[String(o)],treeData:H,proposedSections:An,existingSections:Tn,deviationNumberRegistry:Bn,getBadgeRef:zn,getSectionCompareStyle:St,connectedSections:Ae,openMoreFunctionsPopup:rt,openSummaryPopup:jt,deviationNodeIdToView:Q,deviationTargetParentId:Lt,onToggle:function(){et[$?"right-".concat(o):String(o)]&&sn(),it(o,"right")},navigation:t.id?kt[t.id]:null,showOpenNodeRef:Mt,resolvedMarkdownStyles:Ge,maintainRelativeOrder:$,renderSubSections:Ht})})),$&&!le&&v&&n.jsx(i.Box,e.__assign({ref:kn.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:Ke,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"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),s=require("./CognitiveCompareConstants.js"),a=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),g=require("./components/ThreeDotsLoader.js"),f=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),_=require("./hooks/useDeviationNavigation.js"),m=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),S=require("./components/CognitiveSummaryPopup.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(b){var A,T,E,I,B,C,D,O,j,w,P,N,F,k,M,L=b.componentHeaderText,V=void 0===L?s.DEFAULT_COMPONENT_HEADER_TEXT:L,H=b.treeData,G=b.comparisonConfig,q=b.leftColumnTitleText,z=b.rightColumnTitleText,W=b.markdownStyles,Y=b.displayConfig,K=void 0===Y?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0}:Y,U=b.popupConfig,X=b.deviationData,J=void 0===X?{}:X,Q=b.deviationNodeIdToView,Z=t.useState(K.maintainRelativeOrder),$=Z[0],ee=Z[1],ne=t.useState(!1),te=ne[0],ie=ne[1],oe=t.useState(!1),le=oe[0],re=oe[1],ue=t.useState(null),ce=ue[0],se=ue[1],ae=t.useState(!1),de=ae[0],ve=ae[1],ge=t.useState(!1),fe=ge[0],pe=ge[1],he=t.useState(!1),xe=he[0],_e=he[1],me=t.useState(null),Re=me[0],ye=me[1],Se=t.useRef(!1),be=t.useState(new Set),Ae=be[0],Te=be[1],Ee=t.useState([]),Ie=Ee[0],Be=Ee[1],Ce=t.useRef(null),De=t.useRef(!1),Oe=t.useRef(null),je=t.useRef({}),we=t.useRef([]),Pe=t.useRef(!1),Ne=t.useRef(!1),Fe=t.useRef(null),ke=t.useRef(function(){}),Me=t.useMemo(function(){return(null==H?void 0:H.cognitive_decisioning)||{}},[H]),Le=t.useState({width:0,height:0}),Ve=Le[0],He=Le[1],Ge=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),W)},[W]),qe=t.useRef(null),ze=t.useRef(null),We=t.useRef(null),Ye=t.useRef(null),Ke=t.useRef(null),Ue=t.useRef(null),Xe=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(!1),Ze=p.useComparePopups(qe),$e=Ze.cognitivePopup,en=Ze.setCognitivePopup,nn=Ze.moreFunctions,tn=Ze.setMoreFunctions,on=Ze.position,ln=Ze.setPosition,rn=Ze.activeBadgeId,un=Ze.summaryPopup,cn=Ze.setSummaryPopup,sn=Ze.closeSummaryPopup,an=Ze.setActiveBadgeId,dn=Ze.popupRef,vn=Ze.closeCognitivePopup,gn=Ze.closeMoreFunctionsPopup,fn=t.useMemo(function(){var e,n,t,i,o,l,r;return{fields:null!==(e=null==G?void 0:G.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==G?void 0:G.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==G?void 0:G.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(r=null===(l=null==G?void 0:G.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[G]),pn=t.useState(null),hn=pn[0];pn[1];var xn=null===(E=null===(A=null==H?void 0:H.documents)||void 0===A?void 0:A[null===(T=null==H?void 0:H.input_index_map)||void 0===T?void 0:T[0]])||void 0===E?void 0:E.title,_n=null===(C=null===(I=null==H?void 0:H.documents)||void 0===I?void 0:I[null===(B=null==H?void 0:H.input_index_map)||void 0===B?void 0:B[1]])||void 0===C?void 0:C.title,mn=u.safeStringify(q||xn||"Uploaded Contract"),Rn=u.safeStringify(z||_n||"Reference Template"),yn=f.useCognitiveTreeData(H,$,J,fn),Sn=yn.activeProposed,bn=yn.existingRule,An=yn.proposedSections,Tn=yn.existingSections,En=yn.visibleFields,In=yn.parentDeviationRecord,Bn=yn.deviationNumberRegistry,Cn=yn.parseError;t.useEffect(function(){Cn&&se("Failed to load comparison: ".concat(Cn))},[Cn]);var Dn=An.length>0||Tn.length>0,On=h.useSectionRefs(En.map(function(e){return e.key}),Math.max(An.length,Tn.length)),jn=On.leftRefs,wn=On.rightRefs,Pn=On.sectionLeftRefs,Nn=On.sectionRightRefs,Fn=On.lhsBadgeRefs,kn=On.rhsBadgeRefs,Mn=On.sectionRightRowRefs,Ln=On.subSectionLeftRefs,Vn=On.subSectionRightRefs,Hn=On.sectionRowRefs,Gn=On.getSectionRowRef,qn=On.getSubSectionRef,zn=On.getBadgeRef,Wn=bn.analysis,Yn=u.safeStringify(null===(O=null===(D=null==Wn?void 0:Wn.rule_difference_comparison)||void 0===D?void 0:D.summary)||void 0===O?void 0:O.overall_summary),Kn=!!Yn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Un=null!==(j=null==H?void 0:H.base_root_id)&&void 0!==j?j:"-1";null==H||H[Un];var Xn=(null===(w=null==J?void 0:J[Un])||void 0===w?void 0:w.evaluation_result)||(null===(N=null===(P=null==H?void 0:H.nodes)||void 0===P?void 0:P[Un])||void 0===N?void 0:N.evaluation_result)||null,Jn=u.extractDeviationScore(Xn),Qn=u.generateColorPalette(null!==(M=null===(k=null===(F=null==Xn?void 0:Xn.evaluation_outputs)||void 0===F?void 0:F.metadata)||void 0===k?void 0:k.label_color)&&void 0!==M?M:""),Zn=t.useCallback(function(){var e,n,t,i;ve(!1),Ne.current=!1;var o=Fe.current,l=dt.current;if(null!==o)if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR);(c=null===(e=Ln.current[r[2]])||void 0===e?void 0:e.current)&&(c.style.paddingTop="0px")}else{var c;(c=null===(n=Pn.current[o])||void 0===n?void 0:n.current)&&(c.style.paddingTop="0px")}if(null!==l)if("string"==typeof l&&l.includes(u.DEVIATION_BADGE_SEPARATOR)){r=l.split(u.DEVIATION_BADGE_SEPARATOR);(s=null===(t=Vn.current[r[3]])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}else{var s;(s=null===(i=Nn.current[l])||void 0===i?void 0:i.current)&&(s.style.paddingTop="0px")}ye(null),Fe.current=null,dt.current=null,pe(!1),re(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ue.current&&(Ue.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px")},[]),$n=x.useAccordionState({maintainRelativeOrder:!!$,proposedSections:An,existingSections:Tn,activeSideBySideSection:Re,connectedSections:Ae,resetSideBySide:Zn,setConnectedSections:Te,setConnectedLines:Be,cachedConnectedPositions:we,svgContainerRef:Ce,isAnimatingRef:De,animationTimerRef:Oe,calculateLinesRef:ke,sectionLeftRefs:Pn,sectionRightRefs:Nn,subSectionLeftRefs:Ln,subSectionRightRefs:Vn}),et=$n.expandedSections,nt=$n.expandedSubSections,tt=$n.setExpandedSubSections,it=$n.toggleSection,ot=t.useCallback(function(e,n,t,i,o,l,r){var c,s,a,d=u.safeStringify(null==n?void 0:n.id)||u.safeStringify(null==t?void 0:t.id)||"",v=(d?Me[d]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:d,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(c=Hn.current[i])||void 0===c?void 0:c.current)&&void 0!==s?s:null;return{isLoading:null!==(a=null==K?void 0:K.isLoading)&&void 0!==a&&a,open:!0,sectionTitle:(null==n?void 0:n.displayTitle)?null==n?void 0:n.title:"no title",refSectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:i,docData:{documents:null==H?void 0:H.documents,input_index_map:null==H?void 0:H.input_index_map},deviationData:(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,isOrphan:!!o}},[Me,H]),lt=t.useCallback(function(e){gn(),ln(null),en(e)},[gn]),rt=function(e,n,t,i,o,l){e.stopPropagation(),nn.open&&nn.sectionIdx===o?gn():(vn(),tn(ot(e.currentTarget,n,i,o,t,l)))},ut=t.useCallback(function(){null!==nn.sectionIdx&&nn.anchorEl?lt(e.__assign(e.__assign({},nn),{open:!0})):gn()},[nn,gn,lt]),ct=t.useCallback(function(){var e=nn.sectionIdx,n=nn.isOrphan;gn(),sn(),null!==e&&(n?se("No counterpart exists to connect to."):(Ne.current&&Zn(),Be([]),we.current=[],Te(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){ke.current&&ke.current()},50)))},[nn.sectionIdx,nn.isOrphan,gn,sn,Zn]),st=t.useRef(null),at=t.useRef(null),dt=t.useRef(null),vt=t.useRef(null),gt=t.useRef(null),ft=t.useRef(null),pt=t.useState([]),ht=pt[0],xt=pt[1];t.useRef(null);var _t=t.useState(null),mt=_t[0],Rt=_t[1];t.useEffect(function(){if(hn){var e=fn.fields.find(function(e){return e.analysisKey===hn||e.key===hn});if(e){var n=jn.current[e.key]||wn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[hn,fn.fields]);var yt=t.useCallback(function(e){var n,t,i,o,l,r,u,c,s,a=null===(n=null==Wn?void 0:Wn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!a||!a[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=a[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(l=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===l?void 0:l.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var g=d.mappings[0]||{};return{score:d.score,relation:g.relation||"",highlightsA:(null===(r=g.highlights)||void 0===r?void 0:r.ruleA_spans)||[],highlightsB:(null===(u=g.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(s=d.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}},[Wn]),St=t.useCallback(function(n,t){var i,o,l,r,c,a,d;void 0===t&&(t="left");var v=null,g=null;if("left"===t)if(v=An[n],$&&v){var f=Tn.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});g=f.find(function(e){return e.evaluationResult})||f[0]}else g=Tn[n];else if(g=Tn[n],$&&g){var p=An.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(g.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=An[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,_=!(!(null==v?void 0:v.cognitiveData)&&!(null==g?void 0:g.cognitiveData));if(!h&&!x&&!_)return e.__assign(e.__assign({},u.generateColorPalette(s.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var m=null!==(o=null!==(i=null==v?void 0:v.evaluationResult)&&void 0!==i?i:null==g?void 0:g.evaluationResult)&&void 0!==o?o:null,R=null===(l=null==m?void 0:m.evaluation_outputs)||void 0===l?void 0:l.output_value,y=null!==(a=null===(c=null===(r=null==m?void 0:m.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===c?void 0:c.label_color)&&void 0!==a?a:s.DEFAULT_DEVIAION_COLOR;return null!=m?e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null!==(d=R)&&void 0!==d?d:""}):e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null})},[An,Tn,Me,fn,$]),bt=t.useCallback(function(n){for(var t,i,o,l,r,c,a,d,v,g=n.split("-").map(Number),f=An[g[0]],p=Tn[g[0]],h=1;h<g.length;h++)(null==f?void 0:f.subsections)&&(f=f.subsections[g[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[g[h]]);if(!f&&!p)return null;var x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,_=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,m=u.safeStringify(null==f?void 0:f.id)||u.safeStringify(null==p?void 0:p.id)||"",R=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!x&&!_&&!R)return e.__assign(e.__assign({},u.generateColorPalette(s.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||m&&(null===(o=Me[m])||void 0===o||o.relevance_score);var y=null!==(r=null!==(l=null==f?void 0:f.evaluationResult)&&void 0!==l?l:null==p?void 0:p.evaluationResult)&&void 0!==r?r:null,S=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.output_value,b=null!==(v=null===(d=null===(a=null==y?void 0:y.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===d?void 0:d.label_color)&&void 0!==v?v:s.DEFAULT_DEVIAION_COLOR;return null!=y?e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null!=S?S:""}):e.__assign(e.__assign({},u.generateColorPalette(b)),{label:null})},[An,Tn,Me,fn]),At=t.useCallback(function(){var e,n,t,i,o,l,r,c,s,a,d,v,g,f,p,h,x,_;if(!Qe.current&&!De.current){Qe.current=!0;try{if(!st.current)return;var m=function(e){var n=e.split("-"),t=n[0];if(!et[t]&&!1===$)return!1;if($&&!et["left-".concat(t)]&&!et["right-".concat(t)]&&!et[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!nt[i])return!1;return!0},R=st.current.getBoundingClientRect();He({width:R.width,height:R.height});var y=[];if(En.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=wn.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")}),!De.current){for(var S=0;S<Math.max(An.length,Tn.length);S++){var b=null===(e=Pn.current[S])||void 0===e?void 0:e.current,A=null===(n=Nn.current[S])||void 0===n?void 0:n.current;b&&(b.style.height="auto",b.style.minHeight="0px"),A&&(A.style.height="auto",A.style.minHeight="0px")}$||Object.keys(Ln.current).forEach(function(e){var n,t;if(m(e)){var i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,o=null===(t=Vn.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 T={};En.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=wn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),u=l.getBoundingClientRect();T[i]=Math.max(r.height,u.height)}});var E={left:{},right:{}},I={};if(!De.current)if($){if(de&&null!==Re)if("number"==typeof Re){var B=Re,C=An[B],D=null===(o=Pn.current[B])||void 0===o?void 0:o.current;D&&C&&(C.refIndexes||[]).forEach(function(e){var n,t=Tn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Nn.current[t])||void 0===n?void 0:n.current;if(i&&(et["left-".concat(B)]||et["right-".concat(t)])){var o=Math.max(D.getBoundingClientRect().height,i.getBoundingClientRect().height);E.left[B]=Math.max(E.left[B]||0,o),E.right[t]=Math.max(E.right[t]||0,o)}})}else{var O=Re.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(O){b=null===(l=Ln.current[O])||void 0===l?void 0:l.current,A=null===(r=Vn.current[O])||void 0===r?void 0:r.current;if(b&&A){j=Math.max(b.getBoundingClientRect().height,A.getBoundingClientRect().height);I[O]=Math.max(I[O]||0,j)}}}}else{Object.keys(Ln.current).forEach(function(e){var n,t;if(m(e)){var i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,o=null===(t=Vn.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);I[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(S=0;S<Math.min(An.length,Tn.length);S++){var b=null===(t=Pn.current[S])||void 0===t?void 0:t.current,A=null===(i=Nn.current[S])||void 0===i?void 0:i.current;if(b&&A){var j=Math.max(b.getBoundingClientRect().height,A.getBoundingClientRect().height);E.left[S]=j,E.right[S]=j}}}if(En.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=wn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=T[i];o.style.minHeight="".concat(r,"px"),l.style.minHeight="".concat(r,"px")}}),De.current||(Object.entries(E.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Pn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(E.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Nn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),$||Object.keys(I).forEach(function(e){var n,t,i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,o=null===(t=Vn.current[e])||void 0===t?void 0:t.current;if(i&&o&&I[e]){var l=I[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),$)An.forEach(function(e,n){var t;(null===(t=Pn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,l,r,u,c=Tn.findIndex(function(n){return n.selfIndex===e});if(-1!==c){var s=null===(t=Fn.current[n])||void 0===t?void 0:t.current,a=null===(i=kn.current[c])||void 0===i?void 0:i.current;if(s&&a){var d,v,g,f=s.getBoundingClientRect(),p=a.getBoundingClientRect(),h=f.right-R.left,x=p.left-R.left,_=f.top+f.height/2-R.top,m=p.top+p.height/2-R.top;if(de&&Re===n){var S=null!==(l=null===(o=Je.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,b=S+(null!==(u=null===(r=Je.current)||void 0===r?void 0:r.clientHeight)&&void 0!==u?u:1/0),A=f.top+f.height/2;d=A,v=S,g=b,m=_=Math.max(v,Math.min(g,d))-R.top}var T=St(n);T&&y.push({id:"line-".concat(n,"-").concat(c),x1:h,y1:_,x2:x,y2:m,style:T,sectionIdx:n,targetRightIdx:c})}}})});else{for(S=0;S<Math.min(An.length,Tn.length);S++){var w=null===(c=Pn.current[S])||void 0===c?void 0:c.current,P=null===(s=Nn.current[S])||void 0===s?void 0:s.current;if(w&&P){var N=w.getBoundingClientRect(),F=P.getBoundingClientRect(),k=Math.max(N.top,F.top)+18-R.top,M=(null===(a=Tn[S])||void 0===a?void 0:a.id)||"sec-".concat(S);(Y=St(S))&&y.push({id:M,x1:N.right-R.left,y1:k,x2:F.left-R.left,y2:k,style:Y,sectionIdx:S,hasCognitive:!!((null===(d=An[S])||void 0===d?void 0:d.cognitiveData)||(null===(v=Tn[S])||void 0===v?void 0:v.cognitiveData)||M&&Me[M]),isSubSection:!1})}}Object.keys(Ln.current).forEach(function(e){var n,t,i,o,l,r;if(m(e)){var c=null===(n=Ln.current[e])||void 0===n?void 0:n.current,s=null===(t=Vn.current[e])||void 0===t?void 0:t.current;if(c&&s){for(var a=e.split("-").map(Number),d=An[a[0]],v=Tn[a[0]],g=1;g<a.length;g++)(null==d?void 0:d.subsections)&&(d=d.subsections[a[g]]),(null==v?void 0:v.subsections)&&(v=v.subsections[a[g]]);var f=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(l=v.displayTitle)||void 0===l||l)&&u.hasValue(v.title)),x=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&u.hasValue(v.content));if(f&&p||h&&x){var _=c.getBoundingClientRect(),S=s.getBoundingClientRect(),b=Math.max(_.top,S.top)+16-R.top,A=bt(e);A&&"Not Defined"!==A.label&&y.push({id:"subsec-".concat(e),x1:_.right-R.left,y1:b,x2:S.left-R.left,y2:b,style:A,sectionIdx:a[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(de&&"string"==typeof Re&&Re.includes(u.DEVIATION_BADGE_SEPARATOR)){var L=Re.split(u.DEVIATION_BADGE_SEPARATOR),V=L[0],H=L[1],G=L[2],q=(L[3],"".concat(V).concat(u.DEVIATION_BADGE_SEPARATOR).concat(H)),z=null===(g=Fn.current[q])||void 0===g?void 0:g.current,W=null===(f=kn.current[q])||void 0===f?void 0:f.current;if(z&&W){var Y,K=z.getBoundingClientRect(),U=W.getBoundingClientRect(),X=K.right-R.left,J=U.left-R.left,Q=K.top+K.height/2-R.top,Z=(U.top,U.height,R.top);if($){var ee=null!==(h=null===(p=Je.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,ne=ee+(null!==(_=null===(x=Je.current)||void 0===x?void 0:x.clientHeight)&&void 0!==_?_:1/0);_e=K.top+K.height/2,me=ee,ye=ne,Q=Math.max(me,Math.min(ye,_e))-R.top}Z=Q,(Y=bt(G))&&y.push({id:"line-subsec-".concat(q),x1:X,y1:Q,x2:J,y2:Z,style:Y,sectionIdx:Number(G.split("-")[0]),isSubSection:!0,subSectionKeyPath:Re})}}if(xt(y),gt.current&&ft.current){var te=gt.current.getBoundingClientRect(),ie=ft.current.getBoundingClientRect(),oe=(te.top+te.height/2-R.top+ie.top+ie.height/2-R.top)/2;Rt({x1:te.right-R.left,x2:ie.left-R.left,y:oe})}else Rt(null);if(Ae.size>0){var le=[],re=Je.current,ue=We.current;if(re&&ue){var ce=[],se=re.getBoundingClientRect().top,ae=ue.getBoundingClientRect().top,ve=se+re.clientHeight,ge=ae+ue.clientHeight,fe=re.scrollTop,pe=ue.scrollTop,he=R.top,xe=function(e,n,t){return Math.max(n,Math.min(t,e))};Ae.forEach(function(e){var n,t,i,o,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=e.split(u.DEVIATION_BADGE_SEPARATOR),c=r[0],s=r[1],a=r[2],d=(r[3],"".concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),v=null===(n=Fn.current[d])||void 0===n?void 0:n.current,g=null===(t=kn.current[d])||void 0===t?void 0:t.current;if(!v||!g)return;var f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=bt(a),x=(P=f.right-R.left)+.5*((N=p.left-R.left-0)-P),_=f.top+f.height/2,m=p.top+p.height/2,y=_-se+fe,S=m-ae+pe,b="conn-subsec-".concat(d);ce.push({lhsScrollY:y,rhsScrollY:S,x1:P,x2:N,containerTop:he,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:b});var A=xe(_,se,ve),T=xe(m,ae,ge),E=A-he,I=T-he,B=m>=ae-4&&m<=ge+4,C="";C=(F=_>=se-4&&_<=ve+4)&&B?u.getBentArrowPath(P,E,N,I):F&&!B?"M ".concat(P,",").concat(E," L ").concat(x,",").concat(E," L ").concat(x,",").concat(I):!F&&B?"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I," L ").concat(N,",").concat(I):"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I),le.push({id:b,pathD:C,style:h,leftIdx:e,rhsArrayIdx:e})}else if($){var D=e,O=An[D];if(!(null===(l=null==O?void 0:O.refIndexes)||void 0===l?void 0:l.length))return;O.refIndexes.forEach(function(e){var n,t,i=Tn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Fn.current[D])||void 0===n?void 0:n.current,l=null===(t=kn.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),c=l.getBoundingClientRect(),s=St(D),a=r.right-R.left,d=c.left-R.left-0,v=a+.5*(d-a),g=r.top+r.height/2,f=c.top+c.height/2,p=g-se+fe,h=f-ae+pe,x="conn-".concat(D,"-").concat(i);ce.push({lhsScrollY:p,rhsScrollY:h,x1:a,x2:d,containerTop:he,leftIdx:D,rhsArrayIdx:i,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleId:x});var _=xe(g,se,ve),m=xe(f,ae,ge),y=_-he,S=m-he,b=g>=se-4&&g<=ve+4,A=f>=ae-4&&f<=ge+4,T="";T=b&&A?u.getBentArrowPath(a,y,d,S):b&&!A?"M ".concat(a,",").concat(y," L ").concat(v,",").concat(y," L ").concat(v,",").concat(S):!b&&A?"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(v,",").concat(y," L ").concat(v,",").concat(S),le.push({id:x,pathD:T,style:s,leftIdx:D,rhsArrayIdx:i})}}})}else{var j=e,w=j;v=null===(i=Fn.current[j])||void 0===i?void 0:i.current,g=null===(o=kn.current[w])||void 0===o?void 0:o.current;if(!v||!g)return;var P,N;f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=St(j),x=(P=f.right-R.left)+.5*((N=p.left-R.left-0)-P),_=f.top+f.height/2,m=p.top+p.height/2,y=_-se+fe,S=m-ae+pe,b="conn-".concat(j,"-").concat(w);ce.push({lhsScrollY:y,rhsScrollY:S,x1:P,x2:N,containerTop:he,leftIdx:j,rhsArrayIdx:w,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:b});var F;A=xe(_,se,ve),T=xe(m,ae,ge),E=A-he,I=T-he,B=m>=ae-4&&m<=ge+4,C="";C=(F=_>=se-4&&_<=ve+4)&&B?u.getBentArrowPath(P,E,N,I):F&&!B?"M ".concat(P,",").concat(E," L ").concat(x,",").concat(E," L ").concat(x,",").concat(I):!F&&B?"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I," L ").concat(N,",").concat(I):"M ".concat(x,",").concat(E," L ").concat(x,",").concat(I),le.push({id:b,pathD:C,style:h,leftIdx:j,rhsArrayIdx:w})}}),we.current=ce}Be(le)}else Be([]),we.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Qe.current=!1}var _e,me,ye}},[En,An,Tn,Me,fn,yt,St,$,de,Re,Ae,et,nt]),Tt=t.useCallback(function(){var e,n,t,i,o,l,r,c,s,a,d,v,g,f,p=we.current;if(p.length&&!De.current){var h=null!==(n=null===(e=Je.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=We.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(l=null===(o=Je.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,m=null!==(c=null===(r=We.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,R=null!==(a=null===(s=Je.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==a?a:0,y=null!==(v=null===(d=We.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,b=y+m,A=null!==(f=null===(g=st.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==f?f:0,T=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=je.current[e.styleId+"-stroke"],o=je.current[e.styleId+"-bg"];if(i||o){var l,r=T(n,R,S),c=T(t,y,b),s=r-A,a=c-A,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=b+4,g=e.x1+.5*(e.x2-e.x1);l=d&&v?u.getBentArrowPath(e.x1,s,e.x2,a):d&&!v?"M ".concat(e.x1,",").concat(s," L ").concat(g,",").concat(s," L ").concat(g,",").concat(a):!d&&v?"M ".concat(g,",").concat(s," L ").concat(g,",").concat(a," L ").concat(e.x2,",").concat(a):"M ".concat(g,",").concat(s," L ").concat(g,",").concat(a),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]);t.useEffect(function(){ke.current=At},[At]);var Et=t.useRef(null),It=t.useRef(null),Bt=t.useCallback(function(){we.current.length>0&&!De.current||(null!==Et.current&&clearTimeout(Et.current),Et.current=setTimeout(function(){ke.current(),Et.current=null},50))},[]),Ct=t.useCallback(function(){_e(!0),pe(!1),null!==It.current&&clearTimeout(It.current),null!==Et.current&&(clearTimeout(Et.current),Et.current=null),It.current=setTimeout(function(){var e,n,t,i,o,l,r,c;if(we.current=[],Ne.current&&null!==Fe.current&&null!==dt.current){var s=Fe.current,a=dt.current,d=null,v=null,g=null,f=null;if("string"==typeof s&&s.includes(u.DEVIATION_BADGE_SEPARATOR)){var p=s.split(u.DEVIATION_BADGE_SEPARATOR),h="".concat(p[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(p[1]);d=(null===(e=Fn.current[h])||void 0===e?void 0:e.current)||null,v=(null===(n=kn.current[h])||void 0===n?void 0:n.current)||null,g=(null===(t=Ln.current[p[2]])||void 0===t?void 0:t.current)||null,f=(null===(i=Vn.current[p[3]])||void 0===i?void 0:i.current)||null}else d=(null===(o=Hn.current[s])||void 0===o?void 0:o.current)||null,g=(null===(l=Pn.current[s])||void 0===l?void 0:l.current)||null,v=(null===(r=Mn.current[a])||void 0===r?void 0:r.current)||null,f=(null===(c=Nn.current[a])||void 0===c?void 0:c.current)||null;if(d&&v&&g&&f){if(g.style.paddingTop="0px",f.style.paddingTop="0px",!$){var x=d.getBoundingClientRect(),_=v.getBoundingClientRect(),m=x.top-_.top;m>0?f.style.paddingTop="".concat(m,"px"):m<0&&(g.style.paddingTop="".concat(Math.abs(m),"px"))}var R=Je.current,y=We.current;if(R&&y){var S=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,b=v.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop-(S-R.scrollTop);Math.abs(y.scrollTop-b)>1&&(y.scrollTop=b)}}}ke.current(),Ne.current&&pe(!0),_e(!1),It.current=null},150)},[$,An,Tn]),Dt=t.useCallback(function(e){var n,t,i,o,l,r,c,s,a,d;if(!Se.current){if($||Bt(),Ne.current){var v=Fe.current,g=dt.current,f=Je.current,p=We.current;if(null!==v&&null!==g&&f&&p){var h="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Fn.current["".concat(v.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(v.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=Hn.current[v])||void 0===t?void 0:t.current,x="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=kn.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=Mn.current[g])||void 0===o?void 0:o.current;if(h&&x){var _=h.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop,m=x.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop;if(e.currentTarget===f){var R=m-(_-f.scrollTop),y=p.scrollHeight-p.clientHeight,S=Math.max(0,Math.min(R,y));Math.abs(p.scrollTop-S)>1&&(p.scrollTop=S)}else if(e.currentTarget===p){var b=_-(m-p.scrollTop),A=f.scrollHeight-f.clientHeight,T=Math.max(0,Math.min(b,A));Math.abs(f.scrollTop-T)>1&&(f.scrollTop=T)}if(vt.current){var E=void 0,I=void 0;if("string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR)){var B=v.split(u.DEVIATION_BADGE_SEPARATOR),C="".concat(B[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(B[1]);E=null===(l=Fn.current[C])||void 0===l?void 0:l.current,I=null===(r=kn.current[C])||void 0===r?void 0:r.current}else E=null===(c=Fn.current[v])||void 0===c?void 0:c.current,I=null===(s=kn.current[g])||void 0===s?void 0:s.current;var D=null!==(d=null===(a=st.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==d?d:0,O=f.getBoundingClientRect().top,j=O+f.clientHeight;p.getBoundingClientRect().top;p.clientHeight;if(E&&I){var w=E.getBoundingClientRect(),P=I.getBoundingClientRect(),N=w.top+w.height/2;P.top,P.height;var F=((M=N,L=O,V=j,Math.max(L,Math.min(V,M)))-D).toString();vt.current.setAttribute("y1",F),vt.current.setAttribute("y2",F);var k=N>=O-4&&N<=j+4;vt.current.setAttribute("visibility",k?"visible":"hidden")}}}}}var M,L,V;we.current.length>0&&!Pe.current&&(Pe.current=!0,requestAnimationFrame(function(){Tt(),Pe.current=!1}))}},[Tt,$,Bt]);t.useEffect(function(){var e=setTimeout(Bt,250);window.addEventListener("resize",Ct);var n=null,t=null;return qe.current&&(n=new ResizeObserver(Bt)).observe(qe.current),st.current&&(t=new ResizeObserver(Bt)).observe(st.current),function(){clearTimeout(e),null!==Et.current&&clearTimeout(Et.current),null!==It.current&&clearTimeout(It.current),window.removeEventListener("resize",Ct),null==n||n.disconnect(),null==t||t.disconnect()}},[Sn,bn,Wn,En,et,nt,An,Tn,fn,Bt,Ct,de,Re,fe,Ae]),t.useEffect(function(){Ne.current=de},[de]),t.useEffect(function(){Fe.current=Re},[Re]);var Ot=t.useCallback(function(e,n,t){var i,o,l,r,c,s,a=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,d=null==t?void 0:t.onReady,v=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";if(gn(),null!=e)if(n)se("No counterpart exists for this section.");else if(de&&Re===e)a?Zn():null==d||d();else{if(!$){var g=Fe.current,f=dt.current;if(null!==g)if("string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)){var p=g.split(u.DEVIATION_BADGE_SEPARATOR);(h=null===(l=Ln.current[p[2]])||void 0===l?void 0:l.current)&&(h.style.paddingTop="0px")}else{var h;(h=null===(r=Pn.current[g])||void 0===r?void 0:r.current)&&(h.style.paddingTop="0px")}if(null!==f)if("string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)){p=f.split(u.DEVIATION_BADGE_SEPARATOR);(x=null===(c=Vn.current[p[3]])||void 0===c?void 0:c.current)&&(x.style.paddingTop="0px")}else{var x;(x=null===(s=Nn.current[f])||void 0===s?void 0:s.current)&&(x.style.paddingTop="0px")}}Te(new Set),Be([]),we.current=[],re(!0),Se.current=!0,ye(e),Fe.current=e,ve(!0),Ne.current=!0,pe(!1),Ye.current&&(Ye.current.style.height="0px"),Ke.current&&(Ke.current.style.height="0px"),Ue.current&&(Ue.current.style.height="0px"),Xe.current&&(Xe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,l,r,c,s,a,g,f=null,p=null,h=null,x=null,_=null;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var m=e.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(m[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(m[1]);f=(null===(n=Fn.current[R])||void 0===n?void 0:n.current)||null,_=(p=(null===(t=kn.current[R])||void 0===t?void 0:t.current)||null)?e:null,h=(null===(i=Ln.current[m[2]])||void 0===i?void 0:i.current)||null,x=(null===(o=Vn.current[m[3]])||void 0===o?void 0:o.current)||null}else if(f=(null===(l=Hn.current[e])||void 0===l?void 0:l.current)||null,h=(null===(r=Pn.current[e])||void 0===r?void 0:r.current)||null,$){var y=An[e],S=(null==y?void 0:y.refIndexes)||[];if(S.length>0){var b=S[0],A=Tn.findIndex(function(e){return e.selfIndex===b});-1!==A&&(p=(null===(a=Mn.current[A])||void 0===a?void 0:a.current)||null,x=(null===(g=Nn.current[A])||void 0===g?void 0:g.current)||null,_=A)}}else p=(null===(c=Mn.current[e])||void 0===c?void 0:c.current)||null,x=(null===(s=Nn.current[e])||void 0===s?void 0:s.current)||null,_=p?e:null;dt.current=_;var T=Je.current,E=We.current;if(!f||!T)return Se.current=!1,re(!1),void(null==d||d());if(!p||!E)return pe(!0),ke.current(),Se.current=!1,re(!1),void(null==d||d());if(!$){var I=f.getBoundingClientRect(),B=p.getBoundingClientRect(),C=I.top-B.top;h&&x&&(h.style.paddingTop="0px",x.style.paddingTop="0px",C>0?x.style.paddingTop="".concat(C,"px"):C<0&&(h.style.paddingTop="".concat(Math.abs(C),"px")));var D=0;D="right"===v?p?p.getBoundingClientRect().top:(null==x?void 0:x.getBoundingClientRect().top)||0:f?f.getBoundingClientRect().top:(null==h?void 0:h.getBoundingClientRect().top)||0;var O=qe.current,j=O?O.scrollTop+D-150:0;return O?void u.smoothScrollTo(O,j,200,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()}):(pe(!0),ke.current(),Se.current=!1,re(!1),void(null==d||d()))}var w=f.getBoundingClientRect().top-T.getBoundingClientRect().top+T.scrollTop,P=p.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop,N=200;if("left"===v){var F=P-(w-T.scrollTop);F<0&&Ye.current&&(Ye.current.style.height="".concat(Math.abs(F),"px")),requestAnimationFrame(function(){var e,n=E.scrollHeight-E.clientHeight;if(F<0)e=0;else{if(F>n){var t=F-n;return Ke.current&&(Ke.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(E,F,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}e=F}u.smoothScrollTo(E,e,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}else{var k=w-(P-E.scrollTop);k<0&&Ue.current&&(Ue.current.style.height="".concat(Math.abs(k),"px")),requestAnimationFrame(function(){var e,n=T.scrollHeight-T.clientHeight;if(k<0)e=0;else{if(k>n){var t=k-n;return Xe.current&&(Xe.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(T,k,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}e=k}u.smoothScrollTo(T,e,N,function(){pe(!0),ke.current(),Se.current=!1,re(!1),null==d||d()})})}})}},[Re,gn,Tn,de,$,An,Zn]),jt=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;vn();var c="left";(null===(o=We.current)||void 0===o?void 0:o.contains(r))&&(c="right"),t?l&&cn({open:!0,anchorEl:r,summary:i}):Ot(n,t,l?{toggleIfSame:!1,sourceSide:c,onReady:function(){cn({open:!0,anchorEl:r,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[Ot,vn,cn]),wt=t.useCallback(function(){var e,n=nn.sectionIdx,t=nn.isOrphan;if(sn(),null!=n){var i="left";nn.anchorEl&&(null===(e=We.current)||void 0===e?void 0:e.contains(nn.anchorEl))&&(i="right"),Ot(n,t,{sourceSide:i})}},[Ot,nn.isOrphan,nn.sectionIdx,nn.anchorEl,sn]),Pt=t.useCallback(function(){sn(),Zn()},[sn,Zn]),Nt=null!==nn.sectionIdx&&Ae.has(nn.sectionIdx),Ft=_.useDeviationNavigation({proposedSections:An,existingSections:Tn,parentDeviationRecord:In,expandedSections:et,maintainRelativeOrder:!!$,scrollContainerRef:qe,leftContainerRef:Je,lhsBadgeRefs:Fn,rhsBadgeRefs:kn}),kt=Ft.showDeviationNavigation,Mt=Ft.showOpenNodeRef,Lt=t.useMemo(function(){if(!Q)return null;for(var e in In){if((In[e]||[]).some(function(e){return e.id===Q}))return e}return null},[Q,In]),Vt=t.useRef(null);t.useEffect(function(){if(Q&&Vt.current!==Q){var n=!1,t=0,i=null,o=150,l=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},r=function(){var c,s,a,d;if(!n){var v=null,g=null;for(var f in In){var p=In[f].find(function(e){return e.id===Q});if(p){v=f,g=p;break}}if(g&&v){var h=An.findIndex(function(e){return e.id===v});if(!($?!!et["left-".concat(h)]:!!et[String(h)])&&h>=0)return it(h,"left"),t+=1,void(i=setTimeout(r,450));var x=l(An,g.id),_=l(Tn,g.id);if(x&&!_){var m=x.split("-"),R=Number(m[0]);if($){var y=null===(s=null===(c=An[R])||void 0===c?void 0:c.refIndexes)||void 0===s?void 0:s[0],S=Tn.findIndex(function(e){return e.selfIndex===y});-1!==S&&(R=S)}_=e.__spreadArray([R],m.slice(1),!0).join("-")}if(x&&_){var b="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0").concat(u.DEVIATION_BADGE_SEPARATOR).concat(x).concat(u.DEVIATION_BADGE_SEPARATOR).concat(_),A="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0"),T=null===(a=Fn.current[A])||void 0===a?void 0:a.current,E=null===(d=kn.current[A])||void 0===d?void 0:d.current,I=$?Je.current:qe.current;if(T&&I){var B=T.getBoundingClientRect();if(0===B.height)return void((t+=1)<20&&(i=setTimeout(r,o)));var C=I.getBoundingClientRect(),D=B.top-C.top+I.scrollTop-C.height/2+B.height/2,O=function(){var e=window.getComputedStyle(T).color;T.style.transition="box-shadow 300ms ease-in-out",T.style.boxShadow="0 0 10px ".concat(e),E&&(E.style.transition="box-shadow 300ms ease-in-out",E.style.boxShadow="0 0 10px ".concat(e)),setTimeout(function(){T&&(T.style.boxShadow=""),E&&(E.style.boxShadow="")},2e3)},j=function(){var e,n,t,i=(null==g?void 0:g.evaluationResult)||(null===(e=null==J?void 0:J[null==g?void 0:g.id])||void 0===e?void 0:e.evaluation_result)||(null===(t=null===(n=null==H?void 0:H.nodes)||void 0===n?void 0:n[null==g?void 0:g.id])||void 0===t?void 0:t.evaluation_result)||null,o=(null==i?void 0:i.deviations)||{},l=Object.keys(o).sort()[0]||null,r=l?o[l]:null,u=(null==r?void 0:r.deviation_summary)||"";cn({open:!0,anchorEl:T,summary:{deviation_summary:u,deviation_title:null==i?void 0:i.deviation_title,evaluation_outputs:null==i?void 0:i.evaluation_outputs}})};Vt.current=Q,$?(I.scrollTo({top:D,behavior:"smooth"}),Ot(b,!1,{toggleIfSame:!1}),j(),setTimeout(function(){ke.current()},0),O()):u.smoothScrollTo(I,D,300,function(){n||(Ot(b,!1,{toggleIfSame:!1}),j(),setTimeout(function(){ke.current()},0),O())})}else(t+=1)<20&&(i=setTimeout(r,o))}else(t+=1)<20&&(i=setTimeout(r,o))}else(t+=1)<20&&(i=setTimeout(r,o))}};return i=setTimeout(r,o),function(){n=!0,i&&clearTimeout(i)}}},[Q,In,An,Tn,$,et,it,J,H,cn,Ot]);var Ht=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,s=void 0===c?"":c;return n.jsx(y.default,{section:t,keyPath:i,depth:l,columnKey:u,parentNodeId:s,expandedSubSections:nt,setExpandedSubSections:tt,maintainRelativeOrder:$||!1,proposedSections:An,existingSections:Tn,treeData:H,deviationNumberRegistry:Bn,connectedSections:Ae,activeSideBySideSection:Re,resolvedMarkdownStyles:Ge,getSubSectionRef:qn,getSubSectionCompareStyle:bt,getBadgeRef:zn,openMoreFunctionsPopup:rt,openSummaryPopup:jt,resetSideBySide:Zn,setConnectedSections:Te,setConnectedLines:Be,cachedConnectedPositions:we})};return n.jsxs(i.Box,e.__assign({ref:ze,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},$?{}:{overflow:"visible"}),{position:"relative"})},{children:[te&&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,{})})),un.open&&n.jsx(S.default,{open:un.open,anchorEl:un.anchorEl,containerEl:at.current,clipTopEl:gt.current,onClose:Pt,summary:un.summary}),n.jsx(d.default,{open:nn.open,anchorEl:nn.anchorEl,sectionTitle:nn.sectionTitle,referenceSectionTitle:nn.refSectionTitle,onClose:gn,onOpenCognitiveCompare:ut,onOpenSideBySide:wt,onConnect:ct,isConnected:Nt,isOrphan:nn.isOrphan}),$e.open&&n.jsx(a.default,{open:$e.open,popupRef:dn,position:on,popupConfig:U,onClose:function(){ln(null),en(function(n){return e.__assign(e.__assign({},n),{open:!1})}),an(null)},markdownStyles:W,sectionTitle:$e.sectionTitle,referenceSectionTitle:$e.refSectionTitle,cognitiveData:$e.cognitiveData,anchorEl:$e.anchorEl,sectionAnchorEl:$e.sectionAnchorEl,scrollContainerEl:qe.current,badgeStyle:$e.badgeStyle,docData:$e.docData,deviationData:$e.deviationData,isLoading:$e.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!ce,autoHideDuration:8e3,onClose:function(){return se(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return se(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ce}))})),n.jsx(m.default,{componentHeaderText:V,displayConfig:K,maintainRelativeOrder:$,onToggleView:function(e){ie(!0),setTimeout(function(){ee(!e),Zn(),Te(new Set),Be([]),we.current=[],setTimeout(function(){ie(!1)},400)},50)}}),n.jsx(i.Box,e.__assign({ref:qe,onScroll:Dt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:$?"hidden":"auto",borderTop:Yn&&Kn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},$?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:st,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},$?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Ce,style:{position:"absolute",top:0,left:0,width:Ve.width||"100%",height:Ve.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:xe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[mt&&n.jsx("g",{children:n.jsx("line",{x1:mt.x1,y1:mt.y,x2:mt.x2,y2:mt.y,stroke:Qn.badgeBorder,strokeWidth:"1.5"})}),ht.map(function(t){var r,c,a,d,v,f,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?de&&Re===t.subSectionKeyPath&&fe:de&&Re===t.sectionIdx&&fe)return n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{ref:vt,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id);if(!$){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),_=An[t.sectionIdx]||{title:"",content:""},m=Tn[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),T=An[b[0]],E=Tn[A[0]],I=(null==T?void 0:T.title)||"",B=(null==E?void 0:E.title)||"";console.log("Root Parent Titles:",I,B);for(var C=1;C<b.length;C++)(null==T?void 0:T.subsections)&&(T=T.subsections[b[C]]);for(C=1;C<A.length;C++)(null==E?void 0:E.subsections)&&(E=E.subsections[A[C]]);T&&(_=e.__assign(e.__assign({},T),{title:I||T.title})),console.log("Base Section for Subsection Badge:",_),E&&(m=e.__assign(e.__assign({},E),{title:B||E.title})),console.log("Ref Section for Subsection Badge:",m)}var D=!(null===(r=_.cognitiveData)||void 0===r?void 0:r.isMissingRationale)||Boolean(null===(a=null===(c=_.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===a?void 0:a.length),O=(null===(f=null===(v=null===(d=_.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.length)||!1,j=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(),j&&($e.open&&rn===t.id?vn():(an(t.id),lt(ot(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:j?"pointer":"default"}},{children:[t.style.badgeText===s.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(g.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),j&&n.jsx(o.ChevronDown,{size:11,style:{transform:$e.open&&rn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Ie.map(function(t){var i,o=t.pathD,l=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",r="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),c="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:r,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),n.jsx("path",{ref:function(e){je.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){je.current[c]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(r,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},$?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:gt,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:Je,onScroll:Dt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},$?{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:Ue,style:{width:"100%",height:"0px",flexShrink:0}}),Dn&&An.map(function(t,l){var r,c,s=!t.title&&!t.content;if($&&s)return null;var a=t,d=St(l,"left"),v=$?!(null===(r=a.refIndexes)||void 0===r?void 0:r.length)||a.selfIndex<0:!Tn[l],f=$?"number"==typeof a.selfIndex&&a.selfIndex>=0?a.selfIndex+1:null:l+1,p=Ae.has(l),h=u.extractDeviationScore(a.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:Gn(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:Pn.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:Gn("left-accordion-".concat(l)),mb:0,treeData:H,proposedSections:An,existingSections:Tn,deviationNumberRegistry:Bn,getSectionCompareStyle:St,getBadgeRef:zn,connectedSections:Ae,openMoreFunctionsPopup:rt,openSummaryPopup:jt,deviationNodeIdToView:Q,deviationTargetParentId:Lt,parentNodeId:(null===(c=null==H?void 0:H.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:$?!!et["left-".concat(l)]:!!et[String(l)],onToggle:function(){et[$?"left-".concat(l):String(l)]&&sn(),it(l,"left")},navigation:t.id?kt[t.id]:null,showOpenNodeRef:Mt,resolvedMarkdownStyles:Ge,maintainRelativeOrder:$,renderSubSections:Ht})})),$&&d&&n.jsxs(i.Box,e.__assign({ref:Fn.current[l],onClick:function(e){var n=$?Tn.find(function(e){var n;return null===(n=a.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Tn[l]||{title:"",content:""};rt(e,t,v,n,l,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!K.isLoading||null!=a.evaluationResult&&null!=a.evaluationResult?v?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(g.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(l))}),n.jsx("div",{ref:Xe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:at,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(),$e.open&&rn===Un?vn():(an(Un),lt(ot(n.currentTarget,{title:"",content:"",evaluationResult:Xn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Un,!0,e.__assign(e.__assign({},Qn),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:Qn.badgeBg,color:Qn.badgeText,border:"1px solid ".concat(Qn.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Jn?Jn:n.jsx(g.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:$e.open&&rn===Un?"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},$?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[le&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:ft,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:Rn,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:Rn}))}))})),n.jsxs(i.Box,e.__assign({ref:We,onScroll:Dt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},$?{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:Ye,style:{width:"100%",height:"0px",flexShrink:0}}),Dn&&Tn.map(function(t,o){var l,r=t,u=[],c=!1,s=null,a=-1;if($){u=An.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}),a=An.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(r.selfIndex))&&e.selfIndex>=0});var d=An.findIndex(function(e,n){var t;return Ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(r.selfIndex))});(c=-1!==d)&&(s=St(d))}else u=[o+1],(c=Ae.has(o))&&(s=St(o));var v=St($&&-1!==a?a:o);return n.jsx(i.Box,e.__assign({ref:Mn.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:Nn.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:o,columnKey:"right",colRef:Gn("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(l=null==H?void 0:H.input_index_map)||void 0===l?void 0:l[1])||"",isExpanded:$?!!et["right-".concat(o)]:!!et[String(o)],treeData:H,proposedSections:An,existingSections:Tn,deviationNumberRegistry:Bn,getBadgeRef:zn,getSectionCompareStyle:St,connectedSections:Ae,openMoreFunctionsPopup:rt,openSummaryPopup:jt,deviationNodeIdToView:Q,deviationTargetParentId:Lt,onToggle:function(){et[$?"right-".concat(o):String(o)]&&sn(),it(o,"right")},navigation:t.id?kt[t.id]:null,showOpenNodeRef:Mt,resolvedMarkdownStyles:Ge,maintainRelativeOrder:$,renderSubSections:Ht})})),$&&!le&&v&&n.jsx(i.Box,e.__assign({ref:kn.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:Ke,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=function(n){return null==n?"":"string"==typeof n?n:Array.isArray(n)?n.map(t).join("\n\n"):"object"==typeof n?JSON.stringify(n):String(n)},n=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return n(t)}))};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){if(t.content!==n.content)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;var e=t.highlights||[],r=n.highlights||[];if(e.length!==r.length)return!1;for(var o=0;o<e.length;o++)if(e[o]!==r[o])return!1;var i=t.deviationBadges||[],a=n.deviationBadges||[];if(i.length!==a.length)return!1;for(o=0;o<i.length;o++){if(i[o].id!==a[o].id)return!1;if(i[o].label!==a[o].label)return!1;if(i[o].isConnected!==a[o].isConnected)return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,r)},n)}},exports.escapeRegExp=function(t){var n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n=(n=(n=(n=n.replace(/['’‘`]/g,"['’‘`]")).replace(/["”“]/g,'["”“]')).replace(/[-—–]/g,"[-—–]")).replace(/\s+/g,"\\s+")},exports.extractDeviationScore=function(t,n){var e,r,o,i,a,u,l;if(!t)return n;var c=null!==(u=null!==(i=null!==(r=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==r?r:null===(o=t.evaluation_outputs)||void 0===o?void 0:o.output_score)&&void 0!==i?i:null===(a=t.evaluation_outputs)||void 0===a?void 0:a.output_value)&&void 0!==u?u:t.output_score;return null!==(l=null!=c?c:n)&&void 0!==l?l:""},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),r=e.r,o=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(r+(255-r)*n),Math.round(o+(255-o)*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,r,o){void 0===o&&(o=14);var i=t+.5*(e-t),a=r-n;if(Math.abs(a)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var u=a>0?1:-1,l=Math.min(o,Math.abs(a)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-l),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+u*l),"V ".concat(r-u*l),"Q ".concat(i," ").concat(r," ").concat(i+l," ").concat(r),"H ".concat(e)].join(" ")},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(n,e,r){var o,i=r[e],a=null===(o=null==n?void 0:n.comparison_inputs)||void 0===o?void 0:o[i];return{title:t((null==a?void 0:a.title)||""),content:t((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},exports.hasValue=n,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.safeStringify=t,exports.smoothScrollTo=function(t,n,e,r,o){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var a=t.scrollTop,u=n-a,l=null,c=function(s){null===l&&(l=s);var v,p=s-l;p<e?(t.scrollTop=(v=p,v/=e,u*(--v*v*v+1)+a),o&&o(),requestAnimationFrame(c)):(t.scrollTop=n,t.style.scrollBehavior=i,o&&o(),r&&r())};requestAnimationFrame(c)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(n){return null==n?"":"string"==typeof n?n:Array.isArray(n)?n.map(t).join("\n\n"):"object"==typeof n?JSON.stringify(n):String(n)},n=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return n(t)}))};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var e,r,o,i,a,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 u=t.highlights||[],s=n.highlights||[];if(u.length!==s.length)return!1;for(var c=0;c<u.length;c++)if(u[c]!==s[c])return!1;var d=t.deviationBadges||[],v=n.deviationBadges||[];if(d.length!==v.length)return!1;for(c=0;c<d.length;c++){if(d[c].id!==v[c].id)return!1;if(d[c].actionId!==v[c].actionId)return!1;if(d[c].label!==v[c].label)return!1;if(d[c].score!==v[c].score)return!1;if(d[c].isOrphan!==v[c].isOrphan)return!1;if(d[c].isConnected!==v[c].isConnected)return!1;if((null===(e=d[c].style)||void 0===e?void 0:e.badgeBg)!==(null===(r=v[c].style)||void 0===r?void 0:r.badgeBg))return!1;if((null===(o=d[c].style)||void 0===o?void 0:o.badgeBorder)!==(null===(i=v[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(a=d[c].style)||void 0===a?void 0:a.badgeText)!==(null===(l=v[c].style)||void 0===l?void 0:l.badgeText))return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,r)},n)}},exports.escapeRegExp=function(t){var n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n=(n=(n=(n=n.replace(/['’‘`]/g,"['’‘`]")).replace(/["”“]/g,'["”“]')).replace(/[-—–]/g,"[-—–]")).replace(/\s+/g,"\\s+")},exports.extractDeviationScore=function(t,n){var e,r,o,i,a,l,u;if(!t)return n;var s=null!==(l=null!==(i=null!==(r=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==r?r:null===(o=t.evaluation_outputs)||void 0===o?void 0:o.output_score)&&void 0!==i?i:null===(a=t.evaluation_outputs)||void 0===a?void 0:a.output_value)&&void 0!==l?l:t.output_score;return null!==(u=null!=s?s:n)&&void 0!==u?u:""},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),r=e.r,o=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(r+(255-r)*n),Math.round(o+(255-o)*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,r,o){void 0===o&&(o=14);var i=t+.5*(e-t),a=r-n;if(Math.abs(a)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var l=a>0?1:-1,u=Math.min(o,Math.abs(a)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-u),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+l*u),"V ".concat(r-l*u),"Q ".concat(i," ").concat(r," ").concat(i+u," ").concat(r),"H ".concat(e)].join(" ")},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(n,e,r){var o,i=r[e],a=null===(o=null==n?void 0:n.comparison_inputs)||void 0===o?void 0:o[i];return{title:t((null==a?void 0:a.title)||""),content:t((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},exports.hasValue=n,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.safeStringify=t,exports.smoothScrollTo=function(t,n,e,r,o){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var a=t.scrollTop,l=n-a,u=null,s=function(c){null===u&&(u=c);var d,v=c-u;v<e?(t.scrollTop=(d=v,d/=e,l*(--d*d*d+1)+a),o&&o(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,o&&o(),r&&r())};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"),i=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=d(i);exports.default=function(d){var u,c,v,f,p,g,h,x,m,_,b,y,w,I,A,S,R=d.section,B=d.idx,E=d.columnKey,F=d.colRef,j=d.mb,C=void 0===j?1:j,T=d.parentNodeId,k=void 0===T?"":T,D=d.isExpanded,O=d.onToggle,M=d.navigation,N=d.showOpenNodeRef,P=d.resolvedMarkdownStyles,V=d.maintainRelativeOrder,W=d.renderSubSections,q=d.treeData,G=d.proposedSections,z=void 0===G?[]:G,K=d.existingSections,L=void 0===K?[]:K,U=d.deviationNumberRegistry,X=void 0===U?{}:U,Y=d.getBadgeRef,H=d.openSummaryPopup,$=d.getSectionCompareStyle,J=d.connectedSections,Q=d.openMoreFunctionsPopup,Z=d.deviationNodeIdToView,ee=d.deviationTargetParentId,ne=(null===(u=R.displayTitle)||void 0===u||u)&&r.hasValue(R.title),ie=(null===(c=R.displayContent)||void 0===c||c)&&r.hasValue(R.content),oe=!ne&&!ie,te={current:1},le=R.title;ne||(le=ie?"No Title Found":"No Matching Section Found");var re=R.evaluationResult;if(!re&&"right"===E)if(V){var ae=null===(v=R.refIndexes)||void 0===v?void 0:v[0],de=z.find(function(e){return e.selfIndex===ae});re=null==de?void 0:de.evaluationResult}else re=null===(f=z[B])||void 0===f?void 0:f.evaluationResult;var se=null===(p=null==q?void 0:q.input_index_map)||void 0===p?void 0:p[0],ue=null===(g=null==q?void 0:q.input_index_map)||void 0===g?void 0:g[1],ce="left"===E?ue:se,ve="left"===E?R:z[B],fe="right"===E?R:L[B];if(V)if("left"===E){var pe=null===(h=R.refIndexes)||void 0===h?void 0:h[0],ge=L.findIndex(function(e){return e.selfIndex===pe});fe=-1!==ge?L[ge]:void 0}else{var he=null===(x=R.refIndexes)||void 0===x?void 0:x[0],xe=z.findIndex(function(e){return e.selfIndex===he});ve=-1!==xe?z[xe]:void 0}var me="left"===E?!fe:!ve,_e=re||(null==ve?void 0:ve.evaluationResult)||(null==fe?void 0:fe.evaluationResult),be=null!==(b=null===(_=null===(m=null==_e?void 0:_e.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==b?b:a.DEFAULT_DEVIAION_COLOR,ye=r.generateColorPalette(be),we=ye.highlightBg,Ie=null!==(w=null===(y=null==_e?void 0:_e.evaluation_outputs)||void 0===y?void 0:y.output_value)&&void 0!==w?w:null,Ae=(null==_e?void 0:_e.deviations)||{},Se=B+1,Re=R.id;if("right"===E&&V){var Be=null===(I=R.refIndexes)||void 0===I?void 0:I[0];-1!==(xe=z.findIndex(function(e){return e.selfIndex===Be}))&&(Se=xe+1,Re=z[xe].id)}var Ee,Fe=[],je=Object.entries(Ae).map(function(n){var i,o,t,l=n[0],a=n[1],d="".concat(Re).concat(r.DEVIATION_BADGE_SEPARATOR).concat(l),s=X[d];if(!s)return null;var u=a[k],c=r.isMissingStr(u);if(c)u="";else if(!u)return null;Fe.push(u);var v=a[ce],f="left"===E?null===(i=z[B])||void 0===i?void 0:i.content:null===(o=L[B])||void 0===o?void 0:o.content,p=r.safeStringify(f),g=Object.keys(Ae).map(function(e){return{key:e,text:Ae[e][ce]}}).filter(function(e){return!r.isMissingStr(e.text)}).sort(function(e,n){return n.text.length-e.text.length}),h=new Set;g.forEach(function(e){var n=e.text.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n){var i=new RegExp(r.escapeRegExp(n));i.test(p)&&(h.add(e.key),p=p.replace(i,"__TOKEN_".concat(e.key,"__")))}});var x=!r.isMissingStr(v)&&!h.has(l),m=me||r.isMissingStr(v)||x,_="".concat(Se,".").concat(s),b="".concat(Re).concat(r.DEVIATION_BADGE_SEPARATOR).concat(l).concat(r.DEVIATION_BADGE_SEPARATOR).concat(B).concat(r.DEVIATION_BADGE_SEPARATOR).concat(B),y=B;if("right"===E&&V){var w=null===(t=R.refIndexes)||void 0===t?void 0:t[0],I=z.findIndex(function(e){return e.selfIndex===w});-1!==I&&(y=I)}var A=$?$(y):null,S=!1;u&&(S=Object.values(Ae).map(function(e){return e[k]}).filter(Boolean).some(function(e){return e.length>u.length&&e.includes(u)}));var F=A?e.__assign(e.__assign({},A),{badgeBg:ye.badgeBg,badgeBorder:ye.badgeBorder,badgeText:ye.badgeText}):e.__assign({},ye);S&&(F.badgeBg="#FFFBEB",F.badgeBorder="#FCD34D",F.badgeText="#B45309",F.highlightBg="#FDE68A");var j=(null==a?void 0:a.deviation_summary)?{deviation_summary:a.deviation_summary,deviation_title:null==_e?void 0:_e.deviation_title,evaluation_outputs:null==_e?void 0:_e.evaluation_outputs}:null;return{id:d,actionId:b,label:_,highlight:u,side:E,style:F,score:Ie,isConnected:null==J?void 0:J.has(b),isOrphan:m,isMissingClause:c,badgeRef:Y(E,d),onClick:function(e){e.stopPropagation(),Q&&Q(e,ve||{id:"orphan-left",title:"",content:""},m,fe||{id:"orphan-right",title:"",content:""},b,F)},onSummaryClick:function(e){e.stopPropagation(),H(e,b,m,j)}}}).filter(Boolean),Ce=R.id&&E===(null==M?void 0:M.columnKey)?M:null,Te=s.default.useRef(!1);return i.useEffect(function(){D||(Te.current=!1)},[D]),i.useEffect(function(){var e=!!Z&&!!ee&&Re===ee,n=!!Z&&(R.subsections||[]).some(function(e){return e.id===Z});if(D&&!Te.current&&!e&&!n){var i=setTimeout(function(){var e,n;Te.current=!0,null===(n=null===(e=null==Ce?void 0:Ce.showBelowRef)||void 0===e?void 0:e.current)||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},600);return function(){return clearTimeout(i)}}},[D,Z,ee,Re,null==Ce?void 0:Ce.showBelow]),n.jsxs(o.Box,e.__assign({ref:F,sx:{mb:C,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[D&&(null==Ce?void 0:Ce.showAbove)&&n.jsx("div",e.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Ce?void 0:Ce.showAboveRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===E?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronUp,{color:window.getComputedStyle(null===(A=null==Ce?void 0:Ce.showAboveRef)||void 0===A?void 0:A.current).color})}))})),n.jsxs(o.Accordion,e.__assign({disableGutters:!0,expanded:!oe&&D,onChange:function(){oe||(O(),N.current=R.id)},sx:{boxShadow:"none",border:oe?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:oe?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:oe?null:n.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:oe?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:ne&&n.jsx(o.Tooltip,e.__assign({title:le,placement:"top"},{children:n.jsx(o.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:oe?"#94A3B8":"#19213D",fontWeight:oe?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Ee=le,Ee?r.safeStringify(Ee).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,i){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},i):n.jsx(s.default.Fragment,{children:e},i)}):null)}))}))})),!oe&&n.jsxs(o.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[ie&&n.jsx(l.MemoizedMarkdown,{content:R.content,sxStyles:P,highlights:Fe,maintainRelativeOrder:V,highlightBg:we,deviationBadges:je}),(R.subsections||[]).map(function(e,n){return W({section:e,keyPath:"".concat(B,"-").concat(n),depth:0,columnKey:E,parentNodeId:k,devCounter:te})})]}))]})),D&&(null==Ce?void 0:Ce.showBelow)&&n.jsx("div",e.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Ce?void 0:Ce.showBelowRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===E?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronDown,{color:window.getComputedStyle(null===(S=null==Ce?void 0:Ce.showBelowRef)||void 0===S?void 0:S.current).color})}))}))]}),"".concat(E,"-sec-").concat(B))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=d(i),u=function(e){var n=function(e){for(var n=(null==e?void 0:e.parentElement)||null;n;){var i=window.getComputedStyle(n).overflowY;if(("auto"===i||"scroll"===i)&&n.scrollHeight>n.clientHeight)return n;n=n.parentElement}return null}(e),i=e.getBoundingClientRect(),t=(null==n?void 0:n.getBoundingClientRect())||{top:0,bottom:window.innerHeight};return i.top>=t.top&&i.bottom<=t.bottom};exports.default=function(d){var c,v,f,p,g,h,x,m,_,y,b,w,I,S,R,A,E=d.section,C=d.idx,j=d.columnKey,D=d.colRef,F=d.mb,T=void 0===F?1:F,k=d.parentNodeId,B=void 0===k?"":k,O=d.isExpanded,M=d.onToggle,P=d.navigation,N=d.showOpenNodeRef,V=d.resolvedMarkdownStyles,W=d.maintainRelativeOrder,q=d.renderSubSections,G=d.treeData,z=d.proposedSections,H=void 0===z?[]:z,K=d.existingSections,Y=void 0===K?[]:K,L=d.deviationNumberRegistry,U=void 0===L?{}:L,X=d.getBadgeRef,$=d.openSummaryPopup,J=d.getSectionCompareStyle,Q=d.connectedSections,Z=d.openMoreFunctionsPopup,ee=d.deviationNodeIdToView,ne=d.deviationTargetParentId,ie=(null===(c=E.displayTitle)||void 0===c||c)&&r.hasValue(E.title),te=(null===(v=E.displayContent)||void 0===v||v)&&r.hasValue(E.content),oe=!ie&&!te,le={current:1},re=E.title;ie||(re=te?"No Title Found":"No Matching Section Found");var ae=E.evaluationResult;if(!ae&&"right"===j)if(W){var de=null===(f=E.refIndexes)||void 0===f?void 0:f[0],se=H.find(function(e){return e.selfIndex===de});ae=null==se?void 0:se.evaluationResult}else ae=null===(p=H[C])||void 0===p?void 0:p.evaluationResult;var ue=null===(g=null==G?void 0:G.input_index_map)||void 0===g?void 0:g[0],ce=null===(h=null==G?void 0:G.input_index_map)||void 0===h?void 0:h[1],ve="left"===j?ce:ue,fe="left"===j?E:H[C],pe="right"===j?E:Y[C];if(W)if("left"===j){var ge=null===(x=E.refIndexes)||void 0===x?void 0:x[0],he=Y.findIndex(function(e){return e.selfIndex===ge});pe=-1!==he?Y[he]:void 0}else{var xe=null===(m=E.refIndexes)||void 0===m?void 0:m[0],me=H.findIndex(function(e){return e.selfIndex===xe});fe=-1!==me?H[me]:void 0}var _e="left"===j?!pe:!fe,ye=ae||(null==fe?void 0:fe.evaluationResult)||(null==pe?void 0:pe.evaluationResult),be=null!==(b=null===(y=null===(_=null==ye?void 0:ye.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===y?void 0:y.label_color)&&void 0!==b?b:a.DEFAULT_DEVIAION_COLOR,we=r.generateColorPalette(be),Ie=we.highlightBg,Se=null!==(I=null===(w=null==ye?void 0:ye.evaluation_outputs)||void 0===w?void 0:w.output_value)&&void 0!==I?I:null,Re=(null==ye?void 0:ye.deviations)||{},Ae=C+1,Ee=E.id;if("right"===j&&W){var Ce=null===(S=E.refIndexes)||void 0===S?void 0:S[0];-1!==(me=H.findIndex(function(e){return e.selfIndex===Ce}))&&(Ae=me+1,Ee=H[me].id)}var je,De=[],Fe=Object.entries(Re).map(function(n){var i,t,o,l=n[0],a=n[1],d="".concat(Ee).concat(r.DEVIATION_BADGE_SEPARATOR).concat(l),s=U[d];if(!s)return null;var u=a[B],c=r.isMissingStr(u);if(c)u="";else if(!u)return null;De.push(u);var v=a[ve],f="left"===j?null===(i=H[C])||void 0===i?void 0:i.content:null===(t=Y[C])||void 0===t?void 0:t.content,p=r.safeStringify(f),g=Object.keys(Re).map(function(e){return{key:e,text:Re[e][ve]}}).filter(function(e){return!r.isMissingStr(e.text)}).sort(function(e,n){return n.text.length-e.text.length}),h=new Set;g.forEach(function(e){var n=e.text.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n){var i=new RegExp(r.escapeRegExp(n));i.test(p)&&(h.add(e.key),p=p.replace(i,"__TOKEN_".concat(e.key,"__")))}});var x=!r.isMissingStr(v)&&!h.has(l),m=_e||r.isMissingStr(v)||x,_="".concat(Ae,".").concat(s),y="".concat(Ee).concat(r.DEVIATION_BADGE_SEPARATOR).concat(l).concat(r.DEVIATION_BADGE_SEPARATOR).concat(C).concat(r.DEVIATION_BADGE_SEPARATOR).concat(C),b=C;if("right"===j&&W){var w=null===(o=E.refIndexes)||void 0===o?void 0:o[0],I=H.findIndex(function(e){return e.selfIndex===w});-1!==I&&(b=I)}var S=J?J(b):null,R=S?e.__assign(e.__assign({},S),{badgeBg:we.badgeBg,badgeBorder:we.badgeBorder,badgeText:we.badgeText}):e.__assign({},we),A=(null==a?void 0:a.deviation_summary)?{deviation_summary:a.deviation_summary,deviation_title:null==ye?void 0:ye.deviation_title,evaluation_outputs:null==ye?void 0:ye.evaluation_outputs}:null;return{id:d,actionId:y,label:_,highlight:u,side:j,style:R,score:Se,isConnected:null==Q?void 0:Q.has(y),isOrphan:m,isMissingClause:c,badgeRef:X(j,d),onClick:function(e){e.stopPropagation(),Z&&Z(e,fe||{id:"orphan-left",title:"",content:""},m,pe||{id:"orphan-right",title:"",content:""},y,R)},onSummaryClick:function(e){e.stopPropagation(),$(e,y,m,A)}}}).filter(Boolean),Te=E.id&&j===(null==P?void 0:P.columnKey)?P:null,ke=s.default.useRef(!1);return i.useEffect(function(){O||(ke.current=!1)},[O]),i.useEffect(function(){var e=!!ee&&!!ne&&Ee===ne,n=!!ee&&(E.subsections||[]).some(function(e){return e.id===ee});if(O&&!ke.current&&!e&&!n){var i=setTimeout(function(){var e,n=null===(e=null==Te?void 0:Te.firstDeviationRef)||void 0===e?void 0:e.current,i=null==Te?void 0:Te.firstDeviationPosition;n?"inside"===i||u(n)?ke.current=!0:(ke.current=!0,n.scrollIntoView({behavior:"smooth",block:"center"})):ke.current=!0},600);return function(){return clearTimeout(i)}}},[O,ee,ne,Ee,null==Te?void 0:Te.firstDeviationPosition,null==Te?void 0:Te.firstDeviationRef]),n.jsxs(t.Box,e.__assign({ref:D,sx:{mb:T,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[O&&(null==Te?void 0:Te.showAbove)&&n.jsx("div",e.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Te?void 0:Te.showAboveRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===j?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===j?{right:"0px"}:{left:"0px"})},{children:n.jsx(o.ChevronUp,{color:window.getComputedStyle(null===(R=null==Te?void 0:Te.showAboveRef)||void 0===R?void 0:R.current).color})}))})),n.jsxs(t.Accordion,e.__assign({disableGutters:!0,expanded:!oe&&O,onChange:function(){oe||(M(),N.current=E.id)},sx:{boxShadow:"none",border:oe?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:oe?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:oe?null:n.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:oe?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:ie&&n.jsx(t.Tooltip,e.__assign({title:re,placement:"top"},{children:n.jsx(t.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:oe?"#94A3B8":"#19213D",fontWeight:oe?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(je=re,je?r.safeStringify(je).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,i){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},i):n.jsx(s.default.Fragment,{children:e},i)}):null)}))}))})),!oe&&n.jsxs(t.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[te&&n.jsx(l.MemoizedMarkdown,{content:E.content,sxStyles:V,highlights:De,maintainRelativeOrder:W,highlightBg:Ie,deviationBadges:Fe}),(E.subsections||[]).map(function(e,n){return q({section:e,keyPath:"".concat(C,"-").concat(n),depth:0,columnKey:j,parentNodeId:B,devCounter:le})})]}))]})),O&&(null==Te?void 0:Te.showBelow)&&n.jsx("div",e.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Te?void 0:Te.showBelowRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===j?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===j?{right:"0px"}:{left:"0px"})},{children:n.jsx(o.ChevronDown,{color:window.getComputedStyle(null===(A=null==Te?void 0:Te.showBelowRef)||void 0===A?void 0:A.current).color})}))}))]}),"".concat(j,"-sec-").concat(C))};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("react"),t=require("@mui/material"),o=require("lucide-react"),s=require("../hooks/memoizedMarkdown.js"),l=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=d(n).default.memo(function(n){var d,u,c,v,g,h,p,_,f,m,x,S=n.section,b=n.keyPath,y=n.depth,B=void 0===y?0:y,A=n.columnKey,j=void 0===A?"left":A,R=n.parentNodeId,E=void 0===R?"":R,I=n.expandedSubSections,O=n.setExpandedSubSections,C=n.maintainRelativeOrder,F=n.proposedSections,w=n.existingSections,D=n.treeData,P=n.deviationNumberRegistry,M=n.connectedSections,T=n.activeSideBySideSection,k=n.resolvedMarkdownStyles,N=n.getSubSectionRef,q=n.getSubSectionCompareStyle,V=n.getBadgeRef,W=n.openMoreFunctionsPopup,z=n.openSummaryPopup,G=n.resetSideBySide,L=n.setConnectedSections,U=n.setConnectedLines,H=n.cachedConnectedPositions,K=(null===(d=S.displayTitle)||void 0===d||d)&&l.hasValue(S.title),J=(null===(u=S.displayContent)||void 0===u||u)&&l.hasValue(S.content),Q=!K&&!J,X=K?S.title:J?"No Title Found":"No Matching Section Found",Y=!!I[b],Z=N(j,b),$=b.split("-").map(Number),ee=$[0],ie=F[ee],ne=w[ee],te=b,oe=b;if(C)if("left"===j){var se=null===(c=null==ie?void 0:ie.refIndexes)||void 0===c?void 0:c[0],le=w.findIndex(function(e){return e.selfIndex===se});-1!==le&&(ne=w[le],oe=e.__spreadArray([le],$.slice(1),!0).join("-"))}else{var ae=null===(v=null==ne?void 0:ne.refIndexes)||void 0===v?void 0:v[0];-1!==(ce=F.findIndex(function(e){return e.selfIndex===ae}))&&(ie=F[ce],te=e.__spreadArray([ce],$.slice(1),!0).join("-"))}for(var de=ie,re=ne,ue=1;ue<$.length;ue++)(null==de?void 0:de.subsections)&&(de=de.subsections[$[ue]]),(null==re?void 0:re.subsections)&&(re=re.subsections[$[ue]]);var ce,ve=q(te)||q(b),ge=null===(g=null==D?void 0:D.input_index_map)||void 0===g?void 0:g[0],he=null===(h=null==D?void 0:D.input_index_map)||void 0===h?void 0:h[1],pe="left"===j?he:ge,_e="left"===j?!re:!de,fe=S.evaluationResult||(null==de?void 0:de.evaluationResult)||(null==re?void 0:re.evaluationResult),me=null!==(_=null===(p=null==fe?void 0:fe.evaluation_outputs)||void 0===p?void 0:p.output_value)&&void 0!==_?_:null,xe=ee+1,Se=S.id;"right"===j&&C&&((null==de?void 0:de.id)&&(Se=de.id),ie&&-1!==(ce=F.findIndex(function(e){return e.id===ie.id}))&&(xe=ce+1));var be=null!==(x=null===(m=null===(f=null==fe?void 0:fe.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===m?void 0:m.label_color)&&void 0!==x?x:a.DEFAULT_DEVIAION_COLOR,ye=l.generateColorPalette(be),Be=ye.highlightBg,Ae=(null==fe?void 0:fe.deviations)||{},je=[],Re=Object.entries(Ae).map(function(i){var n,t,o,s=i[0],a=i[1],d="".concat(Se).concat(l.DEVIATION_BADGE_SEPARATOR).concat(s),r=P[d];if(!r)return null;var u=a[E],c=l.isMissingStr(u);if(c)u="";else if(!u)return null;je.push(u);var v=a[pe],g=!1;v&&(g=Object.values(Ae).map(function(e){return e[pe]}).filter(Boolean).some(function(e){return e.length>v.length&&e.includes(v)}));var h=_e||l.isMissingStr(v)||g,p="".concat(xe,".").concat(r),_="".concat(Se).concat(l.DEVIATION_BADGE_SEPARATOR).concat(s).concat(l.DEVIATION_BADGE_SEPARATOR).concat(te).concat(l.DEVIATION_BADGE_SEPARATOR).concat(oe),f=e.__assign({},ye),m=!1;u&&(m=Object.values(Ae).map(function(e){return e[E]}).filter(Boolean).some(function(e){return e.length>u.length&&e.includes(u)}));m&&(f.badgeBg="#FFFBEB",f.badgeBorder="#FCD34D",f.badgeText="#B45309",f.highlightBg="#FDE68A");var x=(null==a?void 0:a.deviation_summary)?{deviation_summary:a.deviation_summary||(null===(n=S.evaluationResult)||void 0===n?void 0:n.deviation_summary),deviation_title:null===(t=S.evaluationResult)||void 0===t?void 0:t.deviation_title,evaluation_outputs:null===(o=S.evaluationResult)||void 0===o?void 0:o.evaluation_outputs}:null;return{id:d,actionId:_,label:p,highlight:u,side:j,style:f,score:me,isConnected:M.has(_),isOrphan:h,isMissingClause:c,badgeRef:V(j,d),onClick:function(i){i.stopPropagation();var n=de?e.__assign(e.__assign({},de),{title:(null==ie?void 0:ie.title)||(null==de?void 0:de.title)||""}):{id:"orphan-left",title:"",content:""},t=re?e.__assign(e.__assign({},re),{title:(null==ne?void 0:ne.title)||(null==re?void 0:re.title)||""}):{id:"orphan-right",title:"",content:""};W(i,n,h,t,_,f)},onSummaryClick:function(e){e.stopPropagation(),z(e,_,h,x)}}}).filter(Boolean),Ee=Re.some(function(e){return M.has(e.actionId)});if(!(K||J||S.subsections&&0!==S.subsections.length))return null;var Ie=!C&&K&&J,Oe=Ee&&ve?{borderRadius:"4px",outline:"2px solid ".concat(ve.badgeBorder),outlineOffset:"1px"}:{};return K?i.jsx(t.Box,e.__assign({ref:Z,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i.jsx(t.Box,e.__assign({sx:e.__assign({width:"100%"},Oe)},{children:i.jsxs(t.Accordion,e.__assign({disableGutters:!0,expanded:!Q&&Y,onChange:function(){if(!Q){if(Y){var i=String(T||""),n=i.includes(te)||i.includes(oe);n||M.forEach(function(e){(String(e).includes(te)||String(e).includes(oe))&&(n=!0)}),n&&(G(),L(new Set),U([]),H.current=[])}O(function(i){var n;return e.__assign(e.__assign({},i),((n={})[b]=!i[b],n))})}},sx:{mt:0,boxShadow:"none",border:Q?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i.jsx(t.AccordionSummary,e.__assign({expandIcon:Q?null:i.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i.jsx(t.Typography,e.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Q?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:X||"Untitled Subsection"}))})),!Q&&i.jsxs(t.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[J&&i.jsx(s.MemoizedMarkdown,{content:S.content,sxStyles:k,deviationBadges:Ie?[]:Re,maintainRelativeOrder:C,highlightBg:Be,highlights:je}),(S.subsections||[]).map(function(t,o){return i.jsx(r,e.__assign({},n,{section:t,keyPath:"".concat(b,"-").concat(o),depth:B+1}),"".concat(b,"-").concat(o))})]}))]}))}))})):i.jsx(t.Box,e.__assign({ref:Z,sx:{mt:0===B?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Q&&i.jsxs(t.Box,e.__assign({sx:e.__assign({width:"100%"},Oe)},{children:[J&&i.jsx(s.MemoizedMarkdown,{content:S.content,sxStyles:k,deviationBadges:Re,maintainRelativeOrder:C,highlightBg:Be,highlights:je}),(S.subsections||[]).map(function(t,o){return i.jsx(r,e.__assign({},n,{section:t,keyPath:"".concat(b,"-").concat(o),depth:B+1}),"".concat(b,"-").concat(o))})]}))}))});exports.default=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),i=require("react/jsx-runtime"),e=require("react"),t=require("@mui/material"),o=require("lucide-react"),s=require("../hooks/memoizedMarkdown.js"),l=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function r(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var d=r(e).default.memo(function(e){var r,u,c,v,h,p,f,g,_,m,x,S=e.section,y=e.keyPath,b=e.depth,A=void 0===b?0:b,j=e.columnKey,I=void 0===j?"left":j,E=e.parentNodeId,R=void 0===E?"":E,B=e.expandedSubSections,O=e.setExpandedSubSections,P=e.maintainRelativeOrder,C=e.proposedSections,w=e.existingSections,k=e.treeData,D=e.deviationNumberRegistry,F=e.connectedSections,M=e.activeSideBySideSection,T=e.resolvedMarkdownStyles,N=e.getSubSectionRef,q=e.getSubSectionCompareStyle,V=e.getBadgeRef,W=e.openMoreFunctionsPopup,z=e.openSummaryPopup,G=e.resetSideBySide,L=e.setConnectedSections,U=e.setConnectedLines,H=e.cachedConnectedPositions,K=(null===(r=S.displayTitle)||void 0===r||r)&&l.hasValue(S.title),J=(null===(u=S.displayContent)||void 0===u||u)&&l.hasValue(S.content),Q=!K&&!J,X=K?S.title:J?"No Title Found":"No Matching Section Found",Y=!!B[y],Z=N(I,y),$=y.split("-").map(Number),nn=$[0],en=C[nn],tn=w[nn],on=y,sn=y,ln=nn,an=nn,rn=function(n,i,e){if(!n||!i)return null;if(n.id===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var s=o();if("object"==typeof s)return s.value}return null};if(P)if("left"===I){var dn=null===(c=null==en?void 0:en.refIndexes)||void 0===c?void 0:c[0],un=w.findIndex(function(n){return n.selfIndex===dn});-1!==un&&(tn=w[un],an=un)}else{var cn=null===(v=null==tn?void 0:tn.refIndexes)||void 0===v?void 0:v[0];-1!==(_n=C.findIndex(function(n){return n.selfIndex===cn}))&&(en=C[_n],ln=_n)}var vn=en,hn=tn;if(P)if("left"===I){vn=S,on=y;var pn=rn(tn,S.id,String(an));hn=(null==pn?void 0:pn.section)||null,sn=(null==pn?void 0:pn.keyPath)||""}else{hn=S,sn=y;var fn=rn(en,S.id,String(ln));vn=(null==fn?void 0:fn.section)||null,on=(null==fn?void 0:fn.keyPath)||""}else for(var gn=1;gn<$.length;gn++)(null==vn?void 0:vn.subsections)&&(vn=vn.subsections[$[gn]]),(null==hn?void 0:hn.subsections)&&(hn=hn.subsections[$[gn]]);var _n,mn=(on?q(on):null)||q(y),xn=null===(h=null==k?void 0:k.input_index_map)||void 0===h?void 0:h[0],Sn=null===(p=null==k?void 0:k.input_index_map)||void 0===p?void 0:p[1],yn="left"===I?Sn:xn,bn="left"===I?!hn:!vn,An=S.evaluationResult||(null==vn?void 0:vn.evaluationResult)||(null==hn?void 0:hn.evaluationResult),jn=null!==(g=null===(f=null==An?void 0:An.evaluation_outputs)||void 0===f?void 0:f.output_value)&&void 0!==g?g:null,In=nn+1,En=S.id||(null==vn?void 0:vn.id)||(null==hn?void 0:hn.id);"right"===I&&P&&(en&&-1!==(_n=C.findIndex(function(n){return n.id===en.id}))&&(In=_n+1));var Rn=null!==(x=null===(m=null===(_=null==An?void 0:An.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===m?void 0:m.label_color)&&void 0!==x?x:a.DEFAULT_DEVIAION_COLOR,Bn=l.generateColorPalette(Rn),On=Bn.highlightBg,Pn=(null==An?void 0:An.deviations)||{},Cn=[],wn=Object.entries(Pn).map(function(i){var e=i[0],t=i[1],o="".concat(En).concat(l.DEVIATION_BADGE_SEPARATOR).concat(e),s=D[o];if(!s)return null;var a=t[R],r=l.isMissingStr(a);if(r)a="";else if(!a)return null;Cn.push(a);var d=t[yn],u=!1;d&&(u=Object.values(Pn).map(function(n){return n[yn]}).filter(Boolean).some(function(n){return n.length>d.length&&n.includes(d)}));var c=bn||l.isMissingStr(d)||u,v="".concat(In,".").concat(s),h="".concat(En).concat(l.DEVIATION_BADGE_SEPARATOR).concat(e).concat(l.DEVIATION_BADGE_SEPARATOR).concat(on).concat(l.DEVIATION_BADGE_SEPARATOR).concat(sn),p=n.__assign({},Bn),f=(null==t?void 0:t.deviation_summary)?{deviation_summary:t.deviation_summary||(null==An?void 0:An.deviation_summary),deviation_title:null==An?void 0:An.deviation_title,evaluation_outputs:null==An?void 0:An.evaluation_outputs}:null;return{id:o,actionId:h,label:v,highlight:a,side:I,style:p,score:jn,isConnected:F.has(h),isOrphan:c,isMissingClause:r,badgeRef:V(I,o),onClick:function(i){i.stopPropagation();var e=vn?n.__assign(n.__assign({},vn),{title:(null==en?void 0:en.title)||(null==vn?void 0:vn.title)||""}):{id:"orphan-left",title:"",content:""},t=hn?n.__assign(n.__assign({},hn),{title:(null==tn?void 0:tn.title)||(null==hn?void 0:hn.title)||""}):{id:"orphan-right",title:"",content:""};W(i,e,c,t,h,p)},onSummaryClick:function(n){n.stopPropagation(),z(n,h,c,f)}}}).filter(Boolean),kn=wn.some(function(n){return F.has(n.actionId)});if(!(K||J||S.subsections&&0!==S.subsections.length))return null;var Dn=!P&&K&&J,Fn=kn&&mn?{borderRadius:"4px",outline:"2px solid ".concat(mn.badgeBorder),outlineOffset:"1px"}:{};return K?i.jsx(t.Box,n.__assign({ref:Z,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i.jsx(t.Box,n.__assign({sx:n.__assign({width:"100%"},Fn)},{children:i.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!Q&&Y,onChange:function(){if(!Q){if(Y){var i=String(M||""),e=i.includes(on)||i.includes(sn);e||F.forEach(function(n){(String(n).includes(on)||String(n).includes(sn))&&(e=!0)}),e&&(G(),L(new Set),U([]),H.current=[])}O(function(i){var e;return n.__assign(n.__assign({},i),((e={})[y]=!i[y],e))})}},sx:{mt:0,boxShadow:"none",border:Q?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i.jsx(t.AccordionSummary,n.__assign({expandIcon:Q?null:i.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Q?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:X||"Untitled Subsection"}))})),!Q&&i.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[J&&i.jsx(s.MemoizedMarkdown,{content:S.content,sxStyles:T,deviationBadges:Dn?[]:wn,maintainRelativeOrder:P,highlightBg:On,highlights:Cn}),(S.subsections||[]).map(function(t,o){return i.jsx(d,n.__assign({},e,{section:t,keyPath:"".concat(y,"-").concat(o),depth:A+1}),"".concat(y,"-").concat(o))})]}))]}))}))})):i.jsx(t.Box,n.__assign({ref:Z,sx:{mt:0===A?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Q&&i.jsxs(t.Box,n.__assign({sx:n.__assign({width:"100%"},Fn)},{children:[J&&i.jsx(s.MemoizedMarkdown,{content:S.content,sxStyles:T,deviationBadges:wn,maintainRelativeOrder:P,highlightBg:On,highlights:Cn}),(S.subsections||[]).map(function(t,o){return i.jsx(d,n.__assign({},e,{section:t,keyPath:"".concat(y,"-").concat(o),depth:A+1}),"".concat(y,"-").concat(o))})]}))}))});exports.default=d;
2
2
  //# sourceMappingURL=SubSectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react"),o=require("../CognitiveComparehelpers.js");exports.useDeviationNavigation=function(t){var i=t.proposedSections,r=t.existingSections,l=t.parentDeviationRecord,u=t.expandedSections,c=t.maintainRelativeOrder,d=t.scrollContainerRef,s=t.leftContainerRef,v=t.lhsBadgeRefs,a=t.rhsBadgeRefs,f=n.useState({}),h=f[0],w=f[1],R=n.useRef();return n.useEffect(function(){if(d.current){var n=c?s.current:d.current;if(n){var t=null,f=setTimeout(function(){var s=function(e,n){var o=e.getBoundingClientRect(),t=n.getBoundingClientRect();return o.bottom<t.top?"above":o.top>t.bottom?"below":"inside"};t=o.debounce(function(){w(function(n){var t=e.__assign({},n);return i.forEach(function(e,n){var i=c?!!u["left-".concat(n)]:!!u[String(n)],r=!1,a=!1,f=null,h=null;i&&(null==e?void 0:e.id)&&(l[e.id]||[]).forEach(function(n){var t="".concat(n.id).concat(o.DEVIATION_BADGE_SEPARATOR,"0"),i=v.current[t];if((null==i?void 0:i.current)&&d.current){var l=s(i.current,d.current);"above"===l?(r=!0,f=i):"below"!==l||a?R.current===e.id&&(R.current=""):(a=!0,h=i)}}),e.id&&(t[e.id]={showAbove:r,showBelow:a,showAboveRef:f,showBelowRef:h,columnKey:"left"})}),c||r.forEach(function(e,n){var i=!!u[String(n)],r=!1,c=!1,v=null,f=null;i&&(null==e?void 0:e.id)&&(l[e.id]||[]).forEach(function(n){var i,l,u,h,w,g=!(null===(i=n.refIndexes)||void 0===i?void 0:i.length)||void 0!==n.selfIndex&&n.selfIndex<0,b="".concat(n.id).concat(o.DEVIATION_BADGE_SEPARATOR,"0"),B=a.current[b];if((null==B?void 0:B.current)&&d.current&&g&&(null==e?void 0:e.id)){var A=s(B.current,d.current);if("above"===A){var p=null===(u=null===(l=t[e.id])||void 0===l?void 0:l.showAboveRef)||void 0===u?void 0:u.current;(!p||p.getBoundingClientRect().top<B.current.getBoundingClientRect().top)&&(r=!0,v=B)}else if("below"!==A||c)R.current===e.id&&(R.current="");else{var E=null===(w=null===(h=t[e.id])||void 0===h?void 0:h.showBelowRef)||void 0===w?void 0:w.current;(!E||E.getBoundingClientRect().top>B.current.getBoundingClientRect().top)&&(c=!0,f=B)}}}),e.id&&i&&(r&&(t[e.id]=t[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,columnKey:"right"},t[e.id].showAbove=r,t[e.id].showAboveRef=v,t[e.id].columnKey="right"),c&&(t[e.id]=t[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,columnKey:"right"},t[e.id].showBelow=c,t[e.id].showBelowRef=f,t[e.id].columnKey="right"))}),t})},100),t(),null==n||n.addEventListener("scroll",t)},0);return function(){clearTimeout(f),t&&n.removeEventListener("scroll",t)}}}},[i,r,l,u,c,d,s,v,a]),{showDeviationNavigation:h,showOpenNodeRef:R}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react"),o=require("../CognitiveComparehelpers.js");exports.useDeviationNavigation=function(n){var t=n.proposedSections,r=n.existingSections,l=n.parentDeviationRecord,u=n.expandedSections,s=n.maintainRelativeOrder,d=n.scrollContainerRef,c=n.leftContainerRef,v=n.lhsBadgeRefs,f=n.rhsBadgeRefs,a=i.useState({}),R=a[0],h=a[1],w=i.useRef();return i.useEffect(function(){if(d.current){var i=s?c.current:d.current;if(i){var n=null,a=setTimeout(function(){var d=function(e,i){var o=e.getBoundingClientRect(),n=i.getBoundingClientRect();return o.bottom<n.top?"above":o.top>n.bottom?"below":"inside"};n=o.debounce(function(){h(function(n){var c=e.__assign({},n);return t.forEach(function(e,n){var t=s?!!u["left-".concat(n)]:!!u[String(n)],r=!1,f=!1,a=null,R=null,h=null,g=null;t&&(null==e?void 0:e.id)&&(l[e.id]||[]).forEach(function(n){var t="".concat(n.id).concat(o.DEVIATION_BADGE_SEPARATOR,"0"),l=v.current[t];if(null==l?void 0:l.current){var u=d(l.current,i);h||(h=l,g=u),"above"===u?(r=!0,a=l):"below"!==u||f?w.current===e.id&&(w.current=""):(f=!0,R=l)}}),e.id&&(c[e.id]={showAbove:r,showBelow:f,showAboveRef:a,showBelowRef:R,firstDeviationRef:h,firstDeviationPosition:g,columnKey:"left"})}),s||r.forEach(function(e,n){var t=!!u[String(n)],r=!1,s=!1,v=null,a=null,R=null,h=null;t&&(null==e?void 0:e.id)&&(l[e.id]||[]).forEach(function(n){var t,l,u,g,b,B=!(null===(t=n.refIndexes)||void 0===t?void 0:t.length)||void 0!==n.selfIndex&&n.selfIndex<0,A="".concat(n.id).concat(o.DEVIATION_BADGE_SEPARATOR,"0"),D=f.current[A];if((null==D?void 0:D.current)&&B&&(null==e?void 0:e.id)){var p=d(D.current,i);if(R||(R=D,h=p),"above"===p){var E=null===(u=null===(l=c[e.id])||void 0===l?void 0:l.showAboveRef)||void 0===u?void 0:u.current;(!E||E.getBoundingClientRect().top<D.current.getBoundingClientRect().top)&&(r=!0,v=D)}else if("below"!==p||s)w.current===e.id&&(w.current="");else{var m=null===(b=null===(g=c[e.id])||void 0===g?void 0:g.showBelowRef)||void 0===b?void 0:b.current;(!m||m.getBoundingClientRect().top>D.current.getBoundingClientRect().top)&&(s=!0,a=D)}}}),e.id&&t&&(r&&(c[e.id]=c[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,firstDeviationRef:null,firstDeviationPosition:null,columnKey:"right"},c[e.id].showAbove=r,c[e.id].showAboveRef=v,c[e.id].firstDeviationRef=R,c[e.id].firstDeviationPosition=h,c[e.id].columnKey="right"),s&&(c[e.id]=c[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,firstDeviationRef:null,firstDeviationPosition:null,columnKey:"right"},c[e.id].showBelow=s,c[e.id].showBelowRef=a,c[e.id].firstDeviationRef=R,c[e.id].firstDeviationPosition=h,c[e.id].columnKey="right"))}),c})},100),n(),null==i||i.addEventListener("scroll",n)},0);return function(){clearTimeout(a),n&&i.removeEventListener("scroll",n)}}}},[t,r,l,u,s,d,c,v,f]),{showDeviationNavigation:R,showOpenNodeRef:w}};
2
2
  //# sourceMappingURL=useDeviationNavigation.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as c,useCallback as u}from"react";import{Box as d,Snackbar as a,Alert as s,Tooltip as v,Typography as p}from"@mui/material";import{ChevronDown as f,EllipsisVertical as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import x from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as y,generateColorPalette as b,DEVIATION_BADGE_SEPARATOR as S,hasValue as R,getBentArrowPath as C,smoothScrollTo as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as I,DEFAULT_FIELD_CONFIG as B,DEFAULT_COMPARISON_CONFIG as w}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as E,DEFAULT_COMPONENT_HEADER_TEXT as F}from"./CognitiveCompareConstants.js";import _ from"./CognitivePopup.js";import k from"./MoreFunctionsPopup.js";import M from"./LoaderComponent.js";import D from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as A}from"./hooks/useComparePopups.js";import{useSectionRefs as L}from"./hooks/useSectionRefs.js";import{useAccordionState as O}from"./hooks/useAccordionState.js";import{useDeviationNavigation as P}from"./hooks/useDeviationNavigation.js";import j from"./components/CompareHeader.js";import N from"./components/SectionAccordion.js";import z from"./components/SubSectionAccordion.js";import W from"./components/CognitiveSummaryPopup.js";var Y=function(Y){var K,V,X,q,J,U,G,Q,Z,$,ee,ne,te,ie,oe,re=Y.componentHeaderText,le=void 0===re?F:re,ce=Y.treeData,ue=Y.comparisonConfig,de=Y.leftColumnTitleText,ae=Y.rightColumnTitleText,se=Y.markdownStyles,ve=Y.displayConfig,pe=void 0===ve?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0}:ve,fe=Y.popupConfig,ge=Y.deviationData,he=void 0===ge?{}:ge,xe=Y.deviationNodeIdToView,me=o(pe.maintainRelativeOrder),ye=me[0],be=me[1],Se=o(!1),Re=Se[0],Ce=Se[1],Te=o(!1),Ie=Te[0],Be=Te[1],we=o(null),Ee=we[0],Fe=we[1],_e=o(!1),ke=_e[0],Me=_e[1],De=o(!1),He=De[0],Ae=De[1],Le=o(!1),Oe=Le[0],Pe=Le[1],je=o(null),Ne=je[0],ze=je[1],We=r(!1),Ye=o(new Set),Ke=Ye[0],Ve=Ye[1],Xe=o([]),qe=Xe[0],Je=Xe[1],Ue=r(null),Ge=r(!1),Qe=r(null),Ze=r({}),$e=r([]),en=r(!1),nn=r(!1),tn=r(null),on=r(function(){}),rn=l(function(){return(null==ce?void 0:ce.cognitive_decisioning)||{}},[ce]),ln=o({width:0,height:0}),cn=ln[0],un=ln[1],dn=l(function(){return e(e({},I),se)},[se]),an=r(null),sn=r(null),vn=r(null),pn=r(null),fn=r(null),gn=r(null),hn=r(null),xn=r(null),mn=r(!1),yn=A(an),bn=yn.cognitivePopup,Sn=yn.setCognitivePopup,Rn=yn.moreFunctions,Cn=yn.setMoreFunctions,Tn=yn.position,In=yn.setPosition,Bn=yn.activeBadgeId,wn=yn.summaryPopup,En=yn.setSummaryPopup,Fn=yn.closeSummaryPopup,_n=yn.setActiveBadgeId,kn=yn.popupRef,Mn=yn.closeCognitivePopup,Dn=yn.closeMoreFunctionsPopup,Hn=l(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==ue?void 0:ue.fields)&&void 0!==e?e:B,thresholds:{high:null!==(t=null===(n=null==ue?void 0:ue.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:w.thresholds.high,medium:null!==(o=null===(i=null==ue?void 0:ue.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:w.thresholds.medium,exact:null!==(l=null===(r=null==ue?void 0:ue.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:w.thresholds.exact}}},[ue]),An=o(null),Ln=An[0];An[1];var On=null===(X=null===(K=null==ce?void 0:ce.documents)||void 0===K?void 0:K[null===(V=null==ce?void 0:ce.input_index_map)||void 0===V?void 0:V[0]])||void 0===X?void 0:X.title,Pn=null===(U=null===(q=null==ce?void 0:ce.documents)||void 0===q?void 0:q[null===(J=null==ce?void 0:ce.input_index_map)||void 0===J?void 0:J[1]])||void 0===U?void 0:U.title,jn=m(de||On||"Uploaded Contract"),Nn=m(ae||Pn||"Reference Template"),zn=H(ce,ye,he,Hn),Wn=zn.activeProposed,Yn=zn.existingRule,Kn=zn.proposedSections,Vn=zn.existingSections,Xn=zn.visibleFields,qn=zn.parentDeviationRecord,Jn=zn.deviationNumberRegistry,Un=zn.parseError;c(function(){Un&&Fe("Failed to load comparison: ".concat(Un))},[Un]);var Gn=Kn.length>0||Vn.length>0,Qn=L(Xn.map(function(e){return e.key}),Math.max(Kn.length,Vn.length)),Zn=Qn.leftRefs,$n=Qn.rightRefs,et=Qn.sectionLeftRefs,nt=Qn.sectionRightRefs,tt=Qn.lhsBadgeRefs,it=Qn.rhsBadgeRefs,ot=Qn.sectionRightRowRefs,rt=Qn.subSectionLeftRefs,lt=Qn.subSectionRightRefs,ct=Qn.sectionRowRefs,ut=Qn.getSectionRowRef,dt=Qn.getSubSectionRef,at=Qn.getBadgeRef,st=Yn.analysis,vt=m(null===(Q=null===(G=null==st?void 0:st.rule_difference_comparison)||void 0===G?void 0:G.summary)||void 0===Q?void 0:Q.overall_summary),pt=!!vt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),ft=null!==(Z=null==ce?void 0:ce.base_root_id)&&void 0!==Z?Z:"-1";null==ce||ce[ft];var gt=(null===($=null==he?void 0:he[ft])||void 0===$?void 0:$.evaluation_result)||(null===(ne=null===(ee=null==ce?void 0:ce.nodes)||void 0===ee?void 0:ee[ft])||void 0===ne?void 0:ne.evaluation_result)||null,ht=y(gt),xt=b(null!==(oe=null===(ie=null===(te=null==gt?void 0:gt.evaluation_outputs)||void 0===te?void 0:te.metadata)||void 0===ie?void 0:ie.label_color)&&void 0!==oe?oe:""),mt=u(function(){var e,n,t,i;Me(!1),nn.current=!1;var o=tn.current,r=kt.current;if(null!==o)if("string"==typeof o&&o.includes(S)){var l=o.split(S);(c=null===(e=rt.current[l[2]])||void 0===e?void 0:e.current)&&(c.style.paddingTop="0px")}else{var c;(c=null===(n=et.current[o])||void 0===n?void 0:n.current)&&(c.style.paddingTop="0px")}if(null!==r)if("string"==typeof r&&r.includes(S)){l=r.split(S);(u=null===(t=lt.current[l[3]])||void 0===t?void 0:t.current)&&(u.style.paddingTop="0px")}else{var u;(u=null===(i=nt.current[r])||void 0===i?void 0:i.current)&&(u.style.paddingTop="0px")}ze(null),tn.current=null,kt.current=null,Ae(!1),Be(!1),pn.current&&(pn.current.style.height="0px"),fn.current&&(fn.current.style.height="0px"),gn.current&&(gn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px")},[]),yt=O({maintainRelativeOrder:!!ye,proposedSections:Kn,existingSections:Vn,activeSideBySideSection:Ne,connectedSections:Ke,resetSideBySide:mt,setConnectedSections:Ve,setConnectedLines:Je,cachedConnectedPositions:$e,svgContainerRef:Ue,isAnimatingRef:Ge,animationTimerRef:Qe,calculateLinesRef:on,sectionLeftRefs:et,sectionRightRefs:nt,subSectionLeftRefs:rt,subSectionRightRefs:lt}),bt=yt.expandedSections,St=yt.expandedSubSections,Rt=yt.setExpandedSubSections,Ct=yt.toggleSection,Tt=u(function(e,n,t,i,o,r,l){var c,u,d,a=m(null==n?void 0:n.id)||m(null==t?void 0:t.id)||"",s=(a?rn[a]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:a,decisioning:[],gap:[],relevance_score:0},v=null!==(u=null===(c=ct.current[i])||void 0===c?void 0:c.current)&&void 0!==u?u:null;return{isLoading:null!==(d=null==pe?void 0:pe.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==n?void 0:n.displayTitle)?null==n?void 0:n.title:"no title",refSectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",cognitiveData:s,anchorEl:e,sectionAnchorEl:v,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==ce?void 0:ce.documents,input_index_map:null==ce?void 0:ce.input_index_map},deviationData:(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,isOrphan:!!o}},[rn,ce]),It=u(function(e){Dn(),In(null),Sn(e)},[Dn]),Bt=function(e,n,t,i,o,r){e.stopPropagation(),Rn.open&&Rn.sectionIdx===o?Dn():(Mn(),Cn(Tt(e.currentTarget,n,i,o,t,r)))},wt=u(function(){null!==Rn.sectionIdx&&Rn.anchorEl?It(e(e({},Rn),{open:!0})):Dn()},[Rn,Dn,It]),Et=u(function(){var e=Rn.sectionIdx,n=Rn.isOrphan;Dn(),Fn(),null!==e&&(n?Fe("No counterpart exists to connect to."):(nn.current&&mt(),Je([]),$e.current=[],Ve(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){on.current&&on.current()},50)))},[Rn.sectionIdx,Rn.isOrphan,Dn,Fn,mt]),Ft=r(null),_t=r(null),kt=r(null),Mt=r(null),Dt=r(null),Ht=r(null),At=o([]),Lt=At[0],Ot=At[1];r(null);var Pt=o(null),jt=Pt[0],Nt=Pt[1];c(function(){if(Ln){var e=Hn.fields.find(function(e){return e.analysisKey===Ln||e.key===Ln});if(e){var n=Zn.current[e.key]||$n.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Ln,Hn.fields]);var zt=u(function(e){var n,t,i,o,r,l,c,u,d,a=null===(n=null==st?void 0:st.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!a||!a[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=a[e],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var p=s.mappings[0]||{};return{score:s.score,relation:p.relation||"",highlightsA:(null===(l=p.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=p.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(u=s.highlights)||void 0===u?void 0:u.ruleA_spans)||[],highlightsB:(null===(d=s.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!v}},[st]),Wt=u(function(n,t){var i,o,r,l,c,u,d;void 0===t&&(t="left");var a=null,s=null;if("left"===t)if(a=Kn[n],ye&&a){var v=Vn.filter(function(e){var n;return null===(n=a.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});s=v.find(function(e){return e.evaluationResult})||v[0]}else s=Vn[n];else if(s=Vn[n],ye&&s){var p=Kn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex)});a=p.find(function(e){return e.evaluationResult})||p[0]}else a=Kn[n];var f=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,g=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,h=!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData));if(!f&&!g&&!h)return e(e({},b(E)),{label:"Not Defined"});var x=null!==(o=null!==(i=null==a?void 0:a.evaluationResult)&&void 0!==i?i:null==s?void 0:s.evaluationResult)&&void 0!==o?o:null,m=null===(r=null==x?void 0:x.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(u=null===(c=null===(l=null==x?void 0:x.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===c?void 0:c.label_color)&&void 0!==u?u:E;return e(e({},b(y)),null!=x?{label:null!==(d=m)&&void 0!==d?d:""}:{label:null})},[Kn,Vn,rn,Hn,ye]),Yt=u(function(n){for(var t,i,o,r,l,c,u,d,a,s=n.split("-").map(Number),v=Kn[s[0]],p=Vn[s[0]],f=1;f<s.length;f++)(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]),(null==p?void 0:p.subsections)&&(p=p.subsections[s[f]]);if(!v&&!p)return null;var g=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,h=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,x=m(null==v?void 0:v.id)||m(null==p?void 0:p.id)||"",y=!(!(null==v?void 0:v.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!g&&!h&&!y)return e(e({},b(E)),{label:"Not Defined"});null!==(i=null!==(t=null==v?void 0:v.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||x&&(null===(o=rn[x])||void 0===o||o.relevance_score);var S=null!==(l=null!==(r=null==v?void 0:v.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,R=null===(c=null==S?void 0:S.evaluation_outputs)||void 0===c?void 0:c.output_value,C=null!==(a=null===(d=null===(u=null==S?void 0:S.evaluation_outputs)||void 0===u?void 0:u.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:E;return e(e({},b(C)),null!=S?{label:null!=R?R:""}:{label:null})},[Kn,Vn,rn,Hn]),Kt=u(function(){var e,n,t,i,o,r,l,c,u,d,a,s,v,p,f,g,h,x;if(!mn.current&&!Ge.current){mn.current=!0;try{if(!Ft.current)return;var m=function(e){var n=e.split("-"),t=n[0];if(!bt[t]&&!1===ye)return!1;if(ye&&!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]),!St[i])return!1;return!0},y=Ft.current.getBoundingClientRect();un({width:y.width,height:y.height});var b=[];if(Xn.forEach(function(e){var n,t,i=e.key,o=null===(n=Zn.current[i])||void 0===n?void 0:n.current,r=null===(t=$n.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")}),!Ge.current){for(var T=0;T<Math.max(Kn.length,Vn.length);T++){var I=null===(e=et.current[T])||void 0===e?void 0:e.current,B=null===(n=nt.current[T])||void 0===n?void 0:n.current;I&&(I.style.height="auto",I.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}ye||Object.keys(rt.current).forEach(function(e){var n,t;if(m(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 w={};Xn.forEach(function(e){var n,t,i=e.key,o=null===(n=Zn.current[i])||void 0===n?void 0:n.current,r=null===(t=$n.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect();w[i]=Math.max(l.height,c.height)}});var E={left:{},right:{}},F={};if(!Ge.current)if(ye){if(ke&&null!==Ne)if("number"==typeof Ne){var _=Ne,k=Kn[_],M=null===(o=et.current[_])||void 0===o?void 0:o.current;M&&k&&(k.refIndexes||[]).forEach(function(e){var n,t=Vn.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(_)]||bt["right-".concat(t)])){var o=Math.max(M.getBoundingClientRect().height,i.getBoundingClientRect().height);E.left[_]=Math.max(E.left[_]||0,o),E.right[t]=Math.max(E.right[t]||0,o)}})}else{var D=Ne.split(S)[2];if(D){I=null===(r=rt.current[D])||void 0===r?void 0:r.current,B=null===(l=lt.current[D])||void 0===l?void 0:l.current;if(I&&B){H=Math.max(I.getBoundingClientRect().height,B.getBoundingClientRect().height);F[D]=Math.max(F[D]||0,H)}}}}else{Object.keys(rt.current).forEach(function(e){var n,t;if(m(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(),c=Math.max(r.height,l.height);F[e]=c,i.style.minHeight="".concat(c,"px"),o.style.minHeight="".concat(c,"px")}}});for(T=0;T<Math.min(Kn.length,Vn.length);T++){var I=null===(t=et.current[T])||void 0===t?void 0:t.current,B=null===(i=nt.current[T])||void 0===i?void 0:i.current;if(I&&B){var H=Math.max(I.getBoundingClientRect().height,B.getBoundingClientRect().height);E.left[T]=H,E.right[T]=H}}}if(Xn.forEach(function(e){var n,t,i=e.key,o=null===(n=Zn.current[i])||void 0===n?void 0:n.current,r=null===(t=$n.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=w[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Ge.current||(Object.entries(E.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(E.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"))}),ye||Object.keys(F).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&&F[e]){var r=F[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),ye)Kn.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,c,u=Vn.findIndex(function(n){return n.selfIndex===e});if(-1!==u){var d=null===(t=tt.current[n])||void 0===t?void 0:t.current,a=null===(i=it.current[u])||void 0===i?void 0:i.current;if(d&&a){var s,v,p,f=d.getBoundingClientRect(),g=a.getBoundingClientRect(),h=f.right-y.left,x=g.left-y.left,m=f.top+f.height/2-y.top,S=g.top+g.height/2-y.top;if(ke&&Ne===n){var R=null!==(r=null===(o=xn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,C=R+(null!==(c=null===(l=xn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0),T=f.top+f.height/2;s=T,v=R,p=C,S=m=Math.max(v,Math.min(p,s))-y.top}var I=Wt(n);I&&b.push({id:"line-".concat(n,"-").concat(u),x1:h,y1:m,x2:x,y2:S,style:I,sectionIdx:n,targetRightIdx:u})}}})});else{for(T=0;T<Math.min(Kn.length,Vn.length);T++){var A=null===(c=et.current[T])||void 0===c?void 0:c.current,L=null===(u=nt.current[T])||void 0===u?void 0:u.current;if(A&&L){var O=A.getBoundingClientRect(),P=L.getBoundingClientRect(),j=Math.max(O.top,P.top)+18-y.top,N=(null===(d=Vn[T])||void 0===d?void 0:d.id)||"sec-".concat(T);(J=Wt(T))&&b.push({id:N,x1:O.right-y.left,y1:j,x2:P.left-y.left,y2:j,style:J,sectionIdx:T,hasCognitive:!!((null===(a=Kn[T])||void 0===a?void 0:a.cognitiveData)||(null===(s=Vn[T])||void 0===s?void 0:s.cognitiveData)||N&&rn[N]),isSubSection:!1})}}Object.keys(rt.current).forEach(function(e){var n,t,i,o,r,l;if(m(e)){var c=null===(n=rt.current[e])||void 0===n?void 0:n.current,u=null===(t=lt.current[e])||void 0===t?void 0:t.current;if(c&&u){for(var d=e.split("-").map(Number),a=Kn[d[0]],s=Vn[d[0]],v=1;v<d.length;v++)(null==a?void 0:a.subsections)&&(a=a.subsections[d[v]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[v]]);var p=!!a&&((null===(i=a.displayTitle)||void 0===i||i)&&R(a.title)),f=!!a&&((null===(o=a.displayContent)||void 0===o||o)&&R(a.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&R(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&R(s.content));if(p&&f||g&&h){var x=c.getBoundingClientRect(),S=u.getBoundingClientRect(),C=Math.max(x.top,S.top)+16-y.top,T=Yt(e);T&&"Not Defined"!==T.label&&b.push({id:"subsec-".concat(e),x1:x.right-y.left,y1:C,x2:S.left-y.left,y2:C,style:T,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(ke&&"string"==typeof Ne&&Ne.includes(S)){var z=Ne.split(S),W=z[0],Y=z[1],K=z[2],V=(z[3],"".concat(W).concat(S).concat(Y)),X=null===(v=tt.current[V])||void 0===v?void 0:v.current,q=null===(p=it.current[V])||void 0===p?void 0:p.current;if(X&&q){var J,U=X.getBoundingClientRect(),G=q.getBoundingClientRect(),Q=U.right-y.left,Z=G.left-y.left,$=U.top+U.height/2-y.top,ee=(G.top,G.height,y.top);if(ye){var ne=null!==(g=null===(f=xn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,te=ne+(null!==(x=null===(h=xn.current)||void 0===h?void 0:h.clientHeight)&&void 0!==x?x:1/0);me=U.top+U.height/2,be=ne,Se=te,$=Math.max(be,Math.min(Se,me))-y.top}ee=$,(J=Yt(K))&&b.push({id:"line-subsec-".concat(V),x1:Q,y1:$,x2:Z,y2:ee,style:J,sectionIdx:Number(K.split("-")[0]),isSubSection:!0,subSectionKeyPath:Ne})}}if(Ot(b),Dt.current&&Ht.current){var ie=Dt.current.getBoundingClientRect(),oe=Ht.current.getBoundingClientRect(),re=(ie.top+ie.height/2-y.top+oe.top+oe.height/2-y.top)/2;Nt({x1:ie.right-y.left,x2:oe.left-y.left,y:re})}else Nt(null);if(Ke.size>0){var le=[],ce=xn.current,ue=vn.current;if(ce&&ue){var de=[],ae=ce.getBoundingClientRect().top,se=ue.getBoundingClientRect().top,ve=ae+ce.clientHeight,pe=se+ue.clientHeight,fe=ce.scrollTop,ge=ue.scrollTop,he=y.top,xe=function(e,n,t){return Math.max(n,Math.min(t,e))};Ke.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(S)){var l=e.split(S),c=l[0],u=l[1],d=l[2],a=(l[3],"".concat(c).concat(S).concat(u)),s=null===(n=tt.current[a])||void 0===n?void 0:n.current,v=null===(t=it.current[a])||void 0===t?void 0:t.current;if(!s||!v)return;var p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=Yt(d),h=(A=p.right-y.left)+.5*((L=f.left-y.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,b=x-ae+fe,R=m-se+ge,T="conn-subsec-".concat(a);de.push({lhsScrollY:b,rhsScrollY:R,x1:A,x2:L,containerTop:he,leftIdx:e,rhsArrayIdx:e,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:T});var I=xe(x,ae,ve),B=xe(m,se,pe),w=I-he,E=B-he,F=m>=se-4&&m<=pe+4,_="";_=(O=x>=ae-4&&x<=ve+4)&&F?C(A,w,L,E):O&&!F?"M ".concat(A,",").concat(w," L ").concat(h,",").concat(w," L ").concat(h,",").concat(E):!O&&F?"M ".concat(h,",").concat(w," L ").concat(h,",").concat(E," L ").concat(L,",").concat(E):"M ".concat(h,",").concat(w," L ").concat(h,",").concat(E),le.push({id:T,pathD:_,style:g,leftIdx:e,rhsArrayIdx:e})}else if(ye){var k=e,M=Kn[k];if(!(null===(r=null==M?void 0:M.refIndexes)||void 0===r?void 0:r.length))return;M.refIndexes.forEach(function(e){var n,t,i=Vn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=tt.current[k])||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(),u=Wt(k),d=l.right-y.left,a=c.left-y.left-0,s=d+.5*(a-d),v=l.top+l.height/2,p=c.top+c.height/2,f=v-ae+fe,g=p-se+ge,h="conn-".concat(k,"-").concat(i);de.push({lhsScrollY:f,rhsScrollY:g,x1:d,x2:a,containerTop:he,leftIdx:k,rhsArrayIdx:i,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:h});var x=xe(v,ae,ve),m=xe(p,se,pe),b=x-he,S=m-he,R=v>=ae-4&&v<=ve+4,T=p>=se-4&&p<=pe+4,I="";I=R&&T?C(d,b,a,S):R&&!T?"M ".concat(d,",").concat(b," L ").concat(s,",").concat(b," L ").concat(s,",").concat(S):!R&&T?"M ".concat(s,",").concat(b," L ").concat(s,",").concat(S," L ").concat(a,",").concat(S):"M ".concat(s,",").concat(b," L ").concat(s,",").concat(S),le.push({id:h,pathD:I,style:u,leftIdx:k,rhsArrayIdx:i})}}})}else{var D=e,H=D;s=null===(i=tt.current[D])||void 0===i?void 0:i.current,v=null===(o=it.current[H])||void 0===o?void 0:o.current;if(!s||!v)return;var A,L;p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=Wt(D),h=(A=p.right-y.left)+.5*((L=f.left-y.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,b=x-ae+fe,R=m-se+ge,T="conn-".concat(D,"-").concat(H);de.push({lhsScrollY:b,rhsScrollY:R,x1:A,x2:L,containerTop:he,leftIdx:D,rhsArrayIdx:H,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:T});var O;I=xe(x,ae,ve),B=xe(m,se,pe),w=I-he,E=B-he,F=m>=se-4&&m<=pe+4,_="";_=(O=x>=ae-4&&x<=ve+4)&&F?C(A,w,L,E):O&&!F?"M ".concat(A,",").concat(w," L ").concat(h,",").concat(w," L ").concat(h,",").concat(E):!O&&F?"M ".concat(h,",").concat(w," L ").concat(h,",").concat(E," L ").concat(L,",").concat(E):"M ".concat(h,",").concat(w," L ").concat(h,",").concat(E),le.push({id:T,pathD:_,style:g,leftIdx:D,rhsArrayIdx:H})}}),$e.current=de}Je(le)}else Je([]),$e.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{mn.current=!1}var me,be,Se}},[Xn,Kn,Vn,rn,Hn,zt,Wt,ye,ke,Ne,Ke,bt,St]),Vt=u(function(){var e,n,t,i,o,r,l,c,u,d,a,s,v,p,f=$e.current;if(f.length&&!Ge.current){var g=null!==(n=null===(e=xn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,h=null!==(i=null===(t=vn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=xn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=vn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,y=null!==(d=null===(u=xn.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,b=null!==(s=null===(a=vn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,R=b+m,T=null!==(p=null===(v=Ft.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,I=function(e,n,t){return Math.max(n,Math.min(t,e))};f.forEach(function(e){var n=e.lhsScrollY-g+y,t=e.rhsScrollY-h+b,i=Ze.current[e.styleId+"-stroke"],o=Ze.current[e.styleId+"-bg"];if(i||o){var r,l=I(n,y,S),c=I(t,b,R),u=l-T,d=c-T,a=n>=y-4&&n<=S+4,s=t>=b-4&&t<=R+4,v=e.x1+.5*(e.x2-e.x1);r=a&&s?C(e.x1,u,e.x2,d):a&&!s?"M ".concat(e.x1,",").concat(u," L ").concat(v,",").concat(u," L ").concat(v,",").concat(d):!a&&s?"M ".concat(v,",").concat(u," L ").concat(v,",").concat(d," L ").concat(e.x2,",").concat(d):"M ".concat(v,",").concat(u," L ").concat(v,",").concat(d),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);c(function(){on.current=Kt},[Kt]);var Xt=r(null),qt=r(null),Jt=u(function(){$e.current.length>0&&!Ge.current||(null!==Xt.current&&clearTimeout(Xt.current),Xt.current=setTimeout(function(){on.current(),Xt.current=null},50))},[]),Ut=u(function(){Pe(!0),Ae(!1),null!==qt.current&&clearTimeout(qt.current),null!==Xt.current&&(clearTimeout(Xt.current),Xt.current=null),qt.current=setTimeout(function(){var e,n,t,i,o,r,l,c;if($e.current=[],nn.current&&null!==tn.current&&null!==kt.current){var u=tn.current,d=kt.current,a=null,s=null,v=null,p=null;if("string"==typeof u&&u.includes(S)){var f=u.split(S),g="".concat(f[0]).concat(S).concat(f[1]);a=(null===(e=tt.current[g])||void 0===e?void 0:e.current)||null,s=(null===(n=it.current[g])||void 0===n?void 0:n.current)||null,v=(null===(t=rt.current[f[2]])||void 0===t?void 0:t.current)||null,p=(null===(i=lt.current[f[3]])||void 0===i?void 0:i.current)||null}else a=(null===(o=ct.current[u])||void 0===o?void 0:o.current)||null,v=(null===(r=et.current[u])||void 0===r?void 0:r.current)||null,s=(null===(l=ot.current[d])||void 0===l?void 0:l.current)||null,p=(null===(c=nt.current[d])||void 0===c?void 0:c.current)||null;if(a&&s&&v&&p){if(v.style.paddingTop="0px",p.style.paddingTop="0px",!ye){var h=a.getBoundingClientRect(),x=s.getBoundingClientRect(),m=h.top-x.top;m>0?p.style.paddingTop="".concat(m,"px"):m<0&&(v.style.paddingTop="".concat(Math.abs(m),"px"))}var y=xn.current,b=vn.current;if(y&&b){var R=a.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,C=s.getBoundingClientRect().top-b.getBoundingClientRect().top+b.scrollTop-(R-y.scrollTop);Math.abs(b.scrollTop-C)>1&&(b.scrollTop=C)}}}on.current(),nn.current&&Ae(!0),Pe(!1),qt.current=null},150)},[ye,Kn,Vn]),Gt=u(function(e){var n,t,i,o,r,l,c,u,d,a;if(!We.current){if(ye||Jt(),nn.current){var s=tn.current,v=kt.current,p=xn.current,f=vn.current;if(null!==s&&null!==v&&p&&f){var g="string"==typeof s&&s.includes(S)?null===(n=tt.current["".concat(s.split(S)[0]).concat(S).concat(s.split(S)[1])])||void 0===n?void 0:n.current:null===(t=ct.current[s])||void 0===t?void 0:t.current,h="string"==typeof v&&v.includes(S)?null===(i=it.current["".concat(v.split(S)[0]).concat(S).concat(v.split(S)[1])])||void 0===i?void 0:i.current:null===(o=ot.current[v])||void 0===o?void 0:o.current;if(g&&h){var x=g.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop,m=h.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop;if(e.currentTarget===p){var y=m-(x-p.scrollTop),b=f.scrollHeight-f.clientHeight,R=Math.max(0,Math.min(y,b));Math.abs(f.scrollTop-R)>1&&(f.scrollTop=R)}else if(e.currentTarget===f){var C=x-(m-f.scrollTop),T=p.scrollHeight-p.clientHeight,I=Math.max(0,Math.min(C,T));Math.abs(p.scrollTop-I)>1&&(p.scrollTop=I)}if(Mt.current){var B=void 0,w=void 0;if("string"==typeof s&&s.includes(S)){var E=s.split(S),F="".concat(E[0]).concat(S).concat(E[1]);B=null===(r=tt.current[F])||void 0===r?void 0:r.current,w=null===(l=it.current[F])||void 0===l?void 0:l.current}else B=null===(c=tt.current[s])||void 0===c?void 0:c.current,w=null===(u=it.current[v])||void 0===u?void 0:u.current;var _=null!==(a=null===(d=Ft.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==a?a:0,k=p.getBoundingClientRect().top,M=k+p.clientHeight;f.getBoundingClientRect().top;f.clientHeight;if(B&&w){var D=B.getBoundingClientRect(),H=w.getBoundingClientRect(),A=D.top+D.height/2;H.top,H.height;var L=((P=A,j=k,N=M,Math.max(j,Math.min(N,P)))-_).toString();Mt.current.setAttribute("y1",L),Mt.current.setAttribute("y2",L);var O=A>=k-4&&A<=M+4;Mt.current.setAttribute("visibility",O?"visible":"hidden")}}}}}var P,j,N;$e.current.length>0&&!en.current&&(en.current=!0,requestAnimationFrame(function(){Vt(),en.current=!1}))}},[Vt,ye,Jt]);c(function(){var e=setTimeout(Jt,250);window.addEventListener("resize",Ut);var n=null,t=null;return an.current&&(n=new ResizeObserver(Jt)).observe(an.current),Ft.current&&(t=new ResizeObserver(Jt)).observe(Ft.current),function(){clearTimeout(e),null!==Xt.current&&clearTimeout(Xt.current),null!==qt.current&&clearTimeout(qt.current),window.removeEventListener("resize",Ut),null==n||n.disconnect(),null==t||t.disconnect()}},[Wn,Yn,st,Xn,bt,St,Kn,Vn,Hn,Jt,Ut,ke,Ne,He,Ke]),c(function(){nn.current=ke},[ke]),c(function(){tn.current=Ne},[Ne]);var Qt=u(function(e,n,t){var i,o,r,l,c,u,d=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,a=null==t?void 0:t.onReady,s=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";if(Dn(),null!=e)if(n)Fe("No counterpart exists for this section.");else if(ke&&Ne===e)d?mt():null==a||a();else{if(!ye){var v=tn.current,p=kt.current;if(null!==v)if("string"==typeof v&&v.includes(S)){var f=v.split(S);(g=null===(r=rt.current[f[2]])||void 0===r?void 0:r.current)&&(g.style.paddingTop="0px")}else{var g;(g=null===(l=et.current[v])||void 0===l?void 0:l.current)&&(g.style.paddingTop="0px")}if(null!==p)if("string"==typeof p&&p.includes(S)){f=p.split(S);(h=null===(c=lt.current[f[3]])||void 0===c?void 0:c.current)&&(h.style.paddingTop="0px")}else{var h;(h=null===(u=nt.current[p])||void 0===u?void 0:u.current)&&(h.style.paddingTop="0px")}}Ve(new Set),Je([]),$e.current=[],Be(!0),We.current=!0,ze(e),tn.current=e,Me(!0),nn.current=!0,Ae(!1),pn.current&&(pn.current.style.height="0px"),fn.current&&(fn.current.style.height="0px"),gn.current&&(gn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,l,c,u,d,v,p=null,f=null,g=null,h=null,x=null;if("string"==typeof e&&e.includes(S)){var m=e.split(S),y="".concat(m[0]).concat(S).concat(m[1]);p=(null===(n=tt.current[y])||void 0===n?void 0:n.current)||null,x=(f=(null===(t=it.current[y])||void 0===t?void 0:t.current)||null)?e:null,g=(null===(i=rt.current[m[2]])||void 0===i?void 0:i.current)||null,h=(null===(o=lt.current[m[3]])||void 0===o?void 0:o.current)||null}else if(p=(null===(r=ct.current[e])||void 0===r?void 0:r.current)||null,g=(null===(l=et.current[e])||void 0===l?void 0:l.current)||null,ye){var b=Kn[e],R=(null==b?void 0:b.refIndexes)||[];if(R.length>0){var C=R[0],I=Vn.findIndex(function(e){return e.selfIndex===C});-1!==I&&(f=(null===(d=ot.current[I])||void 0===d?void 0:d.current)||null,h=(null===(v=nt.current[I])||void 0===v?void 0:v.current)||null,x=I)}}else f=(null===(c=ot.current[e])||void 0===c?void 0:c.current)||null,h=(null===(u=nt.current[e])||void 0===u?void 0:u.current)||null,x=f?e:null;kt.current=x;var B=xn.current,w=vn.current;if(!p||!B)return We.current=!1,Be(!1),void(null==a||a());if(!f||!w)return Ae(!0),on.current(),We.current=!1,Be(!1),void(null==a||a());if(!ye){var E=p.getBoundingClientRect(),F=f.getBoundingClientRect(),_=E.top-F.top;g&&h&&(g.style.paddingTop="0px",h.style.paddingTop="0px",_>0?h.style.paddingTop="".concat(_,"px"):_<0&&(g.style.paddingTop="".concat(Math.abs(_),"px")));var k=0;k="right"===s?f?f.getBoundingClientRect().top:(null==h?void 0:h.getBoundingClientRect().top)||0:p?p.getBoundingClientRect().top:(null==g?void 0:g.getBoundingClientRect().top)||0;var M=an.current,D=M?M.scrollTop+k-150:0;return M?void T(M,D,200,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()}):(Ae(!0),on.current(),We.current=!1,Be(!1),void(null==a||a()))}var H=p.getBoundingClientRect().top-B.getBoundingClientRect().top+B.scrollTop,A=f.getBoundingClientRect().top-w.getBoundingClientRect().top+w.scrollTop,L=200;if("left"===s){var O=A-(H-B.scrollTop);O<0&&pn.current&&(pn.current.style.height="".concat(Math.abs(O),"px")),requestAnimationFrame(function(){var e,n=w.scrollHeight-w.clientHeight;if(O<0)e=0;else{if(O>n){var t=O-n;return fn.current&&(fn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(w,O,L,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()})})}e=O}T(w,e,L,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()})})}else{var P=H-(A-w.scrollTop);P<0&&gn.current&&(gn.current.style.height="".concat(Math.abs(P),"px")),requestAnimationFrame(function(){var e,n=B.scrollHeight-B.clientHeight;if(P<0)e=0;else{if(P>n){var t=P-n;return hn.current&&(hn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(B,P,L,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()})})}e=P}T(B,e,L,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()})})}})}},[Ne,Dn,Vn,ke,ye,Kn,mt]),Zt=u(function(e,n,t,i){var o,r="string"==typeof i?m(i).trim():m(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;Mn();var c="left";(null===(o=vn.current)||void 0===o?void 0:o.contains(l))&&(c="right"),t?r&&En({open:!0,anchorEl:l,summary:i}):Qt(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){En({open:!0,anchorEl:l,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[Qt,Mn,En]),$t=u(function(){var e,n=Rn.sectionIdx,t=Rn.isOrphan;if(Fn(),null!=n){var i="left";Rn.anchorEl&&(null===(e=vn.current)||void 0===e?void 0:e.contains(Rn.anchorEl))&&(i="right"),Qt(n,t,{sourceSide:i})}},[Qt,Rn.isOrphan,Rn.sectionIdx,Rn.anchorEl,Fn]),ei=u(function(){Fn(),mt()},[Fn,mt]),ni=null!==Rn.sectionIdx&&Ke.has(Rn.sectionIdx),ti=P({proposedSections:Kn,existingSections:Vn,parentDeviationRecord:qn,expandedSections:bt,maintainRelativeOrder:!!ye,scrollContainerRef:an,leftContainerRef:xn,lhsBadgeRefs:tt,rhsBadgeRefs:it}),ii=ti.showDeviationNavigation,oi=ti.showOpenNodeRef,ri=l(function(){if(!xe)return null;for(var e in qn){if((qn[e]||[]).some(function(e){return e.id===xe}))return e}return null},[xe,qn]),li=r(null);c(function(){if(xe&&li.current!==xe){var e=!1,t=0,i=null,o=150,r=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},l=function(){var c,u,d,a;if(!e){var s=null,v=null;for(var p in qn){var f=qn[p].find(function(e){return e.id===xe});if(f){s=p,v=f;break}}if(v&&s){var g=Kn.findIndex(function(e){return e.id===s});if(!(ye?!!bt["left-".concat(g)]:!!bt[String(g)])&&g>=0)return Ct(g,"left"),t+=1,void(i=setTimeout(l,450));var h=r(Kn,v.id),x=r(Vn,v.id);if(h&&!x){var m=h.split("-"),y=Number(m[0]);if(ye){var b=null===(u=null===(c=Kn[y])||void 0===c?void 0:c.refIndexes)||void 0===u?void 0:u[0],R=Vn.findIndex(function(e){return e.selfIndex===b});-1!==R&&(y=R)}x=n([y],m.slice(1),!0).join("-")}if(h&&x){var C="".concat(v.id).concat(S,"0").concat(S).concat(h).concat(S).concat(x),I="".concat(v.id).concat(S,"0"),B=null===(d=tt.current[I])||void 0===d?void 0:d.current,w=null===(a=it.current[I])||void 0===a?void 0:a.current,E=ye?xn.current:an.current;if(B&&E){var F=B.getBoundingClientRect();if(0===F.height)return void((t+=1)<20&&(i=setTimeout(l,o)));var _=E.getBoundingClientRect(),k=F.top-_.top+E.scrollTop-_.height/2+F.height/2,M=function(){var e=window.getComputedStyle(B).color;B.style.transition="box-shadow 300ms ease-in-out",B.style.boxShadow="0 0 10px ".concat(e),w&&(w.style.transition="box-shadow 300ms ease-in-out",w.style.boxShadow="0 0 10px ".concat(e)),setTimeout(function(){B&&(B.style.boxShadow=""),w&&(w.style.boxShadow="")},2e3)},D=function(){var e,n,t,i=(null==v?void 0:v.evaluationResult)||(null===(e=null==he?void 0:he[null==v?void 0:v.id])||void 0===e?void 0:e.evaluation_result)||(null===(t=null===(n=null==ce?void 0:ce.nodes)||void 0===n?void 0:n[null==v?void 0:v.id])||void 0===t?void 0:t.evaluation_result)||null,o=(null==i?void 0:i.deviations)||{},r=Object.keys(o).sort()[0]||null,l=r?o[r]:null,c=(null==l?void 0:l.deviation_summary)||"";En({open:!0,anchorEl:B,summary:{deviation_summary:c,deviation_title:null==i?void 0:i.deviation_title,evaluation_outputs:null==i?void 0:i.evaluation_outputs}})};li.current=xe,ye?(E.scrollTo({top:k,behavior:"smooth"}),Qt(C,!1,{toggleIfSame:!1}),D(),setTimeout(function(){on.current()},0),M()):T(E,k,300,function(){e||(Qt(C,!1,{toggleIfSame:!1}),D(),setTimeout(function(){on.current()},0),M())})}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}};return i=setTimeout(l,o),function(){e=!0,i&&clearTimeout(i)}}},[xe,qn,Kn,Vn,ye,bt,Ct,he,ce,En,Qt]);var ci=function(e){var n=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,c=void 0===l?"left":l,u=e.parentNodeId;return i(z,{section:n,keyPath:t,depth:r,columnKey:c,parentNodeId:void 0===u?"":u,expandedSubSections:St,setExpandedSubSections:Rt,maintainRelativeOrder:ye||!1,proposedSections:Kn,existingSections:Vn,treeData:ce,deviationNumberRegistry:Jn,connectedSections:Ke,activeSideBySideSection:Ne,resolvedMarkdownStyles:dn,getSubSectionRef:dt,getSubSectionCompareStyle:Yt,getBadgeRef:at,openMoreFunctionsPopup:Bt,openSummaryPopup:Zt,resetSideBySide:mt,setConnectedSections:Ve,setConnectedLines:Je,cachedConnectedPositions:$e})};return t(d,e({ref:sn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ye?{}:{overflow:"visible"}),{position:"relative"})},{children:[Re&&i(d,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(M,{})})),wn.open&&i(W,{open:wn.open,anchorEl:wn.anchorEl,containerEl:_t.current,clipTopEl:Dt.current,onClose:ei,summary:wn.summary}),i(k,{open:Rn.open,anchorEl:Rn.anchorEl,sectionTitle:Rn.sectionTitle,referenceSectionTitle:Rn.refSectionTitle,onClose:Dn,onOpenCognitiveCompare:wt,onOpenSideBySide:$t,onConnect:Et,isConnected:ni,isOrphan:Rn.isOrphan}),bn.open&&i(_,{open:bn.open,popupRef:kn,position:Tn,popupConfig:fe,onClose:function(){In(null),Sn(function(n){return e(e({},n),{open:!1})}),_n(null)},markdownStyles:se,sectionTitle:bn.sectionTitle,referenceSectionTitle:bn.refSectionTitle,cognitiveData:bn.cognitiveData,anchorEl:bn.anchorEl,sectionAnchorEl:bn.sectionAnchorEl,scrollContainerEl:an.current,badgeStyle:bn.badgeStyle,docData:bn.docData,deviationData:bn.deviationData,isLoading:bn.isLoading}),i(a,e({open:!!Ee,autoHideDuration:8e3,onClose:function(){return Fe(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,e({onClose:function(){return Fe(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Ee}))})),i(j,{componentHeaderText:le,displayConfig:pe,maintainRelativeOrder:ye,onToggleView:function(e){Ce(!0),setTimeout(function(){be(!e),mt(),Ve(new Set),Je([]),$e.current=[],setTimeout(function(){Ce(!1)},400)},50)}}),i(d,e({ref:an,onScroll:Gt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ye?"hidden":"auto",borderTop:vt&&pt?"none":"1.5px solid #EEF0F4"}},{children:i(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ye?{flex:1,minHeight:0}:{})},{children:t(d,e({ref:Ft,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ye?{flex:1,overflow:"visible"}:{})},{children:[t("svg",e({ref:Ue,style:{position:"absolute",top:0,left:0,width:cn.width||"100%",height:cn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Oe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[jt&&i("g",{children:i("line",{x1:jt.x1,y1:jt.y,x2:jt.x2,y2:jt.y,stroke:xt.badgeBorder,strokeWidth:"1.5"})}),Lt.map(function(n){var o,r,l,c,u,a,s=n.x1+.5*(n.x2-n.x1),v=(n.y1+n.y2)/2;if("Not Defined"===n.style.label&&!n.hasCognitive)return null;if(n.isSubSection?ke&&Ne===n.subSectionKeyPath&&He:ke&&Ne===n.sectionIdx&&He)return t("g",e({style:{transition:"opacity 0.2s"}},{children:[i("defs",{children:i("marker",e({id:"arr-".concat(n.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:i("polygon",{points:"0 0, 7 2.5, 0 5",fill:n.style.badgeBorder||"#6366F1"})}))}),i("line",{ref:Mt,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(n.id,")")})]}),n.id);if(!ye){var p=n.isSubSection?C(n.x1,n.y1,n.x2,n.y2):"M ".concat(n.x1," ").concat(n.y1," L ").concat(n.x2," ").concat(n.y2),g=Kn[n.sectionIdx]||{title:"",content:""},x=Vn[n.sectionIdx]||{title:"",content:""};if(n.isSubSection&&n.subSectionKeyPath){for(var m=n.subSectionKeyPath.split(S)[2].split("-").map(Number),y=Kn[m[0]],b=Vn[m[0]],R=(null==y?void 0:y.title)||"",T=(null==b?void 0:b.title)||"",I=1;I<m.length;I++)(null==y?void 0:y.subsections)&&(y=y.subsections[m[I]]),(null==b?void 0:b.subsections)&&(b=b.subsections[m[I]]);y&&(g=e(e({},y),{title:R||y.title})),b&&(x=e(e({},b),{title:T||b.title}))}var B=!(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),w=(null===(a=null===(u=null===(c=g.evaluationResult)||void 0===c?void 0:c.cognitive_decisioning)||void 0===u?void 0:u.decisioning_factors)||void 0===a?void 0:a.length)||!1,F=B||w;return t("g",{children:[i("path",{d:p,fill:"none",stroke:n.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",e({x:s-100,y:v-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,e({onClick:function(e){e.stopPropagation(),F&&(bn.open&&Bn===n.id?Mn():(_n(n.id),It(Tt(e.currentTarget,g,x,n.sectionIdx,n.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:F?"pointer":"default"}},{children:[n.style.badgeText===E&&null==n.style.label?i(D,{color:n.style.badgeText}):0===n.style.label?"Same":n.style.label,i(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),F&&i(f,{size:11,style:{transform:bn.open&&Bn===n.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},n.id)}return null}),qe.map(function(n){var o,r=n.pathD,l=(null===(o=n.style)||void 0===o?void 0:o.badgeBorder)||"#6366F1",c="conn-marker-".concat(n.id),u="".concat(n.id,"-bg"),d="".concat(n.id,"-stroke");return t("g",{children:[i("defs",{children:i("clipPath",e({id:"connections-clip"},{children:i("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:i("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),i("path",{ref:function(e){Ze.current[u]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(e){Ze.current[d]=e},d:r,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},n.id)})]})),t(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ye?{flex:1,overflow:"visible"}:{})},{children:[i(d,e({ref:Dt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:i(v,e({title:jn,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:jn}))}))})),t(d,e({ref:xn,onScroll:Gt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ye?{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:gn,style:{width:"100%",height:"0px",flexShrink:0}}),Gn&&Kn.map(function(n,o){var r,l,c=!n.title&&!n.content;if(ye&&c)return null;var u=n,a=Wt(o,"left"),s=ye?!(null===(r=u.refIndexes)||void 0===r?void 0:r.length)||u.selfIndex<0:!Vn[o],v=ye?"number"==typeof u.selfIndex&&u.selfIndex>=0?u.selfIndex+1:null:o+1,p=Ke.has(o),f=y(u.evaluationResult,null==a?void 0:a.deviationLabel);return i(d,e({ref:ut(o),sx:{mb:1,width:"100%"}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[i(d,e({ref:et.current[o],sx:e({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(N,{section:n,idx:o,columnKey:"left",colRef:ut("left-accordion-".concat(o)),mb:0,treeData:ce,proposedSections:Kn,existingSections:Vn,deviationNumberRegistry:Jn,getSectionCompareStyle:Wt,getBadgeRef:at,connectedSections:Ke,openMoreFunctionsPopup:Bt,openSummaryPopup:Zt,deviationNodeIdToView:xe,deviationTargetParentId:ri,parentNodeId:(null===(l=null==ce?void 0:ce.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:ye?!!bt["left-".concat(o)]:!!bt[String(o)],onToggle:function(){bt[ye?"left-".concat(o):String(o)]&&Fn(),Ct(o,"left")},navigation:n.id?ii[n.id]:null,showOpenNodeRef:oi,resolvedMarkdownStyles:dn,maintainRelativeOrder:ye,renderSubSections:ci})})),ye&&a&&t(d,e({ref:tt.current[o],onClick:function(e){var t=ye?Vn.find(function(e){var n;return null===(n=u.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Vn[o]||{title:"",content:""};Bt(e,n,s,t,o,a)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&i(d,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:v})),i(d,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!pe.isLoading||null!=u.evaluationResult&&null!=u.evaluationResult?s?"No Deviation Found":"N/A"===f||"NA"===f?"N/A":0==f||null==f?"Same":"".concat(f):i(D,{color:a.badgeText})})),i(g,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))}),i("div",{ref:hn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,e({ref:_t,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,e({onClick:function(n){n.stopPropagation(),bn.open&&Bn===ft?Mn():(_n(ft),It(Tt(n.currentTarget,{title:"",content:"",evaluationResult:gt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,ft,!0,e(e({},xt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",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:i(D,{}),i(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(f,{size:11,style:{transform:bn.open&&Bn===ft?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},ye?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ie&&i(x,{sections:11}),i(d,e({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:i(v,e({title:Nn,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Nn}))}))})),t(d,e({ref:vn,onScroll:Gt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ye?{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:pn,style:{width:"100%",height:"0px",flexShrink:0}}),Gn&&Vn.map(function(n,o){var r,l=n,c=[],u=!1,a=null,s=-1;if(ye){c=Kn.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=Kn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var v=Kn.findIndex(function(e,n){var t;return Ke.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(u=-1!==v)&&(a=Wt(v))}else c=[o+1],(u=Ke.has(o))&&(a=Wt(o));var p=Wt(ye&&-1!==s?s:o);return i(d,e({ref:ot.current[o],sx:{mb:1,width:"100%"}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[i(d,e({ref:nt.current[o],sx:e({width:"100%",display:"flex"},u&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:i(N,{section:n,idx:o,columnKey:"right",colRef:ut("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==ce?void 0:ce.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:ye?!!bt["right-".concat(o)]:!!bt[String(o)],treeData:ce,proposedSections:Kn,existingSections:Vn,deviationNumberRegistry:Jn,getBadgeRef:at,getSectionCompareStyle:Wt,connectedSections:Ke,openMoreFunctionsPopup:Bt,openSummaryPopup:Zt,deviationNodeIdToView:xe,deviationTargetParentId:ri,onToggle:function(){bt[ye?"right-".concat(o):String(o)]&&Fn(),Ct(o,"right")},navigation:n.id?ii[n.id]:null,showOpenNodeRef:oi,resolvedMarkdownStyles:dn,maintainRelativeOrder:ye,renderSubSections:ci})})),ye&&!Ie&&p&&i(d,e({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:p.badgeBg,color:p.badgeText,border:"1px solid ".concat(p.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:c.length>0?c.join(", "):"-"}))]}))}),"right-row-".concat(o))}),i("div",{ref:fn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Y as default};
1
+ import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as c,useCallback as u}from"react";import{Box as d,Snackbar as a,Alert as s,Tooltip as v,Typography as p}from"@mui/material";import{ChevronDown as f,EllipsisVertical as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import x from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as y,generateColorPalette as b,DEVIATION_BADGE_SEPARATOR as S,hasValue as R,getBentArrowPath as C,smoothScrollTo as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as I,DEFAULT_FIELD_CONFIG as B,DEFAULT_COMPARISON_CONFIG as w}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as E,DEFAULT_COMPONENT_HEADER_TEXT as F}from"./CognitiveCompareConstants.js";import _ from"./CognitivePopup.js";import k from"./MoreFunctionsPopup.js";import M from"./LoaderComponent.js";import D from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as A}from"./hooks/useComparePopups.js";import{useSectionRefs as L}from"./hooks/useSectionRefs.js";import{useAccordionState as P}from"./hooks/useAccordionState.js";import{useDeviationNavigation as O}from"./hooks/useDeviationNavigation.js";import j from"./components/CompareHeader.js";import N from"./components/SectionAccordion.js";import z from"./components/SubSectionAccordion.js";import W from"./components/CognitiveSummaryPopup.js";var Y=function(Y){var K,V,X,q,J,U,G,Q,Z,$,ee,ne,te,ie,oe,re=Y.componentHeaderText,le=void 0===re?F:re,ce=Y.treeData,ue=Y.comparisonConfig,de=Y.leftColumnTitleText,ae=Y.rightColumnTitleText,se=Y.markdownStyles,ve=Y.displayConfig,pe=void 0===ve?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0}:ve,fe=Y.popupConfig,ge=Y.deviationData,he=void 0===ge?{}:ge,xe=Y.deviationNodeIdToView,me=o(pe.maintainRelativeOrder),ye=me[0],be=me[1],Se=o(!1),Re=Se[0],Ce=Se[1],Te=o(!1),Ie=Te[0],Be=Te[1],we=o(null),Ee=we[0],Fe=we[1],_e=o(!1),ke=_e[0],Me=_e[1],De=o(!1),He=De[0],Ae=De[1],Le=o(!1),Pe=Le[0],Oe=Le[1],je=o(null),Ne=je[0],ze=je[1],We=r(!1),Ye=o(new Set),Ke=Ye[0],Ve=Ye[1],Xe=o([]),qe=Xe[0],Je=Xe[1],Ue=r(null),Ge=r(!1),Qe=r(null),Ze=r({}),$e=r([]),en=r(!1),nn=r(!1),tn=r(null),on=r(function(){}),rn=l(function(){return(null==ce?void 0:ce.cognitive_decisioning)||{}},[ce]),ln=o({width:0,height:0}),cn=ln[0],un=ln[1],dn=l(function(){return e(e({},I),se)},[se]),an=r(null),sn=r(null),vn=r(null),pn=r(null),fn=r(null),gn=r(null),hn=r(null),xn=r(null),mn=r(!1),yn=A(an),bn=yn.cognitivePopup,Sn=yn.setCognitivePopup,Rn=yn.moreFunctions,Cn=yn.setMoreFunctions,Tn=yn.position,In=yn.setPosition,Bn=yn.activeBadgeId,wn=yn.summaryPopup,En=yn.setSummaryPopup,Fn=yn.closeSummaryPopup,_n=yn.setActiveBadgeId,kn=yn.popupRef,Mn=yn.closeCognitivePopup,Dn=yn.closeMoreFunctionsPopup,Hn=l(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==ue?void 0:ue.fields)&&void 0!==e?e:B,thresholds:{high:null!==(t=null===(n=null==ue?void 0:ue.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:w.thresholds.high,medium:null!==(o=null===(i=null==ue?void 0:ue.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:w.thresholds.medium,exact:null!==(l=null===(r=null==ue?void 0:ue.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:w.thresholds.exact}}},[ue]),An=o(null),Ln=An[0];An[1];var Pn=null===(X=null===(K=null==ce?void 0:ce.documents)||void 0===K?void 0:K[null===(V=null==ce?void 0:ce.input_index_map)||void 0===V?void 0:V[0]])||void 0===X?void 0:X.title,On=null===(U=null===(q=null==ce?void 0:ce.documents)||void 0===q?void 0:q[null===(J=null==ce?void 0:ce.input_index_map)||void 0===J?void 0:J[1]])||void 0===U?void 0:U.title,jn=m(de||Pn||"Uploaded Contract"),Nn=m(ae||On||"Reference Template"),zn=H(ce,ye,he,Hn),Wn=zn.activeProposed,Yn=zn.existingRule,Kn=zn.proposedSections,Vn=zn.existingSections,Xn=zn.visibleFields,qn=zn.parentDeviationRecord,Jn=zn.deviationNumberRegistry,Un=zn.parseError;c(function(){Un&&Fe("Failed to load comparison: ".concat(Un))},[Un]);var Gn=Kn.length>0||Vn.length>0,Qn=L(Xn.map(function(e){return e.key}),Math.max(Kn.length,Vn.length)),Zn=Qn.leftRefs,$n=Qn.rightRefs,et=Qn.sectionLeftRefs,nt=Qn.sectionRightRefs,tt=Qn.lhsBadgeRefs,it=Qn.rhsBadgeRefs,ot=Qn.sectionRightRowRefs,rt=Qn.subSectionLeftRefs,lt=Qn.subSectionRightRefs,ct=Qn.sectionRowRefs,ut=Qn.getSectionRowRef,dt=Qn.getSubSectionRef,at=Qn.getBadgeRef,st=Yn.analysis,vt=m(null===(Q=null===(G=null==st?void 0:st.rule_difference_comparison)||void 0===G?void 0:G.summary)||void 0===Q?void 0:Q.overall_summary),pt=!!vt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),ft=null!==(Z=null==ce?void 0:ce.base_root_id)&&void 0!==Z?Z:"-1";null==ce||ce[ft];var gt=(null===($=null==he?void 0:he[ft])||void 0===$?void 0:$.evaluation_result)||(null===(ne=null===(ee=null==ce?void 0:ce.nodes)||void 0===ee?void 0:ee[ft])||void 0===ne?void 0:ne.evaluation_result)||null,ht=y(gt),xt=b(null!==(oe=null===(ie=null===(te=null==gt?void 0:gt.evaluation_outputs)||void 0===te?void 0:te.metadata)||void 0===ie?void 0:ie.label_color)&&void 0!==oe?oe:""),mt=u(function(){var e,n,t,i;Me(!1),nn.current=!1;var o=tn.current,r=kt.current;if(null!==o)if("string"==typeof o&&o.includes(S)){var l=o.split(S);(c=null===(e=rt.current[l[2]])||void 0===e?void 0:e.current)&&(c.style.paddingTop="0px")}else{var c;(c=null===(n=et.current[o])||void 0===n?void 0:n.current)&&(c.style.paddingTop="0px")}if(null!==r)if("string"==typeof r&&r.includes(S)){l=r.split(S);(u=null===(t=lt.current[l[3]])||void 0===t?void 0:t.current)&&(u.style.paddingTop="0px")}else{var u;(u=null===(i=nt.current[r])||void 0===i?void 0:i.current)&&(u.style.paddingTop="0px")}ze(null),tn.current=null,kt.current=null,Ae(!1),Be(!1),pn.current&&(pn.current.style.height="0px"),fn.current&&(fn.current.style.height="0px"),gn.current&&(gn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px")},[]),yt=P({maintainRelativeOrder:!!ye,proposedSections:Kn,existingSections:Vn,activeSideBySideSection:Ne,connectedSections:Ke,resetSideBySide:mt,setConnectedSections:Ve,setConnectedLines:Je,cachedConnectedPositions:$e,svgContainerRef:Ue,isAnimatingRef:Ge,animationTimerRef:Qe,calculateLinesRef:on,sectionLeftRefs:et,sectionRightRefs:nt,subSectionLeftRefs:rt,subSectionRightRefs:lt}),bt=yt.expandedSections,St=yt.expandedSubSections,Rt=yt.setExpandedSubSections,Ct=yt.toggleSection,Tt=u(function(e,n,t,i,o,r,l){var c,u,d,a=m(null==n?void 0:n.id)||m(null==t?void 0:t.id)||"",s=(a?rn[a]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:a,decisioning:[],gap:[],relevance_score:0},v=null!==(u=null===(c=ct.current[i])||void 0===c?void 0:c.current)&&void 0!==u?u:null;return{isLoading:null!==(d=null==pe?void 0:pe.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==n?void 0:n.displayTitle)?null==n?void 0:n.title:"no title",refSectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",cognitiveData:s,anchorEl:e,sectionAnchorEl:v,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==ce?void 0:ce.documents,input_index_map:null==ce?void 0:ce.input_index_map},deviationData:(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,isOrphan:!!o}},[rn,ce]),It=u(function(e){Dn(),In(null),Sn(e)},[Dn]),Bt=function(e,n,t,i,o,r){e.stopPropagation(),Rn.open&&Rn.sectionIdx===o?Dn():(Mn(),Cn(Tt(e.currentTarget,n,i,o,t,r)))},wt=u(function(){null!==Rn.sectionIdx&&Rn.anchorEl?It(e(e({},Rn),{open:!0})):Dn()},[Rn,Dn,It]),Et=u(function(){var e=Rn.sectionIdx,n=Rn.isOrphan;Dn(),Fn(),null!==e&&(n?Fe("No counterpart exists to connect to."):(nn.current&&mt(),Je([]),$e.current=[],Ve(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){on.current&&on.current()},50)))},[Rn.sectionIdx,Rn.isOrphan,Dn,Fn,mt]),Ft=r(null),_t=r(null),kt=r(null),Mt=r(null),Dt=r(null),Ht=r(null),At=o([]),Lt=At[0],Pt=At[1];r(null);var Ot=o(null),jt=Ot[0],Nt=Ot[1];c(function(){if(Ln){var e=Hn.fields.find(function(e){return e.analysisKey===Ln||e.key===Ln});if(e){var n=Zn.current[e.key]||$n.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Ln,Hn.fields]);var zt=u(function(e){var n,t,i,o,r,l,c,u,d,a=null===(n=null==st?void 0:st.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!a||!a[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=a[e],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var p=s.mappings[0]||{};return{score:s.score,relation:p.relation||"",highlightsA:(null===(l=p.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=p.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(u=s.highlights)||void 0===u?void 0:u.ruleA_spans)||[],highlightsB:(null===(d=s.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!v}},[st]),Wt=u(function(n,t){var i,o,r,l,c,u,d;void 0===t&&(t="left");var a=null,s=null;if("left"===t)if(a=Kn[n],ye&&a){var v=Vn.filter(function(e){var n;return null===(n=a.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});s=v.find(function(e){return e.evaluationResult})||v[0]}else s=Vn[n];else if(s=Vn[n],ye&&s){var p=Kn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex)});a=p.find(function(e){return e.evaluationResult})||p[0]}else a=Kn[n];var f=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,g=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,h=!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData));if(!f&&!g&&!h)return e(e({},b(E)),{label:"Not Defined"});var x=null!==(o=null!==(i=null==a?void 0:a.evaluationResult)&&void 0!==i?i:null==s?void 0:s.evaluationResult)&&void 0!==o?o:null,m=null===(r=null==x?void 0:x.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(u=null===(c=null===(l=null==x?void 0:x.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===c?void 0:c.label_color)&&void 0!==u?u:E;return e(e({},b(y)),null!=x?{label:null!==(d=m)&&void 0!==d?d:""}:{label:null})},[Kn,Vn,rn,Hn,ye]),Yt=u(function(n){for(var t,i,o,r,l,c,u,d,a,s=n.split("-").map(Number),v=Kn[s[0]],p=Vn[s[0]],f=1;f<s.length;f++)(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]),(null==p?void 0:p.subsections)&&(p=p.subsections[s[f]]);if(!v&&!p)return null;var g=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,h=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,x=m(null==v?void 0:v.id)||m(null==p?void 0:p.id)||"",y=!(!(null==v?void 0:v.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!g&&!h&&!y)return e(e({},b(E)),{label:"Not Defined"});null!==(i=null!==(t=null==v?void 0:v.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||x&&(null===(o=rn[x])||void 0===o||o.relevance_score);var S=null!==(l=null!==(r=null==v?void 0:v.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,R=null===(c=null==S?void 0:S.evaluation_outputs)||void 0===c?void 0:c.output_value,C=null!==(a=null===(d=null===(u=null==S?void 0:S.evaluation_outputs)||void 0===u?void 0:u.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:E;return e(e({},b(C)),null!=S?{label:null!=R?R:""}:{label:null})},[Kn,Vn,rn,Hn]),Kt=u(function(){var e,n,t,i,o,r,l,c,u,d,a,s,v,p,f,g,h,x;if(!mn.current&&!Ge.current){mn.current=!0;try{if(!Ft.current)return;var m=function(e){var n=e.split("-"),t=n[0];if(!bt[t]&&!1===ye)return!1;if(ye&&!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]),!St[i])return!1;return!0},y=Ft.current.getBoundingClientRect();un({width:y.width,height:y.height});var b=[];if(Xn.forEach(function(e){var n,t,i=e.key,o=null===(n=Zn.current[i])||void 0===n?void 0:n.current,r=null===(t=$n.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")}),!Ge.current){for(var T=0;T<Math.max(Kn.length,Vn.length);T++){var I=null===(e=et.current[T])||void 0===e?void 0:e.current,B=null===(n=nt.current[T])||void 0===n?void 0:n.current;I&&(I.style.height="auto",I.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}ye||Object.keys(rt.current).forEach(function(e){var n,t;if(m(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 w={};Xn.forEach(function(e){var n,t,i=e.key,o=null===(n=Zn.current[i])||void 0===n?void 0:n.current,r=null===(t=$n.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect();w[i]=Math.max(l.height,c.height)}});var E={left:{},right:{}},F={};if(!Ge.current)if(ye){if(ke&&null!==Ne)if("number"==typeof Ne){var _=Ne,k=Kn[_],M=null===(o=et.current[_])||void 0===o?void 0:o.current;M&&k&&(k.refIndexes||[]).forEach(function(e){var n,t=Vn.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(_)]||bt["right-".concat(t)])){var o=Math.max(M.getBoundingClientRect().height,i.getBoundingClientRect().height);E.left[_]=Math.max(E.left[_]||0,o),E.right[t]=Math.max(E.right[t]||0,o)}})}else{var D=Ne.split(S)[2];if(D){I=null===(r=rt.current[D])||void 0===r?void 0:r.current,B=null===(l=lt.current[D])||void 0===l?void 0:l.current;if(I&&B){H=Math.max(I.getBoundingClientRect().height,B.getBoundingClientRect().height);F[D]=Math.max(F[D]||0,H)}}}}else{Object.keys(rt.current).forEach(function(e){var n,t;if(m(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(),c=Math.max(r.height,l.height);F[e]=c,i.style.minHeight="".concat(c,"px"),o.style.minHeight="".concat(c,"px")}}});for(T=0;T<Math.min(Kn.length,Vn.length);T++){var I=null===(t=et.current[T])||void 0===t?void 0:t.current,B=null===(i=nt.current[T])||void 0===i?void 0:i.current;if(I&&B){var H=Math.max(I.getBoundingClientRect().height,B.getBoundingClientRect().height);E.left[T]=H,E.right[T]=H}}}if(Xn.forEach(function(e){var n,t,i=e.key,o=null===(n=Zn.current[i])||void 0===n?void 0:n.current,r=null===(t=$n.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=w[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Ge.current||(Object.entries(E.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(E.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"))}),ye||Object.keys(F).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&&F[e]){var r=F[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),ye)Kn.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,c,u=Vn.findIndex(function(n){return n.selfIndex===e});if(-1!==u){var d=null===(t=tt.current[n])||void 0===t?void 0:t.current,a=null===(i=it.current[u])||void 0===i?void 0:i.current;if(d&&a){var s,v,p,f=d.getBoundingClientRect(),g=a.getBoundingClientRect(),h=f.right-y.left,x=g.left-y.left,m=f.top+f.height/2-y.top,S=g.top+g.height/2-y.top;if(ke&&Ne===n){var R=null!==(r=null===(o=xn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,C=R+(null!==(c=null===(l=xn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0),T=f.top+f.height/2;s=T,v=R,p=C,S=m=Math.max(v,Math.min(p,s))-y.top}var I=Wt(n);I&&b.push({id:"line-".concat(n,"-").concat(u),x1:h,y1:m,x2:x,y2:S,style:I,sectionIdx:n,targetRightIdx:u})}}})});else{for(T=0;T<Math.min(Kn.length,Vn.length);T++){var A=null===(c=et.current[T])||void 0===c?void 0:c.current,L=null===(u=nt.current[T])||void 0===u?void 0:u.current;if(A&&L){var P=A.getBoundingClientRect(),O=L.getBoundingClientRect(),j=Math.max(P.top,O.top)+18-y.top,N=(null===(d=Vn[T])||void 0===d?void 0:d.id)||"sec-".concat(T);(J=Wt(T))&&b.push({id:N,x1:P.right-y.left,y1:j,x2:O.left-y.left,y2:j,style:J,sectionIdx:T,hasCognitive:!!((null===(a=Kn[T])||void 0===a?void 0:a.cognitiveData)||(null===(s=Vn[T])||void 0===s?void 0:s.cognitiveData)||N&&rn[N]),isSubSection:!1})}}Object.keys(rt.current).forEach(function(e){var n,t,i,o,r,l;if(m(e)){var c=null===(n=rt.current[e])||void 0===n?void 0:n.current,u=null===(t=lt.current[e])||void 0===t?void 0:t.current;if(c&&u){for(var d=e.split("-").map(Number),a=Kn[d[0]],s=Vn[d[0]],v=1;v<d.length;v++)(null==a?void 0:a.subsections)&&(a=a.subsections[d[v]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[v]]);var p=!!a&&((null===(i=a.displayTitle)||void 0===i||i)&&R(a.title)),f=!!a&&((null===(o=a.displayContent)||void 0===o||o)&&R(a.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&R(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&R(s.content));if(p&&f||g&&h){var x=c.getBoundingClientRect(),S=u.getBoundingClientRect(),C=Math.max(x.top,S.top)+16-y.top,T=Yt(e);T&&"Not Defined"!==T.label&&b.push({id:"subsec-".concat(e),x1:x.right-y.left,y1:C,x2:S.left-y.left,y2:C,style:T,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(ke&&"string"==typeof Ne&&Ne.includes(S)){var z=Ne.split(S),W=z[0],Y=z[1],K=z[2],V=(z[3],"".concat(W).concat(S).concat(Y)),X=null===(v=tt.current[V])||void 0===v?void 0:v.current,q=null===(p=it.current[V])||void 0===p?void 0:p.current;if(X&&q){var J,U=X.getBoundingClientRect(),G=q.getBoundingClientRect(),Q=U.right-y.left,Z=G.left-y.left,$=U.top+U.height/2-y.top,ee=(G.top,G.height,y.top);if(ye){var ne=null!==(g=null===(f=xn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,te=ne+(null!==(x=null===(h=xn.current)||void 0===h?void 0:h.clientHeight)&&void 0!==x?x:1/0);me=U.top+U.height/2,be=ne,Se=te,$=Math.max(be,Math.min(Se,me))-y.top}ee=$,(J=Yt(K))&&b.push({id:"line-subsec-".concat(V),x1:Q,y1:$,x2:Z,y2:ee,style:J,sectionIdx:Number(K.split("-")[0]),isSubSection:!0,subSectionKeyPath:Ne})}}if(Pt(b),Dt.current&&Ht.current){var ie=Dt.current.getBoundingClientRect(),oe=Ht.current.getBoundingClientRect(),re=(ie.top+ie.height/2-y.top+oe.top+oe.height/2-y.top)/2;Nt({x1:ie.right-y.left,x2:oe.left-y.left,y:re})}else Nt(null);if(Ke.size>0){var le=[],ce=xn.current,ue=vn.current;if(ce&&ue){var de=[],ae=ce.getBoundingClientRect().top,se=ue.getBoundingClientRect().top,ve=ae+ce.clientHeight,pe=se+ue.clientHeight,fe=ce.scrollTop,ge=ue.scrollTop,he=y.top,xe=function(e,n,t){return Math.max(n,Math.min(t,e))};Ke.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(S)){var l=e.split(S),c=l[0],u=l[1],d=l[2],a=(l[3],"".concat(c).concat(S).concat(u)),s=null===(n=tt.current[a])||void 0===n?void 0:n.current,v=null===(t=it.current[a])||void 0===t?void 0:t.current;if(!s||!v)return;var p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=Yt(d),h=(A=p.right-y.left)+.5*((L=f.left-y.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,b=x-ae+fe,R=m-se+ge,T="conn-subsec-".concat(a);de.push({lhsScrollY:b,rhsScrollY:R,x1:A,x2:L,containerTop:he,leftIdx:e,rhsArrayIdx:e,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:T});var I=xe(x,ae,ve),B=xe(m,se,pe),w=I-he,E=B-he,F=m>=se-4&&m<=pe+4,_="";_=(P=x>=ae-4&&x<=ve+4)&&F?C(A,w,L,E):P&&!F?"M ".concat(A,",").concat(w," L ").concat(h,",").concat(w," L ").concat(h,",").concat(E):!P&&F?"M ".concat(h,",").concat(w," L ").concat(h,",").concat(E," L ").concat(L,",").concat(E):"M ".concat(h,",").concat(w," L ").concat(h,",").concat(E),le.push({id:T,pathD:_,style:g,leftIdx:e,rhsArrayIdx:e})}else if(ye){var k=e,M=Kn[k];if(!(null===(r=null==M?void 0:M.refIndexes)||void 0===r?void 0:r.length))return;M.refIndexes.forEach(function(e){var n,t,i=Vn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=tt.current[k])||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(),u=Wt(k),d=l.right-y.left,a=c.left-y.left-0,s=d+.5*(a-d),v=l.top+l.height/2,p=c.top+c.height/2,f=v-ae+fe,g=p-se+ge,h="conn-".concat(k,"-").concat(i);de.push({lhsScrollY:f,rhsScrollY:g,x1:d,x2:a,containerTop:he,leftIdx:k,rhsArrayIdx:i,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:h});var x=xe(v,ae,ve),m=xe(p,se,pe),b=x-he,S=m-he,R=v>=ae-4&&v<=ve+4,T=p>=se-4&&p<=pe+4,I="";I=R&&T?C(d,b,a,S):R&&!T?"M ".concat(d,",").concat(b," L ").concat(s,",").concat(b," L ").concat(s,",").concat(S):!R&&T?"M ".concat(s,",").concat(b," L ").concat(s,",").concat(S," L ").concat(a,",").concat(S):"M ".concat(s,",").concat(b," L ").concat(s,",").concat(S),le.push({id:h,pathD:I,style:u,leftIdx:k,rhsArrayIdx:i})}}})}else{var D=e,H=D;s=null===(i=tt.current[D])||void 0===i?void 0:i.current,v=null===(o=it.current[H])||void 0===o?void 0:o.current;if(!s||!v)return;var A,L;p=s.getBoundingClientRect(),f=v.getBoundingClientRect(),g=Wt(D),h=(A=p.right-y.left)+.5*((L=f.left-y.left-0)-A),x=p.top+p.height/2,m=f.top+f.height/2,b=x-ae+fe,R=m-se+ge,T="conn-".concat(D,"-").concat(H);de.push({lhsScrollY:b,rhsScrollY:R,x1:A,x2:L,containerTop:he,leftIdx:D,rhsArrayIdx:H,styleColor:(null==g?void 0:g.badgeBorder)||"#6366F1",styleId:T});var P;I=xe(x,ae,ve),B=xe(m,se,pe),w=I-he,E=B-he,F=m>=se-4&&m<=pe+4,_="";_=(P=x>=ae-4&&x<=ve+4)&&F?C(A,w,L,E):P&&!F?"M ".concat(A,",").concat(w," L ").concat(h,",").concat(w," L ").concat(h,",").concat(E):!P&&F?"M ".concat(h,",").concat(w," L ").concat(h,",").concat(E," L ").concat(L,",").concat(E):"M ".concat(h,",").concat(w," L ").concat(h,",").concat(E),le.push({id:T,pathD:_,style:g,leftIdx:D,rhsArrayIdx:H})}}),$e.current=de}Je(le)}else Je([]),$e.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{mn.current=!1}var me,be,Se}},[Xn,Kn,Vn,rn,Hn,zt,Wt,ye,ke,Ne,Ke,bt,St]),Vt=u(function(){var e,n,t,i,o,r,l,c,u,d,a,s,v,p,f=$e.current;if(f.length&&!Ge.current){var g=null!==(n=null===(e=xn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,h=null!==(i=null===(t=vn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=xn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=vn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,y=null!==(d=null===(u=xn.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,b=null!==(s=null===(a=vn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,R=b+m,T=null!==(p=null===(v=Ft.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,I=function(e,n,t){return Math.max(n,Math.min(t,e))};f.forEach(function(e){var n=e.lhsScrollY-g+y,t=e.rhsScrollY-h+b,i=Ze.current[e.styleId+"-stroke"],o=Ze.current[e.styleId+"-bg"];if(i||o){var r,l=I(n,y,S),c=I(t,b,R),u=l-T,d=c-T,a=n>=y-4&&n<=S+4,s=t>=b-4&&t<=R+4,v=e.x1+.5*(e.x2-e.x1);r=a&&s?C(e.x1,u,e.x2,d):a&&!s?"M ".concat(e.x1,",").concat(u," L ").concat(v,",").concat(u," L ").concat(v,",").concat(d):!a&&s?"M ".concat(v,",").concat(u," L ").concat(v,",").concat(d," L ").concat(e.x2,",").concat(d):"M ".concat(v,",").concat(u," L ").concat(v,",").concat(d),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);c(function(){on.current=Kt},[Kt]);var Xt=r(null),qt=r(null),Jt=u(function(){$e.current.length>0&&!Ge.current||(null!==Xt.current&&clearTimeout(Xt.current),Xt.current=setTimeout(function(){on.current(),Xt.current=null},50))},[]),Ut=u(function(){Oe(!0),Ae(!1),null!==qt.current&&clearTimeout(qt.current),null!==Xt.current&&(clearTimeout(Xt.current),Xt.current=null),qt.current=setTimeout(function(){var e,n,t,i,o,r,l,c;if($e.current=[],nn.current&&null!==tn.current&&null!==kt.current){var u=tn.current,d=kt.current,a=null,s=null,v=null,p=null;if("string"==typeof u&&u.includes(S)){var f=u.split(S),g="".concat(f[0]).concat(S).concat(f[1]);a=(null===(e=tt.current[g])||void 0===e?void 0:e.current)||null,s=(null===(n=it.current[g])||void 0===n?void 0:n.current)||null,v=(null===(t=rt.current[f[2]])||void 0===t?void 0:t.current)||null,p=(null===(i=lt.current[f[3]])||void 0===i?void 0:i.current)||null}else a=(null===(o=ct.current[u])||void 0===o?void 0:o.current)||null,v=(null===(r=et.current[u])||void 0===r?void 0:r.current)||null,s=(null===(l=ot.current[d])||void 0===l?void 0:l.current)||null,p=(null===(c=nt.current[d])||void 0===c?void 0:c.current)||null;if(a&&s&&v&&p){if(v.style.paddingTop="0px",p.style.paddingTop="0px",!ye){var h=a.getBoundingClientRect(),x=s.getBoundingClientRect(),m=h.top-x.top;m>0?p.style.paddingTop="".concat(m,"px"):m<0&&(v.style.paddingTop="".concat(Math.abs(m),"px"))}var y=xn.current,b=vn.current;if(y&&b){var R=a.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,C=s.getBoundingClientRect().top-b.getBoundingClientRect().top+b.scrollTop-(R-y.scrollTop);Math.abs(b.scrollTop-C)>1&&(b.scrollTop=C)}}}on.current(),nn.current&&Ae(!0),Oe(!1),qt.current=null},150)},[ye,Kn,Vn]),Gt=u(function(e){var n,t,i,o,r,l,c,u,d,a;if(!We.current){if(ye||Jt(),nn.current){var s=tn.current,v=kt.current,p=xn.current,f=vn.current;if(null!==s&&null!==v&&p&&f){var g="string"==typeof s&&s.includes(S)?null===(n=tt.current["".concat(s.split(S)[0]).concat(S).concat(s.split(S)[1])])||void 0===n?void 0:n.current:null===(t=ct.current[s])||void 0===t?void 0:t.current,h="string"==typeof v&&v.includes(S)?null===(i=it.current["".concat(v.split(S)[0]).concat(S).concat(v.split(S)[1])])||void 0===i?void 0:i.current:null===(o=ot.current[v])||void 0===o?void 0:o.current;if(g&&h){var x=g.getBoundingClientRect().top-p.getBoundingClientRect().top+p.scrollTop,m=h.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop;if(e.currentTarget===p){var y=m-(x-p.scrollTop),b=f.scrollHeight-f.clientHeight,R=Math.max(0,Math.min(y,b));Math.abs(f.scrollTop-R)>1&&(f.scrollTop=R)}else if(e.currentTarget===f){var C=x-(m-f.scrollTop),T=p.scrollHeight-p.clientHeight,I=Math.max(0,Math.min(C,T));Math.abs(p.scrollTop-I)>1&&(p.scrollTop=I)}if(Mt.current){var B=void 0,w=void 0;if("string"==typeof s&&s.includes(S)){var E=s.split(S),F="".concat(E[0]).concat(S).concat(E[1]);B=null===(r=tt.current[F])||void 0===r?void 0:r.current,w=null===(l=it.current[F])||void 0===l?void 0:l.current}else B=null===(c=tt.current[s])||void 0===c?void 0:c.current,w=null===(u=it.current[v])||void 0===u?void 0:u.current;var _=null!==(a=null===(d=Ft.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==a?a:0,k=p.getBoundingClientRect().top,M=k+p.clientHeight;f.getBoundingClientRect().top;f.clientHeight;if(B&&w){var D=B.getBoundingClientRect(),H=w.getBoundingClientRect(),A=D.top+D.height/2;H.top,H.height;var L=((O=A,j=k,N=M,Math.max(j,Math.min(N,O)))-_).toString();Mt.current.setAttribute("y1",L),Mt.current.setAttribute("y2",L);var P=A>=k-4&&A<=M+4;Mt.current.setAttribute("visibility",P?"visible":"hidden")}}}}}var O,j,N;$e.current.length>0&&!en.current&&(en.current=!0,requestAnimationFrame(function(){Vt(),en.current=!1}))}},[Vt,ye,Jt]);c(function(){var e=setTimeout(Jt,250);window.addEventListener("resize",Ut);var n=null,t=null;return an.current&&(n=new ResizeObserver(Jt)).observe(an.current),Ft.current&&(t=new ResizeObserver(Jt)).observe(Ft.current),function(){clearTimeout(e),null!==Xt.current&&clearTimeout(Xt.current),null!==qt.current&&clearTimeout(qt.current),window.removeEventListener("resize",Ut),null==n||n.disconnect(),null==t||t.disconnect()}},[Wn,Yn,st,Xn,bt,St,Kn,Vn,Hn,Jt,Ut,ke,Ne,He,Ke]),c(function(){nn.current=ke},[ke]),c(function(){tn.current=Ne},[Ne]);var Qt=u(function(e,n,t){var i,o,r,l,c,u,d=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,a=null==t?void 0:t.onReady,s=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";if(Dn(),null!=e)if(n)Fe("No counterpart exists for this section.");else if(ke&&Ne===e)d?mt():null==a||a();else{if(!ye){var v=tn.current,p=kt.current;if(null!==v)if("string"==typeof v&&v.includes(S)){var f=v.split(S);(g=null===(r=rt.current[f[2]])||void 0===r?void 0:r.current)&&(g.style.paddingTop="0px")}else{var g;(g=null===(l=et.current[v])||void 0===l?void 0:l.current)&&(g.style.paddingTop="0px")}if(null!==p)if("string"==typeof p&&p.includes(S)){f=p.split(S);(h=null===(c=lt.current[f[3]])||void 0===c?void 0:c.current)&&(h.style.paddingTop="0px")}else{var h;(h=null===(u=nt.current[p])||void 0===u?void 0:u.current)&&(h.style.paddingTop="0px")}}Ve(new Set),Je([]),$e.current=[],Be(!0),We.current=!0,ze(e),tn.current=e,Me(!0),nn.current=!0,Ae(!1),pn.current&&(pn.current.style.height="0px"),fn.current&&(fn.current.style.height="0px"),gn.current&&(gn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,l,c,u,d,v,p=null,f=null,g=null,h=null,x=null;if("string"==typeof e&&e.includes(S)){var m=e.split(S),y="".concat(m[0]).concat(S).concat(m[1]);p=(null===(n=tt.current[y])||void 0===n?void 0:n.current)||null,x=(f=(null===(t=it.current[y])||void 0===t?void 0:t.current)||null)?e:null,g=(null===(i=rt.current[m[2]])||void 0===i?void 0:i.current)||null,h=(null===(o=lt.current[m[3]])||void 0===o?void 0:o.current)||null}else if(p=(null===(r=ct.current[e])||void 0===r?void 0:r.current)||null,g=(null===(l=et.current[e])||void 0===l?void 0:l.current)||null,ye){var b=Kn[e],R=(null==b?void 0:b.refIndexes)||[];if(R.length>0){var C=R[0],I=Vn.findIndex(function(e){return e.selfIndex===C});-1!==I&&(f=(null===(d=ot.current[I])||void 0===d?void 0:d.current)||null,h=(null===(v=nt.current[I])||void 0===v?void 0:v.current)||null,x=I)}}else f=(null===(c=ot.current[e])||void 0===c?void 0:c.current)||null,h=(null===(u=nt.current[e])||void 0===u?void 0:u.current)||null,x=f?e:null;kt.current=x;var B=xn.current,w=vn.current;if(!p||!B)return We.current=!1,Be(!1),void(null==a||a());if(!f||!w)return Ae(!0),on.current(),We.current=!1,Be(!1),void(null==a||a());if(!ye){var E=p.getBoundingClientRect(),F=f.getBoundingClientRect(),_=E.top-F.top;g&&h&&(g.style.paddingTop="0px",h.style.paddingTop="0px",_>0?h.style.paddingTop="".concat(_,"px"):_<0&&(g.style.paddingTop="".concat(Math.abs(_),"px")));var k=0;k="right"===s?f?f.getBoundingClientRect().top:(null==h?void 0:h.getBoundingClientRect().top)||0:p?p.getBoundingClientRect().top:(null==g?void 0:g.getBoundingClientRect().top)||0;var M=an.current,D=M?M.scrollTop+k-150:0;return M?void T(M,D,200,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()}):(Ae(!0),on.current(),We.current=!1,Be(!1),void(null==a||a()))}var H=p.getBoundingClientRect().top-B.getBoundingClientRect().top+B.scrollTop,A=f.getBoundingClientRect().top-w.getBoundingClientRect().top+w.scrollTop,L=200;if("left"===s){var P=A-(H-B.scrollTop);P<0&&pn.current&&(pn.current.style.height="".concat(Math.abs(P),"px")),requestAnimationFrame(function(){var e,n=w.scrollHeight-w.clientHeight;if(P<0)e=0;else{if(P>n){var t=P-n;return fn.current&&(fn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(w,P,L,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()})})}e=P}T(w,e,L,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()})})}else{var O=H-(A-w.scrollTop);O<0&&gn.current&&(gn.current.style.height="".concat(Math.abs(O),"px")),requestAnimationFrame(function(){var e,n=B.scrollHeight-B.clientHeight;if(O<0)e=0;else{if(O>n){var t=O-n;return hn.current&&(hn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(B,O,L,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()})})}e=O}T(B,e,L,function(){Ae(!0),on.current(),We.current=!1,Be(!1),null==a||a()})})}})}},[Ne,Dn,Vn,ke,ye,Kn,mt]),Zt=u(function(e,n,t,i){var o,r="string"==typeof i?m(i).trim():m(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;Mn();var c="left";(null===(o=vn.current)||void 0===o?void 0:o.contains(l))&&(c="right"),t?r&&En({open:!0,anchorEl:l,summary:i}):Qt(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){En({open:!0,anchorEl:l,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[Qt,Mn,En]),$t=u(function(){var e,n=Rn.sectionIdx,t=Rn.isOrphan;if(Fn(),null!=n){var i="left";Rn.anchorEl&&(null===(e=vn.current)||void 0===e?void 0:e.contains(Rn.anchorEl))&&(i="right"),Qt(n,t,{sourceSide:i})}},[Qt,Rn.isOrphan,Rn.sectionIdx,Rn.anchorEl,Fn]),ei=u(function(){Fn(),mt()},[Fn,mt]),ni=null!==Rn.sectionIdx&&Ke.has(Rn.sectionIdx),ti=O({proposedSections:Kn,existingSections:Vn,parentDeviationRecord:qn,expandedSections:bt,maintainRelativeOrder:!!ye,scrollContainerRef:an,leftContainerRef:xn,lhsBadgeRefs:tt,rhsBadgeRefs:it}),ii=ti.showDeviationNavigation,oi=ti.showOpenNodeRef,ri=l(function(){if(!xe)return null;for(var e in qn){if((qn[e]||[]).some(function(e){return e.id===xe}))return e}return null},[xe,qn]),li=r(null);c(function(){if(xe&&li.current!==xe){var e=!1,t=0,i=null,o=150,r=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},l=function(){var c,u,d,a;if(!e){var s=null,v=null;for(var p in qn){var f=qn[p].find(function(e){return e.id===xe});if(f){s=p,v=f;break}}if(v&&s){var g=Kn.findIndex(function(e){return e.id===s});if(!(ye?!!bt["left-".concat(g)]:!!bt[String(g)])&&g>=0)return Ct(g,"left"),t+=1,void(i=setTimeout(l,450));var h=r(Kn,v.id),x=r(Vn,v.id);if(h&&!x){var m=h.split("-"),y=Number(m[0]);if(ye){var b=null===(u=null===(c=Kn[y])||void 0===c?void 0:c.refIndexes)||void 0===u?void 0:u[0],R=Vn.findIndex(function(e){return e.selfIndex===b});-1!==R&&(y=R)}x=n([y],m.slice(1),!0).join("-")}if(h&&x){var C="".concat(v.id).concat(S,"0").concat(S).concat(h).concat(S).concat(x),I="".concat(v.id).concat(S,"0"),B=null===(d=tt.current[I])||void 0===d?void 0:d.current,w=null===(a=it.current[I])||void 0===a?void 0:a.current,E=ye?xn.current:an.current;if(B&&E){var F=B.getBoundingClientRect();if(0===F.height)return void((t+=1)<20&&(i=setTimeout(l,o)));var _=E.getBoundingClientRect(),k=F.top-_.top+E.scrollTop-_.height/2+F.height/2,M=function(){var e=window.getComputedStyle(B).color;B.style.transition="box-shadow 300ms ease-in-out",B.style.boxShadow="0 0 10px ".concat(e),w&&(w.style.transition="box-shadow 300ms ease-in-out",w.style.boxShadow="0 0 10px ".concat(e)),setTimeout(function(){B&&(B.style.boxShadow=""),w&&(w.style.boxShadow="")},2e3)},D=function(){var e,n,t,i=(null==v?void 0:v.evaluationResult)||(null===(e=null==he?void 0:he[null==v?void 0:v.id])||void 0===e?void 0:e.evaluation_result)||(null===(t=null===(n=null==ce?void 0:ce.nodes)||void 0===n?void 0:n[null==v?void 0:v.id])||void 0===t?void 0:t.evaluation_result)||null,o=(null==i?void 0:i.deviations)||{},r=Object.keys(o).sort()[0]||null,l=r?o[r]:null,c=(null==l?void 0:l.deviation_summary)||"";En({open:!0,anchorEl:B,summary:{deviation_summary:c,deviation_title:null==i?void 0:i.deviation_title,evaluation_outputs:null==i?void 0:i.evaluation_outputs}})};li.current=xe,ye?(E.scrollTo({top:k,behavior:"smooth"}),Qt(C,!1,{toggleIfSame:!1}),D(),setTimeout(function(){on.current()},0),M()):T(E,k,300,function(){e||(Qt(C,!1,{toggleIfSame:!1}),D(),setTimeout(function(){on.current()},0),M())})}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}};return i=setTimeout(l,o),function(){e=!0,i&&clearTimeout(i)}}},[xe,qn,Kn,Vn,ye,bt,Ct,he,ce,En,Qt]);var ci=function(e){var n=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,c=void 0===l?"left":l,u=e.parentNodeId;return i(z,{section:n,keyPath:t,depth:r,columnKey:c,parentNodeId:void 0===u?"":u,expandedSubSections:St,setExpandedSubSections:Rt,maintainRelativeOrder:ye||!1,proposedSections:Kn,existingSections:Vn,treeData:ce,deviationNumberRegistry:Jn,connectedSections:Ke,activeSideBySideSection:Ne,resolvedMarkdownStyles:dn,getSubSectionRef:dt,getSubSectionCompareStyle:Yt,getBadgeRef:at,openMoreFunctionsPopup:Bt,openSummaryPopup:Zt,resetSideBySide:mt,setConnectedSections:Ve,setConnectedLines:Je,cachedConnectedPositions:$e})};return t(d,e({ref:sn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ye?{}:{overflow:"visible"}),{position:"relative"})},{children:[Re&&i(d,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(M,{})})),wn.open&&i(W,{open:wn.open,anchorEl:wn.anchorEl,containerEl:_t.current,clipTopEl:Dt.current,onClose:ei,summary:wn.summary}),i(k,{open:Rn.open,anchorEl:Rn.anchorEl,sectionTitle:Rn.sectionTitle,referenceSectionTitle:Rn.refSectionTitle,onClose:Dn,onOpenCognitiveCompare:wt,onOpenSideBySide:$t,onConnect:Et,isConnected:ni,isOrphan:Rn.isOrphan}),bn.open&&i(_,{open:bn.open,popupRef:kn,position:Tn,popupConfig:fe,onClose:function(){In(null),Sn(function(n){return e(e({},n),{open:!1})}),_n(null)},markdownStyles:se,sectionTitle:bn.sectionTitle,referenceSectionTitle:bn.refSectionTitle,cognitiveData:bn.cognitiveData,anchorEl:bn.anchorEl,sectionAnchorEl:bn.sectionAnchorEl,scrollContainerEl:an.current,badgeStyle:bn.badgeStyle,docData:bn.docData,deviationData:bn.deviationData,isLoading:bn.isLoading}),i(a,e({open:!!Ee,autoHideDuration:8e3,onClose:function(){return Fe(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,e({onClose:function(){return Fe(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Ee}))})),i(j,{componentHeaderText:le,displayConfig:pe,maintainRelativeOrder:ye,onToggleView:function(e){Ce(!0),setTimeout(function(){be(!e),mt(),Ve(new Set),Je([]),$e.current=[],setTimeout(function(){Ce(!1)},400)},50)}}),i(d,e({ref:an,onScroll:Gt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ye?"hidden":"auto",borderTop:vt&&pt?"none":"1.5px solid #EEF0F4"}},{children:i(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ye?{flex:1,minHeight:0}:{})},{children:t(d,e({ref:Ft,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ye?{flex:1,overflow:"visible"}:{})},{children:[t("svg",e({ref:Ue,style:{position:"absolute",top:0,left:0,width:cn.width||"100%",height:cn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Pe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[jt&&i("g",{children:i("line",{x1:jt.x1,y1:jt.y,x2:jt.x2,y2:jt.y,stroke:xt.badgeBorder,strokeWidth:"1.5"})}),Lt.map(function(n){var o,r,l,c,u,a,s=n.x1+.5*(n.x2-n.x1),v=(n.y1+n.y2)/2;if("Not Defined"===n.style.label&&!n.hasCognitive)return null;if(n.isSubSection?ke&&Ne===n.subSectionKeyPath&&He:ke&&Ne===n.sectionIdx&&He)return t("g",e({style:{transition:"opacity 0.2s"}},{children:[i("defs",{children:i("marker",e({id:"arr-".concat(n.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:i("polygon",{points:"0 0, 7 2.5, 0 5",fill:n.style.badgeBorder||"#6366F1"})}))}),i("line",{ref:Mt,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(n.id,")")})]}),n.id);if(!ye){var p=n.isSubSection?C(n.x1,n.y1,n.x2,n.y2):"M ".concat(n.x1," ").concat(n.y1," L ").concat(n.x2," ").concat(n.y2),g=Kn[n.sectionIdx]||{title:"",content:""},x=Vn[n.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",g,x),n.isSubSection&&n.subSectionKeyPath){var m=n.subSectionKeyPath.includes(S)?n.subSectionKeyPath.split(S):[],y=m[2]||n.subSectionKeyPath,b=m[3]||y,R=y.split("-").map(Number),T=b.split("-").map(Number),I=Kn[R[0]],B=Vn[T[0]],w=(null==I?void 0:I.title)||"",F=(null==B?void 0:B.title)||"";console.log("Root Parent Titles:",w,F);for(var _=1;_<R.length;_++)(null==I?void 0:I.subsections)&&(I=I.subsections[R[_]]);for(_=1;_<T.length;_++)(null==B?void 0:B.subsections)&&(B=B.subsections[T[_]]);I&&(g=e(e({},I),{title:w||I.title})),console.log("Base Section for Subsection Badge:",g),B&&(x=e(e({},B),{title:F||B.title})),console.log("Ref Section for Subsection Badge:",x)}var k=!(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===(u=null===(c=g.evaluationResult)||void 0===c?void 0:c.cognitive_decisioning)||void 0===u?void 0:u.decisioning_factors)||void 0===a?void 0:a.length)||!1,H=k||M;return t("g",{children:[i("path",{d:p,fill:"none",stroke:n.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",e({x:s-100,y:v-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,e({onClick:function(e){e.stopPropagation(),H&&(bn.open&&Bn===n.id?Mn():(_n(n.id),It(Tt(e.currentTarget,g,x,n.sectionIdx,n.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:n.style.badgeBg,color:n.style.badgeText,border:"1px solid ".concat(n.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:H?"pointer":"default"}},{children:[n.style.badgeText===E&&null==n.style.label?i(D,{color:n.style.badgeText}):0===n.style.label?"Same":n.style.label,i(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),H&&i(f,{size:11,style:{transform:bn.open&&Bn===n.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},n.id)}return null}),qe.map(function(n){var o,r=n.pathD,l=(null===(o=n.style)||void 0===o?void 0:o.badgeBorder)||"#6366F1",c="conn-marker-".concat(n.id),u="".concat(n.id,"-bg"),d="".concat(n.id,"-stroke");return t("g",{children:[i("defs",{children:i("clipPath",e({id:"connections-clip"},{children:i("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:i("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),i("path",{ref:function(e){Ze.current[u]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),i("path",{ref:function(e){Ze.current[d]=e},d:r,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},n.id)})]})),t(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ye?{flex:1,overflow:"visible"}:{})},{children:[i(d,e({ref:Dt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:i(v,e({title:jn,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:jn}))}))})),t(d,e({ref:xn,onScroll:Gt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ye?{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:gn,style:{width:"100%",height:"0px",flexShrink:0}}),Gn&&Kn.map(function(n,o){var r,l,c=!n.title&&!n.content;if(ye&&c)return null;var u=n,a=Wt(o,"left"),s=ye?!(null===(r=u.refIndexes)||void 0===r?void 0:r.length)||u.selfIndex<0:!Vn[o],v=ye?"number"==typeof u.selfIndex&&u.selfIndex>=0?u.selfIndex+1:null:o+1,p=Ke.has(o),f=y(u.evaluationResult,null==a?void 0:a.deviationLabel);return i(d,e({ref:ut(o),sx:{mb:1,width:"100%"}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[i(d,e({ref:et.current[o],sx:e({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(N,{section:n,idx:o,columnKey:"left",colRef:ut("left-accordion-".concat(o)),mb:0,treeData:ce,proposedSections:Kn,existingSections:Vn,deviationNumberRegistry:Jn,getSectionCompareStyle:Wt,getBadgeRef:at,connectedSections:Ke,openMoreFunctionsPopup:Bt,openSummaryPopup:Zt,deviationNodeIdToView:xe,deviationTargetParentId:ri,parentNodeId:(null===(l=null==ce?void 0:ce.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:ye?!!bt["left-".concat(o)]:!!bt[String(o)],onToggle:function(){bt[ye?"left-".concat(o):String(o)]&&Fn(),Ct(o,"left")},navigation:n.id?ii[n.id]:null,showOpenNodeRef:oi,resolvedMarkdownStyles:dn,maintainRelativeOrder:ye,renderSubSections:ci})})),ye&&a&&t(d,e({ref:tt.current[o],onClick:function(e){var t=ye?Vn.find(function(e){var n;return null===(n=u.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Vn[o]||{title:"",content:""};Bt(e,n,s,t,o,a)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&i(d,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:v})),i(d,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:!pe.isLoading||null!=u.evaluationResult&&null!=u.evaluationResult?s?"No Deviation Found":"N/A"===f||"NA"===f?"N/A":0==f||null==f?"Same":"".concat(f):i(D,{color:a.badgeText})})),i(g,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))}),i("div",{ref:hn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,e({ref:_t,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,e({onClick:function(n){n.stopPropagation(),bn.open&&Bn===ft?Mn():(_n(ft),It(Tt(n.currentTarget,{title:"",content:"",evaluationResult:gt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,ft,!0,e(e({},xt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",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:i(D,{}),i(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(f,{size:11,style:{transform:bn.open&&Bn===ft?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},ye?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ie&&i(x,{sections:11}),i(d,e({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:i(v,e({title:Nn,placement:"top"},{children:i(p,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Nn}))}))})),t(d,e({ref:vn,onScroll:Gt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ye?{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:pn,style:{width:"100%",height:"0px",flexShrink:0}}),Gn&&Vn.map(function(n,o){var r,l=n,c=[],u=!1,a=null,s=-1;if(ye){c=Kn.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=Kn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var v=Kn.findIndex(function(e,n){var t;return Ke.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(u=-1!==v)&&(a=Wt(v))}else c=[o+1],(u=Ke.has(o))&&(a=Wt(o));var p=Wt(ye&&-1!==s?s:o);return i(d,e({ref:ot.current[o],sx:{mb:1,width:"100%"}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[i(d,e({ref:nt.current[o],sx:e({width:"100%",display:"flex"},u&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:i(N,{section:n,idx:o,columnKey:"right",colRef:ut("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==ce?void 0:ce.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:ye?!!bt["right-".concat(o)]:!!bt[String(o)],treeData:ce,proposedSections:Kn,existingSections:Vn,deviationNumberRegistry:Jn,getBadgeRef:at,getSectionCompareStyle:Wt,connectedSections:Ke,openMoreFunctionsPopup:Bt,openSummaryPopup:Zt,deviationNodeIdToView:xe,deviationTargetParentId:ri,onToggle:function(){bt[ye?"right-".concat(o):String(o)]&&Fn(),Ct(o,"right")},navigation:n.id?ii[n.id]:null,showOpenNodeRef:oi,resolvedMarkdownStyles:dn,maintainRelativeOrder:ye,renderSubSections:ci})})),ye&&!Ie&&p&&i(d,e({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:p.badgeBg,color:p.badgeText,border:"1px solid ".concat(p.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:c.length>0?c.join(", "):"-"}))]}))}),"right-row-".concat(o))}),i("div",{ref:fn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{Y as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- 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)},t=function(n){return null!=n&&("string"==typeof n?n.trim().length>0:!Array.isArray(n)||n.length>0&&n.some(function(n){return t(n)}))},r=function(t,r,e){var i,o=e[r],a=null===(i=null==t?void 0:t.comparison_inputs)||void 0===i?void 0:i[o];return{title:n((null==a?void 0:a.title)||""),content:n((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},e=function(n){if(!n.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var t=n.mapping_rationale,r=parseInt(t.decision_strength||"0");return{cognitiveData:{decisioning:t.decisioning_factors||[],gap:t.gaps_in_decision||[],relevance_score:r,citations:t.citations},score:0,relation:"N/A"}};function i(n){var t=function(n,t){var r=function(n){var t=function(n){return 4===n.length?"#"+n[1]+n[1]+n[2]+n[2]+n[3]+n[3]:n}(n).replace("#",""),r=parseInt(t,16);return{r:r>>16&255,g:r>>8&255,b:255&r}}(n),e=r.r,i=r.g,o=r.b;return function(n,t,r){return"#"+[n,t,r].map(function(n){return n.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(e+(255-e)*t),Math.round(i+(255-i)*t),Math.round(o+(255-o)*t))};return{bg:t(n,.8),border:t(n,.5),badgeBg:t(n,.8),badgeBorder:t(n,.5),badgeText:n.toUpperCase(),highlightBg:t(n,.8)}}function o(n,t){var r;return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var o=this;clearTimeout(r),r=setTimeout(function(){return n.apply(o,e)},t)}}var a=function(n,t){if(n.content!==t.content)return!1;if(n.sxStyles!==t.sxStyles)return!1;if(n.maintainRelativeOrder!==t.maintainRelativeOrder)return!1;var r=n.highlights||[],e=t.highlights||[];if(r.length!==e.length)return!1;for(var i=0;i<r.length;i++)if(r[i]!==e[i])return!1;var o=n.deviationBadges||[],a=t.deviationBadges||[];if(o.length!==a.length)return!1;for(i=0;i<o.length;i++){if(o[i].id!==a[i].id)return!1;if(o[i].label!==a[i].label)return!1;if(o[i].isConnected!==a[i].isConnected)return!1}return!0},u="::",l=function(n){if(!n)return!0;var t=n.trim().toLowerCase();return t.includes("no equivalent")||"n/a"===t||"na"===t||"none"===t},c=function(n,t){var r,e,i,o,a,u,l;if(!n)return t;var c=null!==(u=null!==(o=null!==(e=null===(r=n.evaluation_output)||void 0===r?void 0:r.output_score)&&void 0!==e?e:null===(i=n.evaluation_outputs)||void 0===i?void 0:i.output_score)&&void 0!==o?o:null===(a=n.evaluation_outputs)||void 0===a?void 0:a.output_value)&&void 0!==u?u:n.output_score;return null!==(l=null!=c?c:t)&&void 0!==l?l:""},s=function(n,t,r,e,i){void 0===i&&(i=14);var o=n+.5*(r-n),a=e-t;if(Math.abs(a)<3)return"M ".concat(n," ").concat(t," H ").concat(r);var u=a>0?1:-1,l=Math.min(i,Math.abs(a)/2,Math.abs(o-n)/2,Math.abs(r-o)/2);return["M ".concat(n," ").concat(t),"H ".concat(o-l),"Q ".concat(o," ").concat(t," ").concat(o," ").concat(t+u*l),"V ".concat(e-u*l),"Q ".concat(o," ").concat(e," ").concat(o+l," ").concat(e),"H ".concat(r)].join(" ")},v=function(n,t,r,e,i){void 0===r&&(r=300);var o=n.style.scrollBehavior;n.style.scrollBehavior="auto";var a=n.scrollTop,u=t-a,l=null,c=function(s){null===l&&(l=s);var v,g=s-l;g<r?(n.scrollTop=(v=g,v/=r,u*(--v*v*v+1)+a),i&&i(),requestAnimationFrame(c)):(n.scrollTop=t,n.style.scrollBehavior=o,i&&i(),e&&e())};requestAnimationFrame(c)},g=function(n){var t=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t=(t=(t=(t=t.replace(/['’‘`]/g,"['’‘`]")).replace(/["”“]/g,'["”“]')).replace(/[-—–]/g,"[-—–]")).replace(/\s+/g,"\\s+")};export{u as DEVIATION_BADGE_SEPARATOR,a as areMarkdownPropsEqual,o as debounce,g as escapeRegExp,c as extractDeviationScore,i as generateColorPalette,s as getBentArrowPath,e as getRationale,r as getSideData,t as hasValue,l as isMissingStr,n as safeStringify,v as smoothScrollTo};
1
+ 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)},t=function(n){return null!=n&&("string"==typeof n?n.trim().length>0:!Array.isArray(n)||n.length>0&&n.some(function(n){return t(n)}))},r=function(t,r,e){var i,o=e[r],a=null===(i=null==t?void 0:t.comparison_inputs)||void 0===i?void 0:i[o];return{title:n((null==a?void 0:a.title)||""),content:n((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},e=function(n){if(!n.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var t=n.mapping_rationale,r=parseInt(t.decision_strength||"0");return{cognitiveData:{decisioning:t.decisioning_factors||[],gap:t.gaps_in_decision||[],relevance_score:r,citations:t.citations},score:0,relation:"N/A"}};function i(n){var t=function(n,t){var r=function(n){var t=function(n){return 4===n.length?"#"+n[1]+n[1]+n[2]+n[2]+n[3]+n[3]:n}(n).replace("#",""),r=parseInt(t,16);return{r:r>>16&255,g:r>>8&255,b:255&r}}(n),e=r.r,i=r.g,o=r.b;return function(n,t,r){return"#"+[n,t,r].map(function(n){return n.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(e+(255-e)*t),Math.round(i+(255-i)*t),Math.round(o+(255-o)*t))};return{bg:t(n,.8),border:t(n,.5),badgeBg:t(n,.8),badgeBorder:t(n,.5),badgeText:n.toUpperCase(),highlightBg:t(n,.8)}}function o(n,t){var r;return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var o=this;clearTimeout(r),r=setTimeout(function(){return n.apply(o,e)},t)}}var a=function(n,t){var r,e,i,o,a,l;if(n.content!==t.content)return!1;if(n.sxStyles!==t.sxStyles)return!1;if(n.maintainRelativeOrder!==t.maintainRelativeOrder)return!1;if(n.highlightBg!==t.highlightBg)return!1;var u=n.highlights||[],c=t.highlights||[];if(u.length!==c.length)return!1;for(var s=0;s<u.length;s++)if(u[s]!==c[s])return!1;var v=n.deviationBadges||[],d=t.deviationBadges||[];if(v.length!==d.length)return!1;for(s=0;s<v.length;s++){if(v[s].id!==d[s].id)return!1;if(v[s].actionId!==d[s].actionId)return!1;if(v[s].label!==d[s].label)return!1;if(v[s].score!==d[s].score)return!1;if(v[s].isOrphan!==d[s].isOrphan)return!1;if(v[s].isConnected!==d[s].isConnected)return!1;if((null===(r=v[s].style)||void 0===r?void 0:r.badgeBg)!==(null===(e=d[s].style)||void 0===e?void 0:e.badgeBg))return!1;if((null===(i=v[s].style)||void 0===i?void 0:i.badgeBorder)!==(null===(o=d[s].style)||void 0===o?void 0:o.badgeBorder))return!1;if((null===(a=v[s].style)||void 0===a?void 0:a.badgeText)!==(null===(l=d[s].style)||void 0===l?void 0:l.badgeText))return!1}return!0},l="::",u=function(n){if(!n)return!0;var t=n.trim().toLowerCase();return t.includes("no equivalent")||"n/a"===t||"na"===t||"none"===t},c=function(n,t){var r,e,i,o,a,l,u;if(!n)return t;var c=null!==(l=null!==(o=null!==(e=null===(r=n.evaluation_output)||void 0===r?void 0:r.output_score)&&void 0!==e?e:null===(i=n.evaluation_outputs)||void 0===i?void 0:i.output_score)&&void 0!==o?o:null===(a=n.evaluation_outputs)||void 0===a?void 0:a.output_value)&&void 0!==l?l:n.output_score;return null!==(u=null!=c?c:t)&&void 0!==u?u:""},s=function(n,t,r,e,i){void 0===i&&(i=14);var o=n+.5*(r-n),a=e-t;if(Math.abs(a)<3)return"M ".concat(n," ").concat(t," H ").concat(r);var l=a>0?1:-1,u=Math.min(i,Math.abs(a)/2,Math.abs(o-n)/2,Math.abs(r-o)/2);return["M ".concat(n," ").concat(t),"H ".concat(o-u),"Q ".concat(o," ").concat(t," ").concat(o," ").concat(t+l*u),"V ".concat(e-l*u),"Q ".concat(o," ").concat(e," ").concat(o+u," ").concat(e),"H ".concat(r)].join(" ")},v=function(n,t,r,e,i){void 0===r&&(r=300);var o=n.style.scrollBehavior;n.style.scrollBehavior="auto";var a=n.scrollTop,l=t-a,u=null,c=function(s){null===u&&(u=s);var v,d=s-u;d<r?(n.scrollTop=(v=d,v/=r,l*(--v*v*v+1)+a),i&&i(),requestAnimationFrame(c)):(n.scrollTop=t,n.style.scrollBehavior=o,i&&i(),e&&e())};requestAnimationFrame(c)},d=function(n){var t=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t=(t=(t=(t=t.replace(/['’‘`]/g,"['’‘`]")).replace(/["”“]/g,'["”“]')).replace(/[-—–]/g,"[-—–]")).replace(/\s+/g,"\\s+")};export{l as DEVIATION_BADGE_SEPARATOR,a as areMarkdownPropsEqual,o as debounce,d as escapeRegExp,c as extractDeviationScore,i as generateColorPalette,s as getBentArrowPath,e as getRationale,r as getSideData,t as hasValue,u as isMissingStr,n as safeStringify,v as smoothScrollTo};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as n,jsx as o}from"react/jsx-runtime";import t,{useEffect as i}from"react";import{Box as l,Accordion as r,AccordionSummary as d,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{hasValue as p,generateColorPalette as h,isMissingStr as m,safeStringify as g,escapeRegExp as x,DEVIATION_BADGE_SEPARATOR as b}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as y}from"../CognitiveCompareConstants.js";var w=function(w){var I,F,B,S,k,R,_,C,A,T,E,M,W,O,D,N,j=w.section,P=w.idx,z=w.columnKey,K=w.colRef,V=w.mb,G=void 0===V?1:V,X=w.parentNodeId,Y=void 0===X?"":X,H=w.isExpanded,$=w.onToggle,q=w.navigation,J=w.showOpenNodeRef,L=w.resolvedMarkdownStyles,Q=w.maintainRelativeOrder,U=w.renderSubSections,Z=w.treeData,ee=w.proposedSections,ne=void 0===ee?[]:ee,oe=w.existingSections,te=void 0===oe?[]:oe,ie=w.deviationNumberRegistry,le=void 0===ie?{}:ie,re=w.getBadgeRef,de=w.openSummaryPopup,ae=w.getSectionCompareStyle,ue=w.connectedSections,ce=w.openMoreFunctionsPopup,se=w.deviationNodeIdToView,ve=w.deviationTargetParentId,fe=(null===(I=j.displayTitle)||void 0===I||I)&&p(j.title),pe=(null===(F=j.displayContent)||void 0===F||F)&&p(j.content),he=!fe&&!pe,me={current:1},ge=j.title;fe||(ge=pe?"No Title Found":"No Matching Section Found");var xe=j.evaluationResult;if(!xe&&"right"===z)if(Q){var be=null===(B=j.refIndexes)||void 0===B?void 0:B[0],ye=ne.find(function(e){return e.selfIndex===be});xe=null==ye?void 0:ye.evaluationResult}else xe=null===(S=ne[P])||void 0===S?void 0:S.evaluationResult;var we=null===(k=null==Z?void 0:Z.input_index_map)||void 0===k?void 0:k[0],Ie=null===(R=null==Z?void 0:Z.input_index_map)||void 0===R?void 0:R[1],Fe="left"===z?Ie:we,Be="left"===z?j:ne[P],Se="right"===z?j:te[P];if(Q)if("left"===z){var ke=null===(_=j.refIndexes)||void 0===_?void 0:_[0],Re=te.findIndex(function(e){return e.selfIndex===ke});Se=-1!==Re?te[Re]:void 0}else{var _e=null===(C=j.refIndexes)||void 0===C?void 0:C[0],Ce=ne.findIndex(function(e){return e.selfIndex===_e});Be=-1!==Ce?ne[Ce]:void 0}var Ae="left"===z?!Se:!Be,Te=xe||(null==Be?void 0:Be.evaluationResult)||(null==Se?void 0:Se.evaluationResult),Ee=null!==(E=null===(T=null===(A=null==Te?void 0:Te.evaluation_outputs)||void 0===A?void 0:A.metadata)||void 0===T?void 0:T.label_color)&&void 0!==E?E:y,Me=h(Ee),We=Me.highlightBg,Oe=null!==(W=null===(M=null==Te?void 0:Te.evaluation_outputs)||void 0===M?void 0:M.output_value)&&void 0!==W?W:null,De=(null==Te?void 0:Te.deviations)||{},Ne=P+1,je=j.id;if("right"===z&&Q){var Pe=null===(O=j.refIndexes)||void 0===O?void 0:O[0];-1!==(Ce=ne.findIndex(function(e){return e.selfIndex===Pe}))&&(Ne=Ce+1,je=ne[Ce].id)}var ze,Ke=[],Ve=Object.entries(De).map(function(n){var o,t,i,l=n[0],r=n[1],d="".concat(je).concat(b).concat(l),a=le[d];if(!a)return null;var u=r[Y],c=m(u);if(c)u="";else if(!u)return null;Ke.push(u);var s=r[Fe],v="left"===z?null===(o=ne[P])||void 0===o?void 0:o.content:null===(t=te[P])||void 0===t?void 0:t.content,f=g(v),p=Object.keys(De).map(function(e){return{key:e,text:De[e][Fe]}}).filter(function(e){return!m(e.text)}).sort(function(e,n){return n.text.length-e.text.length}),h=new Set;p.forEach(function(e){var n=e.text.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n){var o=new RegExp(x(n));o.test(f)&&(h.add(e.key),f=f.replace(o,"__TOKEN_".concat(e.key,"__")))}});var y=!m(s)&&!h.has(l),w=Ae||m(s)||y,I="".concat(Ne,".").concat(a),F="".concat(je).concat(b).concat(l).concat(b).concat(P).concat(b).concat(P),B=P;if("right"===z&&Q){var S=null===(i=j.refIndexes)||void 0===i?void 0:i[0],k=ne.findIndex(function(e){return e.selfIndex===S});-1!==k&&(B=k)}var R=ae?ae(B):null,_=!1;u&&(_=Object.values(De).map(function(e){return e[Y]}).filter(Boolean).some(function(e){return e.length>u.length&&e.includes(u)}));var C=R?e(e({},R),{badgeBg:Me.badgeBg,badgeBorder:Me.badgeBorder,badgeText:Me.badgeText}):e({},Me);_&&(C.badgeBg="#FFFBEB",C.badgeBorder="#FCD34D",C.badgeText="#B45309",C.highlightBg="#FDE68A");var A=(null==r?void 0:r.deviation_summary)?{deviation_summary:r.deviation_summary,deviation_title:null==Te?void 0:Te.deviation_title,evaluation_outputs:null==Te?void 0:Te.evaluation_outputs}:null;return{id:d,actionId:F,label:I,highlight:u,side:z,style:C,score:Oe,isConnected:null==ue?void 0:ue.has(F),isOrphan:w,isMissingClause:c,badgeRef:re(z,d),onClick:function(e){e.stopPropagation(),ce&&ce(e,Be||{id:"orphan-left",title:"",content:""},w,Se||{id:"orphan-right",title:"",content:""},F,C)},onSummaryClick:function(e){e.stopPropagation(),de(e,F,w,A)}}}).filter(Boolean),Ge=j.id&&z===(null==q?void 0:q.columnKey)?q:null,Xe=t.useRef(!1);return i(function(){H||(Xe.current=!1)},[H]),i(function(){var e=!!se&&!!ve&&je===ve,n=!!se&&(j.subsections||[]).some(function(e){return e.id===se});if(H&&!Xe.current&&!e&&!n){var o=setTimeout(function(){var e,n;Xe.current=!0,null===(n=null===(e=null==Ge?void 0:Ge.showBelowRef)||void 0===e?void 0:e.current)||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"})},600);return function(){return clearTimeout(o)}}},[H,se,ve,je,null==Ge?void 0:Ge.showBelow]),n(l,e({ref:K,sx:{mb:G,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[H&&(null==Ge?void 0:Ge.showAbove)&&o("div",e({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Ge?void 0:Ge.showAboveRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===z?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===z?{right:"0px"}:{left:"0px"})},{children:o(s,{color:window.getComputedStyle(null===(D=null==Ge?void 0:Ge.showAboveRef)||void 0===D?void 0:D.current).color})}))})),n(r,e({disableGutters:!0,expanded:!he&&H,onChange:function(){he||($(),J.current=j.id)},sx:{boxShadow:"none",border:he?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:he?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[o(d,e({expandIcon:he?null:o(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:he?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:fe&&o(a,e({title:ge,placement:"top"},{children:o(u,e({component:"div",sx:{fontSize:"12px",color:he?"#94A3B8":"#19213D",fontWeight:he?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ze=ge,ze?g(ze).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?o("strong",{children:e.slice(2,-2)},n):o(t.Fragment,{children:e},n)}):null)}))}))})),!he&&n(c,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[pe&&o(f,{content:j.content,sxStyles:L,highlights:Ke,maintainRelativeOrder:Q,highlightBg:We,deviationBadges:Ve}),(j.subsections||[]).map(function(e,n){return U({section:e,keyPath:"".concat(P,"-").concat(n),depth:0,columnKey:z,parentNodeId:Y,devCounter:me})})]}))]})),H&&(null==Ge?void 0:Ge.showBelow)&&o("div",e({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Ge?void 0:Ge.showBelowRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===z?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===z?{right:"0px"}:{left:"0px"})},{children:o(v,{color:window.getComputedStyle(null===(N=null==Ge?void 0:Ge.showBelowRef)||void 0===N?void 0:N.current).color})}))}))]}),"".concat(z,"-sec-").concat(P))};export{w as default};
1
+ import{__assign as e}from"tslib";import{jsxs as n,jsx as o}from"react/jsx-runtime";import t,{useEffect as i}from"react";import{Box as l,Accordion as r,AccordionSummary as d,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{hasValue as p,generateColorPalette as m,isMissingStr as h,safeStringify as g,escapeRegExp as x,DEVIATION_BADGE_SEPARATOR as b}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as y}from"../CognitiveCompareConstants.js";var w=function(e){var n=function(e){for(var n=(null==e?void 0:e.parentElement)||null;n;){var o=window.getComputedStyle(n).overflowY;if(("auto"===o||"scroll"===o)&&n.scrollHeight>n.clientHeight)return n;n=n.parentElement}return null}(e),o=e.getBoundingClientRect(),t=(null==n?void 0:n.getBoundingClientRect())||{top:0,bottom:window.innerHeight};return o.top>=t.top&&o.bottom<=t.bottom},I=function(I){var R,S,F,k,C,_,B,A,T,E,M,W,D,N,O,P,j=I.section,z=I.idx,H=I.columnKey,K=I.colRef,V=I.mb,Y=void 0===V?1:V,G=I.parentNodeId,X=void 0===G?"":G,$=I.isExpanded,q=I.onToggle,J=I.navigation,L=I.showOpenNodeRef,Q=I.resolvedMarkdownStyles,U=I.maintainRelativeOrder,Z=I.renderSubSections,ee=I.treeData,ne=I.proposedSections,oe=void 0===ne?[]:ne,te=I.existingSections,ie=void 0===te?[]:te,le=I.deviationNumberRegistry,re=void 0===le?{}:le,de=I.getBadgeRef,ae=I.openSummaryPopup,ue=I.getSectionCompareStyle,ce=I.connectedSections,se=I.openMoreFunctionsPopup,ve=I.deviationNodeIdToView,fe=I.deviationTargetParentId,pe=(null===(R=j.displayTitle)||void 0===R||R)&&p(j.title),me=(null===(S=j.displayContent)||void 0===S||S)&&p(j.content),he=!pe&&!me,ge={current:1},xe=j.title;pe||(xe=me?"No Title Found":"No Matching Section Found");var be=j.evaluationResult;if(!be&&"right"===H)if(U){var ye=null===(F=j.refIndexes)||void 0===F?void 0:F[0],we=oe.find(function(e){return e.selfIndex===ye});be=null==we?void 0:we.evaluationResult}else be=null===(k=oe[z])||void 0===k?void 0:k.evaluationResult;var Ie=null===(C=null==ee?void 0:ee.input_index_map)||void 0===C?void 0:C[0],Re=null===(_=null==ee?void 0:ee.input_index_map)||void 0===_?void 0:_[1],Se="left"===H?Re:Ie,Fe="left"===H?j:oe[z],ke="right"===H?j:ie[z];if(U)if("left"===H){var Ce=null===(B=j.refIndexes)||void 0===B?void 0:B[0],_e=ie.findIndex(function(e){return e.selfIndex===Ce});ke=-1!==_e?ie[_e]:void 0}else{var Be=null===(A=j.refIndexes)||void 0===A?void 0:A[0],Ae=oe.findIndex(function(e){return e.selfIndex===Be});Fe=-1!==Ae?oe[Ae]:void 0}var Te="left"===H?!ke:!Fe,Ee=be||(null==Fe?void 0:Fe.evaluationResult)||(null==ke?void 0:ke.evaluationResult),Me=null!==(M=null===(E=null===(T=null==Ee?void 0:Ee.evaluation_outputs)||void 0===T?void 0:T.metadata)||void 0===E?void 0:E.label_color)&&void 0!==M?M:y,We=m(Me),De=We.highlightBg,Ne=null!==(D=null===(W=null==Ee?void 0:Ee.evaluation_outputs)||void 0===W?void 0:W.output_value)&&void 0!==D?D:null,Oe=(null==Ee?void 0:Ee.deviations)||{},Pe=z+1,je=j.id;if("right"===H&&U){var ze=null===(N=j.refIndexes)||void 0===N?void 0:N[0];-1!==(Ae=oe.findIndex(function(e){return e.selfIndex===ze}))&&(Pe=Ae+1,je=oe[Ae].id)}var He,Ke=[],Ve=Object.entries(Oe).map(function(n){var o,t,i,l=n[0],r=n[1],d="".concat(je).concat(b).concat(l),a=re[d];if(!a)return null;var u=r[X],c=h(u);if(c)u="";else if(!u)return null;Ke.push(u);var s=r[Se],v="left"===H?null===(o=oe[z])||void 0===o?void 0:o.content:null===(t=ie[z])||void 0===t?void 0:t.content,f=g(v),p=Object.keys(Oe).map(function(e){return{key:e,text:Oe[e][Se]}}).filter(function(e){return!h(e.text)}).sort(function(e,n){return n.text.length-e.text.length}),m=new Set;p.forEach(function(e){var n=e.text.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n){var o=new RegExp(x(n));o.test(f)&&(m.add(e.key),f=f.replace(o,"__TOKEN_".concat(e.key,"__")))}});var y=!h(s)&&!m.has(l),w=Te||h(s)||y,I="".concat(Pe,".").concat(a),R="".concat(je).concat(b).concat(l).concat(b).concat(z).concat(b).concat(z),S=z;if("right"===H&&U){var F=null===(i=j.refIndexes)||void 0===i?void 0:i[0],k=oe.findIndex(function(e){return e.selfIndex===F});-1!==k&&(S=k)}var C=ue?ue(S):null,_=C?e(e({},C),{badgeBg:We.badgeBg,badgeBorder:We.badgeBorder,badgeText:We.badgeText}):e({},We),B=(null==r?void 0:r.deviation_summary)?{deviation_summary:r.deviation_summary,deviation_title:null==Ee?void 0:Ee.deviation_title,evaluation_outputs:null==Ee?void 0:Ee.evaluation_outputs}:null;return{id:d,actionId:R,label:I,highlight:u,side:H,style:_,score:Ne,isConnected:null==ce?void 0:ce.has(R),isOrphan:w,isMissingClause:c,badgeRef:de(H,d),onClick:function(e){e.stopPropagation(),se&&se(e,Fe||{id:"orphan-left",title:"",content:""},w,ke||{id:"orphan-right",title:"",content:""},R,_)},onSummaryClick:function(e){e.stopPropagation(),ae(e,R,w,B)}}}).filter(Boolean),Ye=j.id&&H===(null==J?void 0:J.columnKey)?J:null,Ge=t.useRef(!1);return i(function(){$||(Ge.current=!1)},[$]),i(function(){var e=!!ve&&!!fe&&je===fe,n=!!ve&&(j.subsections||[]).some(function(e){return e.id===ve});if($&&!Ge.current&&!e&&!n){var o=setTimeout(function(){var e,n=null===(e=null==Ye?void 0:Ye.firstDeviationRef)||void 0===e?void 0:e.current,o=null==Ye?void 0:Ye.firstDeviationPosition;n?"inside"===o||w(n)?Ge.current=!0:(Ge.current=!0,n.scrollIntoView({behavior:"smooth",block:"center"})):Ge.current=!0},600);return function(){return clearTimeout(o)}}},[$,ve,fe,je,null==Ye?void 0:Ye.firstDeviationPosition,null==Ye?void 0:Ye.firstDeviationRef]),n(l,e({ref:K,sx:{mb:Y,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[$&&(null==Ye?void 0:Ye.showAbove)&&o("div",e({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Ye?void 0:Ye.showAboveRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===H?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===H?{right:"0px"}:{left:"0px"})},{children:o(s,{color:window.getComputedStyle(null===(O=null==Ye?void 0:Ye.showAboveRef)||void 0===O?void 0:O.current).color})}))})),n(r,e({disableGutters:!0,expanded:!he&&$,onChange:function(){he||(q(),L.current=j.id)},sx:{boxShadow:"none",border:he?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:he?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[o(d,e({expandIcon:he?null:o(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:he?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:pe&&o(a,e({title:xe,placement:"top"},{children:o(u,e({component:"div",sx:{fontSize:"12px",color:he?"#94A3B8":"#19213D",fontWeight:he?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(He=xe,He?g(He).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?o("strong",{children:e.slice(2,-2)},n):o(t.Fragment,{children:e},n)}):null)}))}))})),!he&&n(c,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[me&&o(f,{content:j.content,sxStyles:Q,highlights:Ke,maintainRelativeOrder:U,highlightBg:De,deviationBadges:Ve}),(j.subsections||[]).map(function(e,n){return Z({section:e,keyPath:"".concat(z,"-").concat(n),depth:0,columnKey:H,parentNodeId:X,devCounter:ge})})]}))]})),$&&(null==Ye?void 0:Ye.showBelow)&&o("div",e({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==Ye?void 0:Ye.showBelowRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===H?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===H?{right:"0px"}:{left:"0px"})},{children:o(v,{color:window.getComputedStyle(null===(P=null==Ye?void 0:Ye.showBelowRef)||void 0===P?void 0:P.current).color})}))}))]}),"".concat(H,"-sec-").concat(z))};export{I as default};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as t,__assign as i}from"tslib";import{jsx as e,jsxs as n}from"react/jsx-runtime";import o from"react";import{Box as l,Accordion as d,AccordionSummary as a,Typography as r,AccordionDetails as u}from"@mui/material";import{ChevronDown as s}from"lucide-react";import{MemoizedMarkdown as c}from"../hooks/memoizedMarkdown.js";import{hasValue as v,generateColorPalette as p,isMissingStr as h,DEVIATION_BADGE_SEPARATOR as m}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as f}from"../CognitiveCompareConstants.js";var g=o.memo(function(o){var x,b,S,y,B,F,C,_,R,w,I,j=o.section,O=o.keyPath,k=o.depth,E=void 0===k?0:k,P=o.columnKey,W=void 0===P?"left":P,M=o.parentNodeId,D=void 0===M?"":M,N=o.expandedSubSections,z=o.setExpandedSubSections,A=o.maintainRelativeOrder,T=o.proposedSections,G=o.existingSections,H=o.treeData,K=o.deviationNumberRegistry,L=o.connectedSections,U=o.activeSideBySideSection,q=o.resolvedMarkdownStyles,J=o.getSubSectionRef,Q=o.getSubSectionCompareStyle,V=o.getBadgeRef,X=o.openMoreFunctionsPopup,Y=o.openSummaryPopup,Z=o.resetSideBySide,$=o.setConnectedSections,tt=o.setConnectedLines,it=o.cachedConnectedPositions,et=(null===(x=j.displayTitle)||void 0===x||x)&&v(j.title),nt=(null===(b=j.displayContent)||void 0===b||b)&&v(j.content),ot=!et&&!nt,lt=et?j.title:nt?"No Title Found":"No Matching Section Found",dt=!!N[O],at=J(W,O),rt=O.split("-").map(Number),ut=rt[0],st=T[ut],ct=G[ut],vt=O,pt=O;if(A)if("left"===W){var ht=null===(S=null==st?void 0:st.refIndexes)||void 0===S?void 0:S[0],mt=G.findIndex(function(t){return t.selfIndex===ht});-1!==mt&&(ct=G[mt],pt=t([mt],rt.slice(1),!0).join("-"))}else{var ft=null===(y=null==ct?void 0:ct.refIndexes)||void 0===y?void 0:y[0];-1!==(St=T.findIndex(function(t){return t.selfIndex===ft}))&&(st=T[St],vt=t([St],rt.slice(1),!0).join("-"))}for(var gt=st,xt=ct,bt=1;bt<rt.length;bt++)(null==gt?void 0:gt.subsections)&&(gt=gt.subsections[rt[bt]]),(null==xt?void 0:xt.subsections)&&(xt=xt.subsections[rt[bt]]);var St,yt=Q(vt)||Q(O),Bt=null===(B=null==H?void 0:H.input_index_map)||void 0===B?void 0:B[0],Ft=null===(F=null==H?void 0:H.input_index_map)||void 0===F?void 0:F[1],Ct="left"===W?Ft:Bt,_t="left"===W?!xt:!gt,Rt=j.evaluationResult||(null==gt?void 0:gt.evaluationResult)||(null==xt?void 0:xt.evaluationResult),wt=null!==(_=null===(C=null==Rt?void 0:Rt.evaluation_outputs)||void 0===C?void 0:C.output_value)&&void 0!==_?_:null,It=ut+1,jt=j.id;"right"===W&&A&&((null==gt?void 0:gt.id)&&(jt=gt.id),st&&-1!==(St=T.findIndex(function(t){return t.id===st.id}))&&(It=St+1));var Ot=null!==(I=null===(w=null===(R=null==Rt?void 0:Rt.evaluation_outputs)||void 0===R?void 0:R.metadata)||void 0===w?void 0:w.label_color)&&void 0!==I?I:f,kt=p(Ot),Et=kt.highlightBg,Pt=(null==Rt?void 0:Rt.deviations)||{},Wt=[],Mt=Object.entries(Pt).map(function(t){var e,n,o,l=t[0],d=t[1],a="".concat(jt).concat(m).concat(l),r=K[a];if(!r)return null;var u=d[D],s=h(u);if(s)u="";else if(!u)return null;Wt.push(u);var c=d[Ct],v=!1;c&&(v=Object.values(Pt).map(function(t){return t[Ct]}).filter(Boolean).some(function(t){return t.length>c.length&&t.includes(c)}));var p=_t||h(c)||v,f="".concat(It,".").concat(r),g="".concat(jt).concat(m).concat(l).concat(m).concat(vt).concat(m).concat(pt),x=i({},kt),b=!1;u&&(b=Object.values(Pt).map(function(t){return t[D]}).filter(Boolean).some(function(t){return t.length>u.length&&t.includes(u)}));b&&(x.badgeBg="#FFFBEB",x.badgeBorder="#FCD34D",x.badgeText="#B45309",x.highlightBg="#FDE68A");var S=(null==d?void 0:d.deviation_summary)?{deviation_summary:d.deviation_summary||(null===(e=j.evaluationResult)||void 0===e?void 0:e.deviation_summary),deviation_title:null===(n=j.evaluationResult)||void 0===n?void 0:n.deviation_title,evaluation_outputs:null===(o=j.evaluationResult)||void 0===o?void 0:o.evaluation_outputs}:null;return{id:a,actionId:g,label:f,highlight:u,side:W,style:x,score:wt,isConnected:L.has(g),isOrphan:p,isMissingClause:s,badgeRef:V(W,a),onClick:function(t){t.stopPropagation();var e=gt?i(i({},gt),{title:(null==st?void 0:st.title)||(null==gt?void 0:gt.title)||""}):{id:"orphan-left",title:"",content:""},n=xt?i(i({},xt),{title:(null==ct?void 0:ct.title)||(null==xt?void 0:xt.title)||""}):{id:"orphan-right",title:"",content:""};X(t,e,p,n,g,x)},onSummaryClick:function(t){t.stopPropagation(),Y(t,g,p,S)}}}).filter(Boolean),Dt=Mt.some(function(t){return L.has(t.actionId)});if(!(et||nt||j.subsections&&0!==j.subsections.length))return null;var Nt=!A&&et&&nt,zt=Dt&&yt?{borderRadius:"4px",outline:"2px solid ".concat(yt.badgeBorder),outlineOffset:"1px"}:{};return e(l,et?i({ref:at,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e(l,i({sx:i({width:"100%"},zt)},{children:n(d,i({disableGutters:!0,expanded:!ot&&dt,onChange:function(){if(!ot){if(dt){var t=String(U||""),e=t.includes(vt)||t.includes(pt);e||L.forEach(function(t){(String(t).includes(vt)||String(t).includes(pt))&&(e=!0)}),e&&(Z(),$(new Set),tt([]),it.current=[])}z(function(t){var e;return i(i({},t),((e={})[O]=!t[O],e))})}},sx:{mt:0,boxShadow:"none",border:ot?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e(a,i({expandIcon:ot?null:e(s,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e(r,i({component:"div",sx:{fontSize:"11px",fontWeight:600,color:ot?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:lt||"Untitled Subsection"}))})),!ot&&n(u,i({sx:{pt:0,pb:1,minWidth:0}},{children:[nt&&e(c,{content:j.content,sxStyles:q,deviationBadges:Nt?[]:Mt,maintainRelativeOrder:A,highlightBg:Et,highlights:Wt}),(j.subsections||[]).map(function(t,n){return e(g,i({},o,{section:t,keyPath:"".concat(O,"-").concat(n),depth:E+1}),"".concat(O,"-").concat(n))})]}))]}))}))}):i({ref:at,sx:{mt:0===E?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!ot&&n(l,i({sx:i({width:"100%"},zt)},{children:[nt&&e(c,{content:j.content,sxStyles:q,deviationBadges:Mt,maintainRelativeOrder:A,highlightBg:Et,highlights:Wt}),(j.subsections||[]).map(function(t,n){return e(g,i({},o,{section:t,keyPath:"".concat(O,"-").concat(n),depth:E+1}),"".concat(O,"-").concat(n))})]}))}))});export{g as default};
1
+ import{__assign as n}from"tslib";import{jsx as t,jsxs as i}from"react/jsx-runtime";import e from"react";import{Box as o,Accordion as l,AccordionSummary as a,Typography as d,AccordionDetails as r}from"@mui/material";import{ChevronDown as u}from"lucide-react";import{MemoizedMarkdown as c}from"../hooks/memoizedMarkdown.js";import{hasValue as s,generateColorPalette as v,isMissingStr as h,DEVIATION_BADGE_SEPARATOR as p}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as f}from"../CognitiveCompareConstants.js";var m=e.memo(function(e){var g,x,S,b,y,_,C,k,w,P,B,F=e.section,I=e.keyPath,R=e.depth,O=void 0===R?0:R,j=e.columnKey,E=void 0===j?"left":j,W=e.parentNodeId,M=void 0===W?"":W,N=e.expandedSubSections,z=e.setExpandedSubSections,A=e.maintainRelativeOrder,D=e.proposedSections,T=e.existingSections,G=e.treeData,H=e.deviationNumberRegistry,K=e.connectedSections,L=e.activeSideBySideSection,U=e.resolvedMarkdownStyles,q=e.getSubSectionRef,J=e.getSubSectionCompareStyle,Q=e.getBadgeRef,V=e.openMoreFunctionsPopup,X=e.openSummaryPopup,Y=e.resetSideBySide,Z=e.setConnectedSections,$=e.setConnectedLines,nn=e.cachedConnectedPositions,tn=(null===(g=F.displayTitle)||void 0===g||g)&&s(F.title),en=(null===(x=F.displayContent)||void 0===x||x)&&s(F.content),on=!tn&&!en,ln=tn?F.title:en?"No Title Found":"No Matching Section Found",an=!!N[I],dn=q(E,I),rn=I.split("-").map(Number),un=rn[0],cn=D[un],sn=T[un],vn=I,hn=I,pn=un,fn=un,mn=function(n,t,i){if(!n||!t)return null;if(n.id===t)return{section:n,keyPath:i};for(var e=(n.subsections||[]).map(function(n,t){return{section:n,keyPath:"".concat(i,"-").concat(t)}}),o=function(){var n=e.shift();return(null==n?void 0:n.section)?n.section.id===t?{value:n}:void(n.section.subsections||[]).forEach(function(t,i){e.push({section:t,keyPath:"".concat(n.keyPath,"-").concat(i)})}):"continue"};e.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(A)if("left"===E){var gn=null===(S=null==cn?void 0:cn.refIndexes)||void 0===S?void 0:S[0],xn=T.findIndex(function(n){return n.selfIndex===gn});-1!==xn&&(sn=T[xn],fn=xn)}else{var Sn=null===(b=null==sn?void 0:sn.refIndexes)||void 0===b?void 0:b[0];-1!==(wn=D.findIndex(function(n){return n.selfIndex===Sn}))&&(cn=D[wn],pn=wn)}var bn=cn,yn=sn;if(A)if("left"===E){bn=F,vn=I;var _n=mn(sn,F.id,String(fn));yn=(null==_n?void 0:_n.section)||null,hn=(null==_n?void 0:_n.keyPath)||""}else{yn=F,hn=I;var Cn=mn(cn,F.id,String(pn));bn=(null==Cn?void 0:Cn.section)||null,vn=(null==Cn?void 0:Cn.keyPath)||""}else for(var kn=1;kn<rn.length;kn++)(null==bn?void 0:bn.subsections)&&(bn=bn.subsections[rn[kn]]),(null==yn?void 0:yn.subsections)&&(yn=yn.subsections[rn[kn]]);var wn,Pn=(vn?J(vn):null)||J(I),Bn=null===(y=null==G?void 0:G.input_index_map)||void 0===y?void 0:y[0],Fn=null===(_=null==G?void 0:G.input_index_map)||void 0===_?void 0:_[1],In="left"===E?Fn:Bn,Rn="left"===E?!yn:!bn,On=F.evaluationResult||(null==bn?void 0:bn.evaluationResult)||(null==yn?void 0:yn.evaluationResult),jn=null!==(k=null===(C=null==On?void 0:On.evaluation_outputs)||void 0===C?void 0:C.output_value)&&void 0!==k?k:null,En=un+1,Wn=F.id||(null==bn?void 0:bn.id)||(null==yn?void 0:yn.id);"right"===E&&A&&(cn&&-1!==(wn=D.findIndex(function(n){return n.id===cn.id}))&&(En=wn+1));var Mn=null!==(B=null===(P=null===(w=null==On?void 0:On.evaluation_outputs)||void 0===w?void 0:w.metadata)||void 0===P?void 0:P.label_color)&&void 0!==B?B:f,Nn=v(Mn),zn=Nn.highlightBg,An=(null==On?void 0:On.deviations)||{},Dn=[],Tn=Object.entries(An).map(function(t){var i=t[0],e=t[1],o="".concat(Wn).concat(p).concat(i),l=H[o];if(!l)return null;var a=e[M],d=h(a);if(d)a="";else if(!a)return null;Dn.push(a);var r=e[In],u=!1;r&&(u=Object.values(An).map(function(n){return n[In]}).filter(Boolean).some(function(n){return n.length>r.length&&n.includes(r)}));var c=Rn||h(r)||u,s="".concat(En,".").concat(l),v="".concat(Wn).concat(p).concat(i).concat(p).concat(vn).concat(p).concat(hn),f=n({},Nn),m=(null==e?void 0:e.deviation_summary)?{deviation_summary:e.deviation_summary||(null==On?void 0:On.deviation_summary),deviation_title:null==On?void 0:On.deviation_title,evaluation_outputs:null==On?void 0:On.evaluation_outputs}:null;return{id:o,actionId:v,label:s,highlight:a,side:E,style:f,score:jn,isConnected:K.has(v),isOrphan:c,isMissingClause:d,badgeRef:Q(E,o),onClick:function(t){t.stopPropagation();var i=bn?n(n({},bn),{title:(null==cn?void 0:cn.title)||(null==bn?void 0:bn.title)||""}):{id:"orphan-left",title:"",content:""},e=yn?n(n({},yn),{title:(null==sn?void 0:sn.title)||(null==yn?void 0:yn.title)||""}):{id:"orphan-right",title:"",content:""};V(t,i,c,e,v,f)},onSummaryClick:function(n){n.stopPropagation(),X(n,v,c,m)}}}).filter(Boolean),Gn=Tn.some(function(n){return K.has(n.actionId)});if(!(tn||en||F.subsections&&0!==F.subsections.length))return null;var Hn=!A&&tn&&en,Kn=Gn&&Pn?{borderRadius:"4px",outline:"2px solid ".concat(Pn.badgeBorder),outlineOffset:"1px"}:{};return t(o,tn?n({ref:dn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:t(o,n({sx:n({width:"100%"},Kn)},{children:i(l,n({disableGutters:!0,expanded:!on&&an,onChange:function(){if(!on){if(an){var t=String(L||""),i=t.includes(vn)||t.includes(hn);i||K.forEach(function(n){(String(n).includes(vn)||String(n).includes(hn))&&(i=!0)}),i&&(Y(),Z(new Set),$([]),nn.current=[])}z(function(t){var i;return n(n({},t),((i={})[I]=!t[I],i))})}},sx:{mt:0,boxShadow:"none",border:on?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[t(a,n({expandIcon:on?null:t(u,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:t(d,n({component:"div",sx:{fontSize:"11px",fontWeight:600,color:on?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:ln||"Untitled Subsection"}))})),!on&&i(r,n({sx:{pt:0,pb:1,minWidth:0}},{children:[en&&t(c,{content:F.content,sxStyles:U,deviationBadges:Hn?[]:Tn,maintainRelativeOrder:A,highlightBg:zn,highlights:Dn}),(F.subsections||[]).map(function(i,o){return t(m,n({},e,{section:i,keyPath:"".concat(I,"-").concat(o),depth:O+1}),"".concat(I,"-").concat(o))})]}))]}))}))}):n({ref:dn,sx:{mt:0===O?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!on&&i(o,n({sx:n({width:"100%"},Kn)},{children:[en&&t(c,{content:F.content,sxStyles:U,deviationBadges:Tn,maintainRelativeOrder:A,highlightBg:zn,highlights:Dn}),(F.subsections||[]).map(function(i,o){return t(m,n({},e,{section:i,keyPath:"".concat(I,"-").concat(o),depth:O+1}),"".concat(I,"-").concat(o))})]}))}))});export{m as default};
2
2
  //# sourceMappingURL=SubSectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{useState as o,useRef as n,useEffect as t}from"react";import{debounce as i,DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";var l=function(l){var u=l.proposedSections,c=l.existingSections,d=l.parentDeviationRecord,v=l.expandedSections,f=l.maintainRelativeOrder,a=l.scrollContainerRef,s=l.leftContainerRef,h=l.lhsBadgeRefs,w=l.rhsBadgeRefs,g=o({}),R=g[0],b=g[1],m=n();return t(function(){if(a.current){var o=f?s.current:a.current;if(o){var n=null,t=setTimeout(function(){var t=function(e,o){var n=e.getBoundingClientRect(),t=o.getBoundingClientRect();return n.bottom<t.top?"above":n.top>t.bottom?"below":"inside"};n=i(function(){b(function(o){var n=e({},o);return u.forEach(function(e,o){var i=f?!!v["left-".concat(o)]:!!v[String(o)],l=!1,u=!1,c=null,s=null;i&&(null==e?void 0:e.id)&&(d[e.id]||[]).forEach(function(o){var n="".concat(o.id).concat(r,"0"),i=h.current[n];if((null==i?void 0:i.current)&&a.current){var d=t(i.current,a.current);"above"===d?(l=!0,c=i):"below"!==d||u?m.current===e.id&&(m.current=""):(u=!0,s=i)}}),e.id&&(n[e.id]={showAbove:l,showBelow:u,showAboveRef:c,showBelowRef:s,columnKey:"left"})}),f||c.forEach(function(e,o){var i=!!v[String(o)],l=!1,u=!1,c=null,f=null;i&&(null==e?void 0:e.id)&&(d[e.id]||[]).forEach(function(o){var i,d,v,s,h,g=!(null===(i=o.refIndexes)||void 0===i?void 0:i.length)||void 0!==o.selfIndex&&o.selfIndex<0,R="".concat(o.id).concat(r,"0"),b=w.current[R];if((null==b?void 0:b.current)&&a.current&&g&&(null==e?void 0:e.id)){var p=t(b.current,a.current);if("above"===p){var B=null===(v=null===(d=n[e.id])||void 0===d?void 0:d.showAboveRef)||void 0===v?void 0:v.current;(!B||B.getBoundingClientRect().top<b.current.getBoundingClientRect().top)&&(l=!0,c=b)}else if("below"!==p||u)m.current===e.id&&(m.current="");else{var C=null===(h=null===(s=n[e.id])||void 0===s?void 0:s.showBelowRef)||void 0===h?void 0:h.current;(!C||C.getBoundingClientRect().top>b.current.getBoundingClientRect().top)&&(u=!0,f=b)}}}),e.id&&i&&(l&&(n[e.id]=n[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,columnKey:"right"},n[e.id].showAbove=l,n[e.id].showAboveRef=c,n[e.id].columnKey="right"),u&&(n[e.id]=n[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,columnKey:"right"},n[e.id].showBelow=u,n[e.id].showBelowRef=f,n[e.id].columnKey="right"))}),n})},100),n(),null==o||o.addEventListener("scroll",n)},0);return function(){clearTimeout(t),n&&o.removeEventListener("scroll",n)}}}},[u,c,d,v,f,a,s,h,w]),{showDeviationNavigation:R,showOpenNodeRef:m}};export{l as useDeviationNavigation};
1
+ import{__assign as e}from"tslib";import{useState as o,useRef as i,useEffect as n}from"react";import{debounce as t,DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";var l=function(l){var u=l.proposedSections,d=l.existingSections,c=l.parentDeviationRecord,v=l.expandedSections,f=l.maintainRelativeOrder,s=l.scrollContainerRef,a=l.leftContainerRef,h=l.lhsBadgeRefs,w=l.rhsBadgeRefs,R=o({}),g=R[0],b=R[1],m=i();return n(function(){if(s.current){var o=f?a.current:s.current;if(o){var i=null,n=setTimeout(function(){var n=function(e,o){var i=e.getBoundingClientRect(),n=o.getBoundingClientRect();return i.bottom<n.top?"above":i.top>n.bottom?"below":"inside"};i=t(function(){b(function(i){var t=e({},i);return u.forEach(function(e,i){var l=f?!!v["left-".concat(i)]:!!v[String(i)],u=!1,d=!1,s=null,a=null,w=null,R=null;l&&(null==e?void 0:e.id)&&(c[e.id]||[]).forEach(function(i){var t="".concat(i.id).concat(r,"0"),l=h.current[t];if(null==l?void 0:l.current){var c=n(l.current,o);w||(w=l,R=c),"above"===c?(u=!0,s=l):"below"!==c||d?m.current===e.id&&(m.current=""):(d=!0,a=l)}}),e.id&&(t[e.id]={showAbove:u,showBelow:d,showAboveRef:s,showBelowRef:a,firstDeviationRef:w,firstDeviationPosition:R,columnKey:"left"})}),f||d.forEach(function(e,i){var l=!!v[String(i)],u=!1,d=!1,f=null,s=null,a=null,h=null;l&&(null==e?void 0:e.id)&&(c[e.id]||[]).forEach(function(i){var l,c,v,R,g,b=!(null===(l=i.refIndexes)||void 0===l?void 0:l.length)||void 0!==i.selfIndex&&i.selfIndex<0,p="".concat(i.id).concat(r,"0"),B=w.current[p];if((null==B?void 0:B.current)&&b&&(null==e?void 0:e.id)){var D=n(B.current,o);if(a||(a=B,h=D),"above"===D){var C=null===(v=null===(c=t[e.id])||void 0===c?void 0:c.showAboveRef)||void 0===v?void 0:v.current;(!C||C.getBoundingClientRect().top<B.current.getBoundingClientRect().top)&&(u=!0,f=B)}else if("below"!==D||d)m.current===e.id&&(m.current="");else{var A=null===(g=null===(R=t[e.id])||void 0===R?void 0:R.showBelowRef)||void 0===g?void 0:g.current;(!A||A.getBoundingClientRect().top>B.current.getBoundingClientRect().top)&&(d=!0,s=B)}}}),e.id&&l&&(u&&(t[e.id]=t[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,firstDeviationRef:null,firstDeviationPosition:null,columnKey:"right"},t[e.id].showAbove=u,t[e.id].showAboveRef=f,t[e.id].firstDeviationRef=a,t[e.id].firstDeviationPosition=h,t[e.id].columnKey="right"),d&&(t[e.id]=t[e.id]||{showAbove:!1,showAboveRef:null,showBelow:!1,showBelowRef:null,firstDeviationRef:null,firstDeviationPosition:null,columnKey:"right"},t[e.id].showBelow=d,t[e.id].showBelowRef=s,t[e.id].firstDeviationRef=a,t[e.id].firstDeviationPosition=h,t[e.id].columnKey="right"))}),t})},100),i(),null==o||o.addEventListener("scroll",i)},0);return function(){clearTimeout(n),i&&o.removeEventListener("scroll",i)}}}},[u,d,c,v,f,s,a,h,w]),{showDeviationNavigation:g,showOpenNodeRef:m}};export{l as useDeviationNavigation};
2
2
  //# sourceMappingURL=useDeviationNavigation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAyC,CAAA;AAEnF,eAAO,MAAM,iBAAiB,EAAE,GA8hV/B,CAAA"}
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,GAkwQ/B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAiBlC,QAAA,MAAM,gBAAgB,sLAWnB,qBAAqB,4CAk9FvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAiBlC,QAAA,MAAM,gBAAgB,sLAWnB,qBAAqB,4CA29FvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveComparehelpers.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveComparehelpers.ts"],"names":[],"mappings":"AAMA,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,YAyBnE,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"}
1
+ {"version":3,"file":"CognitiveComparehelpers.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveComparehelpers.ts"],"names":[],"mappings":"AAMA,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"SectionAccordion.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/components/SectionAccordion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAoBzC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAe3E,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,YAAY,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACxC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC5C,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5D,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5C,qBAAqB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3C,qBAAqB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,gBAAgB,EAAE,CAChB,CAAC,EAAE,KAAK,CAAC,UAAU,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,kBAAkB,GAAG,IAAI,KAC/B,IAAI,CAAC;IACV,iBAAiB,EAAE,CAAC,IAAI,EAAE;QACxB,OAAO,EAAE,YAAY,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAC5B,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KACjC,KAAK,KAAK,CAAC,SAAS,CAAC;IAGtB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACtG,sBAAsB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;IAC9C,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACzC,sBAAsB,CAAC,EAAE,CACvB,CAAC,EAAE,KAAK,CAAC,UAAU,EACnB,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,GAAG,EACX,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,GAAG,KACP,IAAI,CAAC;CACX,CAAC;AAEF,QAAA,MAAM,gBAAgB,yYAyBnB,qBAAqB,4CA4ZvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"SectionAccordion.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/components/SectionAccordion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAoBzC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AA0C3E,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,YAAY,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACxC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC5C,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5D,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5C,qBAAqB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3C,qBAAqB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,gBAAgB,EAAE,CAChB,CAAC,EAAE,KAAK,CAAC,UAAU,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,kBAAkB,GAAG,IAAI,KAC/B,IAAI,CAAC;IACV,iBAAiB,EAAE,CAAC,IAAI,EAAE;QACxB,OAAO,EAAE,YAAY,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAC5B,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KACjC,KAAK,KAAK,CAAC,SAAS,CAAC;IAGtB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACtG,sBAAsB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;IAC9C,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACzC,sBAAsB,CAAC,EAAE,CACvB,CAAC,EAAE,KAAK,CAAC,UAAU,EACnB,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,GAAG,EACX,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,GAAG,KACP,IAAI,CAAC;CACX,CAAC;AAEF,QAAA,MAAM,gBAAgB,yYAyBnB,qBAAqB,4CA4avB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SubSectionAccordion.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/components/SubSectionAccordion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAqBvC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE1F,UAAU,wBAAwB;IAChC,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,sBAAsB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACtF,qBAAqB,EAAE,OAAO,CAAC;IAC/B,gBAAgB,EAAE,GAAG,EAAE,CAAC;IACxB,gBAAgB,EAAE,GAAG,EAAE,CAAC;IACxB,QAAQ,EAAE,GAAG,CAAC;IACd,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,iBAAiB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACxC,uBAAuB,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAChD,sBAAsB,EAAE,GAAG,CAAC;IAC5B,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC5F,yBAAyB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,YAAY,GAAG,IAAI,CAAC;IACjE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,EAAE,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACrF,sBAAsB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7I,gBAAgB,EAAE,CAChB,CAAC,EAAE,KAAK,CAAC,UAAU,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,kBAAkB,GAAG,IAAI,KAC/B,IAAI,CAAC;IACV,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,oBAAoB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACjF,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC/D,wBAAwB,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC;CACzD;AAED,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAkS1D,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"SubSectionAccordion.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/components/SubSectionAccordion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAqBvC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE1F,UAAU,wBAAwB;IAChC,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,sBAAsB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACtF,qBAAqB,EAAE,OAAO,CAAC;IAC/B,gBAAgB,EAAE,GAAG,EAAE,CAAC;IACxB,gBAAgB,EAAE,GAAG,EAAE,CAAC;IACxB,QAAQ,EAAE,GAAG,CAAC;IACd,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,iBAAiB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACxC,uBAAuB,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAChD,sBAAsB,EAAE,GAAG,CAAC;IAC5B,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC5F,yBAAyB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,YAAY,GAAG,IAAI,CAAC;IACjE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,EAAE,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACrF,sBAAsB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7I,gBAAgB,EAAE,CAChB,CAAC,EAAE,KAAK,CAAC,UAAU,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,kBAAkB,GAAG,IAAI,KAC/B,IAAI,CAAC;IACV,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,oBAAoB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACjF,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC/D,wBAAwB,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC;CACzD;AAED,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAyV1D,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
@@ -5,6 +5,8 @@ export type DeviationNavigationEntry = {
5
5
  showAboveRef: React.RefObject<HTMLDivElement> | null;
6
6
  showBelow: boolean;
7
7
  showBelowRef: React.RefObject<HTMLDivElement> | null;
8
+ firstDeviationRef: React.RefObject<HTMLDivElement> | null;
9
+ firstDeviationPosition: "above" | "below" | "inside" | null;
8
10
  columnKey: "left" | "right";
9
11
  };
10
12
  type UseDeviationNavigationParams = {
@@ -1 +1 @@
1
- {"version":3,"file":"useDeviationNavigation.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/useDeviationNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACrD,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACrD,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IACtD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACpD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAC/F,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CAChG,CAAC;AAEF,eAAO,MAAM,sBAAsB,8KAUhC,4BAA4B;;;CAsL9B,CAAC"}
1
+ {"version":3,"file":"useDeviationNavigation.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/useDeviationNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACrD,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACrD,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IAC1D,sBAAsB,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAC;IAC5D,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IACtD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACpD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAC/F,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CAChG,CAAC;AAEF,eAAO,MAAM,sBAAsB,8KAUhC,4BAA4B;;;CA2M9B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viswa-test/test-citation",
3
- "version": "0.0.72",
3
+ "version": "0.0.73",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",