@viswa-test/test-citation 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),r=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("react-markdown"),a=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),u=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=v(t),h=v(s),p=x.default.memo(function(t){var r=t.content,o=t.sxStyles;return n.jsx(i.Typography,e.__assign({component:"div",sx:o},{children:n.jsx(h.default,{children:a.safeStringify(r).replace(/\\n/g,"\n")})}))}),g=function(e,n,t,i,r){void 0===r&&(r=14);var o=(e+t)/2,l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var s=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-a),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+s*a),"V ".concat(i-s*a),"Q ".concat(o," ").concat(i," ").concat(o+a," ").concat(i),"H ".concat(t)].join(" ")},m={id:"",title:""},_={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},y=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,s=n-l,a=null,c=function(u){null===a&&(a=u);var d,f=u-a;f<t?(e.scrollTop=(d=f,d/=t,s*(--d*d*d+1)+l),r&&r(),requestAnimationFrame(c)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(c)};exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(s){var v,b,S,I,F,R,w,C,j=s.componentHeaderText,E=void 0===j?"Contract Comparison":j,B=s.treeData,T=s.comparisonConfig,A=s.leftColumnTitleText,D=s.rightColumnTitleText,M=s.markdownStyles,k=s.maintainRelativeOrder,O=void 0!==k&&k,H=s.popupConfig,L=s.deviationData,N=void 0===L?{}:L,z=t.useState(O),W=z[0],q=z[1],P=t.useState(!1),Y=P[0],V=P[1],U=t.useState(!1),G=U[0],X=U[1],K=t.useState(null),J=K[0],Q=K[1],Z=t.useState(!1),$=Z[0],ee=Z[1],ne=t.useState(!1),te=ne[0],ie=ne[1],re=t.useRef(!1),oe=t.useState(new Set),le=oe[0],se=oe[1],ae=t.useState([]),ce=ae[0],ue=ae[1],de=t.useRef(null),fe=t.useRef(!1),ve=t.useRef(null),xe=t.useRef({}),he=t.useRef([]),pe=t.useRef(!1),ge=t.useRef(!1),me=t.useRef(null),_e=t.useMemo(function(){return(null==B?void 0:B.cognitive_decisioning)||{}},[B]),ye=t.useState(null),be=ye[0],Se=ye[1],Ie=t.useRef(null),Fe=t.useState({width:0,height:0}),Re=Fe[0],we=Fe[1],Ce=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),M)},[M]),je=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ee=je[0],Be=je[1],Te=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Ae=Te[0],De=Te[1],Me=t.useRef(null),ke=t.useRef(null),Oe=t.useRef(null),He=t.useRef(null),Le=t.useRef(null),Ne=t.useRef(null),ze=t.useRef(!1),We=t.useRef(null);t.useEffect(function(){We.current=null},[Ee.sectionIdx,Ee.open]);var qe=t.useCallback(function(){Se(null),Be(_)},[]),Pe=t.useCallback(function(){De(_)},[]),Ye=t.useCallback(function(){var e;if(Ee.anchorEl&&Ee.refSectionTitle){var n=Ee.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ie?void 0:Ie.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==We.current?!0===We.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),We.current=l;var s=l?o:r,a=Math.min(t||9999,s),c=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,d=u-i/2,f=Math.max(12,Math.min(d,window.innerWidth-i-12)),v=Math.max(14,Math.min(u-f,i-10-4));Se({top:c,left:f,arrowLeft:v,openAbove:l,maxHeight:s})}},[Ee.anchorEl,Ee.refSectionTitle]);t.useEffect(function(){if(Ee.open){window.addEventListener("resize",Ye);var e=requestAnimationFrame(Ye),n=null;return Ie.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(Ye)})).observe(Ie.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",Ye),n&&n.disconnect()}}},[Ee.open,Ye]),t.useEffect(function(){var e=Me.current;if(e&&Ee.open){var n=function(e){Ie.current&&Ie.current.contains(e.target)||(Se(null),qe())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[Ee.open,qe]),t.useEffect(function(){var e=Me.current;if(e&&Ae.open){var n=function(){Pe()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[Ae.open,Pe]);var Ve=t.useMemo(function(){var n,t,i,r,o,l,s,a,u,d,f,v;return{fields:null!==(n=null==T?void 0:T.fields)&&void 0!==n?n:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==T?void 0:T.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==T?void 0:T.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==T?void 0:T.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(a=null==T?void 0:T.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==T?void 0:T.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==T?void 0:T.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(f=null==T?void 0:T.relationStyles)||void 0===f?void 0:f.medium)||{}),low:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(v=null==T?void 0:T.relationStyles)||void 0===v?void 0:v.low)||{})}}},[T]),Ue=t.useMemo(function(){if(B&&Object.keys(B).length>0)try{var n=function(n,t,i){var r,o,l,s,c,u,d,f,v;void 0===t&&(t=!1),void 0===i&&(i=null);var x=[],h=[],p=n.base_root_id,g=n.input_index_map||{0:"left",1:"right"},m=n[p];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var _=function(t,r){var o,l=n[t];if(!l||!1===l.display_node)return null;var s=a.getSideData(l,r,g),c=!!s.title.trim(),u=!!s.content.trim(),d=a.getRationale(l),f=(null===(o=null==i?void 0:i[t])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,v=[];l.next&&Object.values(l.next).forEach(function(e){var t=n[e];if(t&&!1!==t.display_node){var i=_(e,r);i&&v.push(i)}});var x=!(!c&&!u);return e.__assign(e.__assign({id:t,title:c?s.title:"",content:u?s.content:"",subsections:v},x?d:{score:void 0,relation:"not_defined"}),{evaluationResult:f})};if(t){var y={},b={},S=-1,I=-1;for(var F in n)if(!["base_root_id","documents","input_index_map",p].includes(F)){var R=n[F];if(R&&!1!==R.display_node){var w=a.getRationale(R),C=a.getSideData(R,"0",g),j=a.getSideData(R,"1",g),E=C.title.trim()||C.content.trim(),B=j.title.trim()||j.content.trim(),T=(null===(r=null==i?void 0:i[F])||void 0===r?void 0:r.evaluation_result)||R.evaluation_result||null,A=Number(null!==(l=null===(o=C.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:S--),D=Number(null!==(c=null===(s=j.attributes)||void 0===s?void 0:s.display_index)&&void 0!==c?c:I--),M=b[D]||e.__assign(e.__assign({id:F,title:B?j.title:"",content:B?j.content:"",subsections:[]},B?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:D,evaluationResult:T}),k=y[A]||e.__assign(e.__assign({id:F,title:E?C.title:"",content:E?C.content:"",subsections:[]},E?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:A,evaluationResult:T});Number(D)>=0&&Number(A)>=0&&(M.refIndexes.includes(Number(A))||M.refIndexes.push(Number(A)),k.refIndexes.includes(Number(D))||k.refIndexes.push(Number(D))),b[D]=M,y[A]=k}}h=Object.values(b).map(function(e){return e}),x=Object.values(y).map(function(e){return e}),h.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),x.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex})}else m.next&&Object.values(m.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(x.push(_(e,"0")||{id:e,title:"",content:"",subsections:[]}),h.push(_(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(d=null===(u=m.comparison_inputs)||void 0===u?void 0:u[g[0]])||void 0===d?void 0:d.title)||"Uploaded Contract",description:m.decision_scope_description||"",sections:x},activeVariants:[{id:"tree-variant-1",title:(null===(v=null===(f=m.comparison_inputs)||void 0===f?void 0:f[g[1]])||void 0===v?void 0:v.title)||"Reference Template",similarity:0,sections:h,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}}]}}(B,W,N);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(B),W,JSON.stringify(N)]),Ge=Ue.activeProposed,Xe=Ue.activeVariants,Ke=Ue.parseError;t.useEffect(function(){Ke&&Q("Failed to load comparison: ".concat(Ke))},[Ke]);var Je=t.useState(null),Qe=Je[0];Je[1];var Ze=t.useState({}),$e=Ze[0],en=Ze[1],nn=t.useState({}),tn=nn[0],rn=nn[1],on=(null==Xe?void 0:Xe[0])||m,ln=null===(S=null===(v=null==B?void 0:B.documents)||void 0===v?void 0:v[null===(b=null==B?void 0:B.input_index_map)||void 0===b?void 0:b[0]])||void 0===S?void 0:S.title,sn=null===(R=null===(I=null==B?void 0:B.documents)||void 0===I?void 0:I[null===(F=null==B?void 0:B.input_index_map)||void 0===F?void 0:F[1]])||void 0===R?void 0:R.title,an=a.safeStringify(A||ln||"Uploaded Contract"),cn=a.safeStringify(D||sn||"Reference Template"),un=t.useMemo(function(){return(null==Ge?void 0:Ge.sections)||[]},[null==Ge?void 0:Ge.sections]),dn=t.useMemo(function(){return on.sections||[]},[on.sections]),fn=un.length>0||dn.length>0,vn=on.analysis,xn=a.safeStringify(null===(C=null===(w=null==vn?void 0:vn.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===C?void 0:C.overall_summary),hn=!!xn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),pn=t.useRef({}),gn=function(e){return pn.current[e]||(pn.current[e]=x.default.createRef()),pn.current[e]},mn=t.useCallback(function(){ee(!1),ge.current=!1,Dn(null),me.current=null,Fn.current=null,ie(!1),X(!1),He.current&&(He.current.style.height="0px"),Le.current&&(Le.current.style.height="0px")},[]),_n=t.useCallback(function(e,n,t,i,r){var o,l,s=a.safeStringify(n.id)||a.safeStringify(t.id)||"",c=(s?_e[s]:null)||n.cognitiveData||t.cognitiveData||{section_id:s,decisioning:[],gap:[],relevance_score:0},u=null!==(l=null===(o=pn.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:c,anchorEl:e,sectionAnchorEl:u,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==B?void 0:B.documents,input_index_map:null==B?void 0:B.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null}},[_e,B]),yn=t.useCallback(function(e){Pe(),Se(null),Be(e)},[Pe]),bn=t.useCallback(function(){null!==Ae.sectionIdx&&Ae.anchorEl?yn(e.__assign(e.__assign({},Ae),{open:!0})):Pe()},[Ae,Pe,yn]);t.useCallback(function(e){Pe(),Q("".concat(e," is coming soon."))},[Pe]);var Sn=t.useCallback(function(){var e=Ae.sectionIdx;Pe(),null!==e&&(ge.current&&mn(),se(function(n){return n.has(e)?new Set:new Set([e])}))},[Ae.sectionIdx,Pe,mn]),In=t.useRef(null),Fn=t.useRef(null),Rn=t.useRef(null),wn=t.useRef(null),Cn=t.useRef(null),jn=t.useState([]),En=jn[0],Bn=jn[1],Tn=t.useState(null),An=Tn[0],Dn=Tn[1];t.useRef(null);var Mn=t.useState(null),kn=Mn[0],On=Mn[1],Hn=t.useMemo(function(){return Ve.fields.filter(function(e){var n=e.key;return(!fn||"description"!==n)&&(a.hasValue(null==Ge?void 0:Ge[n])||a.hasValue(on[n]))})},[Ge,on,fn,Ve.fields]),Ln=t.useRef({}),Nn=t.useRef({}),zn=t.useRef({}),Wn=t.useRef({}),qn=t.useRef({}),Pn=t.useRef({}),Yn=t.useRef({});Hn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(un.length,dn.length);t+=1)zn.current[t]||(zn.current[t]=x.default.createRef()),Wn.current[t]||(Wn.current[t]=x.default.createRef()),qn.current[t]||(qn.current[t]=x.default.createRef()),Pn.current[t]||(Pn.current[t]=x.default.createRef()),Yn.current[t]||(Yn.current[t]=x.default.createRef());Ln.current[n]||(Ln.current[n]=x.default.createRef()),Nn.current[n]||(Nn.current[n]=x.default.createRef())});for(var Vn=0;Vn<Math.max(un.length,dn.length);Vn+=1)zn.current[Vn]||(zn.current[Vn]=x.default.createRef()),Wn.current[Vn]||(Wn.current[Vn]=x.default.createRef()),qn.current[Vn]||(qn.current[Vn]=x.default.createRef()),Pn.current[Vn]||(Pn.current[Vn]=x.default.createRef()),Yn.current[Vn]||(Yn.current[Vn]=x.default.createRef());t.useEffect(function(){if(Qe){var e=Ve.fields.find(function(e){return e.analysisKey===Qe||e.key===Qe});if(e){var n=Ln.current[e.key]||Nn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Qe,Ve.fields]);var Un=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==vn?void 0:vn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],f=(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===(o=null===(r=null==d?void 0:d.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=v.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}},[vn]),Gn=t.useCallback(function(n){var t,i,r,o,l=un[n],s=dn[n],c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,d=a.safeStringify(null==l?void 0:l.id)||a.safeStringify(null==s?void 0:s.id)||"",f=!(!(null==l?void 0:l.cognitiveData)&&!(null==s?void 0:s.cognitiveData));if(!c&&!u&&!f)return e.__assign(e.__assign({},Ve.relationStyles.noContent),{label:"Not Defined"});var v=Un("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=_e[d])||void 0===r?void 0:r.relevance_score:void 0)){var x=a.cognitiveScoreToRelation(),h=x.score,p=x.relation;return a.getStyleForRelation(h,p,!0,Ve)}var g=c?l.relation:u?s.relation:v.relation,m=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==s?void 0:s.score,_="number"==typeof m?m:v.score;return a.getStyleForRelation(_,g,!0,Ve)},[un,dn,_e,Ve,Un]),Xn=t.useCallback(function(){var e,n,t,i,r,o,l,s,c,u,d;if(!ze.current&&!fe.current){ze.current=!0;try{if(!In.current)return;var f=In.current.getBoundingClientRect();we({width:f.width,height:f.height});var v=[];if(Hn.forEach(function(e){var n,t,i=e.key,r=null===(n=Ln.current[i])||void 0===n?void 0:n.current,o=null===(t=Nn.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!W&&!fe.current)for(var x=0;x<Math.min(un.length,dn.length);x++){var h=null===(e=zn.current[x])||void 0===e?void 0:e.current,p=null===(n=Wn.current[x])||void 0===n?void 0:n.current;h&&p&&(h.style.height="auto",p.style.height="auto",h.style.minHeight="0px",p.style.minHeight="0px")}var m={};Hn.forEach(function(e){var n,t,i=e.key,r=null===(n=Ln.current[i])||void 0===n?void 0:n.current,o=null===(t=Nn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),s=o.getBoundingClientRect();m[i]=Math.max(l.height,s.height)}});var _=[];if(!W&&!fe.current)for(x=0;x<Math.min(un.length,dn.length);x++){h=null===(t=zn.current[x])||void 0===t?void 0:t.current,p=null===(i=Wn.current[x])||void 0===i?void 0:i.current;var y=!!$e[String(x)];if(h&&p&&y){var b=h.getBoundingClientRect(),S=p.getBoundingClientRect();_[x]=Math.max(b.height,S.height)}}if(Hn.forEach(function(e){var n,t,i=e.key,r=null===(n=Ln.current[i])||void 0===n?void 0:n.current,o=null===(t=Nn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=m[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!W&&!fe.current)for(x=0;x<_.length;x++){h=null===(r=zn.current[x])||void 0===r?void 0:r.current,p=null===(o=Wn.current[x])||void 0===o?void 0:o.current;if(h&&p&&_[x]){var I=_[x];h.style.minHeight="".concat(I,"px"),p.style.minHeight="".concat(I,"px")}}if(Hn.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=Ln.current[i])||void 0===n?void 0:n.current,l=null===(t=Nn.current[i])||void 0===t?void 0:t.current;if(o&&l){var s=o.getBoundingClientRect(),c=l.getBoundingClientRect(),u=Un(r),d=a.getStyleForRelation(u.score,u.relation,u.hasContent,Ve);if(!d)return;var x=s.top+s.height/2-f.top;v.push({id:"field-".concat(i),x1:s.right-f.left,y1:x,x2:c.left-f.left,y2:x,style:d})}}),W)un.forEach(function(e,n){var t;(null===(t=zn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,s,a,c,u,d,x=dn.findIndex(function(n){return n.selfIndex===e});if(-1!==x){var h=null===(t=qn.current[n])||void 0===t?void 0:t.current,p=null===(i=Pn.current[x])||void 0===i?void 0:i.current;if(h&&p){var g=h.getBoundingClientRect(),m=p.getBoundingClientRect(),_=g.right-f.left,y=m.left-f.left,b=g.top+g.height/2-f.top,S=m.top+m.height/2-f.top;if($&&An===n){var I=null!==(o=null===(r=Ne.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,F=null!==(s=null===(l=Oe.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==s?s:0,R=I+(null!==(c=null===(a=Ne.current)||void 0===a?void 0:a.clientHeight)&&void 0!==c?c:1/0),w=F+(null!==(d=null===(u=Oe.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),C=g.top+g.height/2,j=function(e,n,t){return Math.max(n,Math.min(t,e))};b=j(C,I,R)-f.top,S=j(C,F,w)-f.top}var E=Gn(n);E&&v.push({id:"line-".concat(n,"-").concat(x),x1:_,y1:b,x2:y,y2:S,style:E,sectionIdx:n,targetRightIdx:x})}}})});else for(x=0;x<Math.min(un.length,dn.length);x++){var F=null===(l=zn.current[x])||void 0===l?void 0:l.current,R=null===(s=Wn.current[x])||void 0===s?void 0:s.current;if(F&&R){var w=F.getBoundingClientRect(),C=R.getBoundingClientRect(),j=(w.top+18-f.top+C.top+18-f.top)/2,E=(null===(c=dn[x])||void 0===c?void 0:c.id)||"sec-".concat(x),B=Gn(x);B&&v.push({id:E,x1:w.right-f.left,y1:j,x2:C.left-f.left,y2:j,style:B,sectionIdx:x,hasCognitive:!!((null===(u=un[x])||void 0===u?void 0:u.cognitiveData)||(null===(d=dn[x])||void 0===d?void 0:d.cognitiveData)||E&&_e[E])})}}if(Bn(v),wn.current&&Cn.current){var T=wn.current.getBoundingClientRect(),A=Cn.current.getBoundingClientRect(),D=(T.top+T.height/2-f.top+A.top+A.height/2-f.top)/2;On({x1:T.right-f.left,x2:A.left-f.left,y:D})}else On(null);if(W&&le.size>0){var M=[],k=Ne.current,O=Oe.current;if(k&&O){var H=[],L=k.getBoundingClientRect().top,N=O.getBoundingClientRect().top,z=L+k.clientHeight,q=N+O.clientHeight,P=k.scrollTop,Y=O.scrollTop,V=f.top,U=function(e,n,t){return Math.max(n,Math.min(t,e))};le.forEach(function(e){var n,t=un[e];(null===(n=null==t?void 0:t.refIndexes)||void 0===n?void 0:n.length)&&t.refIndexes.forEach(function(n){var t,i,r=dn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=qn.current[e])||void 0===t?void 0:t.current,l=null===(i=Pn.current[r])||void 0===i?void 0:i.current;if(o&&l){var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=Gn(e),u=s.right-f.left,d=a.left-f.left,v=(u+d)/2,x=s.top+s.height/2,h=a.top+a.height/2,p=x-L+P,m=h-N+Y,_="conn-".concat(e,"-").concat(r);H.push({lhsScrollY:p,rhsScrollY:m,x1:u,x2:d,containerTop:V,leftIdx:e,rhsArrayIdx:r,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:_});var y=U(x,L,z),b=U(h,N,q),S=y-V,I=b-V,F=x>=L-4&&x<=z+4,R=h>=N-4&&h<=q+4,w="";w=F&&R?g(u,S,d,I):F&&!R?"M ".concat(u,",").concat(S," L ").concat(v,",").concat(S," L ").concat(v,",").concat(I):!F&&R?"M ".concat(v,",").concat(S," L ").concat(v,",").concat(I," L ").concat(d,",").concat(I):"M ".concat(v,",").concat(S," L ").concat(v,",").concat(I),M.push({id:_,pathD:w,style:c,leftIdx:e,rhsArrayIdx:r})}}})}),he.current=H}ue(M)}else ue([]),he.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{ze.current=!1}}},[Hn,un,dn,_e,Ve,Un,Gn,W,$,An,le,$e]),Kn=t.useCallback(function(){var e,n,t,i,r,o,l,s,a,c,u,d,f,v,x=he.current;if(x.length&&!fe.current){var h=null!==(n=null===(e=Ne.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,p=null!==(i=null===(t=Oe.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(o=null===(r=Ne.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,_=null!==(s=null===(l=Oe.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,y=null!==(c=null===(a=Ne.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==c?c:0,b=null!==(d=null===(u=Oe.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,S=y+m,I=b+_,F=null!==(v=null===(f=In.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==v?v:0,R=function(e,n,t){return Math.max(n,Math.min(t,e))};x.forEach(function(e){var n=e.lhsScrollY-h+y,t=e.rhsScrollY-p+b,i=xe.current[e.styleId+"-stroke"],r=xe.current[e.styleId+"-bg"];if(i||r){var o,l=R(n,y,S),s=R(t,b,I),a=l-F,c=s-F,u=n>=y-4&&n<=S+4,d=t>=b-4&&t<=I+4,f=(e.x1+e.x2)/2;o=u&&d?g(e.x1,a,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(c):!u&&d?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),Jn=t.useRef(Xn);t.useEffect(function(){Jn.current=Xn},[Xn]);var Qn=t.useRef(null),Zn=t.useCallback(function(){null!==Qn.current&&clearTimeout(Qn.current),Qn.current=setTimeout(function(){Jn.current(),Qn.current=null},50)},[]),$n=t.useCallback(function(e){var n,t,i,r,o;if(!re.current){if(ge.current){var l=me.current,s=Fn.current,a=Ne.current,c=Oe.current;if(null!==l&&null!==s&&a&&c){var u=null===(n=pn.current[l])||void 0===n?void 0:n.current,d=null===(t=Yn.current[s])||void 0===t?void 0:t.current;if(u&&d){if(e.currentTarget===a){var f=u.offsetTop-a.scrollTop,v=Math.max(0,d.offsetTop-f);Math.abs(c.scrollTop-v)>1&&(c.scrollTop=v)}else if(e.currentTarget===c){var x=d.offsetTop-c.scrollTop,h=Math.max(0,u.offsetTop-x);Math.abs(a.scrollTop-h)>1&&(a.scrollTop=h)}if(Rn.current){var p=null===(i=qn.current[l])||void 0===i?void 0:i.current,g=null!==(o=null===(r=In.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,m=a.getBoundingClientRect().top,_=m+a.clientHeight,y=c.getBoundingClientRect().top,b=y+c.clientHeight,S=function(e,n,t){return Math.max(n,Math.min(t,e))};if(p){var I=p.getBoundingClientRect(),F=I.top+I.height/2,R=S(F,m,_),w=S(F,y,b);Rn.current.setAttribute("y1",(R-g).toString()),Rn.current.setAttribute("y2",(w-g).toString());var C=F>=m-4&&F<=_+4;Rn.current.setAttribute("visibility",C?"visible":"hidden")}}}}}he.current.length>0&&!pe.current&&(pe.current=!0,requestAnimationFrame(function(){Kn(),pe.current=!1}))}},[Kn]);t.useEffect(function(){var e=setTimeout(Zn,250);window.addEventListener("resize",Zn);var n=null,t=null;return Me.current&&(n=new ResizeObserver(Zn)).observe(Me.current),In.current&&(t=new ResizeObserver(Zn)).observe(In.current),function(){clearTimeout(e),window.removeEventListener("resize",Zn),null==n||n.disconnect(),null==t||t.disconnect()}},[Ge,on,vn,Hn,$e,tn,un,dn,Ve,Zn,$,An,te,le]),t.useEffect(function(){ge.current=$},[$]),t.useEffect(function(){me.current=An},[An]);var et=t.useCallback(function(){var e=Ae.sectionIdx;Pe(),null!==e&&($&&An===e?mn():(se(new Set),ue([]),he.current=[],X(!0),re.current=!0,Dn(e),me.current=e,ee(!0),ge.current=!0,ie(!1),He.current&&(He.current.style.height="0px"),Le.current&&(Le.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=pn.current[e])||void 0===n?void 0:n.current,r=un[e],o=(null==r?void 0:r.refIndexes)||[],l=null,s=-1;if(o.length>0){var a=o[0];s=dn.findIndex(function(e){return e.selfIndex===a}),l=null===(t=Yn.current[s])||void 0===t?void 0:t.current}Fn.current=-1!==s?s:null;var c=Ne.current,u=Oe.current;if(!i||!c)return re.current=!1,void X(!1);var d=i.offsetTop-c.scrollTop;if(!l||!u)return ie(!0),Jn.current(),re.current=!1,void X(!1);var f=l.offsetTop-d;f<0&&He.current&&(He.current.style.height="".concat(Math.abs(f),"px"));requestAnimationFrame(function(){var e,n=u.scrollHeight-u.clientHeight;if(f<0)e=0;else{if(f>n){var t=f-n;return Le.current&&(Le.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){y(u,f,200,function(){ie(!0),Jn.current(),re.current=!1,X(!1)})})}e=f}y(u,e,200,function(){ie(!0),Jn.current(),re.current=!1,X(!1)})})})))},[Pe,Ae.sectionIdx,$,An,un,dn,Zn,mn]),nt=null!==Ae.sectionIdx&&le.has(Ae.sectionIdx),tt=function(t,o,l,s,c){void 0===c&&(c=1);var u,d=W?!!$e["".concat(l,"-").concat(o)]:!!$e[String(o)],f=a.hasValue(t.title),v=a.hasValue(t.content),h=!f&&!v,g=t.title;return f||(g=v?"No Title Found":"No Matching Section Found"),n.jsx(i.Box,e.__assign({ref:s,sx:e.__assign(e.__assign({mb:c},W?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!h&&d,onChange:function(){return!h&&function(n,t){var i,r;if(fe.current=!0,ve.current&&clearTimeout(ve.current),de.current&&(de.current.style.opacity="0"),!W){var o=null===(i=zn.current[n])||void 0===i?void 0:i.current,l=null===(r=Wn.current[n])||void 0===r?void 0:r.current;o&&l&&(o.style.minHeight="0px",l.style.minHeight="0px")}ve.current=setTimeout(function(){fe.current=!1,Jn.current(),de.current&&(de.current.style.opacity="1")},350),en(function(i){var r=e.__assign({},i);if(!W){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),s=!i[l];if(r[l]=s,"left"===t)((null==(a=un[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=dn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=dn[n])?void 0:a.selfIndex;un.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c))&&(r["left-".concat(n)]=s)})}return r})}(o,l)},sx:{boxShadow:"none",border:h?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:h?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:h?null:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:h?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n.jsx(i.Tooltip,e.__assign({title:g,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"12px",color:h?"#94A3B8":"#19213D",fontWeight:h?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(u=g,u?a.safeStringify(u).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},t):n.jsx(x.default.Fragment,{children:e},t)}):null)}))}))})),!h&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(p,{content:t.content,sxStyles:Ce}),(t.subsections||[]).map(function(e,n){return it(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},it=function(t,o,l){void 0===l&&(l=0);var s=a.hasValue(t.title),c=a.hasValue(t.content),u=!s&&!c,d=s?t.title:c?"No Title Found":"No Matching Section Found",f=!!tn[o];return t.title?n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!u&&f,onChange:function(){return!u&&rn(function(n){var t;return e.__assign(e.__assign({},n),((t={})[o]=!n[o],t))})},sx:{mt:1,boxShadow:"none",border:u?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:u?null:n.jsx(r.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:600,color:u?"#94A3B8":"#19213D"}},{children:d||"Untitled Subsection"}))})),!u&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1}},{children:[c&&n.jsx(i.Typography,e.__assign({component:"div",sx:Ce},{children:n.jsx(h.default,{children:a.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return it(e,"".concat(o,"-").concat(n),l+1)})]}))]}),o):n.jsx(i.Box,e.__assign({sx:{mt:0===l?1:.75}},{children:!u&&n.jsxs("div",{children:[c&&n.jsx(i.Typography,e.__assign({component:"div",sx:Ce},{children:n.jsx(h.default,{children:a.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return it(e,"".concat(o,"-").concat(n),l+1)})]})}),o)};return n.jsxs(i.Box,e.__assign({ref:ke,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},W?{}:{overflow:"visible"}),{position:"relative"})},{children:[Y&&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(f.default,{})})),W&&n.jsx(d.default,{open:Ae.open,anchorEl:Ae.anchorEl,sectionTitle:Ae.sectionTitle,referenceSectionTitle:Ae.refSectionTitle,onClose:Pe,onOpenCognitiveCompare:bn,onOpenSideBySide:et,onConnect:Sn,isConnected:nt}),Ee.open&&n.jsx(u.default,{open:Ee.open,popupRef:Ie,position:be,popupConfig:H,onClose:function(){Se(null),Be(function(n){return e.__assign(e.__assign({},n),{open:!1})})},markdownStyles:M,sectionTitle:Ee.sectionTitle,referenceSectionTitle:Ee.refSectionTitle,cognitiveData:Ee.cognitiveData,anchorEl:Ee.anchorEl,sectionAnchorEl:Ee.sectionAnchorEl,scrollContainerEl:Me.current,badgeStyle:Ee.badgeStyle,docData:Ee.docData,deviationData:Ee.deviationData}),n.jsx(i.Snackbar,e.__assign({open:!!J,autoHideDuration:8e3,onClose:function(){return Q(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Q(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:J}))})),n.jsxs(i.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:E}))})),n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:W,onChange:function(e){var n=e.target.checked;V(!0),setTimeout(function(){q(n),mn(),se(new Set),ue([]),he.current=[],setTimeout(function(){V(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#1976d2",opacity:1,border:0,"&::before":{content:'"Relative Order"',position:"absolute",left:"7px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Default View"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n.jsx(i.Box,e.__assign({ref:Me,onScroll:$n,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:W?"hidden":"auto",borderTop:xn&&hn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},W?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:In,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:de,style:{position:"absolute",top:0,left:0,width:Re.width||"100%",height:Re.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[kn&&n.jsxs("g",{children:[n.jsx("line",{x1:kn.x1,y1:kn.y,x2:Math.max(kn.x1,(kn.x1+kn.x2)/2-70),y2:kn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(kn.x2,(kn.x1+kn.x2)/2+70),y1:kn.y,x2:kn.x2,y2:kn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),En.map(function(t){var l,s=(t.x1+t.x2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!W)return n.jsxs("g",{children:[n.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-100,y:t.y1-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){if(e.stopPropagation(),Ee.open&&Ee.sectionIdx===t.sectionIdx)qe();else{var n=un[t.sectionIdx]||{title:"",content:""},i=dn[t.sectionIdx]||{title:"",content:""};yn(_n(e.currentTarget,n,i,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:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[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(o.ButtonCognitiveIcon,{})})),n.jsx(r.ChevronDown,{size:11,style:{transform:Ee.open&&Ee.sectionIdx===t.sectionIdx?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id);var a=un[t.sectionIdx];return!(null===(l=null==a?void 0:a.refIndexes)||void 0===l?void 0:l.length)||(null==a?void 0:a.selfIndex)<0?null:$&&An===t.sectionIdx&&te?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:Rn,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):null}),ce.map(function(t){var i,r=t.pathD,o=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),s="".concat(t.id,"-bg"),a="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:l,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:o})}))}))}),n.jsx("path",{ref:function(e){xe.current[s]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){xe.current[a]=e},d:r,fill:"none",stroke:o,strokeWidth:"1.75",markerEnd:"url(#".concat(l,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:wn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:an,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:an}))}))})),n.jsx(i.Box,e.__assign({ref:Ne,onScroll:$n,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:fn&&un.map(function(t,o){var l;if(!W)return n.jsx(i.Box,e.__assign({ref:gn(o)},{children:tt(t,o,"left",zn.current[o])}),"left-row-".concat(o));var s=t,a=Gn(o),c=!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0,u="number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null,d=le.has(o);return n.jsx(i.Box,e.__assign({ref:gn(o),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:zn.current[o],sx:e.__assign({width:"100%"},d&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:tt(t,o,"left",x.default.createRef(),0)})),a&&n.jsxs(i.Box,e.__assign({ref:qn.current[o],onClick:function(e){var n=dn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};!function(e,n,t,i,r){e.stopPropagation(),Ae.open&&Ae.sectionIdx===i?Pe():(qe(),De(_n(e.currentTarget,n,t,i,r)))}(e,t,n,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!==u&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:u})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:c?"No Deviation Found":0==a.deviationLabel||void 0===a.deviationLabel?"Same":"".concat(a.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[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(o.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(r.ChevronDown,{size:11})]}))}))})),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},W?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[G&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Cn,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:cn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:cn}))}))})),n.jsxs(i.Box,e.__assign({ref:Oe,onScroll:$n,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:He,style:{width:"100%",height:"0px",flexShrink:0}}),fn&&dn.map(function(t,r){if(!W)return tt(t,r,"right",Wn.current[r]);var o=t,l=un.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(o.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=un.some(function(e,n){var t;return le.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(o.selfIndex))}),a=un.findIndex(function(e,n){var t;return le.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(o.selfIndex))}),c=-1!==a?Gn(a):null;return n.jsx(i.Box,e.__assign({ref:Yn.current[r],sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Wn.current[r],sx:e.__assign({width:"100%"},s&&c&&{borderRadius:"6px",outline:"2px solid ".concat(c.badgeBorder),outlineOffset:"1px"})},{children:tt(t,r,"right",x.default.createRef(),0)})),!G&&n.jsx(i.Box,e.__assign({ref:Pn.current[r],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:l.length>0?l.join(", "):"-"}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:Le,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"),r=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("react-markdown"),a=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),u=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("rehype-raw");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=h(t),p=h(s),g=h(v),m=x.default.memo(function(r){var o=r.content,l=r.sxStyles,s=r.highlights,c=void 0===s?[]:s,u=t.useMemo(function(){return{mark:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{backgroundColor:"#fccccc"}},{children:i}))}}},[]),d=t.useMemo(function(){var e=o;return c.forEach(function(n){e=e.replace(new RegExp(n,"g"),"<mark>".concat(n,"</mark>"))}),e},[o,c]);return n.jsx(i.Typography,e.__assign({component:"div",sx:l},{children:n.jsx(p.default,e.__assign({components:u,rehypePlugins:[g.default]},{children:a.safeStringify(d).replace(/\\n/g,"\n")}))}))}),_=function(e,n,t,i,r){void 0===r&&(r=14);var o=(e+t)/2,l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var s=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-a),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+s*a),"V ".concat(i-s*a),"Q ".concat(o," ").concat(i," ").concat(o+a," ").concat(i),"H ".concat(t)].join(" ")},y={id:"",title:""},b={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},S=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,s=n-l,a=null,c=function(u){null===a&&(a=u);var d,f=u-a;f<t?(e.scrollTop=(d=f,d/=t,s*(--d*d*d+1)+l),r&&r(),requestAnimationFrame(c)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(c)};exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(s){var v,h,g,R,F,I,w,C,j=s.componentHeaderText,E=void 0===j?"Contract Comparison":j,B=s.treeData,T=s.comparisonConfig,D=s.leftColumnTitleText,A=s.rightColumnTitleText,k=s.markdownStyles,M=s.maintainRelativeOrder,O=void 0!==M&&M,H=s.popupConfig,N=s.deviationData,L=void 0===N?{}:N,z=t.useState(O),W=z[0],P=z[1],q=t.useState(!1),Y=q[0],V=q[1],K=t.useState(!1),U=K[0],G=K[1],X=t.useState(null),J=X[0],Q=X[1],Z=t.useState(!1),$=Z[0],ee=Z[1],ne=t.useState(!1),te=ne[0],ie=ne[1],re=t.useRef(!1),oe=t.useState(null),le=oe[0],se=oe[1],ae=t.useState(new Set),ce=ae[0],ue=ae[1],de=t.useState([]),fe=de[0],ve=de[1],he=t.useRef(null),xe=t.useRef(!1),pe=t.useRef(null),ge=t.useRef({}),me=t.useRef([]),_e=t.useRef(!1),ye=t.useRef(!1),be=t.useRef(null),Se=t.useMemo(function(){return(null==B?void 0:B.cognitive_decisioning)||{}},[B]),Re=t.useState(null),Fe=Re[0],Ie=Re[1],we=t.useRef(null),Ce=t.useState({width:0,height:0}),je=Ce[0],Ee=Ce[1],Be=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),k)},[k]),Te=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),De=Te[0],Ae=Te[1],ke=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Me=ke[0],Oe=ke[1],He=t.useRef(null),Ne=t.useRef(null),Le=t.useRef(null),ze=t.useRef(null),We=t.useRef(null),Pe=t.useRef(null),qe=t.useRef(!1),Ye=t.useRef(null);t.useEffect(function(){Ye.current=null},[De.sectionIdx,De.open]);var Ve=t.useCallback(function(){Ie(null),Ae(b),se(null)},[]),Ke=t.useCallback(function(){Oe(b)},[]),Ue=t.useCallback(function(){var e;if(De.anchorEl&&De.refSectionTitle){var n=De.anchorEl.getBoundingClientRect(),t=(null===(e=null==we?void 0:we.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==Ye.current?!0===Ye.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),Ye.current=l;var s=l?o:r,a=Math.min(t||9999,s),c=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,d=u-i/2,f=Math.max(12,Math.min(d,window.innerWidth-i-12)),v=Math.max(14,Math.min(u-f,i-10-4));Ie({top:c,left:f,arrowLeft:v,openAbove:l,maxHeight:s})}},[De.anchorEl,De.refSectionTitle]);t.useEffect(function(){if(De.open){window.addEventListener("resize",Ue);var e=requestAnimationFrame(Ue),n=null;return we.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(Ue)})).observe(we.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",Ue),n&&n.disconnect()}}},[De.open,Ue]),t.useEffect(function(){var e=He.current;if(e&&De.open){var n=function(e){we.current&&we.current.contains(e.target)||(Ie(null),Ve())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[De.open,Ve]),t.useEffect(function(){var e=He.current;if(e&&Me.open){var n=function(){Ke()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[Me.open,Ke]);var Ge=t.useMemo(function(){var n,t,i,r,o,l,s,a,u,d,f,v;return{fields:null!==(n=null==T?void 0:T.fields)&&void 0!==n?n:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==T?void 0:T.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==T?void 0:T.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==T?void 0:T.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(a=null==T?void 0:T.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==T?void 0:T.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==T?void 0:T.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(f=null==T?void 0:T.relationStyles)||void 0===f?void 0:f.medium)||{}),low:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(v=null==T?void 0:T.relationStyles)||void 0===v?void 0:v.low)||{})}}},[T]),Xe=t.useMemo(function(){if(B&&Object.keys(B).length>0)try{var n=function(n,t,i){var r,o,l,s,c,u,d,f,v;void 0===t&&(t=!1),void 0===i&&(i=null);var h=[],x=[],p=n.base_root_id,g=n.input_index_map||{0:"left",1:"right"},m=n[p];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var _=function(t,r){var o,l=n[t];if(!l||!1===l.display_node)return null;var s=a.getSideData(l,r,g),c=!!s.title.trim(),u=!!s.content.trim(),d=a.getRationale(l),f=(null===(o=null==i?void 0:i[t])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,v=[];l.next&&Object.values(l.next).forEach(function(e){var t=n[e];if(t&&!1!==t.display_node){var i=_(e,r);i&&v.push(i)}});var h=!(!c&&!u);return e.__assign(e.__assign({id:t,title:c?s.title:"",content:u?s.content:"",subsections:v},h?d:{score:void 0,relation:"not_defined"}),{evaluationResult:f})};if(t){var y={},b={},S=-1,R=-1;for(var F in n)if(!["base_root_id","documents","input_index_map",p].includes(F)){var I=n[F];if(I&&!1!==I.display_node){var w=a.getRationale(I),C=a.getSideData(I,"0",g),j=a.getSideData(I,"1",g),E=C.title.trim()||C.content.trim(),B=j.title.trim()||j.content.trim(),T=(null===(r=null==i?void 0:i[F])||void 0===r?void 0:r.evaluation_result)||I.evaluation_result||null,D=Number(null!==(l=null===(o=C.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:S--),A=Number(null!==(c=null===(s=j.attributes)||void 0===s?void 0:s.display_index)&&void 0!==c?c:R--),k=b[A]||e.__assign(e.__assign({id:F,title:B?j.title:"",content:B?j.content:"",subsections:[]},B?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:A,evaluationResult:T}),M=y[D]||e.__assign(e.__assign({id:F,title:E?C.title:"",content:E?C.content:"",subsections:[]},E?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:D,evaluationResult:T});Number(A)>=0&&Number(D)>=0&&(k.refIndexes.includes(Number(D))||k.refIndexes.push(Number(D)),M.refIndexes.includes(Number(A))||M.refIndexes.push(Number(A))),b[A]=k,y[D]=M}}x=Object.values(b).map(function(e){return e}),h=Object.values(y).map(function(e){return e}),x.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),h.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex})}else m.next&&Object.values(m.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(h.push(_(e,"0")||{id:e,title:"",content:"",subsections:[]}),x.push(_(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(d=null===(u=m.comparison_inputs)||void 0===u?void 0:u[g[0]])||void 0===d?void 0:d.title)||"Uploaded Contract",description:m.decision_scope_description||"",sections:h},activeVariants:[{id:"tree-variant-1",title:(null===(v=null===(f=m.comparison_inputs)||void 0===f?void 0:f[g[1]])||void 0===v?void 0:v.title)||"Reference Template",similarity:0,sections:x,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}}]}}(B,W,L);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(B),W,JSON.stringify(L)]),Je=Xe.activeProposed,Qe=Xe.activeVariants,Ze=Xe.parseError;t.useEffect(function(){Ze&&Q("Failed to load comparison: ".concat(Ze))},[Ze]);var $e=t.useState(null),en=$e[0];$e[1];var nn=t.useState({}),tn=nn[0],rn=nn[1],on=t.useState({}),ln=on[0],sn=on[1],an=(null==Qe?void 0:Qe[0])||y,cn=null===(g=null===(v=null==B?void 0:B.documents)||void 0===v?void 0:v[null===(h=null==B?void 0:B.input_index_map)||void 0===h?void 0:h[0]])||void 0===g?void 0:g.title,un=null===(I=null===(R=null==B?void 0:B.documents)||void 0===R?void 0:R[null===(F=null==B?void 0:B.input_index_map)||void 0===F?void 0:F[1]])||void 0===I?void 0:I.title,dn=a.safeStringify(D||cn||"Uploaded Contract"),fn=a.safeStringify(A||un||"Reference Template"),vn=t.useMemo(function(){return(null==Je?void 0:Je.sections)||[]},[null==Je?void 0:Je.sections]),hn=t.useMemo(function(){return an.sections||[]},[an.sections]),xn=vn.length>0||hn.length>0,pn=an.analysis,gn=a.safeStringify(null===(C=null===(w=null==pn?void 0:pn.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===C?void 0:C.overall_summary),mn=!!gn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),_n=t.useRef({}),yn=function(e){return _n.current[e]||(_n.current[e]=x.default.createRef()),_n.current[e]},bn=t.useCallback(function(){ee(!1),ye.current=!1,On(null),be.current=null,Cn.current=null,ie(!1),G(!1),ze.current&&(ze.current.style.height="0px"),We.current&&(We.current.style.height="0px")},[]),Sn=t.useCallback(function(e,n,t,i,r){var o,l,s=a.safeStringify(n.id)||a.safeStringify(t.id)||"",c=(s?Se[s]:null)||n.cognitiveData||t.cognitiveData||{section_id:s,decisioning:[],gap:[],relevance_score:0},u=null!==(l=null===(o=_n.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:c,anchorEl:e,sectionAnchorEl:u,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==B?void 0:B.documents,input_index_map:null==B?void 0:B.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null}},[Se,B]),Rn=t.useCallback(function(e){Ke(),Ie(null),Ae(e)},[Ke]),Fn=t.useCallback(function(){null!==Me.sectionIdx&&Me.anchorEl?Rn(e.__assign(e.__assign({},Me),{open:!0})):Ke()},[Me,Ke,Rn]);t.useCallback(function(e){Ke(),Q("".concat(e," is coming soon."))},[Ke]);var In=t.useCallback(function(){var e=Me.sectionIdx;Ke(),null!==e&&(ye.current&&bn(),ue(function(n){return n.has(e)?new Set:new Set([e])}))},[Me.sectionIdx,Ke,bn]),wn=t.useRef(null),Cn=t.useRef(null),jn=t.useRef(null),En=t.useRef(null),Bn=t.useRef(null),Tn=t.useState([]),Dn=Tn[0],An=Tn[1],kn=t.useState(null),Mn=kn[0],On=kn[1];t.useRef(null);var Hn=t.useState(null),Nn=Hn[0],Ln=Hn[1],zn=t.useMemo(function(){return Ge.fields.filter(function(e){var n=e.key;return(!xn||"description"!==n)&&(a.hasValue(null==Je?void 0:Je[n])||a.hasValue(an[n]))})},[Je,an,xn,Ge.fields]),Wn=t.useRef({}),Pn=t.useRef({}),qn=t.useRef({}),Yn=t.useRef({}),Vn=t.useRef({}),Kn=t.useRef({}),Un=t.useRef({}),Gn=t.useRef({}),Xn=t.useRef({});zn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(vn.length,hn.length);t+=1)qn.current[t]||(qn.current[t]=x.default.createRef()),Yn.current[t]||(Yn.current[t]=x.default.createRef()),Vn.current[t]||(Vn.current[t]=x.default.createRef()),Kn.current[t]||(Kn.current[t]=x.default.createRef()),Un.current[t]||(Un.current[t]=x.default.createRef());Wn.current[n]||(Wn.current[n]=x.default.createRef()),Pn.current[n]||(Pn.current[n]=x.default.createRef())});for(var Jn=0;Jn<Math.max(vn.length,hn.length);Jn+=1)qn.current[Jn]||(qn.current[Jn]=x.default.createRef()),Yn.current[Jn]||(Yn.current[Jn]=x.default.createRef()),Vn.current[Jn]||(Vn.current[Jn]=x.default.createRef()),Kn.current[Jn]||(Kn.current[Jn]=x.default.createRef()),Un.current[Jn]||(Un.current[Jn]=x.default.createRef());t.useEffect(function(){if(en){var e=Ge.fields.find(function(e){return e.analysisKey===en||e.key===en});if(e){var n=Wn.current[e.key]||Pn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[en,Ge.fields]);var Qn=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==pn?void 0:pn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],f=(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===(o=null===(r=null==d?void 0:d.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=v.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}},[pn]),Zn=t.useCallback(function(n){var t,i,r,o,l=vn[n],s=hn[n],c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,d=a.safeStringify(null==l?void 0:l.id)||a.safeStringify(null==s?void 0:s.id)||"",f=!(!(null==l?void 0:l.cognitiveData)&&!(null==s?void 0:s.cognitiveData));if(!c&&!u&&!f)return e.__assign(e.__assign({},Ge.relationStyles.noContent),{label:"Not Defined"});var v=Qn("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=Se[d])||void 0===r?void 0:r.relevance_score:void 0)){var h=a.cognitiveScoreToRelation(),x=h.score,p=h.relation;return a.getStyleForRelation(x,p,!0,Ge)}var g=c?l.relation:u?s.relation:v.relation,m=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==s?void 0:s.score,_="number"==typeof m?m:v.score;return a.getStyleForRelation(_,g,!0,Ge)},[vn,hn,Se,Ge,Qn]),$n=t.useCallback(function(){var e,n,t,i,r,o,l,s,c,u,d;if(!qe.current&&!xe.current){qe.current=!0;try{if(!wn.current)return;var f=function(e){var n=e.split("-"),t=n[0];if(!tn[t])return!1;for(var i=t,r=1;r<n.length-1;r++)if(i+="-".concat(n[r]),!ln[i])return!1;return!0},v=wn.current.getBoundingClientRect();Ee({width:v.width,height:v.height});var h=[];if(zn.forEach(function(e){var n,t,i=e.key,r=null===(n=Wn.current[i])||void 0===n?void 0:n.current,o=null===(t=Pn.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!W&&!xe.current){for(var x=0;x<Math.min(vn.length,hn.length);x++){var p=null===(e=qn.current[x])||void 0===e?void 0:e.current,g=null===(n=Yn.current[x])||void 0===n?void 0:n.current;p&&g&&(p.style.height="auto",g.style.height="auto",p.style.minHeight="0px",g.style.minHeight="0px")}Object.keys(Gn.current).forEach(function(e){var n,t;if(f(e)){var i=null===(n=Gn.current[e])||void 0===n?void 0:n.current,r=null===(t=Xn.current[e])||void 0===t?void 0:t.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var m={};zn.forEach(function(e){var n,t,i=e.key,r=null===(n=Wn.current[i])||void 0===n?void 0:n.current,o=null===(t=Pn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),s=o.getBoundingClientRect();m[i]=Math.max(l.height,s.height)}});var y=[],b={};if(!W&&!xe.current){for(x=0;x<Math.min(vn.length,hn.length);x++){p=null===(t=qn.current[x])||void 0===t?void 0:t.current,g=null===(i=Yn.current[x])||void 0===i?void 0:i.current;var S=!!tn[String(x)];if(p&&g&&S){var R=p.getBoundingClientRect(),F=g.getBoundingClientRect();y[x]=Math.max(R.height,F.height)}}Object.keys(Gn.current).forEach(function(e){var n,t;if(f(e)){var i=null===(n=Gn.current[e])||void 0===n?void 0:n.current,r=null===(t=Xn.current[e])||void 0===t?void 0:t.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect();b[e]=Math.max(o.height,l.height)}}})}if(zn.forEach(function(e){var n,t,i=e.key,r=null===(n=Wn.current[i])||void 0===n?void 0:n.current,o=null===(t=Pn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=m[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!W&&!xe.current){for(x=0;x<y.length;x++){p=null===(r=qn.current[x])||void 0===r?void 0:r.current,g=null===(o=Yn.current[x])||void 0===o?void 0:o.current;if(p&&g&&y[x]){var I=y[x];p.style.minHeight="".concat(I,"px"),g.style.minHeight="".concat(I,"px")}}Object.keys(b).forEach(function(e){var n,t,i=null===(n=Gn.current[e])||void 0===n?void 0:n.current,r=null===(t=Xn.current[e])||void 0===t?void 0:t.current;if(i&&r&&b[e]){var o=b[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})}if(zn.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=Wn.current[i])||void 0===n?void 0:n.current,l=null===(t=Pn.current[i])||void 0===t?void 0:t.current;if(o&&l){var s=o.getBoundingClientRect(),c=l.getBoundingClientRect(),u=Qn(r),d=a.getStyleForRelation(u.score,u.relation,u.hasContent,Ge);if(!d)return;var f=s.top+s.height/2-v.top;h.push({id:"field-".concat(i),x1:s.right-v.left,y1:f,x2:c.left-v.left,y2:f,style:d})}}),W)vn.forEach(function(e,n){var t;(null===(t=qn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,s,a,c,u,d,f=hn.findIndex(function(n){return n.selfIndex===e});if(-1!==f){var x=null===(t=Vn.current[n])||void 0===t?void 0:t.current,p=null===(i=Kn.current[f])||void 0===i?void 0:i.current;if(x&&p){var g=x.getBoundingClientRect(),m=p.getBoundingClientRect(),_=g.right-v.left,y=m.left-v.left,b=g.top+g.height/2-v.top,S=m.top+m.height/2-v.top;if($&&Mn===n){var R=null!==(o=null===(r=Pe.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,F=null!==(s=null===(l=Le.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==s?s:0,I=R+(null!==(c=null===(a=Pe.current)||void 0===a?void 0:a.clientHeight)&&void 0!==c?c:1/0),w=F+(null!==(d=null===(u=Le.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),C=g.top+g.height/2,j=function(e,n,t){return Math.max(n,Math.min(t,e))};b=j(C,R,I)-v.top,S=j(C,F,w)-v.top}var E=Zn(n);E&&h.push({id:"line-".concat(n,"-").concat(f),x1:_,y1:b,x2:y,y2:S,style:E,sectionIdx:n,targetRightIdx:f})}}})});else{for(x=0;x<Math.min(vn.length,hn.length);x++){var w=null===(l=qn.current[x])||void 0===l?void 0:l.current,C=null===(s=Yn.current[x])||void 0===s?void 0:s.current;if(w&&C){var j=w.getBoundingClientRect(),E=C.getBoundingClientRect(),B=(j.top+18-v.top+E.top+18-v.top)/2,T=(null===(c=hn[x])||void 0===c?void 0:c.id)||"sec-".concat(x),D=Zn(x);D&&h.push({id:T,x1:j.right-v.left,y1:B,x2:E.left-v.left,y2:B,style:D,sectionIdx:x,hasCognitive:!!((null===(u=vn[x])||void 0===u?void 0:u.cognitiveData)||(null===(d=hn[x])||void 0===d?void 0:d.cognitiveData)||T&&Se[T])})}}Object.keys(Gn.current).forEach(function(e){var n,t,i,r,o,l;if(f(e)){var s=null===(n=Gn.current[e])||void 0===n?void 0:n.current,c=null===(t=Xn.current[e])||void 0===t?void 0:t.current;if(s&&c&&null!==s.offsetParent&&null!==c.offsetParent){for(var u=s.getBoundingClientRect(),d=c.getBoundingClientRect(),x=(u.top+16-v.top+d.top+16-v.top)/2,p=e.split("-").map(Number),g=vn[p[0]],m=hn[p[0]],_=1;_<p.length;_++)(null==g?void 0:g.subsections)&&(g=g.subsections[p[_]]),(null==m?void 0:m.subsections)&&(m=m.subsections[p[_]]);if(!g&&!m)return;var y=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,b=(null==m?void 0:m.relation)&&"not_defined"!==m.relation,S=a.safeStringify(null==g?void 0:g.id)||a.safeStringify(null==m?void 0:m.id)||"",R=!(!(null==g?void 0:g.cognitiveData)&&!(null==m?void 0:m.cognitiveData)),F=null;if(y||b||R){var I=null!==(r=null!==(i=null==g?void 0:g.cognitiveRelevanceScore)&&void 0!==i?i:null==m?void 0:m.cognitiveRelevanceScore)&&void 0!==r?r:S?null===(o=Se[S])||void 0===o?void 0:o.relevance_score:void 0;if(null!=I){var w=a.cognitiveScoreToRelation(I),C=w.score,j=w.relation;F=a.getStyleForRelation(C,j,!0,Ge)}else{j=y?g.relation:b?m.relation:"not_defined";var E=null!==(l=null==g?void 0:g.score)&&void 0!==l?l:null==m?void 0:m.score;C="number"==typeof E?E:0;F=a.getStyleForRelation(C,j,!0,Ge)}}else F={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE",label:"N/A"};F&&h.push({id:"subsec-".concat(e),x1:u.right-v.left,y1:x,x2:d.left-v.left,y2:x,style:F,sectionIdx:p[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:R||S&&Se[S]})}}})}if(An(h),En.current&&Bn.current){var A=En.current.getBoundingClientRect(),k=Bn.current.getBoundingClientRect(),M=(A.top+A.height/2-v.top+k.top+k.height/2-v.top)/2;Ln({x1:A.right-v.left,x2:k.left-v.left,y:M})}else Ln(null);if(W&&ce.size>0){var O=[],H=Pe.current,N=Le.current;if(H&&N){var L=[],z=H.getBoundingClientRect().top,P=N.getBoundingClientRect().top,q=z+H.clientHeight,Y=P+N.clientHeight,V=H.scrollTop,K=N.scrollTop,U=v.top,G=function(e,n,t){return Math.max(n,Math.min(t,e))};ce.forEach(function(e){var n,t=vn[e];(null===(n=null==t?void 0:t.refIndexes)||void 0===n?void 0:n.length)&&t.refIndexes.forEach(function(n){var t,i,r=hn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=Vn.current[e])||void 0===t?void 0:t.current,l=null===(i=Kn.current[r])||void 0===i?void 0:i.current;if(o&&l){var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=Zn(e),u=s.right-v.left,d=a.left-v.left,f=(u+d)/2,h=s.top+s.height/2,x=a.top+a.height/2,p=h-z+V,g=x-P+K,m="conn-".concat(e,"-").concat(r);L.push({lhsScrollY:p,rhsScrollY:g,x1:u,x2:d,containerTop:U,leftIdx:e,rhsArrayIdx:r,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:m});var y=G(h,z,q),b=G(x,P,Y),S=y-U,R=b-U,F=h>=z-4&&h<=q+4,I=x>=P-4&&x<=Y+4,w="";w=F&&I?_(u,S,d,R):F&&!I?"M ".concat(u,",").concat(S," L ").concat(f,",").concat(S," L ").concat(f,",").concat(R):!F&&I?"M ".concat(f,",").concat(S," L ").concat(f,",").concat(R," L ").concat(d,",").concat(R):"M ".concat(f,",").concat(S," L ").concat(f,",").concat(R),O.push({id:m,pathD:w,style:c,leftIdx:e,rhsArrayIdx:r})}}})}),me.current=L}ve(O)}else ve([]),me.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{qe.current=!1}}},[zn,vn,hn,Se,Ge,Qn,Zn,W,$,Mn,ce,tn,ln]),et=t.useCallback(function(){var e,n,t,i,r,o,l,s,a,c,u,d,f,v,h=me.current;if(h.length&&!xe.current){var x=null!==(n=null===(e=Pe.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,p=null!==(i=null===(t=Le.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,g=null!==(o=null===(r=Pe.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(s=null===(l=Le.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,y=null!==(c=null===(a=Pe.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==c?c:0,b=null!==(d=null===(u=Le.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,S=y+g,R=b+m,F=null!==(v=null===(f=wn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==v?v:0,I=function(e,n,t){return Math.max(n,Math.min(t,e))};h.forEach(function(e){var n=e.lhsScrollY-x+y,t=e.rhsScrollY-p+b,i=ge.current[e.styleId+"-stroke"],r=ge.current[e.styleId+"-bg"];if(i||r){var o,l=I(n,y,S),s=I(t,b,R),a=l-F,c=s-F,u=n>=y-4&&n<=S+4,d=t>=b-4&&t<=R+4,f=(e.x1+e.x2)/2;o=u&&d?_(e.x1,a,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(c):!u&&d?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),nt=t.useRef($n);t.useEffect(function(){nt.current=$n},[$n]);var tt=t.useRef(null),it=t.useCallback(function(){null!==tt.current&&clearTimeout(tt.current),tt.current=setTimeout(function(){nt.current(),tt.current=null},50)},[]),rt=t.useCallback(function(e){var n,t,i,r,o;if(!re.current){if(ye.current){var l=be.current,s=Cn.current,a=Pe.current,c=Le.current;if(null!==l&&null!==s&&a&&c){var u=null===(n=_n.current[l])||void 0===n?void 0:n.current,d=null===(t=Un.current[s])||void 0===t?void 0:t.current;if(u&&d){if(e.currentTarget===a){var f=u.offsetTop-a.scrollTop,v=Math.max(0,d.offsetTop-f);Math.abs(c.scrollTop-v)>1&&(c.scrollTop=v)}else if(e.currentTarget===c){var h=d.offsetTop-c.scrollTop,x=Math.max(0,u.offsetTop-h);Math.abs(a.scrollTop-x)>1&&(a.scrollTop=x)}if(jn.current){var p=null===(i=Vn.current[l])||void 0===i?void 0:i.current,g=null!==(o=null===(r=wn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,m=a.getBoundingClientRect().top,_=m+a.clientHeight,y=c.getBoundingClientRect().top,b=y+c.clientHeight,S=function(e,n,t){return Math.max(n,Math.min(t,e))};if(p){var R=p.getBoundingClientRect(),F=R.top+R.height/2,I=S(F,m,_),w=S(F,y,b);jn.current.setAttribute("y1",(I-g).toString()),jn.current.setAttribute("y2",(w-g).toString());var C=F>=m-4&&F<=_+4;jn.current.setAttribute("visibility",C?"visible":"hidden")}}}}}me.current.length>0&&!_e.current&&(_e.current=!0,requestAnimationFrame(function(){et(),_e.current=!1}))}},[et]);t.useEffect(function(){var e=setTimeout(it,250);window.addEventListener("resize",it);var n=null,t=null;return He.current&&(n=new ResizeObserver(it)).observe(He.current),wn.current&&(t=new ResizeObserver(it)).observe(wn.current),function(){clearTimeout(e),window.removeEventListener("resize",it),null==n||n.disconnect(),null==t||t.disconnect()}},[Je,an,pn,zn,tn,ln,vn,hn,Ge,it,$,Mn,te,ce]),t.useEffect(function(){ye.current=$},[$]),t.useEffect(function(){be.current=Mn},[Mn]);var ot=t.useCallback(function(){var e=Me.sectionIdx;Ke(),null!==e&&($&&Mn===e?bn():(ue(new Set),ve([]),me.current=[],G(!0),re.current=!0,On(e),be.current=e,ee(!0),ye.current=!0,ie(!1),ze.current&&(ze.current.style.height="0px"),We.current&&(We.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=_n.current[e])||void 0===n?void 0:n.current,r=vn[e],o=(null==r?void 0:r.refIndexes)||[],l=null,s=-1;if(o.length>0){var a=o[0];s=hn.findIndex(function(e){return e.selfIndex===a}),l=null===(t=Un.current[s])||void 0===t?void 0:t.current}Cn.current=-1!==s?s:null;var c=Pe.current,u=Le.current;if(!i||!c)return re.current=!1,void G(!1);var d=i.offsetTop-c.scrollTop;if(!l||!u)return ie(!0),nt.current(),re.current=!1,void G(!1);var f=l.offsetTop-d;f<0&&ze.current&&(ze.current.style.height="".concat(Math.abs(f),"px"));requestAnimationFrame(function(){var e,n=u.scrollHeight-u.clientHeight;if(f<0)e=0;else{if(f>n){var t=f-n;return We.current&&(We.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){S(u,f,200,function(){ie(!0),nt.current(),re.current=!1,G(!1)})})}e=f}S(u,e,200,function(){ie(!0),nt.current(),re.current=!1,G(!1)})})})))},[Ke,Me.sectionIdx,$,Mn,vn,hn,it,bn]),lt=null!==Me.sectionIdx&&ce.has(Me.sectionIdx),st=function(t){var o,l=t.section,s=t.idx,c=t.columnKey,u=t.colRef,d=t.mb,f=void 0===d?1:d,v=t.parentNodeId,h=void 0===v?"":v,p=W?!!tn["".concat(c,"-").concat(s)]:!!tn[String(s)],g=a.hasValue(l.title),_=a.hasValue(l.content),y=!g&&!_,b=l.title;return g||(b=_?"No Title Found":"No Matching Section Found"),n.jsx(i.Box,e.__assign({ref:u,sx:e.__assign(e.__assign({mb:f},W?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!y&&p,onChange:function(){return!y&&function(n,t){var i,r;if(xe.current=!0,pe.current&&clearTimeout(pe.current),he.current&&(he.current.style.opacity="0"),!W){var o=null===(i=qn.current[n])||void 0===i?void 0:i.current,l=null===(r=Yn.current[n])||void 0===r?void 0:r.current;o&&l&&(o.style.minHeight="0px",l.style.minHeight="0px")}pe.current=setTimeout(function(){xe.current=!1,nt.current(),he.current&&(he.current.style.opacity="1")},350),rn(function(i){var r=e.__assign({},i);if(!W){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),s=!i[l];if(r[l]=s,"left"===t)((null==(a=vn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=hn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=hn[n])?void 0:a.selfIndex;vn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c))&&(r["left-".concat(n)]=s)})}return r})}(s,c)},sx:{boxShadow:"none",border:y?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:y?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:y?null:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:y?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n.jsx(i.Tooltip,e.__assign({title:b,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"12px",color:y?"#94A3B8":"#19213D",fontWeight:y?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(o=b,o?a.safeStringify(o).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},t):n.jsx(x.default.Fragment,{children:e},t)}):null)}))}))})),!y&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(m,{content:l.content,sxStyles:Be,highlights:function(){var e,n;if(!(null===(e=l.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=l.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][h];o&&i.push(o)}return i}()}),(l.subsections||[]).map(function(e,n){return at(e,"".concat(s,"-").concat(n),0,c)})]}))]}))}),"".concat(c,"-sec-").concat(s))},at=function(t,o,l,s){void 0===l&&(l=0),void 0===s&&(s="left");var c=a.hasValue(t.title),u=a.hasValue(t.content),d=!c&&!u,f=c?t.title:u?"No Title Found":"No Matching Section Found",v=!!ln[o];"left"!==s||Gn.current[o]||(Gn.current[o]=x.default.createRef()),"right"!==s||Xn.current[o]||(Xn.current[o]=x.default.createRef());var h="left"===s?Gn.current[o]:Xn.current[o];return t.title?n.jsx(i.Box,e.__assign({ref:h,sx:{mt:1,width:"100%",position:"relative"}},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!d&&v,onChange:function(){return!d&&sn(function(n){var t;return e.__assign(e.__assign({},n),((t={})[o]=!n[o],t))})},sx:{mt:0,boxShadow:"none",border:d?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:d?null:n.jsx(r.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:600,color:d?"#94A3B8":"#19213D"}},{children:f||"Untitled Subsection"}))})),!d&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1}},{children:[u&&n.jsx(i.Typography,e.__assign({component:"div",sx:Be},{children:n.jsx(p.default,{children:a.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return at(e,"".concat(o,"-").concat(n),l+1,s)})]}))]}))}),o):n.jsx(i.Box,e.__assign({ref:h,sx:{mt:0===l?1:.75,width:"100%"}},{children:!d&&n.jsxs("div",{children:[u&&n.jsx(i.Typography,e.__assign({component:"div",sx:Be},{children:n.jsx(p.default,{children:a.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return at(e,"".concat(o,"-").concat(n),l+1,s)})]})}),o)};return n.jsxs(i.Box,e.__assign({ref:Ne,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},W?{}:{overflow:"visible"}),{position:"relative"})},{children:[Y&&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(f.default,{})})),W&&n.jsx(d.default,{open:Me.open,anchorEl:Me.anchorEl,sectionTitle:Me.sectionTitle,referenceSectionTitle:Me.refSectionTitle,onClose:Ke,onOpenCognitiveCompare:Fn,onOpenSideBySide:ot,onConnect:In,isConnected:lt}),De.open&&n.jsx(u.default,{open:De.open,popupRef:we,position:Fe,popupConfig:H,onClose:function(){Ie(null),Ae(function(n){return e.__assign(e.__assign({},n),{open:!1})}),se(null)},markdownStyles:k,sectionTitle:De.sectionTitle,referenceSectionTitle:De.refSectionTitle,cognitiveData:De.cognitiveData,anchorEl:De.anchorEl,sectionAnchorEl:De.sectionAnchorEl,scrollContainerEl:He.current,badgeStyle:De.badgeStyle,docData:De.docData,deviationData:De.deviationData}),n.jsx(i.Snackbar,e.__assign({open:!!J,autoHideDuration:8e3,onClose:function(){return Q(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Q(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:J}))})),n.jsxs(i.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:E}))})),n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:W,onChange:function(e){var n=e.target.checked;V(!0),setTimeout(function(){P(n),bn(),ue(new Set),ve([]),me.current=[],setTimeout(function(){V(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#1976d2",opacity:1,border:0,"&::before":{content:'"Relative Order"',position:"absolute",left:"7px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Default View"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n.jsx(i.Box,e.__assign({ref:He,onScroll:rt,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:W?"hidden":"auto",borderTop:gn&&mn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},W?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:wn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:he,style:{position:"absolute",top:0,left:0,width:je.width||"100%",height:je.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[Nn&&n.jsxs("g",{children:[n.jsx("line",{x1:Nn.x1,y1:Nn.y,x2:Math.max(Nn.x1,(Nn.x1+Nn.x2)/2-70),y2:Nn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(Nn.x2,(Nn.x1+Nn.x2)/2+70),y1:Nn.y,x2:Nn.x2,y2:Nn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Dn.map(function(t){var l,s=(t.x1+t.x2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!W)return n.jsxs("g",{children:[n.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-100,y:t.y1-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){if(e.stopPropagation(),De.open&&le===t.id)Ve();else{var n=vn[t.sectionIdx]||{title:"",content:""},i=hn[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var r=t.subSectionKeyPath.split("-").map(Number),o=vn[r[0]],l=hn[r[0]],s=1;s<r.length;s++)(null==o?void 0:o.subsections)&&(o=o.subsections[r[s]]),(null==l?void 0:l.subsections)&&(l=l.subsections[r[s]]);o&&(n=o),l&&(i=l)}se(t.id),Rn(Sn(e.currentTarget,n,i,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:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[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(o.ButtonCognitiveIcon,{})})),n.jsx(r.ChevronDown,{size:11,style:{transform:De.open&&le===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id);var a=vn[t.sectionIdx];return!(null===(l=null==a?void 0:a.refIndexes)||void 0===l?void 0:l.length)||(null==a?void 0:a.selfIndex)<0?null:$&&Mn===t.sectionIdx&&te?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:jn,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):null}),fe.map(function(t){var i,r=t.pathD,o=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),s="".concat(t.id,"-bg"),a="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:l,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:o})}))}))}),n.jsx("path",{ref:function(e){ge.current[s]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){ge.current[a]=e},d:r,fill:"none",stroke:o,strokeWidth:"1.75",markerEnd:"url(#".concat(l,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:En,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:dn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:dn}))}))})),n.jsx(i.Box,e.__assign({ref:Pe,onScroll:rt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:xn&&vn.map(function(t,o){var l,s,a;if(!W)return n.jsx(i.Box,e.__assign({ref:yn(o)},{children:st({section:t,idx:o,columnKey:"left",colRef:qn.current[o],parentNodeId:(null===(l=null==B?void 0:B.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(o));var c=t,u=Zn(o),d=!(null===(s=c.refIndexes)||void 0===s?void 0:s.length)||c.selfIndex<0,f="number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null,v=ce.has(o);return n.jsx(i.Box,e.__assign({ref:yn(o),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:qn.current[o],sx:e.__assign({width:"100%"},v&&{borderRadius:"6px",outline:"2px solid ".concat((null==u?void 0:u.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:st({section:t,idx:o,columnKey:"left",colRef:x.default.createRef(),mb:0,parentNodeId:(null===(a=null==B?void 0:B.input_index_map)||void 0===a?void 0:a[0])||""})})),u&&n.jsxs(i.Box,e.__assign({ref:Vn.current[o],onClick:function(e){var n=hn.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};!function(e,n,t,i,r){e.stopPropagation(),Me.open&&Me.sectionIdx===i?Ke():(Ve(),Oe(Sn(e.currentTarget,n,t,i,r)))}(e,t,n,o,u)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:u.badgeBg,color:u.badgeText,border:"1px solid ".concat(u.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(u.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:d?"No Deviation Found":0==u.deviationLabel||void 0===u.deviationLabel?"Same":"".concat(u.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:11,color:u.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[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(o.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(r.ChevronDown,{size:11})]}))}))})),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},W?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[U&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Bn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:fn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:fn}))}))})),n.jsxs(i.Box,e.__assign({ref:Le,onScroll:rt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:ze,style:{width:"100%",height:"0px",flexShrink:0}}),xn&&hn.map(function(t,r){var o,l;if(!W)return st({section:t,idx:r,columnKey:"right",colRef:Yn.current[r],parentNodeId:(null===(o=null==B?void 0:B.input_index_map)||void 0===o?void 0:o[1])||""});var s=t,a=vn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),c=vn.some(function(e,n){var t;return ce.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),u=vn.findIndex(function(e,n){var t;return ce.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),d=-1!==u?Zn(u):null;return n.jsx(i.Box,e.__assign({ref:Un.current[r],sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Yn.current[r],sx:e.__assign({width:"100%"},c&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:st({section:t,idx:r,columnKey:"right",colRef:x.default.createRef(),mb:0,parentNodeId:(null===(l=null==B?void 0:B.input_index_map)||void 0===l?void 0:l[1])||""})})),!U&&n.jsx(i.Box,e.__assign({ref:Kn.current[r],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:We,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as n,jsxs as t}from"react/jsx-runtime";import i,{useState as r,useRef as o,useMemo as l,useEffect as c,useCallback as a}from"react";import{Typography as u,Box as d,Snackbar as s,Alert as f,FormControlLabel as v,Switch as p,Tooltip as h,Accordion as x,AccordionSummary as g,AccordionDetails as m}from"@mui/material";import{ChevronDown as y,EllipsisVertical as b}from"lucide-react";import{ButtonCognitiveIcon as w}from"../../assests/svg/ButtonCognitiveIcon.js";import I from"./OverlayComponent.js";import F from"react-markdown";import{safeStringify as S,hasValue as E,getStyleForRelation as C,getRationale as R,getSideData as T,cognitiveScoreToRelation as B}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as _,DEFAULT_FIELD_CONFIG as D,DEFAULT_COMPARISON_CONFIG as M}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import k from"./CognitivePopup.js";import A from"./MoreFunctionsPopup.js";import H from"./LoaderComponent.js";var z=i.memo(function(t){var i=t.content,r=t.sxStyles;return n(u,e({component:"div",sx:r},{children:n(F,{children:S(i).replace(/\\n/g,"\n")})}))}),W=function(e,n,t,i,r){void 0===r&&(r=14);var o=(e+t)/2,l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var c=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-a),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+c*a),"V ".concat(i-c*a),"Q ".concat(o," ").concat(i," ").concat(o+a," ").concat(i),"H ".concat(t)].join(" ")},L={id:"",title:""},O={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},j=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,c=n-l,a=null,u=function(d){null===a&&(a=d);var s,f=d-a;f<t?(e.scrollTop=(s=f,s/=t,c*(--s*s*s+1)+l),r&&r(),requestAnimationFrame(u)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(u)},N=function(N){var Y,P,q,X,V,U,J,K,G=N.componentHeaderText,Q=void 0===G?"Contract Comparison":G,Z=N.treeData,$=N.comparisonConfig,ee=N.leftColumnTitleText,ne=N.rightColumnTitleText,te=N.markdownStyles,ie=N.maintainRelativeOrder,re=void 0!==ie&&ie,oe=N.popupConfig,le=N.deviationData,ce=void 0===le?{}:le,ae=r(re),ue=ae[0],de=ae[1],se=r(!1),fe=se[0],ve=se[1],pe=r(!1),he=pe[0],xe=pe[1],ge=r(null),me=ge[0],ye=ge[1],be=r(!1),we=be[0],Ie=be[1],Fe=r(!1),Se=Fe[0],Ee=Fe[1],Ce=o(!1),Re=r(new Set),Te=Re[0],Be=Re[1],_e=r([]),De=_e[0],Me=_e[1],ke=o(null),Ae=o(!1),He=o(null),ze=o({}),We=o([]),Le=o(!1),Oe=o(!1),je=o(null),Ne=l(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),Ye=r(null),Pe=Ye[0],qe=Ye[1],Xe=o(null),Ve=r({width:0,height:0}),Ue=Ve[0],Je=Ve[1],Ke=l(function(){return e(e({},_),te)},[te]),Ge=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Qe=Ge[0],Ze=Ge[1],$e=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),en=$e[0],nn=$e[1],tn=o(null),rn=o(null),on=o(null),ln=o(null),cn=o(null),an=o(null),un=o(!1),dn=o(null);c(function(){dn.current=null},[Qe.sectionIdx,Qe.open]);var sn=a(function(){qe(null),Ze(O)},[]),fn=a(function(){nn(O)},[]),vn=a(function(){var e;if(Qe.anchorEl&&Qe.refSectionTitle){var n=Qe.anchorEl.getBoundingClientRect(),t=(null===(e=null==Xe?void 0:Xe.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==dn.current?!0===dn.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),dn.current=l;var c=l?o:r,a=Math.min(t||9999,c),u=l?n.top-12-a:n.bottom+12,d=n.left+n.width/2,s=d-i/2,f=Math.max(12,Math.min(s,window.innerWidth-i-12)),v=Math.max(14,Math.min(d-f,i-10-4));qe({top:u,left:f,arrowLeft:v,openAbove:l,maxHeight:c})}},[Qe.anchorEl,Qe.refSectionTitle]);c(function(){if(Qe.open){window.addEventListener("resize",vn);var e=requestAnimationFrame(vn),n=null;return Xe.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(vn)})).observe(Xe.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",vn),n&&n.disconnect()}}},[Qe.open,vn]),c(function(){var e=tn.current;if(e&&Qe.open){var n=function(e){Xe.current&&Xe.current.contains(e.target)||(qe(null),sn())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[Qe.open,sn]),c(function(){var e=tn.current;if(e&&en.open){var n=function(){fn()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[en.open,fn]);var pn=l(function(){var n,t,i,r,o,l,c,a,u,d,s,f;return{fields:null!==(n=null==$?void 0:$.fields)&&void 0!==n?n:D,thresholds:{high:null!==(i=null===(t=null==$?void 0:$.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:M.thresholds.high,medium:null!==(o=null===(r=null==$?void 0:$.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:M.thresholds.medium,exact:null!==(c=null===(l=null==$?void 0:$.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:M.thresholds.exact},relationStyles:{noContent:e(e({},M.relationStyles.noContent),(null===(a=null==$?void 0:$.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e(e({},M.relationStyles.high),(null===(u=null==$?void 0:$.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e(e({},M.relationStyles.exact),(null===(d=null==$?void 0:$.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},M.relationStyles.medium),(null===(s=null==$?void 0:$.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},M.relationStyles.low),(null===(f=null==$?void 0:$.relationStyles)||void 0===f?void 0:f.low)||{})}}},[$]),hn=l(function(){if(Z&&Object.keys(Z).length>0)try{var n=function(n,t,i){var r,o,l,c,a,u,d,s,f;void 0===t&&(t=!1),void 0===i&&(i=null);var v=[],p=[],h=n.base_root_id,x=n.input_index_map||{0:"left",1:"right"},g=n[h];if(!g||!1===g.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var m=function(t,r){var o,l=n[t];if(!l||!1===l.display_node)return null;var c=T(l,r,x),a=!!c.title.trim(),u=!!c.content.trim(),d=R(l),s=(null===(o=null==i?void 0:i[t])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,f=[];l.next&&Object.values(l.next).forEach(function(e){var t=n[e];if(t&&!1!==t.display_node){var i=m(e,r);i&&f.push(i)}});var v=!(!a&&!u);return e(e({id:t,title:a?c.title:"",content:u?c.content:"",subsections:f},v?d:{score:void 0,relation:"not_defined"}),{evaluationResult:s})};if(t){var y={},b={},w=-1,I=-1;for(var F in n)if(!["base_root_id","documents","input_index_map",h].includes(F)){var S=n[F];if(S&&!1!==S.display_node){var E=R(S),C=T(S,"0",x),B=T(S,"1",x),_=C.title.trim()||C.content.trim(),D=B.title.trim()||B.content.trim(),M=(null===(r=null==i?void 0:i[F])||void 0===r?void 0:r.evaluation_result)||S.evaluation_result||null,k=Number(null!==(l=null===(o=C.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:w--),A=Number(null!==(a=null===(c=B.attributes)||void 0===c?void 0:c.display_index)&&void 0!==a?a:I--),H=b[A]||e(e({id:F,title:D?B.title:"",content:D?B.content:"",subsections:[]},D?E:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:A,evaluationResult:M}),z=y[k]||e(e({id:F,title:_?C.title:"",content:_?C.content:"",subsections:[]},_?E:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:k,evaluationResult:M});Number(A)>=0&&Number(k)>=0&&(H.refIndexes.includes(Number(k))||H.refIndexes.push(Number(k)),z.refIndexes.includes(Number(A))||z.refIndexes.push(Number(A))),b[A]=H,y[k]=z}}p=Object.values(b).map(function(e){return e}),v=Object.values(y).map(function(e){return e}),p.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),v.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex})}else g.next&&Object.values(g.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(v.push(m(e,"0")||{id:e,title:"",content:"",subsections:[]}),p.push(m(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(d=null===(u=g.comparison_inputs)||void 0===u?void 0:u[x[0]])||void 0===d?void 0:d.title)||"Uploaded Contract",description:g.decision_scope_description||"",sections:v},activeVariants:[{id:"tree-variant-1",title:(null===(f=null===(s=g.comparison_inputs)||void 0===s?void 0:s[x[1]])||void 0===f?void 0:f.title)||"Reference Template",similarity:0,sections:p,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:g.decision_scope_description||""},fields:{}}}}]}}(Z,ue,ce);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(Z),ue,JSON.stringify(ce)]),xn=hn.activeProposed,gn=hn.activeVariants,mn=hn.parseError;c(function(){mn&&ye("Failed to load comparison: ".concat(mn))},[mn]);var yn=r(null),bn=yn[0];yn[1];var wn=r({}),In=wn[0],Fn=wn[1],Sn=r({}),En=Sn[0],Cn=Sn[1],Rn=(null==gn?void 0:gn[0])||L,Tn=null===(q=null===(Y=null==Z?void 0:Z.documents)||void 0===Y?void 0:Y[null===(P=null==Z?void 0:Z.input_index_map)||void 0===P?void 0:P[0]])||void 0===q?void 0:q.title,Bn=null===(U=null===(X=null==Z?void 0:Z.documents)||void 0===X?void 0:X[null===(V=null==Z?void 0:Z.input_index_map)||void 0===V?void 0:V[1]])||void 0===U?void 0:U.title,_n=S(ee||Tn||"Uploaded Contract"),Dn=S(ne||Bn||"Reference Template"),Mn=l(function(){return(null==xn?void 0:xn.sections)||[]},[null==xn?void 0:xn.sections]),kn=l(function(){return Rn.sections||[]},[Rn.sections]),An=Mn.length>0||kn.length>0,Hn=Rn.analysis,zn=S(null===(K=null===(J=null==Hn?void 0:Hn.rule_difference_comparison)||void 0===J?void 0:J.summary)||void 0===K?void 0:K.overall_summary),Wn=!!zn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Ln=o({}),On=function(e){return Ln.current[e]||(Ln.current[e]=i.createRef()),Ln.current[e]},jn=a(function(){Ie(!1),Oe.current=!1,nt(null),je.current=null,Vn.current=null,Ee(!1),xe(!1),ln.current&&(ln.current.style.height="0px"),cn.current&&(cn.current.style.height="0px")},[]),Nn=a(function(e,n,t,i,r){var o,l,c=S(n.id)||S(t.id)||"",a=(c?Ne[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},u=null!==(l=null===(o=Ln.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:a,anchorEl:e,sectionAnchorEl:u,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null}},[Ne,Z]),Yn=a(function(e){fn(),qe(null),Ze(e)},[fn]),Pn=a(function(){null!==en.sectionIdx&&en.anchorEl?Yn(e(e({},en),{open:!0})):fn()},[en,fn,Yn]);a(function(e){fn(),ye("".concat(e," is coming soon."))},[fn]);var qn=a(function(){var e=en.sectionIdx;fn(),null!==e&&(Oe.current&&jn(),Be(function(n){return n.has(e)?new Set:new Set([e])}))},[en.sectionIdx,fn,jn]),Xn=o(null),Vn=o(null),Un=o(null),Jn=o(null),Kn=o(null),Gn=r([]),Qn=Gn[0],Zn=Gn[1],$n=r(null),et=$n[0],nt=$n[1];o(null);var tt=r(null),it=tt[0],rt=tt[1],ot=l(function(){return pn.fields.filter(function(e){var n=e.key;return(!An||"description"!==n)&&(E(null==xn?void 0:xn[n])||E(Rn[n]))})},[xn,Rn,An,pn.fields]),lt=o({}),ct=o({}),at=o({}),ut=o({}),dt=o({}),st=o({}),ft=o({});ot.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Mn.length,kn.length);t+=1)at.current[t]||(at.current[t]=i.createRef()),ut.current[t]||(ut.current[t]=i.createRef()),dt.current[t]||(dt.current[t]=i.createRef()),st.current[t]||(st.current[t]=i.createRef()),ft.current[t]||(ft.current[t]=i.createRef());lt.current[n]||(lt.current[n]=i.createRef()),ct.current[n]||(ct.current[n]=i.createRef())});for(var vt=0;vt<Math.max(Mn.length,kn.length);vt+=1)at.current[vt]||(at.current[vt]=i.createRef()),ut.current[vt]||(ut.current[vt]=i.createRef()),dt.current[vt]||(dt.current[vt]=i.createRef()),st.current[vt]||(st.current[vt]=i.createRef()),ft.current[vt]||(ft.current[vt]=i.createRef());c(function(){if(bn){var e=pn.fields.find(function(e){return e.analysisKey===bn||e.key===bn});if(e){var n=lt.current[e.key]||ct.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[bn,pn.fields]);var pt=a(function(e){var n,t,i,r,o,l,c,a,u,d=null===(n=null==Hn?void 0:Hn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[e],f=(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===(o=null===(r=null==s?void 0:s.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var v=s.mappings[0]||{};return{score:s.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=v.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(a=s.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(u=s.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!f}},[Hn]),ht=a(function(n){var t,i,r,o,l=Mn[n],c=kn[n],a=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,d=S(null==l?void 0:l.id)||S(null==c?void 0:c.id)||"",s=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!a&&!u&&!s)return e(e({},pn.relationStyles.noContent),{label:"Not Defined"});var f=pt("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=Ne[d])||void 0===r?void 0:r.relevance_score:void 0)){var v=B(),p=v.score,h=v.relation;return C(p,h,!0,pn)}var x=a?l.relation:u?c.relation:f.relation,g=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==c?void 0:c.score,m="number"==typeof g?g:f.score;return C(m,x,!0,pn)},[Mn,kn,Ne,pn,pt]),xt=a(function(){var e,n,t,i,r,o,l,c,a,u,d;if(!un.current&&!Ae.current){un.current=!0;try{if(!Xn.current)return;var s=Xn.current.getBoundingClientRect();Je({width:s.width,height:s.height});var f=[];if(ot.forEach(function(e){var n,t,i=e.key,r=null===(n=lt.current[i])||void 0===n?void 0:n.current,o=null===(t=ct.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!ue&&!Ae.current)for(var v=0;v<Math.min(Mn.length,kn.length);v++){var p=null===(e=at.current[v])||void 0===e?void 0:e.current,h=null===(n=ut.current[v])||void 0===n?void 0:n.current;p&&h&&(p.style.height="auto",h.style.height="auto",p.style.minHeight="0px",h.style.minHeight="0px")}var x={};ot.forEach(function(e){var n,t,i=e.key,r=null===(n=lt.current[i])||void 0===n?void 0:n.current,o=null===(t=ct.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();x[i]=Math.max(l.height,c.height)}});var g=[];if(!ue&&!Ae.current)for(v=0;v<Math.min(Mn.length,kn.length);v++){p=null===(t=at.current[v])||void 0===t?void 0:t.current,h=null===(i=ut.current[v])||void 0===i?void 0:i.current;var m=!!In[String(v)];if(p&&h&&m){var y=p.getBoundingClientRect(),b=h.getBoundingClientRect();g[v]=Math.max(y.height,b.height)}}if(ot.forEach(function(e){var n,t,i=e.key,r=null===(n=lt.current[i])||void 0===n?void 0:n.current,o=null===(t=ct.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=x[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!ue&&!Ae.current)for(v=0;v<g.length;v++){p=null===(r=at.current[v])||void 0===r?void 0:r.current,h=null===(o=ut.current[v])||void 0===o?void 0:o.current;if(p&&h&&g[v]){var w=g[v];p.style.minHeight="".concat(w,"px"),h.style.minHeight="".concat(w,"px")}}if(ot.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=lt.current[i])||void 0===n?void 0:n.current,l=null===(t=ct.current[i])||void 0===t?void 0:t.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),u=pt(r),d=C(u.score,u.relation,u.hasContent,pn);if(!d)return;var v=c.top+c.height/2-s.top;f.push({id:"field-".concat(i),x1:c.right-s.left,y1:v,x2:a.left-s.left,y2:v,style:d})}}),ue)Mn.forEach(function(e,n){var t;(null===(t=at.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,c,a,u,d,v,p=kn.findIndex(function(n){return n.selfIndex===e});if(-1!==p){var h=null===(t=dt.current[n])||void 0===t?void 0:t.current,x=null===(i=st.current[p])||void 0===i?void 0:i.current;if(h&&x){var g=h.getBoundingClientRect(),m=x.getBoundingClientRect(),y=g.right-s.left,b=m.left-s.left,w=g.top+g.height/2-s.top,I=m.top+m.height/2-s.top;if(we&&et===n){var F=null!==(o=null===(r=an.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,S=null!==(c=null===(l=on.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==c?c:0,E=F+(null!==(u=null===(a=an.current)||void 0===a?void 0:a.clientHeight)&&void 0!==u?u:1/0),C=S+(null!==(v=null===(d=on.current)||void 0===d?void 0:d.clientHeight)&&void 0!==v?v:1/0),R=g.top+g.height/2,T=function(e,n,t){return Math.max(n,Math.min(t,e))};w=T(R,F,E)-s.top,I=T(R,S,C)-s.top}var B=ht(n);B&&f.push({id:"line-".concat(n,"-").concat(p),x1:y,y1:w,x2:b,y2:I,style:B,sectionIdx:n,targetRightIdx:p})}}})});else for(v=0;v<Math.min(Mn.length,kn.length);v++){var I=null===(l=at.current[v])||void 0===l?void 0:l.current,F=null===(c=ut.current[v])||void 0===c?void 0:c.current;if(I&&F){var S=I.getBoundingClientRect(),E=F.getBoundingClientRect(),R=(S.top+18-s.top+E.top+18-s.top)/2,T=(null===(a=kn[v])||void 0===a?void 0:a.id)||"sec-".concat(v),B=ht(v);B&&f.push({id:T,x1:S.right-s.left,y1:R,x2:E.left-s.left,y2:R,style:B,sectionIdx:v,hasCognitive:!!((null===(u=Mn[v])||void 0===u?void 0:u.cognitiveData)||(null===(d=kn[v])||void 0===d?void 0:d.cognitiveData)||T&&Ne[T])})}}if(Zn(f),Jn.current&&Kn.current){var _=Jn.current.getBoundingClientRect(),D=Kn.current.getBoundingClientRect(),M=(_.top+_.height/2-s.top+D.top+D.height/2-s.top)/2;rt({x1:_.right-s.left,x2:D.left-s.left,y:M})}else rt(null);if(ue&&Te.size>0){var k=[],A=an.current,H=on.current;if(A&&H){var z=[],L=A.getBoundingClientRect().top,O=H.getBoundingClientRect().top,j=L+A.clientHeight,N=O+H.clientHeight,Y=A.scrollTop,P=H.scrollTop,q=s.top,X=function(e,n,t){return Math.max(n,Math.min(t,e))};Te.forEach(function(e){var n,t=Mn[e];(null===(n=null==t?void 0:t.refIndexes)||void 0===n?void 0:n.length)&&t.refIndexes.forEach(function(n){var t,i,r=kn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=dt.current[e])||void 0===t?void 0:t.current,l=null===(i=st.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),u=ht(e),d=c.right-s.left,f=a.left-s.left,v=(d+f)/2,p=c.top+c.height/2,h=a.top+a.height/2,x=p-L+Y,g=h-O+P,m="conn-".concat(e,"-").concat(r);z.push({lhsScrollY:x,rhsScrollY:g,x1:d,x2:f,containerTop:q,leftIdx:e,rhsArrayIdx:r,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:m});var y=X(p,L,j),b=X(h,O,N),w=y-q,I=b-q,F=p>=L-4&&p<=j+4,S=h>=O-4&&h<=N+4,E="";E=F&&S?W(d,w,f,I):F&&!S?"M ".concat(d,",").concat(w," L ").concat(v,",").concat(w," L ").concat(v,",").concat(I):!F&&S?"M ".concat(v,",").concat(w," L ").concat(v,",").concat(I," L ").concat(f,",").concat(I):"M ".concat(v,",").concat(w," L ").concat(v,",").concat(I),k.push({id:m,pathD:E,style:u,leftIdx:e,rhsArrayIdx:r})}}})}),We.current=z}Me(k)}else Me([]),We.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{un.current=!1}}},[ot,Mn,kn,Ne,pn,pt,ht,ue,we,et,Te,In]),gt=a(function(){var e,n,t,i,r,o,l,c,a,u,d,s,f,v,p=We.current;if(p.length&&!Ae.current){var h=null!==(n=null===(e=an.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=on.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,g=null!==(o=null===(r=an.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(c=null===(l=on.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,y=null!==(u=null===(a=an.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==u?u:0,b=null!==(s=null===(d=on.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,w=y+g,I=b+m,F=null!==(v=null===(f=Xn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==v?v:0,S=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+b,i=ze.current[e.styleId+"-stroke"],r=ze.current[e.styleId+"-bg"];if(i||r){var o,l=S(n,y,w),c=S(t,b,I),a=l-F,u=c-F,d=n>=y-4&&n<=w+4,s=t>=b-4&&t<=I+4,f=(e.x1+e.x2)/2;o=d&&s?W(e.x1,a,e.x2,u):d&&!s?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(u):!d&&s?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(u," L ").concat(e.x2,",").concat(u):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(u),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),mt=o(xt);c(function(){mt.current=xt},[xt]);var yt=o(null),bt=a(function(){null!==yt.current&&clearTimeout(yt.current),yt.current=setTimeout(function(){mt.current(),yt.current=null},50)},[]),wt=a(function(e){var n,t,i,r,o;if(!Ce.current){if(Oe.current){var l=je.current,c=Vn.current,a=an.current,u=on.current;if(null!==l&&null!==c&&a&&u){var d=null===(n=Ln.current[l])||void 0===n?void 0:n.current,s=null===(t=ft.current[c])||void 0===t?void 0:t.current;if(d&&s){if(e.currentTarget===a){var f=d.offsetTop-a.scrollTop,v=Math.max(0,s.offsetTop-f);Math.abs(u.scrollTop-v)>1&&(u.scrollTop=v)}else if(e.currentTarget===u){var p=s.offsetTop-u.scrollTop,h=Math.max(0,d.offsetTop-p);Math.abs(a.scrollTop-h)>1&&(a.scrollTop=h)}if(Un.current){var x=null===(i=dt.current[l])||void 0===i?void 0:i.current,g=null!==(o=null===(r=Xn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,m=a.getBoundingClientRect().top,y=m+a.clientHeight,b=u.getBoundingClientRect().top,w=b+u.clientHeight,I=function(e,n,t){return Math.max(n,Math.min(t,e))};if(x){var F=x.getBoundingClientRect(),S=F.top+F.height/2,E=I(S,m,y),C=I(S,b,w);Un.current.setAttribute("y1",(E-g).toString()),Un.current.setAttribute("y2",(C-g).toString());var R=S>=m-4&&S<=y+4;Un.current.setAttribute("visibility",R?"visible":"hidden")}}}}}We.current.length>0&&!Le.current&&(Le.current=!0,requestAnimationFrame(function(){gt(),Le.current=!1}))}},[gt]);c(function(){var e=setTimeout(bt,250);window.addEventListener("resize",bt);var n=null,t=null;return tn.current&&(n=new ResizeObserver(bt)).observe(tn.current),Xn.current&&(t=new ResizeObserver(bt)).observe(Xn.current),function(){clearTimeout(e),window.removeEventListener("resize",bt),null==n||n.disconnect(),null==t||t.disconnect()}},[xn,Rn,Hn,ot,In,En,Mn,kn,pn,bt,we,et,Se,Te]),c(function(){Oe.current=we},[we]),c(function(){je.current=et},[et]);var It=a(function(){var e=en.sectionIdx;fn(),null!==e&&(we&&et===e?jn():(Be(new Set),Me([]),We.current=[],xe(!0),Ce.current=!0,nt(e),je.current=e,Ie(!0),Oe.current=!0,Ee(!1),ln.current&&(ln.current.style.height="0px"),cn.current&&(cn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=Ln.current[e])||void 0===n?void 0:n.current,r=Mn[e],o=(null==r?void 0:r.refIndexes)||[],l=null,c=-1;if(o.length>0){var a=o[0];c=kn.findIndex(function(e){return e.selfIndex===a}),l=null===(t=ft.current[c])||void 0===t?void 0:t.current}Vn.current=-1!==c?c:null;var u=an.current,d=on.current;if(!i||!u)return Ce.current=!1,void xe(!1);var s=i.offsetTop-u.scrollTop;if(!l||!d)return Ee(!0),mt.current(),Ce.current=!1,void xe(!1);var f=l.offsetTop-s;f<0&&ln.current&&(ln.current.style.height="".concat(Math.abs(f),"px"));requestAnimationFrame(function(){var e,n=d.scrollHeight-d.clientHeight;if(f<0)e=0;else{if(f>n){var t=f-n;return cn.current&&(cn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){j(d,f,200,function(){Ee(!0),mt.current(),Ce.current=!1,xe(!1)})})}e=f}j(d,e,200,function(){Ee(!0),mt.current(),Ce.current=!1,xe(!1)})})})))},[fn,en.sectionIdx,we,et,Mn,kn,bt,jn]),Ft=null!==en.sectionIdx&&Te.has(en.sectionIdx),St=function(r,o,l,c,a){void 0===a&&(a=1);var s,f=ue?!!In["".concat(l,"-").concat(o)]:!!In[String(o)],v=E(r.title),p=E(r.content),b=!v&&!p,w=r.title;return v||(w=p?"No Title Found":"No Matching Section Found"),n(d,e({ref:c,sx:e(e({mb:a},ue?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:t(x,e({disableGutters:!0,expanded:!b&&f,onChange:function(){return!b&&function(n,t){var i,r;if(Ae.current=!0,He.current&&clearTimeout(He.current),ke.current&&(ke.current.style.opacity="0"),!ue){var o=null===(i=at.current[n])||void 0===i?void 0:i.current,l=null===(r=ut.current[n])||void 0===r?void 0:r.current;o&&l&&(o.style.minHeight="0px",l.style.minHeight="0px")}He.current=setTimeout(function(){Ae.current=!1,mt.current(),ke.current&&(ke.current.style.opacity="1")},350),Fn(function(i){var r=e({},i);if(!ue){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),c=!i[l];if(r[l]=c,"left"===t)((null==(a=Mn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=kn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=c)});else{var a,u=null==(a=kn[n])?void 0:a.selfIndex;Mn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u))&&(r["left-".concat(n)]=c)})}return r})}(o,l)},sx:{boxShadow:"none",border:b?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:b?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n(g,e({expandIcon:b?null:n(y,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:b?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n(h,e({title:w,placement:"top"},{children:n(u,e({sx:{fontSize:"12px",color:b?"#94A3B8":"#19213D",fontWeight:b?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(s=w,s?S(s).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n("strong",{children:e.slice(2,-2)},t):n(i.Fragment,{children:e},t)}):null)}))}))})),!b&&t(m,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n(z,{content:r.content,sxStyles:Ke}),(r.subsections||[]).map(function(e,n){return Et(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},Et=function(i,r,o){void 0===o&&(o=0);var l=E(i.title),c=E(i.content),a=!l&&!c,s=l?i.title:c?"No Title Found":"No Matching Section Found",f=!!En[r];return i.title?t(x,e({disableGutters:!0,expanded:!a&&f,onChange:function(){return!a&&Cn(function(n){var t;return e(e({},n),((t={})[r]=!n[r],t))})},sx:{mt:1,boxShadow:"none",border:a?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF","&:before":{display:"none"}}},{children:[n(g,e({expandIcon:a?null:n(y,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:n(u,e({sx:{fontSize:"11px",fontWeight:600,color:a?"#94A3B8":"#19213D"}},{children:s||"Untitled Subsection"}))})),!a&&t(m,e({sx:{pt:0,pb:1}},{children:[c&&n(u,e({component:"div",sx:Ke},{children:n(F,{children:S(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Et(e,"".concat(r,"-").concat(n),o+1)})]}))]}),r):n(d,e({sx:{mt:0===o?1:.75}},{children:!a&&t("div",{children:[c&&n(u,e({component:"div",sx:Ke},{children:n(F,{children:S(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Et(e,"".concat(r,"-").concat(n),o+1)})]})}),r)};return t(d,e({ref:rn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ue?{}:{overflow:"visible"}),{position:"relative"})},{children:[fe&&n(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:n(H,{})})),ue&&n(A,{open:en.open,anchorEl:en.anchorEl,sectionTitle:en.sectionTitle,referenceSectionTitle:en.refSectionTitle,onClose:fn,onOpenCognitiveCompare:Pn,onOpenSideBySide:It,onConnect:qn,isConnected:Ft}),Qe.open&&n(k,{open:Qe.open,popupRef:Xe,position:Pe,popupConfig:oe,onClose:function(){qe(null),Ze(function(n){return e(e({},n),{open:!1})})},markdownStyles:te,sectionTitle:Qe.sectionTitle,referenceSectionTitle:Qe.refSectionTitle,cognitiveData:Qe.cognitiveData,anchorEl:Qe.anchorEl,sectionAnchorEl:Qe.sectionAnchorEl,scrollContainerEl:tn.current,badgeStyle:Qe.badgeStyle,docData:Qe.docData,deviationData:Qe.deviationData}),n(s,e({open:!!me,autoHideDuration:8e3,onClose:function(){return ye(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n(f,e({onClose:function(){return ye(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:me}))})),t(d,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n(d,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:n(u,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:Q}))})),n(d,e({sx:{display:"flex",alignItems:"center"}},{children:n(v,{control:n(p,{checked:ue,onChange:function(e){var n=e.target.checked;ve(!0),setTimeout(function(){de(n),jn(),Be(new Set),Me([]),We.current=[],setTimeout(function(){ve(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#1976d2",opacity:1,border:0,"&::before":{content:'"Relative Order"',position:"absolute",left:"7px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Default View"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n(d,e({ref:tn,onScroll:wt,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ue?"hidden":"auto",borderTop:zn&&Wn?"none":"1.5px solid #EEF0F4"}},{children:n(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ue?{flex:1,minHeight:0}:{})},{children:t(d,e({ref:Xn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ue?{flex:1,overflow:"visible"}:{})},{children:[t("svg",e({ref:ke,style:{position:"absolute",top:0,left:0,width:Ue.width||"100%",height:Ue.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[it&&t("g",{children:[n("line",{x1:it.x1,y1:it.y,x2:Math.max(it.x1,(it.x1+it.x2)/2-70),y2:it.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n("line",{x1:Math.min(it.x2,(it.x1+it.x2)/2+70),y1:it.y,x2:it.x2,y2:it.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Qn.map(function(i){var r,o=(i.x1+i.x2)/2;if("Not Defined"===i.style.label&&!i.hasCognitive)return null;if(!ue)return t("g",{children:[n("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n("foreignObject",e({x:o-100,y:i.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,e({onClick:function(e){if(e.stopPropagation(),Qe.open&&Qe.sectionIdx===i.sectionIdx)sn();else{var n=Mn[i.sectionIdx]||{title:"",content:""},t=kn[i.sectionIdx]||{title:"",content:""};Yn(Nn(e.currentTarget,n,t,i.sectionIdx,i.style))}},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:i.style.badgeBg,color:i.style.badgeText,border:"1px solid ".concat(i.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[i.style.label,n(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n(w,{})})),n(y,{size:11,style:{transform:Qe.open&&Qe.sectionIdx===i.sectionIdx?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},i.id);var l=Mn[i.sectionIdx];return!(null===(r=null==l?void 0:l.refIndexes)||void 0===r?void 0:r.length)||(null==l?void 0:l.selfIndex)<0?null:we&&et===i.sectionIdx&&Se?t("g",e({style:{transition:"opacity 0.2s"}},{children:[n("defs",{children:n("marker",e({id:"arr-".concat(i.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n("polygon",{points:"0 0, 7 2.5, 0 5",fill:i.style.badgeBorder||"#6366F1"})}))}),n("line",{ref:Un,x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(i.id,")")})]}),i.id):null}),De.map(function(i){var r,o=i.pathD,l=(null===(r=i.style)||void 0===r?void 0:r.badgeBorder)||"#6366F1",c="conn-marker-".concat(i.id),a="".concat(i.id,"-bg"),u="".concat(i.id,"-stroke");return t("g",{children:[n("defs",{children:n("clipPath",e({id:"connections-clip"},{children:n("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),n("path",{ref:function(e){ze.current[a]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n("path",{ref:function(e){ze.current[u]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},i.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)"},ue?{flex:1,overflow:"visible"}:{})},{children:[n(d,e({ref:Jn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:n(h,e({title:_n,placement:"top"},{children:n(u,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:_n}))}))})),n(d,e({ref:an,onScroll:wt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ue?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:An&&Mn.map(function(r,o){var l;if(!ue)return n(d,e({ref:On(o)},{children:St(r,o,"left",at.current[o])}),"left-row-".concat(o));var c=r,a=ht(o),u=!(null===(l=c.refIndexes)||void 0===l?void 0:l.length)||c.selfIndex<0,s="number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null,f=Te.has(o);return n(d,e({ref:On(o),sx:{mb:1}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[n(d,e({ref:at.current[o],sx:e({width:"100%"},f&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:St(r,o,"left",i.createRef(),0)})),a&&t(d,e({ref:dt.current[o],onClick:function(e){var n=kn.find(function(e){var n;return null===(n=c.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};!function(e,n,t,i,r){e.stopPropagation(),en.open&&en.sectionIdx===i?fn():(sn(),nn(Nn(e.currentTarget,n,t,i,r)))}(e,r,n,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!==s&&n(d,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:s})),n(d,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:u?"No Deviation Found":0==a.deviationLabel||void 0===a.deviationLabel?"Same":"".concat(a.deviationLabel,"% Deviation")})),n(b,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),n(d,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:n(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[n(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n(w,{})})),0,"% Similarity",n(y,{size:11})]}))}))})),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},ue?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[he&&n(I,{sections:11}),n(d,e({ref:Kn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n(h,e({title:Dn,placement:"top"},{children:n(u,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:Dn}))}))})),t(d,e({ref:on,onScroll:wt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ue?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n("div",{ref:ln,style:{width:"100%",height:"0px",flexShrink:0}}),An&&kn.map(function(r,o){if(!ue)return St(r,o,"right",ut.current[o]);var l=r,c=Mn.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}),a=Mn.some(function(e,n){var t;return Te.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))}),u=Mn.findIndex(function(e,n){var t;return Te.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))}),s=-1!==u?ht(u):null;return n(d,e({ref:ft.current[o],sx:{mb:1}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[n(d,e({ref:ut.current[o],sx:e({width:"100%"},a&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:St(r,o,"right",i.createRef(),0)})),!he&&n(d,e({ref:st.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:c.length>0?c.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n("div",{ref:cn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{N as default};
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as n,jsxs as t}from"react/jsx-runtime";import i,{useMemo as r,useState as o,useRef as l,useEffect as c,useCallback as u}from"react";import{Typography as a,Box as d,Snackbar as s,Alert as v,FormControlLabel as f,Switch as h,Tooltip as p,Accordion as x,AccordionSummary as g,AccordionDetails as m}from"@mui/material";import{ChevronDown as y,EllipsisVertical as b}from"lucide-react";import{ButtonCognitiveIcon as w}from"../../assests/svg/ButtonCognitiveIcon.js";import I from"./OverlayComponent.js";import S from"react-markdown";import{safeStringify as F,hasValue as E,getStyleForRelation as R,cognitiveScoreToRelation as C,getRationale as _,getSideData as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as B,DEFAULT_FIELD_CONFIG as k,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import M from"./CognitivePopup.js";import A from"./MoreFunctionsPopup.js";import H from"./LoaderComponent.js";import z from"rehype-raw";var W=i.memo(function(t){var i=t.content,o=t.sxStyles,l=t.highlights,c=void 0===l?[]:l,u=r(function(){return{mark:function(t){var i=t.children;return n("span",e({style:{backgroundColor:"#fccccc"}},{children:i}))}}},[]),d=r(function(){var e=i;return c.forEach(function(n){e=e.replace(new RegExp(n,"g"),"<mark>".concat(n,"</mark>"))}),e},[i,c]);return n(a,e({component:"div",sx:o},{children:n(S,e({components:u,rehypePlugins:[z]},{children:F(d).replace(/\\n/g,"\n")}))}))}),L=function(e,n,t,i,r){void 0===r&&(r=14);var o=(e+t)/2,l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var c=l>0?1:-1,u=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-u),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+c*u),"V ".concat(i-c*u),"Q ".concat(o," ").concat(i," ").concat(o+u," ").concat(i),"H ".concat(t)].join(" ")},N={id:"",title:""},O={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},j=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,c=n-l,u=null,a=function(d){null===u&&(u=d);var s,v=d-u;v<t?(e.scrollTop=(s=v,s/=t,c*(--s*s*s+1)+l),r&&r(),requestAnimationFrame(a)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(a)},P=function(z){var P,Y,K,q,X,V,U,J,G=z.componentHeaderText,Q=void 0===G?"Contract Comparison":G,Z=z.treeData,$=z.comparisonConfig,ee=z.leftColumnTitleText,ne=z.rightColumnTitleText,te=z.markdownStyles,ie=z.maintainRelativeOrder,re=void 0!==ie&&ie,oe=z.popupConfig,le=z.deviationData,ce=void 0===le?{}:le,ue=o(re),ae=ue[0],de=ue[1],se=o(!1),ve=se[0],fe=se[1],he=o(!1),pe=he[0],xe=he[1],ge=o(null),me=ge[0],ye=ge[1],be=o(!1),we=be[0],Ie=be[1],Se=o(!1),Fe=Se[0],Ee=Se[1],Re=l(!1),Ce=o(null),_e=Ce[0],Te=Ce[1],Be=o(new Set),ke=Be[0],De=Be[1],Me=o([]),Ae=Me[0],He=Me[1],ze=l(null),We=l(!1),Le=l(null),Ne=l({}),Oe=l([]),je=l(!1),Pe=l(!1),Ye=l(null),Ke=r(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),qe=o(null),Xe=qe[0],Ve=qe[1],Ue=l(null),Je=o({width:0,height:0}),Ge=Je[0],Qe=Je[1],Ze=r(function(){return e(e({},B),te)},[te]),$e=o({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),en=$e[0],nn=$e[1],tn=o({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),rn=tn[0],on=tn[1],ln=l(null),cn=l(null),un=l(null),an=l(null),dn=l(null),sn=l(null),vn=l(!1),fn=l(null);c(function(){fn.current=null},[en.sectionIdx,en.open]);var hn=u(function(){Ve(null),nn(O),Te(null)},[]),pn=u(function(){on(O)},[]),xn=u(function(){var e;if(en.anchorEl&&en.refSectionTitle){var n=en.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ue?void 0:Ue.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==fn.current?!0===fn.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),fn.current=l;var c=l?o:r,u=Math.min(t||9999,c),a=l?n.top-12-u:n.bottom+12,d=n.left+n.width/2,s=d-i/2,v=Math.max(12,Math.min(s,window.innerWidth-i-12)),f=Math.max(14,Math.min(d-v,i-10-4));Ve({top:a,left:v,arrowLeft:f,openAbove:l,maxHeight:c})}},[en.anchorEl,en.refSectionTitle]);c(function(){if(en.open){window.addEventListener("resize",xn);var e=requestAnimationFrame(xn),n=null;return Ue.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(xn)})).observe(Ue.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",xn),n&&n.disconnect()}}},[en.open,xn]),c(function(){var e=ln.current;if(e&&en.open){var n=function(e){Ue.current&&Ue.current.contains(e.target)||(Ve(null),hn())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[en.open,hn]),c(function(){var e=ln.current;if(e&&rn.open){var n=function(){pn()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[rn.open,pn]);var gn=r(function(){var n,t,i,r,o,l,c,u,a,d,s,v;return{fields:null!==(n=null==$?void 0:$.fields)&&void 0!==n?n:k,thresholds:{high:null!==(i=null===(t=null==$?void 0:$.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:D.thresholds.high,medium:null!==(o=null===(r=null==$?void 0:$.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(c=null===(l=null==$?void 0:$.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:D.thresholds.exact},relationStyles:{noContent:e(e({},D.relationStyles.noContent),(null===(u=null==$?void 0:$.relationStyles)||void 0===u?void 0:u.noContent)||{}),high:e(e({},D.relationStyles.high),(null===(a=null==$?void 0:$.relationStyles)||void 0===a?void 0:a.high)||{}),exact:e(e({},D.relationStyles.exact),(null===(d=null==$?void 0:$.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e(e({},D.relationStyles.medium),(null===(s=null==$?void 0:$.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},D.relationStyles.low),(null===(v=null==$?void 0:$.relationStyles)||void 0===v?void 0:v.low)||{})}}},[$]),mn=r(function(){if(Z&&Object.keys(Z).length>0)try{var n=function(n,t,i){var r,o,l,c,u,a,d,s,v;void 0===t&&(t=!1),void 0===i&&(i=null);var f=[],h=[],p=n.base_root_id,x=n.input_index_map||{0:"left",1:"right"},g=n[p];if(!g||!1===g.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var m=function(t,r){var o,l=n[t];if(!l||!1===l.display_node)return null;var c=T(l,r,x),u=!!c.title.trim(),a=!!c.content.trim(),d=_(l),s=(null===(o=null==i?void 0:i[t])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,v=[];l.next&&Object.values(l.next).forEach(function(e){var t=n[e];if(t&&!1!==t.display_node){var i=m(e,r);i&&v.push(i)}});var f=!(!u&&!a);return e(e({id:t,title:u?c.title:"",content:a?c.content:"",subsections:v},f?d:{score:void 0,relation:"not_defined"}),{evaluationResult:s})};if(t){var y={},b={},w=-1,I=-1;for(var S in n)if(!["base_root_id","documents","input_index_map",p].includes(S)){var F=n[S];if(F&&!1!==F.display_node){var E=_(F),R=T(F,"0",x),C=T(F,"1",x),B=R.title.trim()||R.content.trim(),k=C.title.trim()||C.content.trim(),D=(null===(r=null==i?void 0:i[S])||void 0===r?void 0:r.evaluation_result)||F.evaluation_result||null,M=Number(null!==(l=null===(o=R.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:w--),A=Number(null!==(u=null===(c=C.attributes)||void 0===c?void 0:c.display_index)&&void 0!==u?u:I--),H=b[A]||e(e({id:S,title:k?C.title:"",content:k?C.content:"",subsections:[]},k?E:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:A,evaluationResult:D}),z=y[M]||e(e({id:S,title:B?R.title:"",content:B?R.content:"",subsections:[]},B?E:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:M,evaluationResult:D});Number(A)>=0&&Number(M)>=0&&(H.refIndexes.includes(Number(M))||H.refIndexes.push(Number(M)),z.refIndexes.includes(Number(A))||z.refIndexes.push(Number(A))),b[A]=H,y[M]=z}}h=Object.values(b).map(function(e){return e}),f=Object.values(y).map(function(e){return e}),h.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),f.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex})}else g.next&&Object.values(g.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(f.push(m(e,"0")||{id:e,title:"",content:"",subsections:[]}),h.push(m(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(d=null===(a=g.comparison_inputs)||void 0===a?void 0:a[x[0]])||void 0===d?void 0:d.title)||"Uploaded Contract",description:g.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(v=null===(s=g.comparison_inputs)||void 0===s?void 0:s[x[1]])||void 0===v?void 0:v.title)||"Reference Template",similarity:0,sections:h,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:g.decision_scope_description||""},fields:{}}}}]}}(Z,ae,ce);return e(e({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(Z),ae,JSON.stringify(ce)]),yn=mn.activeProposed,bn=mn.activeVariants,wn=mn.parseError;c(function(){wn&&ye("Failed to load comparison: ".concat(wn))},[wn]);var In=o(null),Sn=In[0];In[1];var Fn=o({}),En=Fn[0],Rn=Fn[1],Cn=o({}),_n=Cn[0],Tn=Cn[1],Bn=(null==bn?void 0:bn[0])||N,kn=null===(K=null===(P=null==Z?void 0:Z.documents)||void 0===P?void 0:P[null===(Y=null==Z?void 0:Z.input_index_map)||void 0===Y?void 0:Y[0]])||void 0===K?void 0:K.title,Dn=null===(V=null===(q=null==Z?void 0:Z.documents)||void 0===q?void 0:q[null===(X=null==Z?void 0:Z.input_index_map)||void 0===X?void 0:X[1]])||void 0===V?void 0:V.title,Mn=F(ee||kn||"Uploaded Contract"),An=F(ne||Dn||"Reference Template"),Hn=r(function(){return(null==yn?void 0:yn.sections)||[]},[null==yn?void 0:yn.sections]),zn=r(function(){return Bn.sections||[]},[Bn.sections]),Wn=Hn.length>0||zn.length>0,Ln=Bn.analysis,Nn=F(null===(J=null===(U=null==Ln?void 0:Ln.rule_difference_comparison)||void 0===U?void 0:U.summary)||void 0===J?void 0:J.overall_summary),On=!!Nn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),jn=l({}),Pn=function(e){return jn.current[e]||(jn.current[e]=i.createRef()),jn.current[e]},Yn=u(function(){Ie(!1),Pe.current=!1,rt(null),Ye.current=null,Jn.current=null,Ee(!1),xe(!1),an.current&&(an.current.style.height="0px"),dn.current&&(dn.current.style.height="0px")},[]),Kn=u(function(e,n,t,i,r){var o,l,c=F(n.id)||F(t.id)||"",u=(c?Ke[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},a=null!==(l=null===(o=jn.current[i])||void 0===o?void 0:o.current)&&void 0!==l?l:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:u,anchorEl:e,sectionAnchorEl:a,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null}},[Ke,Z]),qn=u(function(e){pn(),Ve(null),nn(e)},[pn]),Xn=u(function(){null!==rn.sectionIdx&&rn.anchorEl?qn(e(e({},rn),{open:!0})):pn()},[rn,pn,qn]);u(function(e){pn(),ye("".concat(e," is coming soon."))},[pn]);var Vn=u(function(){var e=rn.sectionIdx;pn(),null!==e&&(Pe.current&&Yn(),De(function(n){return n.has(e)?new Set:new Set([e])}))},[rn.sectionIdx,pn,Yn]),Un=l(null),Jn=l(null),Gn=l(null),Qn=l(null),Zn=l(null),$n=o([]),et=$n[0],nt=$n[1],tt=o(null),it=tt[0],rt=tt[1];l(null);var ot=o(null),lt=ot[0],ct=ot[1],ut=r(function(){return gn.fields.filter(function(e){var n=e.key;return(!Wn||"description"!==n)&&(E(null==yn?void 0:yn[n])||E(Bn[n]))})},[yn,Bn,Wn,gn.fields]),at=l({}),dt=l({}),st=l({}),vt=l({}),ft=l({}),ht=l({}),pt=l({}),xt=l({}),gt=l({});ut.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Hn.length,zn.length);t+=1)st.current[t]||(st.current[t]=i.createRef()),vt.current[t]||(vt.current[t]=i.createRef()),ft.current[t]||(ft.current[t]=i.createRef()),ht.current[t]||(ht.current[t]=i.createRef()),pt.current[t]||(pt.current[t]=i.createRef());at.current[n]||(at.current[n]=i.createRef()),dt.current[n]||(dt.current[n]=i.createRef())});for(var mt=0;mt<Math.max(Hn.length,zn.length);mt+=1)st.current[mt]||(st.current[mt]=i.createRef()),vt.current[mt]||(vt.current[mt]=i.createRef()),ft.current[mt]||(ft.current[mt]=i.createRef()),ht.current[mt]||(ht.current[mt]=i.createRef()),pt.current[mt]||(pt.current[mt]=i.createRef());c(function(){if(Sn){var e=gn.fields.find(function(e){return e.analysisKey===Sn||e.key===Sn});if(e){var n=at.current[e.key]||dt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Sn,gn.fields]);var yt=u(function(e){var n,t,i,r,o,l,c,u,a,d=null===(n=null==Ln?void 0:Ln.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!d||!d[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[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===(o=null===(r=null==s?void 0:s.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var f=s.mappings[0]||{};return{score:s.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=f.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===(a=s.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[Ln]),bt=u(function(n){var t,i,r,o,l=Hn[n],c=zn[n],u=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,a=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,d=F(null==l?void 0:l.id)||F(null==c?void 0:c.id)||"",s=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!u&&!a&&!s)return e(e({},gn.relationStyles.noContent),{label:"Not Defined"});var v=yt("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=Ke[d])||void 0===r?void 0:r.relevance_score:void 0)){var f=C(),h=f.score,p=f.relation;return R(h,p,!0,gn)}var x=u?l.relation:a?c.relation:v.relation,g=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==c?void 0:c.score,m="number"==typeof g?g:v.score;return R(m,x,!0,gn)},[Hn,zn,Ke,gn,yt]),wt=u(function(){var e,n,t,i,r,o,l,c,u,a,d;if(!vn.current&&!We.current){vn.current=!0;try{if(!Un.current)return;var s=function(e){var n=e.split("-"),t=n[0];if(!En[t])return!1;for(var i=t,r=1;r<n.length-1;r++)if(i+="-".concat(n[r]),!_n[i])return!1;return!0},v=Un.current.getBoundingClientRect();Qe({width:v.width,height:v.height});var f=[];if(ut.forEach(function(e){var n,t,i=e.key,r=null===(n=at.current[i])||void 0===n?void 0:n.current,o=null===(t=dt.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!ae&&!We.current){for(var h=0;h<Math.min(Hn.length,zn.length);h++){var p=null===(e=st.current[h])||void 0===e?void 0:e.current,x=null===(n=vt.current[h])||void 0===n?void 0:n.current;p&&x&&(p.style.height="auto",x.style.height="auto",p.style.minHeight="0px",x.style.minHeight="0px")}Object.keys(xt.current).forEach(function(e){var n,t;if(s(e)){var i=null===(n=xt.current[e])||void 0===n?void 0:n.current,r=null===(t=gt.current[e])||void 0===t?void 0:t.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var g={};ut.forEach(function(e){var n,t,i=e.key,r=null===(n=at.current[i])||void 0===n?void 0:n.current,o=null===(t=dt.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();g[i]=Math.max(l.height,c.height)}});var m=[],y={};if(!ae&&!We.current){for(h=0;h<Math.min(Hn.length,zn.length);h++){p=null===(t=st.current[h])||void 0===t?void 0:t.current,x=null===(i=vt.current[h])||void 0===i?void 0:i.current;var b=!!En[String(h)];if(p&&x&&b){var w=p.getBoundingClientRect(),I=x.getBoundingClientRect();m[h]=Math.max(w.height,I.height)}}Object.keys(xt.current).forEach(function(e){var n,t;if(s(e)){var i=null===(n=xt.current[e])||void 0===n?void 0:n.current,r=null===(t=gt.current[e])||void 0===t?void 0:t.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect();y[e]=Math.max(o.height,l.height)}}})}if(ut.forEach(function(e){var n,t,i=e.key,r=null===(n=at.current[i])||void 0===n?void 0:n.current,o=null===(t=dt.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=g[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!ae&&!We.current){for(h=0;h<m.length;h++){p=null===(r=st.current[h])||void 0===r?void 0:r.current,x=null===(o=vt.current[h])||void 0===o?void 0:o.current;if(p&&x&&m[h]){var S=m[h];p.style.minHeight="".concat(S,"px"),x.style.minHeight="".concat(S,"px")}}Object.keys(y).forEach(function(e){var n,t,i=null===(n=xt.current[e])||void 0===n?void 0:n.current,r=null===(t=gt.current[e])||void 0===t?void 0:t.current;if(i&&r&&y[e]){var o=y[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})}if(ut.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=at.current[i])||void 0===n?void 0:n.current,l=null===(t=dt.current[i])||void 0===t?void 0:t.current;if(o&&l){var c=o.getBoundingClientRect(),u=l.getBoundingClientRect(),a=yt(r),d=R(a.score,a.relation,a.hasContent,gn);if(!d)return;var s=c.top+c.height/2-v.top;f.push({id:"field-".concat(i),x1:c.right-v.left,y1:s,x2:u.left-v.left,y2:s,style:d})}}),ae)Hn.forEach(function(e,n){var t;(null===(t=st.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,c,u,a,d,s,h=zn.findIndex(function(n){return n.selfIndex===e});if(-1!==h){var p=null===(t=ft.current[n])||void 0===t?void 0:t.current,x=null===(i=ht.current[h])||void 0===i?void 0:i.current;if(p&&x){var g=p.getBoundingClientRect(),m=x.getBoundingClientRect(),y=g.right-v.left,b=m.left-v.left,w=g.top+g.height/2-v.top,I=m.top+m.height/2-v.top;if(we&&it===n){var S=null!==(o=null===(r=sn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,F=null!==(c=null===(l=un.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==c?c:0,E=S+(null!==(a=null===(u=sn.current)||void 0===u?void 0:u.clientHeight)&&void 0!==a?a:1/0),R=F+(null!==(s=null===(d=un.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),C=g.top+g.height/2,_=function(e,n,t){return Math.max(n,Math.min(t,e))};w=_(C,S,E)-v.top,I=_(C,F,R)-v.top}var T=bt(n);T&&f.push({id:"line-".concat(n,"-").concat(h),x1:y,y1:w,x2:b,y2:I,style:T,sectionIdx:n,targetRightIdx:h})}}})});else{for(h=0;h<Math.min(Hn.length,zn.length);h++){var E=null===(l=st.current[h])||void 0===l?void 0:l.current,_=null===(c=vt.current[h])||void 0===c?void 0:c.current;if(E&&_){var T=E.getBoundingClientRect(),B=_.getBoundingClientRect(),k=(T.top+18-v.top+B.top+18-v.top)/2,D=(null===(u=zn[h])||void 0===u?void 0:u.id)||"sec-".concat(h),M=bt(h);M&&f.push({id:D,x1:T.right-v.left,y1:k,x2:B.left-v.left,y2:k,style:M,sectionIdx:h,hasCognitive:!!((null===(a=Hn[h])||void 0===a?void 0:a.cognitiveData)||(null===(d=zn[h])||void 0===d?void 0:d.cognitiveData)||D&&Ke[D])})}}Object.keys(xt.current).forEach(function(e){var n,t,i,r,o,l;if(s(e)){var c=null===(n=xt.current[e])||void 0===n?void 0:n.current,u=null===(t=gt.current[e])||void 0===t?void 0:t.current;if(c&&u&&null!==c.offsetParent&&null!==u.offsetParent){for(var a=c.getBoundingClientRect(),d=u.getBoundingClientRect(),h=(a.top+16-v.top+d.top+16-v.top)/2,p=e.split("-").map(Number),x=Hn[p[0]],g=zn[p[0]],m=1;m<p.length;m++)(null==x?void 0:x.subsections)&&(x=x.subsections[p[m]]),(null==g?void 0:g.subsections)&&(g=g.subsections[p[m]]);if(!x&&!g)return;var y=(null==x?void 0:x.relation)&&"not_defined"!==x.relation,b=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,w=F(null==x?void 0:x.id)||F(null==g?void 0:g.id)||"",I=!(!(null==x?void 0:x.cognitiveData)&&!(null==g?void 0:g.cognitiveData)),S=null;if(y||b||I){var E=null!==(r=null!==(i=null==x?void 0:x.cognitiveRelevanceScore)&&void 0!==i?i:null==g?void 0:g.cognitiveRelevanceScore)&&void 0!==r?r:w?null===(o=Ke[w])||void 0===o?void 0:o.relevance_score:void 0;if(null!=E){var _=C(E),T=_.score,B=_.relation;S=R(T,B,!0,gn)}else{B=y?x.relation:b?g.relation:"not_defined";var k=null!==(l=null==x?void 0:x.score)&&void 0!==l?l:null==g?void 0:g.score;S=R(T="number"==typeof k?k:0,B,!0,gn)}}else S={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE",label:"N/A"};S&&f.push({id:"subsec-".concat(e),x1:a.right-v.left,y1:h,x2:d.left-v.left,y2:h,style:S,sectionIdx:p[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:I||w&&Ke[w]})}}})}if(nt(f),Qn.current&&Zn.current){var A=Qn.current.getBoundingClientRect(),H=Zn.current.getBoundingClientRect(),z=(A.top+A.height/2-v.top+H.top+H.height/2-v.top)/2;ct({x1:A.right-v.left,x2:H.left-v.left,y:z})}else ct(null);if(ae&&ke.size>0){var W=[],N=sn.current,O=un.current;if(N&&O){var j=[],P=N.getBoundingClientRect().top,Y=O.getBoundingClientRect().top,K=P+N.clientHeight,q=Y+O.clientHeight,X=N.scrollTop,V=O.scrollTop,U=v.top,J=function(e,n,t){return Math.max(n,Math.min(t,e))};ke.forEach(function(e){var n,t=Hn[e];(null===(n=null==t?void 0:t.refIndexes)||void 0===n?void 0:n.length)&&t.refIndexes.forEach(function(n){var t,i,r=zn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=ft.current[e])||void 0===t?void 0:t.current,l=null===(i=ht.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),u=l.getBoundingClientRect(),a=bt(e),d=c.right-v.left,s=u.left-v.left,f=(d+s)/2,h=c.top+c.height/2,p=u.top+u.height/2,x=h-P+X,g=p-Y+V,m="conn-".concat(e,"-").concat(r);j.push({lhsScrollY:x,rhsScrollY:g,x1:d,x2:s,containerTop:U,leftIdx:e,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:m});var y=J(h,P,K),b=J(p,Y,q),w=y-U,I=b-U,S=h>=P-4&&h<=K+4,F=p>=Y-4&&p<=q+4,E="";E=S&&F?L(d,w,s,I):S&&!F?"M ".concat(d,",").concat(w," L ").concat(f,",").concat(w," L ").concat(f,",").concat(I):!S&&F?"M ".concat(f,",").concat(w," L ").concat(f,",").concat(I," L ").concat(s,",").concat(I):"M ".concat(f,",").concat(w," L ").concat(f,",").concat(I),W.push({id:m,pathD:E,style:a,leftIdx:e,rhsArrayIdx:r})}}})}),Oe.current=j}He(W)}else He([]),Oe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{vn.current=!1}}},[ut,Hn,zn,Ke,gn,yt,bt,ae,we,it,ke,En,_n]),It=u(function(){var e,n,t,i,r,o,l,c,u,a,d,s,v,f,h=Oe.current;if(h.length&&!We.current){var p=null!==(n=null===(e=sn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=un.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,g=null!==(o=null===(r=sn.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(c=null===(l=un.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,y=null!==(a=null===(u=sn.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==a?a:0,b=null!==(s=null===(d=un.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,w=y+g,I=b+m,S=null!==(f=null===(v=Un.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,F=function(e,n,t){return Math.max(n,Math.min(t,e))};h.forEach(function(e){var n=e.lhsScrollY-p+y,t=e.rhsScrollY-x+b,i=Ne.current[e.styleId+"-stroke"],r=Ne.current[e.styleId+"-bg"];if(i||r){var o,l=F(n,y,w),c=F(t,b,I),u=l-S,a=c-S,d=n>=y-4&&n<=w+4,s=t>=b-4&&t<=I+4,v=(e.x1+e.x2)/2;o=d&&s?L(e.x1,u,e.x2,a):d&&!s?"M ".concat(e.x1,",").concat(u," L ").concat(v,",").concat(u," L ").concat(v,",").concat(a):!d&&s?"M ".concat(v,",").concat(u," L ").concat(v,",").concat(a," L ").concat(e.x2,",").concat(a):"M ".concat(v,",").concat(u," L ").concat(v,",").concat(a),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),St=l(wt);c(function(){St.current=wt},[wt]);var Ft=l(null),Et=u(function(){null!==Ft.current&&clearTimeout(Ft.current),Ft.current=setTimeout(function(){St.current(),Ft.current=null},50)},[]),Rt=u(function(e){var n,t,i,r,o;if(!Re.current){if(Pe.current){var l=Ye.current,c=Jn.current,u=sn.current,a=un.current;if(null!==l&&null!==c&&u&&a){var d=null===(n=jn.current[l])||void 0===n?void 0:n.current,s=null===(t=pt.current[c])||void 0===t?void 0:t.current;if(d&&s){if(e.currentTarget===u){var v=d.offsetTop-u.scrollTop,f=Math.max(0,s.offsetTop-v);Math.abs(a.scrollTop-f)>1&&(a.scrollTop=f)}else if(e.currentTarget===a){var h=s.offsetTop-a.scrollTop,p=Math.max(0,d.offsetTop-h);Math.abs(u.scrollTop-p)>1&&(u.scrollTop=p)}if(Gn.current){var x=null===(i=ft.current[l])||void 0===i?void 0:i.current,g=null!==(o=null===(r=Un.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,m=u.getBoundingClientRect().top,y=m+u.clientHeight,b=a.getBoundingClientRect().top,w=b+a.clientHeight,I=function(e,n,t){return Math.max(n,Math.min(t,e))};if(x){var S=x.getBoundingClientRect(),F=S.top+S.height/2,E=I(F,m,y),R=I(F,b,w);Gn.current.setAttribute("y1",(E-g).toString()),Gn.current.setAttribute("y2",(R-g).toString());var C=F>=m-4&&F<=y+4;Gn.current.setAttribute("visibility",C?"visible":"hidden")}}}}}Oe.current.length>0&&!je.current&&(je.current=!0,requestAnimationFrame(function(){It(),je.current=!1}))}},[It]);c(function(){var e=setTimeout(Et,250);window.addEventListener("resize",Et);var n=null,t=null;return ln.current&&(n=new ResizeObserver(Et)).observe(ln.current),Un.current&&(t=new ResizeObserver(Et)).observe(Un.current),function(){clearTimeout(e),window.removeEventListener("resize",Et),null==n||n.disconnect(),null==t||t.disconnect()}},[yn,Bn,Ln,ut,En,_n,Hn,zn,gn,Et,we,it,Fe,ke]),c(function(){Pe.current=we},[we]),c(function(){Ye.current=it},[it]);var Ct=u(function(){var e=rn.sectionIdx;pn(),null!==e&&(we&&it===e?Yn():(De(new Set),He([]),Oe.current=[],xe(!0),Re.current=!0,rt(e),Ye.current=e,Ie(!0),Pe.current=!0,Ee(!1),an.current&&(an.current.style.height="0px"),dn.current&&(dn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=jn.current[e])||void 0===n?void 0:n.current,r=Hn[e],o=(null==r?void 0:r.refIndexes)||[],l=null,c=-1;if(o.length>0){var u=o[0];c=zn.findIndex(function(e){return e.selfIndex===u}),l=null===(t=pt.current[c])||void 0===t?void 0:t.current}Jn.current=-1!==c?c:null;var a=sn.current,d=un.current;if(!i||!a)return Re.current=!1,void xe(!1);var s=i.offsetTop-a.scrollTop;if(!l||!d)return Ee(!0),St.current(),Re.current=!1,void xe(!1);var v=l.offsetTop-s;v<0&&an.current&&(an.current.style.height="".concat(Math.abs(v),"px"));requestAnimationFrame(function(){var e,n=d.scrollHeight-d.clientHeight;if(v<0)e=0;else{if(v>n){var t=v-n;return dn.current&&(dn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){j(d,v,200,function(){Ee(!0),St.current(),Re.current=!1,xe(!1)})})}e=v}j(d,e,200,function(){Ee(!0),St.current(),Re.current=!1,xe(!1)})})})))},[pn,rn.sectionIdx,we,it,Hn,zn,Et,Yn]),_t=null!==rn.sectionIdx&&ke.has(rn.sectionIdx),Tt=function(r){var o,l=r.section,c=r.idx,u=r.columnKey,s=r.colRef,v=r.mb,f=void 0===v?1:v,h=r.parentNodeId,b=void 0===h?"":h,w=ae?!!En["".concat(u,"-").concat(c)]:!!En[String(c)],I=E(l.title),S=E(l.content),R=!I&&!S,C=l.title;return I||(C=S?"No Title Found":"No Matching Section Found"),n(d,e({ref:s,sx:e(e({mb:f},ae?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:t(x,e({disableGutters:!0,expanded:!R&&w,onChange:function(){return!R&&function(n,t){var i,r;if(We.current=!0,Le.current&&clearTimeout(Le.current),ze.current&&(ze.current.style.opacity="0"),!ae){var o=null===(i=st.current[n])||void 0===i?void 0:i.current,l=null===(r=vt.current[n])||void 0===r?void 0:r.current;o&&l&&(o.style.minHeight="0px",l.style.minHeight="0px")}Le.current=setTimeout(function(){We.current=!1,St.current(),ze.current&&(ze.current.style.opacity="1")},350),Rn(function(i){var r=e({},i);if(!ae){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),c=!i[l];if(r[l]=c,"left"===t)((null==(u=Hn[n])?void 0:u.refIndexes)||[]).forEach(function(e){var n=zn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=c)});else{var u,a=null==(u=zn[n])?void 0:u.selfIndex;Hn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(a))&&(r["left-".concat(n)]=c)})}return r})}(c,u)},sx:{boxShadow:"none",border:R?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:R?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n(g,e({expandIcon:R?null:n(y,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:R?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"flex",alignItems:"center",overflow:"hidden"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:n(p,e({title:C,placement:"top"},{children:n(a,e({sx:{fontSize:"12px",color:R?"#94A3B8":"#19213D",fontWeight:R?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(o=C,o?F(o).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n("strong",{children:e.slice(2,-2)},t):n(i.Fragment,{children:e},t)}):null)}))}))})),!R&&t(m,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n(W,{content:l.content,sxStyles:Ze,highlights:function(){var e,n;if(!(null===(e=l.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=l.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][b];o&&i.push(o)}return i}()}),(l.subsections||[]).map(function(e,n){return Bt(e,"".concat(c,"-").concat(n),0,u)})]}))]}))}),"".concat(u,"-sec-").concat(c))},Bt=function(r,o,l,c){void 0===l&&(l=0),void 0===c&&(c="left");var u=E(r.title),s=E(r.content),v=!u&&!s,f=u?r.title:s?"No Title Found":"No Matching Section Found",h=!!_n[o];"left"!==c||xt.current[o]||(xt.current[o]=i.createRef()),"right"!==c||gt.current[o]||(gt.current[o]=i.createRef());var p="left"===c?xt.current[o]:gt.current[o];return r.title?n(d,e({ref:p,sx:{mt:1,width:"100%",position:"relative"}},{children:t(x,e({disableGutters:!0,expanded:!v&&h,onChange:function(){return!v&&Tn(function(n){var t;return e(e({},n),((t={})[o]=!n[o],t))})},sx:{mt:0,boxShadow:"none",border:v?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF","&:before":{display:"none"}}},{children:[n(g,e({expandIcon:v?null:n(y,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:n(a,e({sx:{fontSize:"11px",fontWeight:600,color:v?"#94A3B8":"#19213D"}},{children:f||"Untitled Subsection"}))})),!v&&t(m,e({sx:{pt:0,pb:1}},{children:[s&&n(a,e({component:"div",sx:Ze},{children:n(S,{children:F(r.content).replace(/\\n/g,"\n")})})),(r.subsections||[]).map(function(e,n){return Bt(e,"".concat(o,"-").concat(n),l+1,c)})]}))]}))}),o):n(d,e({ref:p,sx:{mt:0===l?1:.75,width:"100%"}},{children:!v&&t("div",{children:[s&&n(a,e({component:"div",sx:Ze},{children:n(S,{children:F(r.content).replace(/\\n/g,"\n")})})),(r.subsections||[]).map(function(e,n){return Bt(e,"".concat(o,"-").concat(n),l+1,c)})]})}),o)};return t(d,e({ref:cn,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ae?{}:{overflow:"visible"}),{position:"relative"})},{children:[ve&&n(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:n(H,{})})),ae&&n(A,{open:rn.open,anchorEl:rn.anchorEl,sectionTitle:rn.sectionTitle,referenceSectionTitle:rn.refSectionTitle,onClose:pn,onOpenCognitiveCompare:Xn,onOpenSideBySide:Ct,onConnect:Vn,isConnected:_t}),en.open&&n(M,{open:en.open,popupRef:Ue,position:Xe,popupConfig:oe,onClose:function(){Ve(null),nn(function(n){return e(e({},n),{open:!1})}),Te(null)},markdownStyles:te,sectionTitle:en.sectionTitle,referenceSectionTitle:en.refSectionTitle,cognitiveData:en.cognitiveData,anchorEl:en.anchorEl,sectionAnchorEl:en.sectionAnchorEl,scrollContainerEl:ln.current,badgeStyle:en.badgeStyle,docData:en.docData,deviationData:en.deviationData}),n(s,e({open:!!me,autoHideDuration:8e3,onClose:function(){return ye(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n(v,e({onClose:function(){return ye(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:me}))})),t(d,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n(d,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:n(a,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:Q}))})),n(d,e({sx:{display:"flex",alignItems:"center"}},{children:n(f,{control:n(h,{checked:ae,onChange:function(e){var n=e.target.checked;fe(!0),setTimeout(function(){de(n),Yn(),De(new Set),He([]),Oe.current=[],setTimeout(function(){fe(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#1976d2",opacity:1,border:0,"&::before":{content:'"Relative Order"',position:"absolute",left:"7px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px"}}}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#9e9e9e",opacity:1,position:"relative","&::after":{content:'"Default View"',position:"absolute",right:"13px",top:"50%",transform:"translateY(-50%)",fontSize:"9px",fontWeight:700,color:"#fff",letterSpacing:"0.3px",opacity:1,transition:"opacity 0.2s"}},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{"&::after":{opacity:0}}}}),label:"",labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n(d,e({ref:ln,onScroll:Rt,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ae?"hidden":"auto",borderTop:Nn&&On?"none":"1.5px solid #EEF0F4"}},{children:n(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ae?{flex:1,minHeight:0}:{})},{children:t(d,e({ref:Un,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ae?{flex:1,overflow:"visible"}:{})},{children:[t("svg",e({ref:ze,style:{position:"absolute",top:0,left:0,width:Ge.width||"100%",height:Ge.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[lt&&t("g",{children:[n("line",{x1:lt.x1,y1:lt.y,x2:Math.max(lt.x1,(lt.x1+lt.x2)/2-70),y2:lt.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n("line",{x1:Math.min(lt.x2,(lt.x1+lt.x2)/2+70),y1:lt.y,x2:lt.x2,y2:lt.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),et.map(function(i){var r,o=(i.x1+i.x2)/2;if("Not Defined"===i.style.label&&!i.hasCognitive)return null;if(!ae)return t("g",{children:[n("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n("foreignObject",e({x:o-100,y:i.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,e({onClick:function(e){if(e.stopPropagation(),en.open&&_e===i.id)hn();else{var n=Hn[i.sectionIdx]||{title:"",content:""},t=zn[i.sectionIdx]||{title:"",content:""};if(i.isSubSection&&i.subSectionKeyPath){for(var r=i.subSectionKeyPath.split("-").map(Number),o=Hn[r[0]],l=zn[r[0]],c=1;c<r.length;c++)(null==o?void 0:o.subsections)&&(o=o.subsections[r[c]]),(null==l?void 0:l.subsections)&&(l=l.subsections[r[c]]);o&&(n=o),l&&(t=l)}Te(i.id),qn(Kn(e.currentTarget,n,t,i.sectionIdx,i.style))}},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:i.style.badgeBg,color:i.style.badgeText,border:"1px solid ".concat(i.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[i.style.label,n(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n(w,{})})),n(y,{size:11,style:{transform:en.open&&_e===i.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},i.id);var l=Hn[i.sectionIdx];return!(null===(r=null==l?void 0:l.refIndexes)||void 0===r?void 0:r.length)||(null==l?void 0:l.selfIndex)<0?null:we&&it===i.sectionIdx&&Fe?t("g",e({style:{transition:"opacity 0.2s"}},{children:[n("defs",{children:n("marker",e({id:"arr-".concat(i.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n("polygon",{points:"0 0, 7 2.5, 0 5",fill:i.style.badgeBorder||"#6366F1"})}))}),n("line",{ref:Gn,x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(i.id,")")})]}),i.id):null}),Ae.map(function(i){var r,o=i.pathD,l=(null===(r=i.style)||void 0===r?void 0:r.badgeBorder)||"#6366F1",c="conn-marker-".concat(i.id),u="".concat(i.id,"-bg"),a="".concat(i.id,"-stroke");return t("g",{children:[n("defs",{children:n("clipPath",e({id:"connections-clip"},{children:n("marker",e({id:c,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n("polygon",{points:"0 0, 8 3, 0 6",fill:l})}))}))}),n("path",{ref:function(e){Ne.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n("path",{ref:function(e){Ne.current[a]=e},d:o,fill:"none",stroke:l,strokeWidth:"1.75",markerEnd:"url(#".concat(c,")")})]},i.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)"},ae?{flex:1,overflow:"visible"}:{})},{children:[n(d,e({ref:Qn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:n(p,e({title:Mn,placement:"top"},{children:n(a,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:Mn}))}))})),n(d,e({ref:sn,onScroll:Rt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ae?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:Wn&&Hn.map(function(r,o){var l,c,u;if(!ae)return n(d,e({ref:Pn(o)},{children:Tt({section:r,idx:o,columnKey:"left",colRef:st.current[o],parentNodeId:(null===(l=null==Z?void 0:Z.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(o));var a=r,s=bt(o),v=!(null===(c=a.refIndexes)||void 0===c?void 0:c.length)||a.selfIndex<0,f="number"==typeof a.selfIndex&&a.selfIndex>=0?a.selfIndex+1:null,h=ke.has(o);return n(d,e({ref:Pn(o),sx:{mb:1}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[n(d,e({ref:st.current[o],sx:e({width:"100%"},h&&{borderRadius:"6px",outline:"2px solid ".concat((null==s?void 0:s.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:Tt({section:r,idx:o,columnKey:"left",colRef:i.createRef(),mb:0,parentNodeId:(null===(u=null==Z?void 0:Z.input_index_map)||void 0===u?void 0:u[0])||""})})),s&&t(d,e({ref:ft.current[o],onClick:function(e){var n=zn.find(function(e){var n;return null===(n=a.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};!function(e,n,t,i,r){e.stopPropagation(),rn.open&&rn.sectionIdx===i?pn():(hn(),on(Kn(e.currentTarget,n,t,i,r)))}(e,r,n,o,s)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:s.badgeBg,color:s.badgeText,border:"1px solid ".concat(s.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(d,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(s.badgeBorder)}},{children:f})),n(d,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:v?"No Deviation Found":0==s.deviationLabel||void 0===s.deviationLabel?"Same":"".concat(s.deviationLabel,"% Deviation")})),n(b,{size:11,color:s.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),n(d,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:n(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,e({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[n(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n(w,{})})),0,"% Similarity",n(y,{size:11})]}))}))})),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},ae?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[pe&&n(I,{sections:11}),n(d,e({ref:Zn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n(p,e({title:An,placement:"top"},{children:n(a,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:An}))}))})),t(d,e({ref:un,onScroll:Rt,sx:e({p:"12px",display:"flex",flexDirection:"column"},ae?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n("div",{ref:an,style:{width:"100%",height:"0px",flexShrink:0}}),Wn&&zn.map(function(r,o){var l,c;if(!ae)return Tt({section:r,idx:o,columnKey:"right",colRef:vt.current[o],parentNodeId:(null===(l=null==Z?void 0:Z.input_index_map)||void 0===l?void 0:l[1])||""});var u=r,a=Hn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(u.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=Hn.some(function(e,n){var t;return ke.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u.selfIndex))}),v=Hn.findIndex(function(e,n){var t;return ke.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(u.selfIndex))}),f=-1!==v?bt(v):null;return n(d,e({ref:pt.current[o],sx:{mb:1}},{children:t(d,e({sx:{position:"relative",width:"100%"}},{children:[n(d,e({ref:vt.current[o],sx:e({width:"100%"},s&&f&&{borderRadius:"6px",outline:"2px solid ".concat(f.badgeBorder),outlineOffset:"1px"})},{children:Tt({section:r,idx:o,columnKey:"right",colRef:i.createRef(),mb:0,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[1])||""})})),!pe&&n(d,e({ref:ht.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n("div",{ref:dn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{P as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAyC,CAAA;AAEnF,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"CommonConstants.d.ts","sourceRoot":"","sources":["../../../../src/CommonConstants/CommonConstants.tsx"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,aAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,aAAuB,CAAC;AAChD,eAAO,MAAM,6BAA6B,yCAAyC,CAAA;AAEnF,eAAO,MAAM,iBAAiB,EAAE,GAoT7B,CAAA;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiM1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAIL,qBAAqB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAIL,qBAAqB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AA+UlC,QAAA,MAAM,gBAAgB,qMAUnB,qBAAqB,4CA0kFvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
|