@viswa-test/test-citation 0.0.116 → 0.0.118

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/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  5. package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
  6. package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
  7. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  8. package/dist/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
  9. package/dist/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
  10. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  11. package/dist/features/PdfViewer/PdfViewer.js +1 -1
  12. package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
  13. package/dist/types/src/CognitiveCompareTest.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/CognitiveCompareConstants.d.ts.map +1 -1
  16. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +3 -0
  17. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  18. package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts +1 -1
  19. package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts.map +1 -1
  20. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  21. package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +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 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"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),m=require("./hooks/useDeviationNavigation.js"),_=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),b=require("./components/CognitiveSummaryPopup.js"),S=require("./components/connectedLines.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var E,I,T,B,C,D,O,w,N,P,j,F,M,k,L,V,H,G,q,z,K,W,Y,U,X,$,J=A.componentHeaderText,Q=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Z=A.treeData,ee=A.comparisonConfig,ne=A.leftColumnTitleText,te=A.rightColumnTitleText,ie=A.markdownStyles,oe=A.resetTrigger,re=A.displayConfig,le=void 0===re?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:re,ue=A.popupConfig,ce=A.deviationData,ae=void 0===ce?{}:ce,se=A.deviationNodeIdToView,de=A.resetDeviationNodeId,ve=A.isProposingFix,fe=void 0!==ve&&ve,ge=A.proposingFixNodeId,pe=t.useState(le.maintainRelativeOrder),he=pe[0],xe=pe[1],me=!!he||!!(null==le?void 0:le.showDeviationBadges),_e=t.useState(!1),Re=_e[0],ye=_e[1],be=t.useState(!1),Se=be[0],Ae=be[1],Ee=t.useState(null),Ie=Ee[0],Te=Ee[1],Be=t.useState(!1),Ce=Be[0],De=Be[1],Oe=t.useState(null===(I=null!==(E=null==Z?void 0:Z.newEvaluationResult)&&void 0!==E?E:null==le?void 0:le.enableDeviationSchemaBackwardCompatibility)||void 0===I||I)[0],we=t.useState(!1),Ne=we[0],Pe=we[1],je=t.useState(!1),Fe=je[0],Me=je[1],ke=t.useState(null),Le=ke[0],Ve=ke[1],He=t.useRef(!1),Ge=t.useState(new Set),qe=Ge[0],ze=Ge[1],Ke=t.useState([]),We=Ke[0],Ye=Ke[1],Ue=t.useRef(null),Xe=t.useRef(null),$e=t.useRef(null),Je=t.useRef(new Set),Qe=t.useRef(!1),Ze=t.useRef(null),en=t.useRef({}),nn=t.useRef([]),tn=t.useRef(!1),on=t.useRef(!1),rn=t.useRef(null),ln=t.useRef(function(){}),un=t.useMemo(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),cn=t.useState({width:0,height:0}),an=cn[0],sn=cn[1],dn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),ie)},[ie]),vn=t.useRef(null),fn=t.useRef(null),gn=t.useRef(null),pn=t.useRef(null),hn=t.useRef(null),xn=t.useRef(null),mn=t.useRef(null),_n=t.useRef(null),Rn=t.useRef(!1),yn=t.useRef(null),bn=t.useRef(null),Sn=p.useComparePopups(vn),An=Sn.cognitivePopup,En=Sn.setCognitivePopup,In=Sn.moreFunctions,Tn=Sn.setMoreFunctions,Bn=Sn.position,Cn=Sn.setPosition,Dn=Sn.activeBadgeId,On=Sn.summaryPopup,wn=Sn.setSummaryPopup,Nn=Sn.closeSummaryPopup,Pn=Sn.setActiveBadgeId,jn=Sn.popupRef,Fn=Sn.closeCognitivePopup,Mn=Sn.closeMoreFunctionsPopup,kn=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==ee?void 0:ee.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==ee?void 0:ee.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==ee?void 0:ee.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==ee?void 0:ee.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[ee]),Ln=t.useState(null),Vn=Ln[0];Ln[1];var Hn=null===(C=null===(T=null==Z?void 0:Z.documents)||void 0===T?void 0:T[null===(B=null==Z?void 0:Z.input_index_map)||void 0===B?void 0:B[0]])||void 0===C?void 0:C.title,Gn=null===(w=null===(D=null==Z?void 0:Z.documents)||void 0===D?void 0:D[null===(O=null==Z?void 0:Z.input_index_map)||void 0===O?void 0:O[1]])||void 0===w?void 0:w.title,qn=u.safeStringify(ne||Hn||"Uploaded Contract"),zn=u.safeStringify(te||Gn||"Reference Template"),Kn=g.useCognitiveTreeData(Z,he,ae,kn,Oe),Wn=Kn.activeProposed,Yn=Kn.existingRule,Un=Kn.proposedSections,Xn=Kn.existingSections,$n=Kn.visibleFields,Jn=Kn.parentDeviationRecord,Qn=Kn.deviationNumberRegistry,Zn=Kn.parseError;t.useEffect(function(){Zn&&Te("Failed to load comparison: ".concat(Zn))},[Zn]);var et=Un.length>0||Xn.length>0,nt=h.useSectionRefs($n.map(function(e){return e.key}),Math.max(Un.length,Xn.length)),tt=nt.leftRefs,it=nt.rightRefs,ot=nt.sectionLeftRefs,rt=nt.sectionRightRefs,lt=nt.lhsBadgeRefs,ut=nt.rhsBadgeRefs,ct=nt.sectionRightRowRefs,at=nt.subSectionLeftRefs,st=nt.subSectionRightRefs,dt=nt.sectionRowRefs,vt=nt.getSectionRowRef,ft=nt.getSubSectionRef,gt=nt.getBadgeRef,pt=Yn.analysis,ht=u.safeStringify(null===(P=null===(N=null==pt?void 0:pt.rule_difference_comparison)||void 0===N?void 0:N.summary)||void 0===P?void 0:P.overall_summary),xt=!!ht.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),mt=null!==(j=null==Z?void 0:Z.base_root_id)&&void 0!==j?j:"-1";null==Z||Z[mt];var _t=Oe?null!==(Y=null!==(z=ae&&(null===(q=null==ae?void 0:ae[mt])||void 0===q?void 0:q.evaluation_result))&&void 0!==z?z:null===(W=null===(K=null==Z?void 0:Z.nodes)||void 0===K?void 0:K[mt])||void 0===W?void 0:W.evaluation_result)&&void 0!==Y?Y:null:null!==(G=null!==(k=ae&&(null===(M=null===(F=null==ae?void 0:ae[mt])||void 0===F?void 0:F.evaluation_result)||void 0===M?void 0:M[0]))&&void 0!==k?k:null===(H=null===(V=null===(L=null==Z?void 0:Z.nodes)||void 0===L?void 0:L[mt])||void 0===V?void 0:V.evaluation_result)||void 0===H?void 0:H[0])&&void 0!==G?G:null,Rt=u.extractDeviationScore(_t),yt=u.generateColorPalette(null!==($=null===(X=null===(U=null==_t?void 0:_t.evaluation_outputs)||void 0===U?void 0:U.metadata)||void 0===X?void 0:X.label_color)&&void 0!==$?$:""),bt=function(){Je.current.forEach(function(e){u.resetClauseHighlight(e)}),Je.current.clear()},St=t.useCallback(function(){var e,n,t,i,o,r;bt(),De(!1),on.current=!1,Xe.current=null;var l=rn.current,c=Gt.current;if(null!==l)if("string"==typeof l&&l.includes(u.DEVIATION_BADGE_SEPARATOR)){var a=l.split(u.DEVIATION_BADGE_SEPARATOR);(s=(null===(e=at.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=ot.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=ot.current[l])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}if(null!==c)if("string"==typeof c&&c.includes(u.DEVIATION_BADGE_SEPARATOR)){a=c.split(u.DEVIATION_BADGE_SEPARATOR);(d=(null===(i=st.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=rt.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=rt.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Ve(null),rn.current=null,Gt.current=null,Pe(!1),Ae(!1),pn.current&&(pn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px")},[]),At=t.useCallback(function(){bt(),St(),ze(new Set),Ye([]),nn.current=[],Ut([]),Jt(null),wn(a.EMPTY_SUMMARY_POPUP_STATE),Fn(),requestAnimationFrame(function(){var e;null===(e=ln.current)||void 0===e||e.call(ln)})},[]),Et=t.useRef(At);t.useEffect(function(){Et.current=At},[At]),t.useEffect(function(){oe&&Et.current()},[oe]);var It=x.useAccordionState({maintainRelativeOrder:!!he,proposedSections:Un,existingSections:Xn,activeSideBySideSection:Le,connectedSections:qe,resetSideBySide:St,setConnectedSections:ze,setConnectedLines:Ye,cachedConnectedPositions:nn,svgContainerRef:Ue,isAnimatingRef:Qe,animationTimerRef:Ze,calculateLinesRef:ln,sectionLeftRefs:ot,sectionRightRefs:rt,subSectionLeftRefs:at,subSectionRightRefs:st}),Tt=It.expandedSections,Bt=It.setExpandedSections,Ct=It.expandedSubSections,Dt=It.setExpandedSubSections,Ot=It.toggleSection,wt=t.useCallback(function(n,t,i,o,r,l,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",f=(v?un[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(a=dt.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==le?void 0:le.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:f,anchorEl:n,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,c=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return t?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return c(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var s=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(n=null==s?void 0:s.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==s?void 0:s.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},s),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==s?void 0:s.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==s?void 0:s.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==s?void 0:s.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==s?void 0:s.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==s?void 0:s.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==s?void 0:s.cognitive_decisioning)}):c(l)}(),isOrphan:!!r}},[un,Z]),Nt=t.useCallback(function(e){Mn(),Cn(null),En(e)},[Mn]),Pt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),In.open&&In.sectionIdx===o)Mn();else{var c=e.currentTarget,a="left";(null===(l=gn.current)||void 0===l?void 0:l.contains(c))&&(a="right");bt(),on.current&&St(),ze(new Set),Ye([]),nn.current=[],Fn(),On.open?mi():Nn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=ut.current[l])||void 0===e?void 0:e.current:null===(n=lt.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=ut.current[o])||void 0===t?void 0:t.current:null===(i=lt.current[o])||void 0===i?void 0:i.current}()||c;Tn(wt(e,n,i,o,t,r))})}},jt=t.useCallback(function(){null!==In.sectionIdx&&In.anchorEl?Nt(e.__assign(e.__assign({},In),{open:!0})):Mn()},[In,Mn,Nt]),Ft=t.useCallback(function(){var e=In.sectionIdx,n=In.isOrphan;Mn(),Nn(),null!==e&&(n?Te("No counterpart exists to connect to."):(bt(),on.current&&St(),Ye([]),nn.current=[],ze(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){ln.current&&ln.current()},50)))},[In.sectionIdx,In.isOrphan,Mn,Nn,St]),Mt=t.useCallback(function(){var e=$e.current;if(e){$e.current=null;var n=Un.findIndex(function(n){return n.id===e}),t=Xn.findIndex(function(n){return n.id===e}),i=-1===n?u.findKeyPathByNodeId(Un,e):null,o=-1===t?u.findKeyPathByNodeId(Xn,e):null,r=-1!==n?n:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=function(e,n,t,i){var o,r,l,u;return-1!==e?null!==(r=null===(o=t.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=i.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,t){void 0===t&&(t=30);var i=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Je.current.add(r),u.scrollAndHighlightClause(r,n)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(he)-1!==r&&_n.current&&a(function(){return c(n,i,ot,at)},_n.current),-1!==l&&gn.current&&a(function(){return c(t,o,rt,st)},gn.current);else{var s=vn.current;if(!s)return;a(function(){return-1!==r?c(n,i,ot,at):c(t,o,rt,st)},s)}}},[Un,Xn,he,ot,rt,at,st,_n,gn,vn]),kt=t.useCallback(function(n){if(n){bt(),St(),ze(new Set),Ye([]),nn.current=[],Nn(),Fn();var t=Un.findIndex(function(e){return e.id===n}),i=Xn.findIndex(function(e){return e.id===n}),o=-1===t?u.findKeyPathByNodeId(Un,n):null,r=-1===i?u.findKeyPathByNodeId(Xn,n):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=-1!==i?i:r?Number(r.split("-")[0]):-1;$e.current=n,Bt(function(n){var t,i=e.__assign({},n),o=!1;-1!==l&&(i[t=he?"left-".concat(l):String(l)]||(i[t]=!0,o=!0));-1!==c&&(i[t=he?"right-".concat(c):String(c)]||(i[t]=!0,o=!0));return o?i:n}),Dt(function(n){var t=e.__assign({},n),i=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:n}),setTimeout(function(){requestAnimationFrame(function(){$e.current===n&&Lt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Un,Xn,he,Bt,Dt,St,Nn,Fn]),Lt=t.useRef(Mt);t.useEffect(function(){Lt.current=Mt},[Mt]);var Vt=t.useRef(null),Ht=t.useRef(null),Gt=t.useRef(null),qt=t.useRef(null),zt=t.useRef(null),Kt=t.useRef(null),Wt=t.useState([]),Yt=Wt[0],Ut=Wt[1];t.useRef(null);var Xt=t.useState(null),$t=Xt[0],Jt=Xt[1];t.useEffect(function(){if(Vn){var e=kn.fields.find(function(e){return e.analysisKey===Vn||e.key===Vn});if(e){var n=tt.current[e.key]||it.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Vn,kn.fields]);var Qt=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==pt?void 0:pt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[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===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[pt]),Zt=t.useCallback(function(n,t){var i,o,r;void 0===t&&(t="left");var l=null,c=null;if("left"===t)if(l=Un[n],he&&l){var s=Xn.filter(function(e){var n;return null===(n=l.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});c=s.find(function(e){return e.evaluationResult})||s[0]}else c=Xn[n];else if(c=Xn[n],he&&c){var d=Un.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)});l=d.find(function(e){return e.evaluationResult})||d[0]}else l=Un[n];var v=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,g=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!v&&!f&&!g)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==c?void 0:c.evaluationResult)&&void 0!==o?o:null,h=u.getFirstDeviationOutputValue(p),x=u.getFirstDeviationColor(p);return null!=p?e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null!==(r=h)&&void 0!==r?r:""}):e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null})},[Un,Xn,un,kn,he]),ei=t.useCallback(function(n){for(var t,i,o,r,l,c=n.split("-").map(Number),s=Un[c[0]],d=Xn[c[0]],v=1;v<c.length;v++)(null==s?void 0:s.subsections)&&(s=s.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!s&&!d)return null;var f=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,g=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=u.safeStringify(null==s?void 0:s.id)||u.safeStringify(null==d?void 0:d.id)||"",h=!(!(null==s?void 0:s.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!f&&!g&&!h)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=un[p])||void 0===o||o.relevance_score);var x=null!==(l=null!==(r=null==s?void 0:s.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,m=u.getFirstDeviationOutputValue(x),_=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null!=m?m:""}):e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null})},[Un,Xn,un,kn]),ni=t.useCallback(function(n,t){var i,o,r,l,c,s,d,v,f,g,p,h,x,m,_,R,y;if(!n||null==t)return null;var b=null!==(d=null!==(c=null!==(o=null===(i=null==ae?void 0:ae[n])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==Z?void 0:Z.nodes)||void 0===r?void 0:r[n])||void 0===l?void 0:l.evaluation_result)&&void 0!==c?c:null===(s=null==Z?void 0:Z[n])||void 0===s?void 0:s.evaluation_result)&&void 0!==d?d:null;if(!b||"object"!=typeof b)return null;var S=null!==(p=null!==(f=null===(v=null==b?void 0:b.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==b?void 0:b.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==b?void 0:b[t],A=null!==(y=null!==(m=null===(x=null===(h=null==S?void 0:S.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==m?m:null===(R=null===(_=null==b?void 0:b.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===R?void 0:R.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR;return e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[ae,Z]),ti=t.useCallback(function(){bt(),Bt({}),Dt({}),St(),ze(new Set),Ye([]),nn.current=[],Nn(),Fn(),Mn(),requestAnimationFrame(function(){ln.current&&ln.current()})},[Bt,Dt,St,Nn,Fn,Mn]),ii=t.useMemo(function(){return Object.values(Tt).some(Boolean)||Object.values(Ct).some(Boolean)},[Tt,Ct]),oi=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p,h,x,m,_,R,y,b,S;if(!Rn.current&&!Qe.current){Rn.current=!0;try{if(!Vt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!Tt[t]&&!1===he)return!1;if(he&&!Tt["left-".concat(t)]&&!Tt["right-".concat(t)]&&!Tt[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!Ct[i])return!1;return!0},E=Vt.current.getBoundingClientRect();sn({width:E.width,height:E.height});var I=[];if($n.forEach(function(e){var n,t,i=e.key,o=null===(n=tt.current[i])||void 0===n?void 0:n.current,r=null===(t=it.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")}),!Qe.current){for(var T=0;T<Math.max(Un.length,Xn.length);T++){var B=null===(e=ot.current[T])||void 0===e?void 0:e.current,C=null===(n=rt.current[T])||void 0===n?void 0:n.current;B&&(B.style.height="auto",B.style.minHeight="0px"),C&&(C.style.height="auto",C.style.minHeight="0px")}he||Object.keys(at.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=at.current[e])||void 0===n?void 0:n.current,o=null===(t=st.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 D={};$n.forEach(function(e){var n,t,i=e.key,o=null===(n=tt.current[i])||void 0===n?void 0:n.current,r=null===(t=it.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var O={left:{},right:{}},w={};if(!Qe.current)if(he){if(Ce&&null!==Le)if("number"==typeof Le){var N=Le,P=Un[N],j=null===(o=ot.current[N])||void 0===o?void 0:o.current;j&&P&&(P.refIndexes||[]).forEach(function(e){var n,t=Xn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=rt.current[t])||void 0===n?void 0:n.current;if(i&&(Tt["left-".concat(N)]||Tt["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[N]=Math.max(O.left[N]||0,o),O.right[t]=Math.max(O.right[t]||0,o)}})}else{var F=Le.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(r=at.current[F])||void 0===r?void 0:r.current,C=null===(l=st.current[F])||void 0===l?void 0:l.current;if(B&&C){M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);w[F]=Math.max(w[F]||0,M)}}}}else{Object.keys(at.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=at.current[e])||void 0===n?void 0:n.current,o=null===(t=st.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(),u=Math.max(r.height,l.height);w[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(T=0;T<Math.min(Un.length,Xn.length);T++){var B=null===(t=ot.current[T])||void 0===t?void 0:t.current,C=null===(i=rt.current[T])||void 0===i?void 0:i.current;if(B&&C){var M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);O.left[T]=M,O.right[T]=M}}}if($n.forEach(function(e){var n,t,i=e.key,o=null===(n=tt.current[i])||void 0===n?void 0:n.current,r=null===(t=it.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Qe.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ot.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(O.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=rt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),he||Object.keys(w).forEach(function(e){var n,t,i=null===(n=at.current[e])||void 0===n?void 0:n.current,o=null===(t=st.current[e])||void 0===t?void 0:t.current;if(i&&o&&w[e]){var r=w[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),he)Un.forEach(function(e,n){var t;(null===(t=ot.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,a,s,d,v=Xn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=lt.current[n])||void 0===t?void 0:t.current,g=null===(i=ut.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-E.left,m=h.left-E.left,_=p.top+p.height/2-E.top,R=h.top+h.height/2-E.top;if(Ce&&Le===n){var y=null!==(r=null===(o=_n.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,b=null!==(u=null===(l=gn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,S=y+(null!==(a=null===(c=_n.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=b+(null!==(d=null===(s=gn.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),T=p.top+p.height/2,B=h.top+h.height/2,C=function(e,n,t){return Math.max(n,Math.min(t,e))};_=C(T,y,S)-E.top,R=C(B,b,A)-E.top}var D=Zt(n);D&&I.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:_,x2:m,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(T=0;T<Math.min(Un.length,Xn.length);T++){var k=null===(c=ot.current[T])||void 0===c?void 0:c.current,L=null===(a=rt.current[T])||void 0===a?void 0:a.current;if(k&&L){var V=k.getBoundingClientRect(),H=L.getBoundingClientRect(),G=Math.max(V.top,H.top)+18-E.top,q=(null===(s=Xn[T])||void 0===s?void 0:s.id)||"sec-".concat(T);(J=Zt(T))&&I.push({id:q,x1:V.right-E.left,y1:G,x2:H.left-E.left,y2:G,style:J,sectionIdx:T,hasCognitive:!!((null===(d=Un[T])||void 0===d?void 0:d.cognitiveData)||(null===(v=Xn[T])||void 0===v?void 0:v.cognitiveData)||q&&un[q]),isSubSection:!1})}}Object.keys(at.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=at.current[e])||void 0===n?void 0:n.current,a=null===(t=st.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Un[s[0]],v=Xn[s[0]],f=1;f<s.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]);var g=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(r=v.displayTitle)||void 0===r||r)&&u.hasValue(v.title)),x=!!v&&((null===(l=v.displayContent)||void 0===l||l)&&u.hasValue(v.content));if(g&&p||h&&x){var m=c.getBoundingClientRect(),_=a.getBoundingClientRect(),R=Math.max(m.top,_.top)+16-E.top,y=ei(e);y&&"Not Defined"!==y.label&&I.push({id:"subsec-".concat(e),x1:m.right-E.left,y1:R,x2:_.left-E.left,y2:R,style:y,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(Ce&&"string"==typeof Le&&Le.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Le.split(u.DEVIATION_BADGE_SEPARATOR),K=z[0],W=z[1],Y=z[2],U=(z[3],"".concat(K).concat(u.DEVIATION_BADGE_SEPARATOR).concat(W)),X=null===(f=lt.current[U])||void 0===f?void 0:f.current,$=null===(g=ut.current[U])||void 0===g?void 0:g.current;if(X&&$){var J,Q=X.getBoundingClientRect(),Z=$.getBoundingClientRect(),ee=Q.right-E.left,ne=Z.left-E.left,te=Q.top+Q.height/2-E.top,ie=Z.top+Z.height/2-E.top;if(he){var oe=null!==(h=null===(p=_n.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(m=null===(x=gn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,le=oe+(null!==(R=null===(_=_n.current)||void 0===_?void 0:_.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(b=null===(y=gn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==b?b:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,le)-E.top,ie=ce(Z.top+Z.height/2,re,ue)-E.top}(J=null!==(S=ni(K,W))&&void 0!==S?S:ei(Y))&&I.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:Le})}}if(Ut(I),zt.current&&Kt.current){var ae=zt.current.getBoundingClientRect(),se=Kt.current.getBoundingClientRect(),de=(ae.top+ae.height/2-E.top+se.top+se.height/2-E.top)/2;Jt({x1:ae.right-E.left,x2:se.left-E.left,y:de})}else Jt(null);if(qe.size>0){var ve=[],fe=_n.current,ge=gn.current;if(fe&&ge){var pe=[],xe=fe.getBoundingClientRect().top,me=ge.getBoundingClientRect().top,_e=xe+fe.clientHeight,Re=me+ge.clientHeight,ye=fe.scrollTop,be=ge.scrollTop,Se=E.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};qe.forEach(function(e){var n,t,i,o,r,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var c=e.split(u.DEVIATION_BADGE_SEPARATOR),a=c[0],s=c[1],d=c[2],v=(c[3],"".concat(a).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=lt.current[v])||void 0===n?void 0:n.current,g=null===(t=ut.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=ni(a,s))&&void 0!==i?i:ei(d),m=(j=p.right-E.left)+.5*((F=h.left-E.left-0)-j),_=p.top+p.height/2,R=h.top+h.height/2,y=_-xe+ye,b=R-me+be,S="conn-subsec-".concat(v);pe.push({lhsScrollY:y,rhsScrollY:b,x1:j,x2:F,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var A=Ae(_,xe,_e),I=Ae(R,me,Re),T=A-Se,B=I-Se,C=R>=me-4&&R<=Re+4,D="";D=(M=_>=xe-4&&_<=_e+4)&&C?u.getBentArrowPath(j,T,F,B):M&&!C?"M ".concat(j,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(he){var O=e,w=Un[O];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(e){var n,t,i=Xn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=lt.current[O])||void 0===n?void 0:n.current,r=null===(t=ut.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Zt(O),s=l.right-E.left,d=c.left-E.left-0,v=s+.5*(d-s),f=l.top+l.height/2,g=c.top+c.height/2,p=f-xe+ye,h=g-me+be,x="conn-".concat(O,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ae(f,xe,_e),_=Ae(g,me,Re),R=m-Se,y=_-Se,b=f>=xe-4&&f<=_e+4,S=g>=me-4&&g<=Re+4,A="";A=b&&S?u.getBentArrowPath(s,R,d,y):b&&!S?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!b&&S?"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y," L ").concat(d,",").concat(y):"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y),ve.push({id:x,pathD:A,style:a,leftIdx:O,rhsArrayIdx:i})}}})}else{var N=e,P=N;f=null===(o=lt.current[N])||void 0===o?void 0:o.current,g=null===(r=ut.current[P])||void 0===r?void 0:r.current;if(!f||!g)return;var j,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=Zt(N),m=(j=p.right-E.left)+.5*((F=h.left-E.left-0)-j),_=p.top+p.height/2,R=h.top+h.height/2,y=_-xe+ye,b=R-me+be,S="conn-".concat(N,"-").concat(P);pe.push({lhsScrollY:y,rhsScrollY:b,x1:j,x2:F,containerTop:Se,leftIdx:N,rhsArrayIdx:P,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var M;A=Ae(_,xe,_e),I=Ae(R,me,Re),T=A-Se,B=I-Se,C=R>=me-4&&R<=Re+4,D="";D=(M=_>=xe-4&&_<=_e+4)&&C?u.getBentArrowPath(j,T,F,B):M&&!C?"M ".concat(j,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:N,rhsArrayIdx:P})}}),nn.current=pe}Ye(ve)}else Ye([]),nn.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Rn.current=!1}}},[$n,Un,Xn,un,kn,Qt,Zt,ni,he,Ce,Le,qe,Tt,Ct]),ri=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p=nn.current;if(p.length&&!Qe.current){var h=null!==(n=null===(e=_n.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=gn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(r=null===(o=_n.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,_=null!==(c=null===(l=gn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=_n.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=gn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,b=R+m,S=y+_,A=null!==(g=null===(f=Vt.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,E=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+R,t=e.rhsScrollY-x+y,i=en.current[e.styleId+"-stroke"],o=en.current[e.styleId+"-bg"];if(i||o){var r,l=E(n,R,b),c=E(t,y,S),a=l-A,s=c-A,d=n>=R-4&&n<=b+4,v=t>=y-4&&t<=S+4,f=e.x1+.5*(e.x2-e.x1);r=d&&v?u.getBentArrowPath(e.x1,a,e.x2,s):d&&!v?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(s):!d&&v?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){ln.current=oi},[oi]);var li=t.useRef(null),ui=t.useRef(null),ci=t.useCallback(function(){nn.current.length>0&&!Qe.current||(null!==li.current&&clearTimeout(li.current),li.current=setTimeout(function(){ln.current(),li.current=null},50))},[]),ai=t.useCallback(function(){Me(!0),Pe(!1),Xe.current=null,null!==ui.current&&clearTimeout(ui.current),null!==li.current&&(clearTimeout(li.current),li.current=null),ui.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s,d;try{if(nn.current=[],on.current&&null!==rn.current&&null!==Gt.current){var v=rn.current,f=Gt.current,g="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR),p=null,h=null,x=null,m=null;if(g){var _=v.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(_[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(_[1]);p=(null===(e=lt.current[R])||void 0===e?void 0:e.current)||null,h=(null===(n=ut.current[R])||void 0===n?void 0:n.current)||null,x=(null===(t=at.current[_[2]])||void 0===t?void 0:t.current)||(null===(i=ot.current[Number(_[2])])||void 0===i?void 0:i.current)||null,m=(null===(o=st.current[_[3]])||void 0===o?void 0:o.current)||(null===(r=rt.current[Number(_[3])])||void 0===r?void 0:r.current)||null}else p=(null===(l=dt.current[v])||void 0===l?void 0:l.current)||null,x=(null===(c=ot.current[v])||void 0===c?void 0:c.current)||null,h=(null===(a=ct.current[f])||void 0===a?void 0:a.current)||null,m=(null===(s=rt.current[f])||void 0===s?void 0:s.current)||null;if(p&&h&&x&&m){if(x.style.paddingTop="0px",m.style.paddingTop="0px",!he){var y=p.getBoundingClientRect(),b=h.getBoundingClientRect(),S=y.top-b.top;S>0?m.style.paddingTop="".concat(S,"px"):S<0&&(x.style.paddingTop="".concat(Math.abs(S),"px"))}var A=_n.current,E=gn.current;if(A&&E){var I=p.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop,T=h.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop-(I-A.scrollTop);Math.abs(E.scrollTop-T)>1&&(E.scrollTop=T)}}}null===(d=ln.current)||void 0===d||d.call(ln),on.current&&Pe(!0)}catch(e){console.error("Safely caught error during resize calculation:",e)}finally{Me(!1),ui.current=null}},150)},[he,Un,Xn]),si=t.useCallback(function(e){if(null!==yn.current&&bn.current&&Math.abs(e.currentTarget.scrollTop-yn.current)<=2){var n=bn.current;yn.current=null,bn.current=null,n()}He.current||(he||ci(),tn.current||(tn.current=!0,requestAnimationFrame(function(){var e,n,t,i,o,r,l;if(on.current){var c=_n.current,a=gn.current;if(c&&a&&qt.current){if(!Xe.current){var s=rn.current,d=void 0;if("string"==typeof s&&s.includes(u.DEVIATION_BADGE_SEPARATOR)){var v=s.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(v[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(v[1]);d=null===(e=lt.current[f])||void 0===e?void 0:e.current}else d=null===(n=lt.current[s])||void 0===n?void 0:n.current;if(d){var g=d.getBoundingClientRect();Xe.current={badgeScreenY:g.top+g.height/2,initialScrollTop:c.scrollTop,leftTop:c.getBoundingClientRect().top,leftBottom:c.getBoundingClientRect().top+c.clientHeight,cTop:null!==(i=null===(t=Vt.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(Xe.current){var p=Xe.current,h=c.scrollTop-p.initialScrollTop,x=p.badgeScreenY-h,m=((o=x,r=p.leftTop,l=p.leftBottom,Math.max(r,Math.min(l,o)))-p.cTop).toString(),_=x>=p.leftTop-4&&x<=p.leftBottom+4;qt.current.setAttribute("y1",m),qt.current.setAttribute("y2",m),qt.current.setAttribute("visibility",_?"visible":"hidden")}}}nn.current.length>0&&ri(),tn.current=!1})))},[ri,he,ci]),di=t.useRef(0),vi=t.useRef(0),fi=t.useRef(0),gi=t.useRef(function(){});t.useRef(null),t.useEffect(function(){gi.current=ai},[ai]),t.useEffect(function(){var e=setTimeout(ci,250),n=function(){return gi.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==li.current&&clearTimeout(li.current),null!==ui.current&&clearTimeout(ui.current),window.removeEventListener("resize",n)}},[Wn,Yn,pt,$n,Tt,Ct,Un,Xn,kn,ci,Ce,Le,Ne,qe]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return r.observe(e),r},n={current:null},t={current:null},i={current:null},o=[],r=[n,t,i];return fn.current&&o.push(e(fn.current,di,n,function(){return gi.current()},function(){})),vn.current&&o.push(e(vn.current,vi,t,function(){return gi.current()},function(){return ln.current()})),Vt.current&&o.push(e(Vt.current,fi,i,function(){return gi.current()},function(){return ln.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){on.current=Ce},[Ce]),t.useEffect(function(){rn.current=Le},[Le]);var pi=t.useCallback(function(e,n,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,c=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";Mn(),null!=e&&(n?Te("No counterpart exists for this section."):(bt(),Ce&&Le===e?r?St():null==l||l():(ze(new Set([e])),Ye([]),nn.current=[],Ae(!0),He.current=!0,Ve(e),rn.current=e,De(!0),on.current=!0,Pe(!1),pn.current&&(pn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,a="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=null,d=null,v=null;if(a){var f=e.split(u.DEVIATION_BADGE_SEPARATOR),g="".concat(f[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f[1]);s=(null===(n=lt.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=ut.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=dt.current[e])||void 0===i?void 0:i.current)||null,he){var p=Un[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],m=Xn.findIndex(function(e){return e.selfIndex===x});-1!==m&&(d=(null===(r=ct.current[m])||void 0===r?void 0:r.current)||null,v=m)}}else d=(null===(o=ct.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Gt.current=v;var _=_n.current,R=gn.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,f,g,p,h=null,x=null,m=null,_=null;if(a){var R=e.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(R[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(R[1]);h=(null===(n=at.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=ot.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=st.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=rt.current[Number(R[3])])||void 0===o?void 0:o.current)||null,m=(null===(r=lt.current[y])||void 0===r?void 0:r.current)||h,_=(null===(l=ut.current[y])||void 0===l?void 0:l.current)||x}else{var b=Number(e),S=null!==v?Number(v):b;h=(null===(c=ot.current[b])||void 0===c?void 0:c.current)||null,x=(null===(s=rt.current[S])||void 0===s?void 0:s.current)||null,m=(null===(d=lt.current[b])||void 0===d?void 0:d.current)||(null===(f=dt.current[b])||void 0===f?void 0:f.current)||h,_=(null===(g=ut.current[S])||void 0===g?void 0:g.current)||(null===(p=ct.current[S])||void 0===p?void 0:p.current)||x}if(m&&_&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=m.getBoundingClientRect(),E=_.getBoundingClientRect(),I=A.top-E.top;I>0?x.style.paddingTop="".concat(I,"px"):I<0&&(h.style.paddingTop="".concat(Math.abs(I),"px"))}}(),Pe(!0),ln.current&&ln.current(),He.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):_&&_.dispatchEvent(new Event("scroll")),Ae(!1),null==l||l()};if(!s||!_)return He.current=!1,Ae(!1),void(null==l||l());if(d&&R){if(!he){var b=0;b="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var S=vn.current,A=(null==S?void 0:S.getBoundingClientRect().top)||0,E=S?S.scrollTop+b-A-150:0;return S?void u.smoothScrollTo(S,E,200,y):void y()}var I=s.getBoundingClientRect().top-_.getBoundingClientRect().top+_.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=T-(I-_.scrollTop);C<0&&pn.current&&(pn.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return hn.current&&(hn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,C,B,y)})}e=C}u.smoothScrollTo(R,e,B,y)})}else{var D=I-(T-R.scrollTop);D<0&&xn.current&&(xn.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=_.scrollHeight-_.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return mn.current&&(mn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(_,D,B,y)})}e=D}u.smoothScrollTo(_,e,B,y)})}}else y()}))))},[Le,Mn,Xn,Ce,he,Un,St]),hi=t.useCallback(function(e,n,t,i){var o,r="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),l=e.currentTarget;Fn();var c="left";(null===(o=gn.current)||void 0===o?void 0:o.contains(l))&&(c="right");var a=function(){var e,t,i,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===c?null===(e=ut.current[l])||void 0===e?void 0:e.current:null===(t=lt.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=ut.current[n])||void 0===i?void 0:i.current:null===(o=lt.current[n])||void 0===o?void 0:o.current};if(t)return St(),ze(new Set),Ye([]),nn.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;wn({open:!0,anchorEl:e,summary:i})}));pi(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;wn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[pi,Fn,wn,St]),xi=t.useCallback(function(){var e,n=In.sectionIdx,t=In.isOrphan;if(Nn(),null!=n){var i="left";In.anchorEl&&(null===(e=gn.current)||void 0===e?void 0:e.contains(In.anchorEl))&&(i="right"),pi(n,t,{sourceSide:i})}},[pi,In.isOrphan,In.sectionIdx,In.anchorEl,Nn]),mi=t.useCallback(function(){Nn(),St(),ze(new Set),Ye([]),nn.current=[]},[Nn,St]),_i=null!==In.sectionIdx&&qe.has(In.sectionIdx),Ri=m.useDeviationNavigation({proposedSections:Un,existingSections:Xn,parentDeviationRecord:Jn,expandedSections:Tt,maintainRelativeOrder:!!he,scrollContainerRef:vn,leftContainerRef:_n,lhsBadgeRefs:lt,rhsBadgeRefs:ut}),yi=Ri.showDeviationNavigation,bi=Ri.showOpenNodeRef,Si=t.useMemo(function(){var e;if(!se)return null;var n=null===(e=null==se?void 0:se.id)||void 0===e?void 0:e.split(":")[0];for(var t in Jn){if((Jn[t]||[]).some(function(e){return e.id===n}))return t}return null},[se,Jn]),Ai=t.useRef({id:null,triggerMs:null}),Ei=t.useRef(null);t.useEffect(function(){var n;if(null==se?void 0:se.id){var t=Number(se.trigger),i=Ai.current;if((null==i?void 0:i.triggerMs)!==t){if(!(se.id.includes(":")&&/:\d+$/.test(se.id)))return Ai.current={id:se.id,triggerMs:t},void kt(se.id);var o=null===(n=null==se?void 0:se.id)||void 0===n?void 0:n.split(":"),r=o[0],l=o[1],c=null!=l?l:"0";Ei.current!==se.id&&(Nn(),Fn(),St(),ze(new Set),Ye([]),nn.current=[],Ei.current=se.id);var a=!1,s=0,d=null,v=150,f=function(e,n){for(var t=function(e,i){if(!e)return null;if(e.id===n)return i;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=t(e.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<e.length;i++){var o=t(e[i],String(i));if(o)return o}return null},g=function(){var n,i,o,l;if(!a){var p=function(){Ai.current={id:se.id,triggerMs:t}},h=null,x=null;for(var m in Jn){var _=Jn[m].find(function(e){return e.id===r});if(_){h=m,x=_;break}}if(x&&h){var R=Un.findIndex(function(e){return e.id===h}),y=Xn.findIndex(function(e){return e.id===h}),b=-1===R&&-1!==y,S=f(Un,x.id),A=f(Xn,x.id);if(S&&!A&&!b){var E=S.split("-"),I=Number(E[0]);if(he){var T=null===(i=null===(n=Un[I])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],B=Xn.findIndex(function(e){return e.selfIndex===T});-1!==B&&(I=B)}A=e.__spreadArray([I],E.slice(1),!0).join("-")}if(S||A){var C=b||!S&&!!A,D=S?Number(S.split("-")[0]):R,O=A?Number(A.split("-")[0]):y;if(C){if(!(he?!!Tt["right-".concat(O)]:!!Tt[String(O)])&&O>=0)return Ot(O,"right"),s+=1,void(d=setTimeout(g,450))}else if(!(he?!!Tt["left-".concat(D)]:!!Tt[String(D)])&&D>=0)return Ot(D,"left"),s+=1,void(d=setTimeout(g,450));var w,N=S||"",P=A||"",j="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(N).concat(u.DEVIATION_BADGE_SEPARATOR).concat(P),F="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c),M=null===(o=lt.current[F])||void 0===o?void 0:o.current,k=null===(l=ut.current[F])||void 0===l?void 0:l.current,L=C||!M&&!!k,V=L?k:M;if(w=he?L?gn.current:_n.current:vn.current,V&&w){var H=V.getBoundingClientRect();if(0===H.height)return void((s+=1)<2?d=setTimeout(g,v):p());var G=w.getBoundingClientRect(),q=H.top-G.top+w.scrollTop-G.height/2+H.height/2+150,z=function(){var n,t,i,o,r;if(!a){p();var l=window.getComputedStyle(V).color;M&&(M.style.transition="box-shadow 300ms ease-in-out",M.style.boxShadow="0 0 10px ".concat(l)),k&&(k.style.transition="box-shadow 300ms ease-in-out",k.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){M&&(M.style.boxShadow=""),k&&(k.style.boxShadow="")},2e3);var u=(null===(t=null===(n=x.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[c])||x,s=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!M&&!!k)){var d=L?(null===(o=ut.current[F])||void 0===o?void 0:o.current)||k:(null===(r=lt.current[F])||void 0===r?void 0:r.current)||M;return wn({open:!0,anchorEl:d,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})}),void(null==de||de())}pi(j,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=lt.current[F])||void 0===n?void 0:n.current)||M;console.log("Summary data",s,u),wn({open:!0,anchorEl:t,summary:e.__assign({},u)})}})}};Math.abs(w.scrollTop-q)<=2?z():(yn.current=q,bn.current=z,w.scrollTo({top:q,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(bn.current){yn.current=null;var e=bn.current;bn.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}};return d=setTimeout(g,v),function(){a=!0,d&&clearTimeout(d)}}}},[se,Jn,Un,Xn,he,Tt,Ot,pi,wn,kt]);var Ii=function(e){var t=e.section,i=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c;return n.jsx(y.default,{section:t,keyPath:i,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:Ct,setExpandedSubSections:Dt,maintainRelativeOrder:he||!1,proposedSections:Un,existingSections:Xn,treeData:Z,deviationNumberRegistry:Qn,connectedSections:qe,activeSideBySideSection:Le,resolvedMarkdownStyles:dn,getSubSectionRef:ft,getSubSectionCompareStyle:ei,getBadgeRef:gt,openMoreFunctionsPopup:Pt,openSummaryPopup:hi,showDeviationBadges:me,resetSideBySide:St,setConnectedSections:ze,setConnectedLines:Ye,cachedConnectedPositions:nn,isProposingFix:fe,proposingFixNodeId:ge})};return n.jsxs(i.Box,e.__assign({ref:fn,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},he?{}:{overflow:"visible"}),{position:"relative"})},{children:[Re&&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,{})})),On.open&&n.jsx(b.default,{open:On.open,anchorEl:On.anchorEl,containerEl:Ht.current,clipTopEl:zt.current,scrollContainerEl:vn.current,onClose:mi,summary:On.summary}),n.jsx(d.default,{open:In.open,anchorEl:In.anchorEl,sectionTitle:In.sectionTitle,referenceSectionTitle:In.refSectionTitle,onClose:Mn,onOpenCognitiveCompare:jt,onOpenSideBySide:xi,onConnect:Ft,isConnected:_i,isOrphan:In.isOrphan}),An.open&&n.jsx(s.default,{open:An.open,popupRef:jn,position:Bn,popupConfig:ue,onClose:function(){Cn(null),En(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Pn(null)},markdownStyles:ie,sectionTitle:An.sectionTitle,referenceSectionTitle:An.refSectionTitle,cognitiveData:An.cognitiveData,anchorEl:An.anchorEl,sectionAnchorEl:An.sectionAnchorEl,scrollContainerEl:vn.current,badgeStyle:An.badgeStyle,docData:An.docData,deviationData:An.deviationData,isLoading:An.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!Ie,autoHideDuration:8e3,onClose:function(){return Te(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Te(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Ie}))})),n.jsx(_.default,{componentHeaderText:Q,displayConfig:le,maintainRelativeOrder:he,onCollapseAll:ti,showCollapseAll:ii,onToggleView:function(e){ye(!0),setTimeout(function(){xe(!e),St(),Nn(),ze(new Set),Ye([]),nn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ye(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:vn,onScroll:si,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:he?"hidden":"auto",borderTop:ht&&xt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},he?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Vt,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},he?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Ue,style:{position:"absolute",top:0,left:0,width:an.width||"100%",height:an.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Fe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[$t&&n.jsx("g",{children:n.jsx("line",{x1:$t.x1,y1:$t.y,x2:$t.x2,y2:$t.y,stroke:yt.badgeBorder,strokeWidth:"1.5"})}),Yt.map(function(t){var l,c,s,d,v,g,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?Ce&&Le===t.subSectionKeyPath&&Ne:Ce&&Le===t.sectionIdx&&Ne)return null;if(!he){var x=t.isSubSection?u.getBentArrowPath(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2),m=Un[t.sectionIdx]||{title:"",content:""},_=Xn[t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",m,_),t.isSubSection&&t.subSectionKeyPath){var R=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],y=R[2]||t.subSectionKeyPath,b=R[3]||y,S=y.split("-").map(Number),A=b.split("-").map(Number),E=null,I=null;S.length>0&&(E=Un[S[0]]),A.length>0&&(I=Xn[A[0]]);var T=(null==E?void 0:E.title)||"",B=(null==I?void 0:I.title)||"";console.log("Root Parent Titles:",T,B);for(var C=1;C<S.length;C++)(null==E?void 0:E.subsections)&&(E=E.subsections[S[C]]);for(C=1;C<A.length;C++)(null==I?void 0:I.subsections)&&(I=I.subsections[A[C]]);E&&(m=e.__assign(e.__assign({},E),{title:T||E.title})),console.log("Base Section for Subsection Badge:",m),I&&(_=e.__assign(e.__assign({},I),{title:B||I.title})),console.log("Ref Section for Subsection Badge:",_)}var D=!(null===(l=m.cognitiveData)||void 0===l?void 0:l.isMissingRationale)||Boolean(null===(s=null===(c=m.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===s?void 0:s.length),O=(null===(g=null===(v=null===(d=m.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===g?void 0:g.length)||!1,w=D||O;return n.jsxs("g",{children:[n.jsx("path",{d:x,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:p-100,y:h-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),w&&(An.open&&Dn===t.id?Fn():(Pn(t.id),Nt(wt(e.currentTarget,m,_,t.sectionIdx,t.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:w?"pointer":"default"}},{children:[t.style.badgeText===a.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(f.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),w&&n.jsx(o.ChevronDown,{size:11,style:{transform:An.open&&Dn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),n.jsx(S.default,{connectedLines:We,pathRefs:en})]})),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)"},he?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:zt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(i.Tooltip,e.__assign({title:qn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:qn}))}))})),n.jsxs(i.Box,e.__assign({ref:_n,onScroll:si,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},he?{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:xn,style:{width:"100%",height:"0px",flexShrink:0}}),et&&Un.map(function(t,r){var l,c,a=!t.title&&!t.content;if(he&&a)return null;var s=t,d=Zt(r,"left"),v=he?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Xn[r],g=he?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=qe.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:vt(r),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:ot.current[r],sx:e.__assign({width:"100%",display:"flex",flexDirection:"column",minWidth:0},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:r,columnKey:"left",colRef:vt("left-accordion-".concat(r)),mb:0,treeData:Z,proposedSections:Un,existingSections:Xn,deviationNumberRegistry:Qn,getSectionCompareStyle:Zt,getBadgeRef:gt,connectedSections:qe,openMoreFunctionsPopup:Pt,openSummaryPopup:hi,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Si,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:he?!!Tt["left-".concat(r)]:!!Tt[String(r)],onToggle:function(){mi(),Ot(r,"left")},navigation:t.id?yi[t.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:dn,maintainRelativeOrder:he,showDeviationBadges:me,renderSubSections:Ii,isProposingFix:fe,proposingFixNodeId:ge,collisionKey:"".concat(Ce?"1":"0","-").concat(String(null!=Le?Le:""))})})),he&&d&&n.jsxs(i.Box,e.__assign({ref:lt.current[r],onClick:function(e){var n=he?Xn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Xn[r]||{title:"",content:""};Pt(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:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,t,i;e.stopPropagation();var o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=s.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=s.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;console.log("LOG: Printing evaluationResult",o,s),hi(e,String(r),v,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:v?"default":"pointer",borderRight:"1px solid ".concat(d.badgeBorder),"&:hover":v?{}:{bgColor:"".concat(d.badgeBorder,"22")}}},{children:[null!=g&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:g})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!le.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(f.default,{color:d.badgeText})}))]})),n.jsx(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=he?Xn.find(function(e){var n;return(null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e))||{title:"",content:""}}):Xn[r]||{title:"",content:""};Pt(e,t,v,n,r,d)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(d.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})}))]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:mn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:Ht,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){n.stopPropagation(),An.open&&Dn===mt?Fn():(Pn(mt),Nt(wt(n.currentTarget,{title:"",content:"",evaluationResult:_t,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,mt,!0,e.__assign(e.__assign({},yt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:yt.badgeBg,color:yt.badgeText,border:"1px solid ".concat(yt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Rt?Rt:n.jsx(f.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:An.open&&Dn===mt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},he?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Se&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Kt,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:zn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:zn}))}))})),n.jsxs(i.Box,e.__assign({ref:gn,onScroll:si,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},he?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:pn,style:{width:"100%",height:"0px",flexShrink:0}}),et&&Xn.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(he){u=Un.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=Un.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=Un.findIndex(function(e,n){var t;return qe.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=Zt(d))}else u=[o+1],(c=qe.has(o))&&(a=Zt(o));var v=Zt(he&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:ct.current[o],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:rt.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:o,columnKey:"right",colRef:vt("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==Z?void 0:Z.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:he?!!Tt["right-".concat(o)]:!!Tt[String(o)],treeData:Z,proposedSections:Un,existingSections:Xn,deviationNumberRegistry:Qn,getBadgeRef:gt,getSectionCompareStyle:Zt,connectedSections:qe,openMoreFunctionsPopup:Pt,openSummaryPopup:hi,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Si,onToggle:function(){mi(),Ot(o,"right")},navigation:t.id?yi[t.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:dn,maintainRelativeOrder:he,showDeviationBadges:me,renderSubSections:Ii,isProposingFix:fe,proposingFixNodeId:ge,collisionKey:"".concat(Ce?"1":"0","-").concat(String(null!=Le?Le:""))})})),he&&v&&n.jsx(i.Box,e.__assign({ref:ut.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:hn,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"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),m=require("./hooks/useDeviationNavigation.js"),_=require("./components/CompareHeader.js"),y=require("./components/SectionAccordion.js"),R=require("./components/SubSectionAccordion.js"),b=require("./components/CognitiveSummaryPopup.js"),S=require("./components/connectedLines.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var I,E,T,B,C,D,O,w,N,j,P,F,M,k,L,V,H,q,G,z,K,W,Y,U,X,$,J=A.componentHeaderText,Q=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Z=A.treeData,ee=A.comparisonConfig,ne=A.leftColumnTitleText,te=A.rightColumnTitleText,ie=A.markdownStyles,oe=A.resetTrigger,re=A.displayConfig,le=void 0===re?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:re,ue=A.popupConfig,ce=A.deviationData,ae=void 0===ce?{}:ce,se=A.deviationNodeIdToView,de=A.resetDeviationNodeId,ve=A.isProposingFix,fe=void 0!==ve&&ve,ge=A.proposingFixNodeId,pe=t.useState(le.maintainRelativeOrder),he=pe[0],xe=pe[1],me=!!he||!!(null==le?void 0:le.showDeviationBadges),_e=t.useState(!1),ye=_e[0],Re=_e[1],be=t.useState(!1),Se=be[0],Ae=be[1],Ie=t.useState(null),Ee=Ie[0],Te=Ie[1],Be=t.useState(!1),Ce=Be[0],De=Be[1],Oe=t.useState(null===(E=null!==(I=null==Z?void 0:Z.newEvaluationResult)&&void 0!==I?I:null==le?void 0:le.enableDeviationSchemaBackwardCompatibility)||void 0===E||E)[0],we=t.useState(!1),Ne=we[0],je=we[1],Pe=t.useState(!1),Fe=Pe[0],Me=Pe[1],ke=t.useState(null),Le=ke[0],Ve=ke[1],He=t.useRef(!1),qe=t.useState(new Set),Ge=qe[0],ze=qe[1],Ke=t.useState([]),We=Ke[0],Ye=Ke[1],Ue=t.useRef(null),Xe=t.useRef(null),$e=t.useRef(null),Je=t.useRef(new Set),Qe=t.useRef(!1),Ze=t.useRef(null),en=t.useRef({}),nn=t.useRef([]),tn=t.useRef(!1),on=t.useRef(!1),rn=t.useRef(null),ln=t.useRef(function(){}),un=t.useMemo(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),cn=t.useState({width:0,height:0}),an=cn[0],sn=cn[1],dn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),ie)},[ie]),vn=t.useRef(null),fn=t.useRef(null),gn=t.useRef(null),pn=t.useRef(null),hn=t.useRef(null),xn=t.useRef(null),mn=t.useRef(null),_n=t.useRef(null),yn=t.useRef(!1),Rn=t.useRef(null),bn=t.useRef(null),Sn=p.useComparePopups(vn),An=Sn.cognitivePopup,In=Sn.setCognitivePopup,En=Sn.moreFunctions,Tn=Sn.setMoreFunctions,Bn=Sn.position,Cn=Sn.setPosition,Dn=Sn.activeBadgeId,On=Sn.summaryPopup,wn=Sn.setSummaryPopup,Nn=Sn.closeSummaryPopup,jn=Sn.setActiveBadgeId,Pn=Sn.popupRef,Fn=Sn.closeCognitivePopup,Mn=Sn.closeMoreFunctionsPopup,kn=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==ee?void 0:ee.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==ee?void 0:ee.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==ee?void 0:ee.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==ee?void 0:ee.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[ee]),Ln=t.useState(null),Vn=Ln[0];Ln[1];var Hn=null===(C=null===(T=null==Z?void 0:Z.documents)||void 0===T?void 0:T[null===(B=null==Z?void 0:Z.input_index_map)||void 0===B?void 0:B[0]])||void 0===C?void 0:C.title,qn=null===(w=null===(D=null==Z?void 0:Z.documents)||void 0===D?void 0:D[null===(O=null==Z?void 0:Z.input_index_map)||void 0===O?void 0:O[1]])||void 0===w?void 0:w.title,Gn=u.safeStringify(ne||Hn||"Uploaded Contract"),zn=u.safeStringify(te||qn||"Reference Template"),Kn=g.useCognitiveTreeData(Z,he,ae,kn,Oe),Wn=Kn.activeProposed,Yn=Kn.existingRule,Un=Kn.proposedSections,Xn=Kn.existingSections,$n=Kn.visibleFields,Jn=Kn.parentDeviationRecord,Qn=Kn.deviationNumberRegistry,Zn=Kn.parseError;t.useEffect(function(){Zn&&Te("Failed to load comparison: ".concat(Zn))},[Zn]);var et=Un.length>0||Xn.length>0,nt=h.useSectionRefs($n.map(function(e){return e.key}),Math.max(Un.length,Xn.length)),tt=nt.leftRefs,it=nt.rightRefs,ot=nt.sectionLeftRefs,rt=nt.sectionRightRefs,lt=nt.lhsBadgeRefs,ut=nt.rhsBadgeRefs,ct=nt.sectionRightRowRefs,at=nt.subSectionLeftRefs,st=nt.subSectionRightRefs,dt=nt.sectionRowRefs,vt=nt.getSectionRowRef,ft=nt.getSubSectionRef,gt=nt.getBadgeRef,pt=Yn.analysis,ht=u.safeStringify(null===(j=null===(N=null==pt?void 0:pt.rule_difference_comparison)||void 0===N?void 0:N.summary)||void 0===j?void 0:j.overall_summary),xt=!!ht.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),mt=null!==(P=null==Z?void 0:Z.base_root_id)&&void 0!==P?P:"-1";null==Z||Z[mt];var _t=Oe?null!==(Y=null!==(z=ae&&(null===(G=null==ae?void 0:ae[mt])||void 0===G?void 0:G.evaluation_result))&&void 0!==z?z:null===(W=null===(K=null==Z?void 0:Z.nodes)||void 0===K?void 0:K[mt])||void 0===W?void 0:W.evaluation_result)&&void 0!==Y?Y:null:null!==(q=null!==(k=ae&&(null===(M=null===(F=null==ae?void 0:ae[mt])||void 0===F?void 0:F.evaluation_result)||void 0===M?void 0:M[0]))&&void 0!==k?k:null===(H=null===(V=null===(L=null==Z?void 0:Z.nodes)||void 0===L?void 0:L[mt])||void 0===V?void 0:V.evaluation_result)||void 0===H?void 0:H[0])&&void 0!==q?q:null,yt=u.extractDeviationScore(_t),Rt=u.generateColorPalette(null!==($=null===(X=null===(U=null==_t?void 0:_t.evaluation_outputs)||void 0===U?void 0:U.metadata)||void 0===X?void 0:X.label_color)&&void 0!==$?$:""),bt=function(){Je.current.forEach(function(e){u.resetClauseHighlight(e)}),Je.current.clear()},St=t.useCallback(function(){var e,n,t,i,o,r;bt(),De(!1),on.current=!1,Xe.current=null;var l=rn.current,c=qt.current;if(null!==l)if("string"==typeof l&&l.includes(u.DEVIATION_BADGE_SEPARATOR)){var a=l.split(u.DEVIATION_BADGE_SEPARATOR);(s=(null===(e=at.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=ot.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=ot.current[l])||void 0===t?void 0:t.current)&&(s.style.paddingTop="0px")}if(null!==c)if("string"==typeof c&&c.includes(u.DEVIATION_BADGE_SEPARATOR)){a=c.split(u.DEVIATION_BADGE_SEPARATOR);(d=(null===(i=st.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=rt.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=rt.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Ve(null),rn.current=null,qt.current=null,je(!1),Ae(!1),pn.current&&(pn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px")},[]),At=t.useCallback(function(){bt(),St(),ze(new Set),Ye([]),nn.current=[],Ut([]),Jt(null),wn(a.EMPTY_SUMMARY_POPUP_STATE),Fn(),requestAnimationFrame(function(){var e;null===(e=ln.current)||void 0===e||e.call(ln)})},[]),It=t.useRef(At);t.useEffect(function(){It.current=At},[At]),t.useEffect(function(){oe&&It.current()},[oe]);var Et=x.useAccordionState({maintainRelativeOrder:!!he,proposedSections:Un,existingSections:Xn,activeSideBySideSection:Le,connectedSections:Ge,resetSideBySide:St,setConnectedSections:ze,setConnectedLines:Ye,cachedConnectedPositions:nn,svgContainerRef:Ue,isAnimatingRef:Qe,animationTimerRef:Ze,calculateLinesRef:ln,sectionLeftRefs:ot,sectionRightRefs:rt,subSectionLeftRefs:at,subSectionRightRefs:st}),Tt=Et.expandedSections,Bt=Et.setExpandedSections,Ct=Et.expandedSubSections,Dt=Et.setExpandedSubSections,Ot=Et.toggleSection,wt=t.useCallback(function(n,t,i,o,r,l,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",f=(v?un[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(a=dt.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==le?void 0:le.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:f,anchorEl:n,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,c=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return t?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return c(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var s=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(n=null==s?void 0:s.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==s?void 0:s.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},s),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==s?void 0:s.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==s?void 0:s.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==s?void 0:s.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==s?void 0:s.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==s?void 0:s.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==s?void 0:s.cognitive_decisioning)}):c(l)}(),isOrphan:!!r}},[un,Z]),Nt=t.useCallback(function(e){Mn(),Cn(null),In(e)},[Mn]),jt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),En.open&&En.sectionIdx===o)Mn();else{var c=e.currentTarget,a="left";(null===(l=gn.current)||void 0===l?void 0:l.contains(c))&&(a="right");bt(),on.current&&St(),ze(new Set),Ye([]),nn.current=[],Fn(),On.open?mi():Nn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=ut.current[l])||void 0===e?void 0:e.current:null===(n=lt.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=ut.current[o])||void 0===t?void 0:t.current:null===(i=lt.current[o])||void 0===i?void 0:i.current}()||c;Tn(wt(e,n,i,o,t,r))})}},Pt=t.useCallback(function(){null!==En.sectionIdx&&En.anchorEl?Nt(e.__assign(e.__assign({},En),{open:!0})):Mn()},[En,Mn,Nt]),Ft=t.useCallback(function(){var e=En.sectionIdx,n=En.isOrphan;Mn(),Nn(),null!==e&&(n?Te("No counterpart exists to connect to."):(bt(),on.current&&St(),Ye([]),nn.current=[],ze(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){ln.current&&ln.current()},50)))},[En.sectionIdx,En.isOrphan,Mn,Nn,St]),Mt=t.useCallback(function(){var e=$e.current;if(e){$e.current=null;var n=Un.findIndex(function(n){return n.id===e}),t=Xn.findIndex(function(n){return n.id===e}),i=-1===n?u.findKeyPathByNodeId(Un,e):null,o=-1===t?u.findKeyPathByNodeId(Xn,e):null,r=-1!==n?n:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=function(e,n,t,i){var o,r,l,u;return-1!==e?null!==(r=null===(o=t.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=i.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,t){void 0===t&&(t=30);var i=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Je.current.add(r),u.scrollAndHighlightClause(r,n)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(he)-1!==r&&_n.current&&a(function(){return c(n,i,ot,at)},_n.current),-1!==l&&gn.current&&a(function(){return c(t,o,rt,st)},gn.current);else{var s=vn.current;if(!s)return;a(function(){return-1!==r?c(n,i,ot,at):c(t,o,rt,st)},s)}}},[Un,Xn,he,ot,rt,at,st,_n,gn,vn]),kt=t.useCallback(function(n){if(n){bt(),St(),ze(new Set),Ye([]),nn.current=[],Nn(),Fn();var t=Un.findIndex(function(e){return e.id===n}),i=Xn.findIndex(function(e){return e.id===n}),o=-1===t?u.findKeyPathByNodeId(Un,n):null,r=-1===i?u.findKeyPathByNodeId(Xn,n):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=-1!==i?i:r?Number(r.split("-")[0]):-1;$e.current=n,Bt(function(n){var t,i=e.__assign({},n),o=!1;-1!==l&&(i[t=he?"left-".concat(l):String(l)]||(i[t]=!0,o=!0));-1!==c&&(i[t=he?"right-".concat(c):String(c)]||(i[t]=!0,o=!0));return o?i:n}),Dt(function(n){var t=e.__assign({},n),i=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:n}),setTimeout(function(){requestAnimationFrame(function(){$e.current===n&&Lt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Un,Xn,he,Bt,Dt,St,Nn,Fn]),Lt=t.useRef(Mt);t.useEffect(function(){Lt.current=Mt},[Mt]);var Vt=t.useRef(null),Ht=t.useRef(null),qt=t.useRef(null),Gt=t.useRef(null),zt=t.useRef(null),Kt=t.useRef(null),Wt=t.useState([]),Yt=Wt[0],Ut=Wt[1];t.useRef(null);var Xt=t.useState(null),$t=Xt[0],Jt=Xt[1];t.useEffect(function(){if(Vn){var e=kn.fields.find(function(e){return e.analysisKey===Vn||e.key===Vn});if(e){var n=tt.current[e.key]||it.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Vn,kn.fields]);var Qt=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==pt?void 0:pt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[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===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[pt]),Zt=t.useCallback(function(n,t){var i,o,r;void 0===t&&(t="left");var l=null,c=null;if("left"===t)if(l=Un[n],he&&l){var s=Xn.filter(function(e){var n;return null===(n=l.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});c=s.find(function(e){return e.evaluationResult})||s[0]}else c=Xn[n];else if(c=Xn[n],he&&c){var d=Un.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)});l=d.find(function(e){return e.evaluationResult})||d[0]}else l=Un[n];var v=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,g=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!v&&!f&&!g)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==c?void 0:c.evaluationResult)&&void 0!==o?o:null,h=u.getFirstDeviationOutputValue(p),x=u.getFirstDeviationColor(p);return null!=p?e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null!==(r=h)&&void 0!==r?r:""}):e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null})},[Un,Xn,un,kn,he]),ei=t.useCallback(function(n){for(var t,i,o,r,l,c=n.split("-").map(Number),s=Un[c[0]],d=Xn[c[0]],v=1;v<c.length;v++)(null==s?void 0:s.subsections)&&(s=s.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!s&&!d)return null;var f=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,g=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=u.safeStringify(null==s?void 0:s.id)||u.safeStringify(null==d?void 0:d.id)||"",h=!(!(null==s?void 0:s.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!f&&!g&&!h)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=un[p])||void 0===o||o.relevance_score);var x=null!==(l=null!==(r=null==s?void 0:s.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,m=u.getFirstDeviationOutputValue(x),_=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null!=m?m:""}):e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null})},[Un,Xn,un,kn]),ni=t.useCallback(function(n,t){var i,o,r,l,c,s,d,v,f,g,p,h,x,m,_,y,R;if(!n||null==t)return null;var b=null!==(d=null!==(c=null!==(o=null===(i=null==ae?void 0:ae[n])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==Z?void 0:Z.nodes)||void 0===r?void 0:r[n])||void 0===l?void 0:l.evaluation_result)&&void 0!==c?c:null===(s=null==Z?void 0:Z[n])||void 0===s?void 0:s.evaluation_result)&&void 0!==d?d:null;if(!b||"object"!=typeof b)return null;var S=null!==(p=null!==(f=null===(v=null==b?void 0:b.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==b?void 0:b.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==b?void 0:b[t],A=null!==(R=null!==(m=null===(x=null===(h=null==S?void 0:S.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==m?m:null===(y=null===(_=null==b?void 0:b.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===y?void 0:y.label_color)&&void 0!==R?R:a.DEFAULT_DEVIAION_COLOR;return e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[ae,Z]),ti=t.useCallback(function(){bt(),Bt({}),Dt({}),St(),ze(new Set),Ye([]),nn.current=[],Nn(),Fn(),Mn(),requestAnimationFrame(function(){ln.current&&ln.current()})},[Bt,Dt,St,Nn,Fn,Mn]),ii=t.useMemo(function(){return Object.values(Tt).some(Boolean)||Object.values(Ct).some(Boolean)},[Tt,Ct]),oi=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p,h,x,m,_,y,R,b,S;if(!yn.current&&!Qe.current){yn.current=!0;try{if(!Vt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!Tt[t]&&!1===he)return!1;if(he&&!Tt["left-".concat(t)]&&!Tt["right-".concat(t)]&&!Tt[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!Ct[i])return!1;return!0},I=Vt.current.getBoundingClientRect();sn({width:I.width,height:I.height});var E=[];if($n.forEach(function(e){var n,t,i=e.key,o=null===(n=tt.current[i])||void 0===n?void 0:n.current,r=null===(t=it.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")}),!Qe.current){for(var T=0;T<Math.max(Un.length,Xn.length);T++){var B=null===(e=ot.current[T])||void 0===e?void 0:e.current,C=null===(n=rt.current[T])||void 0===n?void 0:n.current;B&&(B.style.height="auto",B.style.minHeight="0px"),C&&(C.style.height="auto",C.style.minHeight="0px")}he||Object.keys(at.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=at.current[e])||void 0===n?void 0:n.current,o=null===(t=st.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 D={};$n.forEach(function(e){var n,t,i=e.key,o=null===(n=tt.current[i])||void 0===n?void 0:n.current,r=null===(t=it.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var O={left:{},right:{}},w={};if(!Qe.current)if(he){if(Ce&&null!==Le)if("number"==typeof Le){var N=Le,j=Un[N],P=null===(o=ot.current[N])||void 0===o?void 0:o.current;P&&j&&(j.refIndexes||[]).forEach(function(e){var n,t=Xn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=rt.current[t])||void 0===n?void 0:n.current;if(i&&(Tt["left-".concat(N)]||Tt["right-".concat(t)])){var o=Math.max(P.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[N]=Math.max(O.left[N]||0,o),O.right[t]=Math.max(O.right[t]||0,o)}})}else{var F=Le.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(r=at.current[F])||void 0===r?void 0:r.current,C=null===(l=st.current[F])||void 0===l?void 0:l.current;if(B&&C){M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);w[F]=Math.max(w[F]||0,M)}}}}else{Object.keys(at.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=at.current[e])||void 0===n?void 0:n.current,o=null===(t=st.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(),u=Math.max(r.height,l.height);w[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(T=0;T<Math.min(Un.length,Xn.length);T++){var B=null===(t=ot.current[T])||void 0===t?void 0:t.current,C=null===(i=rt.current[T])||void 0===i?void 0:i.current;if(B&&C){var M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);O.left[T]=M,O.right[T]=M}}}if($n.forEach(function(e){var n,t,i=e.key,o=null===(n=tt.current[i])||void 0===n?void 0:n.current,r=null===(t=it.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Qe.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ot.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(O.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=rt.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),he||Object.keys(w).forEach(function(e){var n,t,i=null===(n=at.current[e])||void 0===n?void 0:n.current,o=null===(t=st.current[e])||void 0===t?void 0:t.current;if(i&&o&&w[e]){var r=w[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),he)Un.forEach(function(e,n){var t;(null===(t=ot.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,a,s,d,v=Xn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=lt.current[n])||void 0===t?void 0:t.current,g=null===(i=ut.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-I.left,m=h.left-I.left,_=p.top+p.height/2-I.top,y=h.top+h.height/2-I.top;if(Ce&&Le===n){var R=null!==(r=null===(o=_n.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,b=null!==(u=null===(l=gn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,S=R+(null!==(a=null===(c=_n.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=b+(null!==(d=null===(s=gn.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),T=p.top+p.height/2,B=h.top+h.height/2,C=function(e,n,t){return Math.max(n,Math.min(t,e))};_=C(T,R,S)-I.top,y=C(B,b,A)-I.top}var D=Zt(n);D&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:_,x2:m,y2:y,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(T=0;T<Math.min(Un.length,Xn.length);T++){var k=null===(c=ot.current[T])||void 0===c?void 0:c.current,L=null===(a=rt.current[T])||void 0===a?void 0:a.current;if(k&&L){var V=k.getBoundingClientRect(),H=L.getBoundingClientRect(),q=Math.max(V.top,H.top)+18-I.top,G=(null===(s=Xn[T])||void 0===s?void 0:s.id)||"sec-".concat(T);(J=Zt(T))&&E.push({id:G,x1:V.right-I.left,y1:q,x2:H.left-I.left,y2:q,style:J,sectionIdx:T,hasCognitive:!!((null===(d=Un[T])||void 0===d?void 0:d.cognitiveData)||(null===(v=Xn[T])||void 0===v?void 0:v.cognitiveData)||G&&un[G]),isSubSection:!1})}}Object.keys(at.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=at.current[e])||void 0===n?void 0:n.current,a=null===(t=st.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Un[s[0]],v=Xn[s[0]],f=1;f<s.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]);var g=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(r=v.displayTitle)||void 0===r||r)&&u.hasValue(v.title)),x=!!v&&((null===(l=v.displayContent)||void 0===l||l)&&u.hasValue(v.content));if(g&&p||h&&x){var m=c.getBoundingClientRect(),_=a.getBoundingClientRect(),y=Math.max(m.top,_.top)+16-I.top,R=ei(e);R&&"Not Defined"!==R.label&&E.push({id:"subsec-".concat(e),x1:m.right-I.left,y1:y,x2:_.left-I.left,y2:y,style:R,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(Ce&&"string"==typeof Le&&Le.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Le.split(u.DEVIATION_BADGE_SEPARATOR),K=z[0],W=z[1],Y=z[2],U=(z[3],"".concat(K).concat(u.DEVIATION_BADGE_SEPARATOR).concat(W)),X=null===(f=lt.current[U])||void 0===f?void 0:f.current,$=null===(g=ut.current[U])||void 0===g?void 0:g.current;if(X&&$){var J,Q=X.getBoundingClientRect(),Z=$.getBoundingClientRect(),ee=Q.right-I.left,ne=Z.left-I.left,te=Q.top+Q.height/2-I.top,ie=Z.top+Z.height/2-I.top;if(he){var oe=null!==(h=null===(p=_n.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(m=null===(x=gn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,le=oe+(null!==(y=null===(_=_n.current)||void 0===_?void 0:_.clientHeight)&&void 0!==y?y:1/0),ue=re+(null!==(b=null===(R=gn.current)||void 0===R?void 0:R.clientHeight)&&void 0!==b?b:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,le)-I.top,ie=ce(Z.top+Z.height/2,re,ue)-I.top}(J=null!==(S=ni(K,W))&&void 0!==S?S:ei(Y))&&E.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:Le})}}if(Ut(E),zt.current&&Kt.current){var ae=zt.current.getBoundingClientRect(),se=Kt.current.getBoundingClientRect(),de=(ae.top+ae.height/2-I.top+se.top+se.height/2-I.top)/2;Jt({x1:ae.right-I.left,x2:se.left-I.left,y:de})}else Jt(null);if(Ge.size>0){var ve=[],fe=_n.current,ge=gn.current;if(fe&&ge){var pe=[],xe=fe.getBoundingClientRect().top,me=ge.getBoundingClientRect().top,_e=xe+fe.clientHeight,ye=me+ge.clientHeight,Re=fe.scrollTop,be=ge.scrollTop,Se=I.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};Ge.forEach(function(e){var n,t,i,o,r,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var c=e.split(u.DEVIATION_BADGE_SEPARATOR),a=c[0],s=c[1],d=c[2],v=(c[3],"".concat(a).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=lt.current[v])||void 0===n?void 0:n.current,g=null===(t=ut.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=ni(a,s))&&void 0!==i?i:ei(d),m=(P=p.right-I.left)+.5*((F=h.left-I.left-0)-P),_=p.top+p.height/2,y=h.top+h.height/2,R=_-xe+Re,b=y-me+be,S="conn-subsec-".concat(v);pe.push({lhsScrollY:R,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var A=Ae(_,xe,_e),E=Ae(y,me,ye),T=A-Se,B=E-Se,C=y>=me-4&&y<=ye+4,D="";D=(M=_>=xe-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):M&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(he){var O=e,w=Un[O];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(e){var n,t,i=Xn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=lt.current[O])||void 0===n?void 0:n.current,r=null===(t=ut.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Zt(O),s=l.right-I.left,d=c.left-I.left-0,v=s+.5*(d-s),f=l.top+l.height/2,g=c.top+c.height/2,p=f-xe+Re,h=g-me+be,x="conn-".concat(O,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ae(f,xe,_e),_=Ae(g,me,ye),y=m-Se,R=_-Se,b=f>=xe-4&&f<=_e+4,S=g>=me-4&&g<=ye+4,A="";A=b&&S?u.getBentArrowPath(s,y,d,R):b&&!S?"M ".concat(s,",").concat(y," L ").concat(v,",").concat(y," L ").concat(v,",").concat(R):!b&&S?"M ".concat(v,",").concat(y," L ").concat(v,",").concat(R," L ").concat(d,",").concat(R):"M ".concat(v,",").concat(y," L ").concat(v,",").concat(R),ve.push({id:x,pathD:A,style:a,leftIdx:O,rhsArrayIdx:i})}}})}else{var N=e,j=N;f=null===(o=lt.current[N])||void 0===o?void 0:o.current,g=null===(r=ut.current[j])||void 0===r?void 0:r.current;if(!f||!g)return;var P,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=Zt(N),m=(P=p.right-I.left)+.5*((F=h.left-I.left-0)-P),_=p.top+p.height/2,y=h.top+h.height/2,R=_-xe+Re,b=y-me+be,S="conn-".concat(N,"-").concat(j);pe.push({lhsScrollY:R,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:N,rhsArrayIdx:j,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var M;A=Ae(_,xe,_e),E=Ae(y,me,ye),T=A-Se,B=E-Se,C=y>=me-4&&y<=ye+4,D="";D=(M=_>=xe-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):M&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:N,rhsArrayIdx:j})}}),nn.current=pe}Ye(ve)}else Ye([]),nn.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{yn.current=!1}}},[$n,Un,Xn,un,kn,Qt,Zt,ni,he,Ce,Le,Ge,Tt,Ct]),ri=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p=nn.current;if(p.length&&!Qe.current){var h=null!==(n=null===(e=_n.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=gn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(r=null===(o=_n.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,_=null!==(c=null===(l=gn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,y=null!==(s=null===(a=_n.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,R=null!==(v=null===(d=gn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,b=y+m,S=R+_,A=null!==(g=null===(f=Vt.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,I=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+y,t=e.rhsScrollY-x+R,i=en.current[e.styleId+"-stroke"],o=en.current[e.styleId+"-bg"];if(i||o){var r,l=I(n,y,b),c=I(t,R,S),a=l-A,s=c-A,d=n>=y-4&&n<=b+4,v=t>=R-4&&t<=S+4,f=e.x1+.5*(e.x2-e.x1);r=d&&v?u.getBentArrowPath(e.x1,a,e.x2,s):d&&!v?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(s):!d&&v?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){ln.current=oi},[oi]);var li=t.useRef(null),ui=t.useRef(null),ci=t.useCallback(function(){nn.current.length>0&&!Qe.current||(null!==li.current&&clearTimeout(li.current),li.current=setTimeout(function(){ln.current(),li.current=null},50))},[]),ai=t.useCallback(function(){Me(!0),je(!1),Xe.current=null,null!==ui.current&&clearTimeout(ui.current),null!==li.current&&(clearTimeout(li.current),li.current=null),ui.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s,d;try{if(nn.current=[],on.current&&null!==rn.current&&null!==qt.current){var v=rn.current,f=qt.current,g="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR),p=null,h=null,x=null,m=null;if(g){var _=v.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(_[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(_[1]);p=(null===(e=lt.current[y])||void 0===e?void 0:e.current)||null,h=(null===(n=ut.current[y])||void 0===n?void 0:n.current)||null,x=(null===(t=at.current[_[2]])||void 0===t?void 0:t.current)||(null===(i=ot.current[Number(_[2])])||void 0===i?void 0:i.current)||null,m=(null===(o=st.current[_[3]])||void 0===o?void 0:o.current)||(null===(r=rt.current[Number(_[3])])||void 0===r?void 0:r.current)||null}else p=(null===(l=dt.current[v])||void 0===l?void 0:l.current)||null,x=(null===(c=ot.current[v])||void 0===c?void 0:c.current)||null,h=(null===(a=ct.current[f])||void 0===a?void 0:a.current)||null,m=(null===(s=rt.current[f])||void 0===s?void 0:s.current)||null;if(p&&h&&x&&m){if(x.style.paddingTop="0px",m.style.paddingTop="0px",!he){var R=p.getBoundingClientRect(),b=h.getBoundingClientRect(),S=R.top-b.top;S>0?m.style.paddingTop="".concat(S,"px"):S<0&&(x.style.paddingTop="".concat(Math.abs(S),"px"))}var A=_n.current,I=gn.current;if(A&&I){var E=p.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop,T=h.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop-(E-A.scrollTop);Math.abs(I.scrollTop-T)>1&&(I.scrollTop=T)}}}null===(d=ln.current)||void 0===d||d.call(ln),on.current&&je(!0)}catch(e){console.error("Safely caught error during resize calculation:",e)}finally{Me(!1),ui.current=null}},150)},[he,Un,Xn]),si=t.useCallback(function(e){if(null!==Rn.current&&bn.current&&Math.abs(e.currentTarget.scrollTop-Rn.current)<=2){var n=bn.current;Rn.current=null,bn.current=null,n()}He.current||(he||ci(),tn.current||(tn.current=!0,requestAnimationFrame(function(){var e,n,t,i,o,r,l;if(on.current){var c=_n.current,a=gn.current;if(c&&a&&Gt.current){if(!Xe.current){var s=rn.current,d=void 0;if("string"==typeof s&&s.includes(u.DEVIATION_BADGE_SEPARATOR)){var v=s.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(v[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(v[1]);d=null===(e=lt.current[f])||void 0===e?void 0:e.current}else d=null===(n=lt.current[s])||void 0===n?void 0:n.current;if(d){var g=d.getBoundingClientRect();Xe.current={badgeScreenY:g.top+g.height/2,initialScrollTop:c.scrollTop,leftTop:c.getBoundingClientRect().top,leftBottom:c.getBoundingClientRect().top+c.clientHeight,cTop:null!==(i=null===(t=Vt.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(Xe.current){var p=Xe.current,h=c.scrollTop-p.initialScrollTop,x=p.badgeScreenY-h,m=((o=x,r=p.leftTop,l=p.leftBottom,Math.max(r,Math.min(l,o)))-p.cTop).toString(),_=x>=p.leftTop-4&&x<=p.leftBottom+4;Gt.current.setAttribute("y1",m),Gt.current.setAttribute("y2",m),Gt.current.setAttribute("visibility",_?"visible":"hidden")}}}nn.current.length>0&&ri(),tn.current=!1})))},[ri,he,ci]),di=t.useRef(0),vi=t.useRef(0),fi=t.useRef(0),gi=t.useRef(function(){});t.useRef(null),t.useEffect(function(){gi.current=ai},[ai]),t.useEffect(function(){var e=setTimeout(ci,250),n=function(){return gi.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==li.current&&clearTimeout(li.current),null!==ui.current&&clearTimeout(ui.current),window.removeEventListener("resize",n)}},[Wn,Yn,pt,$n,Tt,Ct,Un,Xn,kn,ci,Ce,Le,Ne,Ge]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return r.observe(e),r},n={current:null},t={current:null},i={current:null},o=[],r=[n,t,i];return fn.current&&o.push(e(fn.current,di,n,function(){return gi.current()},function(){})),vn.current&&o.push(e(vn.current,vi,t,function(){return gi.current()},function(){return ln.current()})),Vt.current&&o.push(e(Vt.current,fi,i,function(){return gi.current()},function(){return ln.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){on.current=Ce},[Ce]),t.useEffect(function(){rn.current=Le},[Le]);var pi=t.useCallback(function(e,n,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,c=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";Mn(),null!=e&&(n?Te("No counterpart exists for this section."):(bt(),Ce&&Le===e?r?St():null==l||l():(ze(new Set([e])),Ye([]),nn.current=[],Ae(!0),He.current=!0,Ve(e),rn.current=e,De(!0),on.current=!0,je(!1),pn.current&&(pn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,a="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=null,d=null,v=null;if(a){var f=e.split(u.DEVIATION_BADGE_SEPARATOR),g="".concat(f[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f[1]);s=(null===(n=lt.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=ut.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=dt.current[e])||void 0===i?void 0:i.current)||null,he){var p=Un[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],m=Xn.findIndex(function(e){return e.selfIndex===x});-1!==m&&(d=(null===(r=ct.current[m])||void 0===r?void 0:r.current)||null,v=m)}}else d=(null===(o=ct.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;qt.current=v;var _=_n.current,y=gn.current,R=function(){!function(){var n,t,i,o,r,l,c,s,d,f,g,p,h=null,x=null,m=null,_=null;if(a){var y=e.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);h=(null===(n=at.current[y[2]])||void 0===n?void 0:n.current)||(null===(t=ot.current[Number(y[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=st.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=rt.current[Number(y[3])])||void 0===o?void 0:o.current)||null,m=(null===(r=lt.current[R])||void 0===r?void 0:r.current)||h,_=(null===(l=ut.current[R])||void 0===l?void 0:l.current)||x}else{var b=Number(e),S=null!==v?Number(v):b;h=(null===(c=ot.current[b])||void 0===c?void 0:c.current)||null,x=(null===(s=rt.current[S])||void 0===s?void 0:s.current)||null,m=(null===(d=lt.current[b])||void 0===d?void 0:d.current)||(null===(f=dt.current[b])||void 0===f?void 0:f.current)||h,_=(null===(g=ut.current[S])||void 0===g?void 0:g.current)||(null===(p=ct.current[S])||void 0===p?void 0:p.current)||x}if(m&&_&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=m.getBoundingClientRect(),I=_.getBoundingClientRect(),E=A.top-I.top;E>0?x.style.paddingTop="".concat(E,"px"):E<0&&(h.style.paddingTop="".concat(Math.abs(E),"px"))}}(),je(!0),ln.current&&ln.current(),He.current=!1,"right"===c&&y?y.dispatchEvent(new Event("scroll")):_&&_.dispatchEvent(new Event("scroll")),Ae(!1),null==l||l()};if(!s||!_)return He.current=!1,Ae(!1),void(null==l||l());if(d&&y){if(!he){var b=0;b="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var S=vn.current,A=(null==S?void 0:S.getBoundingClientRect().top)||0,I=S?S.scrollTop+b-A-150:0;return S?void u.smoothScrollTo(S,I,200,R):void R()}var E=s.getBoundingClientRect().top-_.getBoundingClientRect().top+_.scrollTop,T=d.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,B=200;if("left"===c){var C=T-(E-_.scrollTop);C<0&&pn.current&&(pn.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=y.scrollHeight-y.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return hn.current&&(hn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(y,C,B,R)})}e=C}u.smoothScrollTo(y,e,B,R)})}else{var D=E-(T-y.scrollTop);D<0&&xn.current&&(xn.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=_.scrollHeight-_.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return mn.current&&(mn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(_,D,B,R)})}e=D}u.smoothScrollTo(_,e,B,R)})}}else R()}))))},[Le,Mn,Xn,Ce,he,Un,St]),hi=t.useCallback(function(e,n,t,i,o){var r,l="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),c=e.currentTarget;Fn();var a="left";(null===(r=gn.current)||void 0===r?void 0:r.contains(c))&&(a="right");var s=function(){var e,t,i,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=ut.current[l])||void 0===e?void 0:e.current:null===(t=lt.current[l])||void 0===t?void 0:t.current}return"right"===a?null===(i=ut.current[n])||void 0===i?void 0:i.current:null===(o=lt.current[n])||void 0===o?void 0:o.current};if(t)return St(),ze(new Set),Ye([]),nn.current=[],void(l&&requestAnimationFrame(function(){var e=s()||c;wn({open:!0,anchorEl:e,summary:i,displayImpact:o})}));pi(n,t,l?{toggleIfSame:!1,sourceSide:a,onReady:function(){var e=s()||c;wn({open:!0,anchorEl:e,summary:i,displayImpact:o})}}:{toggleIfSame:!1,sourceSide:a})},[pi,Fn,wn,St]),xi=t.useCallback(function(){var e,n=En.sectionIdx,t=En.isOrphan;if(Nn(),null!=n){var i="left";En.anchorEl&&(null===(e=gn.current)||void 0===e?void 0:e.contains(En.anchorEl))&&(i="right"),pi(n,t,{sourceSide:i})}},[pi,En.isOrphan,En.sectionIdx,En.anchorEl,Nn]),mi=t.useCallback(function(){Nn(),St(),ze(new Set),Ye([]),nn.current=[]},[Nn,St]),_i=null!==En.sectionIdx&&Ge.has(En.sectionIdx),yi=m.useDeviationNavigation({proposedSections:Un,existingSections:Xn,parentDeviationRecord:Jn,expandedSections:Tt,maintainRelativeOrder:!!he,scrollContainerRef:vn,leftContainerRef:_n,lhsBadgeRefs:lt,rhsBadgeRefs:ut}),Ri=yi.showDeviationNavigation,bi=yi.showOpenNodeRef,Si=t.useMemo(function(){var e;if(!se)return null;var n=null===(e=null==se?void 0:se.id)||void 0===e?void 0:e.split(":")[0];for(var t in Jn){if((Jn[t]||[]).some(function(e){return e.id===n}))return t}return null},[se,Jn]),Ai=t.useRef({id:null,triggerMs:null}),Ii=t.useRef(null);t.useEffect(function(){var n;if(null==se?void 0:se.id){var t=Number(se.trigger),i=Ai.current;if((null==i?void 0:i.triggerMs)!==t){if(!(se.id.includes(":")&&/:\d+$/.test(se.id)))return Ai.current={id:se.id,triggerMs:t},void kt(se.id);var o=null===(n=null==se?void 0:se.id)||void 0===n?void 0:n.split(":"),r=o[0],l=o[1],c=null!=l?l:"0";Ii.current!==se.id&&(Nn(),Fn(),St(),ze(new Set),Ye([]),nn.current=[],Ii.current=se.id);var a=!1,s=0,d=null,v=150,f=function(e,n){for(var t=function(e,i){if(!e)return null;if(e.id===n)return i;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=t(e.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<e.length;i++){var o=t(e[i],String(i));if(o)return o}return null},g=function(){var n,i,o,l;if(!a){var p=function(){Ai.current={id:se.id,triggerMs:t}},h=null,x=null;for(var m in Jn){var _=Jn[m].find(function(e){return e.id===r});if(_){h=m,x=_;break}}if(x&&h){var y=Un.findIndex(function(e){return e.id===h}),R=Xn.findIndex(function(e){return e.id===h}),b=-1===y&&-1!==R,S=f(Un,x.id),A=f(Xn,x.id);if(S&&!A&&!b){var I=S.split("-"),E=Number(I[0]);if(he){var T=null===(i=null===(n=Un[E])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],B=Xn.findIndex(function(e){return e.selfIndex===T});-1!==B&&(E=B)}A=e.__spreadArray([E],I.slice(1),!0).join("-")}if(S||A){var C=b||!S&&!!A,D=S?Number(S.split("-")[0]):y,O=A?Number(A.split("-")[0]):R;if(C){if(!(he?!!Tt["right-".concat(O)]:!!Tt[String(O)])&&O>=0)return Ot(O,"right"),s+=1,void(d=setTimeout(g,450))}else if(!(he?!!Tt["left-".concat(D)]:!!Tt[String(D)])&&D>=0)return Ot(D,"left"),s+=1,void(d=setTimeout(g,450));var w,N=S||"",j=A||"",P="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(N).concat(u.DEVIATION_BADGE_SEPARATOR).concat(j),F="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c),M=null===(o=lt.current[F])||void 0===o?void 0:o.current,k=null===(l=ut.current[F])||void 0===l?void 0:l.current,L=C||!M&&!!k,V=L?k:M;if(w=he?L?gn.current:_n.current:vn.current,V&&w){var H=V.getBoundingClientRect();if(0===H.height)return void((s+=1)<2?d=setTimeout(g,v):p());var q=w.getBoundingClientRect(),G=H.top-q.top+w.scrollTop-q.height/2+H.height/2+150,z=function(){var n,t,i,o,r;if(!a){p();var l=V instanceof Element?window.getComputedStyle(V).color:"";M&&(M.style.transition="box-shadow 300ms ease-in-out",M.style.boxShadow="0 0 10px ".concat(l)),k&&(k.style.transition="box-shadow 300ms ease-in-out",k.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){M&&(M.style.boxShadow=""),k&&(k.style.boxShadow="")},2e3);var u=(null===(t=null===(n=x.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[c])||x,s=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!M&&!!k)){var d=L?(null===(o=ut.current[F])||void 0===o?void 0:o.current)||k:(null===(r=lt.current[F])||void 0===r?void 0:r.current)||M;return wn({open:!0,anchorEl:d,displayImpact:se.displayImpact,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})}),void(null==de||de())}pi(P,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=lt.current[F])||void 0===n?void 0:n.current)||M;console.log("Summary data",s,u),wn({open:!0,anchorEl:t,displayImpact:null==se?void 0:se.displayImpact,summary:e.__assign({},u)})}})}};Math.abs(w.scrollTop-G)<=2?z():(Rn.current=G,bn.current=z,w.scrollTo({top:G,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(bn.current){Rn.current=null;var e=bn.current;bn.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}};return d=setTimeout(g,v),function(){a=!0,d&&clearTimeout(d)}}}},[se,Jn,Un,Xn,he,Tt,Ot,pi,wn,kt]);var Ei=function(e){var t=e.section,i=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c;return n.jsx(R.default,{section:t,keyPath:i,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:Ct,setExpandedSubSections:Dt,maintainRelativeOrder:he||!1,proposedSections:Un,existingSections:Xn,treeData:Z,deviationNumberRegistry:Qn,connectedSections:Ge,activeSideBySideSection:Le,resolvedMarkdownStyles:dn,getSubSectionRef:ft,getSubSectionCompareStyle:ei,getBadgeRef:gt,openMoreFunctionsPopup:jt,openSummaryPopup:hi,showDeviationBadges:me,resetSideBySide:St,setConnectedSections:ze,setConnectedLines:Ye,cachedConnectedPositions:nn,isProposingFix:fe,proposingFixNodeId:ge})};return n.jsxs(i.Box,e.__assign({ref:fn,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},he?{}:{overflow:"visible"}),{position:"relative"})},{children:[ye&&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,{})})),On.open&&n.jsx(b.default,{open:On.open,anchorEl:On.anchorEl,containerEl:Ht.current,clipTopEl:zt.current,scrollContainerEl:vn.current,onClose:mi,summary:On.summary,displayImpact:On.displayImpact}),n.jsx(d.default,{open:En.open,anchorEl:En.anchorEl,sectionTitle:En.sectionTitle,referenceSectionTitle:En.refSectionTitle,onClose:Mn,onOpenCognitiveCompare:Pt,onOpenSideBySide:xi,onConnect:Ft,isConnected:_i,isOrphan:En.isOrphan}),An.open&&n.jsx(s.default,{open:An.open,popupRef:Pn,position:Bn,popupConfig:ue,onClose:function(){Cn(null),In(function(n){return e.__assign(e.__assign({},n),{open:!1})}),jn(null)},markdownStyles:ie,sectionTitle:An.sectionTitle,referenceSectionTitle:An.refSectionTitle,cognitiveData:An.cognitiveData,anchorEl:An.anchorEl,sectionAnchorEl:An.sectionAnchorEl,scrollContainerEl:vn.current,badgeStyle:An.badgeStyle,docData:An.docData,deviationData:An.deviationData,isLoading:An.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!Ee,autoHideDuration:8e3,onClose:function(){return Te(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Te(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Ee}))})),n.jsx(_.default,{componentHeaderText:Q,displayConfig:le,maintainRelativeOrder:he,onCollapseAll:ti,showCollapseAll:ii,onToggleView:function(e){Re(!0),setTimeout(function(){xe(!e),St(),Nn(),ze(new Set),Ye([]),nn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){Re(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:vn,onScroll:si,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:he?"hidden":"auto",borderTop:ht&&xt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},he?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Vt,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},he?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Ue,style:{position:"absolute",top:0,left:0,width:an.width||"100%",height:an.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Fe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[$t&&n.jsx("g",{children:n.jsx("line",{x1:$t.x1,y1:$t.y,x2:$t.x2,y2:$t.y,stroke:Rt.badgeBorder,strokeWidth:"1.5"})}),Yt.map(function(t){var l,c,s,d,v,g,p=t.x1+.5*(t.x2-t.x1),h=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?Ce&&Le===t.subSectionKeyPath&&Ne:Ce&&Le===t.sectionIdx&&Ne)return null;if(!he){var x=t.isSubSection?u.getBentArrowPath(t.x1,t.y1,t.x2,t.y2):"M ".concat(t.x1," ").concat(t.y1," L ").concat(t.x2," ").concat(t.y2),m=Un[t.sectionIdx]||{title:"",content:""},_=Xn[t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",m,_),t.isSubSection&&t.subSectionKeyPath){var y=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],R=y[2]||t.subSectionKeyPath,b=y[3]||R,S=R.split("-").map(Number),A=b.split("-").map(Number),I=null,E=null;S.length>0&&(I=Un[S[0]]),A.length>0&&(E=Xn[A[0]]);var T=(null==I?void 0:I.title)||"",B=(null==E?void 0:E.title)||"";console.log("Root Parent Titles:",T,B);for(var C=1;C<S.length;C++)(null==I?void 0:I.subsections)&&(I=I.subsections[S[C]]);for(C=1;C<A.length;C++)(null==E?void 0:E.subsections)&&(E=E.subsections[A[C]]);I&&(m=e.__assign(e.__assign({},I),{title:T||I.title})),console.log("Base Section for Subsection Badge:",m),E&&(_=e.__assign(e.__assign({},E),{title:B||E.title})),console.log("Ref Section for Subsection Badge:",_)}var D=!(null===(l=m.cognitiveData)||void 0===l?void 0:l.isMissingRationale)||Boolean(null===(s=null===(c=m.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===s?void 0:s.length),O=(null===(g=null===(v=null===(d=m.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===g?void 0:g.length)||!1,w=D||O;return n.jsxs("g",{children:[n.jsx("path",{d:x,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:p-100,y:h-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n.jsxs(i.Box,e.__assign({onClick:function(e){e.stopPropagation(),w&&(An.open&&Dn===t.id?Fn():(jn(t.id),Nt(wt(e.currentTarget,m,_,t.sectionIdx,t.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:t.style.badgeBg,color:t.style.badgeText,border:"1px solid ".concat(t.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:w?"pointer":"default"}},{children:[t.style.badgeText===a.DEFAULT_DEVIAION_COLOR&&null==t.style.label?n.jsx(f.default,{color:t.style.badgeText}):0===t.style.label?"Same":t.style.label,n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),w&&n.jsx(o.ChevronDown,{size:11,style:{transform:An.open&&Dn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),n.jsx(S.default,{connectedLines:We,pathRefs:en})]})),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)"},he?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:zt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:n.jsx(i.Tooltip,e.__assign({title:Gn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Gn}))}))})),n.jsxs(i.Box,e.__assign({ref:_n,onScroll:si,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},he?{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:xn,style:{width:"100%",height:"0px",flexShrink:0}}),et&&Un.map(function(t,r){var l,c,a=!t.title&&!t.content;if(he&&a)return null;var s=t,d=Zt(r,"left"),v=he?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Xn[r],g=he?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=Ge.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:vt(r),sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:ot.current[r],sx:e.__assign({width:"100%",display:"flex",flexDirection:"column",minWidth:0},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n.jsx(y.default,{section:t,idx:r,columnKey:"left",colRef:vt("left-accordion-".concat(r)),mb:0,treeData:Z,proposedSections:Un,existingSections:Xn,deviationNumberRegistry:Qn,getSectionCompareStyle:Zt,getBadgeRef:gt,connectedSections:Ge,openMoreFunctionsPopup:jt,openSummaryPopup:hi,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Si,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:he?!!Tt["left-".concat(r)]:!!Tt[String(r)],onToggle:function(){mi(),Ot(r,"left")},navigation:t.id?Ri[t.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:dn,maintainRelativeOrder:he,showDeviationBadges:me,renderSubSections:Ei,isProposingFix:fe,proposingFixNodeId:ge,collisionKey:"".concat(Ce?"1":"0","-").concat(String(null!=Le?Le:""))})})),he&&d&&n.jsxs(i.Box,e.__assign({ref:lt.current[r],onClick:function(e){var n,t,i,o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=s.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=s.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;hi(e,String(r),v,o)},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:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,t,i;e.stopPropagation();var o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=s.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=s.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;hi(e,String(r),v,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:v?"default":"pointer",borderRight:"1px solid ".concat(d.badgeBorder),"&:hover":v?{}:{bgColor:"".concat(d.badgeBorder,"22")}}},{children:[null!=g&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:g})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!le.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(f.default,{color:d.badgeText})}))]})),n.jsx(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=he?Xn.find(function(e){var n;return(null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e))||{title:"",content:""}}):Xn[r]||{title:"",content:""};jt(e,t,v,n,r,d)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(d.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})}))]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:mn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:Ht,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){n.stopPropagation(),An.open&&Dn===mt?Fn():(jn(mt),Nt(wt(n.currentTarget,{title:"",content:"",evaluationResult:_t,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,mt,!0,e.__assign(e.__assign({},Rt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Rt.badgeBg,color:Rt.badgeText,border:"1px solid ".concat(Rt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=yt?yt:n.jsx(f.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:An.open&&Dn===mt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},he?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Se&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Kt,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:zn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:zn}))}))})),n.jsxs(i.Box,e.__assign({ref:gn,onScroll:si,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},he?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:pn,style:{width:"100%",height:"0px",flexShrink:0}}),et&&Xn.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(he){u=Un.filter(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0}).map(function(e){return e.selfIndex+1}),s=Un.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=Un.findIndex(function(e,n){var t;return Ge.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=Zt(d))}else u=[o+1],(c=Ge.has(o))&&(a=Zt(o));var v=Zt(he&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:ct.current[o],sx:{mb:1,width:"100%"}},{children:n.jsxs(i.Box,e.__assign({sx:{position:"relative",width:"100%"}},{children:[n.jsx(i.Box,e.__assign({ref:rt.current[o],sx:e.__assign({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(y.default,{section:t,idx:o,columnKey:"right",colRef:vt("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==Z?void 0:Z.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:he?!!Tt["right-".concat(o)]:!!Tt[String(o)],treeData:Z,proposedSections:Un,existingSections:Xn,deviationNumberRegistry:Qn,getBadgeRef:gt,getSectionCompareStyle:Zt,connectedSections:Ge,openMoreFunctionsPopup:jt,openSummaryPopup:hi,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Si,onToggle:function(){mi(),Ot(o,"right")},navigation:t.id?Ri[t.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:dn,maintainRelativeOrder:he,showDeviationBadges:me,renderSubSections:Ei,isProposingFix:fe,proposingFixNodeId:ge,collisionKey:"".concat(Ce?"1":"0","-").concat(String(null!=Le?Le:""))})})),he&&v&&n.jsx(i.Box,e.__assign({ref:ut.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:v.badgeBg,color:v.badgeText,border:"1px solid ".concat(v.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),n.jsx("div",{ref:hn,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});exports.ARROW_SIZE=10,exports.DEFAULT_COMPONENT_HEADER_TEXT="Contract Comparison",exports.DEFAULT_DEVIAION_COLOR="#3730A3",exports.EMPTY_SECTION_POPUP_STATE={isLoading:!1,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},exports.EMPTY_SUMMARY_POPUP_STATE={open:!1,anchorEl:null,summary:"",markdownStyles:{}},exports.POPUP_GAP=12,exports.POPUP_WIDTH=680,exports.VIEWPORT_MARGIN=12;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.ARROW_SIZE=10,exports.DEFAULT_COMPONENT_HEADER_TEXT="Contract Comparison",exports.DEFAULT_DEVIAION_COLOR="#3730A3",exports.EMPTY_SECTION_POPUP_STATE={isLoading:!1,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},exports.EMPTY_SUMMARY_POPUP_STATE={open:!1,anchorEl:null,summary:"",markdownStyles:{},displayImpact:!1},exports.POPUP_GAP=12,exports.POPUP_WIDTH=680,exports.VIEWPORT_MARGIN=12;
2
2
  //# sourceMappingURL=CognitiveCompareConstants.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("@mui/material"),i=require("lucide-react"),o=require("react");exports.default=function(r){var l,a,s,d=r.open,c=r.anchorEl,u=r.containerEl,p=r.clipTopEl,f=r.scrollContainerEl,x=r.onClose,m=r.summary;r.markdownStyles,r.isLoading;var h=o.useRef(null),g=o.useRef(null),v=o.useState(null),y=v[0],b=v[1],_=o.useState(null),w=_[0],S=_[1],j=o.useState(null);j[0];var C=j[1],B=o.useState(0),I=B[0],R=B[1],z="string"==typeof m?{deviation_summary:m}:null!=m?m:{},E=z.deviation_title,F=z.deviation_summary,W=z.deviation_impact,A=z.evaluation_outputs,T=!!String(W||"").trim(),H=(null===(l=null==A?void 0:A.metadata)||void 0===l?void 0:l.label_color)||"#6366F1",M=null!==(a=null==u?void 0:u.getBoundingClientRect().width)&&void 0!==a?a:180,P=Math.max(148,M+120),k=o.useMemo(function(){if(!c||!u)return null;var e=c.getBoundingClientRect();if(0===e.width&&0===e.height)return null;var n=u.getBoundingClientRect();return{top:e.top,bottom:e.bottom,left:n.left+n.width/2}},[c,u]);o.useEffect(function(){if(!d||!c||!u)return b(null),S(null),void C(null);var e=function(){null!==h.current&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(function(){var e,n,t=c.getBoundingClientRect(),i=null==p?void 0:p.getBoundingClientRect(),o=null==f?void 0:f.getBoundingClientRect();if(0===t.width&&0===t.height)b(null);else{var r=u.getBoundingClientRect();b({top:t.top,bottom:t.bottom,left:r.left+r.width/2})}S(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),C(null!==(n=null==o?void 0:o.bottom)&&void 0!==n?n:null),g.current&&R(g.current.offsetHeight)})};return e(),window.addEventListener("scroll",e,{passive:!0,capture:!0}),window.addEventListener("resize",e),function(){null!==h.current&&cancelAnimationFrame(h.current),window.removeEventListener("scroll",e,{capture:!0}),window.removeEventListener("resize",e)}},[d,c,u,p,f]);var q=null!==(s=null!=y?y:k)&&void 0!==s?s:"hidden",L="hidden"===q?"hidden":q.bottom+20,O=null!=w&&"number"==typeof L&&L<w?Math.min(I,w-L):0,D=o.useMemo(function(){return"hidden"===q?{getBoundingClientRect:function(){return{width:0,height:0,top:0,bottom:0,left:0,right:0,x:0,y:0,toJSON:function(){}}}}:{getBoundingClientRect:function(){return{width:0,height:q.bottom-q.top,top:q.top,bottom:q.bottom,left:q.left,right:q.left,x:q.left,y:q.top,toJSON:function(){}}}}},[q]);return m?n.jsx(t.Popper,e.__assign({open:d,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:D,placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}},{name:"preventOverflow",enabled:!0,options:{boundary:f||"clippingParents",tether:!1}},{name:"flip",enabled:!0,options:{boundary:f||"clippingParents",fallbackPlacements:["top"]}}],sx:{zIndex:21,visibility:"hidden"===q?"hidden":"visible",opacity:"hidden"===q?0:1,transition:"opacity 0.15s ease-in-out"}},{children:n.jsxs(t.Paper,e.__assign({ref:g,sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:P,maxWidth:P},O>0&&{clipPath:"inset(".concat(O,"px 0px 0px 0px round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(H,"26"),borderTop:"3px solid ".concat(H),overflow:"hidden",bgcolor:"#fff"})},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[n.jsx(i.Info,{size:14,color:H}),n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:H,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),n.jsx(t.IconButton,e.__assign({size:"small",onClick:x,sx:{p:.25,ml:.5,color:"#64748B"}},{children:n.jsx(i.X,{size:14})}))]})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[n.jsxs(t.Box,{children:[E&&n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#334155",fontFamily:'"Inter", sans-serif',lineHeight:1.6,fontWeight:700,overflowWrap:"anywhere"}},{children:E})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",color:"#334155",lineHeight:1.6,fontFamily:'"Inter", sans-serif',fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:F||"No summary available."}))]}),T&&n.jsxs(t.Accordion,e.__assign({disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(H,"0A"),border:"1px solid ".concat(H,"33"),borderRadius:"4px",fontFamily:'"Inter", sans-serif',overflow:"hidden",flexShrink:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:n.jsx(i.ChevronDown,{size:16,color:H}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(H,"1A")}}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:H,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),n.jsx(t.AccordionDetails,e.__assign({sx:{p:1.5,backgroundColor:"#fff"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",color:"#475569",lineHeight:1.6,fontWeight:400,fontFamily:'"Inter", sans-serif',overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(W).replace("Impact -","").trim()}))}))]}))]}))]}))})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("@mui/material"),i=require("lucide-react"),o=require("react");exports.default=function(r){var l,a,s,d=r.open,c=r.anchorEl,u=r.containerEl,p=r.clipTopEl,f=r.scrollContainerEl,x=r.onClose,m=r.summary;r.markdownStyles,r.isLoading;var h=r.displayImpact,g=o.useRef(null),v=o.useRef(null),y=o.useState(null),b=y[0],_=y[1],w=o.useState(null),S=w[0],j=w[1],C=o.useState(null);C[0];var B=C[1],I=o.useState(0),R=I[0],z=I[1],E="string"==typeof m?{deviation_summary:m}:null!=m?m:{},F=E.deviation_title,W=E.deviation_summary,A=E.deviation_impact,T=E.evaluation_outputs,H=!!String(A||"").trim(),M=(null===(l=null==T?void 0:T.metadata)||void 0===l?void 0:l.label_color)||"#6366F1",P=null!==(a=null==u?void 0:u.getBoundingClientRect().width)&&void 0!==a?a:180,k=Math.max(148,P+120),q=o.useMemo(function(){if(!c||!u)return null;var e=c.getBoundingClientRect();if(0===e.width&&0===e.height)return null;var n=u.getBoundingClientRect();return{top:e.top,bottom:e.bottom,left:n.left+n.width/2}},[c,u]);o.useEffect(function(){if(!d||!c||!u)return _(null),j(null),void B(null);var e=function(){null!==g.current&&cancelAnimationFrame(g.current),g.current=requestAnimationFrame(function(){var e,n,t=c.getBoundingClientRect(),i=null==p?void 0:p.getBoundingClientRect(),o=null==f?void 0:f.getBoundingClientRect();if(0===t.width&&0===t.height)_(null);else{var r=u.getBoundingClientRect();_({top:t.top,bottom:t.bottom,left:r.left+r.width/2})}j(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),B(null!==(n=null==o?void 0:o.bottom)&&void 0!==n?n:null),v.current&&z(v.current.offsetHeight)})};return e(),window.addEventListener("scroll",e,{passive:!0,capture:!0}),window.addEventListener("resize",e),function(){null!==g.current&&cancelAnimationFrame(g.current),window.removeEventListener("scroll",e,{capture:!0}),window.removeEventListener("resize",e)}},[d,c,u,p,f]);var L=null!==(s=null!=b?b:q)&&void 0!==s?s:"hidden",O="hidden"===L?"hidden":L.bottom+20,D=null!=S&&"number"==typeof O&&O<S?Math.min(R,S-O):0,N=o.useMemo(function(){return"hidden"===L?{getBoundingClientRect:function(){return{width:0,height:0,top:0,bottom:0,left:0,right:0,x:0,y:0,toJSON:function(){}}}}:{getBoundingClientRect:function(){return{width:0,height:L.bottom-L.top,top:L.top,bottom:L.bottom,left:L.left,right:L.left,x:L.left,y:L.top,toJSON:function(){}}}}},[L]);return m?n.jsx(t.Popper,e.__assign({open:d,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:N,placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}},{name:"preventOverflow",enabled:!0,options:{boundary:f||"clippingParents",tether:!1}},{name:"flip",enabled:!0,options:{boundary:f||"clippingParents",fallbackPlacements:["top"]}}],sx:{zIndex:21,visibility:"hidden"===L?"hidden":"visible",opacity:"hidden"===L?0:1,transition:"opacity 0.15s ease-in-out"}},{children:n.jsxs(t.Paper,e.__assign({ref:v,sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:k,maxWidth:k},D>0&&{clipPath:"inset(".concat(D,"px 0px 0px 0px round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(M,"26"),borderTop:"3px solid ".concat(M),overflow:"hidden",bgcolor:"#fff"})},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[n.jsx(i.Info,{size:14,color:M}),n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:M,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),n.jsx(t.IconButton,e.__assign({size:"small",onClick:x,sx:{p:.25,ml:.5,color:"#64748B"}},{children:n.jsx(i.X,{size:14})}))]})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[n.jsxs(t.Box,{children:[F&&n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#334155",fontFamily:'"Inter", sans-serif',lineHeight:1.6,fontWeight:700,overflowWrap:"anywhere"}},{children:F})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",color:"#334155",lineHeight:1.6,fontFamily:'"Inter", sans-serif',fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:W||"No summary available."}))]}),H&&n.jsxs(t.Accordion,e.__assign({expanded:h,disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(M,"0A"),border:"1px solid ".concat(M,"33"),borderRadius:"4px",fontFamily:'"Inter", sans-serif',overflow:"hidden",flexShrink:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[n.jsx(t.AccordionSummary,e.__assign({expandIcon:n.jsx(i.ChevronDown,{size:16,color:M}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(M,"1A")}}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:M,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),n.jsx(t.AccordionDetails,e.__assign({sx:{p:1.5,backgroundColor:"#fff"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",color:"#475569",lineHeight:1.6,fontWeight:400,fontFamily:'"Inter", sans-serif',overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(A).replace("Impact -","").trim()}))}))]}))]}))]}))})):null};
2
2
  //# sourceMappingURL=CognitiveSummaryPopup.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),n=require("react/jsx-runtime"),e=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CognitiveComparehelpers.js"),r=require("../CognitiveCompareConstants.js");function a(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var s=a(e);exports.default=function(a){var u,c,v,f,p,x,g,h,m,_,I,y,b,w,A=a.section,S=a.idx,R=a.columnKey,j=a.colRef,C=a.mb,F=void 0===C?1:C,O=a.parentNodeId,B=void 0===O?"":O,E=a.isExpanded,D=a.onToggle,T=a.navigation,k=a.showOpenNodeRef,M=a.resolvedMarkdownStyles,P=a.maintainRelativeOrder,N=a.showDeviationBadges,V=void 0!==N&&N,W=a.renderSubSections,q=a.treeData,G=a.proposedSections,z=void 0===G?[]:G,K=a.existingSections,L=void 0===K?[]:K,U=a.deviationNumberRegistry,X=void 0===U?{}:U,Y=a.getBadgeRef,H=a.openSummaryPopup,J=a.getSectionCompareStyle,Q=a.connectedSections,Z=a.openMoreFunctionsPopup;a.deviationNodeIdToView,a.deviationTargetParentId;var $=a.isProposingFix,ii=a.proposingFixNodeId,ni=a.collisionKey,ei=(null===(u=A.displayTitle)||void 0===u||u)&&d.hasValue(A.title),oi=A.change_history,ti=!!$&&!!ii&&"left"===R&&A.id===ii&&d.hasValue(oi),li=ti?oi||"":A.content,di=ti?A.content:void 0,ri=(null===(c=A.displayContent)||void 0===c||c)&&d.hasValue(li),ai=!ei&&!ri,si={current:1},ui=A.title;ei||(ui=ri?"No Title Found":"No Matching Section Found");var ci=A.evaluationResult;if(!ci&&"right"===R)if(P){var vi=null===(v=A.refIndexes)||void 0===v?void 0:v[0],fi=z.find(function(i){return i.selfIndex===vi});ci=null==fi?void 0:fi.evaluationResult}else ci=null===(f=z[S])||void 0===f?void 0:f.evaluationResult;var pi=null===(p=null==q?void 0:q.input_index_map)||void 0===p?void 0:p[0],xi=null===(x=null==q?void 0:q.input_index_map)||void 0===x?void 0:x[1],gi="left"===R?xi:pi,hi=function(i,n){return i.find(function(i){return(null==i?void 0:i.id)&&n&&i.id===n})},mi="left"===R?A:z[S],_i="right"===R?A:L[S];if(P)if("left"===R){var Ii=null===(g=A.refIndexes)||void 0===g?void 0:g[0],yi=L.findIndex(function(i){return i.selfIndex===Ii});_i=-1!==yi?L[yi]:hi(L,A.id)}else{var bi=null===(h=A.refIndexes)||void 0===h?void 0:h[0],wi=z.findIndex(function(i){return i.selfIndex===bi});mi=-1!==wi?z[wi]:hi(z,A.id)}var Ai="left"===R?!_i:!mi,Si=ci||(null==mi?void 0:mi.evaluationResult)||(null==_i?void 0:_i.evaluationResult),Ri=null!==(I=null===(_=null===(m=null==Si?void 0:Si.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==I?I:r.DEFAULT_DEVIAION_COLOR,ji=d.generateColorPalette(Ri).highlightBg,Ci=(null==Si?void 0:Si.deviations)||{},Fi=S+1,Oi=A.id;if("right"===R&&P){var Bi=null===(y=A.refIndexes)||void 0===y?void 0:y[0],Ei=-1!==(wi=z.findIndex(function(i){return i.selfIndex===Bi}))?z[wi]:hi(z,A.id);if(Ei){var Di=z.findIndex(function(i){return i.id===Ei.id});-1!==Di&&(Fi=Di+1),Oi=Ei.id}}var Ti,ki=[],Mi=Object.entries(Ci).map(function(n){var e,o,t,l,r,a,s=n[0],u=n[1],c="".concat(Oi).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s),v=X[c];if(null==v)return null;var f=u[B],p=d.isMissingStr(f);if(p)f="";else if(!f)return null;ki.push(f);var x=S,g=S;if(P)if("left"===R){var h=null===(e=A.refIndexes)||void 0===e?void 0:e[0],m=L.findIndex(function(i){return i.selfIndex===h});if(-1!==m)g=m;else{var _=L.findIndex(function(i){return i.id===A.id});g=-1!==_?_:S}}else{var I=null===(o=A.refIndexes)||void 0===o?void 0:o[0],y=z.findIndex(function(i){return i.selfIndex===I});if(-1!==y)x=y;else x=-1!==(O=z.findIndex(function(i){return i.id===A.id}))?O:S}var b="".concat(Oi).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(x).concat(d.DEVIATION_BADGE_SEPARATOR).concat(g),w=u[gi],j=Ai||d.isMissingStr(w),C="".concat(Fi,".").concat(v),F=S;if("right"===R&&P){var O,E=null===(t=A.refIndexes)||void 0===t?void 0:t[0],D=z.findIndex(function(i){return i.selfIndex===E});if(-1!==D)F=D;else-1!==(O=z.findIndex(function(i){return i.id===A.id}))&&(F=O)}var T=J?J(F):null,k=(null==u?void 0:u.evaluation_outputs)||(null==Si?void 0:Si.evaluation_outputs),M=null!==(l=null==k?void 0:k.output_value)&&void 0!==l?l:null,N=null!==(a=null===(r=null==k?void 0:k.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:Ri,V=d.generateColorPalette(N),W=T?i.__assign(i.__assign({},T),{badgeBg:V.badgeBg,badgeBorder:V.badgeBorder,badgeText:V.badgeText}):i.__assign({},V),q=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Si?void 0:Si.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Si?void 0:Si.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Si?void 0:Si.deviation_explanation),evaluation_outputs:k,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Si?void 0:Si.cognitive_decisioning)}:null,G=0,K=li||"";if(f&&K){var U=K.split(/\n{2,}/),$=U.findIndex(function(i){return i.includes(f)});if(-1!==$){var ii=Object.entries(Ci).filter(function(i){i[0];var n=i[1][B];return n&&U[$].includes(n)}).sort(function(i,n){return U[$].indexOf(i[1][B])-U[$].indexOf(n[1][B])});G=Math.max(0,ii.findIndex(function(i){return i[0]===s}))}}return{id:c,actionId:b,label:C,highlight:f,side:R,style:W,stackIndex:G,score:M,isConnected:null==Q?void 0:Q.has(b),isOrphan:j,isMissingClause:p,badgeRef:Y(R,c),onClick:function(i){i.stopPropagation(),Z&&Z(i,mi||{id:"orphan-left",title:"",content:""},j,_i||{id:"orphan-right",title:"",content:""},b,W)},onSummaryClick:function(i){i.stopPropagation(),H(i,b,j,q)}}}).filter(Boolean),Pi=V?Mi:[],Ni=A.id&&R===(null==T?void 0:T.columnKey)?T:null,Vi=s.default.useRef(!1);return e.useEffect(function(){E||(Vi.current=!1)},[E]),n.jsxs(o.Box,i.__assign({ref:j,sx:{mb:F,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[E&&(null==Ni?void 0:Ni.showAbove)&&n.jsx("div",i.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var i,n;return null===(n=null===(i=null==Ni?void 0:Ni.showAboveRef)||void 0===i?void 0:i.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",i.__assign({style:i.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===R?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===R?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronUp,{color:window.getComputedStyle(null===(b=null==Ni?void 0:Ni.showAboveRef)||void 0===b?void 0:b.current).color})}))})),n.jsxs(o.Accordion,i.__assign({disableGutters:!0,expanded:!ai&&E,onChange:function(){ai||(D(),k.current=A.id)},sx:{boxShadow:"none",border:ai?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:ai?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[n.jsx(o.AccordionSummary,i.__assign({expandIcon:ai?null:n.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:ai?"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:ei&&n.jsx(o.Tooltip,i.__assign({title:ui,placement:"top"},{children:n.jsx(o.Typography,i.__assign({component:"div",sx:{fontSize:"12px",color:ai?"#94A3B8":"#19213D",fontWeight:ai?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Ti=ui,Ti?d.safeStringify(Ti).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,e){return i.startsWith("**")&&i.endsWith("**")?n.jsx("strong",{children:i.slice(2,-2)},e):n.jsx(s.default.Fragment,{children:i},e)}):null)}))}))})),!ai&&n.jsxs(o.AccordionDetails,i.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[ri&&n.jsx(l.MemoizedMarkdown,{content:li,overlayContent:di,sxStyles:M,highlights:ki,maintainRelativeOrder:P,highlightBg:ji,deviationBadges:Pi,collisionKey:ni}),(A.subsections||[]).map(function(i,n){return W({section:i,keyPath:"".concat(S,"-").concat(n),depth:0,columnKey:R,parentNodeId:B,devCounter:si})})]}))]})),E&&(null==Ni?void 0:Ni.showBelow)&&n.jsx("div",i.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var i,n;return null===(n=null===(i=null==Ni?void 0:Ni.showBelowRef)||void 0===i?void 0:i.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",i.__assign({style:i.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===R?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===R?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronDown,{color:window.getComputedStyle(null===(w=null==Ni?void 0:Ni.showBelowRef)||void 0===w?void 0:w.current).color})}))}))]}),"".concat(R,"-sec-").concat(S))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),e=require("react/jsx-runtime"),n=require("react"),o=require("@mui/material"),t=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),d=require("../CognitiveComparehelpers.js"),r=require("../CognitiveCompareConstants.js");function a(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var s=a(n);exports.default=function(a){var u,c,v,f,p,x,g,h,m,_,I,y,b,w,A=a.section,R=a.idx,S=a.columnKey,j=a.colRef,C=a.mb,F=void 0===C?1:C,B=a.parentNodeId,O=void 0===B?"":B,E=a.isExpanded,D=a.onToggle,T=a.navigation,k=a.showOpenNodeRef,M=a.resolvedMarkdownStyles,P=a.maintainRelativeOrder,N=a.showDeviationBadges,V=void 0!==N&&N,W=a.renderSubSections,q=a.treeData,G=a.proposedSections,z=void 0===G?[]:G,K=a.existingSections,L=void 0===K?[]:K,U=a.deviationNumberRegistry,X=void 0===U?{}:U,Y=a.getBadgeRef,H=a.openSummaryPopup,J=a.getSectionCompareStyle,Q=a.connectedSections,Z=a.openMoreFunctionsPopup;a.deviationNodeIdToView,a.deviationTargetParentId;var $=a.isProposingFix,ii=a.proposingFixNodeId,ei=a.collisionKey,ni=(null===(u=A.displayTitle)||void 0===u||u)&&d.hasValue(A.title),oi=A.change_history,ti=!!$&&!!ii&&"left"===S&&A.id===ii&&d.hasValue(oi),li=ti?oi||"":A.content,di=ti?A.content:void 0,ri=(null===(c=A.displayContent)||void 0===c||c)&&d.hasValue(li),ai=!ni&&!ri,si={current:1},ui=A.title;ni||(ui=ri?"No Title Found":"No Matching Section Found");var ci=A.evaluationResult;if(!ci&&"right"===S)if(P){var vi=null===(v=A.refIndexes)||void 0===v?void 0:v[0],fi=z.find(function(i){return i.selfIndex===vi});ci=null==fi?void 0:fi.evaluationResult}else ci=null===(f=z[R])||void 0===f?void 0:f.evaluationResult;var pi=null===(p=null==q?void 0:q.input_index_map)||void 0===p?void 0:p[0],xi=null===(x=null==q?void 0:q.input_index_map)||void 0===x?void 0:x[1],gi="left"===S?xi:pi,hi=function(i,e){return i.find(function(i){return(null==i?void 0:i.id)&&e&&i.id===e})},mi="left"===S?A:z[R],_i="right"===S?A:L[R];if(P)if("left"===S){var Ii=null===(g=A.refIndexes)||void 0===g?void 0:g[0],yi=L.findIndex(function(i){return i.selfIndex===Ii});_i=-1!==yi?L[yi]:hi(L,A.id)}else{var bi=null===(h=A.refIndexes)||void 0===h?void 0:h[0],wi=z.findIndex(function(i){return i.selfIndex===bi});mi=-1!==wi?z[wi]:hi(z,A.id)}var Ai="left"===S?!_i:!mi,Ri=ci||(null==mi?void 0:mi.evaluationResult)||(null==_i?void 0:_i.evaluationResult),Si=null!==(I=null===(_=null===(m=null==Ri?void 0:Ri.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==I?I:r.DEFAULT_DEVIAION_COLOR,ji=d.generateColorPalette(Si).highlightBg,Ci=(null==Ri?void 0:Ri.deviations)||{},Fi=R+1,Bi=A.id;if("right"===S&&P){var Oi=null===(y=A.refIndexes)||void 0===y?void 0:y[0],Ei=-1!==(wi=z.findIndex(function(i){return i.selfIndex===Oi}))?z[wi]:hi(z,A.id);if(Ei){var Di=z.findIndex(function(i){return i.id===Ei.id});-1!==Di&&(Fi=Di+1),Bi=Ei.id}}var Ti,ki=[],Mi=Object.entries(Ci).map(function(e){var n,o,t,l,r,a,s=e[0],u=e[1],c="".concat(Bi).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s),v=X[c];if(null==v)return null;var f=u[O],p=d.isMissingStr(f);if(p)f="";else if(!f)return null;ki.push(f);var x=R,g=R;if(P)if("left"===S){var h=null===(n=A.refIndexes)||void 0===n?void 0:n[0],m=L.findIndex(function(i){return i.selfIndex===h});if(-1!==m)g=m;else{var _=L.findIndex(function(i){return i.id===A.id});g=-1!==_?_:R}}else{var I=null===(o=A.refIndexes)||void 0===o?void 0:o[0],y=z.findIndex(function(i){return i.selfIndex===I});if(-1!==y)x=y;else x=-1!==(B=z.findIndex(function(i){return i.id===A.id}))?B:R}var b="".concat(Bi).concat(d.DEVIATION_BADGE_SEPARATOR).concat(s).concat(d.DEVIATION_BADGE_SEPARATOR).concat(x).concat(d.DEVIATION_BADGE_SEPARATOR).concat(g),w=u[gi],j=Ai||d.isMissingStr(w),C="".concat(Fi,".").concat(v),F=R;if("right"===S&&P){var B,E=null===(t=A.refIndexes)||void 0===t?void 0:t[0],D=z.findIndex(function(i){return i.selfIndex===E});if(-1!==D)F=D;else-1!==(B=z.findIndex(function(i){return i.id===A.id}))&&(F=B)}var T=J?J(F):null,k=(null==u?void 0:u.evaluation_outputs)||(null==Ri?void 0:Ri.evaluation_outputs),M=null!==(l=null==k?void 0:k.output_value)&&void 0!==l?l:null,N=null!==(a=null===(r=null==k?void 0:k.metadata)||void 0===r?void 0:r.label_color)&&void 0!==a?a:Si,V=d.generateColorPalette(N),W=T?i.__assign(i.__assign({},T),{badgeBg:V.badgeBg,badgeBorder:V.badgeBorder,badgeText:V.badgeText}):i.__assign({},V),q=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Ri?void 0:Ri.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Ri?void 0:Ri.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Ri?void 0:Ri.deviation_explanation),evaluation_outputs:k,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Ri?void 0:Ri.cognitive_decisioning)}:null,G=0,K=li||"";if(f&&K){var U=K.split(/\n{2,}/),$=U.findIndex(function(i){return i.includes(f)});if(-1!==$){var ii=Object.entries(Ci).filter(function(i){i[0];var e=i[1][O];return e&&U[$].includes(e)}).sort(function(i,e){return U[$].indexOf(i[1][O])-U[$].indexOf(e[1][O])});G=Math.max(0,ii.findIndex(function(i){return i[0]===s}))}}return{id:c,actionId:b,label:C,highlight:f,side:S,style:W,stackIndex:G,score:M,isConnected:null==Q?void 0:Q.has(b),isOrphan:j,isMissingClause:p,badgeRef:Y(S,c),onClick:function(i){i.stopPropagation(),Z&&Z(i,mi||{id:"orphan-left",title:"",content:""},j,_i||{id:"orphan-right",title:"",content:""},b,W)},onSummaryClick:function(i){i.stopPropagation(),H(i,b,j,q)}}}).filter(Boolean),Pi=V?Mi:[],Ni=A.id&&S===(null==T?void 0:T.columnKey)?T:null,Vi=s.default.useRef(!1);return n.useEffect(function(){E||(Vi.current=!1)},[E]),e.jsxs(o.Box,i.__assign({ref:j,sx:{mb:F,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[E&&(null==Ni?void 0:Ni.showAbove)&&e.jsx("div",i.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var i,e;return null===(e=null===(i=null==Ni?void 0:Ni.showAboveRef)||void 0===i?void 0:i.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",i.__assign({style:i.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===S?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===S?{right:"0px"}:{left:"0px"})},{children:e.jsx(t.ChevronUp,{color:(null===(b=null==Ni?void 0:Ni.showAboveRef)||void 0===b?void 0:b.current)?window.getComputedStyle(Ni.showAboveRef.current).color:void 0})}))})),e.jsxs(o.Accordion,i.__assign({disableGutters:!0,expanded:!ai&&E,onChange:function(){ai||(D(),k.current=A.id)},sx:{boxShadow:"none",border:ai?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:ai?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e.jsx(o.AccordionSummary,i.__assign({expandIcon:ai?null:e.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:ai?"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:ni&&e.jsx(o.Tooltip,i.__assign({title:ui,placement:"top"},{children:e.jsx(o.Typography,i.__assign({component:"div",sx:{fontSize:"12px",color:ai?"#94A3B8":"#19213D",fontWeight:ai?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Ti=ui,Ti?d.safeStringify(Ti).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,n){return i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{children:i.slice(2,-2)},n):e.jsx(s.default.Fragment,{children:i},n)}):null)}))}))})),!ai&&e.jsxs(o.AccordionDetails,i.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[ri&&e.jsx(l.MemoizedMarkdown,{content:li,overlayContent:di,sxStyles:M,highlights:ki,maintainRelativeOrder:P,highlightBg:ji,deviationBadges:Pi,collisionKey:ei}),(A.subsections||[]).map(function(i,e){return W({section:i,keyPath:"".concat(R,"-").concat(e),depth:0,columnKey:S,parentNodeId:O,devCounter:si})})]}))]})),E&&(null==Ni?void 0:Ni.showBelow)&&e.jsx("div",i.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var i,e;return null===(e=null===(i=null==Ni?void 0:Ni.showBelowRef)||void 0===i?void 0:i.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e.jsx("div",i.__assign({style:i.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===S?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===S?{right:"0px"}:{left:"0px"})},{children:e.jsx(t.ChevronDown,{color:(null===(w=null==Ni?void 0:Ni.showBelowRef)||void 0===w?void 0:w.current)?window.getComputedStyle(Ni.showBelowRef.current).color:void 0})}))}))]}),"".concat(S,"-sec-").concat(R))};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),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,S=void 0===x?"#f7dc51":x,C=c.jumpToPageValue,P=void 0===C?0:C,_=c.pdfName,w=c.onClose,T=c.customStyles,y=c.customClasses,b=c.customIcons,A=c.useCoordinates,q=c.fallbackPages,j=c.activeCitationIndex,H=c.onActiveCitationChange,I=c.headerAction,F=c.isZoomEnabled,Z=void 0===F||F,L=c.showHighlightsAction,z=void 0===L||L,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=c.showFullScreenAction,B=void 0===O||O,U=s.useRef(null),k=s.useMemo(function(){if(A)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]),M=(d=f)&&0!==d.length?d.filter(function(e){return!d.some(function(i){return i!==e&&i.includes(e)})}):d,J=a.PdfHighlightControls(M,A?{}:h,U,k,A,A?v:[],m,S),K=J.highlightIndex,G=J.cursorIndex,Q=J.setCursorIndex,X=J.orderedKeys,Y=J.totalHighlights,$=J.getValidPosition,ee=J.tryJump,ie=J.jumpToPage,te=J.zoomTo,oe=J.plugins,re=J.controls,ne=J.hideNonTargetHighlights,ae=J.deduplicateHighlights,se=$(G);s.useEffect(function(){void 0!==j&&j!==G&&Q(j)},[j]);var le=e.__assign(e.__assign({},re),{goToNext:function(){re.goToNext(),H&&H(G+1)},goToPrevious:function(){re.goToPrevious(),H&&H(G-1)}});if(!g)return i.jsx(l.default,{pages:q,activeCitationIndex:j,onActiveCitationChange:H,headerAction:I});return i.jsxs("div",e.__assign({ref:U,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==T?void 0:T.pdfViewer)},{children:[i.jsx(r.default,{highlightIndex:K,totalHighlights:Y,controls:le,currentPosition:se,pdfName:_,onClose:w,pdfUrl:g,viewerRef:U,customStyles:T,customClasses:y,customIcons:b,headerAction:I,isZoomEnabled:Z,showHighlightsAction:z,showFullScreenAction:B}),i.jsx(o.default,{defaultScale:u(R),pdfUrl:g,plugins:oe,customStyles:T,onLoad:function(){var i=!A&&!V&&P<=0;if(te(t.SpecialZoomLevel.ActualSize),P>0&&!V){var o=P-1,r=X[o],n=h[r],a=v[o];Q(o),console.log(a,"cordinateTargetHighlight"),A&&a.pageIndex>0&&ie(a.pageIndex),n>0&&(setTimeout(function(){ne(k),ae(n-1)},1e3),A||ie(n-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?(ie(r=o-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(e.sent(),ne(k),(n=ae(r))&&n>0)return[3,4];e.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}else if(!A&&h){var s=X.find(function(e){return h[e]>0});if(void 0!==s){var l=h[s]-1;ie(l),setTimeout(function(){ne(k),ae(l)},1e3)}}requestAnimationFrame(function(){i&&ee(),!A&&P>0&&!V&&function(){if(U.current){var e=P-1,i=X[e],t=h[i],o=t>0?t-1:0,r={};X.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=U.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(t){var r=null===(i=U.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;k.has(i)?(ae(i),ne(k)):ne(k)}})]}))};
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,S=void 0===x?"#f7dc51":x,C=c.jumpToPageValue,P=void 0===C?0:C,_=c.pdfName,w=c.onClose,T=c.customStyles,y=c.customClasses,b=c.customIcons,A=c.useCoordinates,q=c.fallbackPages,j=c.activeCitationIndex,H=c.onActiveCitationChange,I=c.headerAction,F=c.isZoomEnabled,Z=void 0===F||F,L=c.showHighlightsAction,z=void 0===L||L,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=c.showFullScreenAction,B=void 0===O||O,U=s.useRef(null),k=s.useMemo(function(){if(A)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]),M=(d=f)&&0!==d.length?d.filter(function(e){return!d.some(function(i){return i!==e&&i.includes(e)})}):d,J=a.PdfHighlightControls(M,A?{}:h,U,k,A,A?v:[],m,S),K=J.highlightIndex,G=J.cursorIndex,Q=J.setCursorIndex,X=J.orderedKeys,Y=J.totalHighlights,$=J.getValidPosition,ee=J.tryJump,ie=J.jumpToPage,te=J.zoomTo,oe=J.plugins,re=J.controls,ne=J.hideNonTargetHighlights,ae=J.deduplicateHighlights,se=$(G);s.useEffect(function(){void 0!==j&&j!==G&&Q(j)},[j]);var le=e.__assign(e.__assign({},re),{goToNext:function(){re.goToNext(),H&&H(G+1)},goToPrevious:function(){re.goToPrevious(),H&&H(G-1)}});if(!g)return i.jsx(l.default,{pages:q,activeCitationIndex:j,onActiveCitationChange:H,headerAction:I});return i.jsxs("div",e.__assign({ref:U,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==T?void 0:T.pdfViewer)},{children:[i.jsx(r.default,{highlightIndex:K,totalHighlights:Y,controls:le,currentPosition:se,pdfName:_,onClose:w,pdfUrl:g,viewerRef:U,customStyles:T,customClasses:y,customIcons:b,headerAction:I,isZoomEnabled:Z,showHighlightsAction:z,showFullScreenAction:B}),i.jsx(o.default,{defaultScale:u(R),pdfUrl:g,plugins:oe,customStyles:T,onLoad:function(){if(te(t.SpecialZoomLevel.ActualSize),P>0&&!V){var i=P-1,o=X[i],r=h[o],n=v[i];Q(i),console.log(n,"cordinateTargetHighlight"),A&&n.pageIndex>0&&ie(n.pageIndex),r>0&&(setTimeout(function(){ne(k),ae(r-1)},1e3),A||ie(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?(ie(r=o-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(e.sent(),ne(k),(n=ae(r))&&n>0)return[3,4];e.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}else if(!A&&h){var a=X.find(function(e){return h[e]>0});if(void 0!==a){var s=h[a]-1;ie(s),setTimeout(function(){ne(k),ae(s)},1e3)}}requestAnimationFrame(function(){ee(),A||function(){if(U.current){var e=P-1,i=X[e],t=h[i],o=t>0?t-1:0,r={};X.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=U.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(t){var r=null===(i=U.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;k.has(i)?(ae(i),ne(k)):ne(k)}})]}))};
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"),i=require("@react-pdf-viewer/page-navigation"),o=require("@react-pdf-viewer/zoom"),a=require("@react-pdf-viewer/highlight");exports.PdfHighlightControls=function(l,u,c,s,g,f,h,p){void 0===h&&(h="yellow"),void 0===p&&(p="#F6D739");var v=r.useState(0),d=v[0],m=v[1],y=r.useRef(!1),_=r.useState(0),x=_[0],T=_[1];r.useRef([]);var b=function(e){return e.replace(/[^\S\n]+/g," ").trim()},w=function(e){return(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},S=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},I=function(e){var t=w(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},A=function(e){return e.replace(/\\([''])/g,"$1").replace(/\]\s*\n\s*\(/g,"](").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(/`([^`]+)`/g,"$1")},q=function(e){return e?A(e).split(/\n+/).map(S).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 b(function(e){return e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2")}(e))}).filter(Boolean):[]},M=Object.keys(u).map(Number).sort(function(e,t){return e-t}),B=r.useMemo(function(){return g?f.length:g?0:Object.values(u).filter(function(e){return e>0}).length},[f,u]),j=function(t){if(c.current){var r=c.current.querySelector('[data-testid="search__highlights-'.concat(t,'"]'));if(r){var n=Array.from(r.querySelectorAll(".rpv-search__highlight"));if(0!==n.length){var i=R.map(I),o=C.map(I);if(0!==i.length||0!==o.length){var a=n.map(function(t){var r=function(e){var t=e.getBoundingClientRect();if(t.height>0||t.width>0)return{top:t.top,left:t.left,right:t.right};var r=e.offsetTop,n=e.offsetLeft;return{top:r,left:n,right:n+e.offsetWidth}}(t),n=(t.textContent||"").trim(),i=(t.getAttribute("title")||"").trim(),o=n||i;return e.__assign({el:t,text:o},r)}).filter(function(e){return e.text.length>0}).sort(function(e,t){return e.top-t.top||e.left-t.left});if(0!==a.length){var u=[],s=null,g=[],f=function(){if(s){var e=g.join(" ");s.title=w(e),s.title&&u.push(s),s=null,g=[]}};if(a.forEach(function(e){if(!s)return s={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(g=[e.text]);var t=Math.abs(e.top-s.lastTop)<=5,r=e.left<=s.lastRight+28;t&&r?(s.elements.push(e.el),s.lastTop=e.top,s.lastRight=Math.max(s.lastRight,e.right),g.push(e.text)):(f(),s={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},g=[e.text])}),f(),0!==u.length){for(var h=function(e,t){if(!e)return!1;if(t.has(e))return!0;for(var r=e.replace(/\s+/g,""),n=0,i=Array.from(t);n<i.length;n++){var o=i[n];if(o){var a=o.replace(/\s+/g,"");if(a===r)return!0;if(o.length>=8&&e.length>=5&&o.includes(e))return!0;if(a.length>=8&&r.length>=5&&a.includes(r))return!0;if(e.length>=10&&o.length>=8&&e.includes(o))return!0;if(r.length>=10&&a.length>=8&&r.includes(a))return!0}}return!1},p=0,v=new Set,d=function(e){if(!e||e.length<8)return null;for(var t=e.replace(/\s+/g,""),r=0;r<u.length;r++)for(var n="",i="",o=new Set,a=r;a<u.length&&a<r+20;a++){var l=u[a].title;if(n=n?"".concat(n," ").concat(l):l,i=i?"".concat(i).concat(l.replace(/\s+/g,"")):l.replace(/\s+/g,""),o.add(a),n.includes(e)||i.includes(t))return o;if(n.length>=15&&(e.includes(n)||t.includes(i)))return o;if(n.length>e.length+150)break}return null},m=0,y=Array.from(new Set(e.__spreadArray(e.__spreadArray([],R,!0),C,!0).map(w).filter(function(e){return e.length>=8}))).sort(function(e,t){return t.length-e.length});m<y.length;m++){var _=d(y[m]);_&&_.size>0&&(_.forEach(function(e){return v.add(e)}),p=v.size)}if(0===p){var x=function(e){if(0===e.length)return null;for(var t=null,r=0,n=e;r<n.length;r++)for(var i=n[r],o=0,a=Array.from(i);o<a.length;o++){var l=a[o];if(l&&!(l.length<5))for(var c=l.replace(/\s+/g,""),s=0;s<u.length;s++)for(var g="",f="",h=new Set,p=s;p<u.length&&p<s+15;p++){var v=u[p].title;if(g=g?"".concat(g," ").concat(v):v,f=f?"".concat(f).concat(v.replace(/\s+/g,"")):v.replace(/\s+/g,""),h.add(p),g.includes(l)||f.includes(c)){var d=Math.max(0,g.length-l.length);(!t||d<t.extra)&&(t={blocks:new Set(h),extra:d});break}if(g.length>l.length+120)break}}return t?t.blocks:null}(i);x&&x.size>0&&(x.forEach(function(e){return v.add(e)}),p=v.size)}var T=function(e){if(e.length<2)return 40;for(var t=[],r=1;r<e.length;r++){var n=Math.abs(e[r].lastTop-e[r-1].lastTop);n>0&&t.push(n)}if(0===t.length)return 40;t.sort(function(e,t){return e-t});var i=t[Math.floor(t.length/2)],o=Math.round(2.25*i);return Math.min(60,Math.max(24,o))}(u),b=C.map(w).filter(function(e){return e.length>=8}),S=b.map(function(e){return e.split(/\s+/).filter(function(e){return e.length>=2})});if(0===p)for(var A=o,q=0;q<u.length;q++)for(var M=u[q].title,B=0;B<A.length;B++)if(h(M,A[B])){for(var j=0,k=new Set,z=B,E=q-1,P=q;P<u.length&&z<A.length;P++){if(h(u[P].title,A[z])){if(E>=0){var F=u[E].lastTop,H=u[P].lastTop;if(Math.abs(H-F)>T)break}j++,k.add(P),E=P,z++}else if(z>0&&h(u[P].title,A[z-1])){F=u[E].lastTop,H=u[P].lastTop;Math.abs(H-F)<=3&&(k.add(P),E=P)}if(P-E>6)break}j>p&&(p=j,v=k)}if(p<Math.min(3,b.length)&&b.length>0){var O=new Set;u.forEach(function(e,t){var r=e.title.split(/\s+/).filter(function(e){return e.length>=2});if(!(r.length<2))for(var n=new Set(r),i=0,o=S;i<o.length;i++){var a=o[i];if(!(a.length<2)){for(var l=0,u=0,c=a;u<c.length;u++){var s=c[u];n.has(s)&&l++}var g=l/a.length;if(l>=3||g>=.5){O.add(t);break}}}}),O.size>0&&(v=O,p=Math.max(p,O.size))}var Z=new Set;if($.forEach(function(e){var t=w(e);t&&(Z.add(t),Z.add(t.replace(/\s+/g,"")))}),0===p){var N=new Set;if(u.forEach(function(e,t){var r=e.title.replace(/\s+/g,"");if(Z.has(e.title)||Z.has(r))N.add(t);else for(var n=Array.from(Z),i=0;i<n.length;i++){var o=n[i];if(o.length>=10&&o.includes(e.title)&&e.title.length>=5){N.add(t);break}}}),0===N.size)return 0;v=N}return u.forEach(function(e,t){var r=v.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(t,"]")),console.log("input->",l),console.log("processed sentences->",R),console.log("processed lines->",C),console.log("Expected sentence count:",i.length),console.log("Expected line count:",o.length),console.log("Matched sequence length:",p),console.log("blocksToKeep",v,"size",v.size),console.groupEnd(),v.size}}}}}}},k=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"),i=t.querySelectorAll(".rpv-search__highlight");e.has(n)||i.forEach(function(e){e.style.display="none"})})},z=l.map(function(e){return function(e){return e?A(e).split(/\n{2,}/).map(function(e){return q(e).join(" ")}).map(function(e){return b(e)}).filter(Boolean):[]}(e)}).flat(),E=l.map(function(e){return q(e)}).flat(),P=z.some(function(e){return e.length>=3})?3:1,R=z.filter(function(e){return e.length>=P}),C=E.filter(function(e){return e.length>=P}),F=C.flatMap(function(e){return function(e,t,r){void 0===t&&(t=6),void 0===r&&(r=4);var n=e.split(/\s+/).filter(Boolean);if(n.length<=t)return[];for(var i=[],o=0;o+t<=n.length;o+=r)i.push(n.slice(o,o+t).join(" "));return n.length>t&&(n.length-t)%r!==0&&i.push(n.slice(n.length-t).join(" ")),i}(e)}),$=Array.from(new Set(e.__spreadArray(e.__spreadArray(e.__spreadArray([],R,!0),C,!0),F,!0).flatMap(function(e){var t=b(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];var r=t.replace(/[\u2013\u2014]/g,"-"),n=b(r.replace(/(\w)-\s+(\w)/g,"$1$2")),i=b(r.replace(/-/g," ")),o=b(r.replace(/-/g,"")),a=b(t.replace(/[^\w\s]/g,"")),l=new Set([t,r,n,i,o,a]);return Array.from(l).filter(Boolean)}))).filter(function(e){var t=e.split(/\s+/).filter(Boolean);return!(e.length<P)&&(t.length>=3||e.length>=12)}),H=n.searchPlugin({keyword:$}),O=i.pageNavigationPlugin(),Z=o.zoomPlugin(),N=H.jumpToMatch,L=O.jumpToPage,D=Z.zoomTo,W=Z.ZoomInButton,K=Z.ZoomOutButton,J=Z.ZoomPopover,V=a.highlightPlugin({renderHighlights:function(r){return t.jsx(t.Fragment,{children:f.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?p:h,opacity:n?.7:.4,transition:"background 0.2s, opacity 0.2s"}},r)})})}}),G=function(){if(!y.current)try{N(0),y.current=!0;var e=f[0];e&&g&&U(e.pageIndex,e.top)}catch(e){requestAnimationFrame(G)}},Q=function(e,t){if(c.current&&c.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var i,o,a=null===(i=c.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(o=c.current)||void 0===o?void 0:o.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.querySelectorAll(".rpv-search__highlight")[t];if(u){var s=a.getBoundingClientRect(),g=u.getBoundingClientRect(),f=a.scrollTop+(g.top-s.top)-a.clientHeight/2+g.height/2;a.scrollTo({top:f,behavior:"smooth"})}}}};setTimeout(n,300)}},U=function(e,t){if(c.current){var r=0,n=function(){var i,o;if(!(++r>60)){var a=null===(i=c.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(a){var l=null===(o=c.current)||void 0===o?void 0:o.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.getBoundingClientRect();if(0!==u.height){var s=a.getBoundingClientRect(),g=t/100*u.height,f=u.top-s.top+g;a.scrollTo({top:a.scrollTop+f-40,behavior:"smooth"})}else setTimeout(n,100)}else setTimeout(n,100)}else setTimeout(n,100)}};setTimeout(n,100)}},X=r.useMemo(function(){var e={};return M.forEach(function(t,r){var n=u[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[M,u]),Y=function(e){var t=u[M[e]];return(X[t]||[]).indexOf(e)},ee=function(e,t){if(c.current){var r=-1,n=0,i=function(){var o,a;if(!(++n>60)){var l=null===(o=c.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(l){if(l.scrollTop!==r)return r=l.scrollTop,void setTimeout(i,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 g=l.getBoundingClientRect(),f=t/100*s.height,h=s.top-g.top+f;l.scrollTo({top:l.scrollTop+h-40,behavior:"instant"})}else setTimeout(i,100)}else setTimeout(i,100)}else setTimeout(i,100)}};setTimeout(i,100)}};return{setHighlightIndex:m,highlightIndex:d,cursorIndex:x,setCursorIndex:T,orderedKeys:M,totalHighlights:B,getValidPosition:function(e){if(g)return e+1;if(!u)return 0;for(var t=0,r=0;r<=e;r++)u[M[r]]>0&&t++;return t},tryJump:G,jumpToPage:L,zoomTo:D,hideNonTargetHighlights:k,deduplicateHighlights:j,scrollToCoord:U,plugins:[g?V:H,O,Z],controls:{ZoomInButton:W,ZoomOutButton:K,ZoomPopover:J,goToNext:function(){if(g&&f)for(var e=x+1;e<f.length;e++){var t=f[e],r=f[x];return T(e),L(t.pageIndex),void(t.pageIndex!==r.pageIndex?(L(t.pageIndex),ee(t.pageIndex,t.top)):U(t.pageIndex,t.top))}else{var n=function(e){var t=M[e];if(u[t]>0){var r=u[t]-1,n=Y(e);return T(e),L(u[t]-1),Q(r,n),setTimeout(function(){j(r)},500),1===Object.keys(u).length&&k(s),{value:void 0}}};for(e=x+1;e<M.length;e++){var i=n(e);if("object"==typeof i)return i.value}}},goToPrevious:function(){if(g&&f)for(var e=x-1;e>=0;e--){var t=f[e],r=f[x];return T(e),L(t.pageIndex),void(t.pageIndex!==r.pageIndex?(L(t.pageIndex),ee(t.pageIndex,t.top)):U(t.pageIndex,t.top))}else{var n=function(e){var t=M[e];if(u[t]>0){var r=u[t]-1,n=Y(e);return T(e),L(u[t]-1),Q(r,n),setTimeout(function(){j(r)},500),1===Object.keys(u).length&&k(s),{value:void 0}}};for(e=x-1;e>=0;e--){var i=n(e);if("object"==typeof i)return i.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(/\\(['’])/g,"$1").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)},$=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),$(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),$(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