@viswa-test/test-citation 0.0.108 → 0.0.109

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 (36) hide show
  1. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/components/CompareHeader.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  9. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  10. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  11. package/dist/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
  12. package/dist/features/CognitiveCompare/components/CompareHeader.js +1 -1
  13. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  14. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  15. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  16. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  17. package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
  18. package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
  19. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
  20. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  21. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +3 -11
  22. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  23. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +0 -11
  24. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  25. package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts.map +1 -1
  26. package/dist/types/src/features/CognitiveCompare/components/CompareHeader.d.ts +1 -3
  27. package/dist/types/src/features/CognitiveCompare/components/CompareHeader.d.ts.map +1 -1
  28. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts +1 -4
  29. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  30. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts +0 -2
  31. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  32. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts +1 -3
  33. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  34. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
  35. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  36. 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"),_=require("./hooks/useDeviationNavigation.js"),m=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),S=require("./components/CognitiveSummaryPopup.js"),b=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,V,L,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],_e=!!he||!!(null==le?void 0:le.showDeviationBadges),me=t.useState(!1),Re=me[0],ye=me[1],Se=t.useState(!1),be=Se[0],Ae=Se[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),Ve=ke[0],Le=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(new Set),Je=t.useRef(!1),Qe=t.useRef(null),Ze=t.useRef({}),en=t.useRef([]),nn=t.useRef(!1),tn=t.useRef(!1),on=t.useRef(null),rn=t.useRef(function(){}),ln=t.useMemo(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),un=t.useState({width:0,height:0}),cn=un[0],an=un[1],sn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),ie)},[ie]),dn=t.useRef(null),vn=t.useRef(null),fn=t.useRef(null),gn=t.useRef(null),pn=t.useRef(null),hn=t.useRef(null),xn=t.useRef(null),_n=t.useRef(null),mn=t.useRef(!1),Rn=t.useRef(null),yn=t.useRef(null),Sn=p.useComparePopups(dn),bn=Sn.cognitivePopup,An=Sn.setCognitivePopup,En=Sn.moreFunctions,In=Sn.setMoreFunctions,Tn=Sn.position,Bn=Sn.setPosition,Cn=Sn.activeBadgeId,Dn=Sn.summaryPopup,On=Sn.setSummaryPopup,wn=Sn.closeSummaryPopup,Nn=Sn.setActiveBadgeId,Pn=Sn.popupRef,jn=Sn.closeCognitivePopup,Fn=Sn.closeMoreFunctionsPopup,Mn=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]),kn=t.useState(null),Vn=kn[0];kn[1];var Ln=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,Hn=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||Ln||"Uploaded Contract"),qn=u.safeStringify(te||Hn||"Reference Template"),zn=g.useCognitiveTreeData(Z,he,ae,Mn,Oe),Kn=zn.activeProposed,Wn=zn.existingRule,Yn=zn.proposedSections,Un=zn.existingSections,Xn=zn.visibleFields,$n=zn.parentDeviationRecord,Jn=zn.deviationNumberRegistry,Qn=zn.parseError;t.useEffect(function(){Qn&&Te("Failed to load comparison: ".concat(Qn))},[Qn]);var Zn=Yn.length>0||Un.length>0,et=h.useSectionRefs(Xn.map(function(e){return e.key}),Math.max(Yn.length,Un.length)),nt=et.leftRefs,tt=et.rightRefs,it=et.sectionLeftRefs,ot=et.sectionRightRefs,rt=et.lhsBadgeRefs,lt=et.rhsBadgeRefs,ut=et.sectionRightRowRefs,ct=et.subSectionLeftRefs,at=et.subSectionRightRefs,st=et.sectionRowRefs,dt=et.getSectionRowRef,vt=et.getSubSectionRef,ft=et.getBadgeRef,gt=Wn.analysis,pt=u.safeStringify(null===(P=null===(N=null==gt?void 0:gt.rule_difference_comparison)||void 0===N?void 0:N.summary)||void 0===P?void 0:P.overall_summary),ht=!!pt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),xt=null!==(j=null==Z?void 0:Z.base_root_id)&&void 0!==j?j:"-1";null==Z||Z[xt];var _t=Oe?null!==(Y=null!==(z=ae&&(null===(q=null==ae?void 0:ae[xt])||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[xt])||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[xt])||void 0===F?void 0:F.evaluation_result)||void 0===M?void 0:M[0]))&&void 0!==k?k:null===(H=null===(L=null===(V=null==Z?void 0:Z.nodes)||void 0===V?void 0:V[xt])||void 0===L?void 0:L.evaluation_result)||void 0===H?void 0:H[0])&&void 0!==G?G:null,mt=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!==$?$:""),yt=function(){$e.current.forEach(function(e){u.resetClauseHighlight(e)}),$e.current.clear()},St=t.useCallback(function(){var e,n,t,i,o,r;yt(),De(!1),tn.current=!1;var l=on.current,c=Ht.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=ct.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=it.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=it.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=at.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=ot.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=ot.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Le(null),on.current=null,Ht.current=null,Pe(!1),Ae(!1),gn.current&&(gn.current.style.height="0px"),pn.current&&(pn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px")},[]),bt=t.useCallback(function(){yt(),St(),ze(new Set),Ye([]),en.current=[],Yt([]),$t(null),On(a.EMPTY_SUMMARY_POPUP_STATE),jn(),requestAnimationFrame(function(){var e;null===(e=rn.current)||void 0===e||e.call(rn)})},[]),At=t.useRef(bt);t.useEffect(function(){At.current=bt},[bt]),t.useEffect(function(){oe&&At.current()},[oe]);var Et=x.useAccordionState({maintainRelativeOrder:!!he,proposedSections:Yn,existingSections:Un,activeSideBySideSection:Ve,connectedSections:qe,resetSideBySide:St,setConnectedSections:ze,setConnectedLines:Ye,cachedConnectedPositions:en,svgContainerRef:Ue,isAnimatingRef:Je,animationTimerRef:Qe,calculateLinesRef:rn,sectionLeftRefs:it,sectionRightRefs:ot,subSectionLeftRefs:ct,subSectionRightRefs:at}),It=Et.expandedSections,Tt=Et.setExpandedSections,Bt=Et.expandedSubSections,Ct=Et.setExpandedSubSections,Dt=Et.toggleSection,Ot=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?ln[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=st.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}},[ln,Z]),wt=t.useCallback(function(e){Fn(),Bn(null),An(e)},[Fn]),Nt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),En.open&&En.sectionIdx===o)Fn();else{var c=e.currentTarget,a="left";(null===(l=fn.current)||void 0===l?void 0:l.contains(c))&&(a="right");yt(),tn.current&&St(),ze(new Set),Ye([]),en.current=[],jn(),Dn.open?xi():wn(),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=lt.current[l])||void 0===e?void 0:e.current:null===(n=rt.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=lt.current[o])||void 0===t?void 0:t.current:null===(i=rt.current[o])||void 0===i?void 0:i.current}()||c;In(Ot(e,n,i,o,t,r))})}},Pt=t.useCallback(function(){null!==En.sectionIdx&&En.anchorEl?wt(e.__assign(e.__assign({},En),{open:!0})):Fn()},[En,Fn,wt]),jt=t.useCallback(function(){var e=En.sectionIdx,n=En.isOrphan;Fn(),wn(),null!==e&&(n?Te("No counterpart exists to connect to."):(yt(),tn.current&&St(),Ye([]),en.current=[],ze(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){rn.current&&rn.current()},50)))},[En.sectionIdx,En.isOrphan,Fn,wn,St]),Ft=t.useCallback(function(){var e=Xe.current;if(e){Xe.current=null;var n=Yn.findIndex(function(n){return n.id===e}),t=Un.findIndex(function(n){return n.id===e}),i=-1===n?u.findKeyPathByNodeId(Yn,e):null,o=-1===t?u.findKeyPathByNodeId(Un,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?($e.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,it,ct)},_n.current),-1!==l&&fn.current&&a(function(){return c(t,o,ot,at)},fn.current);else{var s=dn.current;if(!s)return;a(function(){return-1!==r?c(n,i,it,ct):c(t,o,ot,at)},s)}}},[Yn,Un,he,it,ot,ct,at,_n,fn,dn]),Mt=t.useCallback(function(n){if(n){yt(),St(),ze(new Set),Ye([]),en.current=[],wn(),jn();var t=Yn.findIndex(function(e){return e.id===n}),i=Un.findIndex(function(e){return e.id===n}),o=-1===t?u.findKeyPathByNodeId(Yn,n):null,r=-1===i?u.findKeyPathByNodeId(Un,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;Xe.current=n,Tt(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}),Ct(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(){Xe.current===n&&kt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Yn,Un,he,Tt,Ct,St,wn,jn]),kt=t.useRef(Ft);t.useEffect(function(){kt.current=Ft},[Ft]);var Vt=t.useRef(null),Lt=t.useRef(null),Ht=t.useRef(null),Gt=t.useRef(null),qt=t.useRef(null),zt=t.useRef(null),Kt=t.useState([]),Wt=Kt[0],Yt=Kt[1];t.useRef(null);var Ut=t.useState(null),Xt=Ut[0],$t=Ut[1];t.useEffect(function(){if(Vn){var e=Mn.fields.find(function(e){return e.analysisKey===Vn||e.key===Vn});if(e){var n=nt.current[e.key]||tt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Vn,Mn.fields]);var Jt=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==gt?void 0:gt.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}},[gt]),Qt=t.useCallback(function(n,t){var i,o,r;void 0===t&&(t="left");var l=null,c=null;if("left"===t)if(l=Yn[n],he&&l){var s=Un.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=Un[n];else if(c=Un[n],he&&c){var d=Yn.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=Yn[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})},[Yn,Un,ln,Mn,he]),Zt=t.useCallback(function(n){for(var t,i,o,r,l,c=n.split("-").map(Number),s=Yn[c[0]],d=Un[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=ln[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,_=u.getFirstDeviationOutputValue(x),m=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(m)),{label:null!=_?_:""}):e.__assign(e.__assign({},u.generateColorPalette(m)),{label:null})},[Yn,Un,ln,Mn]),ei=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 S=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(!S||"object"!=typeof S)return null;var b=null!==(p=null!==(f=null===(v=null==S?void 0:S.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==S?void 0:S.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==S?void 0:S[t],A=null!==(y=null!==(_=null===(x=null===(h=null==b?void 0:b.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==_?_:null===(R=null===(m=null==S?void 0:S.evaluation_outputs)||void 0===m?void 0:m.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]),ni=t.useCallback(function(){yt(),Tt({}),Ct({}),St(),ze(new Set),Ye([]),en.current=[],wn(),jn(),Fn(),requestAnimationFrame(function(){rn.current&&rn.current()})},[Tt,Ct,St,wn,jn,Fn]),ti=t.useMemo(function(){return Object.values(It).some(Boolean)||Object.values(Bt).some(Boolean)},[It,Bt]),ii=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p,h,x,_,m,R,y,S,b;if(!mn.current&&!Je.current){mn.current=!0;try{if(!Vt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!It[t]&&!1===he)return!1;if(he&&!It["left-".concat(t)]&&!It["right-".concat(t)]&&!It[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!Bt[i])return!1;return!0},E=Vt.current.getBoundingClientRect();an({width:E.width,height:E.height});var I=[];if(Xn.forEach(function(e){var n,t,i=e.key,o=null===(n=nt.current[i])||void 0===n?void 0:n.current,r=null===(t=tt.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")}),!Je.current){for(var T=0;T<Math.max(Yn.length,Un.length);T++){var B=null===(e=it.current[T])||void 0===e?void 0:e.current,C=null===(n=ot.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(ct.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=ct.current[e])||void 0===n?void 0:n.current,o=null===(t=at.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={};Xn.forEach(function(e){var n,t,i=e.key,o=null===(n=nt.current[i])||void 0===n?void 0:n.current,r=null===(t=tt.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(!Je.current)if(he){if(Ce&&null!==Ve)if("number"==typeof Ve){var N=Ve,P=Yn[N],j=null===(o=it.current[N])||void 0===o?void 0:o.current;j&&P&&(P.refIndexes||[]).forEach(function(e){var n,t=Un.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ot.current[t])||void 0===n?void 0:n.current;if(i&&(It["left-".concat(N)]||It["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=Ve.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(r=ct.current[F])||void 0===r?void 0:r.current,C=null===(l=at.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(ct.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=ct.current[e])||void 0===n?void 0:n.current,o=null===(t=at.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(Yn.length,Un.length);T++){var B=null===(t=it.current[T])||void 0===t?void 0:t.current,C=null===(i=ot.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(Xn.forEach(function(e){var n,t,i=e.key,o=null===(n=nt.current[i])||void 0===n?void 0:n.current,r=null===(t=tt.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")}}),Je.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=it.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=ot.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=ct.current[e])||void 0===n?void 0:n.current,o=null===(t=at.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)Yn.forEach(function(e,n){var t;(null===(t=it.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=Un.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=rt.current[n])||void 0===t?void 0:t.current,g=null===(i=lt.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-E.left,_=h.left-E.left,m=p.top+p.height/2-E.top,R=h.top+h.height/2-E.top;if(Ce&&Ve===n){var y=null!==(r=null===(o=_n.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=fn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,b=y+(null!==(a=null===(c=_n.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=S+(null!==(d=null===(s=fn.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))};m=C(T,y,b)-E.top,R=C(B,S,A)-E.top}var D=Qt(n);D&&I.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:m,x2:_,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(T=0;T<Math.min(Yn.length,Un.length);T++){var k=null===(c=it.current[T])||void 0===c?void 0:c.current,V=null===(a=ot.current[T])||void 0===a?void 0:a.current;if(k&&V){var L=k.getBoundingClientRect(),H=V.getBoundingClientRect(),G=Math.max(L.top,H.top)+18-E.top,q=(null===(s=Un[T])||void 0===s?void 0:s.id)||"sec-".concat(T);(J=Qt(T))&&I.push({id:q,x1:L.right-E.left,y1:G,x2:H.left-E.left,y2:G,style:J,sectionIdx:T,hasCognitive:!!((null===(d=Yn[T])||void 0===d?void 0:d.cognitiveData)||(null===(v=Un[T])||void 0===v?void 0:v.cognitiveData)||q&&ln[q]),isSubSection:!1})}}Object.keys(ct.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=ct.current[e])||void 0===n?void 0:n.current,a=null===(t=at.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Yn[s[0]],v=Un[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 _=c.getBoundingClientRect(),m=a.getBoundingClientRect(),R=Math.max(_.top,m.top)+16-E.top,y=Zt(e);y&&"Not Defined"!==y.label&&I.push({id:"subsec-".concat(e),x1:_.right-E.left,y1:R,x2:m.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 Ve&&Ve.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Ve.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=rt.current[U])||void 0===f?void 0:f.current,$=null===(g=lt.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!==(_=null===(x=fn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==_?_:0,le=oe+(null!==(R=null===(m=_n.current)||void 0===m?void 0:m.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(S=null===(y=fn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S: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!==(b=ei(K,W))&&void 0!==b?b:Zt(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:Ve})}}if(Yt(I),qt.current&&zt.current){var ae=qt.current.getBoundingClientRect(),se=zt.current.getBoundingClientRect(),de=(ae.top+ae.height/2-E.top+se.top+se.height/2-E.top)/2;$t({x1:ae.right-E.left,x2:se.left-E.left,y:de})}else $t(null);if(qe.size>0){var ve=[],fe=_n.current,ge=fn.current;if(fe&&ge){var pe=[],xe=fe.getBoundingClientRect().top,_e=ge.getBoundingClientRect().top,me=xe+fe.clientHeight,Re=_e+ge.clientHeight,ye=fe.scrollTop,Se=ge.scrollTop,be=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=rt.current[v])||void 0===n?void 0:n.current,g=null===(t=lt.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=ei(a,s))&&void 0!==i?i:Zt(d),_=(j=p.right-E.left)+.5*((F=h.left-E.left-0)-j),m=p.top+p.height/2,R=h.top+h.height/2,y=m-xe+ye,S=R-_e+Se,b="conn-subsec-".concat(v);pe.push({lhsScrollY:y,rhsScrollY:S,x1:j,x2:F,containerTop:be,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:b});var A=Ae(m,xe,me),I=Ae(R,_e,Re),T=A-be,B=I-be,C=R>=_e-4&&R<=Re+4,D="";D=(M=m>=xe-4&&m<=me+4)&&C?u.getBentArrowPath(j,T,F,B):M&&!C?"M ".concat(j,",").concat(T," L ").concat(_,",").concat(T," L ").concat(_,",").concat(B):!M&&C?"M ".concat(_,",").concat(T," L ").concat(_,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(_,",").concat(T," L ").concat(_,",").concat(B),ve.push({id:b,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(he){var O=e,w=Yn[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=Un.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=rt.current[O])||void 0===n?void 0:n.current,r=null===(t=lt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Qt(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-_e+Se,x="conn-".concat(O,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:be,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var _=Ae(f,xe,me),m=Ae(g,_e,Re),R=_-be,y=m-be,S=f>=xe-4&&f<=me+4,b=g>=_e-4&&g<=Re+4,A="";A=S&&b?u.getBentArrowPath(s,R,d,y):S&&!b?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!S&&b?"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=rt.current[N])||void 0===o?void 0:o.current,g=null===(r=lt.current[P])||void 0===r?void 0:r.current;if(!f||!g)return;var j,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=Qt(N),_=(j=p.right-E.left)+.5*((F=h.left-E.left-0)-j),m=p.top+p.height/2,R=h.top+h.height/2,y=m-xe+ye,S=R-_e+Se,b="conn-".concat(N,"-").concat(P);pe.push({lhsScrollY:y,rhsScrollY:S,x1:j,x2:F,containerTop:be,leftIdx:N,rhsArrayIdx:P,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:b});var M;A=Ae(m,xe,me),I=Ae(R,_e,Re),T=A-be,B=I-be,C=R>=_e-4&&R<=Re+4,D="";D=(M=m>=xe-4&&m<=me+4)&&C?u.getBentArrowPath(j,T,F,B):M&&!C?"M ".concat(j,",").concat(T," L ").concat(_,",").concat(T," L ").concat(_,",").concat(B):!M&&C?"M ".concat(_,",").concat(T," L ").concat(_,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(_,",").concat(T," L ").concat(_,",").concat(B),ve.push({id:b,pathD:D,style:x,leftIdx:N,rhsArrayIdx:P})}}),en.current=pe}Ye(ve)}else Ye([]),en.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{mn.current=!1}}},[Xn,Yn,Un,ln,Mn,Jt,Qt,ei,he,Ce,Ve,qe,It,Bt]),oi=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p=en.current;if(p.length&&!Je.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=fn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,_=null!==(r=null===(o=_n.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(c=null===(l=fn.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=fn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+_,b=y+m,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=Ze.current[e.styleId+"-stroke"],o=Ze.current[e.styleId+"-bg"];if(i||o){var r,l=E(n,R,S),c=E(t,y,b),a=l-A,s=c-A,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=b+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(){rn.current=ii},[ii]);var ri=t.useRef(null),li=t.useRef(null),ui=t.useCallback(function(){en.current.length>0&&!Je.current||(null!==ri.current&&clearTimeout(ri.current),ri.current=setTimeout(function(){rn.current(),ri.current=null},50))},[]),ci=t.useCallback(function(){Me(!0),Pe(!1),null!==li.current&&clearTimeout(li.current),null!==ri.current&&(clearTimeout(ri.current),ri.current=null),li.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s,d;try{if(en.current=[],tn.current&&null!==on.current&&null!==Ht.current){var v=on.current,f=Ht.current,g="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR),p=null,h=null,x=null,_=null;if(g){var m=v.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(m[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(m[1]);p=(null===(e=rt.current[R])||void 0===e?void 0:e.current)||null,h=(null===(n=lt.current[R])||void 0===n?void 0:n.current)||null,x=(null===(t=ct.current[m[2]])||void 0===t?void 0:t.current)||(null===(i=it.current[Number(m[2])])||void 0===i?void 0:i.current)||null,_=(null===(o=at.current[m[3]])||void 0===o?void 0:o.current)||(null===(r=ot.current[Number(m[3])])||void 0===r?void 0:r.current)||null}else p=(null===(l=st.current[v])||void 0===l?void 0:l.current)||null,x=(null===(c=it.current[v])||void 0===c?void 0:c.current)||null,h=(null===(a=ut.current[f])||void 0===a?void 0:a.current)||null,_=(null===(s=ot.current[f])||void 0===s?void 0:s.current)||null;if(p&&h&&x&&_){if(x.style.paddingTop="0px",_.style.paddingTop="0px",!he){var y=p.getBoundingClientRect(),S=h.getBoundingClientRect(),b=y.top-S.top;b>0?_.style.paddingTop="".concat(b,"px"):b<0&&(x.style.paddingTop="".concat(Math.abs(b),"px"))}var A=_n.current,E=fn.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=rn.current)||void 0===d||d.call(rn),tn.current&&Pe(!0)}catch(e){console.error("Safely caught error during resize calculation:",e)}finally{Me(!1),li.current=null}},150)},[he,Yn,Un]),ai=t.useCallback(function(e){var n,t,i,o,r,l,c,a,s,d;if(null!==Rn.current&&yn.current&&Math.abs(e.currentTarget.scrollTop-Rn.current)<=2){var v=yn.current;Rn.current=null,yn.current=null,v()}if(!He.current){if(he||ui(),tn.current){var f=on.current,g=Ht.current,p=_n.current,h=fn.current;if(null!==f&&null!==g&&p&&h){var x="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=rt.current["".concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=st.current[f])||void 0===t?void 0:t.current,_="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=lt.current["".concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===i?void 0:i.current:null===(o=ut.current[g])||void 0===o?void 0:o.current;if(x&&_&&Gt.current){var m=void 0,R=void 0;if("string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)){var y=f.split(u.DEVIATION_BADGE_SEPARATOR),S="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);m=null===(r=rt.current[S])||void 0===r?void 0:r.current,R=null===(l=lt.current[S])||void 0===l?void 0:l.current}else m=null===(c=rt.current[f])||void 0===c?void 0:c.current,R=null===(a=lt.current[g])||void 0===a?void 0:a.current;var b=null!==(d=null===(s=Vt.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==d?d:0,A=p.getBoundingClientRect().top,E=A+p.clientHeight;h.getBoundingClientRect().top;h.clientHeight;if(m&&R){var I=m.getBoundingClientRect(),T=R.getBoundingClientRect(),B=I.top+I.height/2;T.top,T.height;var C=((O=B,w=A,N=E,Math.max(w,Math.min(N,O)))-b).toString();Gt.current.setAttribute("y1",C),Gt.current.setAttribute("y2",C);var D=B>=A-4&&B<=E+4;Gt.current.setAttribute("visibility",D?"visible":"hidden")}}}}var O,w,N;en.current.length>0&&!nn.current&&(nn.current=!0,requestAnimationFrame(function(){oi(),nn.current=!1}))}},[oi,he,ui]),si=t.useRef(0),di=t.useRef(0),vi=t.useRef(0),fi=t.useRef(function(){});t.useRef(null),t.useEffect(function(){fi.current=ci},[ci]),t.useEffect(function(){var e=setTimeout(ui,250),n=function(){return fi.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==ri.current&&clearTimeout(ri.current),null!==li.current&&clearTimeout(li.current),window.removeEventListener("resize",n)}},[Kn,Wn,gt,Xn,It,Bt,Yn,Un,Mn,ui,Ce,Ve,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 vn.current&&o.push(e(vn.current,si,n,function(){return fi.current()},function(){})),dn.current&&o.push(e(dn.current,di,t,function(){return fi.current()},function(){return rn.current()})),Vt.current&&o.push(e(Vt.current,vi,i,function(){return fi.current()},function(){return rn.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(){tn.current=Ce},[Ce]),t.useEffect(function(){on.current=Ve},[Ve]);var gi=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";Fn(),null!=e&&(n?Te("No counterpart exists for this section."):(yt(),Ce&&Ve===e?r?St():null==l||l():(ze(new Set([e])),Ye([]),en.current=[],Ae(!0),He.current=!0,Le(e),on.current=e,De(!0),tn.current=!0,Pe(!1),gn.current&&(gn.current.style.height="0px"),pn.current&&(pn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.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=rt.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=lt.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=st.current[e])||void 0===i?void 0:i.current)||null,he){var p=Yn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],_=Un.findIndex(function(e){return e.selfIndex===x});-1!==_&&(d=(null===(r=ut.current[_])||void 0===r?void 0:r.current)||null,v=_)}}else d=(null===(o=ut.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Ht.current=v;var m=_n.current,R=fn.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,f,g,p,h=null,x=null,_=null,m=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=ct.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=it.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=at.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=ot.current[Number(R[3])])||void 0===o?void 0:o.current)||null,_=(null===(r=rt.current[y])||void 0===r?void 0:r.current)||h,m=(null===(l=lt.current[y])||void 0===l?void 0:l.current)||x}else{var S=Number(e),b=null!==v?Number(v):S;h=(null===(c=it.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=ot.current[b])||void 0===s?void 0:s.current)||null,_=(null===(d=rt.current[S])||void 0===d?void 0:d.current)||(null===(f=st.current[S])||void 0===f?void 0:f.current)||h,m=(null===(g=lt.current[b])||void 0===g?void 0:g.current)||(null===(p=ut.current[b])||void 0===p?void 0:p.current)||x}if(_&&m&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=_.getBoundingClientRect(),E=m.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),rn.current&&rn.current(),He.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),Ae(!1),null==l||l()};if(!s||!m)return He.current=!1,Ae(!1),void(null==l||l());if(d&&R){if(!he){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var b=dn.current,A=(null==b?void 0:b.getBoundingClientRect().top)||0,E=b?b.scrollTop+S-A-150:0;return b?void u.smoothScrollTo(b,E,200,y):void y()}var I=s.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=T-(I-m.scrollTop);C<0&&gn.current&&(gn.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 pn.current&&(pn.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&&hn.current&&(hn.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=m.scrollHeight-m.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return xn.current&&(xn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(m,D,B,y)})}e=D}u.smoothScrollTo(m,e,B,y)})}}else y()}))))},[Ve,Fn,Un,Ce,he,Yn,St]),pi=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;jn();var c="left";(null===(o=fn.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=lt.current[l])||void 0===e?void 0:e.current:null===(t=rt.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=lt.current[n])||void 0===i?void 0:i.current:null===(o=rt.current[n])||void 0===o?void 0:o.current};if(t)return St(),ze(new Set),Ye([]),en.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;On({open:!0,anchorEl:e,summary:i})}));gi(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;On({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[gi,jn,On,St]),hi=t.useCallback(function(){var e,n=En.sectionIdx,t=En.isOrphan;if(wn(),null!=n){var i="left";En.anchorEl&&(null===(e=fn.current)||void 0===e?void 0:e.contains(En.anchorEl))&&(i="right"),gi(n,t,{sourceSide:i})}},[gi,En.isOrphan,En.sectionIdx,En.anchorEl,wn]),xi=t.useCallback(function(){wn(),St(),ze(new Set),Ye([]),en.current=[]},[wn,St]),_i=null!==En.sectionIdx&&qe.has(En.sectionIdx),mi=_.useDeviationNavigation({proposedSections:Yn,existingSections:Un,parentDeviationRecord:$n,expandedSections:It,maintainRelativeOrder:!!he,scrollContainerRef:dn,leftContainerRef:_n,lhsBadgeRefs:rt,rhsBadgeRefs:lt}),Ri=mi.showDeviationNavigation,yi=mi.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 $n){if(($n[t]||[]).some(function(e){return e.id===n}))return t}return null},[se,$n]),bi=t.useRef({id:null,triggerMs:null}),Ai=t.useRef(null);t.useEffect(function(){var n;if(null==se?void 0:se.id){var t=Number(se.trigger),i=bi.current;if((null==i?void 0:i.triggerMs)!==t){if(!(se.id.includes(":")&&/:\d+$/.test(se.id)))return bi.current={id:se.id,triggerMs:t},void Mt(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";Ai.current!==se.id&&(wn(),jn(),St(),ze(new Set),Ye([]),en.current=[],Ai.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(){bi.current={id:se.id,triggerMs:t}},h=null,x=null;for(var _ in $n){var m=$n[_].find(function(e){return e.id===r});if(m){h=_,x=m;break}}if(x&&h){var R=Yn.findIndex(function(e){return e.id===h}),y=Un.findIndex(function(e){return e.id===h}),S=-1===R&&-1!==y,b=f(Yn,x.id),A=f(Un,x.id);if(b&&!A&&!S){var E=b.split("-"),I=Number(E[0]);if(he){var T=null===(i=null===(n=Yn[I])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],B=Un.findIndex(function(e){return e.selfIndex===T});-1!==B&&(I=B)}A=e.__spreadArray([I],E.slice(1),!0).join("-")}if(b||A){var C=S||!b&&!!A,D=b?Number(b.split("-")[0]):R,O=A?Number(A.split("-")[0]):y;if(C){if(!(he?!!It["right-".concat(O)]:!!It[String(O)])&&O>=0)return Dt(O,"right"),s+=1,void(d=setTimeout(g,450))}else if(!(he?!!It["left-".concat(D)]:!!It[String(D)])&&D>=0)return Dt(D,"left"),s+=1,void(d=setTimeout(g,450));var w,N=b||"",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=rt.current[F])||void 0===o?void 0:o.current,k=null===(l=lt.current[F])||void 0===l?void 0:l.current,V=C||!M&&!!k,L=V?k:M;if(w=he?V?fn.current:_n.current:dn.current,L&&w){var H=L.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(L).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=V?(null===(o=lt.current[F])||void 0===o?void 0:o.current)||k:(null===(r=rt.current[F])||void 0===r?void 0:r.current)||M;return On({open:!0,anchorEl:d,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})}),void(null==de||de())}gi(j,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t=(null===(n=rt.current[F])||void 0===n?void 0:n.current)||M;On({open:!0,anchorEl:t,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})})}})}};Math.abs(w.scrollTop-q)<=2?z():(Rn.current=q,yn.current=z,w.scrollTo({top:q,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(yn.current){Rn.current=null;var e=yn.current;yn.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,$n,Yn,Un,he,It,Dt,gi,On,Mt]);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(y.default,{section:t,keyPath:i,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:Bt,setExpandedSubSections:Ct,maintainRelativeOrder:he||!1,proposedSections:Yn,existingSections:Un,treeData:Z,deviationNumberRegistry:Jn,connectedSections:qe,activeSideBySideSection:Ve,resolvedMarkdownStyles:sn,getSubSectionRef:vt,getSubSectionCompareStyle:Zt,getBadgeRef:ft,openMoreFunctionsPopup:Nt,openSummaryPopup:pi,showDeviationBadges:_e,resetSideBySide:St,setConnectedSections:ze,setConnectedLines:Ye,cachedConnectedPositions:en,isProposingFix:fe,proposingFixNodeId:ge})};return n.jsxs(i.Box,e.__assign({ref:vn,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,{})})),Dn.open&&n.jsx(S.default,{open:Dn.open,anchorEl:Dn.anchorEl,containerEl:Lt.current,clipTopEl:qt.current,scrollContainerEl:dn.current,onClose:xi,summary:Dn.summary}),n.jsx(d.default,{open:En.open,anchorEl:En.anchorEl,sectionTitle:En.sectionTitle,referenceSectionTitle:En.refSectionTitle,onClose:Fn,onOpenCognitiveCompare:Pt,onOpenSideBySide:hi,onConnect:jt,isConnected:_i,isOrphan:En.isOrphan}),bn.open&&n.jsx(s.default,{open:bn.open,popupRef:Pn,position:Tn,popupConfig:ue,onClose:function(){Bn(null),An(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Nn(null)},markdownStyles:ie,sectionTitle:bn.sectionTitle,referenceSectionTitle:bn.refSectionTitle,cognitiveData:bn.cognitiveData,anchorEl:bn.anchorEl,sectionAnchorEl:bn.sectionAnchorEl,scrollContainerEl:dn.current,badgeStyle:bn.badgeStyle,docData:bn.docData,deviationData:bn.deviationData,isLoading:bn.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(m.default,{componentHeaderText:Q,displayConfig:le,maintainRelativeOrder:he,onCollapseAll:ni,showCollapseAll:ti,onToggleView:function(e){ye(!0),setTimeout(function(){xe(!e),St(),wn(),ze(new Set),Ye([]),en.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ye(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:dn,onScroll:ai,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:pt&&ht?"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:cn.width||"100%",height:cn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Fe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Xt&&n.jsx("g",{children:n.jsx("line",{x1:Xt.x1,y1:Xt.y,x2:Xt.x2,y2:Xt.y,stroke:Rt.badgeBorder,strokeWidth:"1.5"})}),Wt.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&&Ve===t.subSectionKeyPath&&Ne:Ce&&Ve===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),_=Yn[t.sectionIdx]||{title:"",content:""},m=Un[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,S=R[3]||y,b=y.split("-").map(Number),A=S.split("-").map(Number),E=null,I=null;b.length>0&&(E=Yn[b[0]]),A.length>0&&(I=Un[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<b.length;C++)(null==E?void 0:E.subsections)&&(E=E.subsections[b[C]]);for(C=1;C<A.length;C++)(null==I?void 0:I.subsections)&&(I=I.subsections[A[C]]);E&&(_=e.__assign(e.__assign({},E),{title:T||E.title})),console.log("Base Section for Subsection Badge:",_),I&&(m=e.__assign(e.__assign({},I),{title:B||I.title})),console.log("Ref Section for Subsection Badge:",m)}var D=!(null===(l=_.cognitiveData)||void 0===l?void 0:l.isMissingRationale)||Boolean(null===(s=null===(c=_.cognitiveData)||void 0===c?void 0:c.decisioning)||void 0===s?void 0:s.length),O=(null===(g=null===(v=null===(d=_.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&&(bn.open&&Cn===t.id?jn():(Nn(t.id),wt(Ot(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:bn.open&&Cn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),n.jsx(b.default,{connectedLines:We,pathRefs:Ze})]})),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:qt,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:ai,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:hn,style:{width:"100%",height:"0px",flexShrink:0}}),Zn&&Yn.map(function(t,r){var l,c,a=!t.title&&!t.content;if(he&&a)return null;var s=t,d=Qt(r,"left"),v=he?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Un[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:dt(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:it.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:dt("left-accordion-".concat(r)),mb:0,treeData:Z,proposedSections:Yn,existingSections:Un,deviationNumberRegistry:Jn,getSectionCompareStyle:Qt,getBadgeRef:ft,connectedSections:qe,openMoreFunctionsPopup:Nt,openSummaryPopup:pi,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?!!It["left-".concat(r)]:!!It[String(r)],onToggle:function(){xi(),Dt(r,"left")},navigation:t.id?Ri[t.id]:null,showOpenNodeRef:yi,resolvedMarkdownStyles:sn,maintainRelativeOrder:he,showDeviationBadges:_e,renderSubSections:Ei,isProposingFix:fe,proposingFixNodeId:ge,collisionKey:"".concat(Ce?"1":"0","-").concat(String(null!=Ve?Ve:""))})})),he&&d&&n.jsxs(i.Box,e.__assign({ref:rt.current[r],onClick:function(e){var n=he?Un.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Un[r]||{title:"",content:""};Nt(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),pi(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?v?"No Deviation Found":"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?Un.find(function(e){var n;return(null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e))||{title:"",content:""}}):Un[r]||{title:"",content:""};Nt(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:xn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:Lt,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(),bn.open&&Cn===xt?jn():(Nn(xt),wt(Ot(n.currentTarget,{title:"",content:"",evaluationResult:_t,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,xt,!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!=mt?mt: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:bn.open&&Cn===xt?"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:[be&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:zt,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:qn,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:qn}))}))})),n.jsxs(i.Box,e.__assign({ref:fn,onScroll:ai,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:gn,style:{width:"100%",height:"0px",flexShrink:0}}),Zn&&Un.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(he){u=Yn.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=Yn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=Yn.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=Qt(d))}else u=[o+1],(c=qe.has(o))&&(a=Qt(o));var v=Qt(he&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:ut.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:ot.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:dt("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?!!It["right-".concat(o)]:!!It[String(o)],treeData:Z,proposedSections:Yn,existingSections:Un,deviationNumberRegistry:Jn,getBadgeRef:ft,getSectionCompareStyle:Qt,connectedSections:qe,openMoreFunctionsPopup:Nt,openSummaryPopup:pi,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Si,onToggle:function(){xi(),Dt(o,"right")},navigation:t.id?Ri[t.id]:null,showOpenNodeRef:yi,resolvedMarkdownStyles:sn,maintainRelativeOrder:he,showDeviationBadges:_e,renderSubSections:Ei,isProposingFix:fe,proposingFixNodeId:ge,collisionKey:"".concat(Ce?"1":"0","-").concat(String(null!=Ve?Ve:""))})})),he&&v&&n.jsx(i.Box,e.__assign({ref:lt.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:pn,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"),g=require("./components/ThreeDotsLoader.js"),f=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"),S=require("./components/CognitiveSummaryPopup.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var b,E,I,T,B,C,D,O,w,N,j,P,F,k,M,L=A.componentHeaderText,V=void 0===L?a.DEFAULT_COMPONENT_HEADER_TEXT:L,H=A.treeData,G=A.comparisonConfig,q=A.leftColumnTitleText,z=A.rightColumnTitleText,W=A.markdownStyles,Y=A.displayConfig,K=void 0===Y?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,expandAllSections:!1,expandLevels:1}:Y,U=A.popupConfig,X=A.deviationData,J=void 0===X?{}:X,Q=A.deviationNodeIdToView,Z=A.resetDeviationNodeId,$=t.useState(K.maintainRelativeOrder),ee=$[0],ne=$[1],te=!!(null==K?void 0:K.showDeviationBadges),ie=!!(null==K?void 0:K.expandAllSections),oe=t.useState(!1),re=oe[0],le=oe[1],ue=t.useState(!1),ce=ue[0],ae=ue[1],se=t.useState(null),de=se[0],ve=se[1],ge=t.useState(!1),fe=ge[0],pe=ge[1],he=t.useState(!1),xe=he[0],me=he[1],_e=t.useState(!1),Re=_e[0],ye=_e[1],Se=null==K?void 0:K.expandLevels,Ae=t.useState(null),be=Ae[0],Ee=Ae[1],Ie=t.useRef(!1),Te=t.useState(new Set),Be=Te[0],Ce=Te[1],De=t.useState([]),Oe=De[0],we=De[1],Ne=t.useRef(null),je=t.useRef(!1),Pe=t.useRef(null),Fe=t.useRef({}),ke=t.useRef([]),Me=t.useRef(!1),Le=t.useRef(!1),Ve=t.useRef(null),He=t.useRef(function(){}),Ge=t.useMemo(function(){return(null==H?void 0:H.cognitive_decisioning)||{}},[H]),qe=t.useState({width:0,height:0}),ze=qe[0],We=qe[1],Ye=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),W)},[W]),Ke=t.useRef(null),Ue=t.useRef(null),Xe=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(null),Ze=t.useRef(null),$e=t.useRef(null),en=t.useRef(null),nn=t.useRef(!1),tn=t.useRef(null),on=t.useRef(null),rn=p.useComparePopups(Ke),ln=rn.cognitivePopup,un=rn.setCognitivePopup,cn=rn.moreFunctions,an=rn.setMoreFunctions,sn=rn.position,dn=rn.setPosition,vn=rn.activeBadgeId,gn=rn.summaryPopup,fn=rn.setSummaryPopup,pn=rn.closeSummaryPopup,hn=rn.setActiveBadgeId,xn=rn.popupRef,mn=rn.closeCognitivePopup,_n=rn.closeMoreFunctionsPopup,Rn=t.useMemo(function(){var e,n,t,i,o,r,l;return{fields:null!==(e=null==G?void 0:G.fields)&&void 0!==e?e:c.DEFAULT_FIELD_CONFIG,thresholds:{high:null!==(t=null===(n=null==G?void 0:G.thresholds)||void 0===n?void 0:n.high)&&void 0!==t?t:c.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:null!==(o=null===(i=null==G?void 0:G.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:c.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:null!==(l=null===(r=null==G?void 0:G.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[G]),yn=t.useState(null),Sn=yn[0];yn[1];var An=null===(I=null===(b=null==H?void 0:H.documents)||void 0===b?void 0:b[null===(E=null==H?void 0:H.input_index_map)||void 0===E?void 0:E[0]])||void 0===I?void 0:I.title,bn=null===(C=null===(T=null==H?void 0:H.documents)||void 0===T?void 0:T[null===(B=null==H?void 0:H.input_index_map)||void 0===B?void 0:B[1]])||void 0===C?void 0:C.title,En=u.safeStringify(q||An||"Uploaded Contract"),In=u.safeStringify(z||bn||"Reference Template"),Tn=f.useCognitiveTreeData(H,ee,J,Rn),Bn=Tn.activeProposed,Cn=Tn.existingRule,Dn=Tn.proposedSections,On=Tn.existingSections,wn=Tn.visibleFields,Nn=Tn.parentDeviationRecord,jn=Tn.deviationNumberRegistry,Pn=Tn.parseError;t.useEffect(function(){Pn&&ve("Failed to load comparison: ".concat(Pn))},[Pn]);var Fn=Dn.length>0||On.length>0,kn=h.useSectionRefs(wn.map(function(e){return e.key}),Math.max(Dn.length,On.length)),Mn=kn.leftRefs,Ln=kn.rightRefs,Vn=kn.sectionLeftRefs,Hn=kn.sectionRightRefs,Gn=kn.lhsBadgeRefs,qn=kn.rhsBadgeRefs,zn=kn.sectionRightRowRefs,Wn=kn.subSectionLeftRefs,Yn=kn.subSectionRightRefs,Kn=kn.sectionRowRefs,Un=kn.getSectionRowRef,Xn=kn.getSubSectionRef,Jn=kn.getBadgeRef,Qn=Cn.analysis,Zn=u.safeStringify(null===(O=null===(D=null==Qn?void 0:Qn.rule_difference_comparison)||void 0===D?void 0:D.summary)||void 0===O?void 0:O.overall_summary),$n=!!Zn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),et=null!==(w=null==H?void 0:H.base_root_id)&&void 0!==w?w:"-1";null==H||H[et];var nt=(null===(N=null==J?void 0:J[et])||void 0===N?void 0:N.evaluation_result)||(null===(P=null===(j=null==H?void 0:H.nodes)||void 0===j?void 0:j[et])||void 0===P?void 0:P.evaluation_result)||null,tt=u.extractDeviationScore(nt),it=u.generateColorPalette(null!==(M=null===(k=null===(F=null==nt?void 0:nt.evaluation_outputs)||void 0===F?void 0:F.metadata)||void 0===k?void 0:k.label_color)&&void 0!==M?M:""),ot=t.useCallback(function(){var e,n,t,i,o,r;pe(!1),Le.current=!1;var l=Ve.current,c=mt.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=Wn.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=Vn.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=Vn.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=Yn.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=Hn.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=Hn.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Ee(null),Ve.current=null,mt.current=null,me(!1),ae(!1),Je.current&&(Je.current.style.height="0px"),Qe.current&&(Qe.current.style.height="0px"),Ze.current&&(Ze.current.style.height="0px"),$e.current&&($e.current.style.height="0px")},[]),rt=x.useAccordionState({maintainRelativeOrder:!!ee,proposedSections:Dn,existingSections:On,activeSideBySideSection:be,connectedSections:Be,resetSideBySide:ot,setConnectedSections:Ce,setConnectedLines:we,cachedConnectedPositions:ke,svgContainerRef:Ne,isAnimatingRef:je,animationTimerRef:Pe,calculateLinesRef:He,sectionLeftRefs:Vn,sectionRightRefs:Hn,subSectionLeftRefs:Wn,subSectionRightRefs:Yn}),lt=rt.expandedSections,ut=rt.setExpandedSections,ct=rt.expandedSubSections,at=rt.setExpandedSubSections,st=rt.toggleSection;t.useEffect(function(){var e=void 0!==Se?Se:ie?1/0:0;if(0!==e){var n={},t=Math.max(Dn.length,On.length);if(e>=1)for(var i=0;i<t;i+=1)ee?(i<Dn.length&&(n["left-".concat(i)]=!0),i<On.length&&(n["right-".concat(i)]=!0)):n[String(i)]=!0;var o={},r=function(n,t,i){var l;!(null===(l=null==n?void 0:n.subsections)||void 0===l?void 0:l.length)||i>e||n.subsections.forEach(function(e,n){var l="".concat(t,"-").concat(n);o[l]=!0,r(e,l,i+1)})};e>=2&&(Dn.forEach(function(e,n){return r(e,String(n),2)}),On.forEach(function(e,n){return r(e,String(n),2)})),ut(n),at(o)}},[ie,Se,ee,Dn,On,ut,at]);var dt=t.useCallback(function(e,n,t,i,o,r,l){var c,a,s,d=u.safeStringify(null==n?void 0:n.id)||u.safeStringify(null==t?void 0:t.id)||"",v=(d?Ge[d]:null)||(null==n?void 0:n.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:d,decisioning:[],gap:[],relevance_score:0},g=null!==(a=null===(c=Kn.current[i])||void 0===c?void 0:c.current)&&void 0!==a?a:null;return{isLoading:null!==(s=null==K?void 0:K.isLoading)&&void 0!==s&&s,open:!0,sectionTitle:(null==n?void 0:n.displayTitle)?null==n?void 0:n.title:"no title",refSectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:g,badgeStyle:r||null,sectionIdx:i,docData:{documents:null==H?void 0:H.documents,input_index_map:null==H?void 0:H.input_index_map},deviationData:(null==n?void 0:n.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,isOrphan:!!o}},[Ge,H]),vt=t.useCallback(function(e){_n(),dn(null),un(e)},[_n]),gt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),cn.open&&cn.sectionIdx===o)_n();else{var c=e.currentTarget,a="left";(null===(l=Xe.current)||void 0===l?void 0:l.contains(c))&&(a="right");Le.current&&ot(),Ce(new Set),we([]),ke.current=[],mn(),gn.open?Ht():pn(),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=qn.current[l])||void 0===e?void 0:e.current:null===(n=Gn.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=qn.current[o])||void 0===t?void 0:t.current:null===(i=Gn.current[o])||void 0===i?void 0:i.current}()||c;an(dt(e,n,i,o,t,r))})}},ft=t.useCallback(function(){null!==cn.sectionIdx&&cn.anchorEl?vt(e.__assign(e.__assign({},cn),{open:!0})):_n()},[cn,_n,vt]),pt=t.useCallback(function(){var e=cn.sectionIdx,n=cn.isOrphan;_n(),pn(),null!==e&&(n?ve("No counterpart exists to connect to."):(Le.current&&ot(),we([]),ke.current=[],Ce(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){He.current&&He.current()},50)))},[cn.sectionIdx,cn.isOrphan,_n,pn,ot]),ht=t.useRef(null),xt=t.useRef(null),mt=t.useRef(null),_t=t.useRef(null),Rt=t.useRef(null),yt=t.useRef(null),St=t.useState([]),At=St[0],bt=St[1];t.useRef(null);var Et=t.useState(null),It=Et[0],Tt=Et[1];t.useEffect(function(){if(Sn){var e=Rn.fields.find(function(e){return e.analysisKey===Sn||e.key===Sn});if(e){var n=Mn.current[e.key]||Ln.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Sn,Rn.fields]);var Bt=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==Qn?void 0:Qn.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 g=d.mappings[0]||{};return{score:d.score,relation:g.relation||"",highlightsA:(null===(l=g.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=g.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}},[Qn]),Ct=t.useCallback(function(n,t){var i,o,r,l,c,s,d;void 0===t&&(t="left");var v=null,g=null;if("left"===t)if(v=Dn[n],ee&&v){var f=On.filter(function(e){var n;return null===(n=v.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});g=f.find(function(e){return e.evaluationResult})||f[0]}else g=On[n];else if(g=On[n],ee&&g){var p=Dn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(g.selfIndex)});v=p.find(function(e){return e.evaluationResult})||p[0]}else v=Dn[n];var h=(null==v?void 0:v.relation)&&"not_defined"!==v.relation,x=(null==g?void 0:g.relation)&&"not_defined"!==g.relation,m=!(!(null==v?void 0:v.cognitiveData)&&!(null==g?void 0:g.cognitiveData));if(!h&&!x&&!m)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var _=null!==(o=null!==(i=null==v?void 0:v.evaluationResult)&&void 0!==i?i:null==g?void 0:g.evaluationResult)&&void 0!==o?o:null,R=null===(r=null==_?void 0:_.evaluation_outputs)||void 0===r?void 0:r.output_value,y=null!==(s=null===(c=null===(l=null==_?void 0:_.evaluation_outputs)||void 0===l?void 0:l.metadata)||void 0===c?void 0:c.label_color)&&void 0!==s?s:a.DEFAULT_DEVIAION_COLOR;return null!=_?e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null!==(d=R)&&void 0!==d?d:""}):e.__assign(e.__assign({},u.generateColorPalette(y)),{label:null})},[Dn,On,Ge,Rn,ee]),Dt=t.useCallback(function(n){for(var t,i,o,r,l,c,s,d,v,g=n.split("-").map(Number),f=Dn[g[0]],p=On[g[0]],h=1;h<g.length;h++)(null==f?void 0:f.subsections)&&(f=f.subsections[g[h]]),(null==p?void 0:p.subsections)&&(p=p.subsections[g[h]]);if(!f&&!p)return null;var x=(null==f?void 0:f.relation)&&"not_defined"!==f.relation,m=(null==p?void 0:p.relation)&&"not_defined"!==p.relation,_=u.safeStringify(null==f?void 0:f.id)||u.safeStringify(null==p?void 0:p.id)||"",R=!(!(null==f?void 0:f.cognitiveData)&&!(null==p?void 0:p.cognitiveData));if(!x&&!m&&!R)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==f?void 0:f.cognitiveRelevanceScore)&&void 0!==t?t:null==p?void 0:p.cognitiveRelevanceScore)&&void 0!==i||_&&(null===(o=Ge[_])||void 0===o||o.relevance_score);var y=null!==(l=null!==(r=null==f?void 0:f.evaluationResult)&&void 0!==r?r:null==p?void 0:p.evaluationResult)&&void 0!==l?l:null,S=null===(c=null==y?void 0:y.evaluation_outputs)||void 0===c?void 0:c.output_value,A=null!==(v=null===(d=null===(s=null==y?void 0:y.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===d?void 0:d.label_color)&&void 0!==v?v:a.DEFAULT_DEVIAION_COLOR;return null!=y?e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null!=S?S:""}):e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[Dn,On,Ge,Rn]),Ot=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,g,f,p,h,x,m,_,R,y,S;if(!nn.current&&!je.current){nn.current=!0;try{if(!ht.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!lt[t]&&!1===ee)return!1;if(ee&&!lt["left-".concat(t)]&&!lt["right-".concat(t)]&&!lt[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},b=ht.current.getBoundingClientRect();We({width:b.width,height:b.height});var E=[];if(wn.forEach(function(e){var n,t,i=e.key,o=null===(n=Mn.current[i])||void 0===n?void 0:n.current,r=null===(t=Ln.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")}),!je.current){for(var I=0;I<Math.max(Dn.length,On.length);I++){var T=null===(e=Vn.current[I])||void 0===e?void 0:e.current,B=null===(n=Hn.current[I])||void 0===n?void 0:n.current;T&&(T.style.height="auto",T.style.minHeight="0px"),B&&(B.style.height="auto",B.style.minHeight="0px")}ee||Object.keys(Wn.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=Wn.current[e])||void 0===n?void 0:n.current,o=null===(t=Yn.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 C={};wn.forEach(function(e){var n,t,i=e.key,o=null===(n=Mn.current[i])||void 0===n?void 0:n.current,r=null===(t=Ln.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();C[i]=Math.max(l.height,u.height)}});var D={left:{},right:{}},O={};if(!je.current)if(ee){if(fe&&null!==be)if("number"==typeof be){var w=be,N=Dn[w],j=null===(o=Vn.current[w])||void 0===o?void 0:o.current;j&&N&&(N.refIndexes||[]).forEach(function(e){var n,t=On.findIndex(function(n){return n.selfIndex===e}),i=null===(n=Hn.current[t])||void 0===n?void 0:n.current;if(i&&(lt["left-".concat(w)]||lt["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);D.left[w]=Math.max(D.left[w]||0,o),D.right[t]=Math.max(D.right[t]||0,o)}})}else{var P=be.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(P){T=null===(r=Wn.current[P])||void 0===r?void 0:r.current,B=null===(l=Yn.current[P])||void 0===l?void 0:l.current;if(T&&B){F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);O[P]=Math.max(O[P]||0,F)}}}}else{Object.keys(Wn.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=Wn.current[e])||void 0===n?void 0:n.current,o=null===(t=Yn.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);O[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(I=0;I<Math.min(Dn.length,On.length);I++){var T=null===(t=Vn.current[I])||void 0===t?void 0:t.current,B=null===(i=Hn.current[I])||void 0===i?void 0:i.current;if(T&&B){var F=Math.max(T.getBoundingClientRect().height,B.getBoundingClientRect().height);D.left[I]=F,D.right[I]=F}}}if(wn.forEach(function(e){var n,t,i=e.key,o=null===(n=Mn.current[i])||void 0===n?void 0:n.current,r=null===(t=Ln.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=C[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),je.current||(Object.entries(D.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Vn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(D.right).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=Hn.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),ee||Object.keys(O).forEach(function(e){var n,t,i=null===(n=Wn.current[e])||void 0===n?void 0:n.current,o=null===(t=Yn.current[e])||void 0===t?void 0:t.current;if(i&&o&&O[e]){var r=O[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),ee)Dn.forEach(function(e,n){var t;(null===(t=Vn.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=On.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var g=null===(t=Gn.current[n])||void 0===t?void 0:t.current,f=null===(i=qn.current[v])||void 0===i?void 0:i.current;if(g&&f){var p=g.getBoundingClientRect(),h=f.getBoundingClientRect(),x=p.right-b.left,m=h.left-b.left,_=p.top+p.height/2-b.top,R=h.top+h.height/2-b.top;if(fe&&be===n){var y=null!==(r=null===(o=en.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,S=null!==(u=null===(l=Xe.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,A=y+(null!==(a=null===(c=en.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=S+(null!==(d=null===(s=Xe.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,A)-b.top,R=C(B,S,I)-b.top}var D=Ct(n);D&&E.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:_,x2:m,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(I=0;I<Math.min(Dn.length,On.length);I++){var k=null===(c=Vn.current[I])||void 0===c?void 0:c.current,M=null===(a=Hn.current[I])||void 0===a?void 0:a.current;if(k&&M){var L=k.getBoundingClientRect(),V=M.getBoundingClientRect(),H=Math.max(L.top,V.top)+18-b.top,G=(null===(s=On[I])||void 0===s?void 0:s.id)||"sec-".concat(I);(J=Ct(I))&&E.push({id:G,x1:L.right-b.left,y1:H,x2:V.left-b.left,y2:H,style:J,sectionIdx:I,hasCognitive:!!((null===(d=Dn[I])||void 0===d?void 0:d.cognitiveData)||(null===(v=On[I])||void 0===v?void 0:v.cognitiveData)||G&&Ge[G]),isSubSection:!1})}}Object.keys(Wn.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=Wn.current[e])||void 0===n?void 0:n.current,a=null===(t=Yn.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Dn[s[0]],v=On[s[0]],g=1;g<s.length;g++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[g]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[g]]);var f=!!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(f&&p||h&&x){var m=c.getBoundingClientRect(),_=a.getBoundingClientRect(),R=Math.max(m.top,_.top)+16-b.top,y=Dt(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:m.right-b.left,y1:R,x2:_.left-b.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(fe&&"string"==typeof be&&be.includes(u.DEVIATION_BADGE_SEPARATOR)){var q=be.split(u.DEVIATION_BADGE_SEPARATOR),z=q[0],W=q[1],Y=q[2],K=(q[3],"".concat(z).concat(u.DEVIATION_BADGE_SEPARATOR).concat(W)),U=null===(g=Gn.current[K])||void 0===g?void 0:g.current,X=null===(f=qn.current[K])||void 0===f?void 0:f.current;if(U&&X){var J,Q=U.getBoundingClientRect(),Z=X.getBoundingClientRect(),$=Q.right-b.left,ne=Z.left-b.left,te=Q.top+Q.height/2-b.top,ie=Z.top+Z.height/2-b.top;if(ee){var oe=null!==(h=null===(p=en.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(m=null===(x=Xe.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,le=oe+(null!==(R=null===(_=en.current)||void 0===_?void 0:_.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(S=null===(y=Xe.current)||void 0===y?void 0:y.clientHeight)&&void 0!==S?S:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,le)-b.top,ie=ce(Z.top+Z.height/2,re,ue)-b.top}(J=Dt(Y))&&E.push({id:"line-subsec-".concat(K),x1:$,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:be})}}if(bt(E),Rt.current&&yt.current){var ae=Rt.current.getBoundingClientRect(),se=yt.current.getBoundingClientRect(),de=(ae.top+ae.height/2-b.top+se.top+se.height/2-b.top)/2;Tt({x1:ae.right-b.left,x2:se.left-b.left,y:de})}else Tt(null);if(Be.size>0){var ve=[],ge=en.current,pe=Xe.current;if(ge&&pe){var he=[],xe=ge.getBoundingClientRect().top,me=pe.getBoundingClientRect().top,_e=xe+ge.clientHeight,Re=me+pe.clientHeight,ye=ge.scrollTop,Se=pe.scrollTop,Ae=b.top,Ee=function(e,n,t){return Math.max(n,Math.min(t,e))};Be.forEach(function(e){var n,t,i,o,r;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=e.split(u.DEVIATION_BADGE_SEPARATOR),c=l[0],a=l[1],s=l[2],d=(l[3],"".concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(a)),v=null===(n=Gn.current[d])||void 0===n?void 0:n.current,g=null===(t=qn.current[d])||void 0===t?void 0:t.current;if(!v||!g)return;var f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=Dt(s),x=(j=f.right-b.left)+.5*((P=p.left-b.left-0)-j),m=f.top+f.height/2,_=p.top+p.height/2,R=m-xe+ye,y=_-me+Se,S="conn-subsec-".concat(d);he.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Ae,leftIdx:e,rhsArrayIdx:e,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var A=Ee(m,xe,_e),E=Ee(_,me,Re),I=A-Ae,T=E-Ae,B=_>=me-4&&_<=Re+4,C="";C=(F=m>=xe-4&&m<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:C,style:h,leftIdx:e,rhsArrayIdx:e})}else if(ee){var D=e,O=Dn[D];if(!(null===(r=null==O?void 0:O.refIndexes)||void 0===r?void 0:r.length))return;O.refIndexes.forEach(function(e){var n,t,i=On.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=Gn.current[D])||void 0===n?void 0:n.current,r=null===(t=qn.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=Ct(D),s=l.right-b.left,d=c.left-b.left-0,v=s+.5*(d-s),g=l.top+l.height/2,f=c.top+c.height/2,p=g-xe+ye,h=f-me+Se,x="conn-".concat(D,"-").concat(i);he.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Ae,leftIdx:D,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ee(g,xe,_e),_=Ee(f,me,Re),R=m-Ae,y=_-Ae,S=g>=xe-4&&g<=_e+4,A=f>=me-4&&f<=Re+4,E="";E=S&&A?u.getBentArrowPath(s,R,d,y):S&&!A?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!S&&A?"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:E,style:a,leftIdx:D,rhsArrayIdx:i})}}})}else{var w=e,N=w;v=null===(i=Gn.current[w])||void 0===i?void 0:i.current,g=null===(o=qn.current[N])||void 0===o?void 0:o.current;if(!v||!g)return;var j,P;f=v.getBoundingClientRect(),p=g.getBoundingClientRect(),h=Ct(w),x=(j=f.right-b.left)+.5*((P=p.left-b.left-0)-j),m=f.top+f.height/2,_=p.top+p.height/2,R=m-xe+ye,y=_-me+Se,S="conn-".concat(w,"-").concat(N);he.push({lhsScrollY:R,rhsScrollY:y,x1:j,x2:P,containerTop:Ae,leftIdx:w,rhsArrayIdx:N,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:S});var F;A=Ee(m,xe,_e),E=Ee(_,me,Re),I=A-Ae,T=E-Ae,B=_>=me-4&&_<=Re+4,C="";C=(F=m>=xe-4&&m<=_e+4)&&B?u.getBentArrowPath(j,I,P,T):F&&!B?"M ".concat(j,",").concat(I," L ").concat(x,",").concat(I," L ").concat(x,",").concat(T):!F&&B?"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T," L ").concat(P,",").concat(T):"M ".concat(x,",").concat(I," L ").concat(x,",").concat(T),ve.push({id:S,pathD:C,style:h,leftIdx:w,rhsArrayIdx:N})}}),ke.current=he}we(ve)}else we([]),ke.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{nn.current=!1}}},[wn,Dn,On,Ge,Rn,Bt,Ct,ee,fe,be,Be,lt,ct]),wt=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,g,f,p=ke.current;if(p.length&&!je.current){var h=null!==(n=null===(e=en.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=Xe.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(r=null===(o=en.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,_=null!==(c=null===(l=Xe.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=en.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=Xe.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,S=R+m,A=y+_,b=null!==(f=null===(g=ht.current)||void 0===g?void 0:g.getBoundingClientRect().top)&&void 0!==f?f: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=Fe.current[e.styleId+"-stroke"],o=Fe.current[e.styleId+"-bg"];if(i||o){var r,l=E(n,R,S),c=E(t,y,A),a=l-b,s=c-b,d=n>=R-4&&n<=S+4,v=t>=y-4&&t<=A+4,g=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(g,",").concat(a," L ").concat(g,",").concat(s):!d&&v?"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(g,",").concat(a," L ").concat(g,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){He.current=Ot},[Ot]);var Nt=t.useRef(null),jt=t.useRef(null),Pt=t.useCallback(function(){ke.current.length>0&&!je.current||(null!==Nt.current&&clearTimeout(Nt.current),Nt.current=setTimeout(function(){He.current(),Nt.current=null},50))},[]),Ft=t.useCallback(function(){ye(!0),me(!1),null!==jt.current&&clearTimeout(jt.current),null!==Nt.current&&(clearTimeout(Nt.current),Nt.current=null),jt.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s;if(ke.current=[],Le.current&&null!==Ve.current&&null!==mt.current){var d=Ve.current,v=mt.current,g=null,f=null,p=null,h=null;if("string"==typeof d&&d.includes(u.DEVIATION_BADGE_SEPARATOR)){var x=d.split(u.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(x[1]);g=(null===(e=Gn.current[m])||void 0===e?void 0:e.current)||null,f=(null===(n=qn.current[m])||void 0===n?void 0:n.current)||null,p=(null===(t=Wn.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=Vn.current[Number(x[2])])||void 0===i?void 0:i.current)||null,h=(null===(o=Yn.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=Hn.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else g=(null===(l=Kn.current[d])||void 0===l?void 0:l.current)||null,p=(null===(c=Vn.current[d])||void 0===c?void 0:c.current)||null,f=(null===(a=zn.current[v])||void 0===a?void 0:a.current)||null,h=(null===(s=Hn.current[v])||void 0===s?void 0:s.current)||null;if(g&&f&&p&&h){if(p.style.paddingTop="0px",h.style.paddingTop="0px",!ee){var _=g.getBoundingClientRect(),R=f.getBoundingClientRect(),y=_.top-R.top;y>0?h.style.paddingTop="".concat(y,"px"):y<0&&(p.style.paddingTop="".concat(Math.abs(y),"px"))}var S=en.current,A=Xe.current;if(S&&A){var b=g.getBoundingClientRect().top-S.getBoundingClientRect().top+S.scrollTop,E=f.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop-(b-S.scrollTop);Math.abs(A.scrollTop-E)>1&&(A.scrollTop=E)}}}He.current(),Le.current&&me(!0),ye(!1),jt.current=null},150)},[ee,Dn,On]),kt=t.useCallback(function(e){var n,t,i,o,r,l,c,a,s,d;if(null!==tn.current&&on.current&&Math.abs(e.currentTarget.scrollTop-tn.current)<=2){var v=on.current;tn.current=null,on.current=null,v()}if(!Ie.current){if(ee||Pt(),Le.current){var g=Ve.current,f=mt.current,p=en.current,h=Xe.current;if(null!==g&&null!==f&&p&&h){var x="string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(n=Gn.current["".concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===n?void 0:n.current:null===(t=Kn.current[g])||void 0===t?void 0:t.current,m="string"==typeof f&&f.includes(u.DEVIATION_BADGE_SEPARATOR)?null===(i=qn.current["".concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f.split(u.DEVIATION_BADGE_SEPARATOR)[1])])||void 0===i?void 0:i.current:null===(o=zn.current[f])||void 0===o?void 0:o.current;if(x&&m&&_t.current){var _=void 0,R=void 0;if("string"==typeof g&&g.includes(u.DEVIATION_BADGE_SEPARATOR)){var y=g.split(u.DEVIATION_BADGE_SEPARATOR),S="".concat(y[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(y[1]);_=null===(r=Gn.current[S])||void 0===r?void 0:r.current,R=null===(l=qn.current[S])||void 0===l?void 0:l.current}else _=null===(c=Gn.current[g])||void 0===c?void 0:c.current,R=null===(a=qn.current[f])||void 0===a?void 0:a.current;var A=null!==(d=null===(s=ht.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==d?d:0,b=p.getBoundingClientRect().top,E=b+p.clientHeight;h.getBoundingClientRect().top;h.clientHeight;if(_&&R){var I=_.getBoundingClientRect(),T=R.getBoundingClientRect(),B=I.top+I.height/2;T.top,T.height;var C=((O=B,w=b,N=E,Math.max(w,Math.min(N,O)))-A).toString();_t.current.setAttribute("y1",C),_t.current.setAttribute("y2",C);var D=B>=b-4&&B<=E+4;_t.current.setAttribute("visibility",D?"visible":"hidden")}}}}var O,w,N;ke.current.length>0&&!Me.current&&(Me.current=!0,requestAnimationFrame(function(){wt(),Me.current=!1}))}},[wt,ee,Pt]);t.useEffect(function(){var e=setTimeout(Pt,250);window.addEventListener("resize",Ft);var n=null,t=null;return Ke.current&&(n=new ResizeObserver(Pt)).observe(Ke.current),ht.current&&(t=new ResizeObserver(Pt)).observe(ht.current),function(){clearTimeout(e),null!==Nt.current&&clearTimeout(Nt.current),null!==jt.current&&clearTimeout(jt.current),window.removeEventListener("resize",Ft),null==n||n.disconnect(),null==t||t.disconnect()}},[Bn,Cn,Qn,wn,lt,ct,Dn,On,Rn,Pt,Ft,fe,be,xe,Be]),t.useEffect(function(){Le.current=fe},[fe]),t.useEffect(function(){Ve.current=be},[be]);var Mt=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";_n(),null!=e&&(n?ve("No counterpart exists for this section."):fe&&be===e?r?ot():null==l||l():(Ce(new Set([e])),we([]),ke.current=[],ae(!0),Ie.current=!0,Ee(e),Ve.current=e,pe(!0),Le.current=!0,me(!1),Je.current&&(Je.current.style.height="0px"),Qe.current&&(Qe.current.style.height="0px"),Ze.current&&(Ze.current.style.height="0px"),$e.current&&($e.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 g=e.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(g[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(g[1]);s=(null===(n=Gn.current[f])||void 0===n?void 0:n.current)||null,d=(null===(t=qn.current[f])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=Kn.current[e])||void 0===i?void 0:i.current)||null,ee){var p=Dn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],m=On.findIndex(function(e){return e.selfIndex===x});-1!==m&&(d=(null===(r=zn.current[m])||void 0===r?void 0:r.current)||null,v=m)}}else d=(null===(o=zn.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;mt.current=v;var _=en.current,R=Xe.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,g,f,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=Wn.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=Vn.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=Yn.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=Hn.current[Number(R[3])])||void 0===o?void 0:o.current)||null,m=(null===(r=Gn.current[y])||void 0===r?void 0:r.current)||h,_=(null===(l=qn.current[y])||void 0===l?void 0:l.current)||x}else{var S=Number(e),A=null!==v?Number(v):S;h=(null===(c=Vn.current[S])||void 0===c?void 0:c.current)||null,x=(null===(s=Hn.current[A])||void 0===s?void 0:s.current)||null,m=(null===(d=Gn.current[S])||void 0===d?void 0:d.current)||(null===(g=Kn.current[S])||void 0===g?void 0:g.current)||h,_=(null===(f=qn.current[A])||void 0===f?void 0:f.current)||(null===(p=zn.current[A])||void 0===p?void 0:p.current)||x}if(m&&_&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var b=m.getBoundingClientRect(),E=_.getBoundingClientRect(),I=b.top-E.top;I>0?x.style.paddingTop="".concat(I,"px"):I<0&&(h.style.paddingTop="".concat(Math.abs(I),"px"))}}(),me(!0),He.current&&He.current(),Ie.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):_&&_.dispatchEvent(new Event("scroll")),ae(!1),null==l||l()};if(!s||!_)return Ie.current=!1,ae(!1),void(null==l||l());if(d&&R){if(!ee){var S=0;S="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var A=Ke.current,b=(null==A?void 0:A.getBoundingClientRect().top)||0,E=A?A.scrollTop+S-b-150:0;return A?void u.smoothScrollTo(A,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&&Je.current&&(Je.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 Qe.current&&(Qe.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&&Ze.current&&(Ze.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 $e.current&&($e.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(_,D,B,y)})}e=D}u.smoothScrollTo(_,e,B,y)})}}else y()})))},[be,_n,On,fe,ee,Dn,ot]),Lt=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;mn();var c="left";(null===(o=Xe.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=qn.current[l])||void 0===e?void 0:e.current:null===(t=Gn.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=qn.current[n])||void 0===i?void 0:i.current:null===(o=Gn.current[n])||void 0===o?void 0:o.current};if(t)return ot(),Ce(new Set),we([]),ke.current=[],void(r&&requestAnimationFrame(function(){var e=a()||l;fn({open:!0,anchorEl:e,summary:i})}));Mt(n,t,r?{toggleIfSame:!1,sourceSide:c,onReady:function(){var e=a()||l;fn({open:!0,anchorEl:e,summary:i})}}:{toggleIfSame:!1,sourceSide:c})},[Mt,mn,fn,ot]),Vt=t.useCallback(function(){var e,n=cn.sectionIdx,t=cn.isOrphan;if(pn(),null!=n){var i="left";cn.anchorEl&&(null===(e=Xe.current)||void 0===e?void 0:e.contains(cn.anchorEl))&&(i="right"),Mt(n,t,{sourceSide:i})}},[Mt,cn.isOrphan,cn.sectionIdx,cn.anchorEl,pn]),Ht=t.useCallback(function(){pn(),ot(),Ce(new Set),we([]),ke.current=[]},[pn,ot]),Gt=null!==cn.sectionIdx&&Be.has(cn.sectionIdx),qt=m.useDeviationNavigation({proposedSections:Dn,existingSections:On,parentDeviationRecord:Nn,expandedSections:lt,maintainRelativeOrder:!!ee,scrollContainerRef:Ke,leftContainerRef:en,lhsBadgeRefs:Gn,rhsBadgeRefs:qn}),zt=qt.showDeviationNavigation,Wt=qt.showOpenNodeRef,Yt=t.useMemo(function(){if(!Q)return null;for(var e in Nn){if((Nn[e]||[]).some(function(e){return e.id===Q}))return e}return null},[Q,Nn]),Kt=t.useRef(null),Ut=t.useRef(null);t.useEffect(function(){if(Q&&Kt.current!==Q){Ut.current!==Q&&(pn(),mn(),ot(),Ce(new Set),we([]),ke.current=[],Ut.current=Q);var n=!1,t=0,i=null,o=150,r=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},l=function(){var c,a,s,d;if(!n){var v=null,g=null;for(var f in Nn){var p=Nn[f].find(function(e){return e.id===Q});if(p){v=f,g=p;break}}if(g&&v){var h=Dn.findIndex(function(e){return e.id===v}),x=On.findIndex(function(e){return e.id===v}),m=-1===h&&-1!==x,_=r(Dn,g.id),R=r(On,g.id);if(_&&!R&&!m){var y=_.split("-"),S=Number(y[0]);if(ee){var A=null===(a=null===(c=Dn[S])||void 0===c?void 0:c.refIndexes)||void 0===a?void 0:a[0],b=On.findIndex(function(e){return e.selfIndex===A});-1!==b&&(S=b)}R=e.__spreadArray([S],y.slice(1),!0).join("-")}if(_||R){var E=m||!_&&!!R,I=_?Number(_.split("-")[0]):h,T=R?Number(R.split("-")[0]):x;if(E){if(!(ee?!!lt["right-".concat(T)]:!!lt[String(T)])&&T>=0)return st(T,"right"),t+=1,void(i=setTimeout(l,450))}else if(!(ee?!!lt["left-".concat(I)]:!!lt[String(I)])&&I>=0)return st(I,"left"),t+=1,void(i=setTimeout(l,450));var B,C=_||"",D=R||"",O="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0").concat(u.DEVIATION_BADGE_SEPARATOR).concat(C).concat(u.DEVIATION_BADGE_SEPARATOR).concat(D),w="".concat(g.id).concat(u.DEVIATION_BADGE_SEPARATOR,"0"),N=null===(s=Gn.current[w])||void 0===s?void 0:s.current,j=null===(d=qn.current[w])||void 0===d?void 0:d.current,P=E||!N&&!!j,F=P?j:N;if(B=ee?P?Xe.current:en.current:Ke.current,F&&B){var k=F.getBoundingClientRect();if(0===k.height)return void((t+=1)<20&&(i=setTimeout(l,o)));var M=B.getBoundingClientRect(),L=k.top-M.top+B.scrollTop-M.height/2+k.height/2,V=function(){var e,t,i,o,r;if(!n){Kt.current=Q;var l=window.getComputedStyle(F).color;N&&(N.style.transition="box-shadow 300ms ease-in-out",N.style.boxShadow="0 0 10px ".concat(l)),j&&(j.style.transition="box-shadow 300ms ease-in-out",j.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){N&&(N.style.boxShadow=""),j&&(j.style.boxShadow="")},2e3);var u=(null===(t=null===(e=g.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[0])||g,c=(null===(i=g.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||g.evaluation_outputs;if(!(!!N&&!!j)){var a=P?(null===(o=qn.current[w])||void 0===o?void 0:o.current)||j:(null===(r=Gn.current[w])||void 0===r?void 0:r.current)||N;return fn({open:!0,anchorEl:a,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}}),void(null==Z||Z())}Mt(O,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,n=(null===(e=Gn.current[w])||void 0===e?void 0:e.current)||N;fn({open:!0,anchorEl:n,summary:{deviation_summary:u.deviation_summary||u,evaluation_outputs:c}})}})}};Math.abs(B.scrollTop-L)<=2?V():(tn.current=L,on.current=V,B.scrollTo({top:L,behavior:"smooth"}),i&&clearTimeout(i),i=setTimeout(function(){if(on.current){tn.current=null;var e=on.current;on.current=null,e()}},800))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}else(t+=1)<20&&(i=setTimeout(l,o))}};return i=setTimeout(l,o),function(){n=!0,i&&clearTimeout(i)}}},[Q,Nn,Dn,On,ee,lt,st,Mt,fn]);var Xt=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:at,maintainRelativeOrder:ee||!1,proposedSections:Dn,existingSections:On,treeData:H,deviationNumberRegistry:jn,connectedSections:Be,activeSideBySideSection:be,resolvedMarkdownStyles:Ye,getSubSectionRef:Xn,getSubSectionCompareStyle:Dt,getBadgeRef:Jn,openMoreFunctionsPopup:gt,openSummaryPopup:Lt,showDeviationBadges:te,resetSideBySide:ot,setConnectedSections:Ce,setConnectedLines:we,cachedConnectedPositions:ke})};return n.jsxs(i.Box,e.__assign({ref:Ue,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},ee?{}:{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,{})})),gn.open&&n.jsx(S.default,{open:gn.open,anchorEl:gn.anchorEl,containerEl:xt.current,clipTopEl:Rt.current,scrollContainerEl:Ke.current,onClose:Ht,summary:gn.summary}),n.jsx(d.default,{open:cn.open,anchorEl:cn.anchorEl,sectionTitle:cn.sectionTitle,referenceSectionTitle:cn.refSectionTitle,onClose:_n,onOpenCognitiveCompare:ft,onOpenSideBySide:Vt,onConnect:pt,isConnected:Gt,isOrphan:cn.isOrphan}),ln.open&&n.jsx(s.default,{open:ln.open,popupRef:xn,position:sn,popupConfig:U,onClose:function(){dn(null),un(function(n){return e.__assign(e.__assign({},n),{open:!1})}),hn(null)},markdownStyles:W,sectionTitle:ln.sectionTitle,referenceSectionTitle:ln.refSectionTitle,cognitiveData:ln.cognitiveData,anchorEl:ln.anchorEl,sectionAnchorEl:ln.sectionAnchorEl,scrollContainerEl:Ke.current,badgeStyle:ln.badgeStyle,docData:ln.docData,deviationData:ln.deviationData,isLoading:ln.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!de,autoHideDuration:8e3,onClose:function(){return ve(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return ve(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:de}))})),n.jsx(_.default,{componentHeaderText:V,displayConfig:K,maintainRelativeOrder:ee,onToggleView:function(e){le(!0),setTimeout(function(){ne(!e),ot(),pn(),Ce(new Set),we([]),ke.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){le(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:Ke,onScroll:kt,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:ee?"hidden":"auto",borderTop:Zn&&$n?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},ee?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:ht,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},ee?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Ne,style:{position:"absolute",top:0,left:0,width:ze.width||"100%",height:ze.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Re?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[It&&n.jsx("g",{children:n.jsx("line",{x1:It.x1,y1:It.y,x2:It.x2,y2:It.y,stroke:it.badgeBorder,strokeWidth:"1.5"})}),At.map(function(t){var l,c,s,d,v,f,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?fe&&be===t.subSectionKeyPath&&xe:fe&&be===t.sectionIdx&&xe)return null;if(!ee){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=Dn[t.sectionIdx]||{title:"",content:""},_=On[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,S=R[3]||y,A=y.split("-").map(Number),b=S.split("-").map(Number),E=null,I=null;A.length>0&&(E=Dn[A[0]]),b.length>0&&(I=On[b[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<A.length;C++)(null==E?void 0:E.subsections)&&(E=E.subsections[A[C]]);for(C=1;C<b.length;C++)(null==I?void 0:I.subsections)&&(I=I.subsections[b[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===(f=null===(v=null===(d=m.evaluationResult)||void 0===d?void 0:d.cognitive_decisioning)||void 0===v?void 0:v.decisioning_factors)||void 0===f?void 0:f.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&&(ln.open&&vn===t.id?mn():(hn(t.id),vt(dt(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(g.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:ln.open&&vn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),Oe.map(function(t){var i,o=t.pathD,r=(null===(i=t.style)||void 0===i?void 0:i.badgeBorder)||"#6366F1",l="conn-marker-".concat(t.id),u="".concat(t.id,"-bg"),c="".concat(t.id,"-stroke");return n.jsxs("g",{children:[n.jsx("defs",{children:n.jsx("clipPath",e.__assign({id:"connections-clip"},{children:n.jsx("marker",e.__assign({id:l,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:n.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:r})}))}))}),n.jsx("path",{ref:function(e){Fe.current[u]=e},d:o,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),n.jsx("path",{ref:function(e){Fe.current[c]=e},d:o,fill:"none",stroke:r,strokeWidth:"1.75",markerEnd:"url(#".concat(l,")")})]},t.id)})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},ee?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Rt,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:En,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:En}))}))})),n.jsxs(i.Box,e.__assign({ref:en,onScroll:kt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ee?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:Ze,style:{width:"100%",height:"0px",flexShrink:0}}),Fn&&Dn.map(function(t,r){var l,c,a=!t.title&&!t.content;if(ee&&a)return null;var s=t,d=Ct(r,"left"),v=ee?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!On[r],f=ee?"number"==typeof s.selfIndex&&s.selfIndex>=0?s.selfIndex+1:null:r+1,p=Be.has(r),h=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel);return n.jsx(i.Box,e.__assign({ref:Un(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:Vn.current[r],sx:e.__assign({width:"100%",display:"flex"},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:Un("left-accordion-".concat(r)),mb:0,treeData:H,proposedSections:Dn,existingSections:On,deviationNumberRegistry:jn,getSectionCompareStyle:Ct,getBadgeRef:Jn,connectedSections:Be,openMoreFunctionsPopup:gt,openSummaryPopup:Lt,deviationNodeIdToView:Q,deviationTargetParentId:Yt,parentNodeId:(null===(c=null==H?void 0:H.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:ee?!!lt["left-".concat(r)]:!!lt[String(r)],onToggle:function(){Ht(),st(r,"left")},navigation:t.id?zt[t.id]:null,showOpenNodeRef:Wt,resolvedMarkdownStyles:Ye,maintainRelativeOrder:ee,showDeviationBadges:te,renderSubSections:Xt})})),ee&&d&&n.jsxs(i.Box,e.__assign({ref:Gn.current[r],onClick:function(e){var n=ee?On.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:On[r]||{title:"",content:""};gt(e,t,v,n,r,d)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[null!==f&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:f})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!K.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?v?"No Deviation Found":"N/A"===h||"NA"===h?"N/A":0==h||null==h?"Same":"".concat(h):n.jsx(g.default,{color:d.badgeText})})),n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:$e,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:xt,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(),ln.open&&vn===et?mn():(hn(et),vt(dt(n.currentTarget,{title:"",content:"",evaluationResult:nt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,et,!0,e.__assign(e.__assign({},it),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-5px",borderRadius:"20px",bgcolor:it.badgeBg,color:it.badgeText,border:"1px solid ".concat(it.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=tt?tt:n.jsx(g.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:ln.open&&vn===et?"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},ee?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[ce&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:yt,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:In,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:In}))}))})),n.jsxs(i.Box,e.__assign({ref:Xe,onScroll:kt,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},ee?{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:Je,style:{width:"100%",height:"0px",flexShrink:0}}),Fn&&On.map(function(t,o){var r,l=t,u=[],c=!1,a=null,s=-1;if(ee){u=Dn.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=Dn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(l.selfIndex))&&e.selfIndex>=0});var d=Dn.findIndex(function(e,n){var t;return Be.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==d)&&(a=Ct(d))}else u=[o+1],(c=Be.has(o))&&(a=Ct(o));var v=Ct(ee&&-1!==s?s:o);return n.jsx(i.Box,e.__assign({ref:zn.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:Hn.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:Un("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==H?void 0:H.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:ee?!!lt["right-".concat(o)]:!!lt[String(o)],treeData:H,proposedSections:Dn,existingSections:On,deviationNumberRegistry:jn,getBadgeRef:Jn,getSectionCompareStyle:Ct,connectedSections:Be,openMoreFunctionsPopup:gt,openSummaryPopup:Lt,deviationNodeIdToView:Q,deviationTargetParentId:Yt,onToggle:function(){Ht(),st(o,"right")},navigation:t.id?zt[t.id]:null,showOpenNodeRef:Wt,resolvedMarkdownStyles:Ye,maintainRelativeOrder:ee,showDeviationBadges:te,renderSubSections:Xt})})),ee&&v&&n.jsx(i.Box,e.__assign({ref:qn.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:Qe,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./CognitiveCompareConstants.js"),n=function(t){return null==t?"":"string"==typeof t?t:Array.isArray(t)?t.map(n).join("\n\n"):"object"==typeof t?JSON.stringify(t):String(t)},e=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return e(t)}))};var o=["#B91C1C","#A16207","#1D4ED8","#000000"],r=function(t){var n=o.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?o.length:n},i=function(t,n,e){if(!t)return null;if(t.id===e)return n;if(!Array.isArray(t.subsections))return null;for(var o=0;o<t.subsections.length;o++){var r=i(t.subsections[o],"".concat(n,"-").concat(o),e);if(r)return r}return null},u=new WeakMap,l=function(t){if(t){var n=u.get(t);null!=n&&(clearTimeout(n),u.delete(t)),t.style.transition="box-shadow 300ms ease-out, outline 300ms ease-out",requestAnimationFrame(function(){t.style.outline="",t.style.boxShadow=""}),window.setTimeout(function(){t.style.transition="",t.style.borderRadius=""},300)}},a=function(t){if(t){var n=u.get(t);null!=n&&clearTimeout(n),t.style.transition="box-shadow 300ms ease-in-out, outline 300ms ease-in-out",t.style.outline="2px solid #ff9494",t.style.borderRadius="6px",t.style.boxShadow="0 0 12px 2px rgba(244, 113, 113, 0.33)";var e=window.setTimeout(function(){l(t)},3e3);u.set(t,e)}};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var e,o,r,i,u,l;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var v=0;v<a.length;v++)if(a[v]!==s[v])return!1;var c=t.deviationBadges||[],d=n.deviationBadges||[];if(c.length!==d.length)return!1;for(v=0;v<c.length;v++){if(c[v].id!==d[v].id)return!1;if(c[v].actionId!==d[v].actionId)return!1;if(c[v].label!==d[v].label)return!1;if(c[v].score!==d[v].score)return!1;if(c[v].isOrphan!==d[v].isOrphan)return!1;if(c[v].isConnected!==d[v].isConnected)return!1;if((null===(e=c[v].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=d[v].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=c[v].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=d[v].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(u=c[v].style)||void 0===u?void 0:u.badgeText)!==(null===(l=d[v].style)||void 0===l?void 0:l.badgeText))return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,o)},n)}},exports.escapeRegExp=function(t){var n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n=(n=(n=(n=n.replace(/['’‘`]/g,"['’‘`]")).replace(/["”“]/g,'["”“]')).replace(/[-—–]/g,"[-—–]")).replace(/\s+/g,"\\s+")},exports.extractDeviationScore=function(t,n){var e,o,r,i,u,l,a;if(!t)return n;var s=null!==(l=null!==(i=null!==(o=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==o?o:null===(r=t.evaluation_outputs)||void 0===r?void 0:r.output_score)&&void 0!==i?i:null===(u=t.evaluation_outputs)||void 0===u?void 0:u.output_value)&&void 0!==l?l:t.output_score;return null!==(a=null!=s?s:n)&&void 0!==a?a:""},exports.findKeyPathByNodeId=function(t,n){for(var e=0;e<t.length;e++){var o=i(t[e],String(e),n);if(o)return o}return null},exports.generateColorPalette=function(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),o=e.r,r=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(o+(255-o)*n),Math.round(r+(255-r)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}},exports.getBentArrowPath=function(t,n,e,o,r){void 0===r&&(r=14);var i=t+.5*(e-t),u=o-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var l=u>0?1:-1,a=Math.min(r,Math.abs(u)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-a),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+l*a),"V ".concat(o-l*a),"Q ".concat(i," ").concat(o," ").concat(i+a," ").concat(o),"H ".concat(e)].join(" ")},exports.getFirstDeviationColor=function(n){for(var e,o,i,u,l,a,s,v,c,d,f,g,p,h=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var y=m[b];(B=null===(u=null===(i=null===(o=null===(e=null==n?void 0:n.deviations)||void 0===e?void 0:e[y])||void 0===o?void 0:o.evaluation_outputs)||void 0===i?void 0:i.metadata)||void 0===u?void 0:u.label_color)&&h.push(B)}for(var _=0,x=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});_<x.length;_++){y=x[_];(B=null===(v=null===(s=null===(a=null===(l=null==n?void 0:n.deviation_entries)||void 0===l?void 0:l[y])||void 0===a?void 0:a.evaluation_outputs)||void 0===s?void 0:s.metadata)||void 0===v?void 0:v.label_color)&&h.push(B)}for(var A=0,C=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});A<C.length;A++){var B;y=C[A];(B=null===(f=null===(d=null===(c=null==n?void 0:n[y])||void 0===c?void 0:c.evaluation_outputs)||void 0===d?void 0:d.metadata)||void 0===f?void 0:f.label_color)&&h.push(B)}return 0===h.length?(null===(p=null===(g=null==n?void 0:n.evaluation_outputs)||void 0===g?void 0:g.metadata)||void 0===p?void 0:p.label_color)?n.evaluation_outputs.metadata.label_color:t.DEFAULT_DEVIAION_COLOR:h.sort(function(t,n){return r(t)-r(n)})[0]},exports.getFirstDeviationOutputValue=function(t){for(var n,e,o,r,i,u,l,a,s,v=0,c=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});v<c.length;v++){var d=c[v];if(b=null===(o=null===(e=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[d])||void 0===e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var f=0,g=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});f<g.length;f++){d=g[f];if(b=null===(u=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[d])||void 0===i?void 0:i.evaluation_outputs)||void 0===u?void 0:u.output_value)return b}for(var p=0,h=Object.keys(t||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});p<h.length;p++){var b;d=h[p];if(b=null===(a=null===(l=null==t?void 0:t[d])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.output_value)return b}return(null===(s=null==t?void 0:t.evaluation_outputs)||void 0===s?void 0:s.output_value)?t.evaluation_outputs.output_value:null},exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}},exports.getSideData=function(t,e,o){var r,i=o[e],u=null===(r=null==t?void 0:t.comparison_inputs)||void 0===r?void 0:r[i];return{title:n((null==u?void 0:u.title)||""),content:n((null==u?void 0:u.content)||""),change_history:n((null==u?void 0:u.change_history)||""),attributes:(null==u?void 0:u.additional_attributes)||null,subsections:(null==u?void 0:u.subsections)||[]}},exports.hasValue=e,exports.highlightClause=a,exports.isMissingStr=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},exports.mixHexColors=function(t,n){var e=function(t){var n=t.replace("#","");return[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]},o=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var r=e(t),i=e(n),u=(r[0]+i[0])/2*.95,l=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(o(u)).concat(o(l)).concat(o(a))}catch(t){return"#FDE68A"}},exports.recursivelyFindSubSectionIdxById=i,exports.resetClauseHighlight=l,exports.safeStringify=n,exports.scrollAndHighlightClause=function(t,n){var e=n.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.scrollTop+o.top-e.top-e.height/2+o.height/2;n.scrollTo({top:r,behavior:"smooth"});var i=function(){return a(t)};if("onscrollend"in n)n.addEventListener("scrollend",i,{once:!0});else{var u=n.scrollTop,l=function(){n.scrollTop===u?i():(u=n.scrollTop,requestAnimationFrame(l))};requestAnimationFrame(l)}},exports.smoothScrollTo=function(t,n,e,o,r){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var u=t.scrollTop,l=n-u,a=null,s=function(v){null===a&&(a=v);var c,d=v-a;d<e?(t.scrollTop=(c=d,c/=e,l*(--c*c*c+1)+u),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(n){return null==n?"":"string"==typeof n?n:Array.isArray(n)?n.map(t).join("\n\n"):"object"==typeof n?JSON.stringify(n):String(n)},n=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return n(t)}))};exports.DEVIATION_BADGE_SEPARATOR="::",exports.areMarkdownPropsEqual=function(t,n){var e,r,o,i,a,l;if(t.content!==n.content)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;var u=t.highlights||[],s=n.highlights||[];if(u.length!==s.length)return!1;for(var c=0;c<u.length;c++)if(u[c]!==s[c])return!1;var d=t.deviationBadges||[],v=n.deviationBadges||[];if(d.length!==v.length)return!1;for(c=0;c<d.length;c++){if(d[c].id!==v[c].id)return!1;if(d[c].actionId!==v[c].actionId)return!1;if(d[c].label!==v[c].label)return!1;if(d[c].score!==v[c].score)return!1;if(d[c].isOrphan!==v[c].isOrphan)return!1;if(d[c].isConnected!==v[c].isConnected)return!1;if((null===(e=d[c].style)||void 0===e?void 0:e.badgeBg)!==(null===(r=v[c].style)||void 0===r?void 0:r.badgeBg))return!1;if((null===(o=d[c].style)||void 0===o?void 0:o.badgeBorder)!==(null===(i=v[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(a=d[c].style)||void 0===a?void 0:a.badgeText)!==(null===(l=v[c].style)||void 0===l?void 0:l.badgeText))return!1}return!0},exports.debounce=function(t,n){var e;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=this;clearTimeout(e),e=setTimeout(function(){return t.apply(i,r)},n)}},exports.escapeRegExp=function(t){var n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n=(n=(n=(n=n.replace(/['’‘`]/g,"['’‘`]")).replace(/["”“]/g,'["”“]')).replace(/[-—–]/g,"[-—–]")).replace(/\s+/g,"\\s+")},exports.extractDeviationScore=function(t,n){var e,r,o,i,a,l,u;if(!t)return n;var s=null!==(l=null!==(i=null!==(r=null===(e=t.evaluation_output)||void 0===e?void 0:e.output_score)&&void 0!==r?r:null===(o=t.evaluation_outputs)||void 0===o?void 0:o.output_score)&&void 0!==i?i:null===(a=t.evaluation_outputs)||void 0===a?void 0:a.output_value)&&void 0!==l?l:t.output_score;return null!==(u=null!=s?s:n)&&void 0!==u?u:""},exports.generateColorPalette=function(t){var n=function(t,n){var e=function(t){var n=function(t){return 4===t.length?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}(t).replace("#",""),e=parseInt(n,16);return{r:e>>16&255,g:e>>8&255,b:255&e}}(t),r=e.r,o=e.g,i=e.b;return function(t,n,e){return"#"+[t,n,e].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(r+(255-r)*n),Math.round(o+(255-o)*n),Math.round(i+(255-i)*n))};return{bg:n(t,.8),border:n(t,.5),badgeBg:n(t,.8),badgeBorder:n(t,.5),badgeText:t.toUpperCase(),highlightBg:n(t,.8)}},exports.getBentArrowPath=function(t,n,e,r,o){void 0===o&&(o=14);var i=t+.5*(e-t),a=r-n;if(Math.abs(a)<3)return"M ".concat(t," ").concat(n," H ").concat(e);var l=a>0?1:-1,u=Math.min(o,Math.abs(a)/2,Math.abs(i-t)/2,Math.abs(e-i)/2);return["M ".concat(t," ").concat(n),"H ".concat(i-u),"Q ".concat(i," ").concat(n," ").concat(i," ").concat(n+l*u),"V ".concat(r-l*u),"Q ".concat(i," ").concat(r," ").concat(i+u," ").concat(r),"H ".concat(e)].join(" ")},exports.getRationale=function(t){if(!t.mapping_rationale)return{cognitiveData:{decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0,citations:[]},score:0,relation:"N/A"};var n=t.mapping_rationale,e=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:e,citations:n.citations},score:0,relation:"N/A"}},exports.getSideData=function(n,e,r){var o,i=r[e],a=null===(o=null==n?void 0:n.comparison_inputs)||void 0===o?void 0:o[i];return{title:t((null==a?void 0:a.title)||""),content:t((null==a?void 0:a.content)||""),attributes:(null==a?void 0:a.additional_attributes)||null,subsections:(null==a?void 0:a.subsections)||[]}},exports.hasValue=n,exports.isMissingStr=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},exports.safeStringify=t,exports.smoothScrollTo=function(t,n,e,r,o){void 0===e&&(e=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var a=t.scrollTop,l=n-a,u=null,s=function(c){null===u&&(u=c);var d,v=c-u;v<e?(t.scrollTop=(d=v,d/=e,l*(--d*d*d+1)+a),o&&o(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,o&&o(),r&&r())};requestAnimationFrame(s)};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.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,c=r.open,d=r.anchorEl,u=r.containerEl,p=r.clipTopEl,x=r.scrollContainerEl,f=r.onClose,m=r.summary;r.markdownStyles,r.isLoading;var g=o.useRef(null),h=o.useRef(null),v=o.useState(null),_=v[0],y=v[1],b=o.useState(null),w=b[0],S=b[1],j=o.useState(null),C=j[0],B=j[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",k=null!==(a=null==u?void 0:u.getBoundingClientRect().width)&&void 0!==a?a:180,q=Math.max(148,k+120),L=d&&u?{top:d.getBoundingClientRect().top,bottom:d.getBoundingClientRect().bottom,left:u.getBoundingClientRect().left+u.getBoundingClientRect().width/2}:null;o.useEffect(function(){if(!c||!d||!u)return y(null),S(null),void B(null);var e=function(){null!==g.current&&cancelAnimationFrame(g.current),g.current=requestAnimationFrame(function(){var e,n,t=d.getBoundingClientRect(),i=u.getBoundingClientRect(),o=null==p?void 0:p.getBoundingClientRect(),r=null==x?void 0:x.getBoundingClientRect();y({top:t.top,bottom:t.bottom,left:i.left+i.width/2}),S(null!==(e=null==o?void 0:o.bottom)&&void 0!==e?e:null),B(null!==(n=null==r?void 0:r.bottom)&&void 0!==n?n:null),h.current&&z(h.current.offsetHeight)})};e();var n=!0;return window.addEventListener("scroll",e,{passive:!0,capture:n}),window.addEventListener("resize",e),function(){null!==g.current&&cancelAnimationFrame(g.current),window.removeEventListener("scroll",e,n),window.removeEventListener("resize",e)}},[c,d,u,p,x]);var P=null!==(s=null!=_?_:L)&&void 0!==s?s:{top:0,bottom:0,left:0},D=P.bottom+20,O=D+R,N=null!=w?Math.max(0,w-D):0,G=null!=C?Math.max(0,O-C):0,J=N>0||G>0;return m?n.jsx(t.Popper,e.__assign({open:c,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:P.bottom-P.top,top:P.top,bottom:P.bottom,left:P.left,right:P.left,x:P.left,y:P.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:21}},{children:n.jsxs(t.Paper,e.__assign({ref:h,sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:q,maxWidth:q},J&&{clipPath:"inset(".concat(N,"px 0 ").concat(G-150,"px 0 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:f,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({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};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("@mui/material"),o=require("lucide-react"),i=require("react");exports.default=function(l){var r,a,s,u=l.open,c=l.anchorEl,d=l.containerEl,p=l.clipTopEl,m=l.scrollContainerEl,f=l.onClose,g=l.summary;l.markdownStyles,l.isLoading;var x=i.useRef(null),v=i.useRef(null),h=i.useState(null),b=h[0],_=h[1],w=i.useState(null),y=w[0],C=w[1],B=i.useState(null),R=B[0],j=B[1],S=i.useState(0),E=S[0],z=S[1],q="string"==typeof g?{deviation_summary:g}:null!=g?g:{};q.deviation_title;var I=q.deviation_summary,L=q.evaluation_outputs,P=(null===(r=null==L?void 0:L.metadata)||void 0===r?void 0:r.label_color)||"#6366F1",T=null!==(a=null==d?void 0:d.getBoundingClientRect().width)&&void 0!==a?a:180,W=Math.max(148,T+70),F=c&&d?{top:c.getBoundingClientRect().top,bottom:c.getBoundingClientRect().bottom,left:d.getBoundingClientRect().left+d.getBoundingClientRect().width/2}:null;i.useEffect(function(){if(!u||!c||!d)return _(null),C(null),void j(null);var e=function(){null!==x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(function(){var e,t,n=c.getBoundingClientRect(),o=d.getBoundingClientRect(),i=null==p?void 0:p.getBoundingClientRect(),l=null==m?void 0:m.getBoundingClientRect();_({top:n.top,bottom:n.bottom,left:o.left+o.width/2}),C(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),j(null!==(t=null==l?void 0:l.bottom)&&void 0!==t?t:null),v.current&&z(v.current.offsetHeight)})};e();var t=!0;return window.addEventListener("scroll",e,{passive:!0,capture:t}),window.addEventListener("resize",e),function(){null!==x.current&&cancelAnimationFrame(x.current),window.removeEventListener("scroll",e,t),window.removeEventListener("resize",e)}},[u,c,d,p,m]);var M=null!==(s=null!=b?b:F)&&void 0!==s?s:{top:0,bottom:0,left:0},k=M.bottom+20,A=k+E,H=null!=y?Math.max(0,y-k):0,O=null!=R?Math.max(0,A-R):0,N=H>0||O>0;return g?t.jsx(n.Popper,e.__assign({open:u,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:{getBoundingClientRect:function(){return{width:0,height:M.bottom-M.top,top:M.top,bottom:M.bottom,left:M.left,right:M.left,x:M.left,y:M.top,toJSON:function(){}}}},placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}}],sx:{zIndex:20}},{children:t.jsxs(n.Paper,e.__assign({ref:v,sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:W,maxWidth:W},N&&{clipPath:"inset(".concat(H,"px 0 ").concat(O-150,"px 0 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(P,"26"),borderTop:"3px solid ".concat(P),overflow:"hidden",bgcolor:"#fff"})},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[t.jsxs(n.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[t.jsx(o.Info,{size:14,color:P}),t.jsx(n.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:P,textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),t.jsx(n.IconButton,e.__assign({size:"small",onClick:f,sx:{p:.25,ml:.5,color:"#64748B"}},{children:t.jsx(o.X,{size:14})}))]})),t.jsx(n.Typography,e.__assign({sx:{fontSize:"12px",color:"#475569",lineHeight:1.5,fontWeight:400,overflowWrap:"anywhere"}},{children:I||"No summary available."}))]}))})):null};
2
2
  //# sourceMappingURL=CognitiveSummaryPopup.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),o=require("@mui/material");exports.default=function(t){var r=t.componentHeaderText,n=t.displayConfig,s=t.maintainRelativeOrder,l=t.onToggleView,a=t.onCollapseAll,c=t.showCollapseAll;return n.isHeaderVisible||n.isToggleVisible?i.jsxs(o.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[i.jsx(o.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:n.isHeaderVisible&&i.jsx(o.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:r}))})),n.isToggleVisible&&i.jsxs(o.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:2}},{children:[c&&i.jsx(o.Button,e.__assign({variant:"outlined",size:"small",onClick:a,sx:{textTransform:"none",fontWeight:600,fontSize:"12px",color:"#5928ED",borderColor:"#5928ED",height:26,"&:hover":{borderColor:"#3E1BB3",backgroundColor:"rgba(89, 40, 237, 0.04)"}}},{children:"Collapse All"})),i.jsx(o.FormControlLabel,{control:i.jsx(o.Switch,{checked:!s,onChange:function(e){return l(e.target.checked)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:8,top:5,fontSize:10,color:"#fff",fontWeight:600}}},"& .MuiSwitch-thumb:before":{position:"absolute",width:"100%",height:"100%",left:0,top:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,color:"#5928ED"}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20,boxShadow:"0px 1px 3px rgba(0,0,0,0.2)"},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#CBD5E1",opacity:1,position:"relative","&::before":{content:'"Side By Side"',position:"absolute",right:8,top:5,left:30,fontSize:10,color:"#1E293B",fontWeight:600}}}}),label:"",sx:{m:0}})]}))]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),t=require("@mui/material");exports.default=function(o){var r=o.componentHeaderText,n=o.displayConfig,s=o.maintainRelativeOrder,a=o.onToggleView;return n.isHeaderVisible||n.isToggleVisible?i.jsxs(t.Box,e.__assign({sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#FFFFFF",border:"1.5px solid #EEF0F4",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}},{children:[i.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:n.isHeaderVisible&&i.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:600,color:"#0F172A"}},{children:r}))})),n.isToggleVisible&&i.jsx(t.Box,e.__assign({sx:{display:"flex",alignItems:"center"}},{children:i.jsx(t.FormControlLabel,{control:i.jsx(t.Switch,{checked:!s,onChange:function(e){return a(e.target.checked)},color:"primary",size:"small",sx:{width:100,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(75px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:"#5928ED",opacity:1,border:0,"&::before":{content:'"Side by Side"',position:"absolute",left:8,top:5,fontSize:10,color:"#fff",fontWeight:600}}},"& .MuiSwitch-thumb:before":{position:"absolute",width:"100%",height:"100%",left:0,top:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,color:"#5928ED"}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:20,height:20,boxShadow:"0px 1px 3px rgba(0,0,0,0.2)"},"& .MuiSwitch-track":{borderRadius:13,backgroundColor:"#CBD5E1",opacity:1,position:"relative","&::before":{content:'"Side By Side"',position:"absolute",right:8,top:5,left:30,fontSize:10,color:"#1E293B",fontWeight:600}}}}),label:"",sx:{m:0}})}))]})):null};
2
2
  //# sourceMappingURL=CompareHeader.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 e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),r=require("../CognitiveComparehelpers.js"),d=require("../CognitiveCompareConstants.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=a(i);exports.default=function(a){var u,c,v,f,p,x,g,h,m,_,I,y,b,w,S,A,R=a.section,j=a.idx,E=a.columnKey,C=a.colRef,F=a.mb,k=void 0===F?1:F,B=a.parentNodeId,O=void 0===B?"":B,T=a.isExpanded,D=a.onToggle,M=a.navigation,N=a.showOpenNodeRef,P=a.resolvedMarkdownStyles,V=a.maintainRelativeOrder,W=a.showDeviationBadges,q=void 0!==W&&W,G=a.renderSubSections,z=a.treeData,K=a.proposedSections,L=void 0===K?[]:K,U=a.existingSections,X=void 0===U?[]:U,Y=a.deviationNumberRegistry,H=void 0===Y?{}:Y,$=a.getBadgeRef,J=a.openSummaryPopup,Q=a.getSectionCompareStyle,Z=a.connectedSections,ee=a.openMoreFunctionsPopup;a.deviationNodeIdToView,a.deviationTargetParentId;var ne=(null===(u=R.displayTitle)||void 0===u||u)&&r.hasValue(R.title),ie=(null===(c=R.displayContent)||void 0===c||c)&&r.hasValue(R.content),te=!ne&&!ie,oe={current:1},le=R.title;ne||(le=ie?"No Title Found":"No Matching Section Found");var re=R.evaluationResult;if(!re&&"right"===E)if(V){var de=null===(v=R.refIndexes)||void 0===v?void 0:v[0],ae=L.find(function(e){return e.selfIndex===de});re=null==ae?void 0:ae.evaluationResult}else re=null===(f=L[j])||void 0===f?void 0:f.evaluationResult;var se=null===(p=null==z?void 0:z.input_index_map)||void 0===p?void 0:p[0],ue=null===(x=null==z?void 0:z.input_index_map)||void 0===x?void 0:x[1],ce="left"===E?ue:se,ve=function(e,n){return e.find(function(e){return(null==e?void 0:e.id)&&n&&e.id===n})},fe="left"===E?R:L[j],pe="right"===E?R:X[j];if(V)if("left"===E){var xe=null===(g=R.refIndexes)||void 0===g?void 0:g[0],ge=X.findIndex(function(e){return e.selfIndex===xe});pe=-1!==ge?X[ge]:ve(X,R.id)}else{var he=null===(h=R.refIndexes)||void 0===h?void 0:h[0],me=L.findIndex(function(e){return e.selfIndex===he});fe=-1!==me?L[me]:ve(L,R.id)}var _e="left"===E?!pe:!fe,Ie=re||(null==fe?void 0:fe.evaluationResult)||(null==pe?void 0:pe.evaluationResult),ye=null!==(I=null===(_=null===(m=null==Ie?void 0:Ie.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==I?I:d.DEFAULT_DEVIAION_COLOR,be=r.generateColorPalette(ye),we=be.highlightBg,Se=null!==(b=null===(y=null==Ie?void 0:Ie.evaluation_outputs)||void 0===y?void 0:y.output_value)&&void 0!==b?b:null,Ae=(null==Ie?void 0:Ie.deviations)||{},Re=j+1,je=R.id;if("right"===E&&V){var Ee=null===(w=R.refIndexes)||void 0===w?void 0:w[0],Ce=-1!==(me=L.findIndex(function(e){return e.selfIndex===Ee}))?L[me]:ve(L,R.id);if(Ce){var Fe=L.findIndex(function(e){return e.id===Ce.id});-1!==Fe&&(Re=Fe+1),je=Ce.id}}var ke,Be=[],Oe=Object.entries(Ae).map(function(n){var i,t,o,l,d,a=n[0],s=n[1],u="".concat(je).concat(r.DEVIATION_BADGE_SEPARATOR).concat(a),c=H[u];if(null==c)return null;var v=s[O],f=r.isMissingStr(v);if(f)v="";else if(!v)return null;Be.push(v);var p=j,x=j;if(V)if("left"===E){var g=null===(i=R.refIndexes)||void 0===i?void 0:i[0],h=X.findIndex(function(e){return e.selfIndex===g});if(-1!==h)x=h;else{var m=X.findIndex(function(e){return e.id===R.id});x=-1!==m?m:j}}else{var _=null===(t=R.refIndexes)||void 0===t?void 0:t[0],I=L.findIndex(function(e){return e.selfIndex===_});if(-1!==I)p=I;else p=-1!==(D=L.findIndex(function(e){return e.id===R.id}))?D:j}var y="".concat(je).concat(r.DEVIATION_BADGE_SEPARATOR).concat(a).concat(r.DEVIATION_BADGE_SEPARATOR).concat(p).concat(r.DEVIATION_BADGE_SEPARATOR).concat(x),b="left"===E?null===(o=X[x])||void 0===o?void 0:o.content:null===(l=L[p])||void 0===l?void 0:l.content,w=s[ce],S=r.safeStringify(b),A=Object.keys(Ae).map(function(e){return{key:e,text:Ae[e][ce]}}).filter(function(e){return!r.isMissingStr(e.text)}).sort(function(e,n){return n.text.length-e.text.length}),C=new Set;A.forEach(function(e){var n=e.text.replace(/\\(['’])/g,"$1").replace(/\\n/g,"\n");if(n){var i=new RegExp(r.escapeRegExp(n));i.test(S)&&(C.add(e.key),S=S.replace(i,"__TOKEN_".concat(e.key,"__")))}});var F=!r.isMissingStr(w)&&!C.has(a),k=_e||r.isMissingStr(w)||F,B="".concat(Re,".").concat(c),T=j;if("right"===E&&V){var D,M=null===(d=R.refIndexes)||void 0===d?void 0:d[0],N=L.findIndex(function(e){return e.selfIndex===M});if(-1!==N)T=N;else-1!==(D=L.findIndex(function(e){return e.id===R.id}))&&(T=D)}var P=Q?Q(T):null,W=P?e.__assign(e.__assign({},P),{badgeBg:be.badgeBg,badgeBorder:be.badgeBorder,badgeText:be.badgeText}):e.__assign({},be),q=(null==s?void 0:s.deviation_summary)?{deviation_summary:s.deviation_summary,deviation_title:null==Ie?void 0:Ie.deviation_title,evaluation_outputs:null==Ie?void 0:Ie.evaluation_outputs}:null;return{id:u,actionId:y,label:B,highlight:v,side:E,style:W,score:Se,isConnected:null==Z?void 0:Z.has(y),isOrphan:k,isMissingClause:f,badgeRef:$(E,u),onClick:function(e){e.stopPropagation(),ee&&ee(e,fe||{id:"orphan-left",title:"",content:""},k,pe||{id:"orphan-right",title:"",content:""},y,W)},onSummaryClick:function(e){e.stopPropagation(),J(e,y,k,q)}}}).filter(Boolean),Te=q?Oe:[],De=R.id&&E===(null==M?void 0:M.columnKey)?M:null,Me=s.default.useRef(!1);return i.useEffect(function(){T||(Me.current=!1)},[T]),n.jsxs(t.Box,e.__assign({ref:C,sx:{mb:k,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[T&&(null==De?void 0:De.showAbove)&&n.jsx("div",e.__assign({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==De?void 0:De.showAboveRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===E?{right:"0px"}:{left:"0px"})},{children:n.jsx(o.ChevronUp,{color:window.getComputedStyle(null===(S=null==De?void 0:De.showAboveRef)||void 0===S?void 0:S.current).color})}))})),n.jsxs(t.Accordion,e.__assign({disableGutters:!0,expanded:!te&&T,onChange:function(){te||(D(),N.current=R.id)},sx:{boxShadow:"none",border:te?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:te?"#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(t.AccordionSummary,e.__assign({expandIcon:te?null:n.jsx(o.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:te?"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:ne&&n.jsx(t.Tooltip,e.__assign({title:le,placement:"top"},{children:n.jsx(t.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:te?"#94A3B8":"#19213D",fontWeight:te?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ke=le,ke?r.safeStringify(ke).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(e,i){return e.startsWith("**")&&e.endsWith("**")?n.jsx("strong",{children:e.slice(2,-2)},i):n.jsx(s.default.Fragment,{children:e},i)}):null)}))}))})),!te&&n.jsxs(t.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[ie&&n.jsx(l.MemoizedMarkdown,{content:R.content,sxStyles:P,highlights:Be,maintainRelativeOrder:V,highlightBg:we,deviationBadges:Te}),(R.subsections||[]).map(function(e,n){return G({section:e,keyPath:"".concat(j,"-").concat(n),depth:0,columnKey:E,parentNodeId:O,devCounter:oe})})]}))]})),T&&(null==De?void 0:De.showBelow)&&n.jsx("div",e.__assign({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var e,n;return null===(n=null===(e=null==De?void 0:De.showBelowRef)||void 0===e?void 0:e.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:n.jsx("div",e.__assign({style:e.__assign({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===E?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===E?{right:"0px"}:{left:"0px"})},{children:n.jsx(o.ChevronDown,{color:window.getComputedStyle(null===(A=null==De?void 0:De.showBelowRef)||void 0===A?void 0:A.current).color})}))}))]}),"".concat(E,"-sec-").concat(j))};
2
2
  //# sourceMappingURL=SectionAccordion.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"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),a=require("../CognitiveComparehelpers.js"),s=require("../CognitiveCompareConstants.js");function d(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var r=d(e).default.memo(function(d){var u,c,v,f,h,p,g,_,x,m,b=d.section,y=d.keyPath,S=d.depth,I=void 0===S?0:S,A=d.columnKey,E=void 0===A?"left":A,R=d.parentNodeId,j=void 0===R?"":R,O=d.expandedSubSections,P=d.setExpandedSubSections,B=d.maintainRelativeOrder,C=d.showDeviationBadges,w=void 0!==C&&C,k=d.proposedSections,F=d.existingSections,D=d.treeData,M=d.deviationNumberRegistry,T=d.connectedSections,N=d.activeSideBySideSection,V=d.resolvedMarkdownStyles,q=d.getSubSectionRef,W=d.getSubSectionCompareStyle,z=d.getBadgeRef,G=d.openMoreFunctionsPopup,K=d.openSummaryPopup,L=d.resetSideBySide,U=d.setConnectedSections,H=d.setConnectedLines,J=d.cachedConnectedPositions,Q=d.isProposingFix,X=d.proposingFixNodeId,Y=null!=N?N:"",Z=(null===(u=b.displayTitle)||void 0===u||u)&&a.hasValue(b.title),$=b.change_history,ii=!!Q&&!!X&&"left"===E&&b.id===X&&a.hasValue($),ni=ii?$||"":b.content,ei=ii?b.content:void 0,ti=(null===(c=b.displayContent)||void 0===c||c)&&a.hasValue(ni),oi=!Z&&!ti,li=Z?b.title:ti?"No Title Found":"No Matching Section Found",ai=!!O[y],si=q(E,y),di=y.split("-").map(Number),ri=di[0],ui=k[ri],ci=F[ri],vi=y,fi=y,hi=ri,pi=ri,gi=function(i,n,e){if(!i||!n)return null;if(i.id===n)return{section:i,keyPath:e};for(var t=(i.subsections||[]).map(function(i,n){return{section:i,keyPath:"".concat(e,"-").concat(n)}}),o=function(){var i=t.shift();return(null==i?void 0:i.section)?i.section.id===n?{value:i}:void(i.section.subsections||[]).forEach(function(n,e){t.push({section:n,keyPath:"".concat(i.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(B)if("left"===E){var _i=null===(v=null==ui?void 0:ui.refIndexes)||void 0===v?void 0:v[0],xi=F.findIndex(function(i){return i.selfIndex===_i});-1!==xi&&(ci=F[xi],pi=xi)}else{var mi=null===(f=null==ci?void 0:ci.refIndexes)||void 0===f?void 0:f[0];-1!==(Ei=k.findIndex(function(i){return i.selfIndex===mi}))&&(ui=k[Ei],hi=Ei)}var bi=ui,yi=ci;if(B)if("left"===E){bi=b,vi=y;var Si=gi(ci,b.id,String(pi));yi=(null==Si?void 0:Si.section)||null,fi=(null==Si?void 0:Si.keyPath)||""}else{yi=b,fi=y;var Ii=gi(ui,b.id,String(hi));bi=(null==Ii?void 0:Ii.section)||null,vi=(null==Ii?void 0:Ii.keyPath)||""}else for(var Ai=1;Ai<di.length;Ai++)(null==bi?void 0:bi.subsections)&&(bi=bi.subsections[di[Ai]]),(null==yi?void 0:yi.subsections)&&(yi=yi.subsections[di[Ai]]);var Ei,Ri=(vi?W(vi):null)||W(y),ji=null===(h=null==D?void 0:D.input_index_map)||void 0===h?void 0:h[0],Oi=null===(p=null==D?void 0:D.input_index_map)||void 0===p?void 0:p[1],Pi="left"===E?Oi:ji,Bi="left"===E?!yi:!bi,Ci=b.evaluationResult||(null==bi?void 0:bi.evaluationResult)||(null==yi?void 0:yi.evaluationResult),wi=ri+1,ki=b.id||(null==bi?void 0:bi.id)||(null==yi?void 0:yi.id);"right"===E&&B&&(ui&&-1!==(Ei=k.findIndex(function(i){return i.id===ui.id}))&&(wi=Ei+1));var Fi=null!==(x=null===(_=null===(g=null==Ci?void 0:Ci.evaluation_outputs)||void 0===g?void 0:g.metadata)||void 0===_?void 0:_.label_color)&&void 0!==x?x:s.DEFAULT_DEVIAION_COLOR,Di=a.generateColorPalette(Fi).highlightBg,Mi=(null==Ci?void 0:Ci.deviations)||{},Ti=[],Ni=Object.entries(Mi).map(function(n){var e,t,o,l=n[0],s=n[1],d="".concat(ki).concat(a.DEVIATION_BADGE_SEPARATOR).concat(l),r=M[d];if(null==r)return null;var u=s[j],c=a.isMissingStr(u);if(c)u="";else if(!u)return null;Ti.push(u);var v=s[Pi],f=Bi||a.isMissingStr(v),h="".concat(wi,".").concat(r),p="".concat(ki).concat(a.DEVIATION_BADGE_SEPARATOR).concat(l).concat(a.DEVIATION_BADGE_SEPARATOR).concat(vi).concat(a.DEVIATION_BADGE_SEPARATOR).concat(fi),g=(null==s?void 0:s.evaluation_outputs)||(null==Ci?void 0:Ci.evaluation_outputs),_=null!==(e=null==g?void 0:g.output_value)&&void 0!==e?e:null,x=null!==(o=null===(t=null==g?void 0:g.metadata)||void 0===t?void 0:t.label_color)&&void 0!==o?o:Fi,m=a.generateColorPalette(x),b=i.__assign({},m),y=(null==s?void 0:s.deviation_summary)?{deviation_summary:s.deviation_summary||(null==Ci?void 0:Ci.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==Ci?void 0:Ci.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==Ci?void 0:Ci.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==Ci?void 0:Ci.deviation_explanation),evaluation_outputs:g,cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==Ci?void 0:Ci.cognitive_decisioning)}:null,S=0,I=ni||"";if(u&&I){var A=I.split(/\n{2,}/),R=A.findIndex(function(i){return i.includes(u)});if(-1!==R){var O=Object.entries(Mi).filter(function(i){i[0];var n=i[1][j];return n&&A[R].includes(n)}).sort(function(i,n){return A[R].indexOf(i[1][j])-A[R].indexOf(n[1][j])});S=Math.max(0,O.findIndex(function(i){return i[0]===l}))}}return{id:d,actionId:p,label:h,highlight:u,side:E,style:b,stackIndex:S,score:_,isConnected:T.has(p),isOrphan:f,isMissingClause:c,badgeRef:z(E,d),onClick:function(n){n.stopPropagation();var e=bi?i.__assign(i.__assign({},bi),{title:(null==ui?void 0:ui.title)||(null==bi?void 0:bi.title)||""}):{id:"orphan-left",title:"",content:""},t=yi?i.__assign(i.__assign({},yi),{title:(null==ci?void 0:ci.title)||(null==yi?void 0:yi.title)||""}):{id:"orphan-right",title:"",content:""};G(n,e,f,t,p,b)},onSummaryClick:function(i){i.stopPropagation(),K(i,p,f,y)}}}).filter(Boolean).sort(function(i,n){return parseFloat(i.label)-parseFloat(n.label)}),Vi=w?Ni:[],qi=e.useRef(!1);e.useEffect(function(){ai||(qi.current=!1)},[ai]),e.useEffect(function(){if(ai&&!qi.current){var i=setTimeout(function(){var i,n;qi.current=!0;var e=null===(n=null===(i=Ni[0])||void 0===i?void 0:i.badgeRef)||void 0===n?void 0:n.current;e&&e.scrollIntoView({behavior:"smooth",block:"center"})},350);return function(){return clearTimeout(i)}}},[ai,Ni]);var Wi=Ni.find(function(i){return T.has(i.actionId)}),zi=!!Wi;if(!(Z||ti||b.subsections&&0!==b.subsections.length))return null;var Gi=(null===(m=null==Wi?void 0:Wi.style)||void 0===m?void 0:m.badgeBorder)||(null==Ri?void 0:Ri.badgeBorder),Ki=zi&&Gi?{borderRadius:"4px",outline:"2px solid ".concat(Gi),outlineOffset:"1px"}:{};return Z?n.jsx(t.Box,i.__assign({ref:si,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:n.jsx(t.Box,i.__assign({sx:i.__assign({width:"100%"},Ki)},{children:n.jsxs(t.Accordion,i.__assign({disableGutters:!0,expanded:!oi&&ai,onChange:function(){if(!oi){if(ai){var n=String(N||""),e=n.includes(vi)||n.includes(fi);e||T.forEach(function(i){(String(i).includes(vi)||String(i).includes(fi))&&(e=!0)}),e&&(L(),U(new Set),H([]),J.current=[])}P(function(n){var e;return i.__assign(i.__assign({},n),((e={})[y]=!n[y],e))})}},sx:{mt:0,boxShadow:"none",border:oi?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[n.jsx(t.AccordionSummary,i.__assign({expandIcon:oi?null:n.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:n.jsx(t.Typography,i.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:oi?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:li||"Untitled Subsection"}))})),!oi&&n.jsxs(t.AccordionDetails,i.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[ti&&n.jsx(l.MemoizedMarkdown,{content:ni,overlayContent:ei,sxStyles:V,deviationBadges:Vi,maintainRelativeOrder:B,highlightBg:Di,highlights:Ti,collisionKey:Y}),(b.subsections||[]).map(function(e,t){return n.jsx(r,i.__assign({},d,{section:e,keyPath:"".concat(y,"-").concat(t),depth:I+1}),"".concat(y,"-").concat(t))})]}))]}))}))})):n.jsx(t.Box,i.__assign({ref:si,sx:{mt:0===I?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!oi&&n.jsxs(t.Box,i.__assign({sx:i.__assign({width:"100%"},Ki)},{children:[ti&&n.jsx(l.MemoizedMarkdown,{content:ni,overlayContent:ei,sxStyles:V,deviationBadges:Vi,maintainRelativeOrder:B,highlightBg:Di,highlights:Ti,collisionKey:Y}),(b.subsections||[]).map(function(e,t){return n.jsx(r,i.__assign({},d,{section:e,keyPath:"".concat(y,"-").concat(t),depth:I+1}),"".concat(y,"-").concat(t))})]}))}))});exports.default=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material"),o=require("lucide-react"),l=require("../hooks/memoizedMarkdown.js"),s=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function r(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=r(i).default.memo(function(r){var d,c,v,h,f,p,g,_,m,x,S,b=r.section,y=r.keyPath,A=r.depth,E=void 0===A?0:A,I=r.columnKey,R=void 0===I?"left":I,j=r.parentNodeId,B=void 0===j?"":j,O=r.expandedSubSections,P=r.setExpandedSubSections,w=r.maintainRelativeOrder,C=r.showDeviationBadges,k=void 0!==C&&C,D=r.proposedSections,F=r.existingSections,T=r.treeData,M=r.deviationNumberRegistry,N=r.connectedSections,q=r.activeSideBySideSection,V=r.resolvedMarkdownStyles,W=r.getSubSectionRef,z=r.getSubSectionCompareStyle,G=r.getBadgeRef,L=r.openMoreFunctionsPopup,U=r.openSummaryPopup,H=r.resetSideBySide,K=r.setConnectedSections,J=r.setConnectedLines,Q=r.cachedConnectedPositions,X=(null===(d=b.displayTitle)||void 0===d||d)&&s.hasValue(b.title),Y=(null===(c=b.displayContent)||void 0===c||c)&&s.hasValue(b.content),Z=!X&&!Y,$=X?b.title:Y?"No Title Found":"No Matching Section Found",nn=!!O[y],en=W(R,y),tn=y.split("-").map(Number),on=tn[0],ln=D[on],sn=F[on],an=y,rn=y,un=on,dn=on,cn=function(n,e,i){if(!n||!e)return null;if(n.id===e)return{section:n,keyPath:i};for(var t=(n.subsections||[]).map(function(n,e){return{section:n,keyPath:"".concat(i,"-").concat(e)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===e?{value:n}:void(n.section.subsections||[]).forEach(function(e,i){t.push({section:e,keyPath:"".concat(n.keyPath,"-").concat(i)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(w)if("left"===R){var vn=null===(v=null==ln?void 0:ln.refIndexes)||void 0===v?void 0:v[0],hn=F.findIndex(function(n){return n.selfIndex===vn});-1!==hn&&(sn=F[hn],dn=hn)}else{var fn=null===(h=null==sn?void 0:sn.refIndexes)||void 0===h?void 0:h[0];-1!==(Sn=D.findIndex(function(n){return n.selfIndex===fn}))&&(ln=D[Sn],un=Sn)}var pn=ln,gn=sn;if(w)if("left"===R){pn=b,an=y;var _n=cn(sn,b.id,String(dn));gn=(null==_n?void 0:_n.section)||null,rn=(null==_n?void 0:_n.keyPath)||""}else{gn=b,rn=y;var mn=cn(ln,b.id,String(un));pn=(null==mn?void 0:mn.section)||null,an=(null==mn?void 0:mn.keyPath)||""}else for(var xn=1;xn<tn.length;xn++)(null==pn?void 0:pn.subsections)&&(pn=pn.subsections[tn[xn]]),(null==gn?void 0:gn.subsections)&&(gn=gn.subsections[tn[xn]]);var Sn,bn=(an?z(an):null)||z(y),yn=null===(f=null==T?void 0:T.input_index_map)||void 0===f?void 0:f[0],An=null===(p=null==T?void 0:T.input_index_map)||void 0===p?void 0:p[1],En="left"===R?An:yn,In="left"===R?!gn:!pn,Rn=b.evaluationResult||(null==pn?void 0:pn.evaluationResult)||(null==gn?void 0:gn.evaluationResult),jn=null!==(_=null===(g=null==Rn?void 0:Rn.evaluation_outputs)||void 0===g?void 0:g.output_value)&&void 0!==_?_:null,Bn=on+1,On=b.id||(null==pn?void 0:pn.id)||(null==gn?void 0:gn.id);"right"===R&&w&&(ln&&-1!==(Sn=D.findIndex(function(n){return n.id===ln.id}))&&(Bn=Sn+1));var Pn=null!==(S=null===(x=null===(m=null==Rn?void 0:Rn.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===x?void 0:x.label_color)&&void 0!==S?S:a.DEFAULT_DEVIAION_COLOR,wn=s.generateColorPalette(Pn),Cn=wn.highlightBg,kn=(null==Rn?void 0:Rn.deviations)||{},Dn=[],Fn=Object.entries(kn).map(function(e){var i=e[0],t=e[1],o="".concat(On).concat(s.DEVIATION_BADGE_SEPARATOR).concat(i),l=M[o];if(null==l)return null;var a=t[B],r=s.isMissingStr(a);if(r)a="";else if(!a)return null;Dn.push(a);var u=t[En],d=!1;u&&(d=Object.values(kn).map(function(n){return n[En]}).filter(Boolean).some(function(n){return n.length>u.length&&n.includes(u)}));var c=In||s.isMissingStr(u)||d,v="".concat(Bn,".").concat(l),h="".concat(On).concat(s.DEVIATION_BADGE_SEPARATOR).concat(i).concat(s.DEVIATION_BADGE_SEPARATOR).concat(an).concat(s.DEVIATION_BADGE_SEPARATOR).concat(rn),f=n.__assign({},wn),p=(null==t?void 0:t.deviation_summary)?{deviation_summary:t.deviation_summary||(null==Rn?void 0:Rn.deviation_summary),deviation_title:null==Rn?void 0:Rn.deviation_title,evaluation_outputs:null==Rn?void 0:Rn.evaluation_outputs}:null;return{id:o,actionId:h,label:v,highlight:a,side:R,style:f,score:jn,isConnected:N.has(h),isOrphan:c,isMissingClause:r,badgeRef:G(R,o),onClick:function(e){e.stopPropagation();var i=pn?n.__assign(n.__assign({},pn),{title:(null==ln?void 0:ln.title)||(null==pn?void 0:pn.title)||""}):{id:"orphan-left",title:"",content:""},t=gn?n.__assign(n.__assign({},gn),{title:(null==sn?void 0:sn.title)||(null==gn?void 0:gn.title)||""}):{id:"orphan-right",title:"",content:""};L(e,i,c,t,h,f)},onSummaryClick:function(n){n.stopPropagation(),U(n,h,c,p)}}}).filter(Boolean).sort(function(n,e){return parseFloat(n.label)-parseFloat(e.label)}),Tn=k?Fn:[],Mn=i.useRef(!1);i.useEffect(function(){nn||(Mn.current=!1)},[nn]),i.useEffect(function(){if(nn&&!Mn.current){var n=setTimeout(function(){var n,e;Mn.current=!0;var i=null===(e=null===(n=Fn[0])||void 0===n?void 0:n.badgeRef)||void 0===e?void 0:e.current;i&&i.scrollIntoView({behavior:"smooth",block:"center"})},350);return function(){return clearTimeout(n)}}},[nn,Fn]);var Nn=Fn.some(function(n){return N.has(n.actionId)});if(!(X||Y||b.subsections&&0!==b.subsections.length))return null;var qn=Nn&&bn?{borderRadius:"4px",outline:"2px solid ".concat(bn.badgeBorder),outlineOffset:"1px"}:{};return X?e.jsx(t.Box,n.__assign({ref:en,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e.jsx(t.Box,n.__assign({sx:n.__assign({width:"100%"},qn)},{children:e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!Z&&nn,onChange:function(){if(!Z){if(nn){var e=String(q||""),i=e.includes(an)||e.includes(rn);i||N.forEach(function(n){(String(n).includes(an)||String(n).includes(rn))&&(i=!0)}),i&&(H(),K(new Set),J([]),Q.current=[])}P(function(e){var i;return n.__assign(n.__assign({},e),((i={})[y]=!e[y],i))})}},sx:{mt:0,boxShadow:"none",border:Z?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:Z?null:e.jsx(o.ChevronDown,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e.jsx(t.Typography,n.__assign({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Z?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:$||"Untitled Subsection"}))})),!Z&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[Y&&e.jsx(l.MemoizedMarkdown,{content:b.content,sxStyles:V,deviationBadges:Tn,maintainRelativeOrder:w,highlightBg:Cn,highlights:Dn}),(b.subsections||[]).map(function(i,t){return e.jsx(u,n.__assign({},r,{section:i,keyPath:"".concat(y,"-").concat(t),depth:E+1}),"".concat(y,"-").concat(t))})]}))]}))}))})):e.jsx(t.Box,n.__assign({ref:en,sx:{mt:0===E?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Z&&e.jsxs(t.Box,n.__assign({sx:n.__assign({width:"100%"},qn)},{children:[Y&&e.jsx(l.MemoizedMarkdown,{content:b.content,sxStyles:V,deviationBadges:Tn,maintainRelativeOrder:w,highlightBg:Cn,highlights:Dn}),(b.subsections||[]).map(function(i,t){return e.jsx(u,n.__assign({},r,{section:i,keyPath:"".concat(y,"-").concat(t),depth:E+1}),"".concat(y,"-").concat(t))})]}))}))});exports.default=u;
2
2
  //# sourceMappingURL=SubSectionAccordion.js.map