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