@viswa-test/test-citation 0.0.23 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),r=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("react-markdown"),s=require("./CognitiveComparehelpers.js"),a=require("./CognitiveCompareConfig.js"),c=require("./CognitivePopup.js"),u=require("./MoreFunctionsPopup.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(t),x=d(l),p={id:"",title:""},v={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null};exports.SHARED_MARKDOWN_STYLES=a.SHARED_MARKDOWN_STYLES,exports.default=function(l){var d,g,h,_,m,y,b,S,F=l.componentHeaderText,E=void 0===F?"Learning Comparison":F,w=l.treeData,I=l.comparisonConfig,j=l.leftColumnTitleText,C=l.rightColumnTitleText,R=l.markdownStyles,B=l.maintainRelativeOrder,T=void 0!==B&&B,D=l.popupConfig,A=t.useState(null),k=A[0],O=A[1],M=t.useState(!1),N=M[0],L=M[1],z=t.useState(!1),H=z[0],W=z[1],P=t.useRef(!1),q=t.useMemo(function(){return(null==w?void 0:w.cognitive_decisioning)||{}},[w]),V=t.useState(null),U=V[0],G=V[1],Y=t.useRef(null),X=t.useState({width:0,height:0}),K=X[0],J=X[1],Q=t.useMemo(function(){return e.__assign(e.__assign({},a.SHARED_MARKDOWN_STYLES),R)},[R]),Z=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),$=Z[0],ee=Z[1],ne=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),te=ne[0],ie=ne[1],re=t.useRef(null),oe=t.useRef(null),le=t.useRef(!1),se=t.useRef(null);t.useEffect(function(){se.current=null},[$.sectionIdx,$.open]);var ae=t.useCallback(function(){G(null),ee(v)},[]),ce=t.useCallback(function(){ie(v)},[]),ue=t.useCallback(function(){var e;if($.anchorEl&&$.refSectionTitle){var n=$.anchorEl.getBoundingClientRect(),t=(null===(e=null==Y?void 0:Y.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!==se.current?!0===se.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),se.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)),x=Math.max(14,Math.min(u-f,i-10-4));G({top:c,left:f,arrowLeft:x,openAbove:l,maxHeight:s})}},[$.anchorEl,$.refSectionTitle]);t.useEffect(function(){if($.open){window.addEventListener("resize",ue);var e=requestAnimationFrame(ue),n=null;return Y.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(ue)})).observe(Y.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",ue),n&&n.disconnect()}}},[$.open,ue]),t.useEffect(function(){var e=re.current;if(e&&$.open){var n=function(e){Y.current&&Y.current.contains(e.target)||(G(null),ae())};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})}}},[$.open,ae]),t.useEffect(function(){var e=re.current;if(e&&te.open){var n=function(){ce()};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})}}},[te.open,ce]);var de=t.useMemo(function(){var n,t,i,r,o,l,s,c,u,d,f,x;return{fields:null!==(n=null==I?void 0:I.fields)&&void 0!==n?n:a.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==I?void 0:I.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:a.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==I?void 0:I.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:a.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==I?void 0:I.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:a.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(c=null==I?void 0:I.relationStyles)||void 0===c?void 0:c.noContent)||{}),high:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==I?void 0:I.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==I?void 0:I.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(f=null==I?void 0:I.relationStyles)||void 0===f?void 0:f.medium)||{}),low:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(x=null==I?void 0:I.relationStyles)||void 0===x?void 0:x.low)||{})}}},[I]),fe=t.useMemo(function(){if(w&&Object.keys(w).length>0)try{var n=function(n,t){var i,r,o,l,a,c,u,d;void 0===t&&(t=!1);var f=[],x=[],p=n.base_root_id,v=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 h=function(t,i){var r=n[t];if(!r)return null;var o=s.getSideData(r,i,v),l=!!o.title.trim(),a=!!o.content.trim(),c=s.getRationale(r),u=[];r.next&&Object.values(r.next).forEach(function(e){if(n[e]){var t=h(e,i);t&&u.push(t)}});var d=!(!l&&!a);return e.__assign({id:t,title:l?o.title:"",content:a?o.content:"",subsections:u},d?c:{score:void 0,relation:"not_defined"})};if(t){var _={},m={},y=-1,b=-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=s.getRationale(F),w=s.getSideData(F,"0",v),I=s.getSideData(F,"1",v),j=w.title.trim()||w.content.trim(),C=I.title.trim()||I.content.trim(),R=Number(null!==(r=null===(i=w.attributes)||void 0===i?void 0:i.display_index)&&void 0!==r?r:y--),B=Number(null!==(l=null===(o=I.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:b--),T=m[B]||e.__assign(e.__assign({id:S,title:C?I.title:"",content:C?I.content:"",subsections:[]},C?E:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:B}),D=_[R]||e.__assign(e.__assign({id:S,title:j?w.title:"",content:j?w.content:"",subsections:[]},j?E:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:R});Number(B)>=0&&Number(R)>=0&&(T.refIndexes.includes(Number(R))||T.refIndexes.push(Number(R)),D.refIndexes.includes(Number(B))||D.refIndexes.push(Number(B))),m[B]=T,_[R]=D}}x=Object.values(m).map(function(e){return e}),f=Object.values(_).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}),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(h(e,"0")||{id:e,title:"",content:"",subsections:[]}),x.push(h(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(c=null===(a=g.comparison_inputs)||void 0===a?void 0:a[v[0]])||void 0===c?void 0:c.title)||"Uploaded Contract",description:g.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(d=null===(u=g.comparison_inputs)||void 0===u?void 0:u[v[1]])||void 0===d?void 0:d.title)||"Reference Template",similarity:0,sections:x,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:g.decision_scope_description||""},fields:{}}}}]}}(w,T);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"}},[w,T]),xe=fe.activeProposed,pe=fe.activeVariants,ve=fe.parseError;t.useEffect(function(){ve&&O("Failed to load comparison: ".concat(ve))},[ve]);var ge=t.useState(null),he=ge[0];ge[1];var _e=t.useState({}),me=_e[0],ye=_e[1],be=t.useState({}),Se=be[0],Fe=be[1],Ee=(null==pe?void 0:pe[0])||p,we=null===(h=null===(d=null==w?void 0:w.documents)||void 0===d?void 0:d[null===(g=null==w?void 0:w.input_index_map)||void 0===g?void 0:g[0]])||void 0===h?void 0:h.title,Ie=null===(y=null===(_=null==w?void 0:w.documents)||void 0===_?void 0:_[null===(m=null==w?void 0:w.input_index_map)||void 0===m?void 0:m[1]])||void 0===y?void 0:y.title,je=s.safeStringify(j||we||"Uploaded Contract"),Ce=s.safeStringify(C||Ie||"Reference Template"),Re=t.useMemo(function(){return(null==xe?void 0:xe.sections)||[]},[null==xe?void 0:xe.sections]),Be=t.useMemo(function(){return Ee.sections||[]},[Ee.sections]),Te=Re.length>0||Be.length>0,De=Ee.analysis,Ae=s.safeStringify(null===(S=null===(b=null==De?void 0:De.rule_difference_comparison)||void 0===b?void 0:b.summary)||void 0===S?void 0:S.overall_summary),ke=!!Ae.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Oe=t.useRef({}),Me=function(e){return Oe.current[e]||(Oe.current[e]=f.default.createRef()),Oe.current[e]},Ne=t.useCallback(function(e,n,t,i,r){var o,l,a=s.safeStringify(n.id)||s.safeStringify(t.id)||"",c=(a?q[a]:null)||n.cognitiveData||t.cognitiveData||{section_id:a,decisioning:[],gap:[],relevance_score:0},u=null!==(l=null===(o=Oe.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==w?void 0:w.documents,input_index_map:null==w?void 0:w.input_index_map}}},[q]),Le=t.useCallback(function(e){ce(),G(null),ee(e)},[ce]),ze=t.useCallback(function(){null!==te.sectionIdx&&te.anchorEl?Le(e.__assign(e.__assign({},te),{open:!0})):ce()},[te,ce,Le]);t.useCallback(function(e){ce(),O("".concat(e," is coming soon."))},[ce]);var He=t.useRef(null),We=t.useRef(null),Pe=t.useRef(null),qe=t.useState([]),Ve=qe[0],Ue=qe[1],Ge=t.useState(null),Ye=Ge[0],Xe=Ge[1],Ke=t.useRef(null),Je=t.useState(null),Qe=Je[0],Ze=Je[1],$e=t.useCallback(function(){var e=te.sectionIdx;ce(),null!==e&&(N&&Ye===e?(L(!1),Xe(null),W(!1)):(P.current=!0,Xe(e),L(!0),W(!1),setTimeout(function(){var n,t=null===(n=Oe.current[e])||void 0===n?void 0:n.current;t&&t.scrollIntoView({behavior:"smooth",block:"center"})},50),setTimeout(function(){W(!0),P.current=!1},600)))},[ce,te.sectionIdx,N,Ye]),en=t.useMemo(function(){return de.fields.filter(function(e){var n=e.key;return(!Te||"description"!==n)&&(s.hasValue(null==xe?void 0:xe[n])||s.hasValue(Ee[n]))})},[xe,Ee,Te,de.fields]),nn=t.useRef({}),tn=t.useRef({}),rn=t.useRef({}),on=t.useRef({}),ln=t.useRef({}),sn=t.useRef({}),an=t.useRef({});en.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Re.length,Be.length);t+=1)rn.current[t]||(rn.current[t]=f.default.createRef()),on.current[t]||(on.current[t]=f.default.createRef()),ln.current[t]||(ln.current[t]=f.default.createRef()),sn.current[t]||(sn.current[t]=f.default.createRef()),an.current[t]||(an.current[t]=f.default.createRef());nn.current[n]||(nn.current[n]=f.default.createRef()),tn.current[n]||(tn.current[n]=f.default.createRef())});for(var cn=0;cn<Math.max(Re.length,Be.length);cn+=1)rn.current[cn]||(rn.current[cn]=f.default.createRef()),on.current[cn]||(on.current[cn]=f.default.createRef()),ln.current[cn]||(ln.current[cn]=f.default.createRef()),sn.current[cn]||(sn.current[cn]=f.default.createRef()),an.current[cn]||(an.current[cn]=f.default.createRef());t.useEffect(function(){if(he){var e=de.fields.find(function(e){return e.analysisKey===he||e.key===he});if(e){var n=nn.current[e.key]||tn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[he,de.fields]);var un=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==De?void 0:De.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 x=d.mappings[0]||{};return{score:d.score,relation:x.relation||"",highlightsA:(null===(l=x.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=x.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}},[De]),dn=t.useCallback(function(n){var t,i,r,o,l=Re[n],a=Be[n],c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,d=s.safeStringify(null==l?void 0:l.id)||s.safeStringify(null==a?void 0:a.id)||"",f=!(!(null==l?void 0:l.cognitiveData)&&!(null==a?void 0:a.cognitiveData));if(!c&&!u&&!f)return e.__assign(e.__assign({},de.relationStyles.noContent),{label:"Not Defined"});var x=un("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=q[d])||void 0===r?void 0:r.relevance_score:void 0)){var p=s.cognitiveScoreToRelation(),v=p.score,g=p.relation;return s.getStyleForRelation(v,g,!0,de)}var h=c?l.relation:u?a.relation:x.relation,_=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==a?void 0:a.score,m="number"==typeof _?_:x.score;return s.getStyleForRelation(m,h,!0,de)},[Re,Be,q,de,un]),fn=t.useCallback(function(){var e,n,t,i,r,o,l,a,c,u,d,f,x;if(!le.current){le.current=!0;try{if(!He.current)return;if(Object.values(Oe.current).forEach(function(e){e.current&&(e.current.style.paddingTop="0px",e.current.style.marginTop="0px")}),Object.values(an.current).forEach(function(e){e.current&&(e.current.style.paddingTop="0px",e.current.style.marginTop="0px")}),T&&N&&null!==Ye){var p=Re[Ye],v=(null==p?void 0:p.refIndexes)||[];if(v.length>0){var g=v[0],h=Be.findIndex(function(e){return e.selfIndex===g});if(-1!==h){var _=null===(e=Oe.current[Ye])||void 0===e?void 0:e.current,m=null===(n=an.current[h])||void 0===n?void 0:n.current;if(_&&m){var y=_.getBoundingClientRect().top-m.getBoundingClientRect().top;if(m.style.transition="padding-top 0.3s ease-in-out",y>1)m.style.paddingTop="".concat(y,"px");else if(y<-1){var b=m.parentElement;b&&(P.current=!0,b.scrollTo({top:b.scrollTop+Math.abs(y),behavior:"smooth"}),setTimeout(function(){P.current=!1},400))}}}}}var S=He.current.getBoundingClientRect();J({width:S.width,height:S.height});var F=[];if(en.forEach(function(e){var n,t,i=e.key,r=null===(n=nn.current[i])||void 0===n?void 0:n.current,o=null===(t=tn.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")}),!T)for(var E=0;E<Math.min(Re.length,Be.length);E++){var w=null===(t=rn.current[E])||void 0===t?void 0:t.current,I=null===(i=on.current[E])||void 0===i?void 0:i.current;w&&I&&(w.style.height="auto",I.style.height="auto",w.style.minHeight="0px",I.style.minHeight="0px")}var j={};en.forEach(function(e){var n,t,i=e.key,r=null===(n=nn.current[i])||void 0===n?void 0:n.current,o=null===(t=tn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),s=o.getBoundingClientRect();j[i]=Math.max(l.height,s.height)}});var C=[];if(!T)for(E=0;E<Math.min(Re.length,Be.length);E++){w=null===(r=rn.current[E])||void 0===r?void 0:r.current,I=null===(o=on.current[E])||void 0===o?void 0:o.current;if(w&&I){var R=w.getBoundingClientRect(),B=I.getBoundingClientRect();C[E]=Math.max(R.height,B.height)}}if(en.forEach(function(e){var n,t,i=e.key,r=null===(n=nn.current[i])||void 0===n?void 0:n.current,o=null===(t=tn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=j[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!T)for(E=0;E<C.length;E++){w=null===(l=rn.current[E])||void 0===l?void 0:l.current,I=null===(a=on.current[E])||void 0===a?void 0:a.current;if(w&&I){var D=C[E];w.style.minHeight="".concat(D,"px"),I.style.minHeight="".concat(D,"px")}}if(en.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=nn.current[i])||void 0===n?void 0:n.current,l=null===(t=tn.current[i])||void 0===t?void 0:t.current;if(o&&l){var a=o.getBoundingClientRect(),c=l.getBoundingClientRect(),u=un(r),d=s.getStyleForRelation(u.score,u.relation,u.hasContent,de);if(!d)return;var f=a.top+a.height/2-S.top;F.push({id:"field-".concat(i),x1:a.right-S.left,y1:f,x2:c.left-S.left,y2:f,style:d})}}),T)Re.forEach(function(e,n){var t;(null===(t=rn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r=Be.findIndex(function(n){return n.selfIndex===e});if(-1!==r){var o=null===(t=ln.current[n])||void 0===t?void 0:t.current,l=null===(i=sn.current[r])||void 0===i?void 0:i.current;if(o&&l){var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=s.right-S.left,u=a.left-S.left,d=s.top+s.height/2-S.top,f=a.top+a.height/2-S.top,x=dn(n);x&&F.push({id:"line-".concat(n,"-").concat(r),x1:c,y1:d,x2:u,y2:f,style:x,sectionIdx:n,targetRightIdx:r})}}})});else for(E=0;E<Math.min(Re.length,Be.length);E++){var A=null===(c=rn.current[E])||void 0===c?void 0:c.current,k=null===(u=on.current[E])||void 0===u?void 0:u.current;if(A&&k){var O=A.querySelector(".MuiAccordionSummary-root"),M=k.querySelector(".MuiAccordionSummary-root");if(O&&M){var L=O.getBoundingClientRect(),z=M.getBoundingClientRect(),H=(L.top+L.height/2-S.top+z.top+z.height/2-S.top)/2,W=(null===(d=Be[E])||void 0===d?void 0:d.id)||"sec-".concat(E),V=dn(E);V&&F.push({id:W,x1:L.right-S.left,y1:H,x2:z.left-S.left,y2:H,style:V,sectionIdx:E,hasCognitive:!!((null===(f=Re[E])||void 0===f?void 0:f.cognitiveData)||(null===(x=Be[E])||void 0===x?void 0:x.cognitiveData)||W&&q[W])})}}}if(Ue(F),We.current&&Pe.current){var U=We.current.getBoundingClientRect(),G=Pe.current.getBoundingClientRect(),Y=(U.top+U.height/2-S.top+G.top+G.height/2-S.top)/2;Ze({x1:U.right-S.left,x2:G.left-S.left,y:Y})}else Ze(null)}catch(e){console.error("Line render safe fail: ",e)}finally{le.current=!1}}},[en,Re,Be,q,de,un,dn,T,N,Ye,Se]),xn=t.useCallback(function(){null!==Ke.current&&window.cancelAnimationFrame(Ke.current),Ke.current=window.requestAnimationFrame(function(){fn(),Ke.current=null})},[fn]),pn=t.useCallback(function(){xn(),N&&!P.current&&(L(!1),Xe(null),W(!1))},[xn,N]);t.useEffect(function(){var e=setTimeout(xn,250);window.addEventListener("resize",xn);var n=null,t=null;return re.current&&(n=new ResizeObserver(xn)).observe(re.current),He.current&&(t=new ResizeObserver(xn)).observe(He.current),function(){clearTimeout(e),window.removeEventListener("resize",xn),null==n||n.disconnect(),null==t||t.disconnect()}},[xe,Ee,De,en,me,Re,Be,de,xn]);var vn=function(t,o,l,a,c){void 0===c&&(c=1);var u,d=T?!!me["".concat(l,"-").concat(o)]:!!me[String(o)],p=s.hasValue(t.title),v=s.hasValue(t.content),g=!p&&!v,h=t.title;return p||(h=v?"No Title Found":"No Matching Section Found"),n.jsx(i.Box,e.__assign({ref:a,sx:e.__assign(e.__assign({mb:c},T?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!g&&d,onChange:function(){return!g&&function(n,t){ye(function(i){var r=e.__assign({},i);if(!T){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=Re[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=Be.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=Be[n])?void 0:a.selfIndex;Re.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:g?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:g?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:g?null:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:g?"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:h,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"12px",color:g?"#94A3B8":"#19213D",fontWeight:g?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(u=h,u?s.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(f.default.Fragment,{children:e},t)}):null)}))}))})),!g&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(i.Typography,e.__assign({component:"div",sx:Q},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return gn(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},gn=function(t,o,l){void 0===l&&(l=0);var a=s.hasValue(t.title),c=s.hasValue(t.content),u=!a&&!c,d=a?t.title:c?"No Title Found":"No Matching Section Found",f=!!Se[o];return t.title?n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!u&&f,onChange:function(){return!u&&Fe(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:Q},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return gn(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:Q},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return gn(e,"".concat(o,"-").concat(n),l+1)})]})}),o)};return n.jsxs(i.Box,e.__assign({ref:oe,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},T?{}:{overflow:"visible"}),{position:"relative"})},{children:[T&&n.jsx(u.default,{open:te.open,anchorEl:te.anchorEl,sectionTitle:te.sectionTitle,referenceSectionTitle:te.refSectionTitle,onClose:ce,onOpenCognitiveCompare:ze,onOpenSideBySide:$e}),$.open&&n.jsx(c.default,{open:$.open,popupRef:Y,position:U,popupConfig:D,onClose:function(){G(null),ee(function(n){return e.__assign(e.__assign({},n),{open:!1})})},markdownStyles:R,sectionTitle:$.sectionTitle,referenceSectionTitle:$.refSectionTitle,cognitiveData:$.cognitiveData,anchorEl:$.anchorEl,sectionAnchorEl:$.sectionAnchorEl,scrollContainerEl:re.current,badgeStyle:$.badgeStyle,docData:$.docData}),n.jsx(i.Snackbar,e.__assign({open:!!k,autoHideDuration:8e3,onClose:function(){return O(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return O(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:k}))})),n.jsx(i.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{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:450,color:"#0F172A"}},{children:E}))}))})),n.jsx(i.Box,e.__assign({ref:re,onScroll:pn,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:T?"hidden":"auto",borderTop:Ae&&ke?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},T?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:He,sx:e.__assign({display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},T?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({style:{position:"absolute",top:0,left:0,width:K.width||"100%",height:K.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[Qe&&n.jsxs("g",{children:[n.jsx("line",{x1:Qe.x1,y1:Qe.y,x2:Math.max(Qe.x1,(Qe.x1+Qe.x2)/2-70),y2:Qe.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(Qe.x2,(Qe.x1+Qe.x2)/2+70),y1:Qe.y,x2:Qe.x2,y2:Qe.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Ve.map(function(t){var l,s=(t.x1+t.x2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!T)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){var n=Re[t.sectionIdx]||{title:"",content:""},i=Be[t.sectionIdx]||{title:"",content:""};Le(Ne(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})]}))}))}))]},t.id);var a=Re[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:N&&Ye===t.sectionIdx&&H?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",{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})]})),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)"},T?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:We,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:je,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:je}))}))})),n.jsx(i.Box,e.__assign({onScroll:pn,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},T?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:Te&&Re.map(function(t,o){var l;if(!T)return n.jsx(i.Box,e.__assign({ref:Me(o)},{children:vn(t,o,"left",rn.current[o])}),"left-row-".concat(o));var s=t,a=dn(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;return n.jsx(i.Box,e.__assign({ref:Me(o),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:rn.current[o],sx:{width:"100%"}},{children:vn(t,o,"left",f.default.createRef(),0)})),a&&n.jsxs(i.Box,e.__assign({ref:ln.current[o],onClick:function(e){var n=Be.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(),te.open&&te.sectionIdx===i?ce():(ae(),ie(Ne(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:"6px",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},T?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Pe,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:Ce,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:Ce}))}))})),n.jsx(i.Box,e.__assign({onScroll:pn,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},T?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:Te&&Be.map(function(t,r){if(!T)return vn(t,r,"right",on.current[r]);var o=t,l=Re.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});return n.jsx(i.Box,e.__assign({ref:an.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:on.current[r],sx:{width:"100%"}},{children:vn(t,r,"right",f.default.createRef(),0)})),n.jsx(i.Box,e.__assign({ref:sn.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))})}))]}))]}))}))}))]}))};
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("react-markdown"),s=require("./CognitiveComparehelpers.js"),a=require("./CognitiveCompareConfig.js"),c=require("./CognitivePopup.js"),u=require("./MoreFunctionsPopup.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(t),x=d(l),h={id:"",title:""},p={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},g=function(e,n,t,i){void 0===t&&(t=300);var r=e.style.scrollBehavior;e.style.scrollBehavior="auto";var o=e.scrollTop,l=n-o,s=null,a=function(c){null===s&&(s=c);var u,d=c-s;d<t?(e.scrollTop=(u=d,u/=t,l*(--u*u*u+1)+o),requestAnimationFrame(a)):(e.scrollTop=n,e.style.scrollBehavior=r,i&&i())};requestAnimationFrame(a)};exports.SHARED_MARKDOWN_STYLES=a.SHARED_MARKDOWN_STYLES,exports.default=function(l){var d,v,_,m,y,b,S,F,w=l.componentHeaderText,E=void 0===w?"Learning Comparison":w,I=l.treeData,j=l.comparisonConfig,C=l.leftColumnTitleText,R=l.rightColumnTitleText,B=l.markdownStyles,T=l.maintainRelativeOrder,A=void 0!==T&&T,D=l.popupConfig,k=t.useState(A),M=k[0],O=k[1],N=t.useState(null),H=N[0],L=N[1],z=t.useState(!1),W=z[0],q=z[1],P=t.useState(!1),U=P[0],V=P[1],G=t.useRef(!1),Y=t.useMemo(function(){return(null==I?void 0:I.cognitive_decisioning)||{}},[I]),X=t.useState(null),K=X[0],J=X[1],Q=t.useRef(null),Z=t.useState({width:0,height:0}),$=Z[0],ee=Z[1],ne=t.useMemo(function(){return e.__assign(e.__assign({},a.SHARED_MARKDOWN_STYLES),B)},[B]),te=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),ie=te[0],re=te[1],oe=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),le=oe[0],se=oe[1],ae=t.useRef(null),ce=t.useRef(null),ue=t.useRef(null),de=t.useRef(null),fe=t.useRef(null),xe=t.useRef(!1),he=t.useRef(null);t.useEffect(function(){he.current=null},[ie.sectionIdx,ie.open]);var pe=t.useCallback(function(){J(null),re(p)},[]),ge=t.useCallback(function(){se(p)},[]),ve=t.useCallback(function(){var e;if(ie.anchorEl&&ie.refSectionTitle){var n=ie.anchorEl.getBoundingClientRect(),t=(null===(e=null==Q?void 0:Q.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!==he.current?!0===he.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),he.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)),x=Math.max(14,Math.min(u-f,i-10-4));J({top:c,left:f,arrowLeft:x,openAbove:l,maxHeight:s})}},[ie.anchorEl,ie.refSectionTitle]);t.useEffect(function(){if(ie.open){window.addEventListener("resize",ve);var e=requestAnimationFrame(ve),n=null;return Q.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(ve)})).observe(Q.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",ve),n&&n.disconnect()}}},[ie.open,ve]),t.useEffect(function(){var e=ae.current;if(e&&ie.open){var n=function(e){Q.current&&Q.current.contains(e.target)||(J(null),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})}}},[ie.open,pe]),t.useEffect(function(){var e=ae.current;if(e&&le.open){var n=function(){ge()};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})}}},[le.open,ge]);var _e=t.useMemo(function(){var n,t,i,r,o,l,s,c,u,d,f,x;return{fields:null!==(n=null==j?void 0:j.fields)&&void 0!==n?n:a.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==j?void 0:j.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:a.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==j?void 0:j.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:a.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==j?void 0:j.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:a.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(c=null==j?void 0:j.relationStyles)||void 0===c?void 0:c.noContent)||{}),high:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==j?void 0:j.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==j?void 0:j.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(f=null==j?void 0:j.relationStyles)||void 0===f?void 0:f.medium)||{}),low:e.__assign(e.__assign({},a.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(x=null==j?void 0:j.relationStyles)||void 0===x?void 0:x.low)||{})}}},[j]),me=t.useMemo(function(){if(I&&Object.keys(I).length>0)try{var n=function(n,t){var i,r,o,l,a,c,u,d;void 0===t&&(t=!1);var f=[],x=[],h=n.base_root_id,p=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 v=function(t,i){var r=n[t];if(!r)return null;var o=s.getSideData(r,i,p),l=!!o.title.trim(),a=!!o.content.trim(),c=s.getRationale(r),u=[];r.next&&Object.values(r.next).forEach(function(e){if(n[e]){var t=v(e,i);t&&u.push(t)}});var d=!(!l&&!a);return e.__assign({id:t,title:l?o.title:"",content:a?o.content:"",subsections:u},d?c:{score:void 0,relation:"not_defined"})};if(t){var _={},m={},y=-1,b=-1;for(var S in n)if(!["base_root_id","documents","input_index_map",h].includes(S)){var F=n[S];if(F&&!1!==F.display_node){var w=s.getRationale(F),E=s.getSideData(F,"0",p),I=s.getSideData(F,"1",p),j=E.title.trim()||E.content.trim(),C=I.title.trim()||I.content.trim(),R=Number(null!==(r=null===(i=E.attributes)||void 0===i?void 0:i.display_index)&&void 0!==r?r:y--),B=Number(null!==(l=null===(o=I.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:b--),T=m[B]||e.__assign(e.__assign({id:S,title:C?I.title:"",content:C?I.content:"",subsections:[]},C?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:B}),A=_[R]||e.__assign(e.__assign({id:S,title:j?E.title:"",content:j?E.content:"",subsections:[]},j?w:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:R});Number(B)>=0&&Number(R)>=0&&(T.refIndexes.includes(Number(R))||T.refIndexes.push(Number(R)),A.refIndexes.includes(Number(B))||A.refIndexes.push(Number(B))),m[B]=T,_[R]=A}}x=Object.values(m).map(function(e){return e}),f=Object.values(_).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}),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(v(e,"0")||{id:e,title:"",content:"",subsections:[]}),x.push(v(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(c=null===(a=g.comparison_inputs)||void 0===a?void 0:a[p[0]])||void 0===c?void 0:c.title)||"Uploaded Contract",description:g.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(d=null===(u=g.comparison_inputs)||void 0===u?void 0:u[p[1]])||void 0===d?void 0:d.title)||"Reference Template",similarity:0,sections:x,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:g.decision_scope_description||""},fields:{}}}}]}}(I,M);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"}},[I,M]),ye=me.activeProposed,be=me.activeVariants,Se=me.parseError;t.useEffect(function(){Se&&L("Failed to load comparison: ".concat(Se))},[Se]);var Fe=t.useState(null),we=Fe[0];Fe[1];var Ee=t.useState({}),Ie=Ee[0],je=Ee[1],Ce=t.useState({}),Re=Ce[0],Be=Ce[1],Te=(null==be?void 0:be[0])||h,Ae=null===(_=null===(d=null==I?void 0:I.documents)||void 0===d?void 0:d[null===(v=null==I?void 0:I.input_index_map)||void 0===v?void 0:v[0]])||void 0===_?void 0:_.title,De=null===(b=null===(m=null==I?void 0:I.documents)||void 0===m?void 0:m[null===(y=null==I?void 0:I.input_index_map)||void 0===y?void 0:y[1]])||void 0===b?void 0:b.title,ke=s.safeStringify(C||Ae||"Uploaded Contract"),Me=s.safeStringify(R||De||"Reference Template"),Oe=t.useMemo(function(){return(null==ye?void 0:ye.sections)||[]},[null==ye?void 0:ye.sections]),Ne=t.useMemo(function(){return Te.sections||[]},[Te.sections]),He=Oe.length>0||Ne.length>0,Le=Te.analysis,ze=s.safeStringify(null===(F=null===(S=null==Le?void 0:Le.rule_difference_comparison)||void 0===S?void 0:S.summary)||void 0===F?void 0:F.overall_summary),We=!!ze.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),qe=t.useRef({}),Pe=function(e){return qe.current[e]||(qe.current[e]=f.default.createRef()),qe.current[e]},Ue=t.useCallback(function(e,n,t,i,r){var o,l,a=s.safeStringify(n.id)||s.safeStringify(t.id)||"",c=(a?Y[a]:null)||n.cognitiveData||t.cognitiveData||{section_id:a,decisioning:[],gap:[],relevance_score:0},u=null!==(l=null===(o=qe.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==I?void 0:I.documents,input_index_map:null==I?void 0:I.input_index_map}}},[Y]),Ve=t.useCallback(function(e){ge(),J(null),re(e)},[ge]),Ge=t.useCallback(function(){null!==le.sectionIdx&&le.anchorEl?Ve(e.__assign(e.__assign({},le),{open:!0})):ge()},[le,ge,Ve]);t.useCallback(function(e){ge(),L("".concat(e," is coming soon."))},[ge]);var Ye=t.useRef(null),Xe=t.useRef(null),Ke=t.useRef(null),Je=t.useState([]),Qe=Je[0],Ze=Je[1],$e=t.useState(null),en=$e[0],nn=$e[1],tn=t.useRef(null),rn=t.useState(null),on=rn[0],ln=rn[1],sn=t.useCallback(function(){null!==tn.current&&window.cancelAnimationFrame(tn.current),tn.current=window.requestAnimationFrame(function(){yn(),tn.current=null})},[]),an=t.useCallback(function(){var e=le.sectionIdx;ge(),null!==e&&(W&&en===e?(q(!1),nn(null),V(!1),de.current&&(de.current.style.height="0px"),fe.current&&(fe.current.style.height="0px")):(G.current=!0,nn(e),q(!0),V(!1),de.current&&(de.current.style.height="0px"),fe.current&&(fe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=qe.current[e])||void 0===n?void 0:n.current,r=Oe[e],o=(null==r?void 0:r.refIndexes)||[],l=null;if(o.length>0){var s=o[0],a=Ne.findIndex(function(e){return e.selfIndex===s});l=null===(t=gn.current[a])||void 0===t?void 0:t.current}var c=null==i?void 0:i.parentElement,u=ue.current;if(i&&c){var d=c.clientHeight,f=i.offsetTop-(d/2-i.offsetHeight/2),x=c.scrollHeight-d,h=Math.max(0,Math.min(f,x)),p=i.offsetTop-h,v=null;if(l&&u){var _=l.offsetTop-p;if(_<0)de.current&&(de.current.style.height="".concat(Math.abs(_),"px")),v=0;else{var m=u.scrollHeight-u.clientHeight;_>m?(fe.current&&(fe.current.style.height="".concat(_-m+150,"px")),v=_):v=_}}g(c,h,300),u&&null!==v?g(u,v,300,function(){V(!0),sn(),setTimeout(function(){G.current=!1},50)}):setTimeout(function(){V(!0),sn(),G.current=!1},350)}})))},[ge,le.sectionIdx,W,en,Oe,Ne,sn]),cn=t.useMemo(function(){return _e.fields.filter(function(e){var n=e.key;return(!He||"description"!==n)&&(s.hasValue(null==ye?void 0:ye[n])||s.hasValue(Te[n]))})},[ye,Te,He,_e.fields]),un=t.useRef({}),dn=t.useRef({}),fn=t.useRef({}),xn=t.useRef({}),hn=t.useRef({}),pn=t.useRef({}),gn=t.useRef({});cn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Oe.length,Ne.length);t+=1)fn.current[t]||(fn.current[t]=f.default.createRef()),xn.current[t]||(xn.current[t]=f.default.createRef()),hn.current[t]||(hn.current[t]=f.default.createRef()),pn.current[t]||(pn.current[t]=f.default.createRef()),gn.current[t]||(gn.current[t]=f.default.createRef());un.current[n]||(un.current[n]=f.default.createRef()),dn.current[n]||(dn.current[n]=f.default.createRef())});for(var vn=0;vn<Math.max(Oe.length,Ne.length);vn+=1)fn.current[vn]||(fn.current[vn]=f.default.createRef()),xn.current[vn]||(xn.current[vn]=f.default.createRef()),hn.current[vn]||(hn.current[vn]=f.default.createRef()),pn.current[vn]||(pn.current[vn]=f.default.createRef()),gn.current[vn]||(gn.current[vn]=f.default.createRef());t.useEffect(function(){if(we){var e=_e.fields.find(function(e){return e.analysisKey===we||e.key===we});if(e){var n=un.current[e.key]||dn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[we,_e.fields]);var _n=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==Le?void 0:Le.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 x=d.mappings[0]||{};return{score:d.score,relation:x.relation||"",highlightsA:(null===(l=x.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=x.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}},[Le]),mn=t.useCallback(function(n){var t,i,r,o,l=Oe[n],a=Ne[n],c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,u=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,d=s.safeStringify(null==l?void 0:l.id)||s.safeStringify(null==a?void 0:a.id)||"",f=!(!(null==l?void 0:l.cognitiveData)&&!(null==a?void 0:a.cognitiveData));if(!c&&!u&&!f)return e.__assign(e.__assign({},_e.relationStyles.noContent),{label:"Not Defined"});var x=_n("description");if(null!=(null!==(i=null!==(t=null==l?void 0:l.cognitiveRelevanceScore)&&void 0!==t?t:null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==i?i:d?null===(r=Y[d])||void 0===r?void 0:r.relevance_score:void 0)){var h=s.cognitiveScoreToRelation(),p=h.score,g=h.relation;return s.getStyleForRelation(p,g,!0,_e)}var v=c?l.relation:u?a.relation:x.relation,_=null!==(o=null==l?void 0:l.score)&&void 0!==o?o:null==a?void 0:a.score,m="number"==typeof _?_:x.score;return s.getStyleForRelation(m,v,!0,_e)},[Oe,Ne,Y,_e,_n]),yn=t.useCallback(function(){var e,n,t,i,r,o,l,a,c,u,d;if(!xe.current){xe.current=!0;try{if(!Ye.current)return;var f=Ye.current.getBoundingClientRect();ee({width:f.width,height:f.height});var x=[];if(cn.forEach(function(e){var n,t,i=e.key,r=null===(n=un.current[i])||void 0===n?void 0:n.current,o=null===(t=dn.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")}),!M)for(var h=0;h<Math.min(Oe.length,Ne.length);h++){var p=null===(e=fn.current[h])||void 0===e?void 0:e.current,g=null===(n=xn.current[h])||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")}var v={};cn.forEach(function(e){var n,t,i=e.key,r=null===(n=un.current[i])||void 0===n?void 0:n.current,o=null===(t=dn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),s=o.getBoundingClientRect();v[i]=Math.max(l.height,s.height)}});var _=[];if(!M)for(h=0;h<Math.min(Oe.length,Ne.length);h++){p=null===(t=fn.current[h])||void 0===t?void 0:t.current,g=null===(i=xn.current[h])||void 0===i?void 0:i.current;if(p&&g){var m=p.getBoundingClientRect(),y=g.getBoundingClientRect();_[h]=Math.max(m.height,y.height)}}if(cn.forEach(function(e){var n,t,i=e.key,r=null===(n=un.current[i])||void 0===n?void 0:n.current,o=null===(t=dn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=v[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!M)for(h=0;h<_.length;h++){p=null===(r=fn.current[h])||void 0===r?void 0:r.current,g=null===(o=xn.current[h])||void 0===o?void 0:o.current;if(p&&g){var b=_[h];p.style.minHeight="".concat(b,"px"),g.style.minHeight="".concat(b,"px")}}if(cn.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=un.current[i])||void 0===n?void 0:n.current,l=null===(t=dn.current[i])||void 0===t?void 0:t.current;if(o&&l){var a=o.getBoundingClientRect(),c=l.getBoundingClientRect(),u=_n(r),d=s.getStyleForRelation(u.score,u.relation,u.hasContent,_e);if(!d)return;var h=a.top+a.height/2-f.top;x.push({id:"field-".concat(i),x1:a.right-f.left,y1:h,x2:c.left-f.left,y2:h,style:d})}}),M)Oe.forEach(function(e,n){var t;(null===(t=fn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r=Ne.findIndex(function(n){return n.selfIndex===e});if(-1!==r){var o=null===(t=hn.current[n])||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=s.right-f.left,u=a.left-f.left,d=s.top+s.height/2-f.top,h=a.top+a.height/2-f.top;W&&en===n&&(h=d);var p=mn(n);p&&x.push({id:"line-".concat(n,"-").concat(r),x1:c,y1:d,x2:u,y2:h,style:p,sectionIdx:n,targetRightIdx:r})}}})});else for(h=0;h<Math.min(Oe.length,Ne.length);h++){var S=null===(l=fn.current[h])||void 0===l?void 0:l.current,F=null===(a=xn.current[h])||void 0===a?void 0:a.current;if(S&&F){var w=S.querySelector(".MuiAccordionSummary-root"),E=F.querySelector(".MuiAccordionSummary-root");if(w&&E){var I=w.getBoundingClientRect(),j=E.getBoundingClientRect(),C=(I.top+I.height/2-f.top+j.top+j.height/2-f.top)/2,R=(null===(c=Ne[h])||void 0===c?void 0:c.id)||"sec-".concat(h),B=mn(h);B&&x.push({id:R,x1:I.right-f.left,y1:C,x2:j.left-f.left,y2:C,style:B,sectionIdx:h,hasCognitive:!!((null===(u=Oe[h])||void 0===u?void 0:u.cognitiveData)||(null===(d=Ne[h])||void 0===d?void 0:d.cognitiveData)||R&&Y[R])})}}}if(Ze(x),Xe.current&&Ke.current){var T=Xe.current.getBoundingClientRect(),A=Ke.current.getBoundingClientRect(),D=(T.top+T.height/2-f.top+A.top+A.height/2-f.top)/2;ln({x1:T.right-f.left,x2:A.left-f.left,y:D})}else ln(null)}catch(e){console.error("Line render safe fail: ",e)}finally{xe.current=!1}}},[cn,Oe,Ne,Y,_e,_n,mn,M,W,en]),bn=t.useCallback(function(){G.current||(sn(),W&&!G.current&&(q(!1),nn(null),V(!1),de.current&&(de.current.style.height="0px"),fe.current&&(fe.current.style.height="0px")))},[sn,W]);t.useEffect(function(){var e=setTimeout(sn,250);window.addEventListener("resize",sn);var n=null,t=null;return ae.current&&(n=new ResizeObserver(sn)).observe(ae.current),Ye.current&&(t=new ResizeObserver(sn)).observe(Ye.current),function(){clearTimeout(e),window.removeEventListener("resize",sn),null==n||n.disconnect(),null==t||t.disconnect()}},[ye,Te,Le,cn,Ie,Re,Oe,Ne,_e,sn,W,en,U]);var Sn=function(t,o,l,a,c){void 0===c&&(c=1);var u,d=M?!!Ie["".concat(l,"-").concat(o)]:!!Ie[String(o)],h=s.hasValue(t.title),p=s.hasValue(t.content),g=!h&&!p,v=t.title;return h||(v=p?"No Title Found":"No Matching Section Found"),n.jsx(i.Box,e.__assign({ref:a,sx:e.__assign(e.__assign({mb:c},M?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!g&&d,onChange:function(){return!g&&function(n,t){je(function(i){var r=e.__assign({},i);if(!M){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=Oe[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=Ne.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=Ne[n])?void 0:a.selfIndex;Oe.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:g?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:g?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:g?null:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:g?"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:v,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"12px",color:g?"#94A3B8":"#19213D",fontWeight:g?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(u=v,u?s.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(f.default.Fragment,{children:e},t)}):null)}))}))})),!g&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[n.jsx(i.Typography,e.__assign({component:"div",sx:ne},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return Fn(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},Fn=function(t,o,l){void 0===l&&(l=0);var a=s.hasValue(t.title),c=s.hasValue(t.content),u=!a&&!c,d=a?t.title:c?"No Title Found":"No Matching Section Found",f=!!Re[o];return t.title?n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!u&&f,onChange:function(){return!u&&Be(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:ne},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return Fn(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:ne},{children:n.jsx(x.default,{children:s.safeStringify(t.content).replace(/\\n/g,"\n")})})),(t.subsections||[]).map(function(e,n){return Fn(e,"".concat(o,"-").concat(n),l+1)})]})}),o)};return n.jsxs(i.Box,e.__assign({ref:ce,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},M?{}:{overflow:"visible"}),{position:"relative"})},{children:[M&&n.jsx(u.default,{open:le.open,anchorEl:le.anchorEl,sectionTitle:le.sectionTitle,referenceSectionTitle:le.refSectionTitle,onClose:ge,onOpenCognitiveCompare:Ge,onOpenSideBySide:an}),ie.open&&n.jsx(c.default,{open:ie.open,popupRef:Q,position:K,popupConfig:D,onClose:function(){J(null),re(function(n){return e.__assign(e.__assign({},n),{open:!1})})},markdownStyles:B,sectionTitle:ie.sectionTitle,referenceSectionTitle:ie.refSectionTitle,cognitiveData:ie.cognitiveData,anchorEl:ie.anchorEl,sectionAnchorEl:ie.sectionAnchorEl,scrollContainerEl:ae.current,badgeStyle:ie.badgeStyle,docData:ie.docData}),n.jsx(i.Snackbar,e.__assign({open:!!H,autoHideDuration:8e3,onClose:function(){return L(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return L(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:H}))})),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:M,onChange:function(e){return O(e.target.checked)},color:"primary",size:"small"}),label:n.jsx(i.Typography,e.__assign({sx:{fontSize:"13px",fontWeight:500,color:"#64748B"}},{children:"Relative Order"})),labelPlacement:"start",sx:{m:0,gap:1}})}))]})),n.jsx(i.Box,e.__assign({ref:ae,onScroll:bn,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:M?"hidden":"auto",borderTop:ze&&We?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},M?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Ye,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},M?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({style:{position:"absolute",top:0,left:0,width:$.width||"100%",height:$.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[on&&n.jsxs("g",{children:[n.jsx("line",{x1:on.x1,y1:on.y,x2:Math.max(on.x1,(on.x1+on.x2)/2-70),y2:on.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(on.x2,(on.x1+on.x2)/2+70),y1:on.y,x2:on.x2,y2:on.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Qe.map(function(t){var l,s=(t.x1+t.x2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!M)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){var n=Oe[t.sectionIdx]||{title:"",content:""},i=Ne[t.sectionIdx]||{title:"",content:""};Ve(Ue(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})]}))}))}))]},t.id);var a=Oe[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:W&&en===t.sectionIdx&&U?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",{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})]})),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)"},M?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Xe,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:ke,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:ke}))}))})),n.jsx(i.Box,e.__assign({onScroll:bn,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},M?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:He&&Oe.map(function(t,o){var l;if(!M)return n.jsx(i.Box,e.__assign({ref:Pe(o)},{children:Sn(t,o,"left",fn.current[o])}),"left-row-".concat(o));var s=t,a=mn(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;return n.jsx(i.Box,e.__assign({ref:Pe(o),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:fn.current[o],sx:{width:"100%"}},{children:Sn(t,o,"left",f.default.createRef(),0)})),a&&n.jsxs(i.Box,e.__assign({ref:hn.current[o],onClick:function(e){var n=Ne.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(),le.open&&le.sectionIdx===i?ge():(pe(),se(Ue(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:"6px",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},M?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Ke,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:Me,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:Me}))}))})),n.jsxs(i.Box,e.__assign({ref:ue,onScroll:bn,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},M?{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:de,style:{width:"100%",height:"0px",flexShrink:0}}),He&&Ne.map(function(t,r){if(!M)return Sn(t,r,"right",xn.current[r]);var o=t,l=Oe.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});return n.jsx(i.Box,e.__assign({ref:gn.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:xn.current[r],sx:{width:"100%"}},{children:Sn(t,r,"right",f.default.createRef(),0)})),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:fe,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{jsxs as n,jsx as t}from"react/jsx-runtime";import i,{useState as r,useRef as o,useMemo as l,useEffect as c,useCallback as d}from"react";import{Box as a,Snackbar as u,Alert as s,Typography as f,Tooltip as v,Accordion as p,AccordionSummary as h,AccordionDetails as x}from"@mui/material";import{ChevronDown as g,EllipsisVertical as m}from"lucide-react";import{ButtonCognitiveIcon as y}from"../../assests/svg/ButtonCognitiveIcon.js";import b from"react-markdown";import{safeStringify as w,hasValue as F,getStyleForRelation as E,getRationale as I,getSideData as S,cognitiveScoreToRelation as C}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as _,DEFAULT_FIELD_CONFIG as R,DEFAULT_COMPARISON_CONFIG as T}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import D from"./CognitivePopup.js";import A from"./MoreFunctionsPopup.js";var B={id:"",title:""},k={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},z=function(z){var H,M,W,j,L,N,O,P,V=z.componentHeaderText,X=void 0===V?"Learning Comparison":V,Y=z.treeData,q=z.comparisonConfig,U=z.leftColumnTitleText,K=z.rightColumnTitleText,G=z.markdownStyles,J=z.maintainRelativeOrder,Q=void 0!==J&&J,Z=z.popupConfig,$=r(null),ee=$[0],ne=$[1],te=r(!1),ie=te[0],re=te[1],oe=r(!1),le=oe[0],ce=oe[1],de=o(!1),ae=l(function(){return(null==Y?void 0:Y.cognitive_decisioning)||{}},[Y]),ue=r(null),se=ue[0],fe=ue[1],ve=o(null),pe=r({width:0,height:0}),he=pe[0],xe=pe[1],ge=l(function(){return e(e({},_),G)},[G]),me=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),ye=me[0],be=me[1],we=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),Fe=we[0],Ee=we[1],Ie=o(null),Se=o(null),Ce=o(!1),_e=o(null);c(function(){_e.current=null},[ye.sectionIdx,ye.open]);var Re=d(function(){fe(null),be(k)},[]),Te=d(function(){Ee(k)},[]),De=d(function(){var e;if(ye.anchorEl&&ye.refSectionTitle){var n=ye.anchorEl.getBoundingClientRect(),t=(null===(e=null==ve?void 0:ve.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!==_e.current?!0===_e.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),_e.current=l;var c=l?o:r,d=Math.min(t||9999,c),a=l?n.top-12-d:n.bottom+12,u=n.left+n.width/2,s=u-i/2,f=Math.max(12,Math.min(s,window.innerWidth-i-12)),v=Math.max(14,Math.min(u-f,i-10-4));fe({top:a,left:f,arrowLeft:v,openAbove:l,maxHeight:c})}},[ye.anchorEl,ye.refSectionTitle]);c(function(){if(ye.open){window.addEventListener("resize",De);var e=requestAnimationFrame(De),n=null;return ve.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(De)})).observe(ve.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",De),n&&n.disconnect()}}},[ye.open,De]),c(function(){var e=Ie.current;if(e&&ye.open){var n=function(e){ve.current&&ve.current.contains(e.target)||(fe(null),Re())};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})}}},[ye.open,Re]),c(function(){var e=Ie.current;if(e&&Fe.open){var n=function(){Te()};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})}}},[Fe.open,Te]);var Ae=l(function(){var n,t,i,r,o,l,c,d,a,u,s,f;return{fields:null!==(n=null==q?void 0:q.fields)&&void 0!==n?n:R,thresholds:{high:null!==(i=null===(t=null==q?void 0:q.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:T.thresholds.high,medium:null!==(o=null===(r=null==q?void 0:q.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:T.thresholds.medium,exact:null!==(c=null===(l=null==q?void 0:q.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:T.thresholds.exact},relationStyles:{noContent:e(e({},T.relationStyles.noContent),(null===(d=null==q?void 0:q.relationStyles)||void 0===d?void 0:d.noContent)||{}),high:e(e({},T.relationStyles.high),(null===(a=null==q?void 0:q.relationStyles)||void 0===a?void 0:a.high)||{}),exact:e(e({},T.relationStyles.exact),(null===(u=null==q?void 0:q.relationStyles)||void 0===u?void 0:u.exact)||{}),medium:e(e({},T.relationStyles.medium),(null===(s=null==q?void 0:q.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},T.relationStyles.low),(null===(f=null==q?void 0:q.relationStyles)||void 0===f?void 0:f.low)||{})}}},[q]),Be=l(function(){if(Y&&Object.keys(Y).length>0)try{var n=function(n,t){var i,r,o,l,c,d,a,u;void 0===t&&(t=!1);var s=[],f=[],v=n.base_root_id,p=n.input_index_map||{0:"left",1:"right"},h=n[v];if(!h||!1===h.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var x=function(t,i){var r=n[t];if(!r)return null;var o=S(r,i,p),l=!!o.title.trim(),c=!!o.content.trim(),d=I(r),a=[];r.next&&Object.values(r.next).forEach(function(e){if(n[e]){var t=x(e,i);t&&a.push(t)}});var u=!(!l&&!c);return e({id:t,title:l?o.title:"",content:c?o.content:"",subsections:a},u?d:{score:void 0,relation:"not_defined"})};if(t){var g={},m={},y=-1,b=-1;for(var w in n)if(!["base_root_id","documents","input_index_map",v].includes(w)){var F=n[w];if(F&&!1!==F.display_node){var E=I(F),C=S(F,"0",p),_=S(F,"1",p),R=C.title.trim()||C.content.trim(),T=_.title.trim()||_.content.trim(),D=Number(null!==(r=null===(i=C.attributes)||void 0===i?void 0:i.display_index)&&void 0!==r?r:y--),A=Number(null!==(l=null===(o=_.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:b--),B=m[A]||e(e({id:w,title:T?_.title:"",content:T?_.content:"",subsections:[]},T?E:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:A}),k=g[D]||e(e({id:w,title:R?C.title:"",content:R?C.content:"",subsections:[]},R?E:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:D});Number(A)>=0&&Number(D)>=0&&(B.refIndexes.includes(Number(D))||B.refIndexes.push(Number(D)),k.refIndexes.includes(Number(A))||k.refIndexes.push(Number(A))),m[A]=B,g[D]=k}}f=Object.values(m).map(function(e){return e}),s=Object.values(g).map(function(e){return e}),f.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),s.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex})}else h.next&&Object.values(h.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(s.push(x(e,"0")||{id:e,title:"",content:"",subsections:[]}),f.push(x(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(d=null===(c=h.comparison_inputs)||void 0===c?void 0:c[p[0]])||void 0===d?void 0:d.title)||"Uploaded Contract",description:h.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:(null===(u=null===(a=h.comparison_inputs)||void 0===a?void 0:a[p[1]])||void 0===u?void 0:u.title)||"Reference Template",similarity:0,sections:f,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:h.decision_scope_description||""},fields:{}}}}]}}(Y,Q);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"}},[Y,Q]),ke=Be.activeProposed,ze=Be.activeVariants,He=Be.parseError;c(function(){He&&ne("Failed to load comparison: ".concat(He))},[He]);var Me=r(null),We=Me[0];Me[1];var je=r({}),Le=je[0],Ne=je[1],Oe=r({}),Pe=Oe[0],Ve=Oe[1],Xe=(null==ze?void 0:ze[0])||B,Ye=null===(W=null===(H=null==Y?void 0:Y.documents)||void 0===H?void 0:H[null===(M=null==Y?void 0:Y.input_index_map)||void 0===M?void 0:M[0]])||void 0===W?void 0:W.title,qe=null===(N=null===(j=null==Y?void 0:Y.documents)||void 0===j?void 0:j[null===(L=null==Y?void 0:Y.input_index_map)||void 0===L?void 0:L[1]])||void 0===N?void 0:N.title,Ue=w(U||Ye||"Uploaded Contract"),Ke=w(K||qe||"Reference Template"),Ge=l(function(){return(null==ke?void 0:ke.sections)||[]},[null==ke?void 0:ke.sections]),Je=l(function(){return Xe.sections||[]},[Xe.sections]),Qe=Ge.length>0||Je.length>0,Ze=Xe.analysis,$e=w(null===(P=null===(O=null==Ze?void 0:Ze.rule_difference_comparison)||void 0===O?void 0:O.summary)||void 0===P?void 0:P.overall_summary),en=!!$e.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),nn=o({}),tn=function(e){return nn.current[e]||(nn.current[e]=i.createRef()),nn.current[e]},rn=d(function(e,n,t,i,r){var o,l,c=w(n.id)||w(t.id)||"",d=(c?ae[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},a=null!==(l=null===(o=nn.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:d,anchorEl:e,sectionAnchorEl:a,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==Y?void 0:Y.documents,input_index_map:null==Y?void 0:Y.input_index_map}}},[ae]),on=d(function(e){Te(),fe(null),be(e)},[Te]),ln=d(function(){null!==Fe.sectionIdx&&Fe.anchorEl?on(e(e({},Fe),{open:!0})):Te()},[Fe,Te,on]);d(function(e){Te(),ne("".concat(e," is coming soon."))},[Te]);var cn=o(null),dn=o(null),an=o(null),un=r([]),sn=un[0],fn=un[1],vn=r(null),pn=vn[0],hn=vn[1],xn=o(null),gn=r(null),mn=gn[0],yn=gn[1],bn=d(function(){var e=Fe.sectionIdx;Te(),null!==e&&(ie&&pn===e?(re(!1),hn(null),ce(!1)):(de.current=!0,hn(e),re(!0),ce(!1),setTimeout(function(){var n,t=null===(n=nn.current[e])||void 0===n?void 0:n.current;t&&t.scrollIntoView({behavior:"smooth",block:"center"})},50),setTimeout(function(){ce(!0),de.current=!1},600)))},[Te,Fe.sectionIdx,ie,pn]),wn=l(function(){return Ae.fields.filter(function(e){var n=e.key;return(!Qe||"description"!==n)&&(F(null==ke?void 0:ke[n])||F(Xe[n]))})},[ke,Xe,Qe,Ae.fields]),Fn=o({}),En=o({}),In=o({}),Sn=o({}),Cn=o({}),_n=o({}),Rn=o({});wn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(Ge.length,Je.length);t+=1)In.current[t]||(In.current[t]=i.createRef()),Sn.current[t]||(Sn.current[t]=i.createRef()),Cn.current[t]||(Cn.current[t]=i.createRef()),_n.current[t]||(_n.current[t]=i.createRef()),Rn.current[t]||(Rn.current[t]=i.createRef());Fn.current[n]||(Fn.current[n]=i.createRef()),En.current[n]||(En.current[n]=i.createRef())});for(var Tn=0;Tn<Math.max(Ge.length,Je.length);Tn+=1)In.current[Tn]||(In.current[Tn]=i.createRef()),Sn.current[Tn]||(Sn.current[Tn]=i.createRef()),Cn.current[Tn]||(Cn.current[Tn]=i.createRef()),_n.current[Tn]||(_n.current[Tn]=i.createRef()),Rn.current[Tn]||(Rn.current[Tn]=i.createRef());c(function(){if(We){var e=Ae.fields.find(function(e){return e.analysisKey===We||e.key===We});if(e){var n=Fn.current[e.key]||En.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[We,Ae.fields]);var Dn=d(function(e){var n,t,i,r,o,l,c,d,a,u=null===(n=null==Ze?void 0:Ze.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=u[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===(d=s.highlights)||void 0===d?void 0:d.ruleA_spans)||[],highlightsB:(null===(a=s.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!f}},[Ze]),An=d(function(n){var t,i,r,o,l=Ge[n],c=Je[n],d=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,a=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,u=w(null==l?void 0:l.id)||w(null==c?void 0:c.id)||"",s=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!d&&!a&&!s)return e(e({},Ae.relationStyles.noContent),{label:"Not Defined"});var f=Dn("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:u?null===(r=ae[u])||void 0===r?void 0:r.relevance_score:void 0)){var v=C(),p=v.score,h=v.relation;return E(p,h,!0,Ae)}var x=d?l.relation:a?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 E(m,x,!0,Ae)},[Ge,Je,ae,Ae,Dn]),Bn=d(function(){var e,n,t,i,r,o,l,c,d,a,u,s,f;if(!Ce.current){Ce.current=!0;try{if(!cn.current)return;if(Object.values(nn.current).forEach(function(e){e.current&&(e.current.style.paddingTop="0px",e.current.style.marginTop="0px")}),Object.values(Rn.current).forEach(function(e){e.current&&(e.current.style.paddingTop="0px",e.current.style.marginTop="0px")}),Q&&ie&&null!==pn){var v=Ge[pn],p=(null==v?void 0:v.refIndexes)||[];if(p.length>0){var h=p[0],x=Je.findIndex(function(e){return e.selfIndex===h});if(-1!==x){var g=null===(e=nn.current[pn])||void 0===e?void 0:e.current,m=null===(n=Rn.current[x])||void 0===n?void 0:n.current;if(g&&m){var y=g.getBoundingClientRect().top-m.getBoundingClientRect().top;if(m.style.transition="padding-top 0.3s ease-in-out",y>1)m.style.paddingTop="".concat(y,"px");else if(y<-1){var b=m.parentElement;b&&(de.current=!0,b.scrollTo({top:b.scrollTop+Math.abs(y),behavior:"smooth"}),setTimeout(function(){de.current=!1},400))}}}}}var w=cn.current.getBoundingClientRect();xe({width:w.width,height:w.height});var F=[];if(wn.forEach(function(e){var n,t,i=e.key,r=null===(n=Fn.current[i])||void 0===n?void 0:n.current,o=null===(t=En.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")}),!Q)for(var I=0;I<Math.min(Ge.length,Je.length);I++){var S=null===(t=In.current[I])||void 0===t?void 0:t.current,C=null===(i=Sn.current[I])||void 0===i?void 0:i.current;S&&C&&(S.style.height="auto",C.style.height="auto",S.style.minHeight="0px",C.style.minHeight="0px")}var _={};wn.forEach(function(e){var n,t,i=e.key,r=null===(n=Fn.current[i])||void 0===n?void 0:n.current,o=null===(t=En.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),c=o.getBoundingClientRect();_[i]=Math.max(l.height,c.height)}});var R=[];if(!Q)for(I=0;I<Math.min(Ge.length,Je.length);I++){S=null===(r=In.current[I])||void 0===r?void 0:r.current,C=null===(o=Sn.current[I])||void 0===o?void 0:o.current;if(S&&C){var T=S.getBoundingClientRect(),D=C.getBoundingClientRect();R[I]=Math.max(T.height,D.height)}}if(wn.forEach(function(e){var n,t,i=e.key,r=null===(n=Fn.current[i])||void 0===n?void 0:n.current,o=null===(t=En.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=_[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),!Q)for(I=0;I<R.length;I++){S=null===(l=In.current[I])||void 0===l?void 0:l.current,C=null===(c=Sn.current[I])||void 0===c?void 0:c.current;if(S&&C){var A=R[I];S.style.minHeight="".concat(A,"px"),C.style.minHeight="".concat(A,"px")}}if(wn.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=Fn.current[i])||void 0===n?void 0:n.current,l=null===(t=En.current[i])||void 0===t?void 0:t.current;if(o&&l){var c=o.getBoundingClientRect(),d=l.getBoundingClientRect(),a=Dn(r),u=E(a.score,a.relation,a.hasContent,Ae);if(!u)return;var s=c.top+c.height/2-w.top;F.push({id:"field-".concat(i),x1:c.right-w.left,y1:s,x2:d.left-w.left,y2:s,style:u})}}),Q)Ge.forEach(function(e,n){var t;(null===(t=In.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r=Je.findIndex(function(n){return n.selfIndex===e});if(-1!==r){var o=null===(t=Cn.current[n])||void 0===t?void 0:t.current,l=null===(i=_n.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),d=l.getBoundingClientRect(),a=c.right-w.left,u=d.left-w.left,s=c.top+c.height/2-w.top,f=d.top+d.height/2-w.top,v=An(n);v&&F.push({id:"line-".concat(n,"-").concat(r),x1:a,y1:s,x2:u,y2:f,style:v,sectionIdx:n,targetRightIdx:r})}}})});else for(I=0;I<Math.min(Ge.length,Je.length);I++){var B=null===(d=In.current[I])||void 0===d?void 0:d.current,k=null===(a=Sn.current[I])||void 0===a?void 0:a.current;if(B&&k){var z=B.querySelector(".MuiAccordionSummary-root"),H=k.querySelector(".MuiAccordionSummary-root");if(z&&H){var M=z.getBoundingClientRect(),W=H.getBoundingClientRect(),j=(M.top+M.height/2-w.top+W.top+W.height/2-w.top)/2,L=(null===(u=Je[I])||void 0===u?void 0:u.id)||"sec-".concat(I),N=An(I);N&&F.push({id:L,x1:M.right-w.left,y1:j,x2:W.left-w.left,y2:j,style:N,sectionIdx:I,hasCognitive:!!((null===(s=Ge[I])||void 0===s?void 0:s.cognitiveData)||(null===(f=Je[I])||void 0===f?void 0:f.cognitiveData)||L&&ae[L])})}}}if(fn(F),dn.current&&an.current){var O=dn.current.getBoundingClientRect(),P=an.current.getBoundingClientRect(),V=(O.top+O.height/2-w.top+P.top+P.height/2-w.top)/2;yn({x1:O.right-w.left,x2:P.left-w.left,y:V})}else yn(null)}catch(e){console.error("Line render safe fail: ",e)}finally{Ce.current=!1}}},[wn,Ge,Je,ae,Ae,Dn,An,Q,ie,pn,Pe]),kn=d(function(){null!==xn.current&&window.cancelAnimationFrame(xn.current),xn.current=window.requestAnimationFrame(function(){Bn(),xn.current=null})},[Bn]),zn=d(function(){kn(),ie&&!de.current&&(re(!1),hn(null),ce(!1))},[kn,ie]);c(function(){var e=setTimeout(kn,250);window.addEventListener("resize",kn);var n=null,t=null;return Ie.current&&(n=new ResizeObserver(kn)).observe(Ie.current),cn.current&&(t=new ResizeObserver(kn)).observe(cn.current),function(){clearTimeout(e),window.removeEventListener("resize",kn),null==n||n.disconnect(),null==t||t.disconnect()}},[ke,Xe,Ze,wn,Le,Ge,Je,Ae,kn]);var Hn=function(r,o,l,c,d){void 0===d&&(d=1);var u,s=Q?!!Le["".concat(l,"-").concat(o)]:!!Le[String(o)],m=F(r.title),y=F(r.content),E=!m&&!y,I=r.title;return m||(I=y?"No Title Found":"No Matching Section Found"),t(a,e({ref:c,sx:e(e({mb:d},Q?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n(p,e({disableGutters:!0,expanded:!E&&s,onChange:function(){return!E&&function(n,t){Ne(function(i){var r=e({},i);if(!Q){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==(d=Ge[n])?void 0:d.refIndexes)||[]).forEach(function(e){var n=Je.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=c)});else{var d,a=null==(d=Je[n])?void 0:d.selfIndex;Ge.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})}(o,l)},sx:{boxShadow:"none",border:E?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:E?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flex:1,display:"flex",flexDirection:"column","&:before":{display:"none"}}},{children:[t(h,e({expandIcon:E?null:t(g,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:E?"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:t(v,e({title:I,placement:"top"},{children:t(f,e({sx:{fontSize:"12px",color:E?"#94A3B8":"#19213D",fontWeight:E?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(u=I,u?w(u).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(i.Fragment,{children:e},n)}):null)}))}))})),!E&&n(x,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[t(f,e({component:"div",sx:ge},{children:t(b,{children:w(r.content).replace(/\\n/g,"\n")})})),(r.subsections||[]).map(function(e,n){return Mn(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},Mn=function(i,r,o){void 0===o&&(o=0);var l=F(i.title),c=F(i.content),d=!l&&!c,u=l?i.title:c?"No Title Found":"No Matching Section Found",s=!!Pe[r];return i.title?n(p,e({disableGutters:!0,expanded:!d&&s,onChange:function(){return!d&&Ve(function(n){var t;return e(e({},n),((t={})[r]=!n[r],t))})},sx:{mt:1,boxShadow:"none",border:d?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF","&:before":{display:"none"}}},{children:[t(h,e({expandIcon:d?null:t(g,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:t(f,e({sx:{fontSize:"11px",fontWeight:600,color:d?"#94A3B8":"#19213D"}},{children:u||"Untitled Subsection"}))})),!d&&n(x,e({sx:{pt:0,pb:1}},{children:[c&&t(f,e({component:"div",sx:ge},{children:t(b,{children:w(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Mn(e,"".concat(r,"-").concat(n),o+1)})]}))]}),r):t(a,e({sx:{mt:0===o?1:.75}},{children:!d&&n("div",{children:[c&&t(f,e({component:"div",sx:ge},{children:t(b,{children:w(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Mn(e,"".concat(r,"-").concat(n),o+1)})]})}),r)};return n(a,e({ref:Se,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},Q?{}:{overflow:"visible"}),{position:"relative"})},{children:[Q&&t(A,{open:Fe.open,anchorEl:Fe.anchorEl,sectionTitle:Fe.sectionTitle,referenceSectionTitle:Fe.refSectionTitle,onClose:Te,onOpenCognitiveCompare:ln,onOpenSideBySide:bn}),ye.open&&t(D,{open:ye.open,popupRef:ve,position:se,popupConfig:Z,onClose:function(){fe(null),be(function(n){return e(e({},n),{open:!1})})},markdownStyles:G,sectionTitle:ye.sectionTitle,referenceSectionTitle:ye.refSectionTitle,cognitiveData:ye.cognitiveData,anchorEl:ye.anchorEl,sectionAnchorEl:ye.sectionAnchorEl,scrollContainerEl:Ie.current,badgeStyle:ye.badgeStyle,docData:ye.docData}),t(u,e({open:!!ee,autoHideDuration:8e3,onClose:function(){return ne(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(s,e({onClose:function(){return ne(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:ee}))})),t(a,e({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4"}},{children:t(a,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:t(f,e({sx:{fontSize:"16px",fontWeight:450,color:"#0F172A"}},{children:X}))}))})),t(a,e({ref:Ie,onScroll:zn,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Q?"hidden":"auto",borderTop:$e&&en?"none":"1.5px solid #EEF0F4"}},{children:t(a,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Q?{flex:1,minHeight:0}:{})},{children:n(a,e({ref:cn,sx:e({display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Q?{flex:1,overflow:"visible"}:{})},{children:[n("svg",e({style:{position:"absolute",top:0,left:0,width:he.width||"100%",height:he.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[mn&&n("g",{children:[t("line",{x1:mn.x1,y1:mn.y,x2:Math.max(mn.x1,(mn.x1+mn.x2)/2-70),y2:mn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),t("line",{x1:Math.min(mn.x2,(mn.x1+mn.x2)/2+70),y1:mn.y,x2:mn.x2,y2:mn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),sn.map(function(i){var r,o=(i.x1+i.x2)/2;if("Not Defined"===i.style.label&&!i.hasCognitive)return null;if(!Q)return n("g",{children:[t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),t("foreignObject",e({x:o-100,y:i.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(a,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n(a,e({onClick:function(e){var n=Ge[i.sectionIdx]||{title:"",content:""},t=Je[i.sectionIdx]||{title:"",content:""};on(rn(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,t(a,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(y,{})})),t(g,{size:11})]}))}))}))]},i.id);var l=Ge[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:ie&&pn===i.sectionIdx&&le?n("g",e({style:{transition:"opacity 0.2s"}},{children:[t("defs",{children:t("marker",e({id:"arr-".concat(i.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:t("polygon",{points:"0 0, 7 2.5, 0 5",fill:i.style.badgeBorder||"#6366F1"})}))}),t("line",{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})]})),n(a,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)"},Q?{flex:1,overflow:"visible"}:{})},{children:[t(a,e({ref:dn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:t(v,e({title:Ue,placement:"top"},{children:t(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:Ue}))}))})),t(a,e({onScroll:zn,sx:e({p:"12px",display:"flex",flexDirection:"column"},Q?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:Qe&&Ge.map(function(r,o){var l;if(!Q)return t(a,e({ref:tn(o)},{children:Hn(r,o,"left",In.current[o])}),"left-row-".concat(o));var c=r,d=An(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;return t(a,e({ref:tn(o),sx:{mb:1}},{children:n(a,e({sx:{position:"relative",width:"100%"}},{children:[t(a,e({ref:In.current[o],sx:{width:"100%"}},{children:Hn(r,o,"left",i.createRef(),0)})),d&&n(a,e({ref:Cn.current[o],onClick:function(e){var n=Je.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(),Fe.open&&Fe.sectionIdx===i?Te():(Re(),Ee(rn(e.currentTarget,n,t,i,r)))}(e,r,n,o,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==s&&t(a,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:s})),t(a,e({component:"span",sx:{fontSize:"11px",px:.25}},{children:u?"No Deviation Found":0==d.deviationLabel||void 0===d.deviationLabel?"Same":"".concat(d.deviationLabel,"% Deviation")})),t(m,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),t(a,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:t(a,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n(a,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:[t(a,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(y,{})})),0,"% Similarity",t(g,{size:11})]}))}))})),n(a,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},Q?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[t(a,e({ref:an,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:t(v,e({title:Ke,placement:"top"},{children:t(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:Ke}))}))})),t(a,e({onScroll:zn,sx:e({p:"12px",display:"flex",flexDirection:"column"},Q?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:Qe&&Je.map(function(r,o){if(!Q)return Hn(r,o,"right",Sn.current[o]);var l=r,c=Ge.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});return t(a,e({ref:Rn.current[o],sx:{mb:1}},{children:n(a,e({sx:{position:"relative",width:"100%"}},{children:[t(a,e({ref:Sn.current[o],sx:{width:"100%"}},{children:Hn(r,o,"right",i.createRef(),0)})),t(a,e({ref:_n.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))})}))]}))]}))}))}))]}))};export{z as default};
1
+ import{__assign as e}from"tslib";import{jsxs as n,jsx 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{Box as d,Snackbar as u,Alert as s,Typography as f,FormControlLabel as h,Switch as v,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 F from"react-markdown";import{safeStringify as I,hasValue as E,getStyleForRelation as S,getRationale as C,getSideData as R,cognitiveScoreToRelation as _}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as T,DEFAULT_FIELD_CONFIG as D,DEFAULT_COMPARISON_CONFIG as A}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import B from"./CognitivePopup.js";import k from"./MoreFunctionsPopup.js";var H={id:"",title:""},z={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null},M=function(e,n,t,i){void 0===t&&(t=300);var r=e.style.scrollBehavior;e.style.scrollBehavior="auto";var o=e.scrollTop,l=n-o,c=null,a=function(d){null===c&&(c=d);var u,s=d-c;s<t?(e.scrollTop=(u=s,u/=t,l*(--u*u*u+1)+o),requestAnimationFrame(a)):(e.scrollTop=n,e.style.scrollBehavior=r,i&&i())};requestAnimationFrame(a)},W=function(W){var L,j,N,O,P,q,X,Y,V=W.componentHeaderText,U=void 0===V?"Learning Comparison":V,K=W.treeData,G=W.comparisonConfig,J=W.leftColumnTitleText,Q=W.rightColumnTitleText,Z=W.markdownStyles,$=W.maintainRelativeOrder,ee=void 0!==$&&$,ne=W.popupConfig,te=r(ee),ie=te[0],re=te[1],oe=r(null),le=oe[0],ce=oe[1],ae=r(!1),de=ae[0],ue=ae[1],se=r(!1),fe=se[0],he=se[1],ve=o(!1),pe=l(function(){return(null==K?void 0:K.cognitive_decisioning)||{}},[K]),xe=r(null),ge=xe[0],me=xe[1],ye=o(null),be=r({width:0,height:0}),we=be[0],Fe=be[1],Ie=l(function(){return e(e({},T),Z)},[Z]),Ee=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),Se=Ee[0],Ce=Ee[1],Re=r({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null}),_e=Re[0],Te=Re[1],De=o(null),Ae=o(null),Be=o(null),ke=o(null),He=o(null),ze=o(!1),Me=o(null);c(function(){Me.current=null},[Se.sectionIdx,Se.open]);var We=a(function(){me(null),Ce(z)},[]),Le=a(function(){Te(z)},[]),je=a(function(){var e;if(Se.anchorEl&&Se.refSectionTitle){var n=Se.anchorEl.getBoundingClientRect(),t=(null===(e=null==ye?void 0:ye.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!==Me.current?!0===Me.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),Me.current=l;var c=l?o:r,a=Math.min(t||9999,c),d=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,s=u-i/2,f=Math.max(12,Math.min(s,window.innerWidth-i-12)),h=Math.max(14,Math.min(u-f,i-10-4));me({top:d,left:f,arrowLeft:h,openAbove:l,maxHeight:c})}},[Se.anchorEl,Se.refSectionTitle]);c(function(){if(Se.open){window.addEventListener("resize",je);var e=requestAnimationFrame(je),n=null;return ye.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(je)})).observe(ye.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",je),n&&n.disconnect()}}},[Se.open,je]),c(function(){var e=De.current;if(e&&Se.open){var n=function(e){ye.current&&ye.current.contains(e.target)||(me(null),We())};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})}}},[Se.open,We]),c(function(){var e=De.current;if(e&&_e.open){var n=function(){Le()};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})}}},[_e.open,Le]);var Ne=l(function(){var n,t,i,r,o,l,c,a,d,u,s,f;return{fields:null!==(n=null==G?void 0:G.fields)&&void 0!==n?n:D,thresholds:{high:null!==(i=null===(t=null==G?void 0:G.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:A.thresholds.high,medium:null!==(o=null===(r=null==G?void 0:G.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:A.thresholds.medium,exact:null!==(c=null===(l=null==G?void 0:G.thresholds)||void 0===l?void 0:l.exact)&&void 0!==c?c:A.thresholds.exact},relationStyles:{noContent:e(e({},A.relationStyles.noContent),(null===(a=null==G?void 0:G.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e(e({},A.relationStyles.high),(null===(d=null==G?void 0:G.relationStyles)||void 0===d?void 0:d.high)||{}),exact:e(e({},A.relationStyles.exact),(null===(u=null==G?void 0:G.relationStyles)||void 0===u?void 0:u.exact)||{}),medium:e(e({},A.relationStyles.medium),(null===(s=null==G?void 0:G.relationStyles)||void 0===s?void 0:s.medium)||{}),low:e(e({},A.relationStyles.low),(null===(f=null==G?void 0:G.relationStyles)||void 0===f?void 0:f.low)||{})}}},[G]),Oe=l(function(){if(K&&Object.keys(K).length>0)try{var n=function(n,t){var i,r,o,l,c,a,d,u;void 0===t&&(t=!1);var s=[],f=[],h=n.base_root_id,v=n.input_index_map||{0:"left",1:"right"},p=n[h];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var x=function(t,i){var r=n[t];if(!r)return null;var o=R(r,i,v),l=!!o.title.trim(),c=!!o.content.trim(),a=C(r),d=[];r.next&&Object.values(r.next).forEach(function(e){if(n[e]){var t=x(e,i);t&&d.push(t)}});var u=!(!l&&!c);return e({id:t,title:l?o.title:"",content:c?o.content:"",subsections:d},u?a:{score:void 0,relation:"not_defined"})};if(t){var g={},m={},y=-1,b=-1;for(var w in n)if(!["base_root_id","documents","input_index_map",h].includes(w)){var F=n[w];if(F&&!1!==F.display_node){var I=C(F),E=R(F,"0",v),S=R(F,"1",v),_=E.title.trim()||E.content.trim(),T=S.title.trim()||S.content.trim(),D=Number(null!==(r=null===(i=E.attributes)||void 0===i?void 0:i.display_index)&&void 0!==r?r:y--),A=Number(null!==(l=null===(o=S.attributes)||void 0===o?void 0:o.display_index)&&void 0!==l?l:b--),B=m[A]||e(e({id:w,title:T?S.title:"",content:T?S.content:"",subsections:[]},T?I:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:A}),k=g[D]||e(e({id:w,title:_?E.title:"",content:_?E.content:"",subsections:[]},_?I:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:D});Number(A)>=0&&Number(D)>=0&&(B.refIndexes.includes(Number(D))||B.refIndexes.push(Number(D)),k.refIndexes.includes(Number(A))||k.refIndexes.push(Number(A))),m[A]=B,g[D]=k}}f=Object.values(m).map(function(e){return e}),s=Object.values(g).map(function(e){return e}),f.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),s.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex})}else p.next&&Object.values(p.next).forEach(function(e){var t=n[e];t&&!1!==t.display_node&&(s.push(x(e,"0")||{id:e,title:"",content:"",subsections:[]}),f.push(x(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(a=null===(c=p.comparison_inputs)||void 0===c?void 0:c[v[0]])||void 0===a?void 0:a.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:(null===(u=null===(d=p.comparison_inputs)||void 0===d?void 0:d[v[1]])||void 0===u?void 0:u.title)||"Reference Template",similarity:0,sections:f,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(K,ie);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"}},[K,ie]),Pe=Oe.activeProposed,qe=Oe.activeVariants,Xe=Oe.parseError;c(function(){Xe&&ce("Failed to load comparison: ".concat(Xe))},[Xe]);var Ye=r(null),Ve=Ye[0];Ye[1];var Ue=r({}),Ke=Ue[0],Ge=Ue[1],Je=r({}),Qe=Je[0],Ze=Je[1],$e=(null==qe?void 0:qe[0])||H,en=null===(N=null===(L=null==K?void 0:K.documents)||void 0===L?void 0:L[null===(j=null==K?void 0:K.input_index_map)||void 0===j?void 0:j[0]])||void 0===N?void 0:N.title,nn=null===(q=null===(O=null==K?void 0:K.documents)||void 0===O?void 0:O[null===(P=null==K?void 0:K.input_index_map)||void 0===P?void 0:P[1]])||void 0===q?void 0:q.title,tn=I(J||en||"Uploaded Contract"),rn=I(Q||nn||"Reference Template"),on=l(function(){return(null==Pe?void 0:Pe.sections)||[]},[null==Pe?void 0:Pe.sections]),ln=l(function(){return $e.sections||[]},[$e.sections]),cn=on.length>0||ln.length>0,an=$e.analysis,dn=I(null===(Y=null===(X=null==an?void 0:an.rule_difference_comparison)||void 0===X?void 0:X.summary)||void 0===Y?void 0:Y.overall_summary),un=!!dn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),sn=o({}),fn=function(e){return sn.current[e]||(sn.current[e]=i.createRef()),sn.current[e]},hn=a(function(e,n,t,i,r){var o,l,c=I(n.id)||I(t.id)||"",a=(c?pe[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},d=null!==(l=null===(o=sn.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:d,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==K?void 0:K.documents,input_index_map:null==K?void 0:K.input_index_map}}},[pe]),vn=a(function(e){Le(),me(null),Ce(e)},[Le]),pn=a(function(){null!==_e.sectionIdx&&_e.anchorEl?vn(e(e({},_e),{open:!0})):Le()},[_e,Le,vn]);a(function(e){Le(),ce("".concat(e," is coming soon."))},[Le]);var xn=o(null),gn=o(null),mn=o(null),yn=r([]),bn=yn[0],wn=yn[1],Fn=r(null),In=Fn[0],En=Fn[1],Sn=o(null),Cn=r(null),Rn=Cn[0],_n=Cn[1],Tn=a(function(){null!==Sn.current&&window.cancelAnimationFrame(Sn.current),Sn.current=window.requestAnimationFrame(function(){Pn(),Sn.current=null})},[]),Dn=a(function(){var e=_e.sectionIdx;Le(),null!==e&&(de&&In===e?(ue(!1),En(null),he(!1),ke.current&&(ke.current.style.height="0px"),He.current&&(He.current.style.height="0px")):(ve.current=!0,En(e),ue(!0),he(!1),ke.current&&(ke.current.style.height="0px"),He.current&&(He.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i=null===(n=sn.current[e])||void 0===n?void 0:n.current,r=on[e],o=(null==r?void 0:r.refIndexes)||[],l=null;if(o.length>0){var c=o[0],a=ln.findIndex(function(e){return e.selfIndex===c});l=null===(t=Ln.current[a])||void 0===t?void 0:t.current}var d=null==i?void 0:i.parentElement,u=Be.current;if(i&&d){var s=d.clientHeight,f=i.offsetTop-(s/2-i.offsetHeight/2),h=d.scrollHeight-s,v=Math.max(0,Math.min(f,h)),p=i.offsetTop-v,x=null;if(l&&u){var g=l.offsetTop-p;if(g<0)ke.current&&(ke.current.style.height="".concat(Math.abs(g),"px")),x=0;else{var m=u.scrollHeight-u.clientHeight;g>m?(He.current&&(He.current.style.height="".concat(g-m+150,"px")),x=g):x=g}}M(d,v,300),u&&null!==x?M(u,x,300,function(){he(!0),Tn(),setTimeout(function(){ve.current=!1},50)}):setTimeout(function(){he(!0),Tn(),ve.current=!1},350)}})))},[Le,_e.sectionIdx,de,In,on,ln,Tn]),An=l(function(){return Ne.fields.filter(function(e){var n=e.key;return(!cn||"description"!==n)&&(E(null==Pe?void 0:Pe[n])||E($e[n]))})},[Pe,$e,cn,Ne.fields]),Bn=o({}),kn=o({}),Hn=o({}),zn=o({}),Mn=o({}),Wn=o({}),Ln=o({});An.forEach(function(e){for(var n=e.key,t=0;t<Math.max(on.length,ln.length);t+=1)Hn.current[t]||(Hn.current[t]=i.createRef()),zn.current[t]||(zn.current[t]=i.createRef()),Mn.current[t]||(Mn.current[t]=i.createRef()),Wn.current[t]||(Wn.current[t]=i.createRef()),Ln.current[t]||(Ln.current[t]=i.createRef());Bn.current[n]||(Bn.current[n]=i.createRef()),kn.current[n]||(kn.current[n]=i.createRef())});for(var jn=0;jn<Math.max(on.length,ln.length);jn+=1)Hn.current[jn]||(Hn.current[jn]=i.createRef()),zn.current[jn]||(zn.current[jn]=i.createRef()),Mn.current[jn]||(Mn.current[jn]=i.createRef()),Wn.current[jn]||(Wn.current[jn]=i.createRef()),Ln.current[jn]||(Ln.current[jn]=i.createRef());c(function(){if(Ve){var e=Ne.fields.find(function(e){return e.analysisKey===Ve||e.key===Ve});if(e){var n=Bn.current[e.key]||kn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Ve,Ne.fields]);var Nn=a(function(e){var n,t,i,r,o,l,c,a,d,u=null===(n=null==an?void 0:an.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=u[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 h=s.mappings[0]||{};return{score:s.score,relation:h.relation||"",highlightsA:(null===(l=h.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(c=h.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===(d=s.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!f}},[an]),On=a(function(n){var t,i,r,o,l=on[n],c=ln[n],a=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,d=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,u=I(null==l?void 0:l.id)||I(null==c?void 0:c.id)||"",s=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!a&&!d&&!s)return e(e({},Ne.relationStyles.noContent),{label:"Not Defined"});var f=Nn("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:u?null===(r=pe[u])||void 0===r?void 0:r.relevance_score:void 0)){var h=_(),v=h.score,p=h.relation;return S(v,p,!0,Ne)}var x=a?l.relation:d?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 S(m,x,!0,Ne)},[on,ln,pe,Ne,Nn]),Pn=a(function(){var e,n,t,i,r,o,l,c,a,d,u;if(!ze.current){ze.current=!0;try{if(!xn.current)return;var s=xn.current.getBoundingClientRect();Fe({width:s.width,height:s.height});var f=[];if(An.forEach(function(e){var n,t,i=e.key,r=null===(n=Bn.current[i])||void 0===n?void 0:n.current,o=null===(t=kn.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")}),!ie)for(var h=0;h<Math.min(on.length,ln.length);h++){var v=null===(e=Hn.current[h])||void 0===e?void 0:e.current,p=null===(n=zn.current[h])||void 0===n?void 0:n.current;v&&p&&(v.style.height="auto",p.style.height="auto",v.style.minHeight="0px",p.style.minHeight="0px")}var x={};An.forEach(function(e){var n,t,i=e.key,r=null===(n=Bn.current[i])||void 0===n?void 0:n.current,o=null===(t=kn.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(!ie)for(h=0;h<Math.min(on.length,ln.length);h++){v=null===(t=Hn.current[h])||void 0===t?void 0:t.current,p=null===(i=zn.current[h])||void 0===i?void 0:i.current;if(v&&p){var m=v.getBoundingClientRect(),y=p.getBoundingClientRect();g[h]=Math.max(m.height,y.height)}}if(An.forEach(function(e){var n,t,i=e.key,r=null===(n=Bn.current[i])||void 0===n?void 0:n.current,o=null===(t=kn.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")}}),!ie)for(h=0;h<g.length;h++){v=null===(r=Hn.current[h])||void 0===r?void 0:r.current,p=null===(o=zn.current[h])||void 0===o?void 0:o.current;if(v&&p){var b=g[h];v.style.minHeight="".concat(b,"px"),p.style.minHeight="".concat(b,"px")}}if(An.forEach(function(e){var n,t,i=e.key,r=e.analysisKey,o=null===(n=Bn.current[i])||void 0===n?void 0:n.current,l=null===(t=kn.current[i])||void 0===t?void 0:t.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=Nn(r),u=S(d.score,d.relation,d.hasContent,Ne);if(!u)return;var h=c.top+c.height/2-s.top;f.push({id:"field-".concat(i),x1:c.right-s.left,y1:h,x2:a.left-s.left,y2:h,style:u})}}),ie)on.forEach(function(e,n){var t;(null===(t=Hn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r=ln.findIndex(function(n){return n.selfIndex===e});if(-1!==r){var o=null===(t=Mn.current[n])||void 0===t?void 0:t.current,l=null===(i=Wn.current[r])||void 0===i?void 0:i.current;if(o&&l){var c=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=c.right-s.left,u=a.left-s.left,h=c.top+c.height/2-s.top,v=a.top+a.height/2-s.top;de&&In===n&&(v=h);var p=On(n);p&&f.push({id:"line-".concat(n,"-").concat(r),x1:d,y1:h,x2:u,y2:v,style:p,sectionIdx:n,targetRightIdx:r})}}})});else for(h=0;h<Math.min(on.length,ln.length);h++){var w=null===(l=Hn.current[h])||void 0===l?void 0:l.current,F=null===(c=zn.current[h])||void 0===c?void 0:c.current;if(w&&F){var I=w.querySelector(".MuiAccordionSummary-root"),E=F.querySelector(".MuiAccordionSummary-root");if(I&&E){var C=I.getBoundingClientRect(),R=E.getBoundingClientRect(),_=(C.top+C.height/2-s.top+R.top+R.height/2-s.top)/2,T=(null===(a=ln[h])||void 0===a?void 0:a.id)||"sec-".concat(h),D=On(h);D&&f.push({id:T,x1:C.right-s.left,y1:_,x2:R.left-s.left,y2:_,style:D,sectionIdx:h,hasCognitive:!!((null===(d=on[h])||void 0===d?void 0:d.cognitiveData)||(null===(u=ln[h])||void 0===u?void 0:u.cognitiveData)||T&&pe[T])})}}}if(wn(f),gn.current&&mn.current){var A=gn.current.getBoundingClientRect(),B=mn.current.getBoundingClientRect(),k=(A.top+A.height/2-s.top+B.top+B.height/2-s.top)/2;_n({x1:A.right-s.left,x2:B.left-s.left,y:k})}else _n(null)}catch(e){console.error("Line render safe fail: ",e)}finally{ze.current=!1}}},[An,on,ln,pe,Ne,Nn,On,ie,de,In]),qn=a(function(){ve.current||(Tn(),de&&!ve.current&&(ue(!1),En(null),he(!1),ke.current&&(ke.current.style.height="0px"),He.current&&(He.current.style.height="0px")))},[Tn,de]);c(function(){var e=setTimeout(Tn,250);window.addEventListener("resize",Tn);var n=null,t=null;return De.current&&(n=new ResizeObserver(Tn)).observe(De.current),xn.current&&(t=new ResizeObserver(Tn)).observe(xn.current),function(){clearTimeout(e),window.removeEventListener("resize",Tn),null==n||n.disconnect(),null==t||t.disconnect()}},[Pe,$e,an,An,Ke,Qe,on,ln,Ne,Tn,de,In,fe]);var Xn=function(r,o,l,c,a){void 0===a&&(a=1);var u,s=ie?!!Ke["".concat(l,"-").concat(o)]:!!Ke[String(o)],h=E(r.title),v=E(r.content),b=!h&&!v,w=r.title;return h||(w=v?"No Title Found":"No Matching Section Found"),t(d,e({ref:c,sx:e(e({mb:a},ie?{height:"fit-content"}:{minHeight:0}),{display:"flex",flexDirection:"column",position:"relative"})},{children:n(x,e({disableGutters:!0,expanded:!b&&s,onChange:function(){return!b&&function(n,t){Ge(function(i){var r=e({},i);if(!ie){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=on[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=ln.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=c)});else{var a,d=null==(a=ln[n])?void 0:a.selfIndex;on.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(d))&&(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:[t(g,e({expandIcon:b?null:t(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:t(p,e({title:w,placement:"top"},{children:t(f,e({sx:{fontSize:"12px",color:b?"#94A3B8":"#19213D",fontWeight:b?400:700,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:(u=w,u?I(u).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,n){return e.startsWith("**")&&e.endsWith("**")?t("strong",{children:e.slice(2,-2)},n):t(i.Fragment,{children:e},n)}):null)}))}))})),!b&&n(m,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column"}},{children:[t(f,e({component:"div",sx:Ie},{children:t(F,{children:I(r.content).replace(/\\n/g,"\n")})})),(r.subsections||[]).map(function(e,n){return Yn(e,"".concat(o,"-").concat(n),0)})]}))]}))}),"".concat(l,"-sec-").concat(o))},Yn=function(i,r,o){void 0===o&&(o=0);var l=E(i.title),c=E(i.content),a=!l&&!c,u=l?i.title:c?"No Title Found":"No Matching Section Found",s=!!Qe[r];return i.title?n(x,e({disableGutters:!0,expanded:!a&&s,onChange:function(){return!a&&Ze(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:[t(g,e({expandIcon:a?null:t(y,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5}}},{children:t(f,e({sx:{fontSize:"11px",fontWeight:600,color:a?"#94A3B8":"#19213D"}},{children:u||"Untitled Subsection"}))})),!a&&n(m,e({sx:{pt:0,pb:1}},{children:[c&&t(f,e({component:"div",sx:Ie},{children:t(F,{children:I(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Yn(e,"".concat(r,"-").concat(n),o+1)})]}))]}),r):t(d,e({sx:{mt:0===o?1:.75}},{children:!a&&n("div",{children:[c&&t(f,e({component:"div",sx:Ie},{children:t(F,{children:I(i.content).replace(/\\n/g,"\n")})})),(i.subsections||[]).map(function(e,n){return Yn(e,"".concat(r,"-").concat(n),o+1)})]})}),r)};return n(d,e({ref:Ae,sx:e(e({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ie?{}:{overflow:"visible"}),{position:"relative"})},{children:[ie&&t(k,{open:_e.open,anchorEl:_e.anchorEl,sectionTitle:_e.sectionTitle,referenceSectionTitle:_e.refSectionTitle,onClose:Le,onOpenCognitiveCompare:pn,onOpenSideBySide:Dn}),Se.open&&t(B,{open:Se.open,popupRef:ye,position:ge,popupConfig:ne,onClose:function(){me(null),Ce(function(n){return e(e({},n),{open:!1})})},markdownStyles:Z,sectionTitle:Se.sectionTitle,referenceSectionTitle:Se.refSectionTitle,cognitiveData:Se.cognitiveData,anchorEl:Se.anchorEl,sectionAnchorEl:Se.sectionAnchorEl,scrollContainerEl:De.current,badgeStyle:Se.badgeStyle,docData:Se.docData}),t(u,e({open:!!le,autoHideDuration:8e3,onClose:function(){return ce(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:t(s,e({onClose:function(){return ce(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:le}))})),n(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:[t(d,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:t(f,e({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:U}))})),t(d,e({sx:{display:"flex",alignItems:"center"}},{children:t(h,{control:t(v,{checked:ie,onChange:function(e){return re(e.target.checked)},color:"primary",size:"small"}),label:t(f,e({sx:{fontSize:"13px",fontWeight:500,color:"#64748B"}},{children:"Relative Order"})),labelPlacement:"start",sx:{m:0,gap:1}})}))]})),t(d,e({ref:De,onScroll:qn,sx:{flex:1,minHeight:0,pt:1.5,pb:8,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ie?"hidden":"auto",borderTop:dn&&un?"none":"1.5px solid #EEF0F4"}},{children:t(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ie?{flex:1,minHeight:0}:{})},{children:n(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},ie?{flex:1,overflow:"visible"}:{})},{children:[n("svg",e({style:{position:"absolute",top:0,left:0,width:we.width||"100%",height:we.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible"}},{children:[Rn&&n("g",{children:[t("line",{x1:Rn.x1,y1:Rn.y,x2:Math.max(Rn.x1,(Rn.x1+Rn.x2)/2-70),y2:Rn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),t("line",{x1:Math.min(Rn.x2,(Rn.x1+Rn.x2)/2+70),y1:Rn.y,x2:Rn.x2,y2:Rn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),bn.map(function(i){var r,o=(i.x1+i.x2)/2;if("Not Defined"===i.style.label&&!i.hasCognitive)return null;if(!ie)return n("g",{children:[t("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),t("foreignObject",e({x:o-100,y:i.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:t(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n(d,e({onClick:function(e){var n=on[i.sectionIdx]||{title:"",content:""},t=ln[i.sectionIdx]||{title:"",content:""};vn(hn(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,t(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(w,{})})),t(y,{size:11})]}))}))}))]},i.id);var l=on[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:de&&In===i.sectionIdx&&fe?n("g",e({style:{transition:"opacity 0.2s"}},{children:[t("defs",{children:t("marker",e({id:"arr-".concat(i.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:t("polygon",{points:"0 0, 7 2.5, 0 5",fill:i.style.badgeBorder||"#6366F1"})}))}),t("line",{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})]})),n(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)"},ie?{flex:1,overflow:"visible"}:{})},{children:[t(d,e({ref:gn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:t(p,e({title:tn,placement:"top"},{children:t(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:tn}))}))})),t(d,e({onScroll:qn,sx:e({p:"12px",display:"flex",flexDirection:"column"},ie?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:cn&&on.map(function(r,o){var l;if(!ie)return t(d,e({ref:fn(o)},{children:Xn(r,o,"left",Hn.current[o])}),"left-row-".concat(o));var c=r,a=On(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;return t(d,e({ref:fn(o),sx:{mb:1}},{children:n(d,e({sx:{position:"relative",width:"100%"}},{children:[t(d,e({ref:Hn.current[o],sx:{width:"100%"}},{children:Xn(r,o,"left",i.createRef(),0)})),a&&n(d,e({ref:Mn.current[o],onClick:function(e){var n=ln.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(),_e.open&&_e.sectionIdx===i?Le():(We(),Te(hn(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&&t(d,e({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:s})),t(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")})),t(b,{size:11,color:a.badgeText})]}))]}))}),"left-row-".concat(o))})}))]})),t(d,e({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"6px",gap:0}},{children:t(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n(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:[t(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:t(w,{})})),0,"% Similarity",t(y,{size:11})]}))}))})),n(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},ie?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[t(d,e({ref:mn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:t(p,e({title:rn,placement:"top"},{children:t(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:rn}))}))})),n(d,e({ref:Be,onScroll:qn,sx:e({p:"12px",display:"flex",flexDirection:"column"},ie?{maxHeight:"500px",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-160px",pl:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[t("div",{ref:ke,style:{width:"100%",height:"0px",flexShrink:0}}),cn&&ln.map(function(r,o){if(!ie)return Xn(r,o,"right",zn.current[o]);var l=r,c=on.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});return t(d,e({ref:Ln.current[o],sx:{mb:1}},{children:n(d,e({sx:{position:"relative",width:"100%"}},{children:[t(d,e({ref:zn.current[o],sx:{width:"100%"}},{children:Xn(r,o,"right",i.createRef(),0)})),t(d,e({ref:Wn.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))}),t("div",{ref:He,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{W as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,6 +1,6 @@
1
1
  import { CognitiveCompareProps } from "./CognitiveCompareTypes";
2
2
  import { SHARED_MARKDOWN_STYLES } from "./CognitiveCompareConfig";
3
- declare const CognitiveCompare: ({ componentHeaderText, treeData, comparisonConfig, leftColumnTitleText, rightColumnTitleText, markdownStyles, maintainRelativeOrder, popupConfig, }: CognitiveCompareProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const CognitiveCompare: ({ componentHeaderText, treeData, comparisonConfig, leftColumnTitleText, rightColumnTitleText, markdownStyles, maintainRelativeOrder: initialMaintainRelativeOrder, popupConfig, }: CognitiveCompareProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export { SHARED_MARKDOWN_STYLES };
5
5
  export default CognitiveCompare;
6
6
  //# sourceMappingURL=CognitiveCompare.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAIL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAqNlC,QAAA,MAAM,gBAAgB,wJASnB,qBAAqB,4CAgyDvB,CAAC;AACF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AA+BA,OAAO,EAIL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AA4PlC,QAAA,MAAM,gBAAgB,sLASnB,qBAAqB,4CAy1DvB,CAAC;AACF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viswa-test/test-citation",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "author": "Viswa Koduru",
5
5
  "description": "",
6
6
  "license": "MIT",