@viswa-test/test-citation 0.0.39 → 0.0.40

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.
Files changed (23) hide show
  1. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
  4. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  5. package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
  6. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  7. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  8. package/dist/features/CognitiveCompare/MoreFunctionsPopup.js +1 -1
  9. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  10. package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
  11. package/dist/types/src/CommonConstants/CommonConstants.d.ts +1147 -1264
  12. package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
  13. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  14. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  15. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -1
  16. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  17. package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts +1 -0
  18. package/dist/types/src/features/CognitiveCompare/MoreFunctionsPopup.d.ts.map +1 -1
  19. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts +3 -1
  20. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
  21. package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts +1 -1
  22. package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
  23. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),n=require("react/jsx-runtime"),e=require("lucide-react"),l=require("react"),t=require("./ResizableSplitPane.js"),o=require("../PdfViewer/PdfViewer.js");exports.default=function(r){var a,u,d,s=r.href,c=r.children,g=r.metaData,v=r.chevronUpComponent,h=void 0===v?null:v,p=r.chevronDownComponent,f=void 0===p?null:p,m=r.customStyle,_=void 0===m?{}:m,x=r.defaultState,j=void 0!==x&&x,y=l.useState(j),C=y[0],P=y[1],b="string"==typeof c&&(null===(a=null==c?void 0:c.split("\n"))||void 0===a?void 0:a.length)>1?c.split("\n").join(" "):c,w="string"==typeof c?c:c[0],D=null!=h?h:function(i){var l,t;return n.jsx(e.ChevronUp,{size:null!==(l=null==i?void 0:i.fontSize)&&void 0!==l?l:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(u=null==_?void 0:_.arrow)&&void 0!==u?u:{}),S=null!=f?f:function(i){var l,t;return n.jsx(e.ChevronDown,{size:null!==(l=null==i?void 0:i.fontSize)&&void 0!==l?l:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(d=null==_?void 0:_.arrow)&&void 0!==d?d:{}),q=["contract","clause"];return n.jsxs("span",i.__assign({style:i.__assign({display:"inline"},_.relativeWrapper||{})},{children:[n.jsx("div",i.__assign({style:i.__assign({display:"inline",marginTop:0},_.citationButtonWrapper||{})},{children:n.jsxs("button",i.__assign({type:"button",onClick:function(){return P(function(i){return!i})},style:i.__assign({display:"inline-flex",alignItems:"center",gap:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:700,color:"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},_.citationButton||{})},{children:[n.jsx("span",{children:b}),n.jsx("span",i.__assign({style:{display:"flex",alignItems:"center"}},{children:C?D:S}))]}))})),C&&n.jsx(n.Fragment,{children:n.jsx(function(){var i,e,l,r,a,u,d;console.log("citation details ->","href ->",s,"children ->",c,"metaData ->",g,"citationDisplayTitle ->",b);var v=function(i){try{return new URL(i,window.location.origin).searchParams.get("citationNumber")}catch(i){return null}}(s);if(!v)return null;var h=(null===(i=null==g?void 0:g.citations)||void 0===i?void 0:i[v])||{},p=(null===(e=null==g?void 0:g.docData)||void 0===e?void 0:e.documents)||{},f=(null===(l=null==g?void 0:g.docData)||void 0===l?void 0:l.input_index_map)||{},m=null==f?void 0:f[0],_=null==f?void 0:f[1],x=m?p[m]:null,j=_?p[_]:null,y=m?h[m]:null,C=_?h[_]:null;if(q.includes(w)){console.log("leftDocument",x,"rightDocument",j),console.log("leftCitation",y,"rightCitation",C);var P=y?n.jsx(o.default,{defaultScale:"PageWidth",showHighlightsAction:!1,pdfName:x.title,pdfUrl:x.signed_url,highlightText:[null!==(r=null==y?void 0:y.highlighted_text)&&void 0!==r?r:""],highlightPages:{1:null===(a=null==y?void 0:y.custom_metadata)||void 0===a?void 0:a.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1}):null,D=C?n.jsx(o.default,{defaultScale:"PageWidth",showHighlightsAction:!1,pdfName:j.title,pdfUrl:j.signed_url,jumpToPageValue:1,highlightText:[null!==(u=null==C?void 0:C.highlighted_text)&&void 0!==u?u:""],highlightPages:{1:null===(d=null==C?void 0:C.custom_metadata)||void 0===d?void 0:d.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1}):null;return y||C?n.jsx("div",{children:n.jsx(t.default,{leftComponent:P,rightComponent:D})}):n.jsx("div",{children:"Missing PDF Citation. Please try again later"})}return n.jsx("div",{children:"No Citation Found. Please try again later"})},{})})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("lucide-react"),l=require("react"),t=require("./ResizableSplitPane.js"),o=require("../PdfViewer/PdfViewer.js");exports.default=function(a){var r,d,u,s=a.href,g=a.children,c=a.metaData,v=a.chevronUpComponent,h=void 0===v?null:v,p=a.chevronDownComponent,f=void 0===p?null:p,_=a.customStyle,m=void 0===_?{}:_,x=a.defaultState,j=void 0!==x&&x,b=l.useState(j),y=b[0],P=b[1],C="string"==typeof g&&(null===(r=null==g?void 0:g.split("\n"))||void 0===r?void 0:r.length)>1?g.split("\n").join(" "):g,w="string"==typeof g?g:g[0],D=null!=h?h:function(e){var l,t;return n.jsx(i.ChevronUp,{size:null!==(l=null==e?void 0:e.fontSize)&&void 0!==l?l:16,color:null!==(t=null==e?void 0:e.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(d=null==m?void 0:m.arrow)&&void 0!==d?d:{}),S=null!=f?f:function(e){var l,t;return n.jsx(i.ChevronDown,{size:null!==(l=null==e?void 0:e.fontSize)&&void 0!==l?l:16,color:null!==(t=null==e?void 0:e.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(u=null==m?void 0:m.arrow)&&void 0!==u?u:{}),q=["contract","clause"];return n.jsxs("span",e.__assign({style:e.__assign({display:"inline"},m.relativeWrapper||{})},{children:[n.jsx("div",e.__assign({style:e.__assign({display:"inline",marginTop:0},m.citationButtonWrapper||{})},{children:n.jsxs("button",e.__assign({type:"button",onClick:function(){return P(function(e){return!e})},style:e.__assign({display:"inline-flex",alignItems:"center",gap:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:700,color:"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},m.citationButton||{})},{children:[n.jsx("span",{children:C}),n.jsx("span",e.__assign({style:{display:"flex",alignItems:"center"}},{children:y?D:S}))]}))})),y&&n.jsx(n.Fragment,{children:n.jsx(function(){var e,i,l,a,r,d,u,v,h,p,f;console.log("citation details ->","href ->",s,"children ->",g,"metaData ->",c,"citationDisplayTitle ->",C);var _=function(e){try{return new URL(e,window.location.origin).searchParams.get("citationNumber")}catch(e){return null}}(s);if(!_)return null;var m=(null===(e=null==c?void 0:c.citations)||void 0===e?void 0:e[_])||{},x=(null===(i=null==c?void 0:c.docData)||void 0===i?void 0:i.documents)||{},j=(null===(l=null==c?void 0:c.docData)||void 0===l?void 0:l.input_index_map)||{},b=null==j?void 0:j[0],y=null==j?void 0:j[1],P=b?x[b]:null,D=y?x[y]:null,S=b?m[b]:null,z=y?m[y]:null;if(q.includes(w)){console.log("leftDocument",P,"rightDocument",D),console.log("leftCitation",S,"rightCitation",z);var T=S?n.jsx(o.default,{defaultScale:"PageWidth",showHighlightsAction:!1,pdfName:P.title,pdfUrl:P.signed_url,highlightText:[null!==(a=null==S?void 0:S.highlighted_text)&&void 0!==a?a:""],highlightPages:{1:null===(r=null==S?void 0:S.custom_metadata)||void 0===r?void 0:r.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(d=null==S?void 0:S.custom_metadata)||void 0===d?void 0:d.pdf_start_page_number,null===(u=null==S?void 0:S.custom_metadata)||void 0===u?void 0:u.pdf_end_page_number]}):null,R=z?n.jsx(o.default,{defaultScale:"PageWidth",showHighlightsAction:!1,pdfName:D.title,pdfUrl:D.signed_url,jumpToPageValue:1,highlightText:[null!==(v=null==z?void 0:z.highlighted_text)&&void 0!==v?v:""],highlightPages:{1:null===(h=null==z?void 0:z.custom_metadata)||void 0===h?void 0:h.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(p=null==z?void 0:z.custom_metadata)||void 0===p?void 0:p.pdf_start_page_number,null===(f=null==z?void 0:z.custom_metadata)||void 0===f?void 0:f.pdf_end_page_number]}):null;return S||z?n.jsx("div",{children:n.jsx(t.default,{leftComponent:T,rightComponent:R})}):n.jsx("div",{children:"Missing PDF Citation. Please try again later"})}return n.jsx("div",{children:"No Citation Found. Please try again later"})},{})})]}))};
2
2
  //# sourceMappingURL=CitationAnchor.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),r=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("react-markdown"),a=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),u=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),f=require("./LoaderComponent.js"),v=require("rehype-raw");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=p(t),g=p(s),x=p(v),m=h.default.memo(function(r){var o=r.content,l=r.sxStyles,s=r.highlights,c=void 0===s?[]:s,u=t.useMemo(function(){return{mark:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{backgroundColor:"#fccccc"}},{children:i}))}}},[]),d=t.useMemo(function(){var e=o;return c.forEach(function(n){e=e.replaceAll(n,"<mark>".concat(n,"</mark>"))}),e},[o,c]);return n.jsx(i.Typography,e.__assign({component:"div",sx:l},{children:n.jsx(g.default,e.__assign({components:u,rehypePlugins:[x.default]},{children:a.safeStringify(d).replace(/\\n/g,"\n")}))}))},function(e,n){if(e.content!==n.content)return!1;if(e.sxStyles!==n.sxStyles)return!1;var t=e.highlights||[],i=n.highlights||[];if(t.length!==i.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==i[r])return!1;return!0}),_=function(e,n,t,i,r){void 0===r&&(r=14);var o=e+.65*(t-e),l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var s=l>0?1:-1,a=Math.min(r,Math.abs(l)/2,Math.abs(o-e)/2,Math.abs(t-o)/2);return["M ".concat(e," ").concat(n),"H ".concat(o-a),"Q ".concat(o," ").concat(n," ").concat(o," ").concat(n+s*a),"V ".concat(i-s*a),"Q ".concat(o," ").concat(i," ").concat(o+a," ").concat(i),"H ".concat(t)].join(" ")},b={id:"",title:""},y={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},S=function(e,n,t,i,r){void 0===t&&(t=300);var o=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,s=n-l,a=null,c=function(u){null===a&&(a=u);var d,f=u-a;f<t?(e.scrollTop=(d=f,d/=t,s*(--d*d*d+1)+l),r&&r(),requestAnimationFrame(c)):(e.scrollTop=n,e.style.scrollBehavior=o,r&&r(),i&&i())};requestAnimationFrame(c)};exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(s){var v,p,g,x,R,I,C,w,F=s.componentHeaderText,j=void 0===F?"Contract Comparison":F,B=s.treeData,E=s.comparisonConfig,T=s.leftColumnTitleText,D=s.rightColumnTitleText,A=s.markdownStyles,k=s.displayConfig,M=void 0===k?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:k,O=s.popupConfig,N=s.deviationData,H=void 0===N?{}:N,L=t.useState(M.maintainRelativeOrder),W=L[0],z=L[1],P=t.useState(!1),q=P[0],V=P[1],Y=t.useState(!1),K=Y[0],U=Y[1],X=t.useState(null),G=X[0],J=X[1],Q=t.useState(!1),Z=Q[0],$=Q[1],ee=t.useState(!1),ne=ee[0],te=ee[1],ie=t.useRef(!1),re=t.useState(null),oe=re[0],le=re[1],se=t.useState(new Set),ae=se[0],ce=se[1],ue=t.useState([]),de=ue[0],fe=ue[1],ve=t.useRef(null),pe=t.useRef(!1),he=t.useRef(null),ge=t.useRef({}),xe=t.useRef([]),me=t.useRef(!1),_e=t.useRef(!1),be=t.useRef(null),ye=t.useMemo(function(){return(null==B?void 0:B.cognitive_decisioning)||{}},[B]),Se=t.useState(null),Re=Se[0],Ie=Se[1],Ce=t.useRef(null),we=t.useState({width:0,height:0}),Fe=we[0],je=we[1],Be=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),A)},[A]),Ee=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),Te=Ee[0],De=Ee[1],Ae=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),ke=Ae[0],Me=Ae[1],Oe=t.useRef(null),Ne=t.useRef(null),He=t.useRef(null),Le=t.useRef(null),We=t.useRef(null),ze=t.useRef(null),Pe=t.useRef(null),qe=t.useRef(null),Ve=t.useRef(!1),Ye=t.useRef(null);t.useEffect(function(){Ye.current=null},[Te.sectionIdx,Te.open]);var Ke=t.useCallback(function(){Ie(null),De(y),le(null)},[]),Ue=t.useCallback(function(){Me(y)},[]),Xe=t.useCallback(function(){var e;if(Te.anchorEl&&Te.refSectionTitle){var n=Te.anchorEl.getBoundingClientRect(),t=(null===(e=null==Ce?void 0:Ce.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),r=window.innerHeight-n.bottom-12-12,o=n.top-12-12,l=r<t&&o>r;null!==Ye.current?!0===Ye.current&&(l=o>=t||o>=r):l=!(r>=t||r>=o),Ye.current=l;var s=l?o:r,a=Math.min(t||9999,s),c=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,d=u-i/2,f=Math.max(12,Math.min(d,window.innerWidth-i-12)),v=Math.max(14,Math.min(u-f,i-10-4));Ie({top:c,left:f,arrowLeft:v,openAbove:l,maxHeight:s})}},[Te.anchorEl,Te.refSectionTitle]);t.useEffect(function(){if(Te.open){window.addEventListener("resize",Xe);var e=requestAnimationFrame(Xe),n=null;return Ce.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(Xe)})).observe(Ce.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",Xe),n&&n.disconnect()}}},[Te.open,Xe]),t.useEffect(function(){var e=Oe.current;if(e&&Te.open){var n=function(e){Ce.current&&Ce.current.contains(e.target)||(Ie(null),Ke())};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[Te.open,Ke]),t.useEffect(function(){var e=Oe.current;if(e&&ke.open){var n=function(){Ue()};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})}}},[ke.open,Ue]);var Ge=t.useMemo(function(){var n,t,i,r,o,l,s,a,u,d,f,v;return{fields:null!==(n=null==E?void 0:E.fields)&&void 0!==n?n:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==E?void 0:E.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(r=null==E?void 0:E.thresholds)||void 0===r?void 0:r.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==E?void 0:E.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(a=null==E?void 0:E.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==E?void 0:E.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==E?void 0:E.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(f=null==E?void 0:E.relationStyles)||void 0===f?void 0:f.medium)||{}),low:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(v=null==E?void 0:E.relationStyles)||void 0===v?void 0:v.low)||{})}}},[E]),Je=t.useMemo(function(){if(B&&Object.keys(B).length>0)try{var n=function(n,t,i){var r,o,l,s;void 0===t&&(t=!1),void 0===i&&(i=null);var c=n.nodes||n,u=[],d=[],f=n.base_root_id,v=n.input_index_map||{0:"left",1:"right"},p=n[f]||c[f];if(!p||!1===p.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var h=function(t,r){var o,l=n[t]||c[t];if(!l||!1===l.display_node)return null;var s=a.getSideData(l,r,v),u=!!s.title.trim(),d=!!s.content.trim(),f=a.getRationale(l),p=(null===(o=null==i?void 0:i[t])||void 0===o?void 0:o.evaluation_result)||l.evaluation_result||null,g=[];l.next&&Object.values(l.next).forEach(function(e){var n=c[e];if(n&&!1!==n.display_node){var t=h(e,r);t&&g.push(t)}});var x=!(!u&&!d);return e.__assign(e.__assign({id:t,title:u?s.title:"",content:d?s.content:"",subsections:g},x?f:{score:void 0,relation:"not_defined"}),{evaluationResult:p})};if(t){var g=function(t,r){var o,l,s,u,d,f,p,h,x,m,_,b,y;void 0===r&&(r=0);var S=[],R=[];if(!t)return{refSections:S,baseSections:R};var I={},C={},w=-1,F=-1;for(var j in t){var B=t[j],E=n[B]||c[B];if(E&&!1!==E.display_node){var T=a.getRationale(E),D=(null===(o=null==i?void 0:i[B])||void 0===o?void 0:o.evaluation_result)||E.evaluation_result||null,A=a.getSideData(E,"1",v),k=a.getSideData(E,"0",v),M=A.title.trim()||A.content.trim(),O=k.title.trim()||k.content.trim(),N=Number(null!==(s=null===(l=A.attributes)||void 0===l?void 0:l.display_index)&&void 0!==s?s:w--),H=Number(null!==(d=null===(u=k.attributes)||void 0===u?void 0:u.display_index)&&void 0!==d?d:F--),L=I[N]||e.__assign(e.__assign({id:B,title:M?A.title:"",content:M?A.content:"",subsections:[]},M?T:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:N,evaluationResult:D,displayContent:null===(f=A.attributes)||void 0===f?void 0:f.display_content,displayTitle:null===(p=A.attributes)||void 0===p?void 0:p.display_title}),W=C[H]||e.__assign(e.__assign({id:B,title:O?k.title:"",content:O?k.content:"",subsections:[]},O?T:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:H,evaluationResult:D,displayContent:null===(h=k.attributes)||void 0===h?void 0:h.display_content,displayTitle:null===(x=k.attributes)||void 0===x?void 0:x.display_title});Number(N)>=0&&Number(H)>=0&&((null===(m=L.refIndexes)||void 0===m?void 0:m.includes(Number(H)))||null===(_=L.refIndexes)||void 0===_||_.push(Number(H)),(null===(b=W.refIndexes)||void 0===b?void 0:b.includes(Number(N)))||null===(y=W.refIndexes)||void 0===y||y.push(Number(N))),I[N]=L,C[H]=W;var z=g(E.next,r+1),P=z.refSections,q=z.baseSections;P.length>0&&(L.subsections=e.__spreadArray(e.__spreadArray([],L.subsections||[],!0),P,!0)),q.length>0&&(W.subsections=e.__spreadArray(e.__spreadArray([],W.subsections||[],!0),q,!0))}}return S=Object.values(I).map(function(e){return e}),R=Object.values(C).map(function(e){return e}),S.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),R.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:S,baseSections:R}},x=g(p.next),m=x.refSections,_=x.baseSections;d=m,u=_}else p.next&&Object.values(p.next).forEach(function(e){var t=n[e]||c[e];t&&!1!==t.display_node&&(u.push(h(e,"0")||{id:e,title:"",content:"",subsections:[]}),d.push(h(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(o=null===(r=p.comparison_inputs)||void 0===r?void 0:r[v[0]])||void 0===o?void 0:o.title)||"Uploaded Contract",description:p.decision_scope_description||"",sections:u},activeVariants:[{id:"tree-variant-1",title:(null===(s=null===(l=p.comparison_inputs)||void 0===l?void 0:l[v[1]])||void 0===s?void 0:s.title)||"Reference Template",similarity:0,sections:d,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:p.decision_scope_description||""},fields:{}}}}]}}(B,W,H);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(B),W,JSON.stringify(H)]),Qe=Je.activeProposed,Ze=Je.activeVariants,$e=Je.parseError;t.useEffect(function(){$e&&J("Failed to load comparison: ".concat($e))},[$e]);var en=t.useState(null),nn=en[0];en[1];var tn=t.useState({}),rn=tn[0],on=tn[1],ln=t.useState({}),sn=ln[0],an=ln[1],cn=(null==Ze?void 0:Ze[0])||b,un=null===(g=null===(v=null==B?void 0:B.documents)||void 0===v?void 0:v[null===(p=null==B?void 0:B.input_index_map)||void 0===p?void 0:p[0]])||void 0===g?void 0:g.title,dn=null===(I=null===(x=null==B?void 0:B.documents)||void 0===x?void 0:x[null===(R=null==B?void 0:B.input_index_map)||void 0===R?void 0:R[1]])||void 0===I?void 0:I.title,fn=a.safeStringify(T||un||"Uploaded Contract"),vn=a.safeStringify(D||dn||"Reference Template"),pn=t.useMemo(function(){return(null==Qe?void 0:Qe.sections)||[]},[null==Qe?void 0:Qe.sections]),hn=t.useMemo(function(){return cn.sections||[]},[cn.sections]),gn=pn.length>0||hn.length>0,xn=cn.analysis,mn=a.safeStringify(null===(w=null===(C=null==xn?void 0:xn.rule_difference_comparison)||void 0===C?void 0:C.summary)||void 0===w?void 0:w.overall_summary),_n=!!mn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),bn=t.useRef({}),yn=function(e){return bn.current[e]||(bn.current[e]=h.default.createRef()),bn.current[e]},Sn=t.useCallback(function(){$(!1),_e.current=!1,Hn(null),be.current=null,Bn.current=null,te(!1),U(!1),Le.current&&(Le.current.style.height="0px"),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px")},[]),Rn=t.useCallback(function(e,n,t,i,r,o){var l,s,c=a.safeStringify(n.id)||a.safeStringify(t.id)||"",u=(c?ye[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},d=null!==(s=null===(l=bn.current[i])||void 0===l?void 0:l.current)&&void 0!==s?s:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:u,anchorEl:e,sectionAnchorEl:d,badgeStyle:o||null,sectionIdx:i,docData:{documents:null==B?void 0:B.documents,input_index_map:null==B?void 0:B.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!r}},[ye,B]),In=t.useCallback(function(e){Ue(),Ie(null),De(e)},[Ue]),Cn=function(e,n,t,i,r,o){e.stopPropagation(),ke.open&&ke.sectionIdx===r?Ue():(Ke(),Me(Rn(e.currentTarget,n,i,r,t,o)))},wn=t.useCallback(function(){null!==ke.sectionIdx&&ke.anchorEl?In(e.__assign(e.__assign({},ke),{open:!0})):Ue()},[ke,Ue,In]);t.useCallback(function(e){Ue(),J("".concat(e," is coming soon."))},[Ue]);var Fn=t.useCallback(function(){var e=ke.sectionIdx,n=ke.isOrphan;if(Ue(),null!==e){if(n)return J("No counterpart exists to connect to."),void Ue();_e.current&&Sn(),ce(function(n){return n.has(e)?new Set:new Set([e])})}},[ke.sectionIdx,Ue,Sn]),jn=t.useRef(null),Bn=t.useRef(null),En=t.useRef(null),Tn=t.useRef(null),Dn=t.useRef(null),An=t.useState([]),kn=An[0],Mn=An[1],On=t.useState(null),Nn=On[0],Hn=On[1];t.useRef(null);var Ln=t.useState(null),Wn=Ln[0],zn=Ln[1],Pn=t.useMemo(function(){return Ge.fields.filter(function(e){var n=e.key;return(!gn||"description"!==n)&&(a.hasValue(null==Qe?void 0:Qe[n])||a.hasValue(cn[n]))})},[Qe,cn,gn,Ge.fields]),qn=t.useRef({}),Vn=t.useRef({}),Yn=t.useRef({}),Kn=t.useRef({}),Un=t.useRef({}),Xn=t.useRef({}),Gn=t.useRef({}),Jn=t.useRef({}),Qn=t.useRef({});Pn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(pn.length,hn.length);t+=1)Yn.current[t]||(Yn.current[t]=h.default.createRef()),Kn.current[t]||(Kn.current[t]=h.default.createRef()),Un.current[t]||(Un.current[t]=h.default.createRef()),Xn.current[t]||(Xn.current[t]=h.default.createRef()),Gn.current[t]||(Gn.current[t]=h.default.createRef());qn.current[n]||(qn.current[n]=h.default.createRef()),Vn.current[n]||(Vn.current[n]=h.default.createRef())});for(var Zn=0;Zn<Math.max(pn.length,hn.length);Zn+=1)Yn.current[Zn]||(Yn.current[Zn]=h.default.createRef()),Kn.current[Zn]||(Kn.current[Zn]=h.default.createRef()),Un.current[Zn]||(Un.current[Zn]=h.default.createRef()),Xn.current[Zn]||(Xn.current[Zn]=h.default.createRef()),Gn.current[Zn]||(Gn.current[Zn]=h.default.createRef());t.useEffect(function(){if(nn){var e=Ge.fields.find(function(e){return e.analysisKey===nn||e.key===nn});if(e){var n=qn.current[e.key]||Vn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[nn,Ge.fields]);var $n=t.useCallback(function(e){var n,t,i,r,o,l,s,a,c,u=null===(n=null==xn?void 0:xn.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],f=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(o=null===(r=null==d?void 0:d.highlights)||void 0===r?void 0:r.ruleB_spans)||void 0===o?void 0:o.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var v=d.mappings[0]||{};return{score:d.score,relation:v.relation||"",highlightsA:(null===(l=v.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=v.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!f}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!f}},[xn]),et=t.useCallback(function(n){var t,i,r,o=pn[n],l=hn[n],s=(null==o?void 0:o.relation)&&"not_defined"!==o.relation,c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation;a.safeStringify(null==o?void 0:o.id)||a.safeStringify(null==l?void 0:l.id);var u=!(!(null==o?void 0:o.cognitiveData)&&!(null==l?void 0:l.cognitiveData));if(!s&&!c&&!u)return e.__assign(e.__assign({},Ge.relationStyles.noContent),{label:"Not Defined"});var d=null!==(i=null!==(t=null==o?void 0:o.evaluationResult)&&void 0!==t?t:null==l?void 0:l.evaluationResult)&&void 0!==i?i:null,f=(null===(r=null==d?void 0:d.evaluation_outputs)||void 0===r?void 0:r.output_value)+"%";return null!=d?e.__assign(e.__assign({},Ge.relationStyles.low),{label:f}):e.__assign(e.__assign({},Ge.relationStyles.low),{label:"N/A"})},[pn,hn,ye,Ge,$n]),nt=t.useCallback(function(n){for(var t,i,r,o,l,s,c=n.split("-").map(Number),u=pn[c[0]],d=hn[c[0]],f=1;f<c.length;f++)(null==u?void 0:u.subsections)&&(u=u.subsections[c[f]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[f]]);if(!u&&!d)return null;var v=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,p=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,h=a.safeStringify(null==u?void 0:u.id)||a.safeStringify(null==d?void 0:d.id)||"",g=!(!(null==u?void 0:u.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!v&&!p&&!g)return e.__assign(e.__assign({},Ge.relationStyles.noContent),{label:"Not Defined"});null!==(i=null!==(t=null==u?void 0:u.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||h&&(null===(r=ye[h])||void 0===r||r.relevance_score);var x=null!==(l=null!==(o=null==u?void 0:u.evaluationResult)&&void 0!==o?o:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,m=(null===(s=null==x?void 0:x.evaluation_outputs)||void 0===s?void 0:s.output_value)+"%";return null!=x?e.__assign(e.__assign({},Ge.relationStyles.low),{label:m}):e.__assign(e.__assign({},Ge.relationStyles.low),{label:"N/A"})},[pn,hn,ye,Ge]),tt=t.useCallback(function(){var n,t,i,r,o,l,s,c,u,d,f,v,p,h,g,x,m,b,y,S,R,I;if(!Ve.current&&!pe.current){Ve.current=!0;try{if(!jn.current)return;var C=function(e){var n=e.split("-"),t=n[0];if(!rn[t]&&!1===W)return!1;if(W&&!rn["left-".concat(t)]&&!rn["right-".concat(t)]&&!rn[t])return!1;for(var i=t,r=1;r<n.length-1;r++)if(i+="-".concat(n[r]),!sn[i])return!1;return!0},w=jn.current.getBoundingClientRect();je({width:w.width,height:w.height});var F=[];if(Pn.forEach(function(e){var n,t,i=e.key,r=null===(n=qn.current[i])||void 0===n?void 0:n.current,o=null===(t=Vn.current[i])||void 0===t?void 0:t.current;r&&o&&(r.style.height="auto",o.style.height="auto",r.style.minHeight="0px",o.style.minHeight="0px")}),!pe.current){for(var j=0;j<Math.max(pn.length,hn.length);j++){var B=null===(n=Yn.current[j])||void 0===n?void 0:n.current,E=null===(t=Kn.current[j])||void 0===t?void 0:t.current;B&&(B.style.height="auto",B.style.minHeight="0px"),E&&(E.style.height="auto",E.style.minHeight="0px")}W||Object.keys(Jn.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=Jn.current[e])||void 0===n?void 0:n.current,r=null===(t=Qn.current[e])||void 0===t?void 0:t.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var T={};Pn.forEach(function(e){var n,t,i=e.key,r=null===(n=qn.current[i])||void 0===n?void 0:n.current,o=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=r.getBoundingClientRect(),s=o.getBoundingClientRect();T[i]=Math.max(l.height,s.height)}});var D={left:{},right:{}},A={};if(!pe.current)if(W){if(Z&&null!==Nn)if("number"==typeof Nn){var k=Nn,M=pn[k],O=null===(o=Yn.current[k])||void 0===o?void 0:o.current;O&&M&&(M.refIndexes||[]).forEach(function(e){var n,t=hn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Kn.current[t])||void 0===n?void 0:n.current;if(i&&(rn["left-".concat(k)]||rn["right-".concat(t)])){var r=Math.max(O.getBoundingClientRect().height,i.getBoundingClientRect().height);D.left[k]=Math.max(D.left[k]||0,r),D.right[t]=Math.max(D.right[t]||0,r)}})}else{var N=Nn;B=null===(l=Jn.current[N])||void 0===l?void 0:l.current,E=null===(s=Qn.current[N])||void 0===s?void 0:s.current;if(B&&E){L=Math.max(B.getBoundingClientRect().height,E.getBoundingClientRect().height);A[N]=Math.max(A[N]||0,L)}}}else{for(j=0;j<Math.min(pn.length,hn.length);j++){var B=null===(i=Yn.current[j])||void 0===i?void 0:i.current,E=null===(r=Kn.current[j])||void 0===r?void 0:r.current,H=!!rn[String(j)];if(B&&E&&H){var L=Math.max(B.getBoundingClientRect().height,E.getBoundingClientRect().height);D.left[j]=L,D.right[j]=L}}Object.keys(Jn.current).forEach(function(e){var n,t;if(C(e)){var i=null===(n=Jn.current[e])||void 0===n?void 0:n.current,r=null===(t=Qn.current[e])||void 0===t?void 0:t.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var o=i.getBoundingClientRect(),l=r.getBoundingClientRect();A[e]=Math.max(o.height,l.height)}}})}if(Pn.forEach(function(e){var n,t,i=e.key,r=null===(n=qn.current[i])||void 0===n?void 0:n.current,o=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(r&&o){var l=T[i];r.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}}),pe.current||(Object.entries(D.left).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=Yn.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(D.right).forEach(function(e){var n,t=e[0],i=e[1],r=null===(n=Kn.current[Number(t)])||void 0===n?void 0:n.current;r&&(r.style.minHeight="".concat(i,"px"))}),W||Object.keys(A).forEach(function(e){var n,t,i=null===(n=Jn.current[e])||void 0===n?void 0:n.current,r=null===(t=Qn.current[e])||void 0===t?void 0:t.current;if(i&&r&&A[e]){var o=A[e];i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}})),W){if(pn.forEach(function(e,n){var t;(null===(t=Yn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,r,o,l,s,a,c,u,d,f=hn.findIndex(function(n){return n.selfIndex===e});if(-1!==f){var v=null===(t=Un.current[n])||void 0===t?void 0:t.current,p=null===(i=Xn.current[f])||void 0===i?void 0:i.current;if(v&&p){var h=v.getBoundingClientRect(),g=p.getBoundingClientRect(),x=h.right-w.left,m=g.left-w.left,_=h.top+h.height/2-w.top,b=g.top+g.height/2-w.top;if(Z&&Nn===n){var y=null!==(o=null===(r=qe.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==o?o:0,S=null!==(s=null===(l=He.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==s?s:0,R=y+(null!==(c=null===(a=qe.current)||void 0===a?void 0:a.clientHeight)&&void 0!==c?c:1/0),I=S+(null!==(d=null===(u=He.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),C=h.top+h.height/2,j=function(e,n,t){return Math.max(n,Math.min(t,e))};_=j(C,y,R)-w.top,b=j(C,S,I)-w.top}var B=et(n);B&&F.push({id:"line-".concat(n,"-").concat(f),x1:x,y1:_,x2:m,y2:b,style:B,sectionIdx:n,targetRightIdx:f})}}})}),Z&&"string"==typeof Nn){N=Nn;var z=null===(p=Un.current[N])||void 0===p?void 0:p.current,P=null===(h=Xn.current[N])||void 0===h?void 0:h.current;if(z&&P){var q=z.getBoundingClientRect(),V=P.getBoundingClientRect(),Y=q.right-w.left,K=V.left-w.left,U=null!==(x=null===(g=qe.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==x?x:0,X=null!==(b=null===(m=He.current)||void 0===m?void 0:m.getBoundingClientRect().top)&&void 0!==b?b:0,G=U+(null!==(S=null===(y=qe.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),J=X+(null!==(I=null===(R=He.current)||void 0===R?void 0:R.clientHeight)&&void 0!==I?I:1/0),Q=q.top+q.height/2,$=V.top+V.height/2,ee=function(e,n,t){return Math.max(n,Math.min(t,e))},ne=ee(Q,U,G)-w.top,te=ee($,X,J)-w.top;(oe=nt(N))&&F.push({id:"line-subsec-".concat(N),x1:Y,y1:ne,x2:K,y2:te,style:oe,sectionIdx:Number(N.split("-")[0]),isSubSection:!0,subSectionKeyPath:N})}}}else{for(j=0;j<Math.min(pn.length,hn.length);j++){var ie=null===(c=Yn.current[j])||void 0===c?void 0:c.current,re=null===(u=Kn.current[j])||void 0===u?void 0:u.current;if(ie&&re){var oe,le=ie.getBoundingClientRect(),se=re.getBoundingClientRect(),ce=(le.top+18-w.top+se.top+18-w.top)/2,ue=(null===(d=hn[j])||void 0===d?void 0:d.id)||"sec-".concat(j);(oe=et(j))&&F.push({id:ue,x1:le.right-w.left,y1:ce,x2:se.left-w.left,y2:ce,style:oe,sectionIdx:j,hasCognitive:!!((null===(f=pn[j])||void 0===f?void 0:f.cognitiveData)||(null===(v=hn[j])||void 0===v?void 0:v.cognitiveData)||ue&&ye[ue])})}}Object.keys(Jn.current).forEach(function(n){var t,i,r,o,l,s;if(C(n)){for(var c=null===(t=Jn.current[n])||void 0===t?void 0:t.current,u=n.split("-").map(Number),d=pn[u[0]],f=1;f<u.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[u[f]]);if(d&&(null===(i=d.refIndexes)||void 0===i?void 0:i.length)){var v=null===(r=Qn.current[n])||void 0===r?void 0:r.current;if(c&&v&&null!==c.offsetParent&&null!==v.offsetParent){var p=c.getBoundingClientRect(),h=v.getBoundingClientRect(),g=(p.top+16-w.top+h.top+16-w.top)/2,x=n.split("-").map(Number),m=pn[x[0]],_=hn[x[0]];for(f=1;f<x.length;f++)(null==m?void 0:m.subsections)&&(m=m.subsections[x[f]]),(null==_?void 0:_.subsections)&&(_=_.subsections[x[f]]);if(!m&&!_)return;var b=(null==m?void 0:m.relation)&&"not_defined"!==m.relation,y=(null==_?void 0:_.relation)&&"not_defined"!==_.relation,S=a.safeStringify(null==m?void 0:m.id)||a.safeStringify(null==_?void 0:_.id)||"",R=!(!(null==m?void 0:m.cognitiveData)&&!(null==_?void 0:_.cognitiveData)),I=null;if(b||y||R){var j=null!==(l=null!==(o=null==m?void 0:m.evaluationResult)&&void 0!==o?o:null==_?void 0:_.evaluationResult)&&void 0!==l?l:null,B=(null===(s=null==j?void 0:j.evaluation_outputs)||void 0===s?void 0:s.output_value)+"%";return null!=j?e.__assign(e.__assign({},Ge.relationStyles.low),{label:B}):e.__assign(e.__assign({},Ge.relationStyles.low),{label:"N/A"})}(I={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE"})&&F.push({id:"subsec-".concat(n),x1:p.right-w.left,y1:g,x2:h.left-w.left,y2:g,style:I,sectionIdx:x[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:R||S&&ye[S]})}}}})}if(Mn(F),Tn.current&&Dn.current){var de=Tn.current.getBoundingClientRect(),ve=Dn.current.getBoundingClientRect(),he=(de.top+de.height/2-w.top+ve.top+ve.height/2-w.top)/2;zn({x1:de.right-w.left,x2:ve.left-w.left,y:he})}else zn(null);if(W&&ae.size>0){var ge=[],me=qe.current,_e=He.current;if(me&&_e){var be=[],Se=me.getBoundingClientRect().top,Re=_e.getBoundingClientRect().top,Ie=Se+me.clientHeight,Ce=Re+_e.clientHeight,we=me.scrollTop,Fe=_e.scrollTop,Be=w.top,Ee=function(e,n,t){return Math.max(n,Math.min(t,e))};ae.forEach(function(e){var n,t,i;if("string"==typeof e){var r=e,o=null===(n=Un.current[r])||void 0===n?void 0:n.current,l=null===(t=Xn.current[r])||void 0===t?void 0:t.current;if(!o||!l)return;var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=nt(r),u=s.right-w.left,d=a.left-w.left-0,f=u+.75*(d-u),v=s.top+s.height/2,p=a.top+a.height/2,h=v-Se+we,g=p-Re+Fe,x="conn-subsec-".concat(r);be.push({lhsScrollY:h,rhsScrollY:g,x1:u,x2:d,containerTop:Be,leftIdx:r,rhsArrayIdx:r,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:x});var m=Ee(v,Se,Ie),b=Ee(p,Re,Ce),y=m-Be,S=b-Be,R=v>=Se-4&&v<=Ie+4,I=p>=Re-4&&p<=Ce+4,C="";C=R&&I?_(u,y,d,S):R&&!I?"M ".concat(u,",").concat(y," L ").concat(f,",").concat(y," L ").concat(f,",").concat(S):!R&&I?"M ".concat(f,",").concat(y," L ").concat(f,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(f,",").concat(y," L ").concat(f,",").concat(S),ge.push({id:x,pathD:C,style:c,leftIdx:r,rhsArrayIdx:r})}else{var F=pn[e];if(!(null===(i=null==F?void 0:F.refIndexes)||void 0===i?void 0:i.length))return;F.refIndexes.forEach(function(n){var t,i,r=hn.findIndex(function(e){return e.selfIndex===n});if(-1!==r){var o=null===(t=Un.current[e])||void 0===t?void 0:t.current,l=null===(i=Xn.current[r])||void 0===i?void 0:i.current;if(o&&l){var s=o.getBoundingClientRect(),a=l.getBoundingClientRect(),c=et(e),u=s.right-w.left,d=a.left-w.left-0,f=u+.75*(d-u),v=s.top+s.height/2,p=a.top+a.height/2,h=v-Se+we,g=p-Re+Fe,x="conn-".concat(e,"-").concat(r);be.push({lhsScrollY:h,rhsScrollY:g,x1:u,x2:d,containerTop:Be,leftIdx:e,rhsArrayIdx:r,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:x});var m=Ee(v,Se,Ie),b=Ee(p,Re,Ce),y=m-Be,S=b-Be,R=v>=Se-4&&v<=Ie+4,I=p>=Re-4&&p<=Ce+4,C="";C=R&&I?_(u,y,d,S):R&&!I?"M ".concat(u,",").concat(y," L ").concat(f,",").concat(y," L ").concat(f,",").concat(S):!R&&I?"M ".concat(f,",").concat(y," L ").concat(f,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(f,",").concat(y," L ").concat(f,",").concat(S),ge.push({id:x,pathD:C,style:c,leftIdx:e,rhsArrayIdx:r})}}})}}),xe.current=be}fe(ge)}else fe([]),xe.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Ve.current=!1}}},[Pn,pn,hn,ye,Ge,$n,et,W,Z,Nn,ae,rn,sn]),it=t.useCallback(function(){var e,n,t,i,r,o,l,s,a,c,u,d,f,v,p=xe.current;if(p.length&&!pe.current){var h=null!==(n=null===(e=qe.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=He.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(o=null===(r=qe.current)||void 0===r?void 0:r.clientHeight)&&void 0!==o?o:1/0,m=null!==(s=null===(l=He.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,b=null!==(c=null===(a=qe.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==c?c:0,y=null!==(d=null===(u=He.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,S=b+x,R=y+m,I=null!==(v=null===(f=jn.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==v?v:0,C=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=ge.current[e.styleId+"-stroke"],r=ge.current[e.styleId+"-bg"];if(i||r){var o,l=C(n,b,S),s=C(t,y,R),a=l-I,c=s-I,u=n>=b-4&&n<=S+4,d=t>=y-4&&t<=R+4,f=e.x1+.65*(e.x2-e.x1);o=u&&d?_(e.x1,a,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(c):!u&&d?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",o)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",o))}})}},[]),rt=t.useRef(tt);t.useEffect(function(){rt.current=tt},[tt]);var ot=t.useRef(null),lt=t.useCallback(function(){null!==ot.current&&clearTimeout(ot.current),ot.current=setTimeout(function(){rt.current(),ot.current=null},50)},[]),st=t.useCallback(function(e){var n,t,i,r,o,l,s,a;if(!ie.current){if(_e.current){var c=be.current,u=Bn.current,d=qe.current,f=He.current;if(null!==c&&null!==u&&d&&f){var v="string"==typeof c?null===(n=Jn.current[c])||void 0===n?void 0:n.current:null===(t=bn.current[c])||void 0===t?void 0:t.current,p="string"==typeof u?null===(i=Qn.current[u])||void 0===i?void 0:i.current:null===(r=Gn.current[u])||void 0===r?void 0:r.current;if(v&&p){var h=v.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop,g=p.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop;if(e.currentTarget===d){var x=g-(h-d.scrollTop),m=f.scrollHeight-f.clientHeight,_=Math.max(0,Math.min(x,m));Math.abs(f.scrollTop-_)>1&&(f.scrollTop=_)}else if(e.currentTarget===f){var b=h-(g-f.scrollTop),y=d.scrollHeight-d.clientHeight,S=Math.max(0,Math.min(b,y));Math.abs(d.scrollTop-S)>1&&(d.scrollTop=S)}if(En.current){var R=null===(o=Un.current[c])||void 0===o?void 0:o.current,I=null===(l=Xn.current[u])||void 0===l?void 0:l.current,C=null!==(a=null===(s=jn.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==a?a:0,w=d.getBoundingClientRect().top,F=w+d.clientHeight,j=f.getBoundingClientRect().top,B=j+f.clientHeight,E=function(e,n,t){return Math.max(n,Math.min(t,e))};if(R&&I){var T=R.getBoundingClientRect(),D=I.getBoundingClientRect(),A=T.top+T.height/2,k=D.top+D.height/2,M=E(A,w,F),O=E(k,j,B);En.current.setAttribute("y1",(M-C).toString()),En.current.setAttribute("y2",(O-C).toString());var N=A>=w-4&&A<=F+4;En.current.setAttribute("visibility",N?"visible":"hidden")}}}}}xe.current.length>0&&!me.current&&(me.current=!0,requestAnimationFrame(function(){it(),me.current=!1}))}},[it]);t.useEffect(function(){var e=setTimeout(lt,250);window.addEventListener("resize",lt);var n=null,t=null;return Oe.current&&(n=new ResizeObserver(lt)).observe(Oe.current),jn.current&&(t=new ResizeObserver(lt)).observe(jn.current),function(){clearTimeout(e),window.removeEventListener("resize",lt),null==n||n.disconnect(),null==t||t.disconnect()}},[Qe,cn,xn,Pn,rn,sn,pn,hn,Ge,lt,Z,Nn,ne,ae]),t.useEffect(function(){_e.current=Z},[Z]),t.useEffect(function(){be.current=Nn},[Nn]);var at=t.useCallback(function(){var e=ke.sectionIdx,n=ke.isOrphan;if(null!=e)return n?(J("No counterpart exists for this section."),void Ue()):void(Z&&Nn===e?Sn():(ce(new Set),fe([]),xe.current=[],U(!0),ie.current=!0,Hn(e),be.current=e,$(!0),_e.current=!0,te(!1),Le.current&&(Le.current.style.height="0px"),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,r,o=null,l=null,s=null;if("string"==typeof e)o=(null===(n=Jn.current[e])||void 0===n?void 0:n.current)||null,s=(l=(null===(t=Qn.current[e])||void 0===t?void 0:t.current)||null)?e:null;else{o=(null===(i=bn.current[e])||void 0===i?void 0:i.current)||null;var a=pn[e],c=(null==a?void 0:a.refIndexes)||[];if(c.length>0){var u=c[0],d=hn.findIndex(function(e){return e.selfIndex===u});-1!==d&&(l=(null===(r=Gn.current[d])||void 0===r?void 0:r.current)||null,s=d)}}Bn.current=s;var f=qe.current,v=He.current;if(!o||!f)return ie.current=!1,void U(!1);if(!l||!v)return te(!0),rt.current(),ie.current=!1,void U(!1);var p=o.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop,h=l.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop-(p-f.scrollTop);h<0&&Le.current&&(Le.current.style.height="".concat(Math.abs(h),"px"));requestAnimationFrame(function(){var e,n=v.scrollHeight-v.clientHeight;if(h<0)e=0;else{if(h>n){var t=h-n;return We.current&&(We.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){S(v,h,200,function(){te(!0),rt.current(),ie.current=!1,U(!1)})})}e=h}S(v,e,200,function(){te(!0),rt.current(),ie.current=!1,U(!1)})})})));Ue()},[Ue,ke.sectionIdx,Z,Nn,pn,hn,lt,Sn]),ct=null!==ke.sectionIdx&&ae.has(ke.sectionIdx),ut=function(t){var o,l,s,c=t.section,u=t.idx,d=t.columnKey,f=t.colRef,v=t.mb,p=void 0===v?1:v,g=t.parentNodeId,x=void 0===g?"":g,_=W?!!rn["".concat(d,"-").concat(u)]:!!rn[String(u)],b=(null===(o=c.displayTitle)||void 0===o||o)&&a.hasValue(c.title),y=(null===(l=c.displayContent)||void 0===l||l)&&a.hasValue(c.content),S=!b&&!y,R=c.title;b||(R=y?"No Title Found":"No Matching Section Found");var I,C=[];if(null===(s=c.evaluationResult)||void 0===s?void 0:s.deviations){var w=c.evaluationResult.deviations;for(var F in w){var j=w[F][x];j&&C.push(j)}}return n.jsx(i.Box,e.__assign({ref:f,sx:{mb:p,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!S&&_,onChange:function(){return!S&&function(n,t){var i,r;pe.current=!0,he.current&&clearTimeout(he.current),ve.current&&(ve.current.style.opacity="0");var o=null===(i=Yn.current[n])||void 0===i?void 0:i.current,l=null===(r=Kn.current[n])||void 0===r?void 0:r.current;if(o&&(o.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(Jn.current).forEach(function(e){var t,i;if(e.startsWith("".concat(n,"-"))){var r=null===(t=Jn.current[e])||void 0===t?void 0:t.current,o=null===(i=Qn.current[e])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px"),o&&(o.style.minHeight="0px")}}),W){var s=pn[n];((null==s?void 0:s.refIndexes)||[]).forEach(function(e){var n,t=hn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Kn.current[t])||void 0===n?void 0:n.current;i&&(i.style.minHeight="0px")});var a=hn[n],c=null==a?void 0:a.selfIndex;pn.forEach(function(e,n){var t,i;if(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c)){var r=null===(i=Yn.current[n])||void 0===i?void 0:i.current;r&&(r.style.minHeight="0px")}})}he.current=setTimeout(function(){pe.current=!1,rt.current(),ve.current&&(ve.current.style.opacity="1")},650),on(function(i){var r=e.__assign({},i);if(!W){var o=!!i[String(n)];return r[String(n)]=!o,r}var l="".concat(t,"-").concat(n),s=!i[l];if(r[l]=s,"left"===t)((null==(a=pn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=hn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(r["right-".concat(n)]=s)});else{var a,c=null==(a=hn[n])?void 0:a.selfIndex;pn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c))&&(r["left-".concat(n)]=s)})}return r})}(u,d)},sx:{boxShadow:"none",border:S?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:S?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:S?null:n.jsx(r.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:S?"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:b&&n.jsx(i.Tooltip,e.__assign({title:R,placement:"top"},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:S?"#94A3B8":"#19213D",fontWeight:S?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(I=R,I?a.safeStringify(I).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},t):n.jsx(h.default.Fragment,{children:e},t)}):null)}))}))})),!S&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[y&&n.jsx(m,{content:c.content,sxStyles:Be,highlights:C}),(c.subsections||[]).map(function(e,n){return dt({section:e,keyPath:"".concat(u,"-").concat(n),depth:0,columnKey:d,parentNodeId:x})})]}))]}))}),"".concat(d,"-sec-").concat(u))},dt=function(t){var o,l,s,c=t.section,u=t.keyPath,d=t.depth,f=void 0===d?0:d,v=t.columnKey,p=void 0===v?"left":v,g=t.parentNodeId,x=void 0===g?"":g,_=(null===(o=c.displayTitle)||void 0===o||o)&&a.hasValue(c.title),b=(null===(l=c.displayContent)||void 0===l||l)&&a.hasValue(c.content),y=!_&&!b,S=_?c.title:b?"No Title Found":"No Matching Section Found",R=!!sn[u];"left"!==p||Jn.current[u]||(Jn.current[u]=h.default.createRef()),"right"!==p||Qn.current[u]||(Qn.current[u]=h.default.createRef());var I="left"===p?Jn.current[u]:Qn.current[u];Un.current[u]||(Un.current[u]=h.default.createRef()),Xn.current[u]||(Xn.current[u]=h.default.createRef());for(var C=u.split("-").map(function(e){return Number(e)+1}).join("."),w=nt(u),F=W&&ae.has(u),j=u.split("-").map(Number),B=pn[j[0]],E=hn[j[0]],T=1;T<j.length;T++)(null==B?void 0:B.subsections)&&(B=B.subsections[j[T]]),(null==E?void 0:E.subsections)&&(E=E.subsections[j[T]]);var D=!(null===(s=c.refIndexes)||void 0===s?void 0:s.length)||void 0!==c.selfIndex&&c.selfIndex<0,A="left"===p&&D,k="right"===p&&D;return _?n.jsxs(i.Box,e.__assign({ref:I,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:[n.jsx(i.Box,e.__assign({sx:e.__assign({width:"100%"},F&&w&&{borderRadius:"4px",outline:"2px solid ".concat(w.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!y&&R,onChange:function(){return!y&&an(function(n){var t;return e.__assign(e.__assign({},n),((t={})[u]=!n[u],t))})},sx:{mt:0,boxShadow:"none",border:y?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:y?null:n.jsx(r.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:y?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:S||"Untitled Subsection"}))})),!y&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[b&&n.jsx(m,{content:c.content,sxStyles:Be,highlights:function(){var e,n;if(!(null===(e=c.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=c.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][x];o&&i.push(o)}return i}()}),(c.subsections||[]).map(function(e,n){return dt({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:p,parentNodeId:x})})]}))]}))})),W&&"left"===p&&w&&!y&&n.jsxs(i.Box,e.__assign({ref:Un.current[u],onClick:function(e){e.stopPropagation();for(var n=u.split("-").map(Number),t=pn[n[0]],i=hn[n[0]],r=1;r<n.length;r++)(null==t?void 0:t.subsections)&&(t=t.subsections[n[r]]),(null==i?void 0:i.subsections)&&(i=i.subsections[n[r]]);Cn(e,t||{title:"",content:""},A||k,i||{title:"",content:""},u,w)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:w.badgeBg,color:w.badgeText,border:"1px solid ".concat(w.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(w.badgeBorder)}},{children:C})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:A?"No Deviation Found":0==w.deviationLabel||void 0===w.deviationLabel?w.label:"".concat(w.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:10,color:w.badgeText})]})),W&&"right"===p&&w&&!y&&!K&&n.jsx(i.Box,e.__assign({ref:Xn.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:k?"-":C}))]}),u):n.jsxs(i.Box,e.__assign({ref:I,sx:{mt:0===f?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:[!y&&n.jsxs(i.Box,e.__assign({sx:e.__assign({width:"100%"},F&&w&&{borderRadius:"4px",outline:"2px solid ".concat(w.badgeBorder),outlineOffset:"1px"})},{children:[b&&n.jsx(m,{content:c.content,sxStyles:Be,highlights:function(){var e,n;if(!(null===(e=c.evaluationResult)||void 0===e?void 0:e.deviations))return[];var t=(null===(n=c.evaluationResult)||void 0===n?void 0:n.deviations)||{},i=[];for(var r in t){var o=t[r][x];o&&i.push(o)}return i}()}),(c.subsections||[]).map(function(e,n){return dt({section:e,keyPath:"".concat(u,"-").concat(n),depth:f+1,columnKey:p,parentNodeId:x})})]})),W&&"left"===p&&w&&!y&&n.jsxs(i.Box,e.__assign({ref:Un.current[u],onClick:function(e){var n;e.stopPropagation();var t=function(e,n){for(var i=0,r=e;i<r.length;i++){var o=r[i];if(o.selfIndex===n)return o;if(o.subsections){var l=t(o.subsections,n);if(l)return l}}return null},i=null===(n=c.refIndexes)||void 0===n?void 0:n[0],r="number"==typeof i?t(hn,i):null;Cn(e,c,D,r||{title:"",content:""},u,w)},sx:{position:"absolute",top:"16px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:w.badgeBg,color:w.badgeText,border:"1px solid ".concat(w.badgeBorder),borderRadius:"12px",px:1,py:.3,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(w.badgeBorder)}},{children:C})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:A?"No Deviation Found":0==w.deviationLabel||void 0===w.deviationLabel?w.label:"".concat(w.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:10,color:w.badgeText})]})),W&&"right"===p&&w&&!y&&!K&&n.jsx(i.Box,e.__assign({ref:Xn.current[u],sx:{position:"absolute",top:"16px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:k?"-":C}))]}),u)};return n.jsxs(i.Box,e.__assign({ref:Ne,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},W?{}:{overflow:"visible"}),{position:"relative"})},{children:[q&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(f.default,{})})),W&&n.jsx(d.default,{open:ke.open,anchorEl:ke.anchorEl,sectionTitle:ke.sectionTitle,referenceSectionTitle:ke.refSectionTitle,onClose:Ue,onOpenCognitiveCompare:wn,onOpenSideBySide:at,onConnect:Fn,isConnected:ct}),Te.open&&n.jsx(u.default,{open:Te.open,popupRef:Ce,position:Re,popupConfig:O,onClose:function(){Ie(null),De(function(n){return e.__assign(e.__assign({},n),{open:!1})}),le(null)},markdownStyles:A,sectionTitle:Te.sectionTitle,referenceSectionTitle:Te.refSectionTitle,cognitiveData:Te.cognitiveData,anchorEl:Te.anchorEl,sectionAnchorEl:Te.sectionAnchorEl,scrollContainerEl:Oe.current,badgeStyle:Te.badgeStyle,docData:Te.docData,deviationData:Te.deviationData}),n.jsx(i.Snackbar,e.__assign({open:!!G,autoHideDuration:8e3,onClose:function(){return J(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return J(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:G}))})),(M.isHeaderVisible||M.isToggleVisible)&&n.jsxs(i.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:M.isHeaderVisible&&n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:j}))})),M.isToggleVisible&&n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:W,onChange:function(e){var n=e.target.checked;V(!0),setTimeout(function(){z(n),Sn(),ce(new Set),fe([]),xe.current=[],setTimeout(function(){V(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#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}})}))]})),n.jsx(i.Box,e.__assign({ref:Oe,onScroll:st,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:W?"hidden":"auto",borderTop:mn&&_n?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},W?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:jn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:ve,style:{position:"absolute",top:0,left:0,width:Fe.width||"100%",height:Fe.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[Wn&&n.jsxs("g",{children:[n.jsx("line",{x1:Wn.x1,y1:Wn.y,x2:Math.max(Wn.x1,(Wn.x1+Wn.x2)/2-70),y2:Wn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(Wn.x2,(Wn.x1+Wn.x2)/2+70),y1:Wn.y,x2:Wn.x2,y2:Wn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),kn.map(function(t){var l,s=(t.x1+t.x2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!W)return n.jsxs("g",{children:[n.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:s-100,y:t.y1-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){if(e.stopPropagation(),Te.open&&oe===t.id)Ke();else{var n=pn[t.sectionIdx]||{title:"",content:""},i=hn[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var r=t.subSectionKeyPath.split("-").map(Number),o=pn[r[0]],l=hn[r[0]],s=1;s<r.length;s++)(null==o?void 0:o.subsections)&&(o=o.subsections[r[s]]),(null==l?void 0:l.subsections)&&(l=l.subsections[r[s]]);o&&(n=o),l&&(i=l)}le(t.id),In(Rn(e.currentTarget,n,i,t.sectionIdx,t.style))}},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(o.ButtonCognitiveIcon,{})})),n.jsx(r.ChevronDown,{size:11,style:{transform:Te.open&&oe===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id);var a=!1;if(t.isSubSection)a=Z&&Nn===t.subSectionKeyPath&&ne;else{var c=pn[t.sectionIdx];if(!(null===(l=null==c?void 0:c.refIndexes)||void 0===l?void 0:l.length)||(null==c?void 0:c.selfIndex)<0)return null;a=Z&&Nn===t.sectionIdx&&ne}return a?n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{ref:En,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id):null}),de.map(function(t){var i,r=t.pathD,o=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),s="".concat(t.id,"-bg"),a="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:l,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:o})}))}))}),n.jsx("path",{ref:function(e){ge.current[s]=e},d:r,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){ge.current[a]=e},d:r,fill:"none",stroke:o,strokeWidth:"1.75",markerEnd:"url(#".concat(l,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},W?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Tn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:fn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:fn}))}))})),n.jsxs(i.Box,e.__assign({ref:qe,onScroll:st,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:ze,style:{width:"100%",height:"0px",flexShrink:0}}),gn&&pn.map(function(t,o){var l,s,a,c=!t.title&&!t.content;if(W&&c)return null;if(!W)return n.jsx(i.Box,e.__assign({ref:yn(o)},{children:ut({section:t,idx:o,columnKey:"left",colRef:Yn.current[o],parentNodeId:(null===(l=null==B?void 0:B.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(o));var u=t,d=et(o),f=!(null===(s=u.refIndexes)||void 0===s?void 0:s.length)||u.selfIndex<0,v="number"==typeof u.selfIndex&&u.selfIndex>=0?u.selfIndex+1:null,p=ae.has(o);return n.jsx(i.Box,e.__assign({ref:yn(o),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Yn.current[o],sx:e.__assign({width:"100%",display:"flex"},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:ut({section:t,idx:o,columnKey:"left",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(a=null==B?void 0:B.input_index_map)||void 0===a?void 0:a[0])||""})})),d&&n.jsxs(i.Box,e.__assign({ref:Un.current[o],onClick:function(e){var n=hn.find(function(e){var n;return null===(n=u.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};Cn(e,t,f,n,o,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==v&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:v})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:f?"No Deviation Found":0==d.deviationLabel||void 0===d.deviationLabel?d.label:"".concat(d.deviationLabel,"% Deviation")})),n.jsx(r.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(o))}),n.jsx("div",{ref:Pe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(o.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(r.ChevronDown,{size:11})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},W?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[K&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Dn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:vn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",height:"40px"}},{children:vn}))}))})),n.jsxs(i.Box,e.__assign({ref:He,onScroll:st,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},W?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-20px",pl:"40px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Le,style:{width:"100%",height:"0px",flexShrink:0}}),gn&&hn.map(function(t,r){var o,l;if(!W)return ut({section:t,idx:r,columnKey:"right",colRef:Kn.current[r],parentNodeId:(null===(o=null==B?void 0:B.input_index_map)||void 0===o?void 0:o[1])||""});var s=t,a=pn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),c=pn.some(function(e,n){var t;return ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),u=pn.findIndex(function(e,n){var t;return ae.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),d=-1!==u?et(u):null;return n.jsx(i.Box,e.__assign({ref:Gn.current[r],sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Kn.current[r],sx:e.__assign({width:"100%",display:"flex"},c&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:ut({section:t,idx:r,columnKey:"right",colRef:h.default.createRef(),mb:0,parentNodeId:(null===(l=null==B?void 0:B.input_index_map)||void 0===l?void 0:l[1])||""})})),!K&&n.jsx(i.Box,e.__assign({ref:Xn.current[r],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:We,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),s=require("react-markdown"),a=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),u=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("rehype-raw");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=h(t),g=h(s),x=h(f),_="::",m=p.default.memo(function(r){var l=r.content,s=r.sxStyles,c=r.deviationBadges,u=void 0===c?[]:c,d=r.highlights,v=void 0===d?[]:d,f=r.maintainRelativeOrder,h=void 0===f||f,p=t.useMemo(function(){return u.reduce(function(n,t){var i;return e.__assign(e.__assign({},n),((i={})[t.id]=t,i))},{})},[u]),_=t.useMemo(function(){return{mark:function(t){var i=t.children;return n.jsx("span",e.__assign({style:{backgroundColor:"#fccccc",borderRadius:"2px"}},{children:i}))},span:function(t){var r,l,s,a,c,u=t.children,d=e.__rest(t,["children"]),v=d["data-badge-id"];if(!v)return n.jsx("span",e.__assign({},d,{children:u}));var f=p[v];return f?n.jsxs(i.Box,e.__assign({component:"span",sx:{position:"static",display:"inline"}},{children:[u,n.jsx(i.Box,e.__assign({ref:f.badgeRef,onClick:h?f.onClick:void 0,sx:h?e.__assign(e.__assign({position:"absolute",zIndex:30,display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",bgcolor:(null===(r=f.style)||void 0===r?void 0:r.badgeBg)||"#EEF2FF",color:(null===(l=f.style)||void 0===l?void 0:l.badgeText)||"#3730A3",border:"1px solid ".concat((null===(s=f.style)||void 0===s?void 0:s.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"===f.side?{right:"-16px",transform:"translateY(-20%) translateX(calc(100% + 8px))"}:{left:"-16px",transform:"translateY(-20%) translateX(calc(-100% - 8px))"}),f.isConnected&&f.style&&{outline:"2px solid ".concat(f.style.badgeBorder),outlineOffset:"1px"}):e.__assign({position:"absolute",width:0,height:0,visibility:"hidden"},"left"===f.side?{right:"-16px",transform:"translateY(-50%)"}:{left:"-16px",transform:"translateY(-50%)"})},{children:h&&n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:e.__assign({fontSize:"10px",fontWeight:700},"left"===f.side?{pr:.5,borderRight:"1px solid ".concat((null===(a=f.style)||void 0===a?void 0:a.badgeBorder)||"#C7D2FE")}:{})},{children:f.label})),"left"===f.side&&n.jsxs(n.Fragment,{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"10px",px:.25}},{children:f.isOrphan?"No Deviation Found":0===f.score||null==f.score?"Same":"".concat(f.score,"% Deviation")})),n.jsx(o.EllipsisVertical,{size:10,color:(null===(c=f.style)||void 0===c?void 0:c.badgeText)||"#3730A3"})]})]})}))]})):n.jsx("span",e.__assign({},d,{children:u}))}}},[p,h]),m=t.useMemo(function(){var e=l||"",n=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")};return u.forEach(function(t){t.highlight&&(e=e.replace(new RegExp(n(t.highlight),"g"),'<span data-badge-id="'.concat(t.id,'"><mark>').concat(t.highlight,"</mark></span>")))}),v.forEach(function(t){t&&(e=e.replace(new RegExp(n(t),"g"),"<mark>".concat(t,"</mark>")))}),e},[l,u,v]);return n.jsx(i.Typography,e.__assign({component:"div",sx:e.__assign(e.__assign({},s),{position:"relative",overflow:"visible","& p, & li, & ul, & ol":{position:"static",overflow:"visible"}})},{children:n.jsx(g.default,e.__assign({components:_,rehypePlugins:[x.default]},{children:a.safeStringify(m).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;return!0}),y=function(e,n,t,i,o){void 0===o&&(o=14);var r=e+.5*(t-e),l=i-n;if(Math.abs(l)<3)return"M ".concat(e," ").concat(n," H ").concat(t);var s=l>0?1:-1,a=Math.min(o,Math.abs(l)/2,Math.abs(r-e)/2,Math.abs(t-r)/2);return["M ".concat(e," ").concat(n),"H ".concat(r-a),"Q ".concat(r," ").concat(n," ").concat(r," ").concat(n+s*a),"V ".concat(i-s*a),"Q ".concat(r," ").concat(i," ").concat(r+a," ").concat(i),"H ".concat(t)].join(" ")},b={id:"",title:""},S={open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},R=function(e,n,t,i,o){void 0===t&&(t=300);var r=e.style.scrollBehavior;e.style.scrollBehavior="auto";var l=e.scrollTop,s=n-l,a=null,c=function(u){null===a&&(a=u);var d,v=u-a;v<t?(e.scrollTop=(d=v,d/=t,s*(--d*d*d+1)+l),o&&o(),requestAnimationFrame(c)):(e.scrollTop=n,e.style.scrollBehavior=r,o&&o(),i&&i())};requestAnimationFrame(c)};exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(s){var f,h,g,x,I,C,w,F,j=s.componentHeaderText,B=void 0===j?"Contract Comparison":j,E=s.treeData,T=s.comparisonConfig,k=s.leftColumnTitleText,A=s.rightColumnTitleText,M=s.markdownStyles,D=s.displayConfig,O=void 0===D?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1}:D,N=s.popupConfig,H=s.deviationData,L=void 0===H?{}:H,W=t.useState(O.maintainRelativeOrder),z=W[0],P=W[1],q=t.useState(!1),Y=q[0],V=q[1],K=t.useState(!1),U=K[0],G=K[1],X=t.useState(null),J=X[0],Q=X[1],$=t.useState(!1),Z=$[0],ee=$[1],ne=t.useState(!1),te=ne[0],ie=ne[1],oe=t.useRef(!1),re=t.useState(null),le=re[0],se=re[1],ae=t.useState(new Set),ce=ae[0],ue=ae[1],de=t.useState([]),ve=de[0],fe=de[1],he=t.useRef(null),pe=t.useRef(!1),ge=t.useRef(null),xe=t.useRef({}),_e=t.useRef([]),me=t.useRef(!1),ye=t.useRef(!1),be=t.useRef(null),Se=t.useMemo(function(){return(null==E?void 0:E.cognitive_decisioning)||{}},[E]),Re=t.useState(null),Ie=Re[0],Ce=Re[1],we=t.useRef(null),Fe=t.useState({width:0,height:0}),je=Fe[0],Be=Fe[1],Ee=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),M)},[M]),Te=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),ke=Te[0],Ae=Te[1],Me=t.useState({open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,isOrphan:!1,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,docData:null,deviationData:null}),De=Me[0],Oe=Me[1],Ne=t.useRef(null),He=t.useRef(null),Le=t.useRef(null),We=t.useRef(null),ze=t.useRef(null),Pe=t.useRef(null),qe=t.useRef(null),Ye=t.useRef(null),Ve=t.useRef(!1),Ke=t.useRef(null);t.useEffect(function(){Ke.current=null},[ke.sectionIdx,ke.open]);var Ue=t.useCallback(function(){Ce(null),Ae(S),se(null)},[]),Ge=t.useCallback(function(){Oe(S)},[]),Xe=t.useCallback(function(){var e;if(ke.anchorEl&&ke.refSectionTitle){var n=ke.anchorEl.getBoundingClientRect(),t=(null===(e=null==we?void 0:we.current)||void 0===e?void 0:e.offsetHeight)||0,i=Math.min(680,window.innerWidth-24),o=window.innerHeight-n.bottom-12-12,r=n.top-12-12,l=o<t&&r>o;null!==Ke.current?!0===Ke.current&&(l=r>=t||r>=o):l=!(o>=t||o>=r),Ke.current=l;var s=l?r:o,a=Math.min(t||9999,s),c=l?n.top-12-a:n.bottom+12,u=n.left+n.width/2,d=u-i/2,v=Math.max(12,Math.min(d,window.innerWidth-i-12)),f=Math.max(14,Math.min(u-v,i-10-4));Ce({top:c,left:v,arrowLeft:f,openAbove:l,maxHeight:s})}},[ke.anchorEl,ke.refSectionTitle]);t.useEffect(function(){if(ke.open){window.addEventListener("resize",Xe);var e=requestAnimationFrame(Xe),n=null;return we.current&&(n=new ResizeObserver(function(){cancelAnimationFrame(e),e=requestAnimationFrame(Xe)})).observe(we.current),function(){cancelAnimationFrame(e),window.removeEventListener("resize",Xe),n&&n.disconnect()}}},[ke.open,Xe]),t.useEffect(function(){var e=Ne.current;if(e&&ke.open){var n=function(e){we.current&&we.current.contains(e.target)||(Ce(null),Ue())};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})}}},[ke.open,Ue]),t.useEffect(function(){var e=Ne.current;if(e&&De.open){var n=function(){Ge()};return e.addEventListener("scroll",n,{capture:!0}),window.addEventListener("scroll",n,{capture:!0}),function(){e.removeEventListener("scroll",n,{capture:!0}),window.removeEventListener("scroll",n,{capture:!0})}}},[De.open,Ge]);var Je=t.useMemo(function(){var n,t,i,o,r,l,s,a,u,d,v,f;return{fields:null!==(n=null==T?void 0:T.fields)&&void 0!==n?n:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(i=null===(t=null==T?void 0:T.thresholds)||void 0===t?void 0:t.high)&&void 0!==i?i:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(r=null===(o=null==T?void 0:T.thresholds)||void 0===o?void 0:o.medium)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(s=null===(l=null==T?void 0:T.thresholds)||void 0===l?void 0:l.exact)&&void 0!==s?s:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact},relationStyles:{noContent:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.noContent),(null===(a=null==T?void 0:T.relationStyles)||void 0===a?void 0:a.noContent)||{}),high:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.high),(null===(u=null==T?void 0:T.relationStyles)||void 0===u?void 0:u.high)||{}),exact:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.exact),(null===(d=null==T?void 0:T.relationStyles)||void 0===d?void 0:d.exact)||{}),medium:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.medium),(null===(v=null==T?void 0:T.relationStyles)||void 0===v?void 0:v.medium)||{}),low:e.__assign(e.__assign({},c.DEFAULT_COMPARISON_CONFIG.relationStyles.low),(null===(f=null==T?void 0:T.relationStyles)||void 0===f?void 0:f.low)||{})}}},[T]),Qe=t.useMemo(function(){if(E&&Object.keys(E).length>0)try{var n=function(n,t,i){var o,r,l,s;void 0===t&&(t=!1),void 0===i&&(i=null);var c=n.nodes||n,u=[],d=[],v=n.base_root_id,f=n.input_index_map||{0:"left",1:"right"},h=n[v]||c[v];if(!h||!1===h.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[]};var p=function(t,o){var r,l,s,u=n[t]||c[t];if(!u||!1===u.display_node)return null;var d=a.getSideData(u,o,f),v=!1!==(null===(r=d.attributes)||void 0===r?void 0:r.display_title),h=!1!==(null===(l=d.attributes)||void 0===l?void 0:l.display_content),g=!!d.title.trim(),x=!!d.content.trim(),_=a.getRationale(u),m=(null===(s=null==i?void 0:i[t])||void 0===s?void 0:s.evaluation_result)||u.evaluation_result||null,y=[];u.next&&Object.values(u.next).forEach(function(e){var n=c[e];if(n&&!1!==n.display_node){var t=p(e,o);t&&y.push(t)}});var b=!(!g&&!x);return e.__assign(e.__assign({id:t,title:g?d.title:"",content:x?d.content:"",displayTitle:v,displayContent:h,subsections:y},b?_:{score:void 0,relation:"not_defined"}),{evaluationResult:m})};if(t){var g=function(t,o){var r,l,s,u,d,v,h,p,x,_,m,y,b,S,R,I,C,w,F,j,B;void 0===o&&(o=0);var E=[],T=[];if(!t)return{refSections:E,baseSections:T};var k={},A={},M=-1,D=-1;for(var O in t){var N=t[O],H=n[N]||c[N];if(H&&!1!==H.display_node){var L=a.getRationale(H),W=(null===(r=null==i?void 0:i[N])||void 0===r?void 0:r.evaluation_result)||H.evaluation_result||null,z=a.getSideData(H,"1",f),P=a.getSideData(H,"0",f),q=!1!==(null===(l=z.attributes)||void 0===l?void 0:l.display_title)&&z.title.trim()||!1!==(null===(s=z.attributes)||void 0===s?void 0:s.display_content)&&z.content.trim(),Y=!1!==(null===(u=P.attributes)||void 0===u?void 0:u.display_title)&&P.title.trim()||!1!==(null===(d=P.attributes)||void 0===d?void 0:d.display_content)&&P.content.trim(),V=Number(null!==(h=null===(v=z.attributes)||void 0===v?void 0:v.display_index)&&void 0!==h?h:M--),K=Number(null!==(x=null===(p=P.attributes)||void 0===p?void 0:p.display_index)&&void 0!==x?x:D--),U=k[V]||e.__assign(e.__assign({id:N,title:!1!==(null===(_=z.attributes)||void 0===_?void 0:_.display_title)?z.title:"",content:!1!==(null===(m=z.attributes)||void 0===m?void 0:m.display_content)?z.content:"",subsections:[]},q?L:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:V,evaluationResult:W,displayContent:null===(y=z.attributes)||void 0===y?void 0:y.display_content,displayTitle:null===(b=z.attributes)||void 0===b?void 0:b.display_title}),G=A[K]||e.__assign(e.__assign({id:N,title:!1!==(null===(S=P.attributes)||void 0===S?void 0:S.display_title)?P.title:"",content:!1!==(null===(R=P.attributes)||void 0===R?void 0:R.display_content)?P.content:"",subsections:[]},Y?L:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:K,evaluationResult:W,displayContent:null===(I=P.attributes)||void 0===I?void 0:I.display_content,displayTitle:null===(C=P.attributes)||void 0===C?void 0:C.display_title});Number(V)>=0&&Number(K)>=0&&((null===(w=U.refIndexes)||void 0===w?void 0:w.includes(Number(K)))||null===(F=U.refIndexes)||void 0===F||F.push(Number(K)),(null===(j=G.refIndexes)||void 0===j?void 0:j.includes(Number(V)))||null===(B=G.refIndexes)||void 0===B||B.push(Number(V))),k[V]=U,A[K]=G;var X=g(H.next,o+1),J=X.refSections,Q=X.baseSections;J.length>0&&(U.subsections=e.__spreadArray(e.__spreadArray([],U.subsections||[],!0),J,!0)),Q.length>0&&(G.subsections=e.__spreadArray(e.__spreadArray([],G.subsections||[],!0),Q,!0))}}return E=Object.values(k).map(function(e){return e}),T=Object.values(A).map(function(e){return e}),E.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),T.sort(function(e,n){return e.selfIndex<0&&n.selfIndex>=0?1:e.selfIndex>=0&&n.selfIndex<0?-1:e.selfIndex-n.selfIndex}),{refSections:E,baseSections:T}},x=g(h.next),_=x.refSections,m=x.baseSections;d=_,u=m}else h.next&&Object.values(h.next).forEach(function(e){var t=n[e]||c[e];t&&!1!==t.display_node&&(u.push(p(e,"0")||{id:e,title:"",content:"",subsections:[]}),d.push(p(e,"1")||{id:e,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(r=null===(o=h.comparison_inputs)||void 0===o?void 0:o[f[0]])||void 0===r?void 0:r.title)||"Uploaded Contract",description:h.decision_scope_description||"",sections:u},activeVariants:[{id:"tree-variant-1",title:(null===(s=null===(l=h.comparison_inputs)||void 0===l?void 0:l[f[1]])||void 0===s?void 0:s.title)||"Reference Template",similarity:0,sections:d,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:h.decision_scope_description||""},fields:{}}}}]}}(E,z,L);return e.__assign(e.__assign({},n),{parseError:null})}catch(e){return console.error("Data Transformation Error: ",e),{activeProposed:{},activeVariants:[],parseError:e instanceof Error?e.message:"Unknown Parsing Error"}}return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"}},[JSON.stringify(E),z,JSON.stringify(L)]),$e=Qe.activeProposed,Ze=Qe.activeVariants,en=Qe.parseError;t.useEffect(function(){en&&Q("Failed to load comparison: ".concat(en))},[en]);var nn=t.useState(null),tn=nn[0];nn[1];var on=t.useState({}),rn=on[0],ln=on[1],sn=t.useState({}),an=sn[0],cn=sn[1],un=(null==Ze?void 0:Ze[0])||b,dn=null===(g=null===(f=null==E?void 0:E.documents)||void 0===f?void 0:f[null===(h=null==E?void 0:E.input_index_map)||void 0===h?void 0:h[0]])||void 0===g?void 0:g.title,vn=null===(C=null===(x=null==E?void 0:E.documents)||void 0===x?void 0:x[null===(I=null==E?void 0:E.input_index_map)||void 0===I?void 0:I[1]])||void 0===C?void 0:C.title,fn=a.safeStringify(k||dn||"Uploaded Contract"),hn=a.safeStringify(A||vn||"Reference Template"),pn=t.useMemo(function(){return(null==$e?void 0:$e.sections)||[]},[null==$e?void 0:$e.sections]),gn=t.useMemo(function(){return un.sections||[]},[un.sections]),xn=pn.length>0||gn.length>0,_n=un.analysis,mn=a.safeStringify(null===(F=null===(w=null==_n?void 0:_n.rule_difference_comparison)||void 0===w?void 0:w.summary)||void 0===F?void 0:F.overall_summary),yn=!!mn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),bn=t.useRef({}),Sn=function(e){return bn.current[e]||(bn.current[e]=p.default.createRef()),bn.current[e]},Rn=t.useCallback(function(){ee(!1),ye.current=!1,Ln(null),be.current=null,En.current=null,ie(!1),G(!1),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),qe.current&&(qe.current.style.height="0px")},[]),In=t.useCallback(function(e,n,t,i,o,r){var l,s,c=a.safeStringify(n.id)||a.safeStringify(t.id)||"",u=(c?Se[c]:null)||n.cognitiveData||t.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},d=null!==(s=null===(l=bn.current[i])||void 0===l?void 0:l.current)&&void 0!==s?s:null;return{open:!0,sectionTitle:n.title||"N/A",refSectionTitle:t.title||"NA",cognitiveData:u,anchorEl:e,sectionAnchorEl:d,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==E?void 0:E.documents,input_index_map:null==E?void 0:E.input_index_map},deviationData:n.evaluationResult||t.evaluationResult||null,isOrphan:!!o}},[Se,E]),Cn=t.useCallback(function(e){Ge(),Ce(null),Ae(e)},[Ge]),wn=function(e,n,t,i,o,r){e.stopPropagation(),De.open&&De.sectionIdx===o?Ge():(Ue(),Oe(In(e.currentTarget,n,i,o,t,r)))},Fn=t.useCallback(function(){null!==De.sectionIdx&&De.anchorEl?Cn(e.__assign(e.__assign({},De),{open:!0})):Ge()},[De,Ge,Cn]),jn=t.useCallback(function(){var e=De.sectionIdx,n=De.isOrphan;Ge(),null!==e&&(n?Q("No counterpart exists to connect to."):(ye.current&&Rn(),ue(function(n){return n.has(e)?new Set:new Set([e])})))},[De.sectionIdx,Ge,Rn]),Bn=t.useRef(null),En=t.useRef(null),Tn=t.useRef(null),kn=t.useRef(null),An=t.useRef(null),Mn=t.useState([]),Dn=Mn[0],On=Mn[1],Nn=t.useState(null),Hn=Nn[0],Ln=Nn[1];t.useRef(null);var Wn=t.useState(null),zn=Wn[0],Pn=Wn[1],qn=t.useMemo(function(){return Je.fields.filter(function(e){var n=e.key;return(!xn||"description"!==n)&&(a.hasValue(null==$e?void 0:$e[n])||a.hasValue(un[n]))})},[$e,un,xn,Je.fields]),Yn=t.useRef({}),Vn=t.useRef({}),Kn=t.useRef({}),Un=t.useRef({}),Gn=t.useRef({}),Xn=t.useRef({}),Jn=t.useRef({}),Qn=t.useRef({}),$n=t.useRef({});qn.forEach(function(e){for(var n=e.key,t=0;t<Math.max(pn.length,gn.length);t+=1)Kn.current[t]||(Kn.current[t]=p.default.createRef()),Un.current[t]||(Un.current[t]=p.default.createRef()),Gn.current[t]||(Gn.current[t]=p.default.createRef()),Xn.current[t]||(Xn.current[t]=p.default.createRef()),Jn.current[t]||(Jn.current[t]=p.default.createRef());Yn.current[n]||(Yn.current[n]=p.default.createRef()),Vn.current[n]||(Vn.current[n]=p.default.createRef())});for(var Zn=0;Zn<Math.max(pn.length,gn.length);Zn+=1)Kn.current[Zn]||(Kn.current[Zn]=p.default.createRef()),Un.current[Zn]||(Un.current[Zn]=p.default.createRef()),Gn.current[Zn]||(Gn.current[Zn]=p.default.createRef()),Xn.current[Zn]||(Xn.current[Zn]=p.default.createRef()),Jn.current[Zn]||(Jn.current[Zn]=p.default.createRef());t.useEffect(function(){if(tn){var e=Je.fields.find(function(e){return e.analysisKey===tn||e.key===tn});if(e){var n=Yn.current[e.key]||Vn.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[tn,Je.fields]);var et=t.useCallback(function(e){var n,t,i,o,r,l,s,a,c,u=null===(n=null==_n?void 0:_n.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!u||!u[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=u[e],v=(null==d?void 0:d.relation)||(null===(i=null===(t=null==d?void 0:d.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(s=f.highlights)||void 0===s?void 0:s.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(a=d.highlights)||void 0===a?void 0:a.ruleA_spans)||[],highlightsB:(null===(c=d.highlights)||void 0===c?void 0:c.ruleB_spans)||[],hasContent:!!v}},[_n]),nt=t.useCallback(function(n){var t,i,o,r=pn[n],l=gn[n],s=(null==r?void 0:r.relation)&&"not_defined"!==r.relation,c=(null==l?void 0:l.relation)&&"not_defined"!==l.relation;a.safeStringify(null==r?void 0:r.id)||a.safeStringify(null==l?void 0:l.id);var u=!(!(null==r?void 0:r.cognitiveData)&&!(null==l?void 0:l.cognitiveData));if(!s&&!c&&!u)return e.__assign(e.__assign({},Je.relationStyles.noContent),{label:"Not Defined"});var d=null!==(i=null!==(t=null==r?void 0:r.evaluationResult)&&void 0!==t?t:null==l?void 0:l.evaluationResult)&&void 0!==i?i:null,v=(null===(o=null==d?void 0:d.evaluation_outputs)||void 0===o?void 0:o.output_value)+"%";return null!=d?e.__assign(e.__assign({},Je.relationStyles.low),{label:v}):e.__assign(e.__assign({},Je.relationStyles.low),{label:"N/A"})},[pn,gn,Se,Je,et]),tt=t.useCallback(function(n){for(var t,i,o,r,l,s,c=n.split("-").map(Number),u=pn[c[0]],d=gn[c[0]],v=1;v<c.length;v++)(null==u?void 0:u.subsections)&&(u=u.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!u&&!d)return null;var f=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,h=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=a.safeStringify(null==u?void 0:u.id)||a.safeStringify(null==d?void 0:d.id)||"",g=!(!(null==u?void 0:u.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!f&&!h&&!g)return e.__assign(e.__assign({},Je.relationStyles.noContent),{label:"Not Defined"});null!==(i=null!==(t=null==u?void 0:u.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=Se[p])||void 0===o||o.relevance_score);var x=null!==(l=null!==(r=null==u?void 0:u.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,_=(null===(s=null==x?void 0:x.evaluation_outputs)||void 0===s?void 0:s.output_value)+"%";return null!=x?e.__assign(e.__assign({},Je.relationStyles.low),{label:_}):e.__assign(e.__assign({},Je.relationStyles.low),{label:"N/A"})},[pn,gn,Se,Je]),it=t.useCallback(function(){var n,t,i,o,r,l,s,c,u,d,v,f,h,p,g,x,m,b,S,R,I,C;if(!Ve.current&&!pe.current){Ve.current=!0;try{if(!Bn.current)return;var w=function(e){var n=e.split("-"),t=n[0];if(!rn[t]&&!1===z)return!1;if(z&&!rn["left-".concat(t)]&&!rn["right-".concat(t)]&&!rn[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!an[i])return!1;return!0},F=Bn.current.getBoundingClientRect();Be({width:F.width,height:F.height});var j=[];if(qn.forEach(function(e){var n,t,i=e.key,o=null===(n=Yn.current[i])||void 0===n?void 0:n.current,r=null===(t=Vn.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!pe.current){for(var B=0;B<Math.max(pn.length,gn.length);B++){var E=null===(n=Kn.current[B])||void 0===n?void 0:n.current,T=null===(t=Un.current[B])||void 0===t?void 0:t.current;E&&(E.style.height="auto",E.style.minHeight="0px"),T&&(T.style.height="auto",T.style.minHeight="0px")}z||Object.keys(Qn.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=Qn.current[e])||void 0===n?void 0:n.current,o=null===(t=$n.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 k={};qn.forEach(function(e){var n,t,i=e.key,o=null===(n=Yn.current[i])||void 0===n?void 0:n.current,r=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),s=r.getBoundingClientRect();k[i]=Math.max(l.height,s.height)}});var A={left:{},right:{}},M={};if(!pe.current)if(z){if(Z&&null!==Hn)if("number"==typeof Hn){var D=Hn,O=pn[D],N=null===(r=Kn.current[D])||void 0===r?void 0:r.current;N&&O&&(O.refIndexes||[]).forEach(function(e){var n,t=gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Un.current[t])||void 0===n?void 0:n.current;if(i&&(rn["left-".concat(D)]||rn["right-".concat(t)])){var o=Math.max(N.getBoundingClientRect().height,i.getBoundingClientRect().height);A.left[D]=Math.max(A.left[D]||0,o),A.right[t]=Math.max(A.right[t]||0,o)}})}else{var H=Hn.split(_)[0];E=null===(l=Qn.current[H])||void 0===l?void 0:l.current,T=null===(s=$n.current[H])||void 0===s?void 0:s.current;if(E&&T){L=Math.max(E.getBoundingClientRect().height,T.getBoundingClientRect().height);M[H]=Math.max(M[H]||0,L)}}}else{Object.keys(Qn.current).forEach(function(e){var n,t;if(w(e)){var i=null===(n=Qn.current[e])||void 0===n?void 0:n.current,o=null===(t=$n.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),s=Math.max(r.height,l.height);M[e]=s,i.style.minHeight="".concat(s,"px"),o.style.minHeight="".concat(s,"px")}}});for(B=0;B<Math.min(pn.length,gn.length);B++){var E=null===(i=Kn.current[B])||void 0===i?void 0:i.current,T=null===(o=Un.current[B])||void 0===o?void 0:o.current;if(E&&T){var L=Math.max(E.getBoundingClientRect().height,T.getBoundingClientRect().height);A.left[B]=L,A.right[B]=L}}}if(qn.forEach(function(e){var n,t,i=e.key,o=null===(n=Yn.current[i])||void 0===n?void 0:n.current,r=null===(t=Vn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=k[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),pe.current||(Object.entries(A.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Kn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(A.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Un.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),z||Object.keys(M).forEach(function(e){var n,t,i=null===(n=Qn.current[e])||void 0===n?void 0:n.current,o=null===(t=$n.current[e])||void 0===t?void 0:t.current;if(i&&o&&M[e]){var r=M[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),z){if(pn.forEach(function(e,n){var t;(null===(t=Kn.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,s,a,c,u,d,v=gn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=Gn.current[n])||void 0===t?void 0:t.current,h=null===(i=Xn.current[v])||void 0===i?void 0:i.current;if(f&&h){var p=f.getBoundingClientRect(),g=h.getBoundingClientRect(),x=p.right-F.left,_=g.left-F.left,m=p.top+p.height/2-F.top,y=g.top+g.height/2-F.top;if(Z&&Hn===n){var b=null!==(r=null===(o=Ye.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(s=null===(l=Le.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==s?s:0,R=b+(null!==(c=null===(a=Ye.current)||void 0===a?void 0:a.clientHeight)&&void 0!==c?c:1/0),I=S+(null!==(d=null===(u=Le.current)||void 0===u?void 0:u.clientHeight)&&void 0!==d?d:1/0),C=p.top+p.height/2,w=function(e,n,t){return Math.max(n,Math.min(t,e))};m=w(C,b,R)-F.top,y=w(C,S,I)-F.top}var B=nt(n);B&&j.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:y,style:B,sectionIdx:n,targetRightIdx:v})}}})}),Z&&"string"==typeof Hn){var W=Hn,P=(H=W.split(_)[0],null===(h=Gn.current[W])||void 0===h?void 0:h.current),q=null===(p=Xn.current[W])||void 0===p?void 0:p.current;if(P&&q){var Y=P.getBoundingClientRect(),V=q.getBoundingClientRect(),K=Y.right-F.left,U=V.left-F.left,G=null!==(x=null===(g=Ye.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==x?x:0,X=null!==(b=null===(m=Le.current)||void 0===m?void 0:m.getBoundingClientRect().top)&&void 0!==b?b:0,J=G+(null!==(R=null===(S=Ye.current)||void 0===S?void 0:S.clientHeight)&&void 0!==R?R:1/0),Q=X+(null!==(C=null===(I=Le.current)||void 0===I?void 0:I.clientHeight)&&void 0!==C?C:1/0),$=Y.top+Y.height/2,ee=V.top+V.height/2,ne=function(e,n,t){return Math.max(n,Math.min(t,e))},te=ne($,G,J)-F.top,ie=ne(ee,X,Q)-F.top;(le=tt(H))&&j.push({id:"line-subsec-".concat(W),x1:K,y1:te,x2:U,y2:ie,style:le,sectionIdx:Number(H.split("-")[0]),isSubSection:!0,subSectionKeyPath:W})}}}else{for(B=0;B<Math.min(pn.length,gn.length);B++){var oe=null===(c=Kn.current[B])||void 0===c?void 0:c.current,re=null===(u=Un.current[B])||void 0===u?void 0:u.current;if(oe&&re){var le,se=oe.getBoundingClientRect(),ae=re.getBoundingClientRect(),ue=Math.max(se.top,ae.top)+18-F.top,de=(null===(d=gn[B])||void 0===d?void 0:d.id)||"sec-".concat(B);(le=nt(B))&&j.push({id:de,x1:se.right-F.left,y1:ue,x2:ae.left-F.left,y2:ue,style:le,sectionIdx:B,hasCognitive:!!((null===(v=pn[B])||void 0===v?void 0:v.cognitiveData)||(null===(f=gn[B])||void 0===f?void 0:f.cognitiveData)||de&&Se[de])})}}Object.keys(Gn.current).forEach(function(n){var t,i,o,r,l,s,c,u,d,v;if(n.includes(_)){var f=n.split(_)[0];if(w(f)){var h=null===(t=Gn.current[n])||void 0===t?void 0:t.current,p=null===(i=Xn.current[n])||void 0===i?void 0:i.current;if(h&&p&&null!==h.offsetParent&&null!==p.offsetParent){for(var g=h.getBoundingClientRect(),x=p.getBoundingClientRect(),m=g.top+g.height/2-F.top,y=x.top+x.height/2-F.top,b=f.split("-").map(Number),S=pn[b[0]],R=gn[b[0]],I=1;I<b.length;I++)(null==S?void 0:S.subsections)&&(S=S.subsections[b[I]]),(null==R?void 0:R.subsections)&&(R=R.subsections[b[I]]);if(!S&&!R)return;var C=(null==S?void 0:S.relation)&&"not_defined"!==S.relation,B=(null==R?void 0:R.relation)&&"not_defined"!==R.relation,E=a.safeStringify(null==S?void 0:S.id)||a.safeStringify(null==R?void 0:R.id)||"",T=!(!(null==S?void 0:S.cognitiveData)&&!(null==R?void 0:R.cognitiveData)),k=null;if(C||B||T){var A=null!==(r=null!==(o=null==S?void 0:S.evaluationResult)&&void 0!==o?o:null==R?void 0:R.evaluationResult)&&void 0!==r?r:null,M=null!==(v=null!==(u=null!==(s=null===(l=null==A?void 0:A.evaluation_output)||void 0===l?void 0:l.output_score)&&void 0!==s?s:null===(c=null==A?void 0:A.evaluation_outputs)||void 0===c?void 0:c.output_score)&&void 0!==u?u:null===(d=null==A?void 0:A.evaluation_outputs)||void 0===d?void 0:d.output_value)&&void 0!==v?v:null==A?void 0:A.output_score,D=null!=M?"".concat(M,"%"):"N/A";k=null!=A?e.__assign(e.__assign({},Je.relationStyles.low),{label:D}):e.__assign(e.__assign({},Je.relationStyles.low),{label:"N/A"})}else k={badgeBg:"#EEF2FF",badgeText:"#3730A3",badgeBorder:"#C7D2FE",label:"N/A"};k&&j.push({id:"line-subsec-".concat(n),x1:g.right-F.left,y1:m,x2:x.left-F.left,y2:y,style:k,sectionIdx:b[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:T||!(!E||!Se[E])})}}}})}if(On(j),kn.current&&An.current){var ve=kn.current.getBoundingClientRect(),he=An.current.getBoundingClientRect(),ge=(ve.top+ve.height/2-F.top+he.top+he.height/2-F.top)/2;Pn({x1:ve.right-F.left,x2:he.left-F.left,y:ge})}else Pn(null);if(z&&ce.size>0){var xe=[],me=Ye.current,ye=Le.current;if(me&&ye){var be=[],Re=me.getBoundingClientRect().top,Ie=ye.getBoundingClientRect().top,Ce=Re+me.clientHeight,we=Ie+ye.clientHeight,Fe=me.scrollTop,je=ye.scrollTop,Ee=F.top,Te=function(e,n,t){return Math.max(n,Math.min(t,e))};ce.forEach(function(e){var n,t,i;if("string"==typeof e){var o=e,r=o.split(_)[0],l=null===(n=Gn.current[o])||void 0===n?void 0:n.current,s=null===(t=Xn.current[o])||void 0===t?void 0:t.current;if(!l||!s)return;var a=l.getBoundingClientRect(),c=s.getBoundingClientRect(),u=tt(r),d=a.right-F.left,v=c.left-F.left-0,f=d+.5*(v-d),h=a.top+a.height/2,p=c.top+c.height/2,g=h-Re+Fe,x=p-Ie+je,m="conn-subsec-".concat(o);be.push({lhsScrollY:g,rhsScrollY:x,x1:d,x2:v,containerTop:Ee,leftIdx:o,rhsArrayIdx:o,styleColor:(null==u?void 0:u.badgeBorder)||"#6366F1",styleId:m});var b=Te(h,Re,Ce),S=Te(p,Ie,we),R=b-Ee,I=S-Ee,C=h>=Re-4&&h<=Ce+4,w=p>=Ie-4&&p<=we+4,j="";j=C&&w?y(d,R,v,I):C&&!w?"M ".concat(d,",").concat(R," L ").concat(f,",").concat(R," L ").concat(f,",").concat(I):!C&&w?"M ".concat(f,",").concat(R," L ").concat(f,",").concat(I," L ").concat(v,",").concat(I):"M ".concat(f,",").concat(R," L ").concat(f,",").concat(I),xe.push({id:m,pathD:j,style:u,leftIdx:o,rhsArrayIdx:o})}else{var B=pn[e];if(!(null===(i=null==B?void 0:B.refIndexes)||void 0===i?void 0:i.length))return;B.refIndexes.forEach(function(n){var t,i,o=gn.findIndex(function(e){return e.selfIndex===n});if(-1!==o){var r=null===(t=Gn.current[e])||void 0===t?void 0:t.current,l=null===(i=Xn.current[o])||void 0===i?void 0:i.current;if(r&&l){var s=r.getBoundingClientRect(),a=l.getBoundingClientRect(),c=nt(e),u=s.right-F.left,d=a.left-F.left-0,v=u+.5*(d-u),f=s.top+s.height/2,h=a.top+a.height/2,p=f-Re+Fe,g=h-Ie+je,x="conn-".concat(e,"-").concat(o);be.push({lhsScrollY:p,rhsScrollY:g,x1:u,x2:d,containerTop:Ee,leftIdx:e,rhsArrayIdx:o,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:x});var _=Te(f,Re,Ce),m=Te(h,Ie,we),b=_-Ee,S=m-Ee,R=f>=Re-4&&f<=Ce+4,I=h>=Ie-4&&h<=we+4,C="";C=R&&I?y(u,b,d,S):R&&!I?"M ".concat(u,",").concat(b," L ").concat(v,",").concat(b," L ").concat(v,",").concat(S):!R&&I?"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S," L ").concat(d,",").concat(S):"M ".concat(v,",").concat(b," L ").concat(v,",").concat(S),xe.push({id:x,pathD:C,style:c,leftIdx:e,rhsArrayIdx:o})}}})}}),_e.current=be}fe(xe)}else fe([]),_e.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Ve.current=!1}}},[qn,pn,gn,Se,Je,et,nt,z,Z,Hn,ce,rn,an]),ot=t.useCallback(function(){var e,n,t,i,o,r,l,s,a,c,u,d,v,f,h=_e.current;if(h.length&&!pe.current){var p=null!==(n=null===(e=Ye.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,g=null!==(i=null===(t=Le.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=Ye.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,_=null!==(s=null===(l=Le.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,m=null!==(c=null===(a=Ye.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==c?c:0,b=null!==(d=null===(u=Le.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==d?d:0,S=m+x,R=b+_,I=null!==(f=null===(v=Bn.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,C=function(e,n,t){return Math.max(n,Math.min(t,e))};h.forEach(function(e){var n=e.lhsScrollY-p+m,t=e.rhsScrollY-g+b,i=xe.current[e.styleId+"-stroke"],o=xe.current[e.styleId+"-bg"];if(i||o){var r,l=C(n,m,S),s=C(t,b,R),a=l-I,c=s-I,u=n>=m-4&&n<=S+4,d=t>=b-4&&t<=R+4,v=e.x1+.5*(e.x2-e.x1);r=u&&d?y(e.x1,a,e.x2,c):u&&!d?"M ".concat(e.x1,",").concat(a," L ").concat(v,",").concat(a," L ").concat(v,",").concat(c):!u&&d?"M ".concat(v,",").concat(a," L ").concat(v,",").concat(c," L ").concat(e.x2,",").concat(c):"M ".concat(v,",").concat(a," L ").concat(v,",").concat(c),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]),rt=t.useRef(it);t.useEffect(function(){rt.current=it},[it]);var lt=t.useRef(null),st=t.useCallback(function(){null!==lt.current&&clearTimeout(lt.current),lt.current=setTimeout(function(){rt.current(),lt.current=null},50)},[]),at=t.useCallback(function(e){var n,t,i,o,r,l,s,a;if(!oe.current){if(z||st(),ye.current){var c=be.current,u=En.current,d=Ye.current,v=Le.current;if(null!==c&&null!==u&&d&&v){var f="string"==typeof c?null===(n=Gn.current[c])||void 0===n?void 0:n.current:null===(t=bn.current[c])||void 0===t?void 0:t.current,h="string"==typeof u?null===(i=Xn.current[u])||void 0===i?void 0:i.current:null===(o=Jn.current[u])||void 0===o?void 0:o.current;if(f&&h){var p=f.getBoundingClientRect().top-d.getBoundingClientRect().top+d.scrollTop,g=h.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;if(e.currentTarget===d){var x=g-(p-d.scrollTop),_=v.scrollHeight-v.clientHeight,m=Math.max(0,Math.min(x,_));Math.abs(v.scrollTop-m)>1&&(v.scrollTop=m)}else if(e.currentTarget===v){var y=p-(g-v.scrollTop),b=d.scrollHeight-d.clientHeight,S=Math.max(0,Math.min(y,b));Math.abs(d.scrollTop-S)>1&&(d.scrollTop=S)}if(Tn.current){var R=null===(r=Gn.current[c])||void 0===r?void 0:r.current,I=null===(l=Xn.current[u])||void 0===l?void 0:l.current,C=null!==(a=null===(s=Bn.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==a?a:0,w=d.getBoundingClientRect().top,F=w+d.clientHeight,j=v.getBoundingClientRect().top,B=j+v.clientHeight,E=function(e,n,t){return Math.max(n,Math.min(t,e))};if(R&&I){var T=R.getBoundingClientRect(),k=I.getBoundingClientRect(),A=T.top+T.height/2,M=k.top+k.height/2,D=E(A,w,F),O=E(M,j,B);Tn.current.setAttribute("y1",(D-C).toString()),Tn.current.setAttribute("y2",(O-C).toString());var N=A>=w-4&&A<=F+4;Tn.current.setAttribute("visibility",N?"visible":"hidden")}}}}}_e.current.length>0&&!me.current&&(me.current=!0,requestAnimationFrame(function(){ot(),me.current=!1}))}},[ot,z,st]);t.useEffect(function(){var e=setTimeout(st,250);window.addEventListener("resize",st);var n=null,t=null;return Ne.current&&(n=new ResizeObserver(st)).observe(Ne.current),Bn.current&&(t=new ResizeObserver(st)).observe(Bn.current),function(){clearTimeout(e),window.removeEventListener("resize",st),null==n||n.disconnect(),null==t||t.disconnect()}},[$e,un,_n,qn,rn,an,pn,gn,Je,st,Z,Hn,te,ce]),t.useEffect(function(){ye.current=Z},[Z]),t.useEffect(function(){be.current=Hn},[Hn]);var ct=t.useCallback(function(){var e=De.sectionIdx,n=De.isOrphan;Ge(),null!=e&&(n?Q("No counterpart exists for this section."):Z&&Hn===e?Rn():(ue(new Set),fe([]),_e.current=[],G(!0),oe.current=!0,Ln(e),be.current=e,ee(!0),ye.current=!0,ie(!1),We.current&&(We.current.style.height="0px"),ze.current&&(ze.current.style.height="0px"),Pe.current&&(Pe.current.style.height="0px"),qe.current&&(qe.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r=null,l=null,s=null;if("string"==typeof e)r=(null===(n=Gn.current[e])||void 0===n?void 0:n.current)||null,s=(l=(null===(t=Xn.current[e])||void 0===t?void 0:t.current)||null)?e:null;else{r=(null===(i=bn.current[e])||void 0===i?void 0:i.current)||null;var a=pn[e],c=(null==a?void 0:a.refIndexes)||[];if(c.length>0){var u=c[0],d=gn.findIndex(function(e){return e.selfIndex===u});-1!==d&&(l=(null===(o=Jn.current[d])||void 0===o?void 0:o.current)||null,s=d)}}En.current=s;var v=Ye.current,f=Le.current;if(!r||!v)return oe.current=!1,void G(!1);if(!l||!f)return ie(!0),rt.current(),oe.current=!1,void G(!1);var h=r.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop,p=l.getBoundingClientRect().top-f.getBoundingClientRect().top+f.scrollTop-(h-v.scrollTop);p<0&&We.current&&(We.current.style.height="".concat(Math.abs(p),"px"));requestAnimationFrame(function(){var e,n=f.scrollHeight-f.clientHeight;if(p<0)e=0;else{if(p>n){var t=p-n;return ze.current&&(ze.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){R(f,p,200,function(){ie(!0),rt.current(),oe.current=!1,G(!1)})})}e=p}R(f,e,200,function(){ie(!0),rt.current(),oe.current=!1,G(!1)})})})))},[Ge,De.sectionIdx,Z,Hn,pn,gn,st,Rn]),ut=null!==De.sectionIdx&&ce.has(De.sectionIdx),dt=function(t){var r,l,s,c=t.section,u=t.idx,d=t.columnKey,v=t.colRef,f=t.mb,h=void 0===f?1:f,g=t.parentNodeId,x=void 0===g?"":g,_=z?!!rn["".concat(d,"-").concat(u)]:!!rn[String(u)],y=(null===(r=c.displayTitle)||void 0===r||r)&&a.hasValue(c.title),b=(null===(l=c.displayContent)||void 0===l||l)&&a.hasValue(c.content),S=!y&&!b,R=c.title;y||(R=b?"No Title Found":"No Matching Section Found");var I,C=[];if(null===(s=c.evaluationResult)||void 0===s?void 0:s.deviations){var w=c.evaluationResult.deviations;for(var F in w){var j=w[F][x];j&&C.push(j)}}return n.jsx(i.Box,e.__assign({ref:v,sx:{mb:h,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!S&&_,onChange:function(){return!S&&function(n,t){var i,o;pe.current=!0,ge.current&&clearTimeout(ge.current),he.current&&(he.current.style.opacity="0");var r=null===(i=Kn.current[n])||void 0===i?void 0:i.current,l=null===(o=Un.current[n])||void 0===o?void 0:o.current;if(r&&(r.style.minHeight="0px"),l&&(l.style.minHeight="0px"),Object.keys(Qn.current).forEach(function(e){var t,i;if(e.startsWith("".concat(n,"-"))){var o=null===(t=Qn.current[e])||void 0===t?void 0:t.current,r=null===(i=$n.current[e])||void 0===i?void 0:i.current;o&&(o.style.minHeight="0px"),r&&(r.style.minHeight="0px")}}),z){var s=pn[n];((null==s?void 0:s.refIndexes)||[]).forEach(function(e){var n,t=gn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Un.current[t])||void 0===n?void 0:n.current;i&&(i.style.minHeight="0px")});var a=gn[n],c=null==a?void 0:a.selfIndex;pn.forEach(function(e,n){var t,i;if(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c)){var o=null===(i=Kn.current[n])||void 0===i?void 0:i.current;o&&(o.style.minHeight="0px")}})}ge.current=setTimeout(function(){pe.current=!1,rt.current(),he.current&&(he.current.style.opacity="1")},650),ln(function(i){var o=e.__assign({},i);if(!z){var r=!!i[String(n)];return o[String(n)]=!r,o}var l="".concat(t,"-").concat(n),s=!i[l];if(o[l]=s,"left"===t)((null==(a=pn[n])?void 0:a.refIndexes)||[]).forEach(function(e){var n=gn.findIndex(function(n){return n.selfIndex===e});-1!==n&&(o["right-".concat(n)]=s)});else{var a,c=null==(a=gn[n])?void 0:a.selfIndex;pn.forEach(function(e,n){var t;(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c))&&(o["left-".concat(n)]=s)})}return o})}(u,d)},sx:{boxShadow:"none",border:S?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:S?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:S?null:n.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:S?"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:y&&n.jsx(i.Tooltip,e.__assign({title:R,placement:"top"},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:S?"#94A3B8":"#19213D",fontWeight:S?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(I=R,I?a.safeStringify(I).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,t){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},t):n.jsx(p.default.Fragment,{children:e},t)}):null)}))}))})),!S&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[b&&n.jsx(m,{content:c.content,sxStyles:Ee,highlights:C,maintainRelativeOrder:z}),(c.subsections||[]).map(function(e,n){return vt({section:e,keyPath:"".concat(u,"-").concat(n),depth:0,columnKey:d,parentNodeId:x})})]}))]}))}),"".concat(d,"-sec-").concat(u))},vt=function(t){var r,l,s,c,u,d,v,f,h,g=t.section,x=t.keyPath,y=t.depth,b=void 0===y?0:y,S=t.columnKey,R=void 0===S?"left":S,I=t.parentNodeId,C=void 0===I?"":I,w=(null===(r=g.displayTitle)||void 0===r||r)&&a.hasValue(g.title),F=(null===(l=g.displayContent)||void 0===l||l)&&a.hasValue(g.content),j=!w&&!F,B=w?g.title:F?"No Title Found":"No Matching Section Found",T=!!an[x];"left"!==R||Qn.current[x]||(Qn.current[x]=p.default.createRef()),"right"!==R||$n.current[x]||($n.current[x]=p.default.createRef());for(var k="left"===R?Qn.current[x]:$n.current[x],A=tt(x),M=x.split("-").map(Number),D=pn[M[0]],O=gn[M[0]],N=1;N<M.length;N++)(null==D?void 0:D.subsections)&&(D=D.subsections[M[N]]),(null==O?void 0:O.subsections)&&(O=O.subsections[M[N]]);var H=null===(s=null==E?void 0:E.input_index_map)||void 0===s?void 0:s[0],L=null===(c=null==E?void 0:E.input_index_map)||void 0===c?void 0:c[1],W="left"===R?L:H,P=!(null===(u=g.refIndexes)||void 0===u?void 0:u.length)||void 0!==g.selfIndex&&g.selfIndex<0,q=null!==(f=null===(v=null===(d=g.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||void 0===v?void 0:v.output_value)&&void 0!==f?f:null,Y=Object.entries((null===(h=g.evaluationResult)||void 0===h?void 0:h.deviations)||{}).map(function(e,n){var t=e[0],i=e[1],o=i[C];if(!o||"No equivalent clause present."===o)return null;var r=function(e,n){return"".concat(e).concat(_).concat(n)}(x,t),l=i[W],s=P||!l||"No equivalent clause present."===l,a=M[0]+1,c="".concat(a,".").concat(n+1);return"left"!==R||Gn.current[r]||(Gn.current[r]=p.default.createRef()),"right"!==R||Xn.current[r]||(Xn.current[r]=p.default.createRef()),{id:r,label:c,highlight:o,side:R,style:A,score:q,isConnected:z&&ce.has(r),isOrphan:s,badgeRef:"left"===R?Gn.current[r]:Xn.current[r],onClick:function(e){e.stopPropagation(),wn(e,D||{title:"",content:""},s,O||{title:"",content:""},r,A)}}}).filter(Boolean),V=z&&Y.some(function(e){return ce.has(e.id)});return w||F||g.subsections&&0!==g.subsections.length?w?n.jsx(i.Box,e.__assign({ref:k,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({width:"100%"},V&&A&&{borderRadius:"4px",outline:"2px solid ".concat(A.badgeBorder),outlineOffset:"1px"})},{children:n.jsxs(i.Accordion,e.__assign({disableGutters:!0,expanded:!j&&T,onChange:function(){return!j&&cn(function(n){var t;return e.__assign(e.__assign({},n),((t={})[x]=!n[x],t))})},sx:{mt:0,boxShadow:"none",border:j?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(i.AccordionSummary,e.__assign({expandIcon:j?null:n.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:n.jsx(i.Typography,e.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:j?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:B||"Untitled Subsection"}))})),!j&&n.jsxs(i.AccordionDetails,e.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[F&&n.jsx(m,{content:g.content,sxStyles:Ee,deviationBadges:Y,maintainRelativeOrder:z}),(g.subsections||[]).map(function(e,n){return vt({section:e,keyPath:"".concat(x,"-").concat(n),depth:b+1,columnKey:R,parentNodeId:C})})]}))]}))}))}),x):n.jsx(i.Box,e.__assign({ref:k,sx:{mt:0===b?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!j&&n.jsxs(i.Box,e.__assign({sx:e.__assign({width:"100%"},V&&A&&{borderRadius:"4px",outline:"2px solid ".concat(A.badgeBorder),outlineOffset:"1px"})},{children:[F&&n.jsx(m,{content:g.content,sxStyles:Ee,deviationBadges:Y,maintainRelativeOrder:z}),(g.subsections||[]).map(function(e,n){return vt({section:e,keyPath:"".concat(x,"-").concat(n),depth:b+1,columnKey:R,parentNodeId:C})})]}))}),x):null};return n.jsxs(i.Box,e.__assign({ref:He,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},z?{}:{overflow:"visible"}),{position:"relative"})},{children:[Y&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),z&&n.jsx(d.default,{open:De.open,anchorEl:De.anchorEl,sectionTitle:De.sectionTitle,referenceSectionTitle:De.refSectionTitle,onClose:Ge,onOpenCognitiveCompare:Fn,onOpenSideBySide:ct,onConnect:jn,isConnected:ut,isOrphan:De.isOrphan}),ke.open&&n.jsx(u.default,{open:ke.open,popupRef:we,position:Ie,popupConfig:N,onClose:function(){Ce(null),Ae(function(n){return e.__assign(e.__assign({},n),{open:!1})}),se(null)},markdownStyles:M,sectionTitle:ke.sectionTitle,referenceSectionTitle:ke.refSectionTitle,cognitiveData:ke.cognitiveData,anchorEl:ke.anchorEl,sectionAnchorEl:ke.sectionAnchorEl,scrollContainerEl:Ne.current,badgeStyle:ke.badgeStyle,docData:ke.docData,deviationData:ke.deviationData}),n.jsx(i.Snackbar,e.__assign({open:!!J,autoHideDuration:8e3,onClose:function(){return Q(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Q(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:J}))})),(O.isHeaderVisible||O.isToggleVisible)&&n.jsxs(i.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:O.isHeaderVisible&&n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:B}))})),O.isToggleVisible&&n.jsx(i.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:n.jsx(i.FormControlLabel,{control:n.jsx(i.Switch,{checked:z,onChange:function(e){var n=e.target.checked;V(!0),setTimeout(function(){P(n),Rn(),ue(new Set),fe([]),_e.current=[],setTimeout(function(){V(!1)},400)},50)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#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}})}))]})),n.jsx(i.Box,e.__assign({ref:Ne,onScroll:at,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:z?"hidden":"auto",borderTop:mn&&yn?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},z?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Bn,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"10px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},z?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:he,style:{position:"absolute",top:0,left:0,width:je.width||"100%",height:je.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",transition:"opacity 0.15s ease-in-out"}},{children:[zn&&n.jsxs("g",{children:[n.jsx("line",{x1:zn.x1,y1:zn.y,x2:Math.max(zn.x1,(zn.x1+zn.x2)/2-70),y2:zn.y,stroke:"#BBF7D0",strokeWidth:"1.5"}),n.jsx("line",{x1:Math.min(zn.x2,(zn.x1+zn.x2)/2+70),y1:zn.y,x2:zn.x2,y2:zn.y,stroke:"#BBF7D0",strokeWidth:"1.5"})]}),Dn.map(function(t){var l,s=t.x1+.5*(t.x2-t.x1),a=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(!z){var c=t.isSubSection?y(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2);return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-norm-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#E2E8F0"})}))}),n.jsx("path",{d:c,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5",markerEnd:"url(#arr-norm-".concat(t.id,")")}),n.jsx("foreignObject",e.__assign({x:s-100,y:a-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){if(e.stopPropagation(),ke.open&&le===t.id)Ue();else{var n=pn[t.sectionIdx]||{title:"",content:""},i=gn[t.sectionIdx]||{title:"",content:""};if(t.isSubSection&&t.subSectionKeyPath){for(var o=t.subSectionKeyPath.split("-").map(Number),r=pn[o[0]],l=gn[o[0]],s=1;s<o.length;s++)(null==r?void 0:r.subsections)&&(r=r.subsections[o[s]]),(null==l?void 0:l.subsections)&&(l=l.subsections[o[s]]);r&&(n=r),l&&(i=l)}se(t.id),Cn(In(e.currentTarget,n,i,t.sectionIdx,t.style))}},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:500,textAlign:"center",whiteSpace:"nowrap",cursor:"pointer"}},{children:[t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:ke.open&&le===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}var u=!1;if(t.isSubSection)u=Z&&Hn===t.subSectionKeyPath&&te;else{var d=pn[t.sectionIdx];if(!(null===(l=null==d?void 0:d.refIndexes)||void 0===l?void 0:l.length)||(null==d?void 0:d.selfIndex)<0)return null;u=Z&&Hn===t.sectionIdx&&te}return u?n.jsxs("g",e.__assign({style:{transition:"opacity 0.2s"}},{children:[n.jsx("defs",{children:n.jsx("marker",e.__assign({id:"arr-".concat(t.id),markerWidth:"7",markerHeight:"5",refX:"7",refY:"2.5",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 7 2.5, 0 5",fill:t.style.badgeBorder||"#6366F1"})}))}),n.jsx("line",{ref:Tn,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.badgeBorder||"#6366F1",strokeWidth:"1.5",markerEnd:"url(#arr-".concat(t.id,")")})]}),t.id):null}),ve.map(function(t){var i,o=t.pathD,r=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),s="".concat(t.id,"-bg"),a="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:l,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:r})}))}))}),n.jsx("path",{ref:function(e){xe.current[s]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){xe.current[a]=e},d:o,fill:"none",stroke:r,strokeWidth:"1.75",markerEnd:"url(#".concat(l,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},z?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:kn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",minHeight:"40px",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:fn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:fn}))}))})),n.jsxs(i.Box,e.__assign({ref:Ye,onScroll:at,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},z?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Pe,style:{width:"100%",height:"0px",flexShrink:0}}),xn&&pn.map(function(t,r){var l,s,a,c=!t.title&&!t.content;if(z&&c)return null;if(!z)return n.jsx(i.Box,e.__assign({ref:Sn(r),sx:{width:"100%"}},{children:dt({section:t,idx:r,columnKey:"left",colRef:Kn.current[r],parentNodeId:(null===(l=null==E?void 0:E.input_index_map)||void 0===l?void 0:l[0])||""})}),"left-row-".concat(r));var u=t,d=nt(r),v=!(null===(s=u.refIndexes)||void 0===s?void 0:s.length)||u.selfIndex<0,f="number"==typeof u.selfIndex&&u.selfIndex>=0?u.selfIndex+1:null,h=ce.has(r);return n.jsx(i.Box,e.__assign({ref:Sn(r),sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Kn.current[r],sx:e.__assign({width:"100%",display:"flex"},h&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:dt({section:t,idx:r,columnKey:"left",colRef:p.default.createRef(),mb:0,parentNodeId:(null===(a=null==E?void 0:E.input_index_map)||void 0===a?void 0:a[0])||""})})),d&&n.jsxs(i.Box,e.__assign({ref:Gn.current[r],onClick:function(e){var n=gn.find(function(e){var n;return null===(n=u.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""};wn(e,t,v,n,r,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:v?"No Deviation Found":0==d.deviationLabel||void 0===d.deviationLabel?d.label:"".concat(d.deviationLabel,"% Deviation")})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:qe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",borderRadius:"20px",bgcolor:"#ECFDF3",border:"1px solid #A7F3D0",color:"#15803D",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1}},{children:[n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),0,"% Similarity",n.jsx(o.ChevronDown,{size:11})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},z?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[U&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:An,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:hn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",textOverflow:"ellipsis",whiteSpace:"normal",width:"100%",height:"40px"}},{children:hn}))}))})),n.jsxs(i.Box,e.__assign({ref:Le,onScroll:at,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},z?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-20px",pl:"40px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:We,style:{width:"100%",height:"0px",flexShrink:0}}),xn&&gn.map(function(t,o){var r,l;if(!z)return n.jsx(i.Box,e.__assign({ref:Jn.current[o],sx:{width:"100%"}},{children:dt({section:t,idx:o,columnKey:"right",colRef:Un.current[o],parentNodeId:(null===(r=null==E?void 0:E.input_index_map)||void 0===r?void 0:r[1])||""})}),"right-row-".concat(o));var s=t,a=pn.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(s.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),c=pn.some(function(e,n){var t;return ce.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),u=pn.findIndex(function(e,n){var t;return ce.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(s.selfIndex))}),d=-1!==u?nt(u):null;return n.jsx(i.Box,e.__assign({ref:Jn.current[o],sx:{mb:1}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:Un.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:dt({section:t,idx:o,columnKey:"right",colRef:p.default.createRef(),mb:0,parentNodeId:(null===(l=null==E?void 0:E.input_index_map)||void 0===l?void 0:l[1])||""})})),!U&&n.jsx(i.Box,e.__assign({ref:Xn.current[o],sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:"#EEF2FF",color:"#3730A3",border:"1px solid #C7D2FE",borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:a.length>0?a.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:ze,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("@mui/material"),t=require("../../assests/svg/ButtonCognitiveIcon.js"),o=function(){return i.jsx("svg",e.__assign({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M2 6.5L5 9.5L11 3.5",stroke:"#15803D",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}))},s=[{key:"connect",title:"Connect",icon:i.jsx("svg",e.__assign({width:"15",height:"18",viewBox:"0 0 15 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M14.8237 3.89331C14.547 5.57188 13.0559 6.77501 11.3572 6.69242C9.65857 6.60983 8.2925 5.26384 8.18312 3.56742C4.75678 3.67456 3.54027 4.4759 3.73893 6.10536C3.81259 6.71474 4.18089 7.04063 4.85723 7.19911C5.26794 7.2951 5.7233 7.30849 6.13625 7.27054C6.17419 7.26608 6.21437 7.26385 6.25232 7.25938C6.50455 7.19911 6.76125 7.14777 7.01794 7.1076C7.77911 6.9826 8.55366 6.9201 9.29027 6.96027C11.3617 7.07188 12.7724 7.98483 12.8438 9.92233C12.913 11.7996 11.6229 13.1299 9.5425 14.0205C8.87509 14.3063 8.1675 14.5272 7.45991 14.6946C7.14071 14.7705 6.87286 14.8219 6.67419 14.8554C6.49786 16.5496 5.07821 17.842 3.37509 17.8554C1.67196 17.8688 0.229997 16.6031 0.0246403 14.9112C-0.180717 13.2192 0.917498 11.6455 2.57375 11.2527C4.23 10.8598 5.91973 11.7728 6.49562 13.3755C6.70544 13.3375 6.91303 13.2951 7.12062 13.246C7.75009 13.0987 8.37955 12.9022 8.95991 12.6522C10.538 11.9781 11.3996 11.0875 11.3595 9.9759C11.3237 8.98036 10.6095 8.52054 9.21214 8.44465C8.5983 8.41117 7.92643 8.46474 7.26348 8.57411C7.07821 8.60536 6.90857 8.63661 6.75902 8.6701C6.67196 8.68795 6.61169 8.70358 6.58491 8.71027L6.51571 8.72367C6.4666 8.73036 6.38402 8.74152 6.27687 8.75268C5.71884 8.80402 5.11393 8.78617 4.52464 8.65001C3.2925 8.36206 2.42866 7.59643 2.26794 6.2884C1.9175 3.47143 4.02241 2.16563 8.42866 2.07188C9.07821 0.500452 10.8037 -0.336602 12.4376 0.129916C14.0737 0.596434 15.1005 2.21474 14.8237 3.89331V3.89331ZM3.34161 12.6478C3.09741 12.6478 2.85562 12.6959 2.63002 12.7894C2.40442 12.8828 2.19944 13.0198 2.02678 13.1925C1.85412 13.3652 1.71717 13.5702 1.62373 13.7958C1.5303 14.0214 1.48222 14.2632 1.48223 14.5074C1.48224 14.7516 1.53036 14.9934 1.62382 15.219C1.71728 15.4446 1.85426 15.6495 2.02694 15.8222C2.19962 15.9949 2.40462 16.1318 2.63022 16.2252C2.85583 16.3187 3.09764 16.3668 3.34183 16.3667C3.83499 16.3667 4.30795 16.1708 4.65665 15.822C5.00535 15.4733 5.20123 15.0003 5.2012 14.5071C5.20117 14.014 5.00524 13.541 4.65649 13.1923C4.30775 12.8436 3.83477 12.6477 3.34161 12.6478ZM11.5224 1.49152C11.2782 1.49154 11.0364 1.53965 10.8108 1.63311C10.5852 1.72657 10.3802 1.86355 10.2076 2.03623C10.0349 2.20891 9.89797 2.41391 9.80454 2.63952C9.7111 2.86513 9.66302 3.10693 9.66303 3.35112C9.66305 3.59531 9.71116 3.83711 9.80462 4.06271C9.89808 4.28831 10.0351 4.49329 10.2077 4.66594C10.3804 4.8386 10.5854 4.97556 10.811 5.06899C11.0366 5.16243 11.2784 5.21051 11.5226 5.2105C12.0158 5.21047 12.4888 5.01453 12.8375 4.66579C13.1862 4.31704 13.382 3.84406 13.382 3.3509C13.382 2.85773 13.186 2.38478 12.8373 2.03608C12.4886 1.68738 12.0156 1.49149 11.5224 1.49152V1.49152Z",fill:"#1D2939",fillOpacity:"0.85"})}))},{key:"side-by-side",title:"Side by Side",icon:i.jsx("svg",e.__assign({width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M3.19922 8.19922H13.1992M3.19922 8.19922L4.86589 10.6992M3.19922 8.19922L4.86589 5.69922M13.1992 8.19922L11.5326 10.6992M13.1992 8.19922L11.5326 5.69922M15.6992 0.699219V15.6992M0.699219 0.699219V15.6992",stroke:"#3F4957",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}))},{key:"cognitive-decisioning",title:"Cognitive Decisioning",icon:i.jsx(t.ButtonCognitiveIcon,{})}];exports.default=function(t){var r=t.open,l=t.anchorEl;t.sectionTitle,t.referenceSectionTitle;var C=t.onClose,c=t.onOpenCognitiveCompare,a=t.onOpenSideBySide,d=t.onConnect,g=t.isConnected,x=void 0!==g&&g;return i.jsx(n.Menu,e.__assign({open:r,anchorEl:l,onClose:C,disableScrollLock:!0,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},PaperProps:{sx:{ml:.75,minWidth:190,maxWidth:220,borderRadius:"12px",border:"1px solid #E4E7EC",boxShadow:"0px 12px 28px rgba(16, 24, 40, 0.12)",overflow:"hidden"}},MenuListProps:{sx:{p:.5,bgcolor:"#FFFFFF"}}},{children:s.map(function(t){var s="connect"===t.key,r=s&&x;return i.jsxs(n.MenuItem,e.__assign({onClick:function(){var e;"connect"!==(e=t.key)?"side-by-side"!==e?c():a():d()},sx:{px:1.25,py:1,minHeight:40,borderRadius:"10px",display:"flex",alignItems:"center",gap:1,bgcolor:r?"#F0FDF4":"transparent","&:hover":{bgcolor:r?"#DCFCE7":"#F9FAFB"}}},{children:[i.jsx(n.Box,e.__assign({sx:e.__assign({width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{display:"block"}},r&&{"& svg path":{fill:"#15803D",fillOpacity:1}})},{children:t.icon})),i.jsx(n.Box,e.__assign({sx:{minWidth:0,display:"flex",alignItems:"center",flex:1}},{children:i.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",fontWeight:500,color:r?"#15803D":"#101828",lineHeight:1.2,whiteSpace:"nowrap"}},{children:s?x?"Disconnect":"Connect":t.title}))})),r&&i.jsx(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:"auto"}},{children:i.jsx(o,{})}))]}),t.key)})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("@mui/material"),t=require("../../assests/svg/ButtonCognitiveIcon.js"),o=function(){return i.jsx("svg",e.__assign({width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M2 6.5L5 9.5L11 3.5",stroke:"#15803D",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}))},s=[{key:"connect",title:"Connect",icon:i.jsx("svg",e.__assign({width:"15",height:"18",viewBox:"0 0 15 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M14.8237 3.89331C14.547 5.57188 13.0559 6.77501 11.3572 6.69242C9.65857 6.60983 8.2925 5.26384 8.18312 3.56742C4.75678 3.67456 3.54027 4.4759 3.73893 6.10536C3.81259 6.71474 4.18089 7.04063 4.85723 7.19911C5.26794 7.2951 5.7233 7.30849 6.13625 7.27054C6.17419 7.26608 6.21437 7.26385 6.25232 7.25938C6.50455 7.19911 6.76125 7.14777 7.01794 7.1076C7.77911 6.9826 8.55366 6.9201 9.29027 6.96027C11.3617 7.07188 12.7724 7.98483 12.8438 9.92233C12.913 11.7996 11.6229 13.1299 9.5425 14.0205C8.87509 14.3063 8.1675 14.5272 7.45991 14.6946C7.14071 14.7705 6.87286 14.8219 6.67419 14.8554C6.49786 16.5496 5.07821 17.842 3.37509 17.8554C1.67196 17.8688 0.229997 16.6031 0.0246403 14.9112C-0.180717 13.2192 0.917498 11.6455 2.57375 11.2527C4.23 10.8598 5.91973 11.7728 6.49562 13.3755C6.70544 13.3375 6.91303 13.2951 7.12062 13.246C7.75009 13.0987 8.37955 12.9022 8.95991 12.6522C10.538 11.9781 11.3996 11.0875 11.3595 9.9759C11.3237 8.98036 10.6095 8.52054 9.21214 8.44465C8.5983 8.41117 7.92643 8.46474 7.26348 8.57411C7.07821 8.60536 6.90857 8.63661 6.75902 8.6701C6.67196 8.68795 6.61169 8.70358 6.58491 8.71027L6.51571 8.72367C6.4666 8.73036 6.38402 8.74152 6.27687 8.75268C5.71884 8.80402 5.11393 8.78617 4.52464 8.65001C3.2925 8.36206 2.42866 7.59643 2.26794 6.2884C1.9175 3.47143 4.02241 2.16563 8.42866 2.07188C9.07821 0.500452 10.8037 -0.336602 12.4376 0.129916C14.0737 0.596434 15.1005 2.21474 14.8237 3.89331V3.89331ZM3.34161 12.6478C3.09741 12.6478 2.85562 12.6959 2.63002 12.7894C2.40442 12.8828 2.19944 13.0198 2.02678 13.1925C1.85412 13.3652 1.71717 13.5702 1.62373 13.7958C1.5303 14.0214 1.48222 14.2632 1.48223 14.5074C1.48224 14.7516 1.53036 14.9934 1.62382 15.219C1.71728 15.4446 1.85426 15.6495 2.02694 15.8222C2.19962 15.9949 2.40462 16.1318 2.63022 16.2252C2.85583 16.3187 3.09764 16.3668 3.34183 16.3667C3.83499 16.3667 4.30795 16.1708 4.65665 15.822C5.00535 15.4733 5.20123 15.0003 5.2012 14.5071C5.20117 14.014 5.00524 13.541 4.65649 13.1923C4.30775 12.8436 3.83477 12.6477 3.34161 12.6478ZM11.5224 1.49152C11.2782 1.49154 11.0364 1.53965 10.8108 1.63311C10.5852 1.72657 10.3802 1.86355 10.2076 2.03623C10.0349 2.20891 9.89797 2.41391 9.80454 2.63952C9.7111 2.86513 9.66302 3.10693 9.66303 3.35112C9.66305 3.59531 9.71116 3.83711 9.80462 4.06271C9.89808 4.28831 10.0351 4.49329 10.2077 4.66594C10.3804 4.8386 10.5854 4.97556 10.811 5.06899C11.0366 5.16243 11.2784 5.21051 11.5226 5.2105C12.0158 5.21047 12.4888 5.01453 12.8375 4.66579C13.1862 4.31704 13.382 3.84406 13.382 3.3509C13.382 2.85773 13.186 2.38478 12.8373 2.03608C12.4886 1.68738 12.0156 1.49149 11.5224 1.49152V1.49152Z",fill:"#1D2939",fillOpacity:"0.85"})}))},{key:"side-by-side",title:"Side by Side",icon:i.jsx("svg",e.__assign({width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:i.jsx("path",{d:"M3.19922 8.19922H13.1992M3.19922 8.19922L4.86589 10.6992M3.19922 8.19922L4.86589 5.69922M13.1992 8.19922L11.5326 10.6992M13.1992 8.19922L11.5326 5.69922M15.6992 0.699219V15.6992M0.699219 0.699219V15.6992",stroke:"#3F4957",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}))},{key:"cognitive-decisioning",title:"Cognitive Decisioning",icon:i.jsx(t.ButtonCognitiveIcon,{})}];exports.default=function(t){var r=t.open,l=t.anchorEl;t.sectionTitle,t.referenceSectionTitle;var c=t.onClose,a=t.onOpenCognitiveCompare,C=t.onOpenSideBySide,d=t.onConnect,x=t.isConnected,g=void 0!==x&&x,h=t.isOrphan;return i.jsx(n.Menu,e.__assign({open:r,anchorEl:l,onClose:c,disableScrollLock:!0,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},PaperProps:{sx:{ml:.75,minWidth:190,maxWidth:220,borderRadius:"12px",border:"1px solid #E4E7EC",boxShadow:"0px 12px 28px rgba(16, 24, 40, 0.12)",overflow:"hidden"}},MenuListProps:{sx:{p:.5,bgcolor:"#FFFFFF"}}},{children:s.map(function(t){var s="connect"===t.key,r=s&&g,l=h&&("connect"===t.key||"side-by-side"===t.key);console.log("LOG: Printing isDsiabled: ",l);var c=i.jsxs(i.Fragment,{children:[i.jsx(n.Box,e.__assign({sx:e.__assign(e.__assign({width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{display:"block"}},l&&{opacity:.15}),r&&{"& svg path":{fill:"#15803D",fillOpacity:1}})},{children:t.icon})),i.jsxs(n.Box,e.__assign({sx:{minWidth:0,display:"flex",flexDirection:"column",flex:1}},{children:[i.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",fontWeight:500,color:l?"#98A2B3":r?"#15803D":"#101828",lineHeight:1.2,whiteSpace:"nowrap"}},{children:s?g?"Disconnect":"Connect":t.title})),l&&i.jsx(n.Typography,e.__assign({sx:{mt:.35,fontSize:"10px",lineHeight:1.3,color:"#98A2B3",whiteSpace:"normal"}},{children:"No counterpart exists to connect to."}))]})),r&&!l&&i.jsx(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:"auto"}},{children:i.jsx(o,{})}))]});return l?i.jsx(n.Box,e.__assign({"aria-disabled":"true",sx:{px:1.25,py:1,minHeight:22,borderRadius:"10px",display:"flex",alignItems:"flex-start",gap:1,cursor:"not-allowed",userSelect:"none"}},{children:c}),t.key):i.jsx(n.MenuItem,e.__assign({onClick:function(){return e=t.key,void(h&&("connect"===e||"side-by-side"===e)||("connect"!==e?"side-by-side"!==e?a():C():d()));var e},sx:{px:1.25,py:1,minHeight:40,borderRadius:"10px",display:"flex",alignItems:"center",gap:1,bgcolor:r?"#F0FDF4":"transparent","&:hover":{bgcolor:r?"#DCFCE7":"#F9FAFB"}}},{children:c}),t.key)})}))};
2
2
  //# sourceMappingURL=MoreFunctionsPopup.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("@react-pdf-viewer/core"),o=require("./PdfContainer.js"),r=require("./PdfToolbar.js"),n=require("./PdfStyle.js"),a=require("./usePdfHighlight.js");require("@react-pdf-viewer/zoom/lib/styles/index.css"),require("@react-pdf-viewer/page-navigation/lib/styles/index.css"),require("@react-pdf-viewer/core/lib/styles/index.css"),require("@react-pdf-viewer/search/lib/styles/index.css");var l=require("react"),s=require("../ScannedDocCitation/ScannedDocCitation.js"),c=function(e){switch(e){case"ActualSize":return t.SpecialZoomLevel.ActualSize;case"PageFit":return t.SpecialZoomLevel.PageFit;case"PageWidth":return t.SpecialZoomLevel.PageWidth;default:return null!=e?e:t.SpecialZoomLevel.PageWidth}};exports.default=function(u){var d,g=u.pdfUrl,h=u.highlightText,f=u.highlightPages,v=u.highlightCordinatePages,p=u.highlightColor,m=void 0===p?"yellow":p,x=u.activeHighlightColor,C=void 0===x?"#f7dc51":x,S=u.jumpToPageValue,P=void 0===S?0:S,y=u.pdfName,T=u.onClose,_=u.customStyles,q=u.customClasses,w=u.customIcons,A=u.useCoordinates,b=u.fallbackPages,j=u.activeCitationIndex,H=u.onActiveCitationChange,I=u.headerAction,Z=u.isZoomEnabled,L=void 0===Z||Z,z=u.showHighlightsAction,F=void 0===z||z,N=u.defaultScale,E=void 0===N?t.SpecialZoomLevel.ActualSize:N,R=l.useRef(null),V=l.useMemo(function(){if(A)return new Set(v.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(f).forEach(function(i){i>0&&e.add(i-1)}),e},[f]),W=(d=h)&&0!==d.length?d.filter(function(e){return!d.some(function(i){return i!==e&&i.includes(e)})}):d,D=a.PdfHighlightControls(W,A?{}:f,R,V,A,A?v:[],m,C),B=D.highlightIndex,O=D.cursorIndex,U=D.setCursorIndex,k=D.orderedKeys,M=D.totalHighlights,J=D.getValidPosition,K=D.tryJump,G=D.jumpToPage,Q=D.zoomTo,X=D.plugins,Y=D.controls,$=D.hideNonTargetHighlights,ee=D.deduplicateHighlights,ie=J(O);l.useEffect(function(){void 0!==j&&j!==O&&U(j)},[j]);var te=e.__assign(e.__assign({},Y),{goToNext:function(){Y.goToNext(),H&&H(O+1)},goToPrevious:function(){Y.goToPrevious(),H&&H(O-1)}});if(!g)return i.jsx(s.default,{pages:b,activeCitationIndex:j,onActiveCitationChange:H,headerAction:I});return i.jsxs("div",e.__assign({ref:R,className:(null==q?void 0:q.pdfViewerWrapper)||"",style:e.__assign(e.__assign(e.__assign({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},n.pdfStyles.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==_?void 0:_.pdfViewer)},{children:[i.jsx(r.default,{highlightIndex:B,totalHighlights:M,controls:te,currentPosition:ie,pdfName:y,onClose:T,pdfUrl:g,viewerRef:R,customStyles:_,customClasses:q,customIcons:w,headerAction:I,isZoomEnabled:L,showHighlightsAction:F}),i.jsx(o.default,{defaultScale:c(E),pdfUrl:g,plugins:X,customStyles:_,onLoad:function(){if(Q(t.SpecialZoomLevel.ActualSize),P>0){var e=P-1,i=k[e],o=f[i],r=v[e];U(e),console.log(r,"cordinateTargetHighlight"),A&&r.pageIndex>0&&G(r.pageIndex),o>0&&(setTimeout(function(){$(V),ee(o-1)},1e3),A||G(o-1))}else if(!A&&f){var n=k.find(function(e){return f[e]>0});if(void 0!==n){var a=f[n]-1;G(a),setTimeout(function(){$(V),ee(a)},1e3)}}requestAnimationFrame(function(){K(),A||function(){if(R.current){var e=P-1,i=k[e],t=f[i],o=t>0?t-1:0,r={};k.forEach(function(e,i){var t=f[e];t>0&&(r[t]||(r[t]=[]),r[t].push(i))});var n=(r[t]||[]).indexOf(e),a=0,l=function(){var e,i;if(!(++a>40)){var t=null===(e=R.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(t){var r=null===(i=R.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(o,'"]'));if(r){var s=t.getBoundingClientRect(),c=r.getBoundingClientRect();if(c.top<s.bottom&&c.bottom>s.top){var u=r.querySelectorAll(".rpv-search__highlight")[n];if(u){var d=u.getBoundingClientRect(),g=t.scrollTop+(d.top-s.top)-t.clientHeight/2+d.height/2;t.scrollTo({top:g,behavior:"smooth"})}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}};setTimeout(l,500)}}()})},onPageChange:function(e){var i=e.currentPage;V.has(i)?(ee(i),$(V)):$(V)}})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("@react-pdf-viewer/core"),o=require("./PdfContainer.js"),r=require("./PdfToolbar.js"),n=require("./PdfStyle.js"),a=require("./usePdfHighlight.js");require("@react-pdf-viewer/zoom/lib/styles/index.css"),require("@react-pdf-viewer/page-navigation/lib/styles/index.css"),require("@react-pdf-viewer/core/lib/styles/index.css"),require("@react-pdf-viewer/search/lib/styles/index.css");var s=require("react"),l=require("../ScannedDocCitation/ScannedDocCitation.js"),u=function(e){switch(e){case"ActualSize":return t.SpecialZoomLevel.ActualSize;case"PageFit":return t.SpecialZoomLevel.PageFit;case"PageWidth":return t.SpecialZoomLevel.PageWidth;default:return null!=e?e:t.SpecialZoomLevel.PageWidth}};exports.default=function(c){var d,g=c.pdfUrl,f=c.highlightText,h=c.highlightPages,v=c.highlightCordinatePages,p=c.highlightColor,m=void 0===p?"yellow":p,x=c.activeHighlightColor,C=void 0===x?"#f7dc51":x,P=c.jumpToPageValue,S=void 0===P?0:P,_=c.pdfName,T=c.onClose,w=c.customStyles,y=c.customClasses,b=c.customIcons,q=c.useCoordinates,A=c.fallbackPages,j=c.activeCitationIndex,H=c.onActiveCitationChange,I=c.headerAction,Z=c.isZoomEnabled,L=void 0===Z||Z,z=c.showHighlightsAction,F=void 0===z||z,N=c.defaultScale,R=void 0===N?t.SpecialZoomLevel.ActualSize:N,E=c.useRange,V=void 0!==E&&E,W=c.rangeOfPages,D=void 0===W?null:W,O=s.useRef(null),B=s.useMemo(function(){if(q)return new Set(v.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(h).forEach(function(i){i>0&&e.add(i-1)}),e},[h]),U=(d=f)&&0!==d.length?d.filter(function(e){return!d.some(function(i){return i!==e&&i.includes(e)})}):d,k=a.PdfHighlightControls(U,q?{}:h,O,B,q,q?v:[],m,C),M=k.highlightIndex,J=k.cursorIndex,K=k.setCursorIndex,G=k.orderedKeys,Q=k.totalHighlights,X=k.getValidPosition,Y=k.tryJump,$=k.jumpToPage,ee=k.zoomTo,ie=k.plugins,te=k.controls,oe=k.hideNonTargetHighlights,re=k.deduplicateHighlights,ne=X(J);s.useEffect(function(){void 0!==j&&j!==J&&K(j)},[j]);var ae=e.__assign(e.__assign({},te),{goToNext:function(){te.goToNext(),H&&H(J+1)},goToPrevious:function(){te.goToPrevious(),H&&H(J-1)}});if(!g)return i.jsx(l.default,{pages:A,activeCitationIndex:j,onActiveCitationChange:H,headerAction:I});return i.jsxs("div",e.__assign({ref:O,className:(null==y?void 0:y.pdfViewerWrapper)||"",style:e.__assign(e.__assign(e.__assign({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},n.pdfStyles.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==w?void 0:w.pdfViewer)},{children:[i.jsx(r.default,{highlightIndex:M,totalHighlights:Q,controls:ae,currentPosition:ne,pdfName:_,onClose:T,pdfUrl:g,viewerRef:O,customStyles:w,customClasses:y,customIcons:b,headerAction:I,isZoomEnabled:L,showHighlightsAction:F}),i.jsx(o.default,{defaultScale:u(R),pdfUrl:g,plugins:ie,customStyles:w,onLoad:function(){if(ee(t.SpecialZoomLevel.ActualSize),S>0&&!V){var i=S-1,o=G[i],r=h[o],n=v[i];K(i),console.log(n,"cordinateTargetHighlight"),q&&n.pageIndex>0&&$(n.pageIndex),r>0&&(setTimeout(function(){oe(B),re(r-1)},1e3),q||$(r-1))}else if(V&&D&&2===D.length){e.__awaiter(void 0,void 0,void 0,function(){var i,t,o,r,n;return e.__generator(this,function(e){switch(e.label){case 0:i=D[0],t=D[1],o=i,e.label=1;case 1:return o<=t?($(r=o-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(e.sent(),oe(B),(n=re(r))&&n>0)return[3,4];e.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}else if(!q&&h){var a=G.find(function(e){return h[e]>0});if(void 0!==a){var s=h[a]-1;$(s),setTimeout(function(){oe(B),re(s)},1e3)}}requestAnimationFrame(function(){Y(),q||function(){if(O.current){var e=S-1,i=G[e],t=h[i],o=t>0?t-1:0,r={};G.forEach(function(e,i){var t=h[e];t>0&&(r[t]||(r[t]=[]),r[t].push(i))});var n=(r[t]||[]).indexOf(e),a=0,s=function(){var e,i;if(!(++a>40)){var t=null===(e=O.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(t){var r=null===(i=O.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(o,'"]'));if(r){var l=t.getBoundingClientRect(),u=r.getBoundingClientRect();if(u.top<l.bottom&&u.bottom>l.top){var c=r.querySelectorAll(".rpv-search__highlight")[n];if(c){var d=c.getBoundingClientRect(),g=t.scrollTop+(d.top-l.top)-t.clientHeight/2+d.height/2;t.scrollTo({top:g,behavior:"smooth"})}else setTimeout(s,100)}else setTimeout(s,100)}else setTimeout(s,100)}else setTimeout(s,100)}};setTimeout(s,500)}}()})},onPageChange:function(e){var i=e.currentPage;B.has(i)?(re(i),oe(B)):oe(B)}})]}))};
2
2
  //# sourceMappingURL=PdfViewer.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),r=require("react"),n=require("@react-pdf-viewer/search"),o=require("@react-pdf-viewer/page-navigation"),i=require("@react-pdf-viewer/zoom"),a=require("@react-pdf-viewer/highlight");exports.PdfHighlightControls=function(l,u,c,s,p,g,f,h){void 0===f&&(f="yellow"),void 0===h&&(h="#F6D739");var v=r.useState(0),d=v[0],m=v[1],y=r.useRef(!1),T=r.useState(0),x=T[0],_=T[1];r.useRef([]);var b=function(e){if(!e)return[];return e.replace(/\]\s*\n\s*\(/g,"](").split(/\n+/).map(function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t}).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return e.replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/[^\S\n]+/g," ").trim()}).flatMap(function(e){return e.split(/\n+/)}).flatMap(function(e){for(var t,r=[],n=/([*_]{1,3})([^*_]+)\1|([*_]{1,3})/g,o=0;null!==(t=n.exec(e));){var i=e.slice(o,t.index).trim();i&&r.push(i),t[2]&&r.push(t[2].trim()),o=t.index+t[0].length}var a=e.slice(o).trim();return a&&r.push(a),r.flatMap(function(e){return e.split(/[\u2013\u2014-]/g)}).flatMap(function(e){return e.split(/\n+/)}).map(function(e){return e.replace(/[*_]+/g,"").replace(/`([^`]+)`/g,"$1").replace(/[^\S\n]+/g," ").trim()})})},I=Object.keys(u).map(Number).sort(function(e,t){return e-t}),q=r.useMemo(function(){return p?g.length:p?0:Object.values(u).filter(function(e){return e>0}).length},[g,u]),S=function(e){if(c.current){var t=c.current.querySelector('[data-testid="search__highlights-'.concat(e,'"]'));if(t){var r=Array.from(t.querySelectorAll(".rpv-search__highlight")),n=function(e){return(e||"").toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},o=M.map(n).filter(Boolean);if(0!==o.length){var i=[],a=null;r.forEach(function(e){var t=n(e.getAttribute("title")||e.textContent||""),r=parseFloat(e.style.top||"0");a?a.title===t&&Math.abs(a.lastTop-r)<=3?(a.elements.push(e),a.lastTop=r):(i.push(a),a={title:t,elements:[e],lastTop:r}):a={title:t,elements:[e],lastTop:r}}),a&&i.push(a);for(var u=0,s=new Set,p=0;p<i.length;p++)for(var g=i[p].title,f=0;f<o.length;f++)if(o[f]===g){for(var h=0,v=new Set,d=f,m=p-1,y=p;y<i.length&&d<o.length;y++){if(i[y].title===o[d]){if(m>=0){var T=i[m].lastTop,x=parseFloat(i[y].elements[0].style.top||"0");if(Math.abs(x-T)>15)break}h++,v.add(y),m=y,d++}else if(d>0&&i[y].title===o[d-1]){T=i[m].lastTop,x=parseFloat(i[y].elements[0].style.top||"0");Math.abs(x-T)<=3&&(v.add(y),m=y)}if(y-m>4)break}h>u&&(u=h,s=v)}i.forEach(function(e,t){var r=s.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(e,"]")),console.log("input->",l),console.log("processed text->",M),console.log("Expected sequence length:",o.length),console.log("Matched ordered sequence length:",u),console.groupEnd()}}}},w=function(e){c.current&&c.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(function(e){e.style.display="none"})})},M=l.map(function(e){return b(e)}).flat(),P=n.searchPlugin({keyword:M}),j=o.pageNavigationPlugin(),B=i.zoomPlugin(),C=P.jumpToMatch,A=j.jumpToPage,F=B.zoomTo,E=B.ZoomInButton,k=B.ZoomOutButton,H=B.ZoomPopover,O=a.highlightPlugin({renderHighlights:function(r){return t.jsx(t.Fragment,{children:g.map(function(t,r){return e.__assign(e.__assign({},t),{originalIndex:r})}).filter(function(e){return e.pageNumber?e.pageNumber-1===r.pageIndex:e.pageIndex===r.pageIndex}).map(function(e){var r=e.originalIndex,n=r===x;return t.jsx("div",{style:{position:"absolute",left:"".concat(e.left,"%"),top:"".concat(e.top,"%"),width:"".concat(e.width,"%"),height:"".concat(e.height,"%"),background:n?h:f,opacity:n?.7:.4,transition:"background 0.2s, opacity 0.2s"}},r)})})}}),R=function(){if(!y.current)try{C(0),y.current=!0;var e=g[0];e&&p&&z(e.pageIndex,e.top)}catch(e){requestAnimationFrame(R)}},Z=function(e,t){if(c.current&&c.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var o,i,a=null===(o=c.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(i=c.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.querySelectorAll(".rpv-search__highlight")[t];if(u){var s=a.getBoundingClientRect(),p=u.getBoundingClientRect(),g=a.scrollTop+(p.top-s.top)-a.clientHeight/2+p.height/2;a.scrollTo({top:g,behavior:"smooth"})}}}};setTimeout(n,300)}},z=function(e,t){if(c.current){var r=0,n=function(){var o,i;if(!(++r>60)){var a=null===(o=c.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){var l=null===(i=c.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.getBoundingClientRect();if(0!==u.height){var s=a.getBoundingClientRect(),p=t/100*u.height,g=u.top-s.top+p;a.scrollTo({top:a.scrollTop+g-40,behavior:"smooth"})}else setTimeout(n,100)}else setTimeout(n,100)}else setTimeout(n,100)}};setTimeout(n,100)}},N=r.useMemo(function(){var e={};return I.forEach(function(t,r){var n=u[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[I,u]),L=function(e){var t=u[I[e]];return(N[t]||[]).indexOf(e)},D=function(e,t){if(c.current){var r=-1,n=0,o=function(){var i,a;if(!(++n>60)){var l=null===(i=c.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(l){if(l.scrollTop!==r)return r=l.scrollTop,void setTimeout(o,100);var u=null===(a=c.current)||void 0===a?void 0:a.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(u){var s=u.getBoundingClientRect();if(0!==s.height){var p=l.getBoundingClientRect(),g=t/100*s.height,f=s.top-p.top+g;l.scrollTo({top:l.scrollTop+f-40,behavior:"instant"})}else setTimeout(o,100)}else setTimeout(o,100)}else setTimeout(o,100)}};setTimeout(o,100)}};return{setHighlightIndex:m,highlightIndex:d,cursorIndex:x,setCursorIndex:_,orderedKeys:I,totalHighlights:q,getValidPosition:function(e){if(p)return e+1;if(!u)return 0;for(var t=0,r=0;r<=e;r++)u[I[r]]>0&&t++;return t},tryJump:R,jumpToPage:A,zoomTo:F,hideNonTargetHighlights:w,deduplicateHighlights:S,scrollToCoord:z,plugins:[p?O:P,j,B],controls:{ZoomInButton:E,ZoomOutButton:k,ZoomPopover:H,goToNext:function(){if(p&&g)for(var e=x+1;e<g.length;e++){var t=g[e],r=g[x];return _(e),A(t.pageIndex),void(t.pageIndex!==r.pageIndex?(A(t.pageIndex),D(t.pageIndex,t.top)):z(t.pageIndex,t.top))}else{var n=function(e){var t=I[e];if(u[t]>0){var r=u[t]-1,n=L(e);return _(e),A(u[t]-1),Z(r,n),setTimeout(function(){S(r)},500),1===Object.keys(u).length&&w(s),{value:void 0}}};for(e=x+1;e<I.length;e++){var o=n(e);if("object"==typeof o)return o.value}}},goToPrevious:function(){if(p&&g)for(var e=x-1;e>=0;e--){var t=g[e],r=g[x];return _(e),A(t.pageIndex),void(t.pageIndex!==r.pageIndex?(A(t.pageIndex),D(t.pageIndex,t.top)):z(t.pageIndex,t.top))}else{var n=function(e){var t=I[e];if(u[t]>0){var r=u[t]-1,n=L(e);return _(e),A(u[t]-1),Z(r,n),setTimeout(function(){S(r)},500),1===Object.keys(u).length&&w(s),{value:void 0}}};for(e=x-1;e>=0;e--){var o=n(e);if("object"==typeof o)return o.value}}}}}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),r=require("react"),n=require("@react-pdf-viewer/search"),o=require("@react-pdf-viewer/page-navigation"),i=require("@react-pdf-viewer/zoom"),a=require("@react-pdf-viewer/highlight");exports.PdfHighlightControls=function(l,u,c,s,p,g,f,h){void 0===f&&(f="yellow"),void 0===h&&(h="#F6D739");var v=r.useState(0),d=v[0],m=v[1],T=r.useRef(!1),y=r.useState(0),x=y[0],_=y[1];r.useRef([]);var b=function(e){if(!e)return[];return e.replace(/\]\s*\n\s*\(/g,"](").split(/\n+/).map(function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t}).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return e.replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/[^\S\n]+/g," ").trim()}).flatMap(function(e){return e.split(/\n+/)}).flatMap(function(e){for(var t,r=[],n=/([*_]{1,3})([^*_]+)\1|([*_]{1,3})/g,o=0;null!==(t=n.exec(e));){var i=e.slice(o,t.index).trim();i&&r.push(i),t[2]&&r.push(t[2].trim()),o=t.index+t[0].length}var a=e.slice(o).trim();return a&&r.push(a),r.flatMap(function(e){return e.split(/[\u2013\u2014-]/g)}).flatMap(function(e){return e.split(/\n+/)}).map(function(e){return e.replace(/[*_]+/g,"").replace(/`([^`]+)`/g,"$1").replace(/[^\S\n]+/g," ").trim()})})},I=Object.keys(u).map(Number).sort(function(e,t){return e-t}),q=r.useMemo(function(){return p?g.length:p?0:Object.values(u).filter(function(e){return e>0}).length},[g,u]),S=function(e){if(c.current){var t=c.current.querySelector('[data-testid="search__highlights-'.concat(e,'"]'));if(t){var r=Array.from(t.querySelectorAll(".rpv-search__highlight")),n=function(e){return(e||"").toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},o=M.map(n).filter(Boolean);if(0!==o.length){var i=[],a=null;r.forEach(function(e){var t=n(e.getAttribute("title")||e.textContent||""),r=parseFloat(e.style.top||"0");a?a.title===t&&Math.abs(a.lastTop-r)<=3?(a.elements.push(e),a.lastTop=r):(i.push(a),a={title:t,elements:[e],lastTop:r}):a={title:t,elements:[e],lastTop:r}}),a&&i.push(a);for(var u=0,s=new Set,p=0;p<i.length;p++)for(var g=i[p].title,f=0;f<o.length;f++)if(o[f]===g){for(var h=0,v=new Set,d=f,m=p-1,T=p;T<i.length&&d<o.length;T++){if(i[T].title===o[d]){if(m>=0){var y=i[m].lastTop,x=parseFloat(i[T].elements[0].style.top||"0");if(Math.abs(x-y)>15)break}h++,v.add(T),m=T,d++}else if(d>0&&i[T].title===o[d-1]){y=i[m].lastTop,x=parseFloat(i[T].elements[0].style.top||"0");Math.abs(x-y)<=3&&(v.add(T),m=T)}if(T-m>4)break}h>u&&(u=h,s=v)}return i.forEach(function(e,t){var r=s.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(e,"]")),console.log("input->",l),console.log("processed text->",M),console.log("Expected sequence length:",o.length),console.log("Matched ordered sequence length:",u),console.log("blocksToKeep",s,"size",s.size),console.groupEnd(),s.size}}}},w=function(e){c.current&&c.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(function(e){e.style.display="none"})})},M=l.map(function(e){return b(e)}).flat(),P=n.searchPlugin({keyword:M}),j=o.pageNavigationPlugin(),B=i.zoomPlugin(),C=P.jumpToMatch,A=j.jumpToPage,F=B.zoomTo,E=B.ZoomInButton,k=B.ZoomOutButton,z=B.ZoomPopover,H=a.highlightPlugin({renderHighlights:function(r){return t.jsx(t.Fragment,{children:g.map(function(t,r){return e.__assign(e.__assign({},t),{originalIndex:r})}).filter(function(e){return e.pageNumber?e.pageNumber-1===r.pageIndex:e.pageIndex===r.pageIndex}).map(function(e){var r=e.originalIndex,n=r===x;return t.jsx("div",{style:{position:"absolute",left:"".concat(e.left,"%"),top:"".concat(e.top,"%"),width:"".concat(e.width,"%"),height:"".concat(e.height,"%"),background:n?h:f,opacity:n?.7:.4,transition:"background 0.2s, opacity 0.2s"}},r)})})}}),O=function(){if(!T.current)try{C(0),T.current=!0;var e=g[0];e&&p&&Z(e.pageIndex,e.top)}catch(e){requestAnimationFrame(O)}},R=function(e,t){if(c.current&&c.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var o,i,a=null===(o=c.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(i=c.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.querySelectorAll(".rpv-search__highlight")[t];if(u){var s=a.getBoundingClientRect(),p=u.getBoundingClientRect(),g=a.scrollTop+(p.top-s.top)-a.clientHeight/2+p.height/2;a.scrollTo({top:g,behavior:"smooth"})}}}};setTimeout(n,300)}},Z=function(e,t){if(c.current){var r=0,n=function(){var o,i;if(!(++r>60)){var a=null===(o=c.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){var l=null===(i=c.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.getBoundingClientRect();if(0!==u.height){var s=a.getBoundingClientRect(),p=t/100*u.height,g=u.top-s.top+p;a.scrollTo({top:a.scrollTop+g-40,behavior:"smooth"})}else setTimeout(n,100)}else setTimeout(n,100)}else setTimeout(n,100)}};setTimeout(n,100)}},N=r.useMemo(function(){var e={};return I.forEach(function(t,r){var n=u[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[I,u]),L=function(e){var t=u[I[e]];return(N[t]||[]).indexOf(e)},D=function(e,t){if(c.current){var r=-1,n=0,o=function(){var i,a;if(!(++n>60)){var l=null===(i=c.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(l){if(l.scrollTop!==r)return r=l.scrollTop,void setTimeout(o,100);var u=null===(a=c.current)||void 0===a?void 0:a.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(u){var s=u.getBoundingClientRect();if(0!==s.height){var p=l.getBoundingClientRect(),g=t/100*s.height,f=s.top-p.top+g;l.scrollTo({top:l.scrollTop+f-40,behavior:"instant"})}else setTimeout(o,100)}else setTimeout(o,100)}else setTimeout(o,100)}};setTimeout(o,100)}};return{setHighlightIndex:m,highlightIndex:d,cursorIndex:x,setCursorIndex:_,orderedKeys:I,totalHighlights:q,getValidPosition:function(e){if(p)return e+1;if(!u)return 0;for(var t=0,r=0;r<=e;r++)u[I[r]]>0&&t++;return t},tryJump:O,jumpToPage:A,zoomTo:F,hideNonTargetHighlights:w,deduplicateHighlights:S,scrollToCoord:Z,plugins:[p?H:P,j,B],controls:{ZoomInButton:E,ZoomOutButton:k,ZoomPopover:z,goToNext:function(){if(p&&g)for(var e=x+1;e<g.length;e++){var t=g[e],r=g[x];return _(e),A(t.pageIndex),void(t.pageIndex!==r.pageIndex?(A(t.pageIndex),D(t.pageIndex,t.top)):Z(t.pageIndex,t.top))}else{var n=function(e){var t=I[e];if(u[t]>0){var r=u[t]-1,n=L(e);return _(e),A(u[t]-1),R(r,n),setTimeout(function(){S(r)},500),1===Object.keys(u).length&&w(s),{value:void 0}}};for(e=x+1;e<I.length;e++){var o=n(e);if("object"==typeof o)return o.value}}},goToPrevious:function(){if(p&&g)for(var e=x-1;e>=0;e--){var t=g[e],r=g[x];return _(e),A(t.pageIndex),void(t.pageIndex!==r.pageIndex?(A(t.pageIndex),D(t.pageIndex,t.top)):Z(t.pageIndex,t.top))}else{var n=function(e){var t=I[e];if(u[t]>0){var r=u[t]-1,n=L(e);return _(e),A(u[t]-1),R(r,n),setTimeout(function(){S(r)},500),1===Object.keys(u).length&&w(s),{value:void 0}}};for(e=x-1;e>=0;e--){var o=n(e);if("object"==typeof o)return o.value}}}}}};
2
2
  //# sourceMappingURL=usePdfHighlight.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as i}from"tslib";import{jsxs as n,jsx as l,Fragment as t}from"react/jsx-runtime";import{ChevronUp as o,ChevronDown as e}from"lucide-react";import{useState as r}from"react";import a from"./ResizableSplitPane.js";import d from"../PdfViewer/PdfViewer.js";var u=function(u){var c,s,g,h=u.href,v=u.children,p=u.metaData,f=u.chevronUpComponent,m=void 0===f?null:f,y=u.chevronDownComponent,P=void 0===y?null:y,b=u.customStyle,C=void 0===b?{}:b,_=u.defaultState,w=r(void 0!==_&&_),x=w[0],D=w[1],S="string"==typeof v&&(null===(c=null==v?void 0:v.split("\n"))||void 0===c?void 0:c.length)>1?v.split("\n").join(" "):v,j="string"==typeof v?v:v[0],z=null!=m?m:function(i){var n,t;return l(o,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(s=null==C?void 0:C.arrow)&&void 0!==s?s:{}),T=null!=P?P:function(i){var n,t;return l(e,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(g=null==C?void 0:C.arrow)&&void 0!==g?g:{}),W=["contract","clause"];return n("span",i({style:i({display:"inline"},C.relativeWrapper||{})},{children:[l("div",i({style:i({display:"inline",marginTop:0},C.citationButtonWrapper||{})},{children:n("button",i({type:"button",onClick:function(){return D(function(i){return!i})},style:i({display:"inline-flex",alignItems:"center",gap:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:700,color:"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},C.citationButton||{})},{children:[l("span",{children:S}),l("span",i({style:{display:"flex",alignItems:"center"}},{children:x?z:T}))]}))})),x&&l(t,{children:l(function(){var i,n,t,o,e,r,u;console.log("citation details ->","href ->",h,"children ->",v,"metaData ->",p,"citationDisplayTitle ->",S);var c=function(i){try{return new URL(i,window.location.origin).searchParams.get("citationNumber")}catch(i){return null}}(h);if(!c)return null;var s=(null===(i=null==p?void 0:p.citations)||void 0===i?void 0:i[c])||{},g=(null===(n=null==p?void 0:p.docData)||void 0===n?void 0:n.documents)||{},f=(null===(t=null==p?void 0:p.docData)||void 0===t?void 0:t.input_index_map)||{},m=null==f?void 0:f[0],y=null==f?void 0:f[1],P=m?g[m]:null,b=y?g[y]:null,C=m?s[m]:null,_=y?s[y]:null;if(W.includes(j)){console.log("leftDocument",P,"rightDocument",b),console.log("leftCitation",C,"rightCitation",_);var w=C?l(d,{defaultScale:"PageWidth",showHighlightsAction:!1,pdfName:P.title,pdfUrl:P.signed_url,highlightText:[null!==(o=null==C?void 0:C.highlighted_text)&&void 0!==o?o:""],highlightPages:{1:null===(e=null==C?void 0:C.custom_metadata)||void 0===e?void 0:e.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1}):null,x=_?l(d,{defaultScale:"PageWidth",showHighlightsAction:!1,pdfName:b.title,pdfUrl:b.signed_url,jumpToPageValue:1,highlightText:[null!==(r=null==_?void 0:_.highlighted_text)&&void 0!==r?r:""],highlightPages:{1:null===(u=null==_?void 0:_.custom_metadata)||void 0===u?void 0:u.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1}):null;return l("div",C||_?{children:l(a,{leftComponent:w,rightComponent:x})}:{children:"Missing PDF Citation. Please try again later"})}return l("div",{children:"No Citation Found. Please try again later"})},{})})]}))};export{u as default};
1
+ import{__assign as i}from"tslib";import{jsxs as n,jsx as l,Fragment as t}from"react/jsx-runtime";import{ChevronUp as e,ChevronDown as o}from"lucide-react";import{useState as a}from"react";import r from"./ResizableSplitPane.js";import d from"../PdfViewer/PdfViewer.js";var u=function(u){var s,c,g,v=u.href,p=u.children,h=u.metaData,m=u.chevronUpComponent,f=void 0===m?null:m,_=u.chevronDownComponent,b=void 0===_?null:_,y=u.customStyle,P=void 0===y?{}:y,C=u.defaultState,w=a(void 0!==C&&C),x=w[0],D=w[1],S="string"==typeof p&&(null===(s=null==p?void 0:p.split("\n"))||void 0===s?void 0:s.length)>1?p.split("\n").join(" "):p,j="string"==typeof p?p:p[0],z=null!=f?f:function(i){var n,t;return l(e,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(c=null==P?void 0:P.arrow)&&void 0!==c?c:{}),T=null!=b?b:function(i){var n,t;return l(o,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(g=null==P?void 0:P.arrow)&&void 0!==g?g:{}),R=["contract","clause"];return n("span",i({style:i({display:"inline"},P.relativeWrapper||{})},{children:[l("div",i({style:i({display:"inline",marginTop:0},P.citationButtonWrapper||{})},{children:n("button",i({type:"button",onClick:function(){return D(function(i){return!i})},style:i({display:"inline-flex",alignItems:"center",gap:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:700,color:"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},P.citationButton||{})},{children:[l("span",{children:S}),l("span",i({style:{display:"flex",alignItems:"center"}},{children:x?z:T}))]}))})),x&&l(t,{children:l(function(){var i,n,t,e,o,a,u,s,c,g,m;console.log("citation details ->","href ->",v,"children ->",p,"metaData ->",h,"citationDisplayTitle ->",S);var f=function(i){try{return new URL(i,window.location.origin).searchParams.get("citationNumber")}catch(i){return null}}(v);if(!f)return null;var _=(null===(i=null==h?void 0:h.citations)||void 0===i?void 0:i[f])||{},b=(null===(n=null==h?void 0:h.docData)||void 0===n?void 0:n.documents)||{},y=(null===(t=null==h?void 0:h.docData)||void 0===t?void 0:t.input_index_map)||{},P=null==y?void 0:y[0],C=null==y?void 0:y[1],w=P?b[P]:null,x=C?b[C]:null,D=P?_[P]:null,z=C?_[C]:null;if(R.includes(j)){console.log("leftDocument",w,"rightDocument",x),console.log("leftCitation",D,"rightCitation",z);var T=D?l(d,{defaultScale:"PageWidth",showHighlightsAction:!1,pdfName:w.title,pdfUrl:w.signed_url,highlightText:[null!==(e=null==D?void 0:D.highlighted_text)&&void 0!==e?e:""],highlightPages:{1:null===(o=null==D?void 0:D.custom_metadata)||void 0===o?void 0:o.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(a=null==D?void 0:D.custom_metadata)||void 0===a?void 0:a.pdf_start_page_number,null===(u=null==D?void 0:D.custom_metadata)||void 0===u?void 0:u.pdf_end_page_number]}):null,W=z?l(d,{defaultScale:"PageWidth",showHighlightsAction:!1,pdfName:x.title,pdfUrl:x.signed_url,jumpToPageValue:1,highlightText:[null!==(s=null==z?void 0:z.highlighted_text)&&void 0!==s?s:""],highlightPages:{1:null===(c=null==z?void 0:z.custom_metadata)||void 0===c?void 0:c.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(g=null==z?void 0:z.custom_metadata)||void 0===g?void 0:g.pdf_start_page_number,null===(m=null==z?void 0:z.custom_metadata)||void 0===m?void 0:m.pdf_end_page_number]}):null;return l("div",D||z?{children:l(r,{leftComponent:T,rightComponent:W})}:{children:"Missing PDF Citation. Please try again later"})}return l("div",{children:"No Citation Found. Please try again later"})},{})})]}))};export{u as default};
2
2
  //# sourceMappingURL=CitationAnchor.js.map