@viswa-test/test-citation 0.0.130 → 0.0.132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +2 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +2 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts +2 -1
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts +2 -1
- package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -0
- package/dist/types/src/features/CognitiveCompare/hooks/useStyles.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/hooks/useStyles.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),r=require("../../assests/svg/ButtonCognitiveIcon.js"),l=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),m=require("./hooks/useDeviationNavigation.js"),_=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),b=require("./components/CognitiveSummaryPopup.js"),S=require("./components/connectedLines.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var E,I,T,B,C,D,O,w,N,j,P,F,k,M,L,V,H,q,G,z,W,K,Y,U,X,$,J=A.componentHeaderText,Q=void 0===J?a.DEFAULT_COMPONENT_HEADER_TEXT:J,Z=A.treeData,ee=A.comparisonConfig,ne=A.leftColumnTitleText,te=A.rightColumnTitleText,ie=A.markdownStyles,oe=A.resetTrigger,re=A.displayConfig,le=void 0===re?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:re,ue=A.popupConfig,ce=A.deviationData,ae=void 0===ce?{}:ce,se=A.deviationNodeIdToView,de=A.resetDeviationNodeId,ve=A.isProposingFix,fe=void 0!==ve&&ve,ge=A.proposingFixNodeId,pe=t.useState(le.maintainRelativeOrder),he=pe[0],xe=pe[1],me=!!he||!!(null==le?void 0:le.showDeviationBadges),_e=t.useState(!1),Re=_e[0],ye=_e[1],be=t.useState(!1),Se=be[0],Ae=be[1],Ee=t.useState(null),Ie=Ee[0],Te=Ee[1],Be=t.useState(!1),Ce=Be[0],De=Be[1],Oe=t.useState(null===(I=null!==(E=null==Z?void 0:Z.newEvaluationResult)&&void 0!==E?E:null==le?void 0:le.enableDeviationSchemaBackwardCompatibility)||void 0===I||I)[0],we=t.useState(!1),Ne=we[0],je=we[1],Pe=t.useState(!1),Fe=Pe[0],ke=Pe[1],Me=t.useState(null),Le=Me[0],Ve=Me[1],He=t.useRef(!1),qe=t.useState(new Set),Ge=qe[0],ze=qe[1],We=t.useState([]),Ke=We[0],Ye=We[1],Ue=t.useRef(null),Xe=t.useRef(null),$e=t.useRef(null),Je=t.useRef(new Set),Qe=t.useRef(!1),Ze=t.useRef(null),en=t.useRef({}),nn=t.useRef([]),tn=t.useRef(!1),on=t.useRef(!1),rn=t.useRef(null),ln=t.useRef(function(){}),un=t.useMemo(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),cn=t.useState({width:0,height:0}),an=cn[0],sn=cn[1],dn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),ie)},[ie]),vn=t.useRef(null),fn=t.useRef(null),gn=t.useRef(null),pn=t.useRef(null),hn=t.useRef(null),xn=t.useRef(null),mn=t.useRef(null),_n=t.useRef(null),Rn=t.useRef(!1),yn=t.useRef(null),bn=t.useRef(null),Sn=p.useComparePopups(vn),An=Sn.cognitivePopup,En=Sn.setCognitivePopup,In=Sn.moreFunctions,Tn=Sn.setMoreFunctions,Bn=Sn.position,Cn=Sn.setPosition,Dn=Sn.activeBadgeId,On=Sn.summaryPopup,wn=Sn.setSummaryPopup,Nn=Sn.closeSummaryPopup,jn=Sn.setActiveBadgeId,Pn=Sn.popupRef,Fn=Sn.closeCognitivePopup,kn=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]),Ln=t.useState(null),Vn=Ln[0];Ln[1];var Hn=null===(C=null===(T=null==Z?void 0:Z.documents)||void 0===T?void 0:T[null===(B=null==Z?void 0:Z.input_index_map)||void 0===B?void 0:B[0]])||void 0===C?void 0:C.title,qn=null===(w=null===(D=null==Z?void 0:Z.documents)||void 0===D?void 0:D[null===(O=null==Z?void 0:Z.input_index_map)||void 0===O?void 0:O[1]])||void 0===w?void 0:w.title,Gn=u.safeStringify(ne||Hn||"Uploaded Contract"),zn=u.safeStringify(te||qn||"Reference Template"),Wn=g.useCognitiveTreeData(Z,he,ae,Mn,Oe),Kn=Wn.activeProposed,Yn=Wn.existingRule,Un=Wn.proposedSections,Xn=Wn.existingSections,$n=Wn.visibleFields,Jn=Wn.parentDeviationRecord,Qn=Wn.deviationNumberRegistry,Zn=Wn.parseError;t.useEffect(function(){Zn&&Te("Failed to load comparison: ".concat(Zn))},[Zn]);var et=Un.length>0||Xn.length>0,nt=t.useMemo(function(){var e=new Map,n=new Map,t=1;if(he)Un.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,t++)}),Xn.forEach(function(i){if(i.id){var o=Un.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(i.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(i.id,r.join(", "))}else n.set(i.id,String(t++))}});else for(var i=Math.max(Un.length,Xn.length),o=0;o<i;o++){var r=Un[o],l=Xn[o];r?(e.set(r.id,t),l&&n.set(l.id,String(t)),t++):l&&n.set(l.id,String(t++))}return{leftNums:e,rightNums:n}},[Un,Xn,he]),tt=h.useSectionRefs($n.map(function(e){return e.key}),Math.max(Un.length,Xn.length)),it=tt.leftRefs,ot=tt.rightRefs,rt=tt.sectionLeftRefs,lt=tt.sectionRightRefs,ut=tt.lhsBadgeRefs,ct=tt.rhsBadgeRefs,at=tt.sectionRightRowRefs,st=tt.subSectionLeftRefs,dt=tt.subSectionRightRefs,vt=tt.sectionRowRefs,ft=tt.getSectionRowRef,gt=tt.getSubSectionRef,pt=tt.getBadgeRef,ht=Yn.analysis,xt=u.safeStringify(null===(j=null===(N=null==ht?void 0:ht.rule_difference_comparison)||void 0===N?void 0:N.summary)||void 0===j?void 0:j.overall_summary),mt=!!xt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),_t=null!==(P=null==Z?void 0:Z.base_root_id)&&void 0!==P?P:"-1";null==Z||Z[_t];var Rt=Oe?null!==(Y=null!==(z=ae&&(null===(G=null==ae?void 0:ae[_t])||void 0===G?void 0:G.evaluation_result))&&void 0!==z?z:null===(K=null===(W=null==Z?void 0:Z.nodes)||void 0===W?void 0:W[_t])||void 0===K?void 0:K.evaluation_result)&&void 0!==Y?Y:null:null!==(q=null!==(M=ae&&(null===(k=null===(F=null==ae?void 0:ae[_t])||void 0===F?void 0:F.evaluation_result)||void 0===k?void 0:k[0]))&&void 0!==M?M:null===(H=null===(V=null===(L=null==Z?void 0:Z.nodes)||void 0===L?void 0:L[_t])||void 0===V?void 0:V.evaluation_result)||void 0===H?void 0:H[0])&&void 0!==q?q:null,yt=u.extractDeviationScore(Rt),bt=u.generateColorPalette(null!==($=null===(X=null===(U=null==Rt?void 0:Rt.evaluation_outputs)||void 0===U?void 0:U.metadata)||void 0===X?void 0:X.label_color)&&void 0!==$?$:""),St=function(){Je.current.forEach(function(e){u.resetClauseHighlight(e)}),Je.current.clear()},At=t.useCallback(function(){var e,n,t,i,o,r;St(),De(!1),on.current=!1,Xe.current=null;var l=rn.current,c=Gt.current;if(null!==l)if("string"==typeof l&&l.includes(u.DEVIATION_BADGE_SEPARATOR)){var a=l.split(u.DEVIATION_BADGE_SEPARATOR);(s=(null===(e=st.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=rt.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=rt.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=dt.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=lt.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=lt.current[c])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}Ve(null),rn.current=null,Gt.current=null,je(!1),Ae(!1),pn.current&&(pn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px")},[]),Et=t.useCallback(function(){St(),At(),ze(new Set),Ye([]),nn.current=[],Xt([]),Qt(null),wn(a.EMPTY_SUMMARY_POPUP_STATE),Fn(),requestAnimationFrame(function(){var e;null===(e=ln.current)||void 0===e||e.call(ln)})},[]),It=t.useRef(Et);t.useEffect(function(){It.current=Et},[Et]),t.useEffect(function(){oe&&It.current()},[oe]);var Tt=x.useAccordionState({maintainRelativeOrder:!!he,proposedSections:Un,existingSections:Xn,activeSideBySideSection:Le,connectedSections:Ge,resetSideBySide:At,setConnectedSections:ze,setConnectedLines:Ye,cachedConnectedPositions:nn,svgContainerRef:Ue,isAnimatingRef:Qe,animationTimerRef:Ze,calculateLinesRef:ln,sectionLeftRefs:rt,sectionRightRefs:lt,subSectionLeftRefs:st,subSectionRightRefs:dt}),Bt=Tt.expandedSections,Ct=Tt.setExpandedSections,Dt=Tt.expandedSubSections,Ot=Tt.setExpandedSubSections,wt=Tt.toggleSection,Nt=t.useCallback(function(n,t,i,o,r,l,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",f=(v?un[v]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},g=null!==(s=null===(a=vt.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.title)?null==t?void 0:t.title:"No Counterpart",refSectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",cognitiveData:f,anchorEl:n,sectionAnchorEl:g,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==Z?void 0:Z.documents,input_index_map:null==Z?void 0:Z.input_index_map},deviationData:function(){var n,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,c=function(n){var t=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var t=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(t&&n[t])return n[t]}var i=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(i.length&&e[i[0]])return e[i[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return t?e.__assign(e.__assign({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)))return c(l);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return l;var s=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(n=null==s?void 0:s.deviation_entries)||void 0===n?void 0:n[a])||(null===(r=null==s?void 0:s.deviations)||void 0===r?void 0:r[a])||null;return d?e.__assign(e.__assign(e.__assign({},s),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==s?void 0:s.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==s?void 0:s.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==s?void 0:s.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==s?void 0:s.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==s?void 0:s.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==s?void 0:s.cognitive_decisioning)}):c(l)}(),isOrphan:!!r}},[un,Z]),jt=t.useCallback(function(e){kn(),Cn(null),En(e)},[kn]),Pt=function(e,n,t,i,o,r){var l;if(e.stopPropagation(),In.open&&In.sectionIdx===o)kn();else{var c=e.currentTarget,a="left";(null===(l=gn.current)||void 0===l?void 0:l.contains(c))&&(a="right");St(),on.current&&At(),ze(new Set),Ye([]),nn.current=[],Fn(),On.open?mi():Nn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=o.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=ct.current[l])||void 0===e?void 0:e.current:null===(n=ut.current[l])||void 0===n?void 0:n.current}return"right"===a?null===(t=ct.current[o])||void 0===t?void 0:t.current:null===(i=ut.current[o])||void 0===i?void 0:i.current}()||c;Tn(Nt(e,n,i,o,t,r))})}},Ft=t.useCallback(function(){null!==In.sectionIdx&&In.anchorEl?jt(e.__assign(e.__assign({},In),{open:!0})):kn()},[In,kn,jt]),kt=t.useCallback(function(){var e=In.sectionIdx,n=In.isOrphan;kn(),Nn(),null!==e&&(n?Te("No counterpart exists to connect to."):(St(),on.current&&At(),Ye([]),nn.current=[],ze(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){ln.current&&ln.current()},50)))},[In.sectionIdx,In.isOrphan,kn,Nn,At]),Mt=t.useCallback(function(){var e=$e.current;if(e){$e.current=null;var n=Un.findIndex(function(n){return n.id===e}),t=Xn.findIndex(function(n){return n.id===e}),i=-1===n?u.findKeyPathByNodeId(Un,e):null,o=-1===t?u.findKeyPathByNodeId(Xn,e):null,r=-1!==n?n:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=function(e,n,t,i){var o,r,l,u;return-1!==e?null!==(r=null===(o=t.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=i.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},a=function(e,n,t){void 0===t&&(t=30);var i=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(Je.current.add(r),u.scrollAndHighlightClause(r,n)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(he)-1!==r&&_n.current&&a(function(){return c(n,i,rt,st)},_n.current),-1!==l&&gn.current&&a(function(){return c(t,o,lt,dt)},gn.current);else{var s=vn.current;if(!s)return;a(function(){return-1!==r?c(n,i,rt,st):c(t,o,lt,dt)},s)}}},[Un,Xn,he,rt,lt,st,dt,_n,gn,vn]),Lt=t.useCallback(function(n){if(n){St(),At(),ze(new Set),Ye([]),nn.current=[],Nn(),Fn();var t=Un.findIndex(function(e){return e.id===n}),i=Xn.findIndex(function(e){return e.id===n}),o=-1===t?u.findKeyPathByNodeId(Un,n):null,r=-1===i?u.findKeyPathByNodeId(Xn,n):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,c=-1!==i?i:r?Number(r.split("-")[0]):-1;$e.current=n,Ct(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}),Ot(function(n){var t=e.__assign({},n),i=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:n}),setTimeout(function(){requestAnimationFrame(function(){$e.current===n&&Vt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Un,Xn,he,Ct,Ot,At,Nn,Fn]),Vt=t.useRef(Mt);t.useEffect(function(){Vt.current=Mt},[Mt]);var Ht=t.useRef(null),qt=t.useRef(null),Gt=t.useRef(null),zt=t.useRef(null),Wt=t.useRef(null),Kt=t.useRef(null),Yt=t.useState([]),Ut=Yt[0],Xt=Yt[1];t.useRef(null);var $t=t.useState(null),Jt=$t[0],Qt=$t[1];t.useEffect(function(){if(Vn){var e=Mn.fields.find(function(e){return e.analysisKey===Vn||e.key===Vn});if(e){var n=it.current[e.key]||ot.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Vn,Mn.fields]);var Zt=t.useCallback(function(e){var n,t,i,o,r,l,u,c,a,s=null===(n=null==ht?void 0:ht.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}},[ht]),ei=t.useCallback(function(n,t){var i,o,r;void 0===t&&(t="left");var l=null,c=null;if("left"===t)if(l=Un[n],he&&l){var s=Xn.filter(function(e){var n;return null===(n=l.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});c=s.find(function(e){return e.evaluationResult})||s[0]}else c=Xn[n];else if(c=Xn[n],he&&c){var d=Un.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)});l=d.find(function(e){return e.evaluationResult})||d[0]}else l=Un[n];var v=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,g=!(!(null==l?void 0:l.cognitiveData)&&!(null==c?void 0:c.cognitiveData));if(!v&&!f&&!g)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==c?void 0:c.evaluationResult)&&void 0!==o?o:null,h=u.getFirstDeviationOutputValue(p),x=u.getFirstDeviationColor(p);return null!=p?e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null!==(r=h)&&void 0!==r?r:""}):e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null})},[Un,Xn,un,Mn,he]),ni=t.useCallback(function(n){for(var t,i,o,r,l,c=n.split("-").map(Number),s=Un[c[0]],d=Xn[c[0]],v=1;v<c.length;v++)(null==s?void 0:s.subsections)&&(s=s.subsections[c[v]]),(null==d?void 0:d.subsections)&&(d=d.subsections[c[v]]);if(!s&&!d)return null;var f=(null==s?void 0:s.relation)&&"not_defined"!==s.relation,g=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,p=u.safeStringify(null==s?void 0:s.id)||u.safeStringify(null==d?void 0:d.id)||"",h=!(!(null==s?void 0:s.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!f&&!g&&!h)return e.__assign(e.__assign({},u.generateColorPalette(a.DEFAULT_DEVIAION_COLOR)),{label:"Not Defined"});null!==(i=null!==(t=null==s?void 0:s.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=un[p])||void 0===o||o.relevance_score);var x=null!==(l=null!==(r=null==s?void 0:s.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,m=u.getFirstDeviationOutputValue(x),_=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null!=m?m:""}):e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null})},[Un,Xn,un,Mn]),ti=t.useCallback(function(n,t){var i,o,r,l,c,s,d,v,f,g,p,h,x,m,_,R,y;if(!n||null==t)return null;var b=null!==(d=null!==(c=null!==(o=null===(i=null==ae?void 0:ae[n])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==Z?void 0:Z.nodes)||void 0===r?void 0:r[n])||void 0===l?void 0:l.evaluation_result)&&void 0!==c?c:null===(s=null==Z?void 0:Z[n])||void 0===s?void 0:s.evaluation_result)&&void 0!==d?d:null;if(!b||"object"!=typeof b)return null;var S=null!==(p=null!==(f=null===(v=null==b?void 0:b.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==b?void 0:b.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==b?void 0:b[t],A=null!==(y=null!==(m=null===(x=null===(h=null==S?void 0:S.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==m?m:null===(R=null===(_=null==b?void 0:b.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===R?void 0:R.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR;return e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[ae,Z]),ii=t.useCallback(function(){St(),Ct({}),Ot({}),At(),ze(new Set),Ye([]),nn.current=[],Nn(),Fn(),kn(),requestAnimationFrame(function(){ln.current&&ln.current()})},[Ct,Ot,At,Nn,Fn,kn]),oi=t.useMemo(function(){return Object.values(Bt).some(Boolean)||Object.values(Dt).some(Boolean)},[Bt,Dt]),ri=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p,h,x,m,_,R,y,b,S;if(!Rn.current&&!Qe.current){Rn.current=!0;try{if(!Ht.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!Bt[t]&&!1===he)return!1;if(he&&!Bt["left-".concat(t)]&&!Bt["right-".concat(t)]&&!Bt[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!Dt[i])return!1;return!0},E=Ht.current.getBoundingClientRect();sn({width:E.width,height:E.height});var I=[];if($n.forEach(function(e){var n,t,i=e.key,o=null===(n=it.current[i])||void 0===n?void 0:n.current,r=null===(t=ot.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!Qe.current){for(var T=0;T<Math.max(Un.length,Xn.length);T++){var B=null===(e=rt.current[T])||void 0===e?void 0:e.current,C=null===(n=lt.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(st.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=st.current[e])||void 0===n?void 0:n.current,o=null===(t=dt.current[e])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var D={};$n.forEach(function(e){var n,t,i=e.key,o=null===(n=it.current[i])||void 0===n?void 0:n.current,r=null===(t=ot.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var O={left:{},right:{}},w={};if(!Qe.current)if(he){if(Ce&&null!==Le)if("number"==typeof Le){var N=Le,j=Un[N],P=null===(o=rt.current[N])||void 0===o?void 0:o.current;P&&j&&(j.refIndexes||[]).forEach(function(e){var n,t=Xn.findIndex(function(n){return n.selfIndex===e}),i=null===(n=lt.current[t])||void 0===n?void 0:n.current;if(i&&(Bt["left-".concat(N)]||Bt["right-".concat(t)])){var o=Math.max(P.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[N]=Math.max(O.left[N]||0,o),O.right[t]=Math.max(O.right[t]||0,o)}})}else{var F=Le.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(r=st.current[F])||void 0===r?void 0:r.current,C=null===(l=dt.current[F])||void 0===l?void 0:l.current;if(B&&C){k=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);w[F]=Math.max(w[F]||0,k)}}}}else{Object.keys(st.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=st.current[e])||void 0===n?void 0:n.current,o=null===(t=dt.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);w[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(T=0;T<Math.min(Un.length,Xn.length);T++){var B=null===(t=rt.current[T])||void 0===t?void 0:t.current,C=null===(i=lt.current[T])||void 0===i?void 0:i.current;if(B&&C){var k=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);O.left[T]=k,O.right[T]=k}}}if($n.forEach(function(e){var n,t,i=e.key,o=null===(n=it.current[i])||void 0===n?void 0:n.current,r=null===(t=ot.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Qe.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=rt.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=lt.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=st.current[e])||void 0===n?void 0:n.current,o=null===(t=dt.current[e])||void 0===t?void 0:t.current;if(i&&o&&w[e]){var r=w[e];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),he)Un.forEach(function(e,n){var t;(null===(t=rt.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,r,l,u,c,a,s,d,v=Xn.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=ut.current[n])||void 0===t?void 0:t.current,g=null===(i=ct.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-E.left,m=h.left-E.left,_=p.top+p.height/2-E.top,R=h.top+h.height/2-E.top;if(Ce&&Le===n){var y=null!==(r=null===(o=_n.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,b=null!==(u=null===(l=gn.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,S=y+(null!==(a=null===(c=_n.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=b+(null!==(d=null===(s=gn.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),T=p.top+p.height/2,B=h.top+h.height/2,C=function(e,n,t){return Math.max(n,Math.min(t,e))};_=C(T,y,S)-E.top,R=C(B,b,A)-E.top}var D=ei(n);D&&I.push({id:"line-".concat(n,"-").concat(v),x1:x,y1:_,x2:m,y2:R,style:D,sectionIdx:n,targetRightIdx:v})}}})});else{for(T=0;T<Math.min(Un.length,Xn.length);T++){var M=null===(c=rt.current[T])||void 0===c?void 0:c.current,L=null===(a=lt.current[T])||void 0===a?void 0:a.current;if(M&&L){var V=M.getBoundingClientRect(),H=L.getBoundingClientRect(),q=Math.max(V.top,H.top)+18-E.top,G=(null===(s=Xn[T])||void 0===s?void 0:s.id)||"sec-".concat(T);(J=ei(T))&&I.push({id:G,x1:V.right-E.left,y1:q,x2:H.left-E.left,y2:q,style:J,sectionIdx:T,hasCognitive:!!((null===(d=Un[T])||void 0===d?void 0:d.cognitiveData)||(null===(v=Xn[T])||void 0===v?void 0:v.cognitiveData)||G&&un[G]),isSubSection:!1})}}Object.keys(st.current).forEach(function(e){var n,t,i,o,r,l;if(A(e)){var c=null===(n=st.current[e])||void 0===n?void 0:n.current,a=null===(t=dt.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Un[s[0]],v=Xn[s[0]],f=1;f<s.length;f++)(null==d?void 0:d.subsections)&&(d=d.subsections[s[f]]),(null==v?void 0:v.subsections)&&(v=v.subsections[s[f]]);var g=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&u.hasValue(d.title)),p=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&u.hasValue(d.content)),h=!!v&&((null===(r=v.displayTitle)||void 0===r||r)&&u.hasValue(v.title)),x=!!v&&((null===(l=v.displayContent)||void 0===l||l)&&u.hasValue(v.content));if(g&&p||h&&x){var m=c.getBoundingClientRect(),_=a.getBoundingClientRect(),R=Math.max(m.top,_.top)+16-E.top,y=ni(e);y&&"Not Defined"!==y.label&&I.push({id:"subsec-".concat(e),x1:m.right-E.left,y1:R,x2:_.left-E.left,y2:R,style:y,sectionIdx:s[0],isSubSection:!0,subSectionKeyPath:e,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==v?void 0:v.cognitiveData))})}}}})}if(Ce&&"string"==typeof Le&&Le.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Le.split(u.DEVIATION_BADGE_SEPARATOR),W=z[0],K=z[1],Y=z[2],U=(z[3],"".concat(W).concat(u.DEVIATION_BADGE_SEPARATOR).concat(K)),X=null===(f=ut.current[U])||void 0===f?void 0:f.current,$=null===(g=ct.current[U])||void 0===g?void 0:g.current;if(X&&$){var J,Q=X.getBoundingClientRect(),Z=$.getBoundingClientRect(),ee=Q.right-E.left,ne=Z.left-E.left,te=Q.top+Q.height/2-E.top,ie=Z.top+Z.height/2-E.top;if(he){var oe=null!==(h=null===(p=_n.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,re=null!==(m=null===(x=gn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,le=oe+(null!==(R=null===(_=_n.current)||void 0===_?void 0:_.clientHeight)&&void 0!==R?R:1/0),ue=re+(null!==(b=null===(y=gn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==b?b:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,le)-E.top,ie=ce(Z.top+Z.height/2,re,ue)-E.top}(J=null!==(S=ti(W,K))&&void 0!==S?S:ni(Y))&&I.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:Le})}}if(Xt(I),Wt.current&&Kt.current){var ae=Wt.current.getBoundingClientRect(),se=Kt.current.getBoundingClientRect(),de=(ae.top+ae.height/2-E.top+se.top+se.height/2-E.top)/2;Qt({x1:ae.right-E.left,x2:se.left-E.left,y:de})}else Qt(null);if(Ge.size>0){var ve=[],fe=_n.current,ge=gn.current;if(fe&&ge){var pe=[],xe=fe.getBoundingClientRect().top,me=ge.getBoundingClientRect().top,_e=xe+fe.clientHeight,Re=me+ge.clientHeight,ye=fe.scrollTop,be=ge.scrollTop,Se=E.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};Ge.forEach(function(e){var n,t,i,o,r,l;if("string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR)){var c=e.split(u.DEVIATION_BADGE_SEPARATOR),a=c[0],s=c[1],d=c[2],v=(c[3],"".concat(a).concat(u.DEVIATION_BADGE_SEPARATOR).concat(s)),f=null===(n=ut.current[v])||void 0===n?void 0:n.current,g=null===(t=ct.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=ti(a,s))&&void 0!==i?i:ni(d),m=(P=p.right-E.left)+.5*((F=h.left-E.left-0)-P),_=p.top+p.height/2,R=h.top+h.height/2,y=_-xe+ye,b=R-me+be,S="conn-subsec-".concat(v);pe.push({lhsScrollY:y,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var A=Ae(_,xe,_e),I=Ae(R,me,Re),T=A-Se,B=I-Se,C=R>=me-4&&R<=Re+4,D="";D=(k=_>=xe-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):k&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!k&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(he){var O=e,w=Un[O];if(!(null===(l=null==w?void 0:w.refIndexes)||void 0===l?void 0:l.length))return;w.refIndexes.forEach(function(e){var n,t,i=Xn.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=ut.current[O])||void 0===n?void 0:n.current,r=null===(t=ct.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),a=ei(O),s=l.right-E.left,d=c.left-E.left-0,v=s+.5*(d-s),f=l.top+l.height/2,g=c.top+c.height/2,p=f-xe+ye,h=g-me+be,x="conn-".concat(O,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ae(f,xe,_e),_=Ae(g,me,Re),R=m-Se,y=_-Se,b=f>=xe-4&&f<=_e+4,S=g>=me-4&&g<=Re+4,A="";A=b&&S?u.getBentArrowPath(s,R,d,y):b&&!S?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!b&&S?"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y," L ").concat(d,",").concat(y):"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y),ve.push({id:x,pathD:A,style:a,leftIdx:O,rhsArrayIdx:i})}}})}else{var N=e,j=N;f=null===(o=ut.current[N])||void 0===o?void 0:o.current,g=null===(r=ct.current[j])||void 0===r?void 0:r.current;if(!f||!g)return;var P,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=ei(N),m=(P=p.right-E.left)+.5*((F=h.left-E.left-0)-P),_=p.top+p.height/2,R=h.top+h.height/2,y=_-xe+ye,b=R-me+be,S="conn-".concat(N,"-").concat(j);pe.push({lhsScrollY:y,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:N,rhsArrayIdx:j,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var k;A=Ae(_,xe,_e),I=Ae(R,me,Re),T=A-Se,B=I-Se,C=R>=me-4&&R<=Re+4,D="";D=(k=_>=xe-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):k&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!k&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:N,rhsArrayIdx:j})}}),nn.current=pe}Ye(ve)}else Ye([]),nn.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{Rn.current=!1}}},[$n,Un,Xn,un,Mn,Zt,ei,ti,he,Ce,Le,Ge,Bt,Dt]),li=t.useCallback(function(){var e,n,t,i,o,r,l,c,a,s,d,v,f,g,p=nn.current;if(p.length&&!Qe.current){var h=null!==(n=null===(e=_n.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=gn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(r=null===(o=_n.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,_=null!==(c=null===(l=gn.current)||void 0===l?void 0:l.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=_n.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=gn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,b=R+m,S=y+_,A=null!==(g=null===(f=Ht.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,E=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+R,t=e.rhsScrollY-x+y,i=en.current[e.styleId+"-stroke"],o=en.current[e.styleId+"-bg"];if(i||o){var r,l=E(n,R,b),c=E(t,y,S),a=l-A,s=c-A,d=n>=R-4&&n<=b+4,v=t>=y-4&&t<=S+4,f=e.x1+.5*(e.x2-e.x1);r=d&&v?u.getBentArrowPath(e.x1,a,e.x2,s):d&&!v?"M ".concat(e.x1,",").concat(a," L ").concat(f,",").concat(a," L ").concat(f,",").concat(s):!d&&v?"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s," L ").concat(e.x2,",").concat(s):"M ".concat(f,",").concat(a," L ").concat(f,",").concat(s),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);t.useEffect(function(){ln.current=ri},[ri]);var ui=t.useRef(null),ci=t.useRef(null),ai=t.useCallback(function(){nn.current.length>0&&!Qe.current||(null!==ui.current&&clearTimeout(ui.current),ui.current=setTimeout(function(){ln.current(),ui.current=null},50))},[]),si=t.useCallback(function(){ke(!0),je(!1),Xe.current=null,null!==ci.current&&clearTimeout(ci.current),null!==ui.current&&(clearTimeout(ui.current),ui.current=null),ci.current=setTimeout(function(){var e,n,t,i,o,r,l,c,a,s,d;try{if(nn.current=[],on.current&&null!==rn.current&&null!==Gt.current){var v=rn.current,f=Gt.current,g="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR),p=null,h=null,x=null,m=null;if(g){var _=v.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(_[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(_[1]);p=(null===(e=ut.current[R])||void 0===e?void 0:e.current)||null,h=(null===(n=ct.current[R])||void 0===n?void 0:n.current)||null,x=(null===(t=st.current[_[2]])||void 0===t?void 0:t.current)||(null===(i=rt.current[Number(_[2])])||void 0===i?void 0:i.current)||null,m=(null===(o=dt.current[_[3]])||void 0===o?void 0:o.current)||(null===(r=lt.current[Number(_[3])])||void 0===r?void 0:r.current)||null}else p=(null===(l=vt.current[v])||void 0===l?void 0:l.current)||null,x=(null===(c=rt.current[v])||void 0===c?void 0:c.current)||null,h=(null===(a=at.current[f])||void 0===a?void 0:a.current)||null,m=(null===(s=lt.current[f])||void 0===s?void 0:s.current)||null;if(p&&h&&x&&m){if(x.style.paddingTop="0px",m.style.paddingTop="0px",!he){var y=p.getBoundingClientRect(),b=h.getBoundingClientRect(),S=y.top-b.top;S>0?m.style.paddingTop="".concat(S,"px"):S<0&&(x.style.paddingTop="".concat(Math.abs(S),"px"))}var A=_n.current,E=gn.current;if(A&&E){var I=p.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop,T=h.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop-(I-A.scrollTop);Math.abs(E.scrollTop-T)>1&&(E.scrollTop=T)}}}null===(d=ln.current)||void 0===d||d.call(ln),on.current&&je(!0)}catch(e){console.error("Safely caught error during resize calculation:",e)}finally{ke(!1),ci.current=null}},150)},[he,Un,Xn]),di=t.useCallback(function(e){if(null!==yn.current&&bn.current&&Math.abs(e.currentTarget.scrollTop-yn.current)<=2){var n=bn.current;yn.current=null,bn.current=null,n()}He.current||(he||ai(),tn.current||(tn.current=!0,requestAnimationFrame(function(){var e,n,t,i,o,r,l;if(on.current){var c=_n.current,a=gn.current;if(c&&a&&zt.current){if(!Xe.current){var s=rn.current,d=void 0;if("string"==typeof s&&s.includes(u.DEVIATION_BADGE_SEPARATOR)){var v=s.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(v[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(v[1]);d=null===(e=ut.current[f])||void 0===e?void 0:e.current}else d=null===(n=ut.current[s])||void 0===n?void 0:n.current;if(d){var g=d.getBoundingClientRect();Xe.current={badgeScreenY:g.top+g.height/2,initialScrollTop:c.scrollTop,leftTop:c.getBoundingClientRect().top,leftBottom:c.getBoundingClientRect().top+c.clientHeight,cTop:null!==(i=null===(t=Ht.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(Xe.current){var p=Xe.current,h=c.scrollTop-p.initialScrollTop,x=p.badgeScreenY-h,m=((o=x,r=p.leftTop,l=p.leftBottom,Math.max(r,Math.min(l,o)))-p.cTop).toString(),_=x>=p.leftTop-4&&x<=p.leftBottom+4;zt.current.setAttribute("y1",m),zt.current.setAttribute("y2",m),zt.current.setAttribute("visibility",_?"visible":"hidden")}}}nn.current.length>0&&li(),tn.current=!1})))},[li,he,ai]),vi=t.useRef(0),fi=t.useRef(0),gi=t.useRef(0),pi=t.useRef(function(){});t.useRef(null),t.useEffect(function(){pi.current=si},[si]),t.useEffect(function(){var e=setTimeout(ai,250),n=function(){return pi.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==ui.current&&clearTimeout(ui.current),null!==ci.current&&clearTimeout(ci.current),window.removeEventListener("resize",n)}},[Kn,Yn,ht,$n,Bt,Dt,Un,Xn,Mn,ai,Ce,Le,Ne,Ge]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return r.observe(e),r},n={current:null},t={current:null},i={current:null},o=[],r=[n,t,i];return fn.current&&o.push(e(fn.current,vi,n,function(){return pi.current()},function(){})),vn.current&&o.push(e(vn.current,fi,t,function(){return pi.current()},function(){return ln.current()})),Ht.current&&o.push(e(Ht.current,gi,i,function(){return pi.current()},function(){return ln.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){on.current=Ce},[Ce]),t.useEffect(function(){rn.current=Le},[Le]);var hi=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";kn(),null!=e&&(n?Te("No counterpart exists for this section."):(St(),Ce&&Le===e?r?At():null==l||l():(ze(new Set([e])),Ye([]),nn.current=[],Ae(!0),He.current=!0,Ve(e),rn.current=e,De(!0),on.current=!0,je(!1),pn.current&&(pn.current.style.height="0px"),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,r,a="string"==typeof e&&e.includes(u.DEVIATION_BADGE_SEPARATOR),s=null,d=null,v=null;if(a){var f=e.split(u.DEVIATION_BADGE_SEPARATOR),g="".concat(f[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(f[1]);s=(null===(n=ut.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=ct.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=vt.current[e])||void 0===i?void 0:i.current)||null,he){var p=Un[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],m=Xn.findIndex(function(e){return e.selfIndex===x});-1!==m&&(d=(null===(r=at.current[m])||void 0===r?void 0:r.current)||null,v=m)}}else d=(null===(o=at.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Gt.current=v;var _=_n.current,R=gn.current,y=function(){!function(){var n,t,i,o,r,l,c,s,d,f,g,p,h=null,x=null,m=null,_=null;if(a){var R=e.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(R[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(R[1]);h=(null===(n=st.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=rt.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=dt.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=lt.current[Number(R[3])])||void 0===o?void 0:o.current)||null,m=(null===(r=ut.current[y])||void 0===r?void 0:r.current)||h,_=(null===(l=ct.current[y])||void 0===l?void 0:l.current)||x}else{var b=Number(e),S=null!==v?Number(v):b;h=(null===(c=rt.current[b])||void 0===c?void 0:c.current)||null,x=(null===(s=lt.current[S])||void 0===s?void 0:s.current)||null,m=(null===(d=ut.current[b])||void 0===d?void 0:d.current)||(null===(f=vt.current[b])||void 0===f?void 0:f.current)||h,_=(null===(g=ct.current[S])||void 0===g?void 0:g.current)||(null===(p=at.current[S])||void 0===p?void 0:p.current)||x}if(m&&_&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=m.getBoundingClientRect(),E=_.getBoundingClientRect(),I=A.top-E.top;I>0?x.style.paddingTop="".concat(I,"px"):I<0&&(h.style.paddingTop="".concat(Math.abs(I),"px"))}}(),je(!0),ln.current&&ln.current(),He.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):_&&_.dispatchEvent(new Event("scroll")),Ae(!1),null==l||l()};if(!s||!_)return He.current=!1,Ae(!1),void(null==l||l());if(d&&R){if(!he){var b=0;b="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var S=vn.current,A=(null==S?void 0:S.getBoundingClientRect().top)||0,E=S?S.scrollTop+b-A-150:0;return S?void u.smoothScrollTo(S,E,200,y):void y()}var I=s.getBoundingClientRect().top-_.getBoundingClientRect().top+_.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=T-(I-_.scrollTop);C<0&&pn.current&&(pn.current.style.height="".concat(Math.abs(C),"px")),requestAnimationFrame(function(){var e,n=R.scrollHeight-R.clientHeight;if(C<0)e=0;else{if(C>n){var t=C-n;return hn.current&&(hn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(R,C,B,y)})}e=C}u.smoothScrollTo(R,e,B,y)})}else{var D=I-(T-R.scrollTop);D<0&&xn.current&&(xn.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var e,n=_.scrollHeight-_.clientHeight;if(D<0)e=0;else{if(D>n){var t=D-n;return mn.current&&(mn.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(_,D,B,y)})}e=D}u.smoothScrollTo(_,e,B,y)})}}else y()}))))},[Le,kn,Xn,Ce,he,Un,At]),xi=t.useCallback(function(){var e,n=In.sectionIdx,t=In.isOrphan;if(Nn(),null!=n){var i="left";In.anchorEl&&(null===(e=gn.current)||void 0===e?void 0:e.contains(In.anchorEl))&&(i="right"),hi(n,t,{sourceSide:i})}},[hi,In.isOrphan,In.sectionIdx,In.anchorEl,Nn]),mi=t.useCallback(function(){Nn(),At(),ze(new Set),Ye([]),nn.current=[]},[Nn,At]),_i=null!==In.sectionIdx&&Ge.has(In.sectionIdx),Ri=m.useDeviationNavigation({proposedSections:Un,existingSections:Xn,parentDeviationRecord:Jn,expandedSections:Bt,maintainRelativeOrder:!!he,scrollContainerRef:vn,leftContainerRef:_n,rightContainerRef:gn,lhsBadgeRefs:ut,rhsBadgeRefs:ct}),yi=Ri.showDeviationNavigation,bi=Ri.showOpenNodeRef,Si=Ri.adjustScrollForPopup,Ai=t.useCallback(function(e,n,t,i,o){var r,l="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),c=e.currentTarget;Fn();var a="left";(null===(r=gn.current)||void 0===r?void 0:r.contains(c))&&(a="right");var s=function(){var e,t,i,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var r=n.split(u.DEVIATION_BADGE_SEPARATOR),l="".concat(r[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(r[1]);return"right"===a?null===(e=ct.current[l])||void 0===e?void 0:e.current:null===(t=ut.current[l])||void 0===t?void 0:t.current}return"right"===a?null===(i=ct.current[n])||void 0===i?void 0:i.current:null===(o=ut.current[n])||void 0===o?void 0:o.current};if(t)return At(),ze(new Set),Ye([]),nn.current=[],void(l&&requestAnimationFrame(function(){var e=s()||c;Si(e,function(){wn({open:!0,anchorEl:e,summary:i,displayImpact:o})})}));hi(n,t,l?{toggleIfSame:!1,sourceSide:a,onReady:function(){var e=s()||c;Si(e,function(){wn({open:!0,anchorEl:e,summary:i,displayImpact:o})})}}:{toggleIfSame:!1,sourceSide:a})},[hi,Fn,wn,At,Si]),Ei=t.useMemo(function(){var e;if(!se)return null;var n=null===(e=null==se?void 0:se.id)||void 0===e?void 0:e.split(":")[0];for(var t in Jn){if((Jn[t]||[]).some(function(e){return e.id===n}))return t}return null},[se,Jn]),Ii=t.useRef({id:null,triggerMs:null}),Ti=t.useRef(null);t.useEffect(function(){var n;if(null==se?void 0:se.id){var t=Number(se.trigger),i=Ii.current;if((null==i?void 0:i.triggerMs)!==t){if(!(se.id.includes(":")&&/:\d+$/.test(se.id)))return Ii.current={id:se.id,triggerMs:t},void Lt(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";Ti.current!==se.id&&(Nn(),Fn(),At(),ze(new Set),Ye([]),nn.current=[],Ti.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(){Ii.current={id:se.id,triggerMs:t}},h=null,x=null;for(var m in Jn){var _=Jn[m].find(function(e){return e.id===r});if(_){h=m,x=_;break}}if(x&&h){var R=Un.findIndex(function(e){return e.id===h}),y=Xn.findIndex(function(e){return e.id===h}),b=-1===R&&-1!==y,S=f(Un,x.id),A=f(Xn,x.id);if(S&&!A&&!b){var E=S.split("-"),I=Number(E[0]);if(he){var T=null===(i=null===(n=Un[I])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],B=Xn.findIndex(function(e){return e.selfIndex===T});-1!==B&&(I=B)}A=e.__spreadArray([I],E.slice(1),!0).join("-")}if(S||A){var C=b||!S&&!!A,D=S?Number(S.split("-")[0]):R,O=A?Number(A.split("-")[0]):y;if(C){if(!(he?!!Bt["right-".concat(O)]:!!Bt[String(O)])&&O>=0)return wt(O,"right"),s+=1,void(d=setTimeout(g,450))}else if(!(he?!!Bt["left-".concat(D)]:!!Bt[String(D)])&&D>=0)return wt(D,"left"),s+=1,void(d=setTimeout(g,450));var w,N=S||"",j=A||"",P="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(N).concat(u.DEVIATION_BADGE_SEPARATOR).concat(j),F="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c),k=null===(o=ut.current[F])||void 0===o?void 0:o.current,M=null===(l=ct.current[F])||void 0===l?void 0:l.current,L=C||!k&&!!M,V=L?M:k;if(w=he?L?gn.current:_n.current:vn.current,V&&w){var H=V.getBoundingClientRect();if(0===H.height)return void((s+=1)<2?d=setTimeout(g,v):p());var q=w.getBoundingClientRect(),G=H.top-q.top+w.scrollTop-q.height/2+H.height/2+150,z=function(){var n,t,i,o,r;if(!a){p();var l=V instanceof Element?window.getComputedStyle(V).color:"";k&&(k.style.transition="box-shadow 300ms ease-in-out",k.style.boxShadow="0 0 10px ".concat(l)),M&&(M.style.transition="box-shadow 300ms ease-in-out",M.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){k&&(k.style.boxShadow=""),M&&(M.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(!(!!k&&!!M)){var d=L?(null===(o=ct.current[F])||void 0===o?void 0:o.current)||M:(null===(r=ut.current[F])||void 0===r?void 0:r.current)||k;return Si(d,function(){wn({open:!0,anchorEl:d,displayImpact:se.displayImpact,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})})}),void(null==de||de())}hi(P,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t,i=L?(null===(n=ct.current[F])||void 0===n?void 0:n.current)||M:(null===(t=ut.current[F])||void 0===t?void 0:t.current)||k;Si(i,function(){wn({open:!0,anchorEl:i,displayImpact:null==se?void 0:se.displayImpact,summary:e.__assign({},u)})})}})}};Math.abs(w.scrollTop-G)<=2?z():(yn.current=G,bn.current=z,w.scrollTo({top:G,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(bn.current){yn.current=null;var e=bn.current;bn.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}else(s+=1)<2?d=setTimeout(g,v):p()}};return d=setTimeout(g,v),function(){a=!0,d&&clearTimeout(d)}}}},[se,Jn,Un,Xn,he,Bt,wt,hi,wn,Lt]);var Bi=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,s=e.sectionOffset;return n.jsx(y.default,{section:t,keyPath:i,depth:r,columnKey:u,parentNodeId:a,expandedSubSections:Dt,setExpandedSubSections:Ot,maintainRelativeOrder:he||!1,proposedSections:Un,existingSections:Xn,treeData:Z,deviationNumberRegistry:Qn,connectedSections:Ge,activeSideBySideSection:Le,resolvedMarkdownStyles:dn,getSubSectionRef:gt,getSubSectionCompareStyle:ni,getBadgeRef:pt,openMoreFunctionsPopup:Pt,openSummaryPopup:Ai,showDeviationBadges:me,resetSideBySide:At,setConnectedSections:ze,setConnectedLines:Ye,cachedConnectedPositions:nn,isProposingFix:fe,proposingFixNodeId:ge,sectionOffset:s})};return n.jsxs(i.Box,e.__assign({ref:fn,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},he?{}:{overflow:"visible"}),{position:"relative"})},{children:[Re&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),On.open&&n.jsx(b.default,{open:On.open,anchorEl:On.anchorEl,containerEl:qt.current,clipTopEl:Wt.current,scrollContainerEl:vn.current,onClose:mi,summary:On.summary,displayImpact:On.displayImpact}),n.jsx(d.default,{open:In.open,anchorEl:In.anchorEl,sectionTitle:In.sectionTitle,referenceSectionTitle:In.refSectionTitle,onClose:kn,onOpenCognitiveCompare:Ft,onOpenSideBySide:xi,onConnect:kt,isConnected:_i,isOrphan:In.isOrphan}),An.open&&n.jsx(s.default,{open:An.open,popupRef:Pn,position:Bn,popupConfig:ue,onClose:function(){Cn(null),En(function(n){return e.__assign(e.__assign({},n),{open:!1})}),jn(null)},markdownStyles:ie,sectionTitle:An.sectionTitle,referenceSectionTitle:An.refSectionTitle,cognitiveData:An.cognitiveData,anchorEl:An.anchorEl,sectionAnchorEl:An.sectionAnchorEl,scrollContainerEl:vn.current,badgeStyle:An.badgeStyle,docData:An.docData,deviationData:An.deviationData,isLoading:An.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!Ie,autoHideDuration:8e3,onClose:function(){return Te(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Te(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Ie}))})),n.jsx(_.default,{componentHeaderText:Q,displayConfig:le,maintainRelativeOrder:he,onCollapseAll:ii,showCollapseAll:oi,onToggleView:function(e){ye(!0),setTimeout(function(){xe(!e),At(),Nn(),ze(new Set),Ye([]),nn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){ye(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:vn,onScroll:di,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:xt&&mt?"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:Ht,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},he?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Ue,style:{position:"absolute",top:0,left:0,width:an.width||"100%",height:an.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Fe?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Jt&&n.jsx("g",{children:n.jsx("line",{x1:Jt.x1,y1:Jt.y,x2:Jt.x2,y2:Jt.y,stroke:bt.badgeBorder,strokeWidth:"1.5"})}),Ut.map(function(t){var l,c,s,d,v,g,p,h=t.x1+.5*(t.x2-t.x1),x=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?Ce&&Le===t.subSectionKeyPath&&Ne:Ce&&Le===t.sectionIdx&&Ne)return null;if(!he){var m=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),_=Un[t.sectionIdx]||{title:"",content:""},R=Xn[null!==(l=t.targetRightIdx)&&void 0!==l?l:t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",_,R),t.isSubSection&&t.subSectionKeyPath){var y=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],b=y[2]||t.subSectionKeyPath,S=y[3]||b,A=b.split("-").map(Number),E=S.split("-").map(Number),I=null,T=null;A.length>0&&(I=Un[A[0]]),E.length>0&&(T=Xn[E[0]]);var B=(null==I?void 0:I.title)||"",C=(null==T?void 0:T.title)||"";console.log("Root Parent Titles:",B,C);for(var D=1;D<A.length;D++)(null==I?void 0:I.subsections)&&(I=I.subsections[A[D]]);for(D=1;D<E.length;D++)(null==T?void 0:T.subsections)&&(T=T.subsections[E[D]]);I&&(_=e.__assign(e.__assign({},I),{title:B||I.title})),console.log("Base Section for Subsection Badge:",_),T&&(R=e.__assign(e.__assign({},T),{title:C||T.title})),console.log("Ref Section for Subsection Badge:",R)}var O=!(null===(c=_.cognitiveData)||void 0===c?void 0:c.isMissingRationale)||Boolean(null===(d=null===(s=_.cognitiveData)||void 0===s?void 0:s.decisioning)||void 0===d?void 0:d.length),w=(null===(p=null===(g=null===(v=_.evaluationResult)||void 0===v?void 0:v.cognitive_decisioning)||void 0===g?void 0:g.decisioning_factors)||void 0===p?void 0:p.length)||!1,N=O||w;return n.jsxs("g",{children:[n.jsx("path",{d:m,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:h-100,y:x-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(),N&&(An.open&&Dn===t.id?Fn():(jn(t.id),jt(Nt(e.currentTarget,_,R,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:N?"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,{})})),N&&n.jsx(o.ChevronDown,{size:11,style:{transform:An.open&&Dn===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),n.jsx(S.default,{connectedLines:Ke,pathRefs:en})]})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},he?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Wt,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:di,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},he?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:xn,style:{width:"100%",height:"0px",flexShrink:0}}),et&&Un.map(function(t,r){var l,c,a=!t.title&&!t.content;if(he&&a)return null;var s=t,d=ei(r,"left"),v=he?!(null===(l=s.refIndexes)||void 0===l?void 0:l.length)||s.selfIndex<0:!Xn[r],g=Ge.has(r),p=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel),h=nt.leftNums.get(s.id);return n.jsx(i.Box,e.__assign({ref:ft(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:rt.current[r],sx:e.__assign({width:"100%",display:"flex",flexDirection:"column",minWidth:0},g&&{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:ft("left-accordion-".concat(r)),mb:0,treeData:Z,proposedSections:Un,existingSections:Xn,deviationNumberRegistry:Qn,getSectionCompareStyle:ei,getBadgeRef:pt,connectedSections:Ge,openMoreFunctionsPopup:Pt,openSummaryPopup:Ai,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Ei,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:he?!!Bt["left-".concat(r)]:!!Bt[String(r)],onToggle:function(){mi(),wt(r,"left")},navigation:t.id?yi[t.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:dn,maintainRelativeOrder:he,showDeviationBadges:me,renderSubSections:Bi,isProposingFix:fe,proposingFixNodeId:ge,collisionKey:"".concat(Ce?"1":"0","-").concat(String(null!=Le?Le:""))})})),he&&d&&n.jsxs(i.Box,e.__assign({ref:ut.current[r],onClick:function(e){var n,t,i,o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=s.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=s.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ai(e,String(r),v,o)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.3,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;Ai(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!=h&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:h})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!le.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p):n.jsx(f.default,{color:d.badgeText})}))]})),n.jsx(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=he?Xn.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:Xn[r]||{title:"",content:""};Pt(e,t,v,n,r,d)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(d.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:d.badgeText})}))]}))]}))}),"left-row-".concat(r))}),n.jsx("div",{ref:mn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:qt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:n.jsx(i.Box,e.__assign({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:n.jsxs(i.Box,e.__assign({onClick:function(n){n.stopPropagation(),An.open&&Dn===_t?Fn():(jn(_t),jt(Nt(n.currentTarget,{title:"",content:"",evaluationResult:Rt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,_t,!0,e.__assign(e.__assign({},bt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:bt.badgeBg,color:bt.badgeText,border:"1px solid ".concat(bt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=yt?yt:n.jsx(f.default,{}),n.jsx(i.Box,e.__assign({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:n.jsx(r.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:An.open&&Dn===_t?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),n.jsxs(i.Box,e.__assign({sx:e.__assign({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},he?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Se&&n.jsx(l.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Kt,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:n.jsx(i.Tooltip,e.__assign({title:zn,placement:"top"},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:zn}))}))})),n.jsxs(i.Box,e.__assign({ref:gn,onScroll:di,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},he?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:pn,style:{width:"100%",height:"0px",flexShrink:0}}),et&&Xn.map(function(t,r){var l,u,c=t,a=!1,s=null,d=-1;if(he){d=Un.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex))&&e.selfIndex>=0});var v=Un.findIndex(function(e,n){var t;return Ge.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c.selfIndex))});(a=-1!==v)&&(s=ei(v))}else(a=Ge.has(r))&&(s=ei(r));var g=ei(he&&-1!==d?d:r),p=he?-1!==d||!(null===(l=c.refIndexes)||void 0===l?void 0:l.length)&&Un.some(function(e){return e.id&&e.id===c.id}):Boolean(Un[r]),h=he?c.selfIndex<0||!p:!Un[r],x=nt.rightNums.get(c.id);return n.jsx(i.Box,e.__assign({ref:at.current[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:lt.current[r],sx:e.__assign({width:"100%",display:"flex"},a&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:r,columnKey:"right",colRef:ft("right-accordion-".concat(r)),mb:0,parentNodeId:(null===(u=null==Z?void 0:Z.input_index_map)||void 0===u?void 0:u[1])||"",isExpanded:he?!!Bt["right-".concat(r)]:!!Bt[String(r)],treeData:Z,proposedSections:Un,existingSections:Xn,deviationNumberRegistry:Qn,getBadgeRef:pt,getSectionCompareStyle:ei,connectedSections:Ge,openMoreFunctionsPopup:Pt,openSummaryPopup:Ai,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Ei,onToggle:function(){mi(),wt(r,"right")},navigation:t.id?yi[t.id]:null,showOpenNodeRef:bi,resolvedMarkdownStyles:dn,maintainRelativeOrder:he,showDeviationBadges:me,renderSubSections:Bi,isProposingFix:fe,proposingFixNodeId:ge,collisionKey:"".concat(Ce?"1":"0","-").concat(String(null!=Le?Le:""))})})),he&&g&&n.jsx(i.Box,e.__assign({ref:ct.current[r],"data-section-id":c.id,onClick:function(e){var n,t,i;if(h){var o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=c.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ai(e,String(r),h,o)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:h?"4px":"0px",fontSize:"11px",bgcolor:h?"#F1D2D2":g.badgeBg,color:h?"#B91C1C":g.badgeText,border:h?"1px solid #DC8E8E":"1px solid ".concat(g.badgeBorder),borderRadius:h?"12px":"10px",px:h?1.2:1,py:.3,fontWeight:h?600:700,cursor:h?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:h?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:h?n.jsxs(n.Fragment,{children:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,t,i;e.stopPropagation();var o=le.enableDeviationSchemaBackwardCompatibility?null!==(n=c.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ai(e,String(r),h,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:h?"1px solid #DC8E8E":"1px solid ".concat(g.badgeBorder),"&:hover":{bgcolor:h?"#F1D2D2":"".concat(g.badgeBorder,"22")}}},{children:[null!=x&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:h?"1px solid #DC8E8E":"1px solid ".concat(g.badgeBorder)}},{children:x})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!le.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?"100% Deviation":n.jsx(f.default,{color:h?"#B91C1C":g.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=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)})||{title:"",content:""}:Un[r]||{title:"",content:""};Pt(e,n,h,c,r,g)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(g.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:h?"#B91C1C":g.badgeText})}))]}):null!=x?x:""}))]}))}),"right-row-".concat(r))}),n.jsx("div",{ref:hn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material"),o=require("lucide-react"),l=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),u=require("./CognitiveComparehelpers.js"),c=require("./CognitiveCompareConfig.js"),a=require("./CognitiveCompareConstants.js"),s=require("./CognitivePopup.js"),d=require("./MoreFunctionsPopup.js"),v=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),g=require("./hooks/useCompareData.js"),p=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),x=require("./hooks/useAccordionState.js"),m=require("./hooks/useDeviationNavigation.js"),_=require("./components/CompareHeader.js"),R=require("./components/SectionAccordion.js"),y=require("./components/SubSectionAccordion.js"),b=require("./components/CognitiveSummaryPopup.js"),S=require("./components/connectedLines.js");exports.SHARED_MARKDOWN_STYLES=c.SHARED_MARKDOWN_STYLES,exports.default=function(A){var I,E,T,B,C,D,O,w,N,j,P,F,M,k,L,V,H,q,G,z,W,K,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,le=A.displayConfig,re=void 0===le?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:le,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=A.isRedlineFlow,he=t.useState(re.maintainRelativeOrder),xe=he[0],me=he[1],_e=!!xe||!!(null==re?void 0:re.showDeviationBadges),Re=t.useState(!1),ye=Re[0],be=Re[1],Se=t.useState(!1),Ae=Se[0],Ie=Se[1],Ee=t.useState(null),Te=Ee[0],Be=Ee[1],Ce=t.useState(!1),De=Ce[0],Oe=Ce[1],we=t.useState(null===(E=null!==(I=null==Z?void 0:Z.newEvaluationResult)&&void 0!==I?I:null==re?void 0:re.enableDeviationSchemaBackwardCompatibility)||void 0===E||E)[0],Ne=t.useState(!1),je=Ne[0],Pe=Ne[1],Fe=t.useState(!1),Me=Fe[0],ke=Fe[1],Le=t.useState(null),Ve=Le[0],He=Le[1],qe=t.useRef(!1),Ge=t.useState(new Set),ze=Ge[0],We=Ge[1],Ke=t.useState([]),Ye=Ke[0],Ue=Ke[1],Xe=t.useRef(null),$e=t.useRef(null),Je=t.useRef(null),Qe=t.useRef(new Set),Ze=t.useRef(!1),en=t.useRef(null),nn=t.useRef({}),tn=t.useRef([]),on=t.useRef(!1),ln=t.useRef(!1),rn=t.useRef(null),un=t.useRef(function(){}),cn=t.useMemo(function(){return(null==Z?void 0:Z.cognitive_decisioning)||{}},[Z]),an=t.useState({width:0,height:0}),sn=an[0],dn=an[1],vn=t.useMemo(function(){return e.__assign(e.__assign({},c.SHARED_MARKDOWN_STYLES),ie)},[ie]),fn=t.useRef(null),gn=t.useRef(null),pn=t.useRef(null),hn=t.useRef(null),xn=t.useRef(null),mn=t.useRef(null),_n=t.useRef(null),Rn=t.useRef(null),yn=t.useRef(!1),bn=t.useRef(null),Sn=t.useRef(null),An=p.useComparePopups(fn),In=An.cognitivePopup,En=An.setCognitivePopup,Tn=An.moreFunctions,Bn=An.setMoreFunctions,Cn=An.position,Dn=An.setPosition,On=An.activeBadgeId,wn=An.summaryPopup,Nn=An.setSummaryPopup,jn=An.closeSummaryPopup,Pn=An.setActiveBadgeId,Fn=An.popupRef,Mn=An.closeCognitivePopup,kn=An.closeMoreFunctionsPopup,Ln=t.useMemo(function(){var e,n,t,i,o,l,r;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!==(r=null===(l=null==ee?void 0:ee.thresholds)||void 0===l?void 0:l.exact)&&void 0!==r?r:c.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}},[ee]),Vn=t.useState(null),Hn=Vn[0];Vn[1];var qn=null===(C=null===(T=null==Z?void 0:Z.documents)||void 0===T?void 0:T[null===(B=null==Z?void 0:Z.input_index_map)||void 0===B?void 0:B[0]])||void 0===C?void 0:C.title,Gn=null===(w=null===(D=null==Z?void 0:Z.documents)||void 0===D?void 0:D[null===(O=null==Z?void 0:Z.input_index_map)||void 0===O?void 0:O[1]])||void 0===w?void 0:w.title,zn=u.safeStringify(ne||qn||"Uploaded Contract"),Wn=u.safeStringify(te||Gn||"Reference Template"),Kn=g.useCognitiveTreeData(Z,xe,ae,Ln,we),Yn=Kn.activeProposed,Un=Kn.existingRule,Xn=Kn.proposedSections,$n=Kn.existingSections,Jn=Kn.visibleFields,Qn=Kn.parentDeviationRecord,Zn=Kn.deviationNumberRegistry,et=Kn.parseError;t.useEffect(function(){et&&Be("Failed to load comparison: ".concat(et))},[et]);var nt=Xn.length>0||$n.length>0,tt=t.useMemo(function(){if(!pe)return"off";var e=0,n=0,t=function(i){Array.isArray(i)&&i.forEach(function(i){var o,l=(null==i?void 0:i.content)||"";u.hasMeaningfulRedlineTags(l)&&(e+=1,n+=String(l).length),(null===(o=null==i?void 0:i.subsections)||void 0===o?void 0:o.length)&&t(i.subsections)})};return t(Xn),t($n),"".concat(e,":").concat(n)},[pe,Xn,$n]);t.useEffect(function(){pe&&"off"!==tt&&"0:0"!==tt&&($e.current=null,tn.current=[],requestAnimationFrame(function(){var e;null===(e=un.current)||void 0===e||e.call(un)}))},[pe,tt]);var it=t.useMemo(function(){var e=new Map,n=new Map,t=1;if(xe)Xn.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,t++)}),$n.forEach(function(i){if(i.id){var o=Xn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(i.selfIndex)});if(o.length>0){var l=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(i.id,l.join(", "))}else n.set(i.id,String(t++))}});else for(var i=Math.max(Xn.length,$n.length),o=0;o<i;o++){var l=Xn[o],r=$n[o];l?(e.set(l.id,t),r&&n.set(r.id,String(t)),t++):r&&n.set(r.id,String(t++))}return{leftNums:e,rightNums:n}},[Xn,$n,xe]),ot=h.useSectionRefs(Jn.map(function(e){return e.key}),Math.max(Xn.length,$n.length)),lt=ot.leftRefs,rt=ot.rightRefs,ut=ot.sectionLeftRefs,ct=ot.sectionRightRefs,at=ot.lhsBadgeRefs,st=ot.rhsBadgeRefs,dt=ot.sectionRightRowRefs,vt=ot.subSectionLeftRefs,ft=ot.subSectionRightRefs,gt=ot.sectionRowRefs,pt=ot.getSectionRowRef,ht=ot.getSubSectionRef,xt=ot.getBadgeRef,mt=Un.analysis,_t=u.safeStringify(null===(j=null===(N=null==mt?void 0:mt.rule_difference_comparison)||void 0===N?void 0:N.summary)||void 0===j?void 0:j.overall_summary),Rt=!!_t.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),yt=null!==(P=null==Z?void 0:Z.base_root_id)&&void 0!==P?P:"-1";null==Z||Z[yt];var bt=we?null!==(Y=null!==(z=ae&&(null===(G=null==ae?void 0:ae[yt])||void 0===G?void 0:G.evaluation_result))&&void 0!==z?z:null===(K=null===(W=null==Z?void 0:Z.nodes)||void 0===W?void 0:W[yt])||void 0===K?void 0:K.evaluation_result)&&void 0!==Y?Y:null:null!==(q=null!==(k=ae&&(null===(M=null===(F=null==ae?void 0:ae[yt])||void 0===F?void 0:F.evaluation_result)||void 0===M?void 0:M[0]))&&void 0!==k?k:null===(H=null===(V=null===(L=null==Z?void 0:Z.nodes)||void 0===L?void 0:L[yt])||void 0===V?void 0:V.evaluation_result)||void 0===H?void 0:H[0])&&void 0!==q?q:null,St=u.extractDeviationScore(bt),At=u.generateColorPalette(null!==($=null===(X=null===(U=null==bt?void 0:bt.evaluation_outputs)||void 0===U?void 0:U.metadata)||void 0===X?void 0:X.label_color)&&void 0!==$?$:""),It=function(){Qe.current.forEach(function(e){u.resetClauseHighlight(e)}),Qe.current.clear()},Et=t.useCallback(function(){var e,n,t,i,o,l;It(),Oe(!1),ln.current=!1,$e.current=null;var r=rn.current,c=Wt.current;if(null!==r)if("string"==typeof r&&r.includes(u.DEVIATION_BADGE_SEPARATOR)){var a=r.split(u.DEVIATION_BADGE_SEPARATOR);(s=(null===(e=vt.current[a[2]])||void 0===e?void 0:e.current)||(null===(n=ut.current[Number(a[2])])||void 0===n?void 0:n.current))&&(s.style.paddingTop="0px")}else{var s;(s=null===(t=ut.current[r])||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=ft.current[a[3]])||void 0===i?void 0:i.current)||(null===(o=ct.current[Number(a[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(l=ct.current[c])||void 0===l?void 0:l.current)&&(d.style.paddingTop="0px")}He(null),rn.current=null,Wt.current=null,Pe(!1),Ie(!1),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px")},[]),Tt=t.useCallback(function(){It(),Et(),We(new Set),Ue([]),tn.current=[],Jt([]),ei(null),Nn(a.EMPTY_SUMMARY_POPUP_STATE),Mn(),requestAnimationFrame(function(){var e;null===(e=un.current)||void 0===e||e.call(un)})},[]),Bt=t.useRef(Tt);t.useEffect(function(){Bt.current=Tt},[Tt]),t.useEffect(function(){oe&&Bt.current()},[oe]);var Ct=x.useAccordionState({maintainRelativeOrder:!!xe,proposedSections:Xn,existingSections:$n,activeSideBySideSection:Ve,connectedSections:ze,resetSideBySide:Et,setConnectedSections:We,setConnectedLines:Ue,cachedConnectedPositions:tn,svgContainerRef:Xe,isAnimatingRef:Ze,animationTimerRef:en,calculateLinesRef:un,sectionLeftRefs:ut,sectionRightRefs:ct,subSectionLeftRefs:vt,subSectionRightRefs:ft}),Dt=Ct.expandedSections,Ot=Ct.setExpandedSections,wt=Ct.expandedSubSections,Nt=Ct.setExpandedSubSections,jt=Ct.toggleSection,Pt=t.useCallback(function(n,t,i,o,l,r,c){var a,s,d,v=u.safeStringify(null==t?void 0:t.id)||u.safeStringify(null==i?void 0:i.id)||"",f=(v?cn[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=gt.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==re?void 0:re.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",refSectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",cognitiveData:f,anchorEl:n,sectionAnchorEl:g,badgeStyle:r||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,l,r=(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 l=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(l&&o[l])return o[l]}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(r);var a=o.split(u.DEVIATION_BADGE_SEPARATOR)[1];if(!a)return r;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===(l=null==s?void 0:s.deviations)||void 0===l?void 0:l[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(r)}(),isOrphan:!!l}},[cn,Z]),Ft=t.useCallback(function(e){kn(),Dn(null),En(e)},[kn]),Mt=function(e,n,t,i,o,l){var r;if(e.stopPropagation(),Tn.open&&Tn.sectionIdx===o)kn();else{var c=e.currentTarget,a="left";(null===(r=pn.current)||void 0===r?void 0:r.contains(c))&&(a="right");It(),ln.current&&Et(),We(new Set),Ue([]),tn.current=[],Mn(),wn.open?Ri():jn(),requestAnimationFrame(function(){var e=function(){var e,n,t,i;if("string"==typeof o&&o.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=o.split(u.DEVIATION_BADGE_SEPARATOR),r="".concat(l[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l[1]);return"right"===a?null===(e=st.current[r])||void 0===e?void 0:e.current:null===(n=at.current[r])||void 0===n?void 0:n.current}return"right"===a?null===(t=st.current[o])||void 0===t?void 0:t.current:null===(i=at.current[o])||void 0===i?void 0:i.current}()||c;Bn(Pt(e,n,i,o,t,l))})}},kt=t.useCallback(function(){null!==Tn.sectionIdx&&Tn.anchorEl?Ft(e.__assign(e.__assign({},Tn),{open:!0})):kn()},[Tn,kn,Ft]),Lt=t.useCallback(function(){var e=Tn.sectionIdx,n=Tn.isOrphan;kn(),jn(),null!==e&&(n?Be("No counterpart exists to connect to."):(It(),ln.current&&Et(),Ue([]),tn.current=[],We(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){un.current&&un.current()},50)))},[Tn.sectionIdx,Tn.isOrphan,kn,jn,Et]),Vt=t.useCallback(function(){var e=Je.current;if(e){Je.current=null;var n=Xn.findIndex(function(n){return n.id===e}),t=$n.findIndex(function(n){return n.id===e}),i=-1===n?u.findKeyPathByNodeId(Xn,e):null,o=-1===t?u.findKeyPathByNodeId($n,e):null,l=-1!==n?n:i?Number(i.split("-")[0]):-1,r=-1!==t?t:o?Number(o.split("-")[0]):-1,c=function(e,n,t,i){var o,l,r,u;return-1!==e?null!==(l=null===(o=t.current[e])||void 0===o?void 0:o.current)&&void 0!==l?l:null:n&&null!==(u=null===(r=i.current[n])||void 0===r?void 0:r.current)&&void 0!==u?u:null},a=function(e,n,t){void 0===t&&(t=30);var i=0,o=function(){var l=e();l&&0!==l.getBoundingClientRect().height?(Qe.current.add(l),u.scrollAndHighlightClause(l,n)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(xe)-1!==l&&Rn.current&&a(function(){return c(n,i,ut,vt)},Rn.current),-1!==r&&pn.current&&a(function(){return c(t,o,ct,ft)},pn.current);else{var s=fn.current;if(!s)return;a(function(){return-1!==l?c(n,i,ut,vt):c(t,o,ct,ft)},s)}}},[Xn,$n,xe,ut,ct,vt,ft,Rn,pn,fn]),Ht=t.useCallback(function(n){if(n){It(),Et(),We(new Set),Ue([]),tn.current=[],jn(),Mn();var t=Xn.findIndex(function(e){return e.id===n}),i=$n.findIndex(function(e){return e.id===n}),o=-1===t?u.findKeyPathByNodeId(Xn,n):null,l=-1===i?u.findKeyPathByNodeId($n,n):null;if(-1!==t||o||-1!==i||l){var r=-1!==t?t:o?Number(o.split("-")[0]):-1,c=-1!==i?i:l?Number(l.split("-")[0]):-1;Je.current=n,Ot(function(n){var t,i=e.__assign({},n),o=!1;-1!==r&&(i[t=xe?"left-".concat(r):String(r)]||(i[t]=!0,o=!0));-1!==c&&(i[t=xe?"right-".concat(c):String(c)]||(i[t]=!0,o=!0));return o?i:n}),Nt(function(n){var t=e.__assign({},n),i=!1,r=function(e){for(var n=e.split("-"),o=n[0],l=1;l<n.length;l++)o+="-".concat(n[l]),t[o]||(t[o]=!0,i=!0)};return o&&r(o),l&&r(l),i?t:n}),setTimeout(function(){requestAnimationFrame(function(){Je.current===n&&qt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Xn,$n,xe,Ot,Nt,Et,jn,Mn]),qt=t.useRef(Vt);t.useEffect(function(){qt.current=Vt},[Vt]);var Gt=t.useRef(null),zt=t.useRef(null),Wt=t.useRef(null),Kt=t.useRef(null),Yt=t.useRef(null),Ut=t.useRef(null),Xt=t.useState([]),$t=Xt[0],Jt=Xt[1];t.useRef(null);var Qt=t.useState(null),Zt=Qt[0],ei=Qt[1];t.useEffect(function(){if(Hn){var e=Ln.fields.find(function(e){return e.analysisKey===Hn||e.key===Hn});if(e){var n=lt.current[e.key]||rt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Hn,Ln.fields]);var ni=t.useCallback(function(e){var n,t,i,o,l,r,u,c,a,s=null===(n=null==mt?void 0:mt.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===(l=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===l?void 0:l.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===(r=f.highlights)||void 0===r?void 0:r.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}},[mt]),ti=t.useCallback(function(n,t){var i,o,l;void 0===t&&(t="left");var r=null,c=null;if("left"===t)if(r=Xn[n],xe&&r){var s=$n.filter(function(e){var n;return null===(n=r.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)});c=s.find(function(e){return e.evaluationResult})||s[0]}else c=$n[n];else if(c=$n[n],xe&&c){var d=Xn.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)});r=d.find(function(e){return e.evaluationResult})||d[0]}else r=Xn[n];var v=(null==r?void 0:r.relation)&&"not_defined"!==r.relation,f=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,g=!(!(null==r?void 0:r.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==r?void 0:r.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!==(l=h)&&void 0!==l?l:""}):e.__assign(e.__assign({},u.generateColorPalette(x)),{label:null})},[Xn,$n,cn,Ln,xe]),ii=t.useCallback(function(n){for(var t,i,o,l,r,c=n.split("-").map(Number),s=Xn[c[0]],d=$n[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=cn[p])||void 0===o||o.relevance_score);var x=null!==(r=null!==(l=null==s?void 0:s.evaluationResult)&&void 0!==l?l:null==d?void 0:d.evaluationResult)&&void 0!==r?r:null,m=u.getFirstDeviationOutputValue(x),_=u.getFirstDeviationColor(x);return null!=x?e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null!=m?m:""}):e.__assign(e.__assign({},u.generateColorPalette(_)),{label:null})},[Xn,$n,cn,Ln]),oi=t.useCallback(function(n,t){var i,o,l,r,c,s,d,v,f,g,p,h,x,m,_,R,y;if(!n||null==t)return null;var b=null!==(d=null!==(c=null!==(o=null===(i=null==ae?void 0:ae[n])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(r=null===(l=null==Z?void 0:Z.nodes)||void 0===l?void 0:l[n])||void 0===r?void 0:r.evaluation_result)&&void 0!==c?c:null===(s=null==Z?void 0:Z[n])||void 0===s?void 0:s.evaluation_result)&&void 0!==d?d:null;if(!b||"object"!=typeof b)return null;var S=null!==(p=null!==(f=null===(v=null==b?void 0:b.deviations)||void 0===v?void 0:v[t])&&void 0!==f?f:null===(g=null==b?void 0:b.deviation_entries)||void 0===g?void 0:g[t])&&void 0!==p?p:null==b?void 0:b[t],A=null!==(y=null!==(m=null===(x=null===(h=null==S?void 0:S.evaluation_outputs)||void 0===h?void 0:h.metadata)||void 0===x?void 0:x.label_color)&&void 0!==m?m:null===(R=null===(_=null==b?void 0:b.evaluation_outputs)||void 0===_?void 0:_.metadata)||void 0===R?void 0:R.label_color)&&void 0!==y?y:a.DEFAULT_DEVIAION_COLOR;return e.__assign(e.__assign({},u.generateColorPalette(A)),{label:null})},[ae,Z]),li=t.useCallback(function(){It(),Ot({}),Nt({}),Et(),We(new Set),Ue([]),tn.current=[],jn(),Mn(),kn(),requestAnimationFrame(function(){un.current&&un.current()})},[Ot,Nt,Et,jn,Mn,kn]),ri=t.useMemo(function(){return Object.values(Dt).some(Boolean)||Object.values(wt).some(Boolean)},[Dt,wt]),ui=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,f,g,p,h,x,m,_,R,y,b,S;if(!yn.current&&!Ze.current){yn.current=!0;try{if(!Gt.current)return;var A=function(e){var n=e.split("-"),t=n[0];if(!Dt[t]&&!1===xe)return!1;if(xe&&!Dt["left-".concat(t)]&&!Dt["right-".concat(t)]&&!Dt[t])return!1;for(var i=t,o=1;o<n.length-1;o++)if(i+="-".concat(n[o]),!wt[i])return!1;return!0},I=Gt.current.getBoundingClientRect();dn({width:I.width,height:I.height});var E=[];if(Jn.forEach(function(e){var n,t,i=e.key,o=null===(n=lt.current[i])||void 0===n?void 0:n.current,l=null===(t=rt.current[i])||void 0===t?void 0:t.current;o&&l&&(o.style.height="auto",l.style.height="auto",o.style.minHeight="0px",l.style.minHeight="0px")}),!Ze.current){for(var T=0;T<Math.max(Xn.length,$n.length);T++){var B=null===(e=ut.current[T])||void 0===e?void 0:e.current,C=null===(n=ct.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")}xe||Object.keys(vt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=vt.current[e])||void 0===n?void 0:n.current,o=null===(t=ft.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={};Jn.forEach(function(e){var n,t,i=e.key,o=null===(n=lt.current[i])||void 0===n?void 0:n.current,l=null===(t=rt.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),u=l.getBoundingClientRect();D[i]=Math.max(r.height,u.height)}});var O={left:{},right:{}},w={};if(!Ze.current)if(xe){if(De&&null!==Ve)if("number"==typeof Ve){var N=Ve,j=Xn[N],P=null===(o=ut.current[N])||void 0===o?void 0:o.current;P&&j&&(j.refIndexes||[]).forEach(function(e){var n,t=$n.findIndex(function(n){return n.selfIndex===e}),i=null===(n=ct.current[t])||void 0===n?void 0:n.current;if(i&&(Dt["left-".concat(N)]||Dt["right-".concat(t)])){var o=Math.max(P.getBoundingClientRect().height,i.getBoundingClientRect().height);O.left[N]=Math.max(O.left[N]||0,o),O.right[t]=Math.max(O.right[t]||0,o)}})}else{var F=Ve.split(u.DEVIATION_BADGE_SEPARATOR)[2];if(F){B=null===(l=vt.current[F])||void 0===l?void 0:l.current,C=null===(r=ft.current[F])||void 0===r?void 0:r.current;if(B&&C){M=Math.max(B.getBoundingClientRect().height,C.getBoundingClientRect().height);w[F]=Math.max(w[F]||0,M)}}}}else{Object.keys(vt.current).forEach(function(e){var n,t;if(A(e)){var i=null===(n=vt.current[e])||void 0===n?void 0:n.current,o=null===(t=ft.current[e])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var l=i.getBoundingClientRect(),r=o.getBoundingClientRect(),u=Math.max(l.height,r.height);w[e]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(T=0;T<Math.min(Xn.length,$n.length);T++){var B=null===(t=ut.current[T])||void 0===t?void 0:t.current,C=null===(i=ct.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(Jn.forEach(function(e){var n,t,i=e.key,o=null===(n=lt.current[i])||void 0===n?void 0:n.current,l=null===(t=rt.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=D[i];o.style.minHeight="".concat(r,"px"),l.style.minHeight="".concat(r,"px")}}),Ze.current||(Object.entries(O.left).forEach(function(e){var n,t=e[0],i=e[1],o=null===(n=ut.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=ct.current[Number(t)])||void 0===n?void 0:n.current;o&&(o.style.minHeight="".concat(i,"px"))}),xe||Object.keys(w).forEach(function(e){var n,t,i=null===(n=vt.current[e])||void 0===n?void 0:n.current,o=null===(t=ft.current[e])||void 0===t?void 0:t.current;if(i&&o&&w[e]){var l=w[e];i.style.minHeight="".concat(l,"px"),o.style.minHeight="".concat(l,"px")}})),xe)Xn.forEach(function(e,n){var t;(null===(t=ut.current[n])||void 0===t?void 0:t.current)&&(e.refIndexes||[]).forEach(function(e){var t,i,o,l,r,u,c,a,s,d,v=$n.findIndex(function(n){return n.selfIndex===e});if(-1!==v){var f=null===(t=at.current[n])||void 0===t?void 0:t.current,g=null===(i=st.current[v])||void 0===i?void 0:i.current;if(f&&g){var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=p.right-I.left,m=h.left-I.left,_=p.top+p.height/2-I.top,R=h.top+h.height/2-I.top;if(De&&Ve===n){var y=null!==(l=null===(o=Rn.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,b=null!==(u=null===(r=pn.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==u?u:0,S=y+(null!==(a=null===(c=Rn.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),A=b+(null!==(d=null===(s=pn.current)||void 0===s?void 0:s.clientHeight)&&void 0!==d?d:1/0),T=p.top+p.height/2,B=h.top+h.height/2,C=function(e,n,t){return Math.max(n,Math.min(t,e))};_=C(T,y,S)-I.top,R=C(B,b,A)-I.top}var D=ti(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(T=0;T<Math.min(Xn.length,$n.length);T++){var k=null===(c=ut.current[T])||void 0===c?void 0:c.current,L=null===(a=ct.current[T])||void 0===a?void 0:a.current;if(k&&L){var V=k.getBoundingClientRect(),H=L.getBoundingClientRect(),q=Math.max(V.top,H.top)+18-I.top,G=(null===(s=$n[T])||void 0===s?void 0:s.id)||"sec-".concat(T);(J=ti(T))&&E.push({id:G,x1:V.right-I.left,y1:q,x2:H.left-I.left,y2:q,style:J,sectionIdx:T,hasCognitive:!!((null===(d=Xn[T])||void 0===d?void 0:d.cognitiveData)||(null===(v=$n[T])||void 0===v?void 0:v.cognitiveData)||G&&cn[G]),isSubSection:!1})}}Object.keys(vt.current).forEach(function(e){var n,t,i,o,l,r;if(A(e)){var c=null===(n=vt.current[e])||void 0===n?void 0:n.current,a=null===(t=ft.current[e])||void 0===t?void 0:t.current;if(c&&a){for(var s=e.split("-").map(Number),d=Xn[s[0]],v=$n[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===(l=v.displayTitle)||void 0===l||l)&&u.hasValue(v.title)),x=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&u.hasValue(v.content));if(g&&p||h&&x){var m=c.getBoundingClientRect(),_=a.getBoundingClientRect(),R=Math.max(m.top,_.top)+16-I.top,y=ii(e);y&&"Not Defined"!==y.label&&E.push({id:"subsec-".concat(e),x1:m.right-I.left,y1:R,x2:_.left-I.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(De&&"string"==typeof Ve&&Ve.includes(u.DEVIATION_BADGE_SEPARATOR)){var z=Ve.split(u.DEVIATION_BADGE_SEPARATOR),W=z[0],K=z[1],Y=z[2],U=(z[3],"".concat(W).concat(u.DEVIATION_BADGE_SEPARATOR).concat(K)),X=null===(f=at.current[U])||void 0===f?void 0:f.current,$=null===(g=st.current[U])||void 0===g?void 0:g.current;if(X&&$){var J,Q=X.getBoundingClientRect(),Z=$.getBoundingClientRect(),ee=Q.right-I.left,ne=Z.left-I.left,te=Q.top+Q.height/2-I.top,ie=Z.top+Z.height/2-I.top;if(xe){var oe=null!==(h=null===(p=Rn.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==h?h:0,le=null!==(m=null===(x=pn.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==m?m:0,re=oe+(null!==(R=null===(_=Rn.current)||void 0===_?void 0:_.clientHeight)&&void 0!==R?R:1/0),ue=le+(null!==(b=null===(y=pn.current)||void 0===y?void 0:y.clientHeight)&&void 0!==b?b:1/0),ce=function(e,n,t){return Math.max(n,Math.min(t,e))};te=ce(Q.top+Q.height/2,oe,re)-I.top,ie=ce(Z.top+Z.height/2,le,ue)-I.top}(J=null!==(S=oi(W,K))&&void 0!==S?S:ii(Y))&&E.push({id:"line-subsec-".concat(U),x1:ee,y1:te,x2:ne,y2:ie,style:J,sectionIdx:Number(Y.split("-")[0]),isSubSection:!0,subSectionKeyPath:Ve})}}if(Jt(E),Yt.current&&Ut.current){var ae=Yt.current.getBoundingClientRect(),se=Ut.current.getBoundingClientRect(),de=(ae.top+ae.height/2-I.top+se.top+se.height/2-I.top)/2;ei({x1:ae.right-I.left,x2:se.left-I.left,y:de})}else ei(null);if(ze.size>0){var ve=[],fe=Rn.current,ge=pn.current;if(fe&&ge){var pe=[],he=fe.getBoundingClientRect().top,me=ge.getBoundingClientRect().top,_e=he+fe.clientHeight,Re=me+ge.clientHeight,ye=fe.scrollTop,be=ge.scrollTop,Se=I.top,Ae=function(e,n,t){return Math.max(n,Math.min(t,e))};ze.forEach(function(e){var n,t,i,o,l,r;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=at.current[v])||void 0===n?void 0:n.current,g=null===(t=st.current[v])||void 0===t?void 0:t.current;if(!f||!g)return;var p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=null!==(i=oi(a,s))&&void 0!==i?i:ii(d),m=(P=p.right-I.left)+.5*((F=h.left-I.left-0)-P),_=p.top+p.height/2,R=h.top+h.height/2,y=_-he+ye,b=R-me+be,S="conn-subsec-".concat(v);pe.push({lhsScrollY:y,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:e,rhsArrayIdx:e,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var A=Ae(_,he,_e),E=Ae(R,me,Re),T=A-Se,B=E-Se,C=R>=me-4&&R<=Re+4,D="";D=(M=_>=he-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):M&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:e,rhsArrayIdx:e})}else if(xe){var O=e,w=Xn[O];if(!(null===(r=null==w?void 0:w.refIndexes)||void 0===r?void 0:r.length))return;w.refIndexes.forEach(function(e){var n,t,i=$n.findIndex(function(n){return n.selfIndex===e});if(-1!==i){var o=null===(n=at.current[O])||void 0===n?void 0:n.current,l=null===(t=st.current[i])||void 0===t?void 0:t.current;if(o&&l){var r=o.getBoundingClientRect(),c=l.getBoundingClientRect(),a=ti(O),s=r.right-I.left,d=c.left-I.left-0,v=s+.5*(d-s),f=r.top+r.height/2,g=c.top+c.height/2,p=f-he+ye,h=g-me+be,x="conn-".concat(O,"-").concat(i);pe.push({lhsScrollY:p,rhsScrollY:h,x1:s,x2:d,containerTop:Se,leftIdx:O,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Ae(f,he,_e),_=Ae(g,me,Re),R=m-Se,y=_-Se,b=f>=he-4&&f<=_e+4,S=g>=me-4&&g<=Re+4,A="";A=b&&S?u.getBentArrowPath(s,R,d,y):b&&!S?"M ".concat(s,",").concat(R," L ").concat(v,",").concat(R," L ").concat(v,",").concat(y):!b&&S?"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y," L ").concat(d,",").concat(y):"M ".concat(v,",").concat(R," L ").concat(v,",").concat(y),ve.push({id:x,pathD:A,style:a,leftIdx:O,rhsArrayIdx:i})}}})}else{var N=e,j=N;f=null===(o=at.current[N])||void 0===o?void 0:o.current,g=null===(l=st.current[j])||void 0===l?void 0:l.current;if(!f||!g)return;var P,F;p=f.getBoundingClientRect(),h=g.getBoundingClientRect(),x=ti(N),m=(P=p.right-I.left)+.5*((F=h.left-I.left-0)-P),_=p.top+p.height/2,R=h.top+h.height/2,y=_-he+ye,b=R-me+be,S="conn-".concat(N,"-").concat(j);pe.push({lhsScrollY:y,rhsScrollY:b,x1:P,x2:F,containerTop:Se,leftIdx:N,rhsArrayIdx:j,styleColor:(null==x?void 0:x.badgeBorder)||"#6366F1",styleId:S});var M;A=Ae(_,he,_e),E=Ae(R,me,Re),T=A-Se,B=E-Se,C=R>=me-4&&R<=Re+4,D="";D=(M=_>=he-4&&_<=_e+4)&&C?u.getBentArrowPath(P,T,F,B):M&&!C?"M ".concat(P,",").concat(T," L ").concat(m,",").concat(T," L ").concat(m,",").concat(B):!M&&C?"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B," L ").concat(F,",").concat(B):"M ".concat(m,",").concat(T," L ").concat(m,",").concat(B),ve.push({id:S,pathD:D,style:x,leftIdx:N,rhsArrayIdx:j})}}),tn.current=pe}Ue(ve)}else Ue([]),tn.current=[]}catch(e){console.error("Line render safe fail: ",e)}finally{yn.current=!1}}},[Jn,Xn,$n,cn,Ln,ni,ti,oi,xe,De,Ve,ze,Dt,wt]),ci=t.useCallback(function(){var e,n,t,i,o,l,r,c,a,s,d,v,f,g,p=tn.current;if(p.length&&!Ze.current){var h=null!==(n=null===(e=Rn.current)||void 0===e?void 0:e.scrollTop)&&void 0!==n?n:0,x=null!==(i=null===(t=pn.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(l=null===(o=Rn.current)||void 0===o?void 0:o.clientHeight)&&void 0!==l?l:1/0,_=null!==(c=null===(r=pn.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,R=null!==(s=null===(a=Rn.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,y=null!==(v=null===(d=pn.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==v?v:0,b=R+m,S=y+_,A=null!==(g=null===(f=Gt.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,I=function(e,n,t){return Math.max(n,Math.min(t,e))};p.forEach(function(e){var n=e.lhsScrollY-h+R,t=e.rhsScrollY-x+y,i=nn.current[e.styleId+"-stroke"],o=nn.current[e.styleId+"-bg"];if(i||o){var l,r=I(n,R,b),c=I(t,y,S),a=r-A,s=c-A,d=n>=R-4&&n<=b+4,v=t>=y-4&&t<=S+4,f=e.x1+.5*(e.x2-e.x1);l=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",l)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",l))}})}},[]);t.useEffect(function(){un.current=ui},[ui]);var ai=t.useRef(null),si=t.useRef(null),di=t.useCallback(function(){tn.current.length>0&&!Ze.current||(null!==ai.current&&clearTimeout(ai.current),ai.current=setTimeout(function(){un.current(),ai.current=null},50))},[]),vi=t.useCallback(function(){ke(!0),Pe(!1),$e.current=null,null!==si.current&&clearTimeout(si.current),null!==ai.current&&(clearTimeout(ai.current),ai.current=null),si.current=setTimeout(function(){var e,n,t,i,o,l,r,c,a,s,d;try{if(tn.current=[],ln.current&&null!==rn.current&&null!==Wt.current){var v=rn.current,f=Wt.current,g="string"==typeof v&&v.includes(u.DEVIATION_BADGE_SEPARATOR),p=null,h=null,x=null,m=null;if(g){var _=v.split(u.DEVIATION_BADGE_SEPARATOR),R="".concat(_[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(_[1]);p=(null===(e=at.current[R])||void 0===e?void 0:e.current)||null,h=(null===(n=st.current[R])||void 0===n?void 0:n.current)||null,x=(null===(t=vt.current[_[2]])||void 0===t?void 0:t.current)||(null===(i=ut.current[Number(_[2])])||void 0===i?void 0:i.current)||null,m=(null===(o=ft.current[_[3]])||void 0===o?void 0:o.current)||(null===(l=ct.current[Number(_[3])])||void 0===l?void 0:l.current)||null}else p=(null===(r=gt.current[v])||void 0===r?void 0:r.current)||null,x=(null===(c=ut.current[v])||void 0===c?void 0:c.current)||null,h=(null===(a=dt.current[f])||void 0===a?void 0:a.current)||null,m=(null===(s=ct.current[f])||void 0===s?void 0:s.current)||null;if(p&&h&&x&&m){if(x.style.paddingTop="0px",m.style.paddingTop="0px",!xe){var y=p.getBoundingClientRect(),b=h.getBoundingClientRect(),S=y.top-b.top;S>0?m.style.paddingTop="".concat(S,"px"):S<0&&(x.style.paddingTop="".concat(Math.abs(S),"px"))}var A=Rn.current,I=pn.current;if(A&&I){var E=p.getBoundingClientRect().top-A.getBoundingClientRect().top+A.scrollTop,T=h.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop-(E-A.scrollTop);Math.abs(I.scrollTop-T)>1&&(I.scrollTop=T)}}}null===(d=un.current)||void 0===d||d.call(un),ln.current&&Pe(!0)}catch(e){console.error("Safely caught error during resize calculation:",e)}finally{ke(!1),si.current=null}},150)},[xe,Xn,$n]),fi=t.useCallback(function(e){if(null!==bn.current&&Sn.current&&Math.abs(e.currentTarget.scrollTop-bn.current)<=2){var n=Sn.current;bn.current=null,Sn.current=null,n()}qe.current||(xe||di(),on.current||(on.current=!0,requestAnimationFrame(function(){var e,n,t,i,o,l,r;if(ln.current){var c=Rn.current,a=pn.current;if(c&&a&&Kt.current){if(!$e.current){var s=rn.current,d=void 0;if("string"==typeof s&&s.includes(u.DEVIATION_BADGE_SEPARATOR)){var v=s.split(u.DEVIATION_BADGE_SEPARATOR),f="".concat(v[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(v[1]);d=null===(e=at.current[f])||void 0===e?void 0:e.current}else d=null===(n=at.current[s])||void 0===n?void 0:n.current;if(d){var g=d.getBoundingClientRect();$e.current={badgeScreenY:g.top+g.height/2,initialScrollTop:c.scrollTop,leftTop:c.getBoundingClientRect().top,leftBottom:c.getBoundingClientRect().top+c.clientHeight,cTop:null!==(i=null===(t=Gt.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if($e.current){var p=$e.current,h=c.scrollTop-p.initialScrollTop,x=p.badgeScreenY-h,m=((o=x,l=p.leftTop,r=p.leftBottom,Math.max(l,Math.min(r,o)))-p.cTop).toString(),_=x>=p.leftTop-4&&x<=p.leftBottom+4;Kt.current.setAttribute("y1",m),Kt.current.setAttribute("y2",m),Kt.current.setAttribute("visibility",_?"visible":"hidden")}}}tn.current.length>0&&ci(),on.current=!1})))},[ci,xe,di]),gi=t.useRef(0),pi=t.useRef(0),hi=t.useRef(0),xi=t.useRef(function(){});t.useRef(null),t.useEffect(function(){xi.current=vi},[vi]),t.useEffect(function(){var e=setTimeout(di,250),n=function(){return xi.current()};return window.addEventListener("resize",n),function(){clearTimeout(e),null!==ai.current&&clearTimeout(ai.current),null!==si.current&&clearTimeout(si.current),window.removeEventListener("resize",n)}},[Yn,Un,mt,Jn,Dt,wt,Xn,$n,Ln,di,De,Ve,je,ze]),t.useEffect(function(){var e=function(e,n,t,i,o){n.current=e.getBoundingClientRect().width;var l=new ResizeObserver(function(e){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var l,r,u;t.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(r=null===(l=c.borderBoxSize)||void 0===l?void 0:l[0])||void 0===r?void 0:r.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,i())}})});return l.observe(e),l},n={current:null},t={current:null},i={current:null},o=[],l=[n,t,i];return gn.current&&o.push(e(gn.current,gi,n,function(){return xi.current()},function(){})),fn.current&&o.push(e(fn.current,pi,t,function(){return xi.current()},function(){return un.current()})),Gt.current&&o.push(e(Gt.current,hi,i,function(){return xi.current()},function(){return un.current()})),function(){o.forEach(function(e){return e.disconnect()}),l.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(function(){ln.current=De},[De]),t.useEffect(function(){rn.current=Ve},[Ve]);var mi=t.useCallback(function(e,n,t){var i,o,l=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,r=null==t?void 0:t.onReady,c=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";kn(),null!=e&&(n?Be("No counterpart exists for this section."):(It(),De&&Ve===e?l?Et():null==r||r():(We(new Set([e])),Ue([]),tn.current=[],Ie(!0),qe.current=!0,He(e),rn.current=e,Oe(!0),ln.current=!0,Pe(!1),hn.current&&(hn.current.style.height="0px"),xn.current&&(xn.current.style.height="0px"),mn.current&&(mn.current.style.height="0px"),_n.current&&(_n.current.style.height="0px"),requestAnimationFrame(function(){var n,t,i,o,l,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=at.current[g])||void 0===n?void 0:n.current)||null,d=(null===(t=st.current[g])||void 0===t?void 0:t.current)||null,v=d?e:null}else if(s=(null===(i=gt.current[e])||void 0===i?void 0:i.current)||null,xe){var p=Xn[e],h=(null==p?void 0:p.refIndexes)||[];if(h.length>0){var x=h[0],m=$n.findIndex(function(e){return e.selfIndex===x});-1!==m&&(d=(null===(l=dt.current[m])||void 0===l?void 0:l.current)||null,v=m)}}else d=(null===(o=dt.current[e])||void 0===o?void 0:o.current)||null,v=d?e:null;Wt.current=v;var _=Rn.current,R=pn.current,y=function(){!function(){var n,t,i,o,l,r,c,s,d,f,g,p,h=null,x=null,m=null,_=null;if(a){var R=e.split(u.DEVIATION_BADGE_SEPARATOR),y="".concat(R[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(R[1]);h=(null===(n=vt.current[R[2]])||void 0===n?void 0:n.current)||(null===(t=ut.current[Number(R[2])])||void 0===t?void 0:t.current)||null,x=(null===(i=ft.current[R[3]])||void 0===i?void 0:i.current)||(null===(o=ct.current[Number(R[3])])||void 0===o?void 0:o.current)||null,m=(null===(l=at.current[y])||void 0===l?void 0:l.current)||h,_=(null===(r=st.current[y])||void 0===r?void 0:r.current)||x}else{var b=Number(e),S=null!==v?Number(v):b;h=(null===(c=ut.current[b])||void 0===c?void 0:c.current)||null,x=(null===(s=ct.current[S])||void 0===s?void 0:s.current)||null,m=(null===(d=at.current[b])||void 0===d?void 0:d.current)||(null===(f=gt.current[b])||void 0===f?void 0:f.current)||h,_=(null===(g=st.current[S])||void 0===g?void 0:g.current)||(null===(p=dt.current[S])||void 0===p?void 0:p.current)||x}if(m&&_&&h&&x){h.style.paddingTop="0px",x.style.paddingTop="0px";var A=m.getBoundingClientRect(),I=_.getBoundingClientRect(),E=A.top-I.top;E>0?x.style.paddingTop="".concat(E,"px"):E<0&&(h.style.paddingTop="".concat(Math.abs(E),"px"))}}(),Pe(!0),un.current&&un.current(),qe.current=!1,"right"===c&&R?R.dispatchEvent(new Event("scroll")):_&&_.dispatchEvent(new Event("scroll")),Ie(!1),null==r||r()};if(!s||!_)return qe.current=!1,Ie(!1),void(null==r||r());if(d&&R){if(!xe){var b=0;b="right"===c?d?d.getBoundingClientRect().top:0:s?s.getBoundingClientRect().top:0;var S=fn.current,A=(null==S?void 0:S.getBoundingClientRect().top)||0,I=S?S.scrollTop+b-A-150:0;return S?void u.smoothScrollTo(S,I,200,y):void y()}var E=s.getBoundingClientRect().top-_.getBoundingClientRect().top+_.scrollTop,T=d.getBoundingClientRect().top-R.getBoundingClientRect().top+R.scrollTop,B=200;if("left"===c){var C=T-(E-_.scrollTop);C<0&&hn.current&&(hn.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 xn.current&&(xn.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=E-(T-R.scrollTop);D<0&&mn.current&&(mn.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 _n.current&&(_n.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u.smoothScrollTo(_,D,B,y)})}e=D}u.smoothScrollTo(_,e,B,y)})}}else y()}))))},[Ve,kn,$n,De,xe,Xn,Et]),_i=t.useCallback(function(){var e,n=Tn.sectionIdx,t=Tn.isOrphan;if(jn(),null!=n){var i="left";Tn.anchorEl&&(null===(e=pn.current)||void 0===e?void 0:e.contains(Tn.anchorEl))&&(i="right"),mi(n,t,{sourceSide:i})}},[mi,Tn.isOrphan,Tn.sectionIdx,Tn.anchorEl,jn]),Ri=t.useCallback(function(){jn(),Et(),We(new Set),Ue([]),tn.current=[]},[jn,Et]),yi=null!==Tn.sectionIdx&&ze.has(Tn.sectionIdx),bi=m.useDeviationNavigation({proposedSections:Xn,existingSections:$n,parentDeviationRecord:Qn,expandedSections:Dt,maintainRelativeOrder:!!xe,scrollContainerRef:fn,leftContainerRef:Rn,rightContainerRef:pn,lhsBadgeRefs:at,rhsBadgeRefs:st}),Si=bi.showDeviationNavigation,Ai=bi.showOpenNodeRef,Ii=bi.adjustScrollForPopup,Ei=t.useCallback(function(e,n,t,i,o){var l,r="string"==typeof i?u.safeStringify(i).trim():u.safeStringify(null==i?void 0:i.deviation_summary).trim(),c=e.currentTarget;Mn();var a="left";(null===(l=pn.current)||void 0===l?void 0:l.contains(c))&&(a="right");var s=function(){var e,t,i,o;if("string"==typeof n&&n.includes(u.DEVIATION_BADGE_SEPARATOR)){var l=n.split(u.DEVIATION_BADGE_SEPARATOR),r="".concat(l[0]).concat(u.DEVIATION_BADGE_SEPARATOR).concat(l[1]);return"right"===a?null===(e=st.current[r])||void 0===e?void 0:e.current:null===(t=at.current[r])||void 0===t?void 0:t.current}return"right"===a?null===(i=st.current[n])||void 0===i?void 0:i.current:null===(o=at.current[n])||void 0===o?void 0:o.current},d=function(e,n){var t=!!xe,i=t?"right"===a?pn.current:Rn.current:fn.current,o=t?"right"===a?Rn.current:pn.current:null;if(i&&e){var l=e.getBoundingClientRect(),r=i.getBoundingClientRect(),c=r.bottom-.35*r.height,s=r.top+.35*r.height;if(l.top>c||l.top<s){var d=r.top+r.height/2,v=l.top+l.height/2-d;if(t&&o){var f=i.scrollHeight-i.clientHeight,g=o.scrollHeight-o.clientHeight;if(v>0){var p=f-i.scrollTop,h=g-o.scrollTop;v=Math.max(0,Math.min(v,p,h))}else v=Math.min(0,Math.max(v,-i.scrollTop,-o.scrollTop));u.smoothScrollTo(o,o.scrollTop+v,250,function(){})}u.smoothScrollTo(i,i.scrollTop+v,250,n)}else n()}else n()};if(t)return Et(),We(new Set),Ue([]),tn.current=[],void(r&&requestAnimationFrame(function(){var e=s()||c;d(e,function(){Nn({open:!0,anchorEl:e,summary:i,displayImpact:o})})}));mi(n,t,r?{toggleIfSame:!1,sourceSide:a,onReady:function(){var e=s()||c;d(e,function(){Nn({open:!0,anchorEl:e,summary:i,displayImpact:o})})}}:{toggleIfSame:!1,sourceSide:a})},[mi,Mn,Nn,Et,xe]),Ti=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 Qn){if((Qn[t]||[]).some(function(e){return e.id===n}))return t}return null},[se,Qn]),Bi=t.useRef({id:null,triggerMs:null}),Ci=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 Ht(se.id);var o=null===(n=null==se?void 0:se.id)||void 0===n?void 0:n.split(":"),l=o[0],r=o[1],c=null!=r?r:"0";Ci.current!==se.id&&(jn(),Mn(),Et(),We(new Set),Ue([]),tn.current=[],Ci.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 l=t(e.subsections[o],"".concat(i,"-").concat(o));if(l)return l}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,r;if(!a){var p=function(){Bi.current={id:se.id,triggerMs:t}},h=null,x=null;for(var m in Qn){var _=Qn[m].find(function(e){return e.id===l});if(_){h=m,x=_;break}}if(x&&h){var R=Xn.findIndex(function(e){return e.id===h}),y=$n.findIndex(function(e){return e.id===h}),b=-1===R&&-1!==y,S=f(Xn,x.id),A=f($n,x.id);if(S&&!A&&!b){var I=S.split("-"),E=Number(I[0]);if(xe){var T=null===(i=null===(n=Xn[E])||void 0===n?void 0:n.refIndexes)||void 0===i?void 0:i[0],B=$n.findIndex(function(e){return e.selfIndex===T});-1!==B&&(E=B)}A=e.__spreadArray([E],I.slice(1),!0).join("-")}if(S||A){var C=b||!S&&!!A,D=S?Number(S.split("-")[0]):R,O=A?Number(A.split("-")[0]):y;if(C){if(!(xe?!!Dt["right-".concat(O)]:!!Dt[String(O)])&&O>=0)return jt(O,"right"),s+=1,void(d=setTimeout(g,450))}else if(!(xe?!!Dt["left-".concat(D)]:!!Dt[String(D)])&&D>=0)return jt(D,"left"),s+=1,void(d=setTimeout(g,450));var w,N=S||"",j=A||"",P="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c).concat(u.DEVIATION_BADGE_SEPARATOR).concat(N).concat(u.DEVIATION_BADGE_SEPARATOR).concat(j),F="".concat(x.id).concat(u.DEVIATION_BADGE_SEPARATOR).concat(c),M=null===(o=at.current[F])||void 0===o?void 0:o.current,k=null===(r=st.current[F])||void 0===r?void 0:r.current,L=C||!M&&!!k,V=L?k:M;if(w=xe?L?pn.current:Rn.current:fn.current,V&&w){var H=V.getBoundingClientRect();if(0===H.height)return void((s+=1)<2?d=setTimeout(g,v):p());var q=w.getBoundingClientRect(),G=H.top-q.top+w.scrollTop-q.height/2+H.height/2+150,z=function(){var n,t,i,o,l;if(!a){p();var r=V instanceof Element?window.getComputedStyle(V).color:"";M&&(M.style.transition="box-shadow 300ms ease-in-out",M.style.boxShadow="0 0 10px ".concat(r)),k&&(k.style.transition="box-shadow 300ms ease-in-out",k.style.boxShadow="0 0 10px ".concat(r)),setTimeout(function(){M&&(M.style.boxShadow=""),k&&(k.style.boxShadow="")},2e3);var u=(null===(t=null===(n=x.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===t?void 0:t[c])||x,s=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!M&&!!k)){var d=L?(null===(o=st.current[F])||void 0===o?void 0:o.current)||k:(null===(l=at.current[F])||void 0===l?void 0:l.current)||M;return Ii(d,function(){Nn({open:!0,anchorEl:d,displayImpact:se.displayImpact,summary:e.__assign(e.__assign({},u),{evaluation_outputs:s})})}),void(null==de||de())}mi(P,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var n,t,i=L?(null===(n=st.current[F])||void 0===n?void 0:n.current)||k:(null===(t=at.current[F])||void 0===t?void 0:t.current)||M;Ii(i,function(){Nn({open:!0,anchorEl:i,displayImpact:null==se?void 0:se.displayImpact,summary:e.__assign({},u)})})}})}};Math.abs(w.scrollTop-G)<=2?z():(bn.current=G,Sn.current=z,w.scrollTo({top:G,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(Sn.current){bn.current=null;var e=Sn.current;Sn.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,Qn,Xn,$n,xe,Dt,jt,mi,Nn,Ht]);var Di=function(e){var t=e.section,i=e.keyPath,o=e.depth,l=void 0===o?0:o,r=e.columnKey,u=void 0===r?"left":r,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset;return n.jsx(y.default,{section:t,keyPath:i,depth:l,columnKey:u,parentNodeId:a,expandedSubSections:wt,setExpandedSubSections:Nt,maintainRelativeOrder:xe||!1,proposedSections:Xn,existingSections:$n,treeData:Z,deviationNumberRegistry:Zn,connectedSections:ze,activeSideBySideSection:Ve,resolvedMarkdownStyles:vn,getSubSectionRef:ht,getSubSectionCompareStyle:ii,getBadgeRef:xt,openMoreFunctionsPopup:Mt,openSummaryPopup:Ei,showDeviationBadges:_e,resetSideBySide:Et,setConnectedSections:We,setConnectedLines:Ue,cachedConnectedPositions:tn,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:pe,sectionOffset:s})};return n.jsxs(i.Box,e.__assign({ref:gn,sx:e.__assign(e.__assign({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},xe?{}:{overflow:"visible"}),{position:"relative"})},{children:[ye&&n.jsx(i.Box,e.__assign({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:n.jsx(v.default,{})})),wn.open&&n.jsx(b.default,{open:wn.open,anchorEl:wn.anchorEl,containerEl:zt.current,clipTopEl:Yt.current,scrollContainerEl:fn.current,onClose:Ri,summary:wn.summary,displayImpact:wn.displayImpact}),n.jsx(d.default,{open:Tn.open,anchorEl:Tn.anchorEl,sectionTitle:Tn.sectionTitle,referenceSectionTitle:Tn.refSectionTitle,onClose:kn,onOpenCognitiveCompare:kt,onOpenSideBySide:_i,onConnect:Lt,isConnected:yi,isOrphan:Tn.isOrphan}),In.open&&n.jsx(s.default,{open:In.open,popupRef:Fn,position:Cn,popupConfig:ue,onClose:function(){Dn(null),En(function(n){return e.__assign(e.__assign({},n),{open:!1})}),Pn(null)},markdownStyles:ie,sectionTitle:In.sectionTitle,referenceSectionTitle:In.refSectionTitle,cognitiveData:In.cognitiveData,anchorEl:In.anchorEl,sectionAnchorEl:In.sectionAnchorEl,scrollContainerEl:fn.current,badgeStyle:In.badgeStyle,docData:In.docData,deviationData:In.deviationData,isLoading:In.isLoading}),n.jsx(i.Snackbar,e.__assign({open:!!Te,autoHideDuration:8e3,onClose:function(){return Be(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:n.jsx(i.Alert,e.__assign({onClose:function(){return Be(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Te}))})),n.jsx(_.default,{componentHeaderText:Q,displayConfig:re,maintainRelativeOrder:xe,onCollapseAll:li,showCollapseAll:ri,onToggleView:function(e){be(!0),setTimeout(function(){me(!e),Et(),jn(),We(new Set),Ue([]),tn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){be(!1)},600)})})},50)}}),n.jsx(i.Box,e.__assign({ref:fn,onScroll:fi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:xe?"hidden":"auto",borderTop:_t&&Rt?"none":"1.5px solid #EEF0F4"}},{children:n.jsx(i.Box,e.__assign({sx:e.__assign({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},xe?{flex:1,minHeight:0}:{})},{children:n.jsxs(i.Box,e.__assign({ref:Gt,sx:e.__assign({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},xe?{flex:1,overflow:"visible"}:{})},{children:[n.jsxs("svg",e.__assign({ref:Xe,style:{position:"absolute",top:0,left:0,width:sn.width||"100%",height:sn.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:Me?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Zt&&n.jsx("g",{children:n.jsx("line",{x1:Zt.x1,y1:Zt.y,x2:Zt.x2,y2:Zt.y,stroke:At.badgeBorder,strokeWidth:"1.5"})}),$t.map(function(t){var r,c,s,d,v,g,p,h=t.x1+.5*(t.x2-t.x1),x=(t.y1+t.y2)/2;if("Not Defined"===t.style.label&&!t.hasCognitive)return null;if(t.isSubSection?De&&Ve===t.subSectionKeyPath&&je:De&&Ve===t.sectionIdx&&je)return null;if(!xe){var m=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),_=Xn[t.sectionIdx]||{title:"",content:""},R=$n[null!==(r=t.targetRightIdx)&&void 0!==r?r:t.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",_,R),t.isSubSection&&t.subSectionKeyPath){var y=t.subSectionKeyPath.includes(u.DEVIATION_BADGE_SEPARATOR)?t.subSectionKeyPath.split(u.DEVIATION_BADGE_SEPARATOR):[],b=y[2]||t.subSectionKeyPath,S=y[3]||b,A=b.split("-").map(Number),I=S.split("-").map(Number),E=null,T=null;A.length>0&&(E=Xn[A[0]]),I.length>0&&(T=$n[I[0]]);var B=(null==E?void 0:E.title)||"",C=(null==T?void 0:T.title)||"";console.log("Root Parent Titles:",B,C);for(var D=1;D<A.length;D++)(null==E?void 0:E.subsections)&&(E=E.subsections[A[D]]);for(D=1;D<I.length;D++)(null==T?void 0:T.subsections)&&(T=T.subsections[I[D]]);E&&(_=e.__assign(e.__assign({},E),{title:B||E.title})),console.log("Base Section for Subsection Badge:",_),T&&(R=e.__assign(e.__assign({},T),{title:C||T.title})),console.log("Ref Section for Subsection Badge:",R)}var O=!(null===(c=_.cognitiveData)||void 0===c?void 0:c.isMissingRationale)||Boolean(null===(d=null===(s=_.cognitiveData)||void 0===s?void 0:s.decisioning)||void 0===d?void 0:d.length),w=(null===(p=null===(g=null===(v=_.evaluationResult)||void 0===v?void 0:v.cognitive_decisioning)||void 0===g?void 0:g.decisioning_factors)||void 0===p?void 0:p.length)||!1,N=O||w;return n.jsxs("g",{children:[n.jsx("path",{d:m,fill:"none",stroke:t.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),n.jsx("foreignObject",e.__assign({x:h-100,y:x-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(),N&&(In.open&&On===t.id?Mn():(Pn(t.id),Ft(Pt(e.currentTarget,_,R,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:N?"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(l.ButtonCognitiveIcon,{})})),N&&n.jsx(o.ChevronDown,{size:11,style:{transform:In.open&&On===t.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},t.id)}return null}),n.jsx(S.default,{connectedLines:Ye,pathRefs:nn})]})),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)"},xe?{flex:1,overflow:"visible"}:{})},{children:[n.jsx(i.Box,e.__assign({ref:Yt,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:zn,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:zn}))}))})),n.jsxs(i.Box,e.__assign({ref:Rn,onScroll:fi,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},xe?{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:mn,style:{width:"100%",height:"0px",flexShrink:0}}),nt&&Xn.map(function(t,l){var r,c,a=!t.title&&!t.content;if(xe&&a)return null;var s=t,d=ti(l,"left"),v=xe?!(null===(r=s.refIndexes)||void 0===r?void 0:r.length)||s.selfIndex<0:!$n[l],g=ze.has(l),p=u.extractDeviationScore(s.evaluationResult,null==d?void 0:d.deviationLabel),h=it.leftNums.get(s.id);return n.jsx(i.Box,e.__assign({ref:pt(l),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:ut.current[l],sx:e.__assign({width:"100%",display:"flex",flexDirection:"column",minWidth:0},g&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:l,columnKey:"left",colRef:pt("left-accordion-".concat(l)),mb:0,treeData:Z,proposedSections:Xn,existingSections:$n,deviationNumberRegistry:Zn,getSectionCompareStyle:ti,getBadgeRef:xt,connectedSections:ze,openMoreFunctionsPopup:Mt,openSummaryPopup:Ei,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Ti,parentNodeId:(null===(c=null==Z?void 0:Z.input_index_map)||void 0===c?void 0:c[0])||"",isExpanded:xe?!!Dt["left-".concat(l)]:!!Dt[String(l)],onToggle:function(){Ri(),jt(l,"left")},navigation:t.id?Si[t.id]:null,showOpenNodeRef:Ai,resolvedMarkdownStyles:vn,maintainRelativeOrder:xe,showDeviationBadges:_e,renderSubSections:Di,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:pe,collisionKey:"".concat(De?"1":"0","-").concat(String(null!=Ve?Ve:""))})})),xe&&d&&n.jsxs(i.Box,e.__assign({ref:at.current[l],onClick:function(e){var n,t,i,o=re.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;Ei(e,String(l),v,o)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.3,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=re.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;Ei(e,String(l),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!=h&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:h})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!re.isLoading||null!=s.evaluationResult&&null!=s.evaluationResult?"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p):n.jsx(f.default,{color:d.badgeText})}))]})),n.jsx(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=xe?$n.find(function(e){var n;return null===(n=s.refIndexes)||void 0===n?void 0:n.includes(e.selfIndex)})||{title:"",content:""}:$n[l]||{title:"",content:""};Mt(e,t,v,n,l,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(l))}),n.jsx("div",{ref:_n,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),n.jsx(i.Box,e.__assign({ref:zt,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(),In.open&&On===yt?Mn():(Pn(yt),Ft(Pt(n.currentTarget,{title:"",content:"",evaluationResult:bt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,yt,!0,e.__assign(e.__assign({},At),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:At.badgeBg,color:At.badgeText,border:"1px solid ".concat(At.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=St?St: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(l.ButtonCognitiveIcon,{})})),n.jsx(o.ChevronDown,{size:11,style:{transform:In.open&&On===yt?"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},xe?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Ae&&n.jsx(r.default,{sections:11}),n.jsx(i.Box,e.__assign({ref:Ut,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:Wn,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:Wn}))}))})),n.jsxs(i.Box,e.__assign({ref:pn,onScroll:fi,sx:e.__assign({p:"12px",display:"flex",flexDirection:"column"},xe?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[n.jsx("div",{ref:hn,style:{width:"100%",height:"0px",flexShrink:0}}),nt&&$n.map(function(t,l){var r,u,c=t,a=!1,s=null,d=-1;if(xe){d=Xn.findIndex(function(e){var n;return(null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex))&&e.selfIndex>=0});var v=Xn.findIndex(function(e,n){var t;return ze.has(n)&&(null===(t=e.refIndexes)||void 0===t?void 0:t.includes(c.selfIndex))});(a=-1!==v)&&(s=ti(v,"left"))}else(a=ze.has(l))&&(s=ti(l,"right"));var g=xe&&-1!==d?ti(d,"left"):ti(l,"right"),p=xe?-1!==d||!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)&&Xn.some(function(e){return e.id&&e.id===c.id}):Boolean(Xn[l]),h=xe?c.selfIndex<0||!p:!Xn[l],x=it.rightNums.get(c.id);return n.jsx(i.Box,e.__assign({ref:dt.current[l],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:ct.current[l],sx:e.__assign({width:"100%",display:"flex"},a&&s&&{borderRadius:"6px",outline:"2px solid ".concat(s.badgeBorder),outlineOffset:"1px"})},{children:n.jsx(R.default,{section:t,idx:l,columnKey:"right",colRef:pt("right-accordion-".concat(l)),mb:0,parentNodeId:(null===(u=null==Z?void 0:Z.input_index_map)||void 0===u?void 0:u[1])||"",isExpanded:xe?!!Dt["right-".concat(l)]:!!Dt[String(l)],treeData:Z,proposedSections:Xn,existingSections:$n,deviationNumberRegistry:Zn,getBadgeRef:xt,getSectionCompareStyle:ti,connectedSections:ze,openMoreFunctionsPopup:Mt,openSummaryPopup:Ei,deviationNodeIdToView:null==se?void 0:se.id,deviationTargetParentId:Ti,onToggle:function(){Ri(),jt(l,"right")},navigation:t.id?Si[t.id]:null,showOpenNodeRef:Ai,resolvedMarkdownStyles:vn,maintainRelativeOrder:xe,showDeviationBadges:_e,renderSubSections:Di,isProposingFix:fe,proposingFixNodeId:ge,isRedlineFlow:pe,collisionKey:"".concat(De?"1":"0","-").concat(String(null!=Ve?Ve:""))})})),xe&&g&&n.jsx(i.Box,e.__assign({ref:st.current[l],"data-section-id":c.id,onClick:function(e){var n,t,i;if(h){var o=re.enableDeviationSchemaBackwardCompatibility?null!==(n=c.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(l),h,o)}},sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:h?"4px":"0px",fontSize:"11px",bgcolor:g.badgeBg,color:g.badgeText,border:"1px solid ".concat(g.badgeBorder),borderRadius:h?"12px":"10px",px:h?1.2:1,py:.3,fontWeight:h?600:700,cursor:h?"pointer":"default",whiteSpace:"nowrap",zIndex:20,boxShadow:h?"0 1px 3px rgba(0,0,0,0.07)":"none"}},{children:h?n.jsxs(n.Fragment,{children:[n.jsxs(i.Box,e.__assign({component:"span",onClick:function(e){var n,t,i;e.stopPropagation();var o=re.enableDeviationSchemaBackwardCompatibility?null!==(n=c.evaluationResult)&&void 0!==n?n:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Ei(e,String(l),h,o)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:"pointer",borderRight:"1px solid ".concat(g.badgeBorder),"&:hover":{bgcolor:"".concat(g.badgeBorder,"22")}}},{children:[null!=x&&n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(g.badgeBorder)}},{children:x})),n.jsx(i.Box,e.__assign({component:"span",sx:{fontSize:"11px",px:.25}},{children:!re.isLoading||null!=c.evaluationResult&&void 0!==c.evaluationResult?g.label?"".concat(g.label):"100% Deviation":n.jsx(f.default,{color:g.badgeText})}))]})),n.jsx(i.Box,e.__assign({component:"span",onClick:function(e){e.stopPropagation();var n=xe?Xn.find(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(c.selfIndex)})||{title:"",content:""}:Xn[l]||{title:"",content:""};Mt(e,n,h,c,l,g)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(g.badgeBorder,"22")}}},{children:n.jsx(o.EllipsisVertical,{size:11,color:g.badgeText})}))]}):null!=x?x:""}))]}))}),"right-row-".concat(l))}),n.jsx("div",{ref:xn,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
|
|
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.suppressHighlightBg!==n.suppressHighlightBg)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 d=0;d<a.length;d++)if(a[d]!==s[d])return!1;var v=t.deviationBadges||[],c=n.deviationBadges||[];if(v.length!==c.length)return!1;for(d=0;d<v.length;d++){if(v[d].id!==c[d].id)return!1;if(v[d].actionId!==c[d].actionId)return!1;if(v[d].label!==c[d].label)return!1;if(v[d].score!==c[d].score)return!1;if(v[d].isOrphan!==c[d].isOrphan)return!1;if(v[d].isConnected!==c[d].isConnected)return!1;if((null===(e=v[d].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=c[d].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=v[d].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=c[d].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(u=v[d].style)||void 0===u?void 0:u.badgeText)!==(null===(l=c[d].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.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,d,v,c,g,f,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];(C=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(C)}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[_];(C=null===(d=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===d?void 0:d.label_color)&&h.push(C)}for(var A=0,B=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});A<B.length;A++){var C;y=B[A];(C=null===(g=null===(c=null===(v=null==n?void 0:n[y])||void 0===v?void 0:v.evaluation_outputs)||void 0===c?void 0:c.metadata)||void 0===g?void 0:g.label_color)&&h.push(C)}return 0===h.length?(null===(p=null===(f=null==n?void 0:n.evaluation_outputs)||void 0===f?void 0:f.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,d=0,v=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});d<v.length;d++){var c=v[d];if(b=null===(o=null===(e=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[c])||void 0===e?void 0:e.evaluation_outputs)||void 0===o?void 0:o.output_value)return b}for(var g=0,f=Object.keys((null==t?void 0:t.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});g<f.length;g++){c=f[g];if(b=null===(u=null===(i=null===(r=null==t?void 0:t.deviation_entries)||void 0===r?void 0:r[c])||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;c=h[p];if(b=null===(a=null===(l=null==t?void 0:t[c])||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.hasMeaningfulRedlineTags=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,o=null;null!==(o=e.exec(t));){if((null!==(n=o[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},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(d){null===a&&(a=d);var v,c=d-a;c<e?(t.scrollTop=(v=c,v/=e,l*(--v*v*v+1)+u),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)},exports.stripRedlineTags=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""};
|
|
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,
|
|
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,f=r.scrollContainerEl,x=r.onClose,m=r.summary;r.markdownStyles,r.isLoading;var h=r.displayImpact,g=o.useRef(null),v=o.useRef(null),y=o.useState(null),b=y[0],_=y[1],w=o.useState(null),S=w[0],j=w[1],C=o.useState(null);C[0];var B=C[1],I=o.useState(0),R=I[0],z=I[1],E="string"==typeof m?{deviation_summary:m}:null!=m?m:{},F=E.deviation_title,W=E.deviation_summary,A=E.deviation_impact,T=E.evaluation_outputs,H=!!String(A||"").trim(),M=o.useState(!!h),P=M[0],k=M[1];o.useEffect(function(){H&&k(!!h)},[h,H,m]);var q=(null===(l=null==T?void 0:T.metadata)||void 0===l?void 0:l.label_color)||"#6366F1",L=null!==(a=null==u?void 0:u.getBoundingClientRect().width)&&void 0!==a?a:180,O=Math.max(148,L+120),D=o.useMemo(function(){if(!d||!u)return null;var e=d.getBoundingClientRect();if(0===e.width&&0===e.height)return null;var n=u.getBoundingClientRect();return{top:e.top,bottom:e.bottom,left:n.left+n.width/2}},[d,u]);o.useEffect(function(){if(!c||!d||!u)return _(null),j(null),void B(null);var e=function(){null!==g.current&&cancelAnimationFrame(g.current),g.current=requestAnimationFrame(function(){var e,n,t=d.getBoundingClientRect(),i=null==p?void 0:p.getBoundingClientRect(),o=null==f?void 0:f.getBoundingClientRect();if(0===t.width&&0===t.height)_(null);else{var r=u.getBoundingClientRect();_({top:t.top,bottom:t.bottom,left:r.left+r.width/2})}j(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),B(null!==(n=null==o?void 0:o.bottom)&&void 0!==n?n:null),v.current&&z(v.current.offsetHeight)})};return e(),window.addEventListener("scroll",e,{passive:!0,capture:!0}),window.addEventListener("resize",e),function(){null!==g.current&&cancelAnimationFrame(g.current),window.removeEventListener("scroll",e,{capture:!0}),window.removeEventListener("resize",e)}},[c,d,u,p,f]);var N=null!==(s=null!=b?b:D)&&void 0!==s?s:"hidden",J="hidden"===N?"hidden":N.bottom+20,G=null!=S&&"number"==typeof J&&J<S?Math.min(R,S-J):0,V=o.useMemo(function(){return"hidden"===N?{getBoundingClientRect:function(){return{width:0,height:0,top:0,bottom:0,left:0,right:0,x:0,y:0,toJSON:function(){}}}}:{getBoundingClientRect:function(){return{width:0,height:N.bottom-N.top,top:N.top,bottom:N.bottom,left:N.left,right:N.left,x:N.left,y:N.top,toJSON:function(){}}}}},[N]);return m?n.jsx(t.Popper,e.__assign({open:c,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:V,placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}},{name:"preventOverflow",enabled:!0,options:{boundary:f||"clippingParents",tether:!1}},{name:"flip",enabled:!0,options:{boundary:f||"clippingParents",fallbackPlacements:["top"]}}],sx:{zIndex:21,visibility:"hidden"===N?"hidden":"visible",opacity:"hidden"===N?0:1,transition:"opacity 0.15s ease-in-out"}},{children:n.jsxs(t.Paper,e.__assign({ref:v,sx:e.__assign(e.__assign({p:1.5,borderRadius:"12px",width:O,maxWidth:O},G>0&&{clipPath:"inset(".concat(G,"px 0px 0px 0px round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(q,"26"),borderTop:"3px solid ".concat(q),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:q}),n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:q,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),n.jsx(t.IconButton,e.__assign({size:"small",onClick:x,sx:{p:.25,ml:.5,color:"#64748B"}},{children:n.jsx(i.X,{size:14})}))]})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[n.jsxs(t.Box,{children:[F&&n.jsx(t.Typography,e.__assign({sx:{fontSize:"12px",color:"#334155",fontFamily:'"Inter", sans-serif',lineHeight:1.6,fontWeight:700,overflowWrap:"anywhere"}},{children:F})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",color:"#334155",lineHeight:1.6,fontFamily:'"Inter", sans-serif',fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:W||"No summary available."}))]}),H&&n.jsxs(t.Accordion,e.__assign({expanded:P,onChange:function(e,n){return k(n)},disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(q,"0A"),border:"1px solid ".concat(q,"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:q}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(q,"1A")}}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",fontWeight:700,color:q,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),n.jsx(t.AccordionDetails,e.__assign({sx:{p:1.5,backgroundColor:"#fff"}},{children:n.jsx(t.Typography,e.__assign({sx:{fontSize:"11px",color:"#475569",lineHeight:1.6,fontWeight:400,fontFamily:'"Inter", sans-serif',overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(A).replace("Impact -","").trim()}))}))]}))]}))]}))})):null};
|
|
2
2
|
//# sourceMappingURL=CognitiveSummaryPopup.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=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 u=a(i);exports.default=function(a){var s,c,v,f,p,x,g,h,m,_,I,b,y,A=a.section,w=a.idx,R=a.columnKey,S=a.colRef,E=a.mb,O=void 0===E?1:E,j=a.parentNodeId,F=void 0===j?"":j,B=a.isExpanded,C=a.onToggle,D=a.navigation,T=a.showOpenNodeRef,k=a.resolvedMarkdownStyles,M=a.maintainRelativeOrder,P=a.showDeviationBadges,N=void 0!==P&&P,V=a.renderSubSections,W=a.treeData,q=a.proposedSections,G=void 0===q?[]:q,K=a.existingSections,z=void 0===K?[]:K,L=a.deviationNumberRegistry,U=void 0===L?{}:L,X=a.getBadgeRef,Y=a.openSummaryPopup,H=a.getSectionCompareStyle,J=a.connectedSections,Q=a.openMoreFunctionsPopup;a.deviationNodeIdToView,a.deviationTargetParentId;var Z=a.isProposingFix,$=a.proposingFixNodeId,ee=a.collisionKey,ne=(null===(s=A.displayTitle)||void 0===s||s)&&r.hasValue(A.title),ie=A.change_history,oe=!!Z&&!!$&&"left"===R&&A.id===$&&r.hasValue(ie),te=oe?ie||"":A.content,le=oe?A.content:void 0,re=(null===(c=A.displayContent)||void 0===c||c)&&r.hasValue(te),de=!ne&&!re,ae=A.title;ne||(ae=re?"No Title Found":"No Matching Section Found");var ue=A.evaluationResult;if(!ue&&"right"===R)if(M){var se=null===(v=A.refIndexes)||void 0===v?void 0:v[0],ce=G.find(function(e){return e.selfIndex===se});ue=null==ce?void 0:ce.evaluationResult}else ue=null===(f=G[w])||void 0===f?void 0:f.evaluationResult;var ve=null===(p=null==W?void 0:W.input_index_map)||void 0===p?void 0:p[0],fe=null===(x=null==W?void 0:W.input_index_map)||void 0===x?void 0:x[1],pe="left"===R?fe:ve,xe=function(e,n){return e.find(function(e){return(null==e?void 0:e.id)&&n&&e.id===n})},ge="left"===R?A:G[w],he="right"===R?A:z[w],me=u.default.useMemo(function(){if(!M)return 0;var e=1/0,n=function(i,o,t,l){var d;if(i){var a=i.id;if(l&&"right"===R){var u=G.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(i.selfIndex)});u.length>0&&(a=u[0].id)}var s=i.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),c=(null===(d=i.evaluationResult)||void 0===d?void 0:d.deviations)||{};Object.keys(c).forEach(function(n){var i="".concat(a).concat(r.DEVIATION_BADGE_SEPARATOR).concat(n),o=null==U?void 0:U[i];null!=o&&o<e&&(e=o);var t="".concat(s).concat(r.DEVIATION_BADGE_SEPARATOR).concat(n),l=null==U?void 0:U[t];null!=l&&l<e&&(e=l)});for(var v=i.subsections||[],f=(null==o?void 0:o.subsections)||[],p=(null==t?void 0:t.subsections)||[],x=Math.max(v.length,f.length,p.length),g=0;g<x;g++)n(v[g],f[g],p[g],!1)}};return n(A,ge,he,!0),e!==1/0?e-1:0},[A,ge,he,R,U,M,G]);if(M)if("left"===R){var _e=null===(g=A.refIndexes)||void 0===g?void 0:g[0],Ie=z.findIndex(function(e){return e.selfIndex===_e});he=-1!==Ie?z[Ie]:xe(z,A.id)}else{var be=null===(h=A.refIndexes)||void 0===h?void 0:h[0],ye=G.findIndex(function(e){return e.selfIndex===be});ge=-1!==ye?G[ye]:xe(G,A.id)}var Ae="left"===R?!he:!ge,we=ue||(null==ge?void 0:ge.evaluationResult)||(null==he?void 0:he.evaluationResult),Re=null!==(I=null===(_=null===(m=null==we?void 0:we.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===_?void 0:_.label_color)&&void 0!==I?I:d.DEFAULT_DEVIAION_COLOR,Se=r.generateColorPalette(Re).highlightBg,Ee=(null==we?void 0:we.deviations)||{},Oe=w+1,je=A.id;if(M){var Fe=1,Be=new Map;if(G.forEach(function(e){!e.title&&!e.content||e.id&&Be.set(e.id,Fe++)}),"left"===R)Oe=Be.get(A.id)||w+1;else{var Ce=G.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(A.selfIndex)});if(Ce.length>0)Oe=Be.get(Ce[0].id)||w+1,je=Ce[0].id;else for(var De=Fe,Te=function(e){if(!e.title&&!e.content)return"continue";var n=G.some(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(e.selfIndex)});if(!n){if(e.id===A.id)return Oe=De,"break";De++}},ke=0,Me=z;ke<Me.length;ke++){if("break"===Te(Me[ke]))break}}}var Pe=[],Ne=Object.entries(Ee).map(function(e){var n=e[0],i=e[1],o="".concat(je).concat(r.DEVIATION_BADGE_SEPARATOR).concat(n);return{deviationKey:n,deviationMap:i,refId:o,currentIndex:U[o]}}).filter(function(e){return void 0!==e.currentIndex&&null!==e.currentIndex});Ne.sort(function(e,n){return e.currentIndex-n.currentIndex});var Ve,We=Ne.map(function(n){var i,o,t,l,d,a,u=n.deviationKey,s=n.deviationMap,c=n.refId,v=n.currentIndex;M&&void 0!==me&&(v-=me);var f=s[F],p=r.isMissingStr(f);if(p)f="";else if(!f)return null;Pe.push(f);var x=w,g=w;if(M)if("left"===R){var h=null===(i=A.refIndexes)||void 0===i?void 0:i[0],m=z.findIndex(function(e){return e.selfIndex===h});if(-1!==m)g=m;else{var _=z.findIndex(function(e){return e.id===A.id});g=-1!==_?_:w}}else{var I=null===(o=A.refIndexes)||void 0===o?void 0:o[0],b=G.findIndex(function(e){return e.selfIndex===I});if(-1!==b)x=b;else{var y=G.findIndex(function(e){return e.id===A.id});x=-1!==y?y:w}}var S="".concat(je).concat(r.DEVIATION_BADGE_SEPARATOR).concat(u).concat(r.DEVIATION_BADGE_SEPARATOR).concat(x).concat(r.DEVIATION_BADGE_SEPARATOR).concat(g),E=s[pe],O=Ae||r.isMissingStr(E),j="".concat(Oe,".").concat(v),B=w;if("right"===R&&M){var C=null===(t=A.refIndexes)||void 0===t?void 0:t[0],D=G.findIndex(function(e){return e.selfIndex===C});if(-1!==D)B=D;else{y=G.findIndex(function(e){return e.id===A.id});-1!==y&&(B=y)}}var T=H?H(B):null,k=(null==s?void 0:s.evaluation_outputs)||(null==we?void 0:we.evaluation_outputs),P=null!==(l=null==k?void 0:k.output_value)&&void 0!==l?l:null,N=null!==(a=null===(d=null==k?void 0:k.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:Re,V=r.generateColorPalette(N),W=T?e.__assign(e.__assign({},T),{badgeBg:V.badgeBg,badgeBorder:V.badgeBorder,badgeText:V.badgeText}):e.__assign({},V),q=(null==s?void 0:s.deviation_summary)?{deviation_summary:s.deviation_summary,deviation_title:(null==s?void 0:s.deviation_title)||(null==we?void 0:we.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==we?void 0:we.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==we?void 0:we.deviation_explanation),evaluation_outputs:k,cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==we?void 0:we.cognitive_decisioning)}:null,K=0,L=te||"";if(f&&L){var U=L.split(/\n{2,}/),Z=U.findIndex(function(e){return e.includes(f)});if(-1!==Z){var $=Object.entries(Ee).filter(function(e){e[0];var n=e[1][F];return n&&U[Z].includes(n)}).sort(function(e,n){return U[Z].indexOf(e[1][F])-U[Z].indexOf(n[1][F])});K=Math.max(0,$.findIndex(function(e){return e[0]===u}))}}return{id:c,actionId:S,label:j,highlight:f,side:R,style:W,stackIndex:K,score:P,isConnected:null==J?void 0:J.has(S),isOrphan:O,isMissingClause:p,badgeRef:X(R,c),onClick:function(e){e.stopPropagation(),Q&&Q(e,ge||{id:"orphan-left",title:"",content:""},O,he||{id:"orphan-right",title:"",content:""},S,W)},onSummaryClick:function(e){e.stopPropagation(),Y(e,S,O,q)}}}).filter(Boolean),qe=N?We:[],Ge=A.id&&R===(null==D?void 0:D.columnKey)?D:null,Ke=u.default.useRef(!1);return i.useEffect(function(){B||(Ke.current=!1)},[B]),n.jsxs(o.Box,e.__assign({ref:S,sx:{mb:O,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[B&&(null==Ge?void 0:Ge.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==Ge?void 0:Ge.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"===R?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===R?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronUp,{color:(null===(b=null==Ge?void 0:Ge.showAboveRef)||void 0===b?void 0:b.current)?window.getComputedStyle(Ge.showAboveRef.current).color:void 0})}))})),n.jsxs(o.Accordion,e.__assign({disableGutters:!0,expanded:!de&&B,onChange:function(){de||(C(),T.current=A.id)},sx:{boxShadow:"none",border:de?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:de?"#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,e.__assign({expandIcon:de?null:n.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:de?"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(o.Tooltip,e.__assign({title:ae,placement:"top"},{children:n.jsx(o.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:de?"#94A3B8":"#19213D",fontWeight:de?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Ve=ae,Ve?r.safeStringify(Ve).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(u.default.Fragment,{children:e},i)}):null)}))}))})),!de&&n.jsxs(o.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[re&&n.jsx(l.MemoizedMarkdown,{content:te,overlayContent:le,sxStyles:k,highlights:Pe,maintainRelativeOrder:M,highlightBg:Se,deviationBadges:qe,collisionKey:ee}),(A.subsections||[]).map(function(e,n){return V({section:e,keyPath:"".concat(w,"-").concat(n),depth:0,columnKey:R,parentNodeId:F,sectionOffset:me})})]}))]})),B&&(null==Ge?void 0:Ge.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==Ge?void 0:Ge.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"===R?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===R?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronDown,{color:(null===(y=null==Ge?void 0:Ge.showBelowRef)||void 0===y?void 0:y.current)?window.getComputedStyle(Ge.showBelowRef.current).color:void 0})}))}))]}),"".concat(R,"-sec-").concat(w))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=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 u=a(i);exports.default=function(a){var s,c,v,f,p,g,x,h,m,_,I,b,y,A=a.section,w=a.idx,R=a.columnKey,S=a.colRef,E=a.mb,O=void 0===E?1:E,j=a.parentNodeId,B=void 0===j?"":j,F=a.isExpanded,T=a.onToggle,C=a.navigation,D=a.showOpenNodeRef,M=a.resolvedMarkdownStyles,k=a.maintainRelativeOrder,P=a.showDeviationBadges,N=void 0!==P&&P,V=a.renderSubSections,W=a.treeData,q=a.proposedSections,G=void 0===q?[]:q,K=a.existingSections,z=void 0===K?[]:K,H=a.deviationNumberRegistry,L=void 0===H?{}:H,U=a.getBadgeRef,X=a.openSummaryPopup,Y=a.getSectionCompareStyle,J=a.connectedSections,Q=a.openMoreFunctionsPopup;a.deviationNodeIdToView,a.deviationTargetParentId;var Z=a.isProposingFix,$=a.proposingFixNodeId,ee=a.isRedlineFlow,ne=a.collisionKey,ie=(null===(s=A.displayTitle)||void 0===s||s)&&r.hasValue(A.title),oe=!!Z&&!!$&&"left"===R&&A.id===$,te=r.hasMeaningfulRedlineTags(A.content),le="boolean"==typeof ee?ee:te,re=te,de=le&&te,ae=de?r.stripRedlineTags(A.content):A.content,ue=de?A.content:void 0,se=(null===(c=A.displayContent)||void 0===c||c)&&r.hasValue(ae),ce=!ie&&!se,ve=A.title;ie||(ve=se?"No Title Found":"No Matching Section Found");var fe=A.evaluationResult;if(!fe&&"right"===R)if(k){var pe=null===(v=A.refIndexes)||void 0===v?void 0:v[0],ge=G.find(function(e){return e.selfIndex===pe});fe=null==ge?void 0:ge.evaluationResult}else fe=null===(f=G[w])||void 0===f?void 0:f.evaluationResult;var xe=null===(p=null==W?void 0:W.input_index_map)||void 0===p?void 0:p[0],he=null===(g=null==W?void 0:W.input_index_map)||void 0===g?void 0:g[1],me="left"===R?he:xe,_e=function(e,n){return e.find(function(e){return(null==e?void 0:e.id)&&n&&e.id===n})},Ie="left"===R?A:G[w],be="right"===R?A:z[w],ye=u.default.useMemo(function(){if(!k)return 0;var e=1/0,n=function(i,o,t,l){var d;if(i){var a=i.id;if(l&&"right"===R){var u=G.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(i.selfIndex)});u.length>0&&(a=u[0].id)}var s=i.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),c=(null===(d=i.evaluationResult)||void 0===d?void 0:d.deviations)||{};Object.keys(c).forEach(function(n){var i="".concat(a).concat(r.DEVIATION_BADGE_SEPARATOR).concat(n),o=null==L?void 0:L[i];null!=o&&o<e&&(e=o);var t="".concat(s).concat(r.DEVIATION_BADGE_SEPARATOR).concat(n),l=null==L?void 0:L[t];null!=l&&l<e&&(e=l)});for(var v=i.subsections||[],f=(null==o?void 0:o.subsections)||[],p=(null==t?void 0:t.subsections)||[],g=Math.max(v.length,f.length,p.length),x=0;x<g;x++)n(v[x],f[x],p[x],!1)}};return n(A,Ie,be,!0),e!==1/0?e-1:0},[A,Ie,be,R,L,k,G]);if(k)if("left"===R){var Ae=null===(x=A.refIndexes)||void 0===x?void 0:x[0],we=z.findIndex(function(e){return e.selfIndex===Ae});be=-1!==we?z[we]:_e(z,A.id)}else{var Re=null===(h=A.refIndexes)||void 0===h?void 0:h[0],Se=G.findIndex(function(e){return e.selfIndex===Re});Ie=-1!==Se?G[Se]:_e(G,A.id)}var Ee="left"===R?!be:!Ie,Oe=fe||(null==Ie?void 0:Ie.evaluationResult)||(null==be?void 0:be.evaluationResult),je=null!==(I=null===(_=null===(m=null==Oe?void 0:Oe.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(je).highlightBg,Fe=(null==Oe?void 0:Oe.deviations)||{},Te=w+1,Ce=A.id;if(k){var De=1,Me=new Map;if(G.forEach(function(e){!e.title&&!e.content||e.id&&Me.set(e.id,De++)}),"left"===R)Te=Me.get(A.id)||w+1;else{var ke=G.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(A.selfIndex)});if(ke.length>0)Te=Me.get(ke[0].id)||w+1,Ce=ke[0].id;else for(var Pe=De,Ne=function(e){if(!e.title&&!e.content)return"continue";var n=G.some(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(e.selfIndex)});if(!n){if(e.id===A.id)return Te=Pe,"break";Pe++}},Ve=0,We=z;Ve<We.length;Ve++){if("break"===Ne(We[Ve]))break}}}var qe=Object.entries(Fe).map(function(e){var n=e[0],i=e[1],o="".concat(Ce).concat(r.DEVIATION_BADGE_SEPARATOR).concat(n);return{deviationKey:n,deviationMap:i,refId:o,currentIndex:L[o]}}).filter(function(e){return void 0!==e.currentIndex&&null!==e.currentIndex});qe.sort(function(e,n){return e.currentIndex-n.currentIndex});var Ge,Ke=qe.map(function(n){var i,o,t,l,d,a,u=n.deviationKey,s=n.deviationMap,c=n.refId,v=n.currentIndex;k&&void 0!==ye&&(v-=ye);var f=s[B],p=r.isMissingStr(f);if(p)f="";else if(!f)return null;var g=w,x=w;if(k)if("left"===R){var h=null===(i=A.refIndexes)||void 0===i?void 0:i[0],m=z.findIndex(function(e){return e.selfIndex===h});if(-1!==m)x=m;else{var _=z.findIndex(function(e){return e.id===A.id});x=-1!==_?_:w}}else{var I=null===(o=A.refIndexes)||void 0===o?void 0:o[0],b=G.findIndex(function(e){return e.selfIndex===I});if(-1!==b)g=b;else{var y=G.findIndex(function(e){return e.id===A.id});g=-1!==y?y:w}}var S="".concat(Ce).concat(r.DEVIATION_BADGE_SEPARATOR).concat(u).concat(r.DEVIATION_BADGE_SEPARATOR).concat(g).concat(r.DEVIATION_BADGE_SEPARATOR).concat(x),E=s[me],O=Ee||r.isMissingStr(E),j="".concat(Te,".").concat(v),F=w;if("right"===R&&k){var T=null===(t=A.refIndexes)||void 0===t?void 0:t[0],C=G.findIndex(function(e){return e.selfIndex===T});if(-1!==C)F=C;else{y=G.findIndex(function(e){return e.id===A.id});-1!==y&&(F=y)}}var D=Y?Y(F):null,M=(null==s?void 0:s.evaluation_outputs)||(null==Oe?void 0:Oe.evaluation_outputs),P=null!==(l=null==M?void 0:M.output_value)&&void 0!==l?l:null,N=null!==(a=null===(d=null==M?void 0:M.metadata)||void 0===d?void 0:d.label_color)&&void 0!==a?a:je,V=r.generateColorPalette(N),W=D?e.__assign(e.__assign({},D),{badgeBg:V.badgeBg,badgeBorder:V.badgeBorder,badgeText:V.badgeText}):e.__assign({},V),q=(null==s?void 0:s.deviation_summary)?{deviation_summary:s.deviation_summary,deviation_title:(null==s?void 0:s.deviation_title)||(null==Oe?void 0:Oe.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==Oe?void 0:Oe.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==Oe?void 0:Oe.deviation_explanation),evaluation_outputs:M,cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==Oe?void 0:Oe.cognitive_decisioning)}:null,K=0,H=ae||"";if(f&&H){var L=H.split(/\n{2,}/),Z=L.findIndex(function(e){return e.includes(f)});if(-1!==Z){var $=Object.entries(Fe).filter(function(e){e[0];var n=e[1][B];return n&&L[Z].includes(n)}).sort(function(e,n){return L[Z].indexOf(e[1][B])-L[Z].indexOf(n[1][B])}),ee=$.filter(function(e){e[0];var n=e[1][B];return n&&(n.includes(f)||f.includes(n))});ee.length>1&&(K=Math.max(0,ee.findIndex(function(e){return e[0]===u})))}}return{id:c,actionId:S,label:j,highlight:f,side:R,style:W,stackIndex:K,score:P,isConnected:null==J?void 0:J.has(S),isOrphan:O,isMissingClause:p,badgeRef:U(R,c),onClick:function(e){e.stopPropagation(),Q&&Q(e,Ie||{id:"orphan-left",title:"",content:""},O,be||{id:"orphan-right",title:"",content:""},S,W)},onSummaryClick:function(e){e.stopPropagation(),X(e,S,O,q)}}}).filter(Boolean),ze=N||!le&&oe,He=ze?Ke:[],Le=ze?He.map(function(e){return e.highlight}).filter(Boolean):[],Ue=A.id&&R===(null==C?void 0:C.columnKey)?C:null,Xe=u.default.useRef(!1);return i.useEffect(function(){F||(Xe.current=!1)},[F]),n.jsxs(o.Box,e.__assign({ref:S,sx:{mb:O,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[F&&(null==Ue?void 0:Ue.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==Ue?void 0:Ue.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"===R?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===R?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronUp,{color:(null===(b=null==Ue?void 0:Ue.showAboveRef)||void 0===b?void 0:b.current)?window.getComputedStyle(Ue.showAboveRef.current).color:void 0})}))})),n.jsxs(o.Accordion,e.__assign({disableGutters:!0,expanded:!ce&&F,onChange:function(){ce||(T(),D.current=A.id)},sx:{boxShadow:"none",border:ce?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:ce?"#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,e.__assign({expandIcon:ce?null:n.jsx(t.ChevronDown,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:ce?"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:ie&&n.jsx(o.Tooltip,e.__assign({title:ve,placement:"top"},{children:n.jsx(o.Typography,e.__assign({component:"div",sx:{fontSize:"12px",color:ce?"#94A3B8":"#19213D",fontWeight:ce?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Ge=ve,Ge?r.safeStringify(Ge).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(u.default.Fragment,{children:e},i)}):null)}))}))})),!ce&&n.jsxs(o.AccordionDetails,e.__assign({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[se&&n.jsx(l.MemoizedMarkdown,{content:ae,overlayContent:ue,sxStyles:M,highlights:Le,maintainRelativeOrder:k,highlightBg:Be,suppressHighlightBg:re,deviationBadges:He,collisionKey:ne}),(A.subsections||[]).map(function(e,n){return V({section:e,keyPath:"".concat(w,"-").concat(n),depth:0,columnKey:R,parentNodeId:B,sectionOffset:ye})})]}))]})),F&&(null==Ue?void 0:Ue.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==Ue?void 0:Ue.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"===R?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===R?{right:"0px"}:{left:"0px"})},{children:n.jsx(t.ChevronDown,{color:(null===(y=null==Ue?void 0:Ue.showBelowRef)||void 0===y?void 0:y.current)?window.getComputedStyle(Ue.showBelowRef.current).color:void 0})}))}))]}),"".concat(R,"-sec-").concat(w))};
|
|
2
2
|
//# sourceMappingURL=SectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("tslib"),
|
|
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"),r=require("../CognitiveComparehelpers.js"),a=require("../CognitiveCompareConstants.js");function s(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var d=s(i).default.memo(function(s){var u,c,v,f,g,h,p,_,x,m,b=s.section,y=s.keyPath,S=s.depth,I=void 0===S?0:S,R=s.columnKey,B=void 0===R?"left":R,E=s.parentNodeId,O=void 0===E?"":E,A=s.expandedSubSections,j=s.setExpandedSubSections,P=s.maintainRelativeOrder,k=s.showDeviationBadges,w=void 0!==k&&k,C=s.proposedSections,F=s.existingSections,M=s.treeData,T=s.deviationNumberRegistry,D=s.connectedSections,N=s.activeSideBySideSection,q=s.resolvedMarkdownStyles,V=s.getSubSectionRef,W=s.getSubSectionCompareStyle,z=s.getBadgeRef,G=s.openMoreFunctionsPopup,K=s.openSummaryPopup,H=s.resetSideBySide,L=s.setConnectedSections,U=s.setConnectedLines,J=s.cachedConnectedPositions,Q=s.isProposingFix,X=s.proposingFixNodeId,Y=s.isRedlineFlow,Z=s.sectionOffset,$=null!=N?N:"",nn=(null===(u=b.displayTitle)||void 0===u||u)&&r.hasValue(b.title),en=!!Q&&!!X&&"left"===B&&b.id===X,tn=r.hasMeaningfulRedlineTags(b.content),on="boolean"==typeof Y?Y:tn,ln=tn,rn=on&&tn,an=rn?r.stripRedlineTags(b.content):b.content,sn=rn?b.content:void 0,dn=(null===(c=b.displayContent)||void 0===c||c)&&r.hasValue(an),un=!nn&&!dn,cn=nn?b.title:dn?"No Title Found":"No Matching Section Found",vn=!!A[y],fn=V(B,y),gn=y.split("-").map(Number),hn=gn[0],pn=C[hn],_n=F[hn],xn=y,mn=y,bn=hn,yn=hn,Sn=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(P)if("left"===B){var In=null===(v=null==pn?void 0:pn.refIndexes)||void 0===v?void 0:v[0],Rn=F.findIndex(function(n){return n.selfIndex===In});-1!==Rn&&(_n=F[Rn],yn=Rn)}else{var Bn=null===(f=null==_n?void 0:_n.refIndexes)||void 0===f?void 0:f[0],En=C.findIndex(function(n){return n.selfIndex===Bn});-1!==En&&(pn=C[En],bn=En)}var On=pn,An=_n;if(P)if("left"===B){On=b,xn=y;var jn=Sn(_n,b.id,String(yn));An=(null==jn?void 0:jn.section)||null,mn=(null==jn?void 0:jn.keyPath)||""}else{An=b,mn=y;var Pn=Sn(pn,b.id,String(bn));On=(null==Pn?void 0:Pn.section)||null,xn=(null==Pn?void 0:Pn.keyPath)||""}else for(var kn=1;kn<gn.length;kn++)(null==On?void 0:On.subsections)&&(On=On.subsections[gn[kn]]),(null==An?void 0:An.subsections)&&(An=An.subsections[gn[kn]]);var wn=(xn?W(xn):null)||W(y),Cn=null===(g=null==M?void 0:M.input_index_map)||void 0===g?void 0:g[0],Fn=null===(h=null==M?void 0:M.input_index_map)||void 0===h?void 0:h[1],Mn="left"===B?Fn:Cn,Tn="left"===B?!An:!On,Dn=b.evaluationResult||(null==On?void 0:On.evaluationResult)||(null==An?void 0:An.evaluationResult),Nn=hn+1,qn=b.id||(null==On?void 0:On.id)||(null==An?void 0:An.id);if(P){var Vn=1,Wn=new Map;if(C.forEach(function(n){!n.title&&!n.content||n.id&&Wn.set(n.id,Vn++)}),"left"===B)Nn=Wn.get(null==pn?void 0:pn.id)||hn+1;else{var zn=C.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(null==_n?void 0:_n.selfIndex)});if(zn.length>0)Nn=Wn.get(zn[0].id)||hn+1;else for(var Gn=Vn,Kn=function(n){if(!n.title&&!n.content)return"continue";var e=C.some(function(e){var i;return null===(i=e.refIndexes)||void 0===i?void 0:i.includes(n.selfIndex)});if(!e){if(n.id===(null==_n?void 0:_n.id))return Nn=Gn,"break";Gn++}},Hn=0,Ln=F;Hn<Ln.length;Hn++){if("break"===Kn(Ln[Hn]))break}}}var Un=null!==(x=null===(_=null===(p=null==Dn?void 0:Dn.evaluation_outputs)||void 0===p?void 0:p.metadata)||void 0===_?void 0:_.label_color)&&void 0!==x?x:a.DEFAULT_DEVIAION_COLOR,Jn=r.generateColorPalette(Un).highlightBg,Qn=(null==Dn?void 0:Dn.deviations)||{},Xn=Object.entries(Qn).map(function(n){var e=n[0],i=n[1],t="".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(e);return{deviationKey:e,deviationMap:i,refId:t,currentIndex:T[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});Xn.sort(function(n,e){return n.currentIndex-e.currentIndex});var Yn=Xn.map(function(e){var i,t,o,l=e.deviationKey,a=e.deviationMap,s=e.refId,d=e.currentIndex;P&&void 0!==Z&&(d-=Z);var u=a[O],c=r.isMissingStr(u);if(c)u="";else if(!u)return null;var v=a[Mn],f=Tn||r.isMissingStr(v),g="".concat(Nn,".").concat(d),h="".concat(qn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(l).concat(r.DEVIATION_BADGE_SEPARATOR).concat(xn).concat(r.DEVIATION_BADGE_SEPARATOR).concat(mn),p=(null==a?void 0:a.evaluation_outputs)||(null==Dn?void 0:Dn.evaluation_outputs),_=null!==(i=null==p?void 0:p.output_value)&&void 0!==i?i:null,x=null!==(o=null===(t=null==p?void 0:p.metadata)||void 0===t?void 0:t.label_color)&&void 0!==o?o:Un,m=r.generateColorPalette(x),b=n.__assign({},m),y=(null==a?void 0:a.deviation_summary)?{deviation_summary:a.deviation_summary||(null==Dn?void 0:Dn.deviation_summary),deviation_title:(null==a?void 0:a.deviation_title)||(null==Dn?void 0:Dn.deviation_title),deviation_impact:(null==a?void 0:a.deviation_impact)||(null==Dn?void 0:Dn.deviation_impact),deviation_explanation:(null==a?void 0:a.deviation_explanation)||(null==Dn?void 0:Dn.deviation_explanation),evaluation_outputs:p,cognitive_decisioning:(null==a?void 0:a.cognitive_decisioning)||(null==Dn?void 0:Dn.cognitive_decisioning)}:null,S=0,I=an||"";if(u&&I){var R=I.split(/\n{2,}/),E=R.findIndex(function(n){return n.includes(u)});if(-1!==E){var A=Object.entries(Qn).filter(function(n){n[0];var e=n[1][O];return e&&R[E].includes(e)}).sort(function(n,e){return R[E].indexOf(n[1][O])-R[E].indexOf(e[1][O])}),j=A.filter(function(n){n[0];var e=n[1][O];return e&&(e.includes(u)||u.includes(e))});j.length>1&&(S=Math.max(0,j.findIndex(function(n){return n[0]===l})))}}return{id:s,actionId:h,label:g,highlight:u,side:B,style:b,stackIndex:S,score:_,isConnected:D.has(h),isOrphan:f,isMissingClause:c,badgeRef:z(B,s),onClick:function(e){e.stopPropagation();var i=On?n.__assign(n.__assign({},On),{title:(null==pn?void 0:pn.title)||(null==On?void 0:On.title)||""}):{id:"orphan-left",title:"",content:""},t=An?n.__assign(n.__assign({},An),{title:(null==_n?void 0:_n.title)||(null==An?void 0:An.title)||""}):{id:"orphan-right",title:"",content:""};G(e,i,f,t,h,b)},onSummaryClick:function(n){n.stopPropagation(),K(n,h,f,y)}}}).filter(Boolean).sort(function(n,e){return parseFloat(n.label)-parseFloat(e.label)}),Zn=w||!on&&en,$n=Zn?Yn:[],ne=Zn?$n.map(function(n){return n.highlight}).filter(Boolean):[],ee=i.useRef(!1);i.useEffect(function(){vn||(ee.current=!1)},[vn]),i.useEffect(function(){if(vn&&!ee.current){var n=setTimeout(function(){var n,e;ee.current=!0;var i=null===(e=null===(n=Yn[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)}}},[vn,Yn]);var ie=Yn.find(function(n){return D.has(n.actionId)}),te=!!ie;if(!(nn||dn||b.subsections&&0!==b.subsections.length))return null;var oe=(null===(m=null==ie?void 0:ie.style)||void 0===m?void 0:m.badgeBorder)||(null==wn?void 0:wn.badgeBorder),le=te&&oe?{borderRadius:"4px",outline:"2px solid ".concat(oe),outlineOffset:"1px"}:{};return nn?e.jsx(t.Box,n.__assign({ref:fn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e.jsx(t.Box,n.__assign({sx:n.__assign({width:"100%"},le)},{children:e.jsxs(t.Accordion,n.__assign({disableGutters:!0,expanded:!un&&vn,onChange:function(){if(!un){if(vn){var e=String(N||""),i=e.includes(xn)||e.includes(mn);i||D.forEach(function(n){(String(n).includes(xn)||String(n).includes(mn))&&(i=!0)}),i&&(H(),L(new Set),U([]),J.current=[])}j(function(e){var i;return n.__assign(n.__assign({},e),((i={})[y]=!e[y],i))})}},sx:{mt:0,boxShadow:"none",border:un?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e.jsx(t.AccordionSummary,n.__assign({expandIcon:un?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:un?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:cn||"Untitled Subsection"}))})),!un&&e.jsxs(t.AccordionDetails,n.__assign({sx:{pt:0,pb:1,minWidth:0}},{children:[dn&&e.jsx(l.MemoizedMarkdown,{content:an,overlayContent:sn,sxStyles:q,deviationBadges:$n,maintainRelativeOrder:P,highlightBg:Jn,suppressHighlightBg:ln,highlights:ne,collisionKey:$}),(b.subsections||[]).map(function(i,t){return e.jsx(d,n.__assign({},s,{section:i,keyPath:"".concat(y,"-").concat(t),depth:I+1}),"".concat(y,"-").concat(t))})]}))]}))}))})):e.jsx(t.Box,n.__assign({ref:fn,sx:{mt:0===I?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!un&&e.jsxs(t.Box,n.__assign({sx:n.__assign({width:"100%"},le)},{children:[dn&&e.jsx(l.MemoizedMarkdown,{content:an,overlayContent:sn,sxStyles:q,deviationBadges:$n,maintainRelativeOrder:P,highlightBg:Jn,suppressHighlightBg:ln,highlights:ne,collisionKey:$}),(b.subsections||[]).map(function(i,t){return e.jsx(d,n.__assign({},s,{section:i,keyPath:"".concat(y,"-").concat(t),depth:I+1,sectionOffset:Z}),"".concat(y,"-").concat(t))})]}))}))});exports.default=d;
|
|
2
2
|
//# sourceMappingURL=SubSectionAccordion.js.map
|