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