@e-llm-studio/citation 0.0.207 → 0.0.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  7. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  8. package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
  9. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  10. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  11. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  12. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  13. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  14. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts +2 -0
  15. package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
  16. package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts +1 -0
  17. package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
  18. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  19. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  20. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  21. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +6 -1
  22. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  23. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n}from"tslib";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as c}from"react";import{Box as a,Snackbar as s,Alert as d,Tooltip as v,Typography as f}from"@mui/material";import{ChevronDown as p}from"lucide-react";import{ButtonCognitiveIcon as g}from"../../assests/svg/ButtonCognitiveIcon.js";import h from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as S,generateColorPalette as x,findKeyPathByNodeId as R,DEVIATION_BADGE_SEPARATOR as y,hasMeaningfulRedlineTags as b,scrollAndHighlightClause as C}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as w,DEFAULT_FIELD_CONFIG as B,DEFAULT_COMPARISON_CONFIG as _}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as E,EMPTY_SUMMARY_POPUP_STATE as F,DEFAULT_COMPONENT_HEADER_TEXT as I}from"./CognitiveCompareConstants.js";import T from"./CognitivePopup.js";import A from"./MoreFunctionsPopup.js";import D from"./LoaderComponent.js";import O from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as k}from"./hooks/useCompareData.js";import{useComparePopups as L}from"./hooks/useComparePopups.js";import{useSectionRefs as j}from"./hooks/useSectionRefs.js";import{useAccordionState as P}from"./hooks/useAccordionState.js";import{useDeviationNavigation as N}from"./hooks/useDeviationNavigation.js";import H from"./components/CompareHeader.js";import z from"./components/SubSectionAccordion.js";import M from"./components/LHSSectionRow.js";import q from"./components/RHSSectionRow.js";import W from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as V}from"./CompareContext.js";import{useStyleHelpers as K}from"./hooks/useStyles.js";import{useResizeHandler as J}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Y}from"./hooks/useLinesCalculator.js";import{useSideBySide as X}from"./hooks/useSideBySide.js";import $ from"./components/SvgConnectors.js";var U=function(U){var G,Q,Z,ee,ne,ie,te,oe,re,le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,ye,be,Ce,we,Be,_e,Ee,Fe,Ie,Te,Ae,De=U.componentHeaderText,Oe=void 0===De?I:De,ke=U.treeData,Le=U.comparisonConfig,je=U.leftColumnTitleText,Pe=U.rightColumnTitleText,Ne=U.markdownStyles,He=U.resetTrigger,ze=U.displayConfig,Me=void 0===ze?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0}:ze,qe=U.onMaintainRelativeOrderChange,We=U.popupConfig,Ve=U.deviationData,Ke=void 0===Ve?{}:Ve,Je=U.deviationNodeIdToView,Ye=U.resetDeviationNodeId,Xe=U.isProposingFix,$e=void 0!==Xe&&Xe,Ue=U.proposingFixNodeId,Ge=U.isRedlineFlow,Qe=o(Me.maintainRelativeOrder),Ze=Qe[0],en=Qe[1],nn=null!==(G=null==Me?void 0:Me.expandLevels)&&void 0!==G?G:0,tn=!!(null==Me?void 0:Me.expandAllSections),on=!!Ze||!!(null==Me?void 0:Me.showDeviationBadges),rn=o(!1),ln=rn[0],un=rn[1],cn=o(null),an=cn[0],sn=cn[1],dn=o(null===(Z=null!==(Q=null==ke?void 0:ke.newEvaluationResult)&&void 0!==Q?Q:null==Me?void 0:Me.enableDeviationSchemaBackwardCompatibility)||void 0===Z||Z)[0],vn=o(new Set),fn=vn[0],pn=vn[1],gn=o([]),hn=gn[0],mn=gn[1],Sn=o(!1),xn=Sn[0],Rn=Sn[1],yn=r(null),bn=r(null),Cn=r(null),wn=r(null),Bn=r(null),_n=r(!1),En=r(null),Fn=r({}),In=r([]),Tn=r(function(){}),An=r(null),Dn=r(function(){}),On=l(function(){return JSON.stringify(Ke||{})},[JSON.stringify(Ke)]),kn=l(function(){return Ke||{}},[On]),Ln=l(function(){return(null==ke?void 0:ke.cognitive_decisioning)||{}},[ke]),jn=l(function(){return e(e({},w),Ne)},[Ne]),Pn=r(null),Nn=r(null),Hn=r(null),zn=r(null),Mn=r(null),qn=r(null),Wn=r(null),Vn=r(null),Kn=r(null),Jn=r(null),Yn=L(Pn),Xn=Yn.cognitivePopup,$n=Yn.setCognitivePopup,Un=Yn.moreFunctions,Gn=Yn.setMoreFunctions,Qn=Yn.position,Zn=Yn.setPosition,ei=Yn.activeBadgeId,ni=Yn.summaryPopup,ii=Yn.setSummaryPopup,ti=Yn.closeSummaryPopup,oi=Yn.setActiveBadgeId,ri=Yn.popupRef,li=Yn.handleOpenCognitiveCompare,ui=Yn.openCognitivePopupFromState,ci=Yn.closeCognitivePopup,ai=Yn.closeMoreFunctionsPopup,si=l(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==Le?void 0:Le.fields)&&void 0!==e?e:B,thresholds:{high:null!==(i=null===(n=null==Le?void 0:Le.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:_.thresholds.high,medium:null!==(o=null===(t=null==Le?void 0:Le.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:_.thresholds.medium,exact:null!==(l=null===(r=null==Le?void 0:Le.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:_.thresholds.exact}}},[Le]),di=o(null),vi=di[0];di[1];var fi=null===(ie=null===(ee=null==ke?void 0:ke.documents)||void 0===ee?void 0:ee[null===(ne=null==ke?void 0:ke.input_index_map)||void 0===ne?void 0:ne[0]])||void 0===ie?void 0:ie.title,pi=null===(re=null===(te=null==ke?void 0:ke.documents)||void 0===te?void 0:te[null===(oe=null==ke?void 0:ke.input_index_map)||void 0===oe?void 0:oe[1]])||void 0===re?void 0:re.title,gi=m(je||fi||"Uploaded Contract"),hi=null===(ae=null===(ce=null===(le=null==ke?void 0:ke.documents)||void 0===le?void 0:le[null===(ue=null==ke?void 0:ke.input_index_map)||void 0===ue?void 0:ue[0]])||void 0===ce?void 0:ce.metadata)||void 0===ae?void 0:ae.file_name,mi=m(hi),Si=null===(fe=null===(ve=null===(se=null==ke?void 0:ke.documents)||void 0===se?void 0:se[null===(de=null==ke?void 0:ke.input_index_map)||void 0===de?void 0:de[1]])||void 0===ve?void 0:ve.metadata)||void 0===fe?void 0:fe.file_name,xi=m(Si),Ri=m(Pe||pi||"Reference Template"),yi=k(ke,Ze,kn,si,dn),bi=yi.activeProposed,Ci=yi.existingRule,wi=yi.proposedSections,Bi=yi.existingSections,_i=yi.visibleFields,Ei=yi.parentDeviationRecord,Fi=yi.deviationNumberRegistry,Ii=yi.parseError;u(function(){Ii&&sn("Failed to load comparison: ".concat(Ii))},[Ii]);var Ti=wi.length>0||Bi.length>0,Ai=l(function(){if(!Ge)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";b(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(wi),i(Bi),"".concat(e,":").concat(n)},[Ge,wi,Bi]);u(function(){if(wi.length||Bi.length)if(tn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Ze?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(wi,"left"),i(Bi,"right"),vt(e),pt(n)}else if(nn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=Ze?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(wi,"left",nn),r(Bi,"right",nn),vt(t),pt(o)}},[tn,nn,wi,Bi,Ze]);var Di=j(_i.map(function(e){return e.key}),Math.max(wi.length,Bi.length)),Oi=Di.leftRefs,ki=Di.rightRefs,Li=Di.sectionLeftRefs,ji=Di.sectionRightRefs,Pi=Di.lhsBadgeRefs,Ni=Di.rhsBadgeRefs,Hi=Di.sectionRightRowRefs,zi=Di.subSectionLeftRefs,Mi=Di.subSectionRightRefs,qi=Di.sectionRowRefs,Wi=Di.getSectionRowRef,Vi=Di.getSubSectionRef,Ki=Di.getBadgeRef,Ji=X({maintainRelativeOrder:Ze,proposedSections:wi,existingSections:Bi,leftContainerRef:Vn,rightContainerRef:Hn,scrollContainerRef:Pn,sectionLeftRefs:Li,sectionRightRefs:ji,subSectionLeftRefs:zi,subSectionRightRefs:Mi,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni,sectionRowRefs:qi,sectionRightRowRefs:Hi,rhsTopSpacerRef:zn,rhsBottomSpacerRef:Mn,lhsTopSpacerRef:qn,lhsBottomSpacerRef:Wn,calculateLinesRef:Tn,setConnectedSections:pn,setConnectedLines:mn,cachedConnectedPositions:In,closeMoreFunctionsPopup:ai,setErrorToast:sn,moreFunctions:Un,closeSummaryPopup:ti}),Yi=Ji.isSideBySide,Xi=Ji.isArrowVisible,$i=Ji.setIsArrowVisible,Ui=Ji.isResizing,Gi=Ji.setIsResizing,Qi=Ji.isSideBySideLoading,Zi=Ji.activeSideBySideSection,et=Ji.scrollLock,nt=Ji.sideBySideCacheRef,it=Ji.isSideBySideRef,tt=Ji.activeSideBySideRightSectionRef,ot=Ji.activeSideBySideSectionRef,rt=Ji.sideBySideLineRef,lt=Ji.highlightedClauseRefs,ut=Ji.clearClauseHighlight,ct=Ji.resetSideBySide,at=Ji.activateSideBySide,st=P({maintainRelativeOrder:!!Ze,proposedSections:wi,existingSections:Bi,activeSideBySideSection:Zi,connectedSections:fn,resetSideBySide:ct,setConnectedSections:pn,setConnectedLines:mn,cachedConnectedPositions:In,svgContainerRef:yn,isAnimatingRef:_n,animationTimerRef:En,calculateLinesRef:Tn,sectionLeftRefs:Li,sectionRightRefs:ji,subSectionLeftRefs:zi,subSectionRightRefs:Mi}),dt=st.expandedSections,vt=st.setExpandedSections,ft=st.expandedSubSections,pt=st.setExpandedSubSections,gt=st.handleSubSectionToggle,ht=st.toggleSection,mt=st.forceExpandCrossWiredSections,St=function(){var e,n;if(null!=Zi){var i=null===(e=Li.current[Zi])||void 0===e?void 0:e.current,t=null===(n=ji.current[Zi])||void 0===n?void 0:n.current,o=Hn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},xt=c(function(e){null==e||e.stopPropagation(),Rn(function(e){var n=!e;return n&&requestAnimationFrame(function(){St()}),n})},[St]);u(function(){Ge&&"off"!==Ai&&"0:0"!==Ai&&(nt.current=null,In.current=[],requestAnimationFrame(function(){var e;null===(e=Tn.current)||void 0===e||e.call(Tn)}))},[Ge,Ai]);var Rt=l(function(){var e=new Map,n=new Map,i=1;if(Ze)wi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Bi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=wi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(wi.length,Bi.length),o=0;o<t;o++){var r=wi[o],l=Bi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[wi,Bi,Ze]),yt=Ci.analysis,bt=m(null===(ge=null===(pe=null==yt?void 0:yt.rule_difference_comparison)||void 0===pe?void 0:pe.summary)||void 0===ge?void 0:ge.overall_summary),Ct=!!bt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),wt=null!==(he=null==ke?void 0:ke.base_root_id)&&void 0!==he?he:"-1";null==ke||ke[wt];var Bt=dn?null!==(Fe=null!==(Be=Ke&&(null===(we=null==Ke?void 0:Ke[wt])||void 0===we?void 0:we.evaluation_result))&&void 0!==Be?Be:null===(Ee=null===(_e=null==ke?void 0:ke.nodes)||void 0===_e?void 0:_e[wt])||void 0===Ee?void 0:Ee.evaluation_result)&&void 0!==Fe?Fe:null:null!==(Ce=null!==(xe=Ke&&(null===(Se=null===(me=null==Ke?void 0:Ke[wt])||void 0===me?void 0:me.evaluation_result)||void 0===Se?void 0:Se[0]))&&void 0!==xe?xe:null===(be=null===(ye=null===(Re=null==ke?void 0:ke.nodes)||void 0===Re?void 0:Re[wt])||void 0===ye?void 0:ye.evaluation_result)||void 0===be?void 0:be[0])&&void 0!==Ce?Ce:null,_t=S(Bt),Et=x(null!==(Ae=null===(Te=null===(Ie=null==Bt?void 0:Bt.evaluation_outputs)||void 0===Ie?void 0:Ie.metadata)||void 0===Te?void 0:Te.label_color)&&void 0!==Ae?Ae:E),Ft=r(ct);u(function(){Ft.current=ct},[ct]);var It=r(ci);u(function(){It.current=ci},[ci]);var Tt=c(function(e,n,i,t,o,r){return Lo.current(e,n,i,t,o,r)},[]),At=c(function(e,n,i,t,o){return jo.current(e,n,i,t,o)},[]),Dt=c(function(){return Po.current()},[]),Ot=c(function(e,n){return No.current(e,n)},[]),kt=c(function(e){return Ho.current(e)},[]),Lt=c(function(e){return zo.current(e)},[]),jt=c(function(){return Mo.current()},[]),Pt=c(function(){var e,n;ut(),null===(e=Ft.current)||void 0===e||e.call(Ft),Rn(!1),pn(new Set),mn([]),In.current=[],io([]),oo(null),ii(F),null===(n=It.current)||void 0===n||n.call(It),requestAnimationFrame(function(){var e;null===(e=Tn.current)||void 0===e||e.call(Tn)})},[]),Nt=r(Pt);u(function(){Nt.current=Pt},[Pt]),u(function(){He&&Nt.current()},[He]);var Ht=l(function(){return{documents:null==ke?void 0:ke.documents,input_index_map:null==ke?void 0:ke.input_index_map}},[JSON.stringify(null==ke?void 0:ke.documents),JSON.stringify(null==ke?void 0:ke.input_index_map)]),zt=r(ke);u(function(){zt.current=ke},[ke]);var Mt=r(Ln);u(function(){Mt.current=Ln},[Ln]);var qt=c(function(n,i,t,o,r,l,u){var c,a,s,d,v=m(null==i?void 0:i.id)||m(null==t?void 0:t.id)||"",f=(v?null===(c=Mt.current)||void 0===c?void 0:c[v]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},p=null!==(s=null===(a=qi.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==Me?void 0:Me.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:f,anchorEl:n,sectionAnchorEl:p,badgeStyle:l||null,sectionIdx:o,docData:Ht,deviationData:function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[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 i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(y)))return u(l);var c=o.split(y)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[Ht]),Wt=c(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Un.open&&Un.sectionIdx===o)ai();else{var u=e.currentTarget,c="left";(null===(l=Hn.current)||void 0===l?void 0:l.contains(u))&&(c="right");ut(),it.current&&ct(),pn(new Set),mn([]),In.current=[],ci(),ni.open?ho():ti(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(y)){var r=o.split(y),l="".concat(r[0]).concat(y).concat(r[1]);return"right"===c?null===(e=Ni.current[l])||void 0===e?void 0:e.current:null===(n=Pi.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=Ni.current[o])||void 0===i?void 0:i.current:null===(t=Pi.current[o])||void 0===t?void 0:t.current}()||u;Gn(qt(e,n,t,o,i,r))})}},[Un.open,Un.sectionIdx,ai,ti,qt]),Vt=c(function(){var e=Un.sectionIdx;Un.isOrphan,ai(),ti(),null!==e&&(mt(e),ut(),it.current&&ct(),mn([]),In.current=[],pn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Tn.current&&Tn.current()},50))},[Un.sectionIdx,Un.isOrphan,ai,ti,ct]),Kt=c(function(){var e=Bn.current;if(e){Bn.current=null;var n=wi.findIndex(function(n){return n.id===e}),i=Bi.findIndex(function(n){return n.id===e}),t=-1===n?R(wi,e):null,o=-1===i?R(Bi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(lt.current.add(r),C(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Ze)-1!==r&&Vn.current&&c(function(){return u(n,t,Li,zi)},Vn.current),-1!==l&&Hn.current&&c(function(){return u(i,o,ji,Mi)},Hn.current);else{var a=Pn.current;if(!a)return;c(function(){return-1!==r?u(n,t,Li,zi):u(i,o,ji,Mi)},a)}}},[wi,Bi,Ze,Li,ji,zi,Mi,Vn,Hn,Pn]),Jt=c(function(n){if(n){ut(),ct(),pn(new Set),mn([]),In.current=[],ti(),ci();var i=wi.findIndex(function(e){return e.id===n}),t=Bi.findIndex(function(e){return e.id===n}),o=-1===i?R(wi,n):null,r=-1===t?R(Bi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;Bn.current=n,vt(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=Ze?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=Ze?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),pt(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){Bn.current===n&&Yt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[wi,Bi,Ze,vt,pt,ct,ti,ci]),Yt=r(Kt);u(function(){Yt.current=Kt},[Kt]);var Xt=r(null);u(function(){if(vi){var e=si.fields.find(function(e){return e.analysisKey===vi||e.key===vi});if(e){var n=Oi.current[e.key]||ki.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[vi,si.fields]);var $t=c(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==yt?void 0:yt.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===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.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}},[yt]),Ut=K({proposedSections:wi,existingSections:Bi,maintainRelativeOrder:Ze,cognitiveMap:Ln,deviationData:kn,treeData:ke,resolvedComparisonConfig:si}),Gt=Ut.getSectionCompareStyle,Qt=Ut.getSubSectionCompareStyle,Zt=Ut.getDeviationStyleByKey,eo=Y({containerRef:bn,leftContainerRef:Vn,rightContainerRef:Hn,svgContainerRef:yn,pathRefs:Fn,leftHeaderRef:Cn,rightHeaderRef:wn,proposedSections:wi,existingSections:Bi,visibleFields:_i,leftRefs:Oi,rightRefs:ki,sectionLeftRefs:Li,sectionRightRefs:ji,subSectionLeftRefs:zi,subSectionRightRefs:Mi,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni,sectionRowRefs:qi,expandedSections:dt,expandedSubSections:ft,connectedSections:fn,isSideBySide:Yi,activeSideBySideSection:Zi,maintainRelativeOrder:Ze,cognitiveMap:Ln,getSectionCompareStyle:Gt,getSubSectionCompareStyle:Qt,getDeviationStyleByKey:Zt,isArrowVisible:Xi,isAnimatingRef:_n,isSideBySideRef:it,sideBySideCacheRef:nt,sideBySideLineRef:rt,activeSideBySideSectionRef:ot,activeSideBySideRightSectionRef:tt,connectedLines:hn,setConnectedLines:mn,cachedConnectedPositions:In,calculateLinesRef:Tn,resizeTimerRef:An,scrollLock:et,scrollSyncLocked:xn,handleResizeRef:Dn,activeProposed:bi,existingRule:Ci,analysisData:yt,pendingScrollTargetRef:Kn,pendingScrollCallbackRef:Jn,resolvedComparisonConfig:si,getFieldData:$t}),no=eo.lines,io=eo.setLines,to=eo.overallConnector,oo=eo.setOverallConnector,ro=eo.svgDimensions,lo=eo.handleColumnScroll;u(function(){ni.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Tn.current)||void 0===e||e.call(Tn)})})},[ni.anchorEl,xn]);var uo=c(function(){ut(),Rn(!1),vt({}),pt({}),ct(),pn(new Set),mn([]),In.current=[],ti(),ci(),ai(),requestAnimationFrame(function(){Tn.current&&Tn.current()})},[vt,pt,ct,ti,ci,ai]);u(function(){Yi||0!==fn.size||Rn(!1)},[Yi,fn]);var co=l(function(){return Object.values(dt).some(Boolean)||Object.values(ft).some(Boolean)},[dt,ft]),ao=r(null),so=r(0),vo=r(0),fo=r(0),po=J({timerRef:ao,ruleComponentRef:Nn,scrollContainerRef:Pn,containerRef:bn,maintainRelativeOrder:Ze,proposedSections:wi,existingSections:Bi,isSideBySideRef:it,activeSideBySideSectionRef:ot,activeSideBySideRightSectionRef:tt,sectionRowRefs:qi,sectionRightRowRefs:Hi,sectionLeftRefs:Li,sectionRightRefs:ji,subSectionLeftRefs:zi,subSectionRightRefs:Mi,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni,leftContainerRef:Vn,rightContainerRef:Hn,calculateLinesRef:Tn,handleResizeRef:Dn,setIsResizing:Gi,setIsArrowVisible:$i,sideBySideCacheRef:nt,cachedConnectedPositions:In}).handleResize;u(function(){Dn.current=po},[po,Dn]),u(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.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,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Nn.current&&o.push(e(Nn.current,so,n,function(){return Dn.current()},function(){})),Pn.current&&o.push(e(Pn.current,vo,i,function(){return Dn.current()},function(){return Tn.current()})),bn.current&&o.push(e(bn.current,fo,t,function(){return Dn.current()},function(){return Tn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),u(function(){it.current=Yi},[Yi]),u(function(){ot.current=Zi},[Zi]);var go=c(function(){var e,n=Un.sectionIdx,i=Un.isOrphan;if(ti(),null!=n){var t="left";Un.anchorEl&&(null===(e=Hn.current)||void 0===e?void 0:e.contains(Un.anchorEl))&&(t="right"),mt(n),at(n,i,{sourceSide:t})}},[at,Un.isOrphan,Un.sectionIdx,Un.anchorEl,ti]),ho=c(function(){ti(),ct(),pn(new Set),mn([]),In.current=[]},[ti,ct]),mo=null!==Un.sectionIdx&&fn.has(Un.sectionIdx),So=N({proposedSections:wi,existingSections:Bi,parentDeviationRecord:Ei,expandedSections:dt,maintainRelativeOrder:!!Ze,scrollContainerRef:Pn,leftContainerRef:Vn,rightContainerRef:Hn,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni}),xo=So.showDeviationNavigation,Ro=So.showOpenNodeRef,yo=So.adjustScrollForPopup,bo=c(function(e,n,i,t,o){var r,l="string"==typeof t?m(t).trim():m(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;ci();var c="left";(null===(r=Hn.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(y)){var r=n.split(y),l="".concat(r[0]).concat(y).concat(r[1]);return"right"===c?null===(e=Ni.current[l])||void 0===e?void 0:e.current:null===(i=Pi.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=Ni.current[n])||void 0===t?void 0:t.current:null===(o=Pi.current[n])||void 0===o?void 0:o.current};if(i)return ct(),pn(new Set),mn([]),In.current=[],void(l&&(mt(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));ii({open:!0,anchorEl:e,summary:t,displayImpact:o})})));mt(n),l?setTimeout(function(){at(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,n,i,r=a()||u;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var c=l.top-window.innerHeight/2;Ze?(null===(e=Vn.current)||void 0===e||e.scrollBy({top:c,behavior:"smooth"}),null===(n=Hn.current)||void 0===n||n.scrollBy({top:c,behavior:"smooth"})):null===(i=Pn.current)||void 0===i||i.scrollBy({top:c,behavior:"smooth"})}}ii({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){at(n,i,{toggleIfSame:!1,sourceSide:c})},350)},[at,ci,ii,ct,mt]),Co=l(function(){var e;if(!Je)return null;var n=null===(e=null==Je?void 0:Je.id)||void 0===e?void 0:e.split(":")[0];for(var i in Ei){if((Ei[i]||[]).some(function(e){return e.id===n}))return i}return null},[Je,Ei]),wo=r({id:null,triggerMs:null}),Bo=r(null);u(function(){var i;if(null==Je?void 0:Je.id){var t=Number(Je.trigger),o=wo.current;if((null==o?void 0:o.triggerMs)!==t){if(!(Je.id.includes(":")&&/:\d+$/.test(Je.id)))return wo.current={id:Je.id,triggerMs:t},void Jt(Je.id);var r=null===(i=null==Je?void 0:Je.id)||void 0===i?void 0:i.split(":"),l=r[0],u=r[1],c=null!=u?u:"0";Bo.current!==Je.id&&(ti(),ci(),ct(),pn(new Set),mn([]),In.current=[],Bo.current=Je.id);var a=!1,s=0,d=null,v=150,f=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},p=function(){var i,o,r,u;if(!a){var g=function(){wo.current={id:Je.id,triggerMs:t}},h=null,m=null;for(var S in Ei){var x=Ei[S].find(function(e){return e.id===l});if(x){h=S,m=x;break}}if(m&&h){var R=wi.findIndex(function(e){return e.id===h}),b=Bi.findIndex(function(e){return e.id===h}),C=-1===R&&-1!==b,w=f(wi,m.id),B=f(Bi,m.id);if(w&&!B&&!C){var _=w.split("-"),E=Number(_[0]);if(Ze){var F=null===(o=null===(i=wi[E])||void 0===i?void 0:i.refIndexes)||void 0===o?void 0:o[0],I=Bi.findIndex(function(e){return e.selfIndex===F});-1!==I&&(E=I)}B=n([E],_.slice(1),!0).join("-")}if(w||B){var T=w?Number(w.split("-")[0]):R,A=B?Number(B.split("-")[0]):b,D=A>=0?A:B?Number(B.split("-")[0]):-1,O=wi[T],k=Bi[D],L=O&&!O.title&&!O.content,j=k&&!k.title&&!k.content,P=C||(!w&&!!B||L&&!j);if(P){if(!(Ze?!!dt["right-".concat(A)]:!!dt[String(A)])&&A>=0)return ht(A,"right"),s+=1,void(d=setTimeout(p,450))}else if(!(Ze?!!dt["left-".concat(T)]:!!dt[String(T)])&&T>=0)return ht(T,"left"),s+=1,void(d=setTimeout(p,450));var N=w||"",H=B||"",z="".concat(m.id).concat(y).concat(c).concat(y).concat(N).concat(y).concat(H),M="".concat(m.id).concat(y).concat(c);mt(z);var q,W=null===(r=Pi.current[M])||void 0===r?void 0:r.current,V=null===(u=Ni.current[M])||void 0===u?void 0:u.current,K=P||!W&&!!V,J=K?V:W;if(q=Ze?K?Hn.current:Vn.current:Pn.current,J&&q){var Y=J.getBoundingClientRect();if(0===Y.height)return void((s+=1)<2?d=setTimeout(p,v):g());var X=q.getBoundingClientRect(),$=Y.top-X.top+q.scrollTop-X.height/2+Y.height/2,U=w&&w.includes("-")||B&&B.includes("-"),G=function(){var n,i,t,o,r;if(!a){g();var l=J instanceof Element?window.getComputedStyle(J).color:"";W&&(W.style.transition="box-shadow 300ms ease-in-out",W.style.boxShadow="0 0 10px ".concat(l)),V&&(V.style.transition="box-shadow 300ms ease-in-out",V.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){W&&(W.style.boxShadow=""),V&&(V.style.boxShadow="")},2e3);var u=(null===(i=null===(n=m.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===i?void 0:i[c])||m,s=(null===(t=m.evaluationResult)||void 0===t?void 0:t.evaluation_outputs)||m.evaluation_outputs;if(!(!!W&&!!V)){var d=K?(null===(o=Ni.current[U?M:A])||void 0===o?void 0:o.current)||V:(null===(r=Pi.current[U?M:T])||void 0===r?void 0:r.current)||W;return yo(d,function(){ii({open:!0,anchorEl:d,displayImpact:Je.displayImpact,summary:e(e({},u),{evaluation_outputs:s})})},{skipScroll:!0}),void(null==Ye||Ye())}at(z,!1,{toggleIfSame:!1,sourceSide:C?"right":"left",onReady:function(){var n,i;g();var t=K?(null===(n=Ni.current[M])||void 0===n?void 0:n.current)||V:(null===(i=Pi.current[M])||void 0===i?void 0:i.current)||W;ii({open:!0,anchorEl:t,displayImpact:Je.displayImpact,summary:e({},u)}),null==Ye||Ye()}})}};Math.abs(q.scrollTop-$)<=2?G():(Kn.current=$,Jn.current=G,q.scrollTo({top:$,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(Jn.current){Kn.current=null;var e=Jn.current;Jn.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(p,v):g()}else(s+=1)<2?d=setTimeout(p,v):g()}else(s+=1)<2?d=setTimeout(p,v):g()}};return d=setTimeout(p,v),function(){a=!0,d&&clearTimeout(d)}}}},[Je,Ei,wi,Bi,Ze,dt,ht,at,ii,Jt]),u(function(){var n,i,t;if(ni.open){var o=ni.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Pi.current)||r(Ni.current);if(l){var u=(null===(i=Ni.current[l])||void 0===i?void 0:i.current)||(null===(t=Pi.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&ii(function(n){return e(e({},n),{anchorEl:u})})}}}},[ni.open,ni.anchorEl,xn,fn,dt]);var _o=Xn.open,Eo=Xn.sectionIdx,Fo=Xn.isOrphan,Io=Xn.badgeStyle,To=Xn.anchorEl,Ao=Xn.sectionAnchorEl;u(function(){var n;if(_o&&null!=Eo&&Eo!==wt){var i="string"==typeof Eo?Eo.split(y)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(wi,i):null,r=i&&"string"==typeof i?t(Bi,i):null,l="number"==typeof Eo?wi[Eo]||null:o||i&&((null===(n=null==ke?void 0:ke.nodes)||void 0===n?void 0:n[i])||(null==ke?void 0:ke[i]))||null,u="number"==typeof Eo?Bi[Eo]||null:r,c=qt(To,l,u,Eo,Fo,Io);$n(function(n){return n.open?m(n.cognitiveData)===m(c.cognitiveData)&&m(n.deviationData)===m(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[_o,Eo,Fo,Io,To,Ao,wi,Bi,qt]);var Do=c(function(e){var n=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset;return i(z,{section:n,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s})},[]),Oo=l(function(){return wi.map(function(e,n){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Ze?null:i(M,{section:e,idx:n},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[wi]),ko=l(function(){return Bi.map(function(e,n){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Ze?null:i(q,{section:e,idx:n},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Bi]),Lo=r(Wt);u(function(){Lo.current=Wt},[Wt]);var jo=r(bo);u(function(){jo.current=bo},[bo]);var Po=r(ho);u(function(){Po.current=ho},[ho]);var No=r(ht);u(function(){No.current=ht},[ht]);var Ho=r(gt);u(function(){Ho.current=gt},[gt]);var zo=r(Do);u(function(){zo.current=Do},[Do]);var Mo=r(ct);u(function(){Mo.current=ct},[ct]);var qo=l(function(){return{maintainRelativeOrder:!!Ze,showDeviationBadges:on,isProposingFix:$e,proposingFixNodeId:Ue,isRedlineFlow:Ge,isSideBySide:Yi,activeSideBySideSection:Zi,scrollSyncLocked:xn,toggleScrollSyncLocked:xt,summaryPopupAnchorEl:ni.anchorEl,connectedSections:fn,proposedSections:wi,existingSections:Bi,deviationNumberRegistry:Fi,treeData:ke,displayConfig:Me,resolvedMarkdownStyles:jn,unifiedNumbering:Rt,expandedSections:dt,expandedSubSections:ft,setExpandedSubSections:pt,getSectionCompareStyle:Gt,getSubSectionCompareStyle:Qt,getBadgeRef:Ki,getSectionRowRef:Wi,getSubSectionRef:Vi,sectionLeftRefs:Li,sectionRightRefs:ji,sectionRowRefs:qi,sectionRightRowRefs:Hi,subSectionLeftRefs:zi,subSectionRightRefs:Mi,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni,openMoreFunctionsPopup:Tt,handleOpenSummaryPopup:At,openSummaryPopup:At,handleCloseSummaryPopup:Dt,toggleSection:Ot,handleSubSectionToggle:kt,renderSubSectionAccordion:Lt,resetSideBySide:jt,setConnectedSections:pn,setConnectedLines:mn,cachedConnectedPositions:In,showDeviationNavigation:xo,showOpenNodeRef:Ro,deviationNodeIdToView:null==Je?void 0:Je.id,deviationTargetParentId:Co}},[Ze,on,$e,Ue,Ge,Yi,Zi,xn,xt,ni.anchorEl,fn,wi,Bi,Fi,Me,jn,Rt,dt,ft,pt,Gt,Qt,Ki,Wi,Vi,xo,Ro,Je,Co]);return i(V,e({value:qo},{children:t(a,e({ref:Nn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[ln&&i(a,e({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:i(D,{})})),ni.open&&i(W,{open:ni.open,anchorEl:ni.anchorEl,containerEl:Xt.current,clipTopEl:Cn.current,scrollContainerEl:Pn.current,onClose:ho,summary:ni.summary,displayImpact:ni.displayImpact,isScrollLocked:xn}),i(A,{open:Un.open,anchorEl:Un.anchorEl,maintainRelativeOrder:!!Ze,sectionTitle:Un.sectionTitle,referenceSectionTitle:Un.refSectionTitle,onClose:ai,onOpenCognitiveCompare:li,onOpenSideBySide:go,onConnect:Vt,isConnected:mo,isOrphan:Un.isOrphan}),Xn.open&&i(T,{open:Xn.open,popupRef:ri,position:Qn,popupConfig:We,onClose:function(){Zn(null),$n(function(n){return e(e({},n),{open:!1})}),oi(null)},markdownStyles:Ne,sectionTitle:mi,referenceSectionTitle:xi,cognitiveData:Xn.cognitiveData,anchorEl:Xn.anchorEl,sectionAnchorEl:Xn.sectionAnchorEl,scrollContainerEl:Pn.current,badgeStyle:Xn.badgeStyle,docData:Xn.docData,deviationData:Xn.deviationData,isLoading:Xn.isLoading}),i(s,e({open:!!an,autoHideDuration:8e3,onClose:function(){return sn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(d,e({onClose:function(){return sn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:an}))})),i(H,{componentHeaderText:Oe,displayConfig:Me,maintainRelativeOrder:Ze,onCollapseAll:uo,showCollapseAll:co,onToggleView:function(e){un(!0),setTimeout(function(){en(!e),null==qe||qe(!e),Rn(!1),ct(),ti(),pn(new Set),mn([]),In.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){un(!1)},600)})})},50)}}),i(a,e({ref:Pn,onScroll:lo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Ze?"visible":"auto",borderTop:bt&&Ct?"none":"1.5px solid #EEF0F4"}},{children:i(a,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Ze?{flex:1}:{})},{children:t(a,e({ref:bn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Ze?{flex:1,overflow:"visible"}:{})},{children:[i($,{svgContainerRef:yn,svgDimensions:ro,isResizing:Ui,overallConnector:to,rootDeviationStyle:Et,lines:no,isSideBySide:Yi,activeSideBySideSection:Zi,isArrowVisible:Xi,maintainRelativeOrder:Ze,proposedSections:wi,existingSections:Bi,cognitivePopup:Xn,activeBadgeId:ei,closeCognitivePopup:ci,setActiveBadgeId:oi,openCognitivePopupFromState:ui,buildSectionPopupState:qt,connectedLines:hn,pathRefs:Fn}),t(a,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Ze?{flex:1,overflow:"visible"}:{})},{children:[i(a,e({ref:Cn,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:i(v,e({title:gi,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:gi}))}))})),t(a,e({ref:Vn,onScroll:lo,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ze?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:qn,style:{width:"100%",height:"0px",flexShrink:0}}),Ti&&Oo,i("div",{ref:Wn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(a,e({ref:Xt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(a,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(a,e({onClick:function(n){n.stopPropagation(),Xn.open&&ei===wt?ci():(oi(wt),ui(qt(n.currentTarget,{title:"",content:"",evaluationResult:Bt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,wt,!0,e(e({},Et),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Et.badgeBg,color:Et.badgeText,border:"1px solid ".concat(Et.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=_t?_t:i(O,{}),i(a,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(g,{})})),i(p,{size:11,style:{transform:Xn.open&&ei===wt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(a,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Ze?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Qi&&i(h,{sections:11}),i(a,e({ref:wn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(v,e({title:Ri,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ri}))}))})),t(a,e({ref:Hn,onScroll:lo,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ze?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:zn,style:{width:"100%",height:"0px",flexShrink:0}}),Ti&&ko,i("div",{ref:Mn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{U as default};
1
+ import{__assign as e,__spreadArray as n,__awaiter as i,__generator as t}from"tslib";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{useState as l,useRef as u,useMemo as c,useEffect as a,useCallback as s}from"react";import{Box as d,Snackbar as v,Alert as f,Tooltip as p,Typography as g}from"@mui/material";import{ChevronDown as h}from"lucide-react";import{ButtonCognitiveIcon as m}from"../../assests/svg/ButtonCognitiveIcon.js";import S from"./OverlayComponent.js";import{safeStringify as x,extractDeviationScore as R,generateColorPalette as y,findKeyPathByNodeId as b,DEVIATION_BADGE_SEPARATOR as C,hasMeaningfulRedlineTags as w,scrollAndHighlightClause as _,scrollAndWait as B,waitForScrollIdle as F}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as E,DEFAULT_FIELD_CONFIG as I,DEFAULT_COMPARISON_CONFIG as T}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as A,EMPTY_SUMMARY_POPUP_STATE as D,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import k from"./CognitivePopup.js";import O from"./MoreFunctionsPopup.js";import L from"./LoaderComponent.js";import j from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as N}from"./hooks/useCompareData.js";import{useComparePopups as H}from"./hooks/useComparePopups.js";import{useSectionRefs as M}from"./hooks/useSectionRefs.js";import{useAccordionState as z}from"./hooks/useAccordionState.js";import{useDeviationNavigation as q}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import W from"./components/SubSectionAccordion.js";import K from"./components/LHSSectionRow.js";import J from"./components/RHSSectionRow.js";import Y from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as X}from"./CompareContext.js";import{useStyleHelpers as $}from"./hooks/useStyles.js";import{useResizeHandler as U}from"./hooks/useResizeHandler.js";import{useLinesCalculator as G}from"./hooks/useLinesCalculator.js";import{useSideBySide as Q}from"./hooks/useSideBySide.js";import Z from"./components/SvgConnectors.js";var ee=function(ee){var ne,ie,te,oe,re,le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,ye,be,Ce,we,_e,Be,Fe,Ee,Ie,Te,Ae,De,Pe,ke,Oe,Le=ee.componentHeaderText,je=void 0===Le?P:Le,Ne=ee.treeData,He=ee.comparisonConfig,Me=ee.leftColumnTitleText,ze=ee.rightColumnTitleText,qe=ee.markdownStyles,Ve=ee.resetTrigger,We=ee.displayConfig,Ke=void 0===We?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0}:We,Je=ee.onMaintainRelativeOrderChange,Ye=ee.popupConfig,Xe=ee.deviationData,$e=void 0===Xe?{}:Xe,Ue=ee.deviationNodeIdToView,Ge=ee.resetDeviationNodeId,Qe=ee.isProposingFix,Ze=void 0!==Qe&&Qe,en=ee.proposingFixNodeId,nn=ee.isRedlineFlow,tn=l(Ke.maintainRelativeOrder),on=tn[0],rn=tn[1],ln=null!==(ne=null==Ke?void 0:Ke.expandLevels)&&void 0!==ne?ne:0,un=!!(null==Ke?void 0:Ke.expandAllSections),cn=!!on||!!(null==Ke?void 0:Ke.showDeviationBadges),an=l(!1),sn=an[0],dn=an[1],vn=l(null),fn=vn[0],pn=vn[1],gn=l(null===(te=null!==(ie=null==Ne?void 0:Ne.newEvaluationResult)&&void 0!==ie?ie:null==Ke?void 0:Ke.enableDeviationSchemaBackwardCompatibility)||void 0===te||te)[0],hn=l(new Set),mn=hn[0],Sn=hn[1],xn=l([]),Rn=xn[0],yn=xn[1],bn=l(!1),Cn=bn[0],wn=bn[1],_n=u(null),Bn=u(null),Fn=u(null),En=u(null),In=u(null),Tn=u(!1),An=u(null),Dn=u({}),Pn=u([]),kn=u(function(){}),On=u(null),Ln=u(function(){}),jn=c(function(){return JSON.stringify($e||{})},[JSON.stringify($e)]),Nn=c(function(){return $e||{}},[jn]),Hn=c(function(){return(null==Ne?void 0:Ne.cognitive_decisioning)||{}},[Ne]),Mn=c(function(){return e(e({},E),qe)},[qe]),zn=u(null),qn=u(null),Vn=u(null),Wn=u(null),Kn=u(null),Jn=u(null),Yn=u(null),Xn=u(null),$n=u(null),Un=u(null),Gn=H(zn),Qn=Gn.cognitivePopup,Zn=Gn.setCognitivePopup,ei=Gn.moreFunctions,ni=Gn.setMoreFunctions,ii=Gn.position,ti=Gn.setPosition,oi=Gn.activeBadgeId,ri=Gn.summaryPopup,li=Gn.setSummaryPopup,ui=Gn.closeSummaryPopup,ci=Gn.setActiveBadgeId,ai=Gn.popupRef,si=Gn.handleOpenCognitiveCompare,di=Gn.openCognitivePopupFromState,vi=Gn.closeCognitivePopup,fi=Gn.closeMoreFunctionsPopup,pi=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==He?void 0:He.fields)&&void 0!==e?e:I,thresholds:{high:null!==(i=null===(n=null==He?void 0:He.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:T.thresholds.high,medium:null!==(o=null===(t=null==He?void 0:He.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:T.thresholds.medium,exact:null!==(l=null===(r=null==He?void 0:He.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:T.thresholds.exact}}},[He]),gi=l(null),hi=gi[0];gi[1];var mi=null===(le=null===(oe=null==Ne?void 0:Ne.documents)||void 0===oe?void 0:oe[null===(re=null==Ne?void 0:Ne.input_index_map)||void 0===re?void 0:re[0]])||void 0===le?void 0:le.title,Si=null===(ae=null===(ue=null==Ne?void 0:Ne.documents)||void 0===ue?void 0:ue[null===(ce=null==Ne?void 0:Ne.input_index_map)||void 0===ce?void 0:ce[1]])||void 0===ae?void 0:ae.title,xi=x(Me||mi||"Uploaded Contract"),Ri=null===(fe=null===(ve=null===(se=null==Ne?void 0:Ne.documents)||void 0===se?void 0:se[null===(de=null==Ne?void 0:Ne.input_index_map)||void 0===de?void 0:de[0]])||void 0===ve?void 0:ve.metadata)||void 0===fe?void 0:fe.file_name,yi=x(Ri),bi=null===(me=null===(he=null===(pe=null==Ne?void 0:Ne.documents)||void 0===pe?void 0:pe[null===(ge=null==Ne?void 0:Ne.input_index_map)||void 0===ge?void 0:ge[1]])||void 0===he?void 0:he.metadata)||void 0===me?void 0:me.file_name,Ci=x(bi),wi=x(ze||Si||"Reference Template"),_i=N(Ne,on,Nn,pi,gn),Bi=_i.activeProposed,Fi=_i.existingRule,Ei=_i.proposedSections,Ii=_i.existingSections,Ti=_i.visibleFields,Ai=_i.parentDeviationRecord,Di=_i.deviationNumberRegistry,Pi=_i.deviationParentRegistry,ki=_i.parseError;a(function(){ki&&pn("Failed to load comparison: ".concat(ki))},[ki]);var Oi=Ei.length>0||Ii.length>0,Li=c(function(){if(!nn)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";w(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(Ei),i(Ii),"".concat(e,":").concat(n)},[nn,Ei,Ii]);a(function(){if(Ei.length||Ii.length)if(un){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=on?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(Ei,"left"),i(Ii,"right"),mt(e),xt(n)}else if(ln>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=on?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(Ei,"left",ln),r(Ii,"right",ln),mt(t),xt(o)}},[un,ln,Ei,Ii,on]);var ji=M(Ti.map(function(e){return e.key}),Math.max(Ei.length,Ii.length)),Ni=ji.leftRefs,Hi=ji.rightRefs,Mi=ji.sectionLeftRefs,zi=ji.sectionRightRefs,qi=ji.lhsBadgeRefs,Vi=ji.rhsBadgeRefs,Wi=ji.sectionRightRowRefs,Ki=ji.subSectionLeftRefs,Ji=ji.subSectionRightRefs,Yi=ji.sectionRowRefs,Xi=ji.getSectionRowRef,$i=ji.getSubSectionRef,Ui=ji.getBadgeRef,Gi=Q({maintainRelativeOrder:on,proposedSections:Ei,existingSections:Ii,leftContainerRef:Xn,rightContainerRef:Vn,scrollContainerRef:zn,sectionLeftRefs:Mi,sectionRightRefs:zi,subSectionLeftRefs:Ki,subSectionRightRefs:Ji,lhsBadgeRefs:qi,rhsBadgeRefs:Vi,sectionRowRefs:Yi,sectionRightRowRefs:Wi,rhsTopSpacerRef:Wn,rhsBottomSpacerRef:Kn,lhsTopSpacerRef:Jn,lhsBottomSpacerRef:Yn,calculateLinesRef:kn,setConnectedSections:Sn,setConnectedLines:yn,cachedConnectedPositions:Pn,closeMoreFunctionsPopup:fi,setErrorToast:pn,moreFunctions:ei,closeSummaryPopup:ui}),Qi=Gi.isSideBySide,Zi=Gi.isArrowVisible,et=Gi.setIsArrowVisible,nt=Gi.isResizing,it=Gi.setIsResizing,tt=Gi.isSideBySideLoading,ot=Gi.activeSideBySideSection,rt=Gi.scrollLock,lt=Gi.sideBySideCacheRef,ut=Gi.isSideBySideRef,ct=Gi.activeSideBySideRightSectionRef,at=Gi.activeSideBySideSectionRef,st=Gi.sideBySideLineRef,dt=Gi.highlightedClauseRefs,vt=Gi.clearClauseHighlight,ft=Gi.resetSideBySide,pt=Gi.activateSideBySide,gt=z({maintainRelativeOrder:!!on,proposedSections:Ei,existingSections:Ii,activeSideBySideSection:ot,connectedSections:mn,resetSideBySide:ft,setConnectedSections:Sn,setConnectedLines:yn,cachedConnectedPositions:Pn,svgContainerRef:_n,isAnimatingRef:Tn,animationTimerRef:An,calculateLinesRef:kn,sectionLeftRefs:Mi,sectionRightRefs:zi,subSectionLeftRefs:Ki,subSectionRightRefs:Ji}),ht=gt.expandedSections,mt=gt.setExpandedSections,St=gt.expandedSubSections,xt=gt.setExpandedSubSections,Rt=gt.handleSubSectionToggle,yt=gt.toggleSection,bt=gt.forceExpandCrossWiredSections,Ct=function(){var e,n;if(null!=ot){var i=null===(e=Mi.current[ot])||void 0===e?void 0:e.current,t=null===(n=zi.current[ot])||void 0===n?void 0:n.current,o=Vn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},wt=s(function(e){null==e||e.stopPropagation(),wn(function(e){var n=!e;return n&&requestAnimationFrame(function(){Ct()}),n})},[Ct]);a(function(){nn&&"off"!==Li&&"0:0"!==Li&&(lt.current=null,Pn.current=[],requestAnimationFrame(function(){var e;null===(e=kn.current)||void 0===e||e.call(kn)}))},[nn,Li]);var _t=c(function(){var e=new Map,n=new Map,i=1;if(on)Ei.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Ii.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=Ei.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(Ei.length,Ii.length),o=0;o<t;o++){var r=Ei[o],l=Ii[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[Ei,Ii,on]),Bt=Fi.analysis,Ft=x(null===(xe=null===(Se=null==Bt?void 0:Bt.rule_difference_comparison)||void 0===Se?void 0:Se.summary)||void 0===xe?void 0:xe.overall_summary),Et=!!Ft.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),It=null!==(Re=null==Ne?void 0:Ne.base_root_id)&&void 0!==Re?Re:"-1";null==Ne||Ne[It];var Tt=gn?null!==(De=null!==(Ie=$e&&(null===(Ee=null==$e?void 0:$e[It])||void 0===Ee?void 0:Ee.evaluation_result))&&void 0!==Ie?Ie:null===(Ae=null===(Te=null==Ne?void 0:Ne.nodes)||void 0===Te?void 0:Te[It])||void 0===Ae?void 0:Ae.evaluation_result)&&void 0!==De?De:null:null!==(Fe=null!==(Ce=$e&&(null===(be=null===(ye=null==$e?void 0:$e[It])||void 0===ye?void 0:ye.evaluation_result)||void 0===be?void 0:be[0]))&&void 0!==Ce?Ce:null===(Be=null===(_e=null===(we=null==Ne?void 0:Ne.nodes)||void 0===we?void 0:we[It])||void 0===_e?void 0:_e.evaluation_result)||void 0===Be?void 0:Be[0])&&void 0!==Fe?Fe:null,At=R(Tt),Dt=y(null!==(Oe=null===(ke=null===(Pe=null==Tt?void 0:Tt.evaluation_outputs)||void 0===Pe?void 0:Pe.metadata)||void 0===ke?void 0:ke.label_color)&&void 0!==Oe?Oe:A),Pt=u(ft);a(function(){Pt.current=ft},[ft]);var kt=u(vi);a(function(){kt.current=vi},[vi]);var Ot=s(function(e,n,i,t,o,r){return Mo.current(e,n,i,t,o,r)},[]),Lt=s(function(e,n,i,t,o){return qo.current(e,n,i,t,o)},[]),jt=s(function(){return Vo.current()},[]),Nt=s(function(e,n){return Wo.current(e,n)},[]),Ht=s(function(e){return Ko.current(e)},[]),Mt=s(function(e){return Jo.current(e)},[]),zt=s(function(){return Yo.current()},[]),qt=s(function(){var e,n;vt(),null===(e=Pt.current)||void 0===e||e.call(Pt),wn(!1),Sn(new Set),yn([]),Pn.current=[],uo([]),ao(null),li(D),null===(n=kt.current)||void 0===n||n.call(kt),requestAnimationFrame(function(){var e;null===(e=kn.current)||void 0===e||e.call(kn)})},[]),Vt=u(qt);a(function(){Vt.current=qt},[qt]),a(function(){Ve&&Vt.current()},[Ve]);var Wt=c(function(){return{documents:null==Ne?void 0:Ne.documents,input_index_map:null==Ne?void 0:Ne.input_index_map}},[JSON.stringify(null==Ne?void 0:Ne.documents),JSON.stringify(null==Ne?void 0:Ne.input_index_map)]),Kt=u(Ne);a(function(){Kt.current=Ne},[Ne]);var Jt=u(Hn);a(function(){Jt.current=Hn},[Hn]);var Yt=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=x(null==i?void 0:i.id)||x(null==t?void 0:t.id)||"",R=(S?null===(c=Jt.current)||void 0===c?void 0:c[S]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:S,decisioning:[],gap:[],relevance_score:0},y=null!==(s=null===(a=Yi.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,b=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[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 i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(C)))return u(l);var c=o.split(C)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),w=(null!==(f=null===(v=null===(d=null==b?void 0:b.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(h=null===(g=null===(p=null==b?void 0:b.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0;return{isLoading:null!==(m=null==Ke?void 0:Ke.isLoading)&&void 0!==m&&m&&!w,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:R,anchorEl:n,sectionAnchorEl:y,badgeStyle:l||null,sectionIdx:o,docData:Wt,deviationData:b,isOrphan:!!r}},[Wt,null==Ke?void 0:Ke.isLoading]),Xt=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),ei.open&&ei.sectionIdx===o)fi();else{var u=e.currentTarget,c="left";(null===(l=Vn.current)||void 0===l?void 0:l.contains(u))&&(c="right");vt(),ut.current&&ft(),Sn(new Set),yn([]),Pn.current=[],vi(),ri.open?yo():ui(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(C)){var r=o.split(C),l="".concat(r[0]).concat(C).concat(r[1]);return"right"===c?null===(e=Vi.current[l])||void 0===e?void 0:e.current:null===(n=qi.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=Vi.current[o])||void 0===i?void 0:i.current:null===(t=qi.current[o])||void 0===t?void 0:t.current}()||u;ni(Yt(e,n,t,o,i,r))})}},[ei.open,ei.sectionIdx,fi,ui,Yt]),$t=s(function(){var e=ei.sectionIdx;ei.isOrphan,fi(),ui(),null!==e&&(bt(e),vt(),ut.current&&ft(),yn([]),Pn.current=[],Sn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){kn.current&&kn.current()},50))},[ei.sectionIdx,ei.isOrphan,fi,ui,ft]),Ut=s(function(){var e=In.current;if(e){In.current=null;var n=Ei.findIndex(function(n){return n.id===e}),i=Ii.findIndex(function(n){return n.id===e}),t=-1===n?b(Ei,e):null,o=-1===i?b(Ii,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(dt.current.add(r),_(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(on)-1!==r&&Xn.current&&c(function(){return u(n,t,Mi,Ki)},Xn.current),-1!==l&&Vn.current&&c(function(){return u(i,o,zi,Ji)},Vn.current);else{var a=zn.current;if(!a)return;c(function(){return-1!==r?u(n,t,Mi,Ki):u(i,o,zi,Ji)},a)}}},[Ei,Ii,on,Mi,zi,Ki,Ji,Xn,Vn,zn]),Gt=s(function(n){if(n){vt(),ft(),Sn(new Set),yn([]),Pn.current=[],ui(),vi();var i=Ei.findIndex(function(e){return e.id===n}),t=Ii.findIndex(function(e){return e.id===n}),o=-1===i?b(Ei,n):null,r=-1===t?b(Ii,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;In.current=n,mt(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=on?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=on?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),xt(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){In.current===n&&Qt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Ei,Ii,on,mt,xt,ft,ui,vi]),Qt=u(Ut);a(function(){Qt.current=Ut},[Ut]);var Zt=u(null);a(function(){if(hi){var e=pi.fields.find(function(e){return e.analysisKey===hi||e.key===hi});if(e){var n=Ni.current[e.key]||Hi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[hi,pi.fields]);var eo=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Bt?void 0:Bt.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===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.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}},[Bt]),no=$({proposedSections:Ei,existingSections:Ii,maintainRelativeOrder:on,cognitiveMap:Hn,deviationData:Nn,treeData:Ne,resolvedComparisonConfig:pi}),io=no.getSectionCompareStyle,to=no.getSubSectionCompareStyle,oo=no.getDeviationStyleByKey,ro=G({containerRef:Bn,leftContainerRef:Xn,rightContainerRef:Vn,svgContainerRef:_n,pathRefs:Dn,leftHeaderRef:Fn,rightHeaderRef:En,proposedSections:Ei,existingSections:Ii,visibleFields:Ti,leftRefs:Ni,rightRefs:Hi,sectionLeftRefs:Mi,sectionRightRefs:zi,subSectionLeftRefs:Ki,subSectionRightRefs:Ji,lhsBadgeRefs:qi,rhsBadgeRefs:Vi,sectionRowRefs:Yi,expandedSections:ht,expandedSubSections:St,connectedSections:mn,isSideBySide:Qi,activeSideBySideSection:ot,maintainRelativeOrder:on,cognitiveMap:Hn,getSectionCompareStyle:io,getSubSectionCompareStyle:to,getDeviationStyleByKey:oo,isArrowVisible:Zi,isAnimatingRef:Tn,isSideBySideRef:ut,sideBySideCacheRef:lt,sideBySideLineRef:st,activeSideBySideSectionRef:at,activeSideBySideRightSectionRef:ct,connectedLines:Rn,setConnectedLines:yn,cachedConnectedPositions:Pn,calculateLinesRef:kn,resizeTimerRef:On,scrollLock:rt,scrollSyncLocked:Cn,handleResizeRef:Ln,activeProposed:Bi,existingRule:Fi,analysisData:Bt,pendingScrollTargetRef:$n,pendingScrollCallbackRef:Un,resolvedComparisonConfig:pi,getFieldData:eo}),lo=ro.lines,uo=ro.setLines,co=ro.overallConnector,ao=ro.setOverallConnector,so=ro.svgDimensions,vo=ro.handleColumnScroll;a(function(){ri.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=kn.current)||void 0===e||e.call(kn)})})},[ri.anchorEl,Cn]);var fo=s(function(){vt(),wn(!1),mt({}),xt({}),ft(),Sn(new Set),yn([]),Pn.current=[],ui(),vi(),fi(),requestAnimationFrame(function(){kn.current&&kn.current()})},[mt,xt,ft,ui,vi,fi]);a(function(){Qi||0!==mn.size||wn(!1)},[Qi,mn]);var po=c(function(){return Object.values(ht).some(Boolean)||Object.values(St).some(Boolean)},[ht,St]),go=u(null),ho=u(0),mo=u(0),So=u(0),xo=U({timerRef:go,ruleComponentRef:qn,scrollContainerRef:zn,containerRef:Bn,maintainRelativeOrder:on,proposedSections:Ei,existingSections:Ii,isSideBySideRef:ut,activeSideBySideSectionRef:at,activeSideBySideRightSectionRef:ct,sectionRowRefs:Yi,sectionRightRowRefs:Wi,sectionLeftRefs:Mi,sectionRightRefs:zi,subSectionLeftRefs:Ki,subSectionRightRefs:Ji,lhsBadgeRefs:qi,rhsBadgeRefs:Vi,leftContainerRef:Xn,rightContainerRef:Vn,calculateLinesRef:kn,handleResizeRef:Ln,setIsResizing:it,setIsArrowVisible:et,sideBySideCacheRef:lt,cachedConnectedPositions:Pn}).handleResize;a(function(){Ln.current=xo},[xo,Ln]),a(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.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,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return qn.current&&o.push(e(qn.current,ho,n,function(){return Ln.current()},function(){})),zn.current&&o.push(e(zn.current,mo,i,function(){return Ln.current()},function(){return kn.current()})),Bn.current&&o.push(e(Bn.current,So,t,function(){return Ln.current()},function(){return kn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){ut.current=Qi},[Qi]),a(function(){at.current=ot},[ot]);var Ro=s(function(){var e,n=ei.sectionIdx,i=ei.isOrphan;if(ui(),null!=n){var t="left";ei.anchorEl&&(null===(e=Vn.current)||void 0===e?void 0:e.contains(ei.anchorEl))&&(t="right"),bt(n),pt(n,i,{sourceSide:t})}},[pt,ei.isOrphan,ei.sectionIdx,ei.anchorEl,ui]),yo=s(function(){ui(),ft(),Sn(new Set),yn([]),Pn.current=[]},[ui,ft]),bo=null!==ei.sectionIdx&&mn.has(ei.sectionIdx),Co=q({proposedSections:Ei,existingSections:Ii,parentDeviationRecord:Ai,expandedSections:ht,maintainRelativeOrder:!!on,scrollContainerRef:zn,leftContainerRef:Xn,rightContainerRef:Vn,lhsBadgeRefs:qi,rhsBadgeRefs:Vi}),wo=Co.showDeviationNavigation,_o=Co.showOpenNodeRef,Bo=Co.adjustScrollForPopup,Fo=s(function(e,n,i,t,o){var r,l="string"==typeof t?x(t).trim():x(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;vi();var c="left";(null===(r=Vn.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(C)){var r=n.split(C),l="".concat(r[0]).concat(C).concat(r[1]);return"right"===c?null===(e=Vi.current[l])||void 0===e?void 0:e.current:null===(i=qi.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=Vi.current[n])||void 0===t?void 0:t.current:null===(o=qi.current[n])||void 0===o?void 0:o.current};if(i)return ft(),Sn(new Set),yn([]),Pn.current=[],void(l&&(bt(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));li({open:!0,anchorEl:e,summary:t,displayImpact:o})})));bt(n),l?setTimeout(function(){pt(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,n,i,r=a()||u;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var c=l.top-window.innerHeight/2;on?(null===(e=Xn.current)||void 0===e||e.scrollBy({top:c,behavior:"smooth"}),null===(n=Vn.current)||void 0===n||n.scrollBy({top:c,behavior:"smooth"})):null===(i=zn.current)||void 0===i||i.scrollBy({top:c,behavior:"smooth"})}}li({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){pt(n,i,{toggleIfSame:!1,sourceSide:c})},350)},[pt,vi,li,ft,bt]),Eo=c(function(){var e;if(!Ue)return null;var n=null===(e=null==Ue?void 0:Ue.id)||void 0===e?void 0:e.split(":")[0];for(var i in Ai){if((Ai[i]||[]).some(function(e){return e.id===n}))return i}return null},[Ue,Ai]),Io=u({id:null,triggerMs:null}),To=u(null);a(function(){if(null==Ue?void 0:Ue.id){var o=Number(Ue.trigger),r=Io.current;if((null==r?void 0:r.triggerMs)!==o){if(!(Ue.id.includes(":")&&/:\d+$/.test(Ue.id)))return Io.current={id:Ue.id,triggerMs:o},void Gt(Ue.id);var l=Ue.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0";To.current!==Ue.id&&(ui(),vi(),ft(),Sn(new Set),yn([]),Pn.current=[],To.current=Ue.id);var s=!1,d=0,v=null,f=null,p=!1,g=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},h=function(){var r,l,c,m;if(!s){var S=function(){Io.current={id:Ue.id,triggerMs:o}},x=null,R=null;for(var y in Ai){var b=Ai[y].find(function(e){return e.id===u});if(b){x=y,R=b;break}}if(R&&x){var w=Ei.findIndex(function(e){return e.id===x}),_=Ii.findIndex(function(e){return e.id===x}),E=-1===w&&-1!==_,I=g(Ei,R.id),T=g(Ii,R.id);if(I&&!T&&!E){var A=I.split("-"),D=Number(A[0]);if(on){var P=null===(l=null===(r=Ei[D])||void 0===r?void 0:r.refIndexes)||void 0===l?void 0:l[0],k=Ii.findIndex(function(e){return e.selfIndex===P});-1!==k&&(D=k)}T=n([D],A.slice(1),!0).join("-")}if(I||T){var O=I?Number(I.split("-")[0]):w,L=T?Number(T.split("-")[0]):_,j=L>=0?L:T?Number(T.split("-")[0]):-1,N=Ei[O],H=Ii[j],M=N&&!N.title&&!N.content,z=H&&!H.title&&!H.content,q=E||(!I&&!!T||M&&!z);if(q){if(!(on?!!zo.current["right-".concat(L)]:!!zo.current[String(L)])&&L>=0)return yt(L,"right"),void(v=setTimeout(h,200))}else if(!(on?!!zo.current["left-".concat(O)]:!!zo.current[String(O)])&&O>=0)return yt(O,"left"),void(v=setTimeout(h,200));var V=I||"",W=T||"",K="".concat(R.id).concat(C).concat(a).concat(C).concat(V).concat(C).concat(W),J="".concat(R.id).concat(C).concat(a);if(!p){bt(K),p=!0,d=0;var Y=function(){var e,n,i=null===(e=qi.current[J])||void 0===e?void 0:e.current,t=null===(n=Vi.current[J])||void 0===n?void 0:n.current;return q||!i&&!!t?t:i};return null==f||f(),void(v=setTimeout(function(){var e,n,i,t,o,r,l;s||(e=Y,n=function(){s||(f=null,h())},t=0,o=null,r=null,l=function(){if(!s){var u=e();if(u&&0!==u.getBoundingClientRect().height){var c=u.getBoundingClientRect(),a=c.top,d=c.height,v=null!==o&&Math.abs(a-o)<.5,f=null!==r&&Math.abs(d-r)<.5;if(v&&f){if(++t>=5)return void n()}else t=0;o=a,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),f=function(){return cancelAnimationFrame(i)})},300))}var X=null===(c=qi.current[J])||void 0===c?void 0:c.current,$=null===(m=Vi.current[J])||void 0===m?void 0:m.current;if(X||$){var U=q||!X&&!!$,G=U?$:X,Q=on?U?Vn.current:Xn.current:zn.current;if(G&&Q){var Z=G.getBoundingClientRect();if(0!==Z.height){var ee=Q.getBoundingClientRect(),ne=Z.top-ee.top+Q.scrollTop-ee.height/2+Z.height/2,ie=(null==I?void 0:I.includes("-"))||(null==T?void 0:T.includes("-")),te=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,d,v,f;return t(this,function(t){switch(t.label){case 0:return s?[2]:(S(),n=G instanceof Element?window.getComputedStyle(G).color:"",[X,$].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[X,$].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=R.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||R,o=(null===(d=R.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||R.evaluation_outputs,!!X&&!!$?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},on?[4,Promise.all([Xn.current?l(F(Xn.current),600):Promise.resolve(),Vn.current?l(F(Vn.current),600):Promise.resolve()])]:[3,2]):(r=U?(null===(v=Vi.current[ie?J:L])||void 0===v?void 0:v.current)||$:(null===(f=qi.current[ie?J:O])||void 0===f?void 0:f.current)||X,Bo(r,function(){li({open:!0,anchorEl:r,displayImpact:Ue.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==Ge||Ge(),[2]));case 1:t.sent(),t.label=2;case 2:return pt(K,!1,{toggleIfSame:!1,sourceSide:E?"right":"left",onReady:function(){var n,t,o,r;S();var l=U?(null===(n=Vi.current[J])||void 0===n?void 0:n.current)||$:(null===(t=qi.current[J])||void 0===t?void 0:t.current)||X,u=(null===(o=qi.current[J])||void 0===o?void 0:o.current)||X,c=(null===(r=Vi.current[J])||void 0===r?void 0:r.current)||$;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"})),li({open:!0,anchorEl:l,displayImpact:Ue.displayImpact,summary:e({},i)}),null==Ge||Ge()}}),[2]}})})};Math.abs(Q.scrollTop-ne)<=2?te():B(Q,ne,te)}else++d<2?v=setTimeout(h,100):S()}else++d<2?v=setTimeout(h,100):S()}else++d<2?v=setTimeout(h,100):S()}else++d<2?v=setTimeout(h,100):S()}else++d<2?v=setTimeout(h,100):S()}};return v=setTimeout(h,100),function(){s=!0,v&&clearTimeout(v),null==f||f()}}}},[Ue,Ai,Ei,Ii,on,ht,pt,li,Gt]),a(function(){var n,i,t;if(ri.open){var o=ri.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(qi.current)||r(Vi.current);if(l){var u=(null===(i=Vi.current[l])||void 0===i?void 0:i.current)||(null===(t=qi.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&li(function(n){return e(e({},n),{anchorEl:u})})}}}},[ri.open,ri.anchorEl,Cn,mn,ht]);var Ao=Qn.open,Do=Qn.sectionIdx,Po=Qn.isOrphan,ko=Qn.badgeStyle,Oo=Qn.anchorEl,Lo=Qn.sectionAnchorEl;a(function(){var n;if(Ao&&null!=Do&&Do!==It){var i="string"==typeof Do?Do.split(C)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(Ei,i):null,r=i&&"string"==typeof i?t(Ii,i):null,l="number"==typeof Do?Ei[Do]||null:o||i&&((null===(n=null==Ne?void 0:Ne.nodes)||void 0===n?void 0:n[i])||(null==Ne?void 0:Ne[i]))||null,u="number"==typeof Do?Ii[Do]||null:r,c=Yt(Oo,l,u,Do,Po,ko);Zn(function(n){return n.open?x(n.cognitiveData)===x(c.cognitiveData)&&x(n.deviationData)===x(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Ao,Do,Po,ko,Oo,Lo,Ei,Ii,Yt]);var jo=s(function(e){var n=e.section,i=e.keyPath,t=e.depth,r=void 0===t?0:t,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset;return o(W,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s})},[]),No=c(function(){return Ei.map(function(e,n){var i,t=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return t&&r&&on?null:o(K,{section:e,idx:n},null!==(i=null==e?void 0:e.id)&&void 0!==i?i:"left-row-".concat(n))})},[Ei]),Ho=c(function(){return Ii.map(function(e,n){var i,t=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return t&&r&&on?null:o(J,{section:e,idx:n},null!==(i=null==e?void 0:e.id)&&void 0!==i?i:"right-row-".concat(n))})},[Ii]),Mo=u(Xt);a(function(){Mo.current=Xt},[Xt]);var zo=u(ht);a(function(){zo.current=ht},[ht]);var qo=u(Fo);a(function(){qo.current=Fo},[Fo]);var Vo=u(yo);a(function(){Vo.current=yo},[yo]);var Wo=u(yt);a(function(){Wo.current=yt},[yt]);var Ko=u(Rt);a(function(){Ko.current=Rt},[Rt]);var Jo=u(jo);a(function(){Jo.current=jo},[jo]);var Yo=u(ft);a(function(){Yo.current=ft},[ft]);var Xo=c(function(){return{maintainRelativeOrder:!!on,showDeviationBadges:cn,isProposingFix:Ze,proposingFixNodeId:en,isRedlineFlow:nn,isSideBySide:Qi,activeSideBySideSection:ot,scrollSyncLocked:Cn,toggleScrollSyncLocked:wt,summaryPopupAnchorEl:ri.anchorEl,connectedSections:mn,proposedSections:Ei,existingSections:Ii,deviationNumberRegistry:Di,deviationParentRegistry:Pi,treeData:Ne,displayConfig:Ke,resolvedMarkdownStyles:Mn,unifiedNumbering:_t,expandedSections:ht,expandedSubSections:St,setExpandedSubSections:xt,getSectionCompareStyle:io,getSubSectionCompareStyle:to,getBadgeRef:Ui,getSectionRowRef:Xi,getSubSectionRef:$i,sectionLeftRefs:Mi,sectionRightRefs:zi,sectionRowRefs:Yi,sectionRightRowRefs:Wi,subSectionLeftRefs:Ki,subSectionRightRefs:Ji,lhsBadgeRefs:qi,rhsBadgeRefs:Vi,openMoreFunctionsPopup:Ot,handleOpenSummaryPopup:Lt,openSummaryPopup:Lt,handleCloseSummaryPopup:jt,toggleSection:Nt,handleSubSectionToggle:Ht,renderSubSectionAccordion:Mt,resetSideBySide:zt,setConnectedSections:Sn,setConnectedLines:yn,cachedConnectedPositions:Pn,showDeviationNavigation:wo,showOpenNodeRef:_o,deviationNodeIdToView:null==Ue?void 0:Ue.id,deviationTargetParentId:Eo}},[on,cn,Ze,en,nn,Qi,ot,Cn,wt,ri.anchorEl,mn,Ei,Ii,Di,Ke,Mn,_t,ht,St,xt,io,to,Ui,Xi,$i,wo,_o,Ue,Eo]);return o(X,e({value:Xo},{children:r(d,e({ref:qn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[sn&&o(d,e({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:o(L,{})})),ri.open&&o(Y,{open:ri.open,anchorEl:ri.anchorEl,containerEl:Zt.current,clipTopEl:Fn.current,scrollContainerEl:zn.current,onClose:yo,summary:ri.summary,displayImpact:ri.displayImpact,isScrollLocked:Cn}),o(O,{open:ei.open,anchorEl:ei.anchorEl,maintainRelativeOrder:!!on,sectionTitle:ei.sectionTitle,referenceSectionTitle:ei.refSectionTitle,onClose:fi,onOpenCognitiveCompare:si,onOpenSideBySide:Ro,onConnect:$t,isConnected:bo,isOrphan:ei.isOrphan}),Qn.open&&o(k,{open:Qn.open,popupRef:ai,position:ii,popupConfig:Ye,onClose:function(){ti(null),Zn(function(n){return e(e({},n),{open:!1})}),ci(null)},markdownStyles:qe,sectionTitle:yi,referenceSectionTitle:Ci,cognitiveData:Qn.cognitiveData,anchorEl:Qn.anchorEl,sectionAnchorEl:Qn.sectionAnchorEl,scrollContainerEl:zn.current,badgeStyle:Qn.badgeStyle,docData:Qn.docData,deviationData:Qn.deviationData,isLoading:Qn.isLoading}),o(v,e({open:!!fn,autoHideDuration:8e3,onClose:function(){return pn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return pn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:fn}))})),o(V,{componentHeaderText:je,displayConfig:Ke,maintainRelativeOrder:on,onCollapseAll:fo,showCollapseAll:po,onToggleView:function(e){dn(!0),setTimeout(function(){rn(!e),null==Je||Je(!e),wn(!1),ft(),ui(),Sn(new Set),yn([]),Pn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){dn(!1)},600)})})},50)}}),o(d,e({ref:zn,onScroll:vo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:on?"visible":"auto",borderTop:Ft&&Et?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},on?{flex:1}:{})},{children:r(d,e({ref:Bn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},on?{flex:1,overflow:"visible"}:{})},{children:[o(Z,{svgContainerRef:_n,svgDimensions:so,isResizing:nt,overallConnector:co,rootDeviationStyle:Dt,lines:lo,isSideBySide:Qi,activeSideBySideSection:ot,isArrowVisible:Zi,maintainRelativeOrder:on,proposedSections:Ei,existingSections:Ii,cognitivePopup:Qn,activeBadgeId:oi,closeCognitivePopup:vi,setActiveBadgeId:ci,openCognitivePopupFromState:di,buildSectionPopupState:Yt,connectedLines:Rn,pathRefs:Dn}),r(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},on?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:Fn,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:o(p,e({title:xi,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:xi}))}))})),r(d,e({ref:Xn,onScroll:vo,sx:e({p:"12px",display:"flex",flexDirection:"column"},on?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:Jn,style:{width:"100%",height:"0px",flexShrink:0}}),Oi&&No,o("div",{ref:Yn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:Zt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(d,e({onClick:function(n){n.stopPropagation(),Qn.open&&oi===It?vi():(ci(It),di(Yt(n.currentTarget,{title:"",content:"",evaluationResult:Tt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,It,!0,e(e({},Dt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Dt.badgeBg,color:Dt.badgeText,border:"1px solid ".concat(Dt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=At?At:o(j,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(m,{})})),o(h,{size:11,style:{transform:Qn.open&&oi===It?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},on?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[tt&&o(S,{sections:11}),o(d,e({ref:En,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:o(p,e({title:wi,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:wi}))}))})),r(d,e({ref:Vn,onScroll:vo,sx:e({p:"12px",display:"flex",flexDirection:"column"},on?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:Wn,style:{width:"100%",height:"0px",flexShrink:0}}),Oi&&Ho,o("div",{ref:Kn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{ee as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- import{DEFAULT_DEVIAION_COLOR as t}from"./CognitiveCompareConstants.js";var 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)},o=function(t){return null!=t&&("string"==typeof t?t.trim().length>0:!Array.isArray(t)||t.length>0&&t.some(function(t){return o(t)}))},e=function(t,o,e){var r,i=e[o],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)||[]}},r=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,o=parseInt(n.decision_strength||"0");return{cognitiveData:{decisioning:n.decisioning_factors||[],gap:n.gaps_in_decision||[],relevance_score:o,citations:n.citations},score:0,relation:"N/A"}};function i(t){var n=function(t,n){var o=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("#",""),o=parseInt(n,16);return{r:o>>16&255,g:o>>8&255,b:255&o}}(t),e=o.r,r=o.g,i=o.b;return function(t,n,o){return"#"+[t,n,o].map(function(t){return t.toString(16).padStart(2,"0")}).join("").toUpperCase()}(Math.round(e+(255-e)*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)}}function u(t,n){var o;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var i=this;clearTimeout(o),o=setTimeout(function(){return t.apply(i,e)},n)}}var l=function(t,n){var o,e,r,i,u,l;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.suppressHighlightBg!==n.suppressHighlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==s[c])return!1;var v=t.deviationBadges||[],d=n.deviationBadges||[];if(v.length!==d.length)return!1;for(c=0;c<v.length;c++){if(v[c].id!==d[c].id)return!1;if(v[c].actionId!==d[c].actionId)return!1;if(v[c].label!==d[c].label)return!1;if(v[c].score!==d[c].score)return!1;if(v[c].isOrphan!==d[c].isOrphan)return!1;if(v[c].isConnected!==d[c].isConnected)return!1;if(v[c].showScrollLockToggle!==d[c].showScrollLockToggle)return!1;if(v[c].scrollSyncLocked!==d[c].scrollSyncLocked)return!1;if((null===(o=v[c].style)||void 0===o?void 0:o.badgeBg)!==(null===(e=d[c].style)||void 0===e?void 0:e.badgeBg))return!1;if((null===(r=v[c].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=d[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(u=v[c].style)||void 0===u?void 0:u.badgeText)!==(null===(l=d[c].style)||void 0===l?void 0:l.badgeText))return!1}return!0},a="::",s=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},c=function(t){var n;if("string"!=typeof t||!t)return!1;for(var o=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,e=null;null!==(e=o.exec(t));){if((null!==(n=e[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},v=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},d=function(t,n){var o,e,r,i,u,l,a;if(!t)return n;var s=null!==(l=null!==(i=null!==(e=null===(o=t.evaluation_output)||void 0===o?void 0:o.output_score)&&void 0!==e?e: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:""},f=function(t,n,o,e,r){void 0===r&&(r=14);var i=t+.5*(o-t),u=e-n;if(Math.abs(u)<3)return"M ".concat(t," ").concat(n," H ").concat(o);var l=u>0?1:-1,a=Math.min(r,Math.abs(u)/2,Math.abs(i-t)/2,Math.abs(o-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(e-l*a),"Q ".concat(i," ").concat(e," ").concat(i+a," ").concat(e),"H ".concat(o)].join(" ")},g=function(t,n,o,e,r){void 0===o&&(o=300);var i=t.style.scrollBehavior;t.style.scrollBehavior="auto";var u=t.scrollTop,l=n-u,a=null,s=function(c){null===a&&(a=c);var v,d=c-a;d<o?(t.scrollTop=(v=d,v/=o,l*(--v*v*v+1)+u),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),e&&e())};requestAnimationFrame(s)},p=["#B91C1C","#A16207","#1D4ED8","#000000"],h=function(t){var n=p.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?p.length:n},b=function(n){for(var o,e,r,i,u,l,a,s,c,v,d,f,g,p=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var y=m[b];(C=null===(i=null===(r=null===(e=null===(o=null==n?void 0:n.deviations)||void 0===o?void 0:o[y])||void 0===e?void 0:e.evaluation_outputs)||void 0===r?void 0:r.metadata)||void 0===i?void 0:i.label_color)&&p.push(C)}for(var _=0,B=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});_<B.length;_++){y=B[_];(C=null===(s=null===(a=null===(l=null===(u=null==n?void 0:n.deviation_entries)||void 0===u?void 0:u[y])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===s?void 0:s.label_color)&&p.push(C)}for(var T=0,x=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});T<x.length;T++){var C;y=x[T];(C=null===(d=null===(v=null===(c=null==n?void 0:n[y])||void 0===c?void 0:c.evaluation_outputs)||void 0===v?void 0:v.metadata)||void 0===d?void 0:d.label_color)&&p.push(C)}return 0===p.length?(null===(g=null===(f=null==n?void 0:n.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===g?void 0:g.label_color)?n.evaluation_outputs.metadata.label_color:t:p.sort(function(t,n){return h(t)-h(n)})[0]},m=function(t){for(var n,o,e,r,i,u,l,a,s,c=0,v=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});c<v.length;c++){var d=v[c];if(b=null===(e=null===(o=null===(n=null==t?void 0:t.deviations)||void 0===n?void 0:n[d])||void 0===o?void 0:o.evaluation_outputs)||void 0===e?void 0:e.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},y=function(t,n){var o=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)]},e=function(t){var n=Math.round(t).toString(16);return 1===n.length?"0"+n:n};try{var r=o(t),i=o(n),u=(r[0]+i[0])/2*.95,l=(r[1]+i[1])/2*.95,a=(r[2]+i[2])/2*.95;return"#".concat(e(u)).concat(e(l)).concat(e(a))}catch(t){return"#FDE68A"}},_=function(t,n,o){if(!t)return null;if(t.id===o)return n;if(!Array.isArray(t.subsections))return null;for(var e=0;e<t.subsections.length;e++){var r=_(t.subsections[e],"".concat(n,"-").concat(e),o);if(r)return r}return null},B=function(t,n){for(var o=0;o<t.length;o++){var e=_(t[o],String(o),n);if(e)return e}return null},T=new WeakMap,x=function(t){if(t){var n=T.get(t);null!=n&&(clearTimeout(n),T.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)}},C=function(t){if(t){var n=T.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 o=window.setTimeout(function(){x(t)},3e3);T.set(t,o)}},A=function(t,n){var o=n.getBoundingClientRect(),e=t.getBoundingClientRect(),r=n.scrollTop+e.top-o.top-o.height/2+e.height/2;n.scrollTo({top:r,behavior:"smooth"});var i=function(){return C(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)}};export{a as DEVIATION_BADGE_SEPARATOR,l as areMarkdownPropsEqual,u as debounce,d as extractDeviationScore,B as findKeyPathByNodeId,i as generateColorPalette,f as getBentArrowPath,b as getFirstDeviationColor,m as getFirstDeviationOutputValue,r as getRationale,e as getSideData,c as hasMeaningfulRedlineTags,o as hasValue,C as highlightClause,s as isMissingStr,y as mixHexColors,_ as recursivelyFindSubSectionIdxById,x as resetClauseHighlight,n as safeStringify,A as scrollAndHighlightClause,g as smoothScrollTo,v as stripRedlineTags};
1
+ import{DEFAULT_DEVIAION_COLOR as t}from"./CognitiveCompareConstants.js";var 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)}))},o=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)||[]}},r=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"}};function i(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)}}function u(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)}}var l=function(t,n){var e,o,r,i,u,l;if(t.content!==n.content)return!1;if(t.overlayContent!==n.overlayContent)return!1;if(t.sxStyles!==n.sxStyles)return!1;if(t.maintainRelativeOrder!==n.maintainRelativeOrder)return!1;if(t.highlightBg!==n.highlightBg)return!1;if(t.suppressHighlightBg!==n.suppressHighlightBg)return!1;if(t.collisionKey!==n.collisionKey)return!1;var a=t.highlights||[],s=n.highlights||[];if(a.length!==s.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==s[c])return!1;var v=t.deviationBadges||[],d=n.deviationBadges||[];if(v.length!==d.length)return!1;for(c=0;c<v.length;c++){if(v[c].id!==d[c].id)return!1;if(v[c].actionId!==d[c].actionId)return!1;if(v[c].label!==d[c].label)return!1;if(v[c].score!==d[c].score)return!1;if(v[c].isOrphan!==d[c].isOrphan)return!1;if(v[c].isConnected!==d[c].isConnected)return!1;if(v[c].showScrollLockToggle!==d[c].showScrollLockToggle)return!1;if(v[c].scrollSyncLocked!==d[c].scrollSyncLocked)return!1;if((null===(e=v[c].style)||void 0===e?void 0:e.badgeBg)!==(null===(o=d[c].style)||void 0===o?void 0:o.badgeBg))return!1;if((null===(r=v[c].style)||void 0===r?void 0:r.badgeBorder)!==(null===(i=d[c].style)||void 0===i?void 0:i.badgeBorder))return!1;if((null===(u=v[c].style)||void 0===u?void 0:u.badgeText)!==(null===(l=d[c].style)||void 0===l?void 0:l.badgeText))return!1}return!0},a="::",s=function(t){if(!t)return!0;var n=t.trim().toLowerCase();return n.includes("no equivalent")||"n/a"===n||"na"===n||"none"===n},c=function(t){var n;if("string"!=typeof t||!t)return!1;for(var e=/<(updated|deleted|changed|change)\b[^>]*>([\s\S]*?)<\/\1>/gi,o=null;null!==(o=e.exec(t));){if((null!==(n=o[2])&&void 0!==n?n:"").replace(/<[^>]*>/g,"").trim().length>0)return!0}return!1},v=function(t){return"string"==typeof t&&t?t.replace(/<\/?(updated|deleted|changed|change)\b[^>]*>/gi,""):""},d=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:""},f=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(" ")},g=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(c){null===a&&(a=c);var v,d=c-a;d<e?(t.scrollTop=(v=d,v/=e,l*(--v*v*v+1)+u),r&&r(),requestAnimationFrame(s)):(t.scrollTop=n,t.style.scrollBehavior=i,r&&r(),o&&o())};requestAnimationFrame(s)},p=["#B91C1C","#A16207","#1D4ED8","#000000"],h=function(t){var n=p.findIndex(function(n){return n.toLowerCase()===t.toLowerCase()});return-1===n?p.length:n},b=function(n){for(var e,o,r,i,u,l,a,s,c,v,d,f,g,p=[],b=0,m=Object.keys((null==n?void 0:n.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});b<m.length;b++){var y=m[b];(C=null===(i=null===(r=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===r?void 0:r.metadata)||void 0===i?void 0:i.label_color)&&p.push(C)}for(var _=0,T=Object.keys((null==n?void 0:n.deviation_entries)||{}).sort(function(t,n){return Number(t)-Number(n)});_<T.length;_++){y=T[_];(C=null===(s=null===(a=null===(l=null===(u=null==n?void 0:n.deviation_entries)||void 0===u?void 0:u[y])||void 0===l?void 0:l.evaluation_outputs)||void 0===a?void 0:a.metadata)||void 0===s?void 0:s.label_color)&&p.push(C)}for(var B=0,x=Object.keys(n||{}).filter(function(t){return/^\d+$/.test(t)}).sort(function(t,n){return Number(t)-Number(n)});B<x.length;B++){var C;y=x[B];(C=null===(d=null===(v=null===(c=null==n?void 0:n[y])||void 0===c?void 0:c.evaluation_outputs)||void 0===v?void 0:v.metadata)||void 0===d?void 0:d.label_color)&&p.push(C)}return 0===p.length?(null===(g=null===(f=null==n?void 0:n.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===g?void 0:g.label_color)?n.evaluation_outputs.metadata.label_color:t:p.sort(function(t,n){return h(t)-h(n)})[0]},m=function(t){for(var n,e,o,r,i,u,l,a,s,c=0,v=Object.keys((null==t?void 0:t.deviations)||{}).sort(function(t,n){return Number(t)-Number(n)});c<v.length;c++){var d=v[c];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},y=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"}},_=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=_(t.subsections[o],"".concat(n,"-").concat(o),e);if(r)return r}return null},T=function(t,n){for(var e=0;e<t.length;e++){var o=_(t[e],String(e),n);if(o)return o}return null},B=new WeakMap,x=function(t){if(t){var n=B.get(t);null!=n&&(clearTimeout(n),B.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)}},C=function(t){if(t){var n=B.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(){x(t)},3e3);B.set(t,e)}},w=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 C(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)}},A=function(t,n,e){if(Math.abs(t.scrollTop-n)<=2)e();else{var o,r=!1,i=function(){r||(r=!0,clearTimeout(o),t.removeEventListener("scrollend",u),e())},u=function(){return i()};t.addEventListener("scrollend",u),t.scrollTo({top:n,behavior:"smooth"}),o=setTimeout(i,800)}},N=function(t,n){return void 0===n&&(n=100),new Promise(function(e){var o,r=!1,i=function(){r||(r=!0,t.removeEventListener("scroll",u),e())},u=function(){clearTimeout(o),o=setTimeout(i,n)};t.addEventListener("scroll",u),o=setTimeout(i,n)})};export{a as DEVIATION_BADGE_SEPARATOR,l as areMarkdownPropsEqual,u as debounce,d as extractDeviationScore,T as findKeyPathByNodeId,i as generateColorPalette,f as getBentArrowPath,b as getFirstDeviationColor,m as getFirstDeviationOutputValue,r as getRationale,o as getSideData,c as hasMeaningfulRedlineTags,e as hasValue,C as highlightClause,s as isMissingStr,y as mixHexColors,_ as recursivelyFindSubSectionIdxById,x as resetClauseHighlight,n as safeStringify,w as scrollAndHighlightClause,A as scrollAndWait,g as smoothScrollTo,v as stripRedlineTags,N as waitForScrollIdle};
2
2
  //# sourceMappingURL=CognitiveComparehelpers.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n}from"tslib";import{jsxs as e,jsx as i}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as r,AccordionSummary as d,Tooltip as a,Typography as c,AccordionDetails as u}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{useCompareContext as p}from"../CompareContext.js";import{hasValue as h,hasMeaningfulRedlineTags as g,stripRedlineTags as m,generateColorPalette as x,isMissingStr as I,safeStringify as b,DEVIATION_BADGE_SEPARATOR as y}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";var S=function(S){var _,k,F,R,B,C,M,A,O,W,T,j,E,N=S.section,P=S.idx,D=S.columnKey,K=S.colRef,L=S.mb,z=void 0===L?1:L,V=S.isExpanded,G=S.onToggle,H=S.navigation,X=S.parentNodeId,Y=void 0===X?"":X,q=p(),J=q.showOpenNodeRef,Q=q.resolvedMarkdownStyles,U=q.maintainRelativeOrder,Z=q.showDeviationBadges,$=void 0!==Z&&Z,nn=q.renderSubSectionAccordion,en=q.treeData,on=q.proposedSections,tn=q.existingSections,ln=q.deviationNumberRegistry,rn=q.getBadgeRef,dn=q.openSummaryPopup,an=q.getSectionCompareStyle,cn=q.connectedSections,un=q.openMoreFunctionsPopup;q.deviationNodeIdToView,q.deviationTargetParentId;var sn=q.isProposingFix,vn=q.proposingFixNodeId,fn=q.isRedlineFlow,pn=q.isSideBySide,hn=q.activeSideBySideSection,gn=q.scrollSyncLocked,mn=q.toggleScrollSyncLocked,xn=q.summaryPopupAnchorEl,In="".concat(pn?"1":"0","-").concat(String(null!=hn?hn:"")),bn=(null===(_=N.displayTitle)||void 0===_||_)&&h(N.title),yn=!!sn&&!!vn&&"left"===D&&N.id===vn,wn=g(N.content),Sn="boolean"==typeof fn?fn:wn,_n=wn,kn=Sn&&wn,Fn=kn?m(N.content):N.content,Rn=kn?N.content:void 0,Bn=(null===(k=N.displayContent)||void 0===k||k||wn)&&h(N.content),Cn=!bn&&!Bn,Mn=N.title;bn||(Mn=Bn?"No Title Found":"No Matching Section Found");var An=N.evaluationResult;if(!An&&"right"===D)if(U){var On=null===(F=N.refIndexes)||void 0===F?void 0:F[0],Wn=on.find(function(n){return n.selfIndex===On});An=null==Wn?void 0:Wn.evaluationResult}else An=null===(R=on[P])||void 0===R?void 0:R.evaluationResult;var Tn=null===(B=null==en?void 0:en.input_index_map)||void 0===B?void 0:B[0],jn=null===(C=null==en?void 0:en.input_index_map)||void 0===C?void 0:C[1],En="left"===D?jn:Tn,Nn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Nn(l.subsections,e);if(r)return r}}return null},Pn="left"===D?N:Nn(on,N.id),Dn="right"===D?N:Nn(tn,N.id),Kn=o.useMemo(function(){if(!U)return 0;var n=1/0,e=function(i,o,t,l){var r;if(i){var d=i.id;if(l&&"right"===D){var a=on.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(i.selfIndex)});a.length>0&&(d=a[0].id)}var c=i.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),u=(null===(r=i.evaluationResult)||void 0===r?void 0:r.deviations)||{};Object.keys(u).forEach(function(e){var i="".concat(d).concat(y).concat(e),o=null==ln?void 0:ln[i];null!=o&&o<n&&(n=o);var t="".concat(c).concat(y).concat(e),l=null==ln?void 0:ln[t];null!=l&&l<n&&(n=l)});for(var s=i.subsections||[],v=(null==o?void 0:o.subsections)||[],f=(null==t?void 0:t.subsections)||[],p=Math.max(s.length,v.length,f.length),h=0;h<p;h++)e(s[h],v[h],f[h],!1)}};return e(N,Pn,Dn,!0),n!==1/0?n-1:0},[N,Pn,Dn,D,ln,U,on]);if(U)if("left"===D){var Ln=null===(M=N.refIndexes)||void 0===M?void 0:M[0],zn=tn.findIndex(function(n){return n.selfIndex===Ln});Dn=-1!==zn?tn[zn]:Nn(tn,N.id)}else{var Vn=null===(A=N.refIndexes)||void 0===A?void 0:A[0],Gn=on.findIndex(function(n){return n.selfIndex===Vn});Pn=-1!==Gn?on[Gn]:Nn(on,N.id)}var Hn="left"===D?!Dn:!Pn,Xn=An||(null==Pn?void 0:Pn.evaluationResult)||(null==Dn?void 0:Dn.evaluationResult),Yn=null!==(T=null===(W=null===(O=null==Xn?void 0:Xn.evaluation_outputs)||void 0===O?void 0:O.metadata)||void 0===W?void 0:W.label_color)&&void 0!==T?T:w,qn=x(Yn).highlightBg,Jn=(null==Xn?void 0:Xn.deviations)||{},Qn=P+1,Un=N.id;if(U){var Zn=1,$n=new Map;if(on.forEach(function(n){!n.title&&!n.content||n.id&&$n.set(n.id,Zn++)}),"left"===D)Qn=$n.get(N.id)||P+1;else{var ne=on.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(N.selfIndex)});if(ne.length>0)Qn=$n.get(ne[0].id)||P+1,Un=ne[0].id;else for(var ee=Zn,ie=function(n){if(!n.title&&!n.content)return"continue";var e=on.some(function(e){var i;return null===(i=e.refIndexes)||void 0===i?void 0:i.includes(n.selfIndex)});if(!e){if(n.id===N.id)return Qn=ee,"break";ee++}},oe=0,te=tn;oe<te.length;oe++){if("break"===ie(te[oe]))break}}}var le=Object.entries(Jn).map(function(n){var e=n[0],i=n[1],o="".concat(Un).concat(y).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:ln[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});le.sort(function(n,e){return n.currentIndex-e.currentIndex});var re,de=le.map(function(e){var i,o,t,l,r,d,a=e.deviationKey,c=e.deviationMap,u=e.refId,s=e.currentIndex;U&&void 0!==Kn&&(s-=Kn);var v=c[Y],f=I(v);if(f)v="";else if(!v)return null;var p=P,h=P;if(U)if("left"===D){var g=null===(i=N.refIndexes)||void 0===i?void 0:i[0],m=tn.findIndex(function(n){return n.selfIndex===g});if(-1!==m)h=m;else{var b=tn.findIndex(function(n){return n.id===N.id});h=-1!==b?b:P}}else{var w=null===(o=N.refIndexes)||void 0===o?void 0:o[0],S=on.findIndex(function(n){return n.selfIndex===w});if(-1!==S)p=S;else{var _=on.findIndex(function(n){return n.id===N.id});p=-1!==_?_:P}}var k="".concat(Un).concat(y).concat(a).concat(y).concat(p).concat(y).concat(h),F=c[En],R=Hn||I(F),B="".concat(Qn,".").concat(s),C=P;if("right"===D&&U){var M=null===(t=N.refIndexes)||void 0===t?void 0:t[0],A=on.findIndex(function(n){return n.selfIndex===M});if(-1!==A)C=A;else{_=on.findIndex(function(n){return n.id===N.id});-1!==_&&(C=_)}}var O=an?an(C):null,W=(null==c?void 0:c.evaluation_outputs)||(null==Xn?void 0:Xn.evaluation_outputs),T=null!==(l=null==W?void 0:W.output_value)&&void 0!==l?l:null,j=null!==(d=null===(r=null==W?void 0:W.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:Yn,E=x(j),K=O?n(n({},O),{badgeBg:E.badgeBg,badgeBorder:E.badgeBorder,badgeText:E.badgeText}):n({},E),L=(null==c?void 0:c.deviation_summary)?{deviation_summary:c.deviation_summary,deviation_title:(null==c?void 0:c.deviation_title)||(null==Xn?void 0:Xn.deviation_title),deviation_impact:(null==c?void 0:c.deviation_impact)||(null==Xn?void 0:Xn.deviation_impact),deviation_explanation:(null==c?void 0:c.deviation_explanation)||(null==Xn?void 0:Xn.deviation_explanation),evaluation_outputs:W,cognitive_decisioning:(null==c?void 0:c.cognitive_decisioning)||(null==Xn?void 0:Xn.cognitive_decisioning)}:null,z=0,V=Fn||"";if(v&&V){var G=V.split(/\n{2,}/),H=G.findIndex(function(n){return n.includes(v)});if(-1!==H){var X=Object.entries(Jn).filter(function(n){n[0];var e=n[1][Y];return e&&G[H].includes(e)}).sort(function(n,e){return G[H].indexOf(n[1][Y])-G[H].indexOf(e[1][Y])}),q=X.filter(function(n){n[0];var e=n[1][Y];return e&&(e.includes(v)||v.includes(e))});q.length>1&&(z=Math.max(0,q.findIndex(function(n){return n[0]===a})))}}var J=rn(D,u);return{id:u,actionId:k,label:B,highlight:v,side:D,style:K,stackIndex:z,score:T,isConnected:null==cn?void 0:cn.has(k),showScrollLockToggle:(null==cn?void 0:cn.has(k))||pn&&hn===k||!!xn&&xn===J.current,scrollSyncLocked:gn,toggleScrollSyncLocked:mn,isOrphan:R,isMissingClause:f,badgeRef:J,onClick:function(n){n.stopPropagation(),un&&un(n,Pn||{id:"orphan-left",title:"",content:""},R,Dn||{id:"orphan-right",title:"",content:""},k,K)},onSummaryClick:function(n){n.stopPropagation(),dn(n,k,R,L)}}}).filter(Boolean),ae=$||!Sn&&yn?de:[],ce=de.map(function(n){return n.highlight}).filter(Boolean),ue=N.id&&D===(null==H?void 0:H.columnKey)?H:null,se=o.useRef(!1);return t(function(){V||(se.current=!1)},[V]),e(l,n({ref:K,sx:{mb:z,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[V&&(null==ue?void 0:ue.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ue?void 0:ue.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===D?{right:"0px"}:{left:"0px"})},{children:i(s,{color:(null===(j=null==ue?void 0:ue.showAboveRef)||void 0===j?void 0:j.current)?window.getComputedStyle(ue.showAboveRef.current).color:void 0})}))})),e(r,n({disableGutters:!0,expanded:!Cn&&V,onChange:function(){Cn||(G(),J.current=N.id)},sx:{boxShadow:"none",border:Cn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Cn?"#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:[i(d,n({expandIcon:Cn?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Cn?"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:bn&&i(a,n({title:Mn,placement:"top"},{children:i(c,n({component:"div",sx:{fontSize:"12px",color:Cn?"#94A3B8":"#19213D",fontWeight:Cn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(re=Mn,re?b(re).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,e){return n.startsWith("**")&&n.endsWith("**")?i("strong",{children:n.slice(2,-2)},e):i(o.Fragment,{children:n},e)}):null)}))}))})),!Cn&&e(u,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Bn&&i(f,{content:Fn,overlayContent:Rn,sxStyles:Q,highlights:ce,maintainRelativeOrder:U,highlightBg:qn,suppressHighlightBg:_n,deviationBadges:ae,collisionKey:In}),(N.subsections||[]).map(function(n,e){return nn({section:n,keyPath:"".concat(P,"-").concat(e),depth:0,columnKey:D,parentNodeId:Y,sectionOffset:Kn})})]}))]})),V&&(null==ue?void 0:ue.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ue?void 0:ue.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===D?{right:"0px"}:{left:"0px"})},{children:i(v,{color:(null===(E=null==ue?void 0:ue.showBelowRef)||void 0===E?void 0:E.current)?window.getComputedStyle(ue.showBelowRef.current).color:void 0})}))}))]}),"".concat(D,"-sec-").concat(P))};export{S as default};
1
+ import{__assign as n}from"tslib";import{jsxs as i,jsx as e}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as r,AccordionSummary as d,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{useCompareContext as p}from"../CompareContext.js";import{hasValue as h,hasMeaningfulRedlineTags as g,stripRedlineTags as m,generateColorPalette as x,isMissingStr as y,safeStringify as b,DEVIATION_BADGE_SEPARATOR as I}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";var S=function(S){var _,F,k,R,B,C,M,A,O,N,W,j,P,E=S.section,T=S.idx,D=S.columnKey,K=S.colRef,L=S.mb,z=void 0===L?1:L,G=S.isExpanded,H=S.onToggle,V=S.navigation,X=S.parentNodeId,Y=void 0===X?"":X,q=p(),J=q.showOpenNodeRef,Q=q.resolvedMarkdownStyles,U=q.maintainRelativeOrder,Z=q.showDeviationBadges,$=void 0!==Z&&Z,nn=q.renderSubSectionAccordion,en=q.treeData,on=q.proposedSections,tn=q.existingSections,ln=q.deviationNumberRegistry,rn=q.deviationParentRegistry,dn=q.getBadgeRef,an=q.openSummaryPopup,un=q.getSectionCompareStyle,cn=q.connectedSections,sn=q.openMoreFunctionsPopup,vn=q.isProposingFix,fn=q.proposingFixNodeId,pn=q.isRedlineFlow,hn=q.isSideBySide,gn=q.activeSideBySideSection,mn=q.scrollSyncLocked,xn=q.unifiedNumbering,yn=q.toggleScrollSyncLocked,bn=q.summaryPopupAnchorEl,In="".concat(hn?"1":"0","-").concat(String(null!=gn?gn:"")),wn=(null===(_=E.displayTitle)||void 0===_||_)&&h(E.title),Sn=!!vn&&!!fn&&"left"===D&&E.id===fn,_n=g(E.content),Fn="boolean"==typeof pn?pn:_n,kn=_n,Rn=Fn&&_n,Bn=Rn?m(E.content):E.content,Cn=Rn?E.content:void 0,Mn=(null===(F=E.displayContent)||void 0===F||F||_n)&&h(E.content),An=!wn&&!Mn,On=E.title;wn||(On=Mn?"No Title Found":"No Matching Section Found");var Nn=E.evaluationResult;if(!Nn&&"right"===D)if(U){var Wn=null===(k=E.refIndexes)||void 0===k?void 0:k[0],jn=on.find(function(n){return n.selfIndex===Wn});Nn=null==jn?void 0:jn.evaluationResult}else Nn=null===(R=on[T])||void 0===R?void 0:R.evaluationResult;var Pn=null===(B=null==en?void 0:en.input_index_map)||void 0===B?void 0:B[0],En=null===(C=null==en?void 0:en.input_index_map)||void 0===C?void 0:C[1],Tn="left"===D?En:Pn,Dn=function(n,i){var e;if(!i||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===i)return l;if(null===(e=l.subsections)||void 0===e?void 0:e.length){var r=Dn(l.subsections,i);if(r)return r}}return null},Kn="left"===D?E:Dn(on,E.id),Ln="right"===D?E:Dn(tn,E.id),zn=o.useMemo(function(){if(!U)return 0;var n=1/0,i=function(e,o,t,l){var r;if(e){var d=e.id;if(l&&"right"===D){var a=on.filter(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(e.selfIndex)});a.length>0&&(d=a[0].id)}var u=e.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),c=(null===(r=e.evaluationResult)||void 0===r?void 0:r.deviations)||{};Object.keys(c).forEach(function(i){var e="".concat(d).concat(I).concat(i),o=null==ln?void 0:ln[e];null!=o&&o<n&&(n=o);var t="".concat(u).concat(I).concat(i),l=null==ln?void 0:ln[t];null!=l&&l<n&&(n=l)});for(var s=e.subsections||[],v=(null==o?void 0:o.subsections)||[],f=(null==t?void 0:t.subsections)||[],p=Math.max(s.length,v.length,f.length),h=0;h<p;h++)i(s[h],v[h],f[h],!1)}};return i(E,Kn,Ln,!0),n!==1/0?n-1:0},[E,Kn,Ln,D,ln,U,on]);if(U)if("left"===D){var Gn=null===(M=E.refIndexes)||void 0===M?void 0:M[0],Hn=tn.findIndex(function(n){return n.selfIndex===Gn});Ln=-1!==Hn?tn[Hn]:Dn(tn,E.id)}else{var Vn=null===(A=E.refIndexes)||void 0===A?void 0:A[0],Xn=on.findIndex(function(n){return n.selfIndex===Vn});Kn=-1!==Xn?on[Xn]:Dn(on,E.id)}var Yn="left"===D?!Ln:!Kn,qn=Nn||(null==Kn?void 0:Kn.evaluationResult)||(null==Ln?void 0:Ln.evaluationResult),Jn=null!==(W=null===(N=null===(O=null==qn?void 0:qn.evaluation_outputs)||void 0===O?void 0:O.metadata)||void 0===N?void 0:N.label_color)&&void 0!==W?W:w,Qn=x(Jn).highlightBg,Un=(null==qn?void 0:qn.deviations)||{},Zn=E.id;if(U&&"left"!==D){var $n=on.filter(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(E.selfIndex)});$n.length>0?Zn=$n[0].id:(null==Kn?void 0:Kn.id)&&(Zn=Kn.id)}var ni=Object.keys(Un)[0],ii=ni?"".concat(Zn).concat(I).concat(ni):null,ei=ii?null==rn?void 0:rn[ii]:null,oi=T+1;if(U&&xn){var ti="left"===D?xn.leftNums.get(null==E?void 0:E.id):xn.rightNums.get(null==E?void 0:E.id);Yn&&void 0!==ti?oi=ti:null!=ei&&ei>=0?oi=ei:void 0!==ti&&(oi=ti)}else null!=ei&&ei>=0&&(oi=ei);var li=Object.entries(Un).map(function(n){var i=n[0],e=n[1],o="".concat(Zn).concat(I).concat(i);return{deviationKey:i,deviationMap:e,refId:o,currentIndex:ln[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});li.sort(function(n,i){return n.currentIndex-i.currentIndex});var ri,di=li.map(function(i){var e,o,t,l,r,d,a=i.deviationKey,u=i.deviationMap,c=i.refId,s=i.currentIndex;U&&void 0!==zn&&(s-=zn);var v=u[Y],f=y(v);if(f)v="";else if(!v)return null;var p=T,h=T;if(U)if("left"===D){var g=null===(e=E.refIndexes)||void 0===e?void 0:e[0],m=tn.findIndex(function(n){return n.selfIndex===g});if(-1!==m)h=m;else{var b=tn.findIndex(function(n){return n.id===E.id});h=-1!==b?b:T}}else{var w=null===(o=E.refIndexes)||void 0===o?void 0:o[0],S=on.findIndex(function(n){return n.selfIndex===w});if(-1!==S)p=S;else p=-1!==(C=on.findIndex(function(n){return n.id===E.id}))?C:T}var _="".concat(Zn).concat(I).concat(a).concat(I).concat(p).concat(I).concat(h),F=u[Tn],k=Yn||y(F),R="".concat(oi,".").concat(s),B=T;if("right"===D&&U){var C,M=null===(t=E.refIndexes)||void 0===t?void 0:t[0],A=on.findIndex(function(n){return n.selfIndex===M});if(-1!==A)B=A;else-1!==(C=on.findIndex(function(n){return n.id===E.id}))&&(B=C)}var O=un?un(B):null,N=(null==u?void 0:u.evaluation_outputs)||(null==qn?void 0:qn.evaluation_outputs),W=null!==(l=null==N?void 0:N.output_value)&&void 0!==l?l:null,j=null!==(d=null===(r=null==N?void 0:N.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:Jn,P=x(j),K=O?n(n({},O),{badgeBg:P.badgeBg,badgeBorder:P.badgeBorder,badgeText:P.badgeText}):n({},P),L=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==qn?void 0:qn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==qn?void 0:qn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==qn?void 0:qn.deviation_explanation),evaluation_outputs:N,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==qn?void 0:qn.cognitive_decisioning)}:null,z=0,G=Bn||"";if(v&&G){var H=G.split(/\n{2,}/),V=H.findIndex(function(n){return n.includes(v)});if(-1!==V){var X=Object.entries(Un).filter(function(n){n[0];var i=n[1][Y];return i&&H[V].includes(i)}).sort(function(n,i){return H[V].indexOf(n[1][Y])-H[V].indexOf(i[1][Y])}),q=X.filter(function(n){n[0];var i=n[1][Y];return i&&(i.includes(v)||v.includes(i))});q.length>1&&(z=Math.max(0,q.findIndex(function(n){return n[0]===a})))}}var J=dn(D,c);return{id:c,actionId:_,label:R,highlight:v,side:D,style:K,stackIndex:z,score:W,isConnected:null==cn?void 0:cn.has(_),showScrollLockToggle:(null==cn?void 0:cn.has(_))||hn&&gn===_||!!bn&&bn===J.current,scrollSyncLocked:mn,toggleScrollSyncLocked:yn,isOrphan:k,isMissingClause:f,badgeRef:J,onClick:function(n){n.stopPropagation(),sn&&sn(n,Kn||{id:"orphan-left",title:"",content:""},k,Ln||{id:"orphan-right",title:"",content:""},_,K)},onSummaryClick:function(n){n.stopPropagation(),an(n,_,k,L)}}}).filter(Boolean),ai=$||!Fn&&Sn?di:[],ui=di.map(function(n){return n.highlight}).filter(Boolean),ci=E.id&&D===(null==V?void 0:V.columnKey)?V:null,si=o.useRef(!1);return t(function(){G||(si.current=!1)},[G]),i(l,n({ref:K,sx:{mb:z,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[G&&(null==ci?void 0:ci.showAbove)&&e("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,i;return null===(i=null===(n=null==ci?void 0:ci.showAboveRef)||void 0===n?void 0:n.current)||void 0===i?void 0:i.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===D?{right:"-20px"}:{left:"-20px"})},{children:e(s,{color:(null===(j=null==ci?void 0:ci.showAboveRef)||void 0===j?void 0:j.current)?window.getComputedStyle(ci.showAboveRef.current).color:void 0})}))})),i(r,n({disableGutters:!0,expanded:!An&&G,onChange:function(){An||(H(),J.current=E.id)},sx:{boxShadow:"none",border:An?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:An?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e(d,n({expandIcon:An?null:e(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:An?"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:wn&&e(a,n({title:On,placement:"top"},{children:e(u,n({component:"div",sx:{fontSize:"12px",color:An?"#94A3B8":"#19213D",fontWeight:An?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ri=On,ri?b(ri).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,i){return n.startsWith("**")&&n.endsWith("**")?e("strong",{children:n.slice(2,-2)},i):e(o.Fragment,{children:n},i)}):null)}))}))})),!An&&i(c,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Mn&&e(f,{content:Bn,overlayContent:Cn,sxStyles:Q,highlights:ui,maintainRelativeOrder:U,highlightBg:Qn,suppressHighlightBg:kn,deviationBadges:ai,collisionKey:In}),(E.subsections||[]).map(function(n,i){return nn({section:n,keyPath:"".concat(T,"-").concat(i),depth:0,columnKey:D,parentNodeId:Y,sectionOffset:zn})})]}))]})),G&&(null==ci?void 0:ci.showBelow)&&e("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,i;return null===(i=null===(n=null==ci?void 0:ci.showBelowRef)||void 0===n?void 0:n.current)||void 0===i?void 0:i.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===D?{right:"-20px"}:{left:"-20px"})},{children:e(v,{color:(null===(P=null==ci?void 0:ci.showBelowRef)||void 0===P?void 0:P.current)?window.getComputedStyle(ci.showBelowRef.current).color:void 0})}))}))]}),"".concat(D,"-sec-").concat(T))};export{S as default};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n}from"tslib";import{jsx as i,jsxs as e}from"react/jsx-runtime";import t from"react";import{Box as o,Accordion as l,AccordionSummary as d,Typography as r,AccordionDetails as a}from"@mui/material";import{ChevronDown as u}from"lucide-react";import{MemoizedMarkdown as c}from"../hooks/memoizedMarkdown.js";import{useCompareContext as s}from"../CompareContext.js";import{hasValue as v,hasMeaningfulRedlineTags as f,stripRedlineTags as p,generateColorPalette as h,isMissingStr as m,DEVIATION_BADGE_SEPARATOR as g}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as x}from"../CognitiveCompareConstants.js";var y=t.memo(function(t){var S,b,I,_,k,C,w,P,B,F,R=t.section,O=t.keyPath,M=t.depth,E=void 0===M?0:M,j=t.columnKey,N=void 0===j?"left":j,K=t.parentNodeId,W=void 0===K?"":K,L=t.sectionOffset,z=s(),A=z.expandedSubSections,D=z.setExpandedSubSections,H=z.maintainRelativeOrder,T=z.showDeviationBadges,G=void 0!==T&&T,U=z.proposedSections,q=z.existingSections,J=z.treeData,Q=z.deviationNumberRegistry,V=z.connectedSections,X=z.activeSideBySideSection,Y=z.isSideBySide,Z=z.scrollSyncLocked,$=z.toggleScrollSyncLocked,nn=z.summaryPopupAnchorEl,en=z.resolvedMarkdownStyles,tn=z.getSubSectionRef,on=z.getSubSectionCompareStyle,ln=z.getBadgeRef,dn=z.openMoreFunctionsPopup,rn=z.openSummaryPopup,an=z.resetSideBySide,un=z.setConnectedSections,cn=z.setConnectedLines,sn=z.cachedConnectedPositions,vn=z.isProposingFix,fn=z.proposingFixNodeId,pn=z.isRedlineFlow,hn=null!=X?X:"",mn=(null===(S=R.displayTitle)||void 0===S||S)&&v(R.title),gn=!!vn&&!!fn&&"left"===N&&R.id===fn,xn=f(R.content),yn="boolean"==typeof pn?pn:xn,Sn=xn,bn=yn&&xn,In=bn?p(R.content):R.content,_n=bn?R.content:void 0,kn=(null===(b=R.displayContent)||void 0===b||b||xn)&&v(R.content),Cn=!mn&&!kn,wn=mn?R.title:kn?"No Title Found":"No Matching Section Found",Pn=!!A[O],Bn=tn(N,O),Fn=O.split("-").map(Number)[0],Rn=U[Fn],On=q[Fn],Mn=Fn,En=Fn,jn=function(n,i,e){if(!n||!i)return null;if(n.id===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(H)if("left"===N){var Nn=null===(I=null==Rn?void 0:Rn.refIndexes)||void 0===I?void 0:I[0],Kn=q.findIndex(function(n){return n.selfIndex===Nn});-1!==Kn&&(On=q[Kn],En=Kn)}else{var Wn=null===(_=null==On?void 0:On.refIndexes)||void 0===_?void 0:_[0],Ln=U.findIndex(function(n){return n.selfIndex===Wn});-1!==Ln&&(Rn=U[Ln],Mn=Ln)}var zn=function(n,i){if(!i||!n)return null;for(var e=0;e<n.length;e++){var t=jn(n[e],i,String(e));if(t)return t}return null},An=null,Dn=null,Hn="",Tn="";if(H)"left"===N?(An=R,Hn=O,(Gn=jn(On,R.id,String(En)))||(Gn=zn(q,R.id)),Dn=(null==Gn?void 0:Gn.section)||null,Tn=(null==Gn?void 0:Gn.keyPath)||""):(Dn=R,Tn=O,(Un=jn(Rn,R.id,String(Mn)))||(Un=zn(U,R.id)),An=(null==Un?void 0:Un.section)||null,Hn=(null==Un?void 0:Un.keyPath)||"");else if("left"===N){An=R,Hn=O;var Gn=zn(q,R.id);Dn=(null==Gn?void 0:Gn.section)||null,Tn=(null==Gn?void 0:Gn.keyPath)||""}else{Dn=R,Tn=O;var Un=zn(U,R.id);An=(null==Un?void 0:Un.section)||null,Hn=(null==Un?void 0:Un.keyPath)||""}var qn=(Hn?on(Hn):null)||on(O),Jn=null===(k=null==J?void 0:J.input_index_map)||void 0===k?void 0:k[0],Qn=null===(C=null==J?void 0:J.input_index_map)||void 0===C?void 0:C[1],Vn="left"===N?Qn:Jn,Xn="left"===N?!Dn:!An,Yn=R.evaluationResult||(null==An?void 0:An.evaluationResult)||(null==Dn?void 0:Dn.evaluationResult),Zn=Fn+1,$n=R.id||(null==An?void 0:An.id)||(null==Dn?void 0:Dn.id);if(H){var ni=1,ii=new Map;if(U.forEach(function(n){!n.title&&!n.content||n.id&&ii.set(n.id,ni++)}),"left"===N)Zn=ii.get(null==Rn?void 0:Rn.id)||Fn+1;else{var ei=U.filter(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(null==On?void 0:On.selfIndex)});if(ei.length>0)Zn=ii.get(ei[0].id)||Fn+1;else for(var ti=ni,oi=function(n){if(!n.title&&!n.content)return"continue";var i=U.some(function(i){var e;return null===(e=i.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});if(!i){if(n.id===(null==On?void 0:On.id))return Zn=ti,"break";ti++}},li=0,di=q;li<di.length;li++){if("break"===oi(di[li]))break}}}var ri=null!==(B=null===(P=null===(w=null==Yn?void 0:Yn.evaluation_outputs)||void 0===w?void 0:w.metadata)||void 0===P?void 0:P.label_color)&&void 0!==B?B:x,ai=h(ri).highlightBg,ui=(null==Yn?void 0:Yn.deviations)||{},ci=Object.entries(ui).map(function(n){var i=n[0],e=n[1],t="".concat($n).concat(g).concat(i);return{deviationKey:i,deviationMap:e,refId:t,currentIndex:Q[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});ci.sort(function(n,i){return n.currentIndex-i.currentIndex});var si=ci.map(function(i){var e,t,o,l=i.deviationKey,d=i.deviationMap,r=i.refId,a=i.currentIndex;H&&void 0!==L&&(a-=L);var u=d[W],c=m(u);if(c)u="";else if(!u)return null;var s=d[Vn],v=Xn||m(s),f="".concat(Zn,".").concat(a),p="".concat($n).concat(g).concat(l).concat(g).concat(Hn).concat(g).concat(Tn),x=(null==d?void 0:d.evaluation_outputs)||(null==Yn?void 0:Yn.evaluation_outputs),y=null!==(e=null==x?void 0:x.output_value)&&void 0!==e?e:null,S=null!==(o=null===(t=null==x?void 0:x.metadata)||void 0===t?void 0:t.label_color)&&void 0!==o?o:ri,b=h(S),I=n({},b),_=(null==d?void 0:d.deviation_summary)?{deviation_summary:d.deviation_summary||(null==Yn?void 0:Yn.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==Yn?void 0:Yn.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==Yn?void 0:Yn.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==Yn?void 0:Yn.deviation_explanation),evaluation_outputs:x,cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==Yn?void 0:Yn.cognitive_decisioning)}:null,k=0,C=In||"";if(u&&C){var w=C.split(/\n{2,}/),P=w.findIndex(function(n){return n.includes(u)});if(-1!==P){var B=Object.entries(ui).filter(function(n){n[0];var i=n[1][W];return i&&w[P].includes(i)}).sort(function(n,i){return w[P].indexOf(n[1][W])-w[P].indexOf(i[1][W])}),F=B.filter(function(n){n[0];var i=n[1][W];return i&&(i.includes(u)||u.includes(i))});F.length>1&&(k=Math.max(0,F.findIndex(function(n){return n[0]===l})))}}var R=ln(N,r);return{id:r,actionId:p,label:f,highlight:u,side:N,style:I,stackIndex:k,score:y,isConnected:V.has(p),showScrollLockToggle:V.has(p)||Y&&X===p||!!nn&&nn===R.current,scrollSyncLocked:Z,toggleScrollSyncLocked:$,isOrphan:v,isMissingClause:c,badgeRef:R,onClick:function(i){i.stopPropagation();var e=An?n(n({},An),{title:(null==Rn?void 0:Rn.title)||(null==An?void 0:An.title)||""}):{id:"orphan-left",title:"",content:""},t=Dn?n(n({},Dn),{title:(null==On?void 0:On.title)||(null==Dn?void 0:Dn.title)||""}):{id:"orphan-right",title:"",content:""};dn(i,e,v,t,p,I)},onSummaryClick:function(n){n.stopPropagation(),rn(n,p,v,_)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),vi=G||!yn&&gn?si:[],fi=si.map(function(n){return n.highlight}).filter(Boolean),pi=si.find(function(n){return V.has(n.actionId)}),hi=!!pi;if(!(mn||kn||R.subsections&&0!==R.subsections.length))return null;var mi=(null===(F=null==pi?void 0:pi.style)||void 0===F?void 0:F.badgeBorder)||(null==qn?void 0:qn.badgeBorder),gi=hi&&mi?{borderRadius:"4px",outline:"2px solid ".concat(mi),outlineOffset:"1px"}:{};return i(o,mn?n({ref:Bn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(o,n({sx:n({width:"100%"},gi)},{children:e(l,n({disableGutters:!0,expanded:!Cn&&Pn,onChange:function(){if(!Cn){if(Pn){var i=String(X||""),e=i.includes(Hn)||i.includes(Tn);e||V.forEach(function(n){(String(n).includes(Hn)||String(n).includes(Tn))&&(e=!0)}),e&&(an(),un(new Set),cn([]),sn.current=[])}D(function(i){var e;return n(n({},i),((e={})[O]=!i[O],e))})}},sx:{mt:0,boxShadow:"none",border:Cn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(d,n({expandIcon:Cn?null:i(u,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i(r,n({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Cn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:wn||"Untitled Subsection"}))})),!Cn&&e(a,n({sx:{pt:0,pb:1,minWidth:0}},{children:[kn&&i(c,{content:In,overlayContent:_n,sxStyles:en,deviationBadges:vi,maintainRelativeOrder:H,highlightBg:ai,suppressHighlightBg:Sn,highlights:fi,collisionKey:hn}),(R.subsections||[]).map(function(n,e){return i(y,{section:n,keyPath:"".concat(O,"-").concat(e),depth:E+1,columnKey:N,parentNodeId:W},"".concat(O,"-").concat(e))})]}))]}))}))}):n({ref:Bn,sx:{mt:0===E?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Cn&&e(o,n({sx:n({width:"100%"},gi)},{children:[kn&&i(c,{content:In,overlayContent:_n,sxStyles:en,deviationBadges:vi,maintainRelativeOrder:H,highlightBg:ai,suppressHighlightBg:Sn,highlights:fi,collisionKey:hn}),(R.subsections||[]).map(function(n,e){return i(y,{section:n,keyPath:"".concat(O,"-").concat(e),depth:E+1,columnKey:N,parentNodeId:W,sectionOffset:L},"".concat(O,"-").concat(e))})]}))}))});export{y as default};
1
+ import{__assign as n}from"tslib";import{jsx as i,jsxs as e}from"react/jsx-runtime";import t,{useMemo as o}from"react";import{Box as l,Accordion as d,AccordionSummary as r,Typography as a,AccordionDetails as u}from"@mui/material";import{ChevronDown as c}from"lucide-react";import{MemoizedMarkdown as s}from"../hooks/memoizedMarkdown.js";import{useCompareContext as v}from"../CompareContext.js";import{hasValue as f,hasMeaningfulRedlineTags as p,stripRedlineTags as h,generateColorPalette as m,isMissingStr as g,DEVIATION_BADGE_SEPARATOR as x}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as y}from"../CognitiveCompareConstants.js";var S=t.memo(function(t){var b,_,I,k,C,P,w,B,F,R,O=t.section,N=t.keyPath,j=t.depth,M=void 0===j?0:j,E=t.columnKey,K=void 0===E?"left":E,W=t.parentNodeId,L=void 0===W?"":W,z=t.sectionOffset,A=v(),D=A.expandedSubSections,H=A.setExpandedSubSections,T=A.maintainRelativeOrder,G=A.showDeviationBadges,U=void 0!==G&&G,q=A.proposedSections,J=A.existingSections,Q=A.treeData,V=A.deviationNumberRegistry,X=A.deviationParentRegistry,Y=A.connectedSections,Z=A.activeSideBySideSection,$=A.isSideBySide,nn=A.scrollSyncLocked,en=A.toggleScrollSyncLocked,tn=A.summaryPopupAnchorEl,on=A.resolvedMarkdownStyles,ln=A.getSubSectionRef,dn=A.getSubSectionCompareStyle,rn=A.getBadgeRef,an=A.openMoreFunctionsPopup,un=A.openSummaryPopup,cn=A.resetSideBySide,sn=A.setConnectedSections,vn=A.setConnectedLines,fn=A.cachedConnectedPositions,pn=A.isProposingFix,hn=A.proposingFixNodeId,mn=A.isRedlineFlow,gn=A.unifiedNumbering,xn=null!=Z?Z:"",yn=(null===(b=O.displayTitle)||void 0===b||b)&&f(O.title),Sn=!!pn&&!!hn&&"left"===K&&O.id===hn,bn=p(O.content),_n="boolean"==typeof mn?mn:bn,In=bn,kn=_n&&bn,Cn=kn?h(O.content):O.content,Pn=kn?O.content:void 0,wn=(null===(_=O.displayContent)||void 0===_||_||bn)&&f(O.content),Bn=!yn&&!wn,Fn=yn?O.title:wn?"No Title Found":"No Matching Section Found",Rn=!!D[N],On=ln(K,N),Nn=N.split("-").map(Number)[0],jn=q[Nn],Mn=J[Nn],En=Nn,Kn=Nn,Wn=!1,Ln=function(n,i,e){if(!n||!i)return null;if(n.id===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(T)if("left"===K){var zn=null===(I=null==jn?void 0:jn.refIndexes)||void 0===I?void 0:I[0],An=J.findIndex(function(n){return n.selfIndex===zn});-1!==An?(Mn=J[An],Kn=An):Wn=!0}else{var Dn=null===(k=null==Mn?void 0:Mn.refIndexes)||void 0===k?void 0:k[0],Hn=q.findIndex(function(n){return n.selfIndex===Dn});-1!==Hn?(jn=q[Hn],En=Hn):Wn=!0}var Tn=function(n,i){if(!i||!n)return null;for(var e=0;e<n.length;e++){var t=Ln(n[e],i,String(e));if(t)return t}return null},Gn=null,Un=null,qn="",Jn="";if(T)"left"===K?(Gn=O,qn=N,(Qn=Ln(Mn,O.id,String(Kn)))||(Qn=Tn(J,O.id)),Un=(null==Qn?void 0:Qn.section)||null,Jn=(null==Qn?void 0:Qn.keyPath)||""):(Un=O,Jn=N,(Vn=Ln(jn,O.id,String(En)))||(Vn=Tn(q,O.id)),Gn=(null==Vn?void 0:Vn.section)||null,qn=(null==Vn?void 0:Vn.keyPath)||"");else if("left"===K){Gn=O,qn=N;var Qn=Tn(J,O.id);Un=(null==Qn?void 0:Qn.section)||null,Jn=(null==Qn?void 0:Qn.keyPath)||""}else{Un=O,Jn=N;var Vn=Tn(q,O.id);Gn=(null==Vn?void 0:Vn.section)||null,qn=(null==Vn?void 0:Vn.keyPath)||""}var Xn=(qn?dn(qn):null)||dn(N),Yn=null===(C=null==Q?void 0:Q.input_index_map)||void 0===C?void 0:C[0],Zn=null===(P=null==Q?void 0:Q.input_index_map)||void 0===P?void 0:P[1],$n="left"===K?Zn:Yn,ni="left"===K?!Un:!Gn,ii=O.evaluationResult||(null==Gn?void 0:Gn.evaluationResult)||(null==Un?void 0:Un.evaluationResult),ei=(null==ii?void 0:ii.deviations)||{},ti=O.id||(null==Gn?void 0:Gn.id)||(null==Un?void 0:Un.id);T&&"left"!==K&&(null==Gn?void 0:Gn.id)&&(ti=Gn.id);var oi=Object.keys(ei)[0],li=oi?"".concat(ti).concat(x).concat(oi):null,di=li?null==X?void 0:X[li]:null,ri=Nn+1;if(T&&gn){var ai="left"===K?gn.leftNums.get(null==jn?void 0:jn.id):gn.rightNums.get(null==Mn?void 0:Mn.id);Wn&&void 0!==ai?ri=ai:null!=di&&di>=0?ri=di:void 0!==ai&&(ri=ai)}else null!=di&&di>=0&&(ri=di);var ui=null!==(F=null===(B=null===(w=null==ii?void 0:ii.evaluation_outputs)||void 0===w?void 0:w.metadata)||void 0===B?void 0:B.label_color)&&void 0!==F?F:y,ci=m(ui).highlightBg,si=Object.entries(ei).map(function(n){var i=n[0],e=n[1],t="".concat(ti).concat(x).concat(i);return{deviationKey:i,deviationMap:e,refId:t,currentIndex:V[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});si.sort(function(n,i){return n.currentIndex-i.currentIndex});var vi=si.map(function(i){var e,t,o,l=i.deviationKey,d=i.deviationMap,r=i.refId,a=i.currentIndex;T&&void 0!==z&&(a-=z);var u=d[L],c=g(u);if(c)u="";else if(!u)return null;var s=d[$n],v=ni||g(s),f="".concat(ri,".").concat(a),p="".concat(ti).concat(x).concat(l).concat(x).concat(qn).concat(x).concat(Jn),h=(null==d?void 0:d.evaluation_outputs)||(null==ii?void 0:ii.evaluation_outputs),y=null!==(e=null==h?void 0:h.output_value)&&void 0!==e?e:null,S=null!==(o=null===(t=null==h?void 0:h.metadata)||void 0===t?void 0:t.label_color)&&void 0!==o?o:ui,b=m(S),_=n({},b),I=(null==d?void 0:d.deviation_summary)?{deviation_summary:d.deviation_summary||(null==ii?void 0:ii.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==ii?void 0:ii.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==ii?void 0:ii.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==ii?void 0:ii.deviation_explanation),evaluation_outputs:h,cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==ii?void 0:ii.cognitive_decisioning)}:null,k=0,C=Cn||"";if(u&&C){var P=C.split(/\n{2,}/),w=P.findIndex(function(n){return n.includes(u)});if(-1!==w){var B=Object.entries(ei).filter(function(n){n[0];var i=n[1][L];return i&&P[w].includes(i)}).sort(function(n,i){return P[w].indexOf(n[1][L])-P[w].indexOf(i[1][L])}),F=B.filter(function(n){n[0];var i=n[1][L];return i&&(i.includes(u)||u.includes(i))});F.length>1&&(k=Math.max(0,F.findIndex(function(n){return n[0]===l})))}}var R=rn(K,r);return{id:r,actionId:p,label:f,highlight:u,side:K,style:_,stackIndex:k,score:y,isConnected:Y.has(p),showScrollLockToggle:Y.has(p)||$&&Z===p||!!tn&&tn===R.current,scrollSyncLocked:nn,toggleScrollSyncLocked:en,isOrphan:v,isMissingClause:c,badgeRef:R,onClick:function(i){i.stopPropagation();var e=Gn?n(n({},Gn),{title:(null==jn?void 0:jn.title)||(null==Gn?void 0:Gn.title)||""}):{id:"orphan-left",title:"",content:""},t=Un?n(n({},Un),{title:(null==Mn?void 0:Mn.title)||(null==Un?void 0:Un.title)||""}):{id:"orphan-right",title:"",content:""};an(i,e,v,t,p,_)},onSummaryClick:function(n){n.stopPropagation(),un(n,p,v,I)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),fi=o(function(){var n=new Set;return vi.filter(function(i){return!n.has(i.id)&&(n.add(i.id),!0)})},[vi]),pi=U||!_n&&Sn?fi:[],hi=fi.map(function(n){return n.highlight}).filter(Boolean),mi=vi.find(function(n){return Y.has(n.actionId)}),gi=!!mi;if(!(yn||wn||O.subsections&&0!==O.subsections.length))return null;var xi=(null===(R=null==mi?void 0:mi.style)||void 0===R?void 0:R.badgeBorder)||(null==Xn?void 0:Xn.badgeBorder),yi=gi&&xi?{borderRadius:"4px",outline:"2px solid ".concat(xi),outlineOffset:"1px"}:{};return i(l,yn?n({ref:On,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(l,n({sx:n({width:"100%"},yi)},{children:e(d,n({disableGutters:!0,expanded:!Bn&&Rn,onChange:function(){if(!Bn){if(Rn){var i=String(Z||""),e=i.includes(qn)||i.includes(Jn);e||Y.forEach(function(n){(String(n).includes(qn)||String(n).includes(Jn))&&(e=!0)}),e&&(cn(),sn(new Set),vn([]),fn.current=[])}H(function(i){var e;return n(n({},i),((e={})[N]=!i[N],e))})}},sx:{mt:0,boxShadow:"none",border:Bn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(r,n({expandIcon:Bn?null:i(c,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i(a,n({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Bn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Fn||"Untitled Subsection"}))})),!Bn&&e(u,n({sx:{pt:0,pb:1,minWidth:0}},{children:[wn&&i(s,{content:Cn,overlayContent:Pn,sxStyles:on,deviationBadges:pi,maintainRelativeOrder:T,highlightBg:ci,suppressHighlightBg:In,highlights:hi,collisionKey:xn}),(O.subsections||[]).map(function(n,e){return i(S,{section:n,keyPath:"".concat(N,"-").concat(e),depth:M+1,columnKey:K,parentNodeId:L},"".concat(N,"-").concat(e))})]}))]}))}))}):n({ref:On,sx:{mt:0===M?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Bn&&e(l,n({sx:n({width:"100%"},yi)},{children:[wn&&i(s,{content:Cn,overlayContent:Pn,sxStyles:on,deviationBadges:pi,maintainRelativeOrder:T,highlightBg:ci,suppressHighlightBg:In,highlights:hi,collisionKey:xn}),(O.subsections||[]).map(function(n,e){return i(S,{section:n,keyPath:"".concat(N,"-").concat(e),depth:M+1,columnKey:K,parentNodeId:L,sectionOffset:z},"".concat(N,"-").concat(e))})]}))}))});export{S as default};
2
2
  //# sourceMappingURL=SubSectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n,__rest as e}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{mixHexColors as g,areMarkdownPropsEqual as f}from"../CognitiveComparehelpers.js";import v from"rehype-raw";import m from"remark-gfm";var x=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},b=[x(m)],y=[x(v)],E=l.memo(function(f){var v=f.content,m=f.overlayContent,x=f.sxStyles,E=f.deviationBadges,C=void 0===E?[]:E,B=f.highlights,k=void 0===B?[]:B;f.maintainRelativeOrder;var S=f.highlightBg,F=f.suppressHighlightBg,w=void 0!==F&&F,A=f.collisionKey,z=c(null),T=!!m,I=d(function(){return C.reduce(function(e,t){var r;return n(n({},e),((r={})[t.id]=t,r))},{})},[C]),O=c({badgeMap:I,highlightBg:S,hideHighlightBg:T,suppressHighlightBg:w});O.current={badgeMap:I,highlightBg:S,hideHighlightBg:T,suppressHighlightBg:w};var M=function(e,t){return l.Children.map(e,function(e){var r;if(!l.isValidElement(e))return e;var i=(null===(r=e.props)||void 0===r?void 0:r.children)?M(e.props.children,t):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return t(o)})},j=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=e(r,["children"]),s=O.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=d["data-badge-id"],v=f?u[f]:null,m=d["data-highlight-color"],x=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,b="true"===d["data-is-suggested-deviation-fix"]||g;return t("span",n({style:n(n(n({},b?{}:{backgroundColor:x}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,g=i.children,f=e(i,["children"]),v=O.current.badgeMap,m=f["data-badge-id"];if(!m)return t("span",n({},f,{children:g}));var x=v[m];if(!x)return t("span",n({},f,{children:g}));var b="number"==typeof x.stackIndex?x.stackIndex:0,y="translateY(calc(-20% + ".concat(12*b,"px + var(--badge-nudge, 0px)))");return r(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,n({ref:x.badgeRef,className:"deviation-badge","data-side":x.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+b,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=x.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=x.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=x.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===x.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),x.isConnected&&x.style&&{outline:"2px solid ".concat(x.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,n({onClick:function(n){n.stopPropagation(),x.onSummaryClick&&x.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:x.label})),("left"===x.side||x.isOrphan)&&t(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=x.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=x.score&&"N/A"!==x.score&&"NA"!==x.score&&0!==x.score?"".concat(x.score):"N/A"===x.score||"NA"===x.score?"N/A":"Same"}))]})),("left"===x.side||x.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),x.onClick&&x.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=x.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=x.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),g]}))},table:function(e){var r=e.children;return t(o,n({component:"table",sx:{width:"100%",borderCollapse:"collapse",my:1,fontSize:"inherit"}},{children:r}))},thead:function(e){var r=e.children;return t(o,n({component:"thead"},{children:r}))},tbody:function(e){var r=e.children;return t(o,n({component:"tbody"},{children:r}))},tr:function(e){var r=e.children;return t(o,n({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(e){var r=e.children;return t(o,n({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",fontWeight:600,backgroundColor:"#F9FAFB"}},{children:r}))},td:function(e){var r=e.children;return t(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top"}},{children:r}))},code:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(n){var e=n.children;return t(i,{children:e})},deleted:function(e){var r=e.children,i=M(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(e){var r=e.children,i=M(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))}}},[]),P=function(n){if(!n||"string"!=typeof n)return"";var e=n.replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n"),t=(e=(e=(e=e.replace(/^(\d+\.)(\s{2,})/gm,function(n,e,t){return"".concat(e.slice(0,-1),"\\.").concat(t)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,r){return"".concat(e," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).split(/(\n{2,})/);return e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var r,i=null!==(r=n[t+1])&&void 0!==r?r:"";return/^[#>|\-*+]/.test(i)||/^\d+\./.test(n.slice(t+1))?"\n":" "})}).join(""),e=e.replace(/^[ \t]+/gm,function(n){return n.replace(/ /g," ").replace(/\t/g,"    ")})},D=function(n){return n.replace(/[\.,;:]/g," ")},H=d(function(){return C.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[C]),N=d(function(){var e=P(v||""),t=w?D(e):e,r=(C||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:P((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||S}}).filter(function(n){return n.id&&n.highlight}),i={};r.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var o=function(n,e,t,r){void 0===e&&(e=""),void 0===r&&(r=[]);var i=!1,o=function(n){var o=function(n,e,t){var r,i,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var l=null!==(r=a[1])&&void 0!==r?r:"",c=null!==(i=a[2])&&void 0!==i?i:"",d=null!==(o=a[3])&&void 0!==o?o:"";return c?l+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",r=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(r).concat(t,">")}(e,t)+c+"</mark>"+d:n}(n,e,t),a=o;if(!i&&r.length>0){i=!0;var l="",c="";r.forEach(function(n){l+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),c="</span>"+c}),a=l+o+c}return"​"+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},a=[];Object.entries(i).forEach(function(n){var r=n[0],i=n[1],o=e.indexOf(r),l=!1;if(-1===o&&w){var c=D(r);-1!==(o=t.indexOf(c))&&(l=!0)}if(-1!==o){for(var d=i[0].highlightColor,s=1;s<i.length;s++)d=g(d,i[s].highlightColor||"");a.push({highlight:r,start:o,end:o+r.length,badges:i,color:d,usedLooseMatch:l})}});var l=new Set(Object.keys(i));(k||[]).forEach(function(n){if(n){var r=P(n);if(r&&!l.has(r)){var i=e.indexOf(r),o=!1;if(-1===i&&w){var c=D(r);-1!==(i=t.indexOf(c))&&(o=!0)}if(-1!==i){var d=e.slice(0,i);(d.match(/</g)||[]).length===(d.match(/>/g)||[]).length&&a.push({highlight:r,start:i,end:i+r.length,badges:[],color:S||"",usedLooseMatch:o})}}}}),a.sort(function(n,e){return n.start-e.start||e.end-n.end});var c=[],d={};a.forEach(function(n,e){for(var t=n.start,r=n.end,i=0,o=c;i<o.length;i++){var a=o[i],l=a.start,s=a.end,u=t<s&&r>s&&t>=l,h=t<l&&r>l&&r<=s;if(t>=l&&r<=s){n.orphaned=!0,d[e]=a.matchIdx;break}u&&(t=s),h&&(r=l)}n.trimmedStart=t,n.trimmedEnd=r,!n.orphaned&&t<r&&c.push({start:t,end:r,matchIdx:e})});var s={};Object.entries(d).forEach(function(n){var e=n[0],t=n[1],r=Number(e);s[t]||(s[t]=[]),s[t].push(r)});var u=a.map(function(e,t){return n(n({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,r;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)});return u.forEach(function(n){var t,r,i,l,c=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,d=null!==(r=n.trimmedEnd)&&void 0!==r?r:n.end;if(!(c>=d)){var u=e.slice(c,d),h=function(n,e,t,r){if(!t.length)return n;var i=t.map(function(n){return a[n]}).sort(function(n,e){return n.start-e.start}),l="",c=0;return i.forEach(function(t){var i,a,d=Math.max(c,t.start-e),s=Math.max(d,t.end-e);if(!(d>=s)){var u=g(r,t.color||"");l+=n.slice(c,d),l+=o(n.slice(d,s),(null===(a=null===(i=t.badges)||void 0===i?void 0:i[0])||void 0===a?void 0:a.id)||"",u,t.badges||[]),c=s}}),l+=n.slice(c)}(n.usedLooseMatch||c!==n.start||d!==n.end?u:n.highlight,n.start,s[n.idx]||[],n.color),p=o(h,(null===(l=null===(i=n.badges)||void 0===i?void 0:i[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,c)+p+e.slice(d)}}),e},[v,C,k,S,w]),R=d(function(){return m?P(m||""):""},[m]),$=!!m,L={"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}},q=n(n(n(n({},x),L),{position:"relative",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),$?{color:"transparent"}:{}),W=n(n(n({},x),L),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap",gridArea:"1 / 1",zIndex:1,pointerEvents:"none"});return s(function(){if(z.current){var n=function(){var n=Array.from(z.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),r=z.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],r=[];e.forEach(function(n){if(0===r.length)r.push(n);else{var e=r[r.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,r.push(n)):(t.push(r),r=[n])}}),r.length>0&&t.push(r),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>i){var r=t-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(r,a));n.forEach(function(n){n.currentTop-=l})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(z.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[N,A,H]),r(o,n({ref:z,sx:{position:"relative",display:"grid"}},{children:[t(a,n({component:"div",sx:n(n({},q),{padding:"3px"})},{children:t(p,n({components:j,remarkPlugins:b,rehypePlugins:y},{children:N.replace(/#{3}/g,"")}))})),$&&t(a,n({component:"div",sx:W},{children:t(p,n({components:j,remarkPlugins:b,rehypePlugins:y},{children:R}))}))]}))},f);export{E as MemoizedMarkdown};
1
+ import{__assign as n,__rest as e}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{mixHexColors as g,areMarkdownPropsEqual as f}from"../CognitiveComparehelpers.js";import v from"rehype-raw";import m from"remark-gfm";var b=function(n){return"function"==typeof n?n:(null==n?void 0:n.default)||n},x=[b(m)],y=[b(v)],E=l.memo(function(f){var v=f.content,m=f.overlayContent,b=f.sxStyles,E=f.deviationBadges,C=void 0===E?[]:E,S=f.highlights,k=void 0===S?[]:S;f.maintainRelativeOrder;var B=f.highlightBg,F=f.suppressHighlightBg,w=void 0!==F&&F,A=f.collisionKey,T=c(null),z=!!m,I=d(function(){return C.reduce(function(e,t){var r;return n(n({},e),((r={})[t.id]=t,r))},{})},[C]),O=c({badgeMap:I,highlightBg:B,hideHighlightBg:z,suppressHighlightBg:w});O.current={badgeMap:I,highlightBg:B,hideHighlightBg:z,suppressHighlightBg:w};var M=function(e,t){return l.Children.map(e,function(e){var r;if(!l.isValidElement(e))return e;var i=(null===(r=e.props)||void 0===r?void 0:r.children)?M(e.props.children,t):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return t(o)})},$=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=e(r,["children"]),s=O.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,g=s.suppressHighlightBg,f=d["data-badge-id"],v=f?u[f]:null,m=d["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===d["data-is-suggested-deviation-fix"]||g;return t("span",n({style:n(n(n({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,g=i.children,f=e(i,["children"]),v=O.current.badgeMap,m=f["data-badge-id"];if(!m)return t("span",n({},f,{children:g}));var b=v[m];if(!b)return t("span",n({},f,{children:g}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,n({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,n({onClick:function(n){n.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),b.onClick&&b.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),g]}))},table:function(e){var r=e.children;return t(o,n({component:"table",sx:{width:"100%",borderCollapse:"collapse",my:1,fontSize:"inherit"}},{children:r}))},thead:function(e){var r=e.children;return t(o,n({component:"thead"},{children:r}))},tbody:function(e){var r=e.children;return t(o,n({component:"tbody"},{children:r}))},tr:function(e){var r=e.children;return t(o,n({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(e){var r=e.children;return t(o,n({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",fontWeight:600,backgroundColor:"#F9FAFB"}},{children:r}))},td:function(e){var r=e.children;return t(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top"}},{children:r}))},code:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(e){var r=e.children;return t("span",n({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(n){var e=n.children;return t(i,{children:e})},deleted:function(e){var r=e.children,i=M(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(e){var r=e.children,i=M(r,function(n){return l.cloneElement(n,{"data-is-suggested-deviation-fix":"true"})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=e(r,["children"]);return t(o,n({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),j=function(n){if(!n||"string"!=typeof n)return"";var e=n,t=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^(\d+\.)(\s{2,})/gm,function(n,e,t){return"".concat(e.slice(0,-1),"\\.").concat(t)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(n,e,t,r){return"".concat(e," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(n){return n.replace(/ /g," ").replace(/\t/g,"    ")})).split(/(\n{2,})/);return(e=t.map(function(n){return/^\n+$/.test(n)||/\|.*\|/.test(n)&&/\|[\s:|-]+\|/.test(n)||/^#{1,6} /.test(n.trimStart())?n:n.replace(/\n(?=[^\n])/g,function(e,t){var r=n.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},P=function(n){return n.replace(/[\.,;:]/g," ")},D=d(function(){return C.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[C]),H=d(function(){var e=j(v||""),t=w?P(e):e,r=(C||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:j((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(t=null==n?void 0:n.style)||void 0===t?void 0:t.badgeBg)||B}}).filter(function(n){return n.id&&n.highlight}),i={};r.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var o=function(n,e,t,r){void 0===e&&(e=""),void 0===r&&(r=[]);var i=!1,o=function(n){var o=function(n,e,t){var r,i,o;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var l=null!==(r=a[1])&&void 0!==r?r:"",c=null!==(i=a[2])&&void 0!==i?i:"",d=null!==(o=a[3])&&void 0!==o?o:"";return c?l+function(n,e){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"",r=n?' data-badge-id="'.concat(n,'"'):"";return"<mark".concat(r).concat(t,">")}(e,t)+c+"</mark>"+d:n}(n,e,t),a=o;if(!i&&r.length>0){i=!0;var l="",c="";r.forEach(function(n){l+=function(n){return'<span data-badge-id="'.concat(n,'">')}(n.id),c="</span>"+c}),a=l+o+c}return"​"+a};return n.split(/(\n+)/).map(function(n){return/^\n+$/.test(n)?n:n.trim()?""===n.replace(/[|:\-\s]/g,"")&&n.includes("-")?n:n.includes("|")?n.split(/(\|)/).map(function(n){return"|"!==n&&n.trim()?o(n):n}).join(""):o(n):n}).join("")},a=[];Object.entries(i).forEach(function(n){var r=n[0],i=n[1],o=e.indexOf(r),l=!1;if(-1===o&&w){var c=P(r);-1!==(o=t.indexOf(c))&&(l=!0)}if(-1!==o){for(var d=i[0].highlightColor,s=1;s<i.length;s++)d=g(d,i[s].highlightColor||"");a.push({highlight:r,start:o,end:o+r.length,badges:i,color:d,usedLooseMatch:l})}});var l=new Set(Object.keys(i));(k||[]).forEach(function(n){if(n){var r=j(n);if(r&&!l.has(r)){var i=e.indexOf(r),o=!1;if(-1===i&&w){var c=P(r);-1!==(i=t.indexOf(c))&&(o=!0)}if(-1!==i){var d=e.slice(0,i);(d.match(/</g)||[]).length===(d.match(/>/g)||[]).length&&a.push({highlight:r,start:i,end:i+r.length,badges:[],color:B||"",usedLooseMatch:o})}}}}),a.sort(function(n,e){return n.start-e.start||e.end-n.end});var c=[],d={};a.forEach(function(n,e){for(var t=n.start,r=n.end,i=0,o=c;i<o.length;i++){var a=o[i],l=a.start,s=a.end,u=t<s&&r>s&&t>=l,h=t<l&&r>l&&r<=s;if(t>=l&&r<=s){n.orphaned=!0,d[e]=a.matchIdx;break}u&&(t=s),h&&(r=l)}n.trimmedStart=t,n.trimmedEnd=r,!n.orphaned&&t<r&&c.push({start:t,end:r,matchIdx:e})});var s={};Object.entries(d).forEach(function(n){var e=n[0],t=n[1],r=Number(e);s[t]||(s[t]=[]),s[t].push(r)});var u=a.map(function(e,t){return n(n({},e),{idx:t})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var t,r;return(null!==(t=e.trimmedStart)&&void 0!==t?t:e.start)-(null!==(r=n.trimmedStart)&&void 0!==r?r:n.start)});return u.forEach(function(n){var t,r,i,l,c=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,d=null!==(r=n.trimmedEnd)&&void 0!==r?r:n.end;if(!(c>=d)){var u=e.slice(c,d),h=function(n,e,t,r){if(!t.length)return n;var i=t.map(function(n){return a[n]}).sort(function(n,e){return n.start-e.start}),l="",c=0;return i.forEach(function(t){var i,a,d=Math.max(c,t.start-e),s=Math.max(d,t.end-e);if(!(d>=s)){var u=g(r,t.color||"");l+=n.slice(c,d),l+=o(n.slice(d,s),(null===(a=null===(i=t.badges)||void 0===i?void 0:i[0])||void 0===a?void 0:a.id)||"",u,t.badges||[]),c=s}}),l+=n.slice(c)}(n.usedLooseMatch||c!==n.start||d!==n.end?u:n.highlight,n.start,s[n.idx]||[],n.color),p=o(h,(null===(l=null===(i=n.badges)||void 0===i?void 0:i[0])||void 0===l?void 0:l.id)||"",n.color,n.badges||[]);e=e.slice(0,c)+p+e.slice(d)}}),e},[v,C,k,B,w]),N=d(function(){return m?j(m||""):""},[m]),R=!!m,L={"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"}},q=n(n(n(n({},b),L),{position:"relative",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),R?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto"},"& table":{visibility:"hidden",margin:"0 !important"},"& th, & td":{padding:"0 !important",border:"none !important",backgroundColor:"transparent !important"},"& tr":{border:"none !important"},"& p:empty":{display:"none"}}:{}),W=n(n(n({},b),L),{position:"relative",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:1,pointerEvents:"auto"});return s(function(){if(T.current){var n=function(){var n=Array.from(T.current.querySelectorAll(".deviation-badge"));if(0!==n.length){n.forEach(function(n){n.style.setProperty("--badge-nudge","0px")});var e=n.filter(function(n){return"left"===n.dataset.side}),t=n.filter(function(n){return"left"!==n.dataset.side}),r=T.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=function(n){if(0!==n.length){var e=n.map(function(n){var e=n.getBoundingClientRect();return{el:n,naturalTop:e.top,height:e.height,currentTop:e.top}});e.sort(function(n,e){return n.naturalTop-e.naturalTop});var t=[],r=[];e.forEach(function(n){if(0===r.length)r.push(n);else{var e=r[r.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,r.push(n)):(t.push(r),r=[n])}}),r.length>0&&t.push(r),t.forEach(function(n){var e=n[n.length-1],t=e.currentTop+e.height;if(t>i){var r=t-i,a=n[0].currentTop-o,l=Math.max(0,Math.min(r,a));n.forEach(function(n){n.currentTop-=l})}}),t.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};a(e),a(t)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),t=new ResizeObserver(function(){requestAnimationFrame(n)});return t.observe(T.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[H,A,D]),r(o,n({ref:T,sx:{position:"relative",display:"grid"}},{children:[t(a,n({component:"div",sx:n(n({},q),{padding:"3px"})},{children:t(p,n({components:$,remarkPlugins:x,rehypePlugins:y},{children:H.replace(/#{3}/g,"")}))})),R&&t(a,n({component:"div",sx:W},{children:t(p,n({components:$,remarkPlugins:x,rehypePlugins:y},{children:N}))}))]}))},f);export{E as MemoizedMarkdown};
2
2
  //# sourceMappingURL=memoizedMarkdown.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as i,__spreadArray as n}from"tslib";import{useMemo as e}from"react";import{getSideData as t,safeStringify as o,getRationale as l,hasValue as s,isMissingStr as d,DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";var u={id:"",title:"",similarity:0,sections:[]},a=function(a,v,c,f,_){void 0===_&&(_=!0);var p="string"==typeof c?c:JSON.stringify(c||{}),b=e(function(){var e,s,d,r;if(!a||0===Object.keys(a).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var u=JSON.parse(p);try{var c=a.nodes||a,f=[],b=[],h=a.base_root_id,g=a.input_index_map||{0:"left",1:"right"},m=a[h]||c[h];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var y=function(n,e,t){if(!n||"object"!=typeof n)return n||null;if(n.deviations)return n;if(_)return n;var o=Object.keys(n).filter(function(i){return/^\d+$/.test(i)});if(!o.length)return n;var l=o.sort(function(i,n){return Number(i)-Number(n)}),s={},d={},r=null;return l.forEach(function(i){var o,l,u,a,v,c=n[i];if(c&&"object"==typeof c){r||(r=c);var f=!(null==c?void 0:c.status)||"pending"===c.status,_=f&&((null===(l=null==c?void 0:c.deviation_highlights)||void 0===l?void 0:l[e])||(null===(u=null==c?void 0:c.deviation_highlights)||void 0===u?void 0:u[g[0]]))||[],p=f&&((null===(a=null==c?void 0:c.deviation_highlights)||void 0===a?void 0:a[t])||(null===(v=null==c?void 0:c.deviation_highlights)||void 0===v?void 0:v[g[1]]))||[];s[i]=((o={})[g[0]]=_[0]||"",o[g[1]]=p[0]||"",o.deviation_summary=(null==c?void 0:c.deviation_summary)||"",o.deviation_title=null==c?void 0:c.deviation_title,o.deviation_impact=null==c?void 0:c.deviation_impact,o.deviation_explanation=null==c?void 0:c.deviation_explanation,o.evaluation_outputs=null==c?void 0:c.evaluation_outputs,o.cognitive_decisioning=null==c?void 0:c.cognitive_decisioning,o.deviation_highlights=null==c?void 0:c.deviation_highlights,o),d[i]=c}}),i(i({},n),{deviation_title:(null==r?void 0:r.deviation_title)||(null==n?void 0:n.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==n?void 0:n.deviation_impact),deviation_summary:(null==r?void 0:r.deviation_summary)||(null==n?void 0:n.deviation_summary),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==n?void 0:n.deviation_explanation),evaluation_outputs:(null==r?void 0:r.evaluation_outputs)||(null==n?void 0:n.evaluation_outputs),cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==n?void 0:n.cognitive_decisioning),deviations:s,deviation_entries:d})},x=function(i){var n=new Map,e=function(i){i.forEach(function(i){var t;i.id&&n.set(i.id,i),(null===(t=i.subsections)||void 0===t?void 0:t.length)&&e(i.subsections)})};e(i);var t=function(i,e){for(var o,l=[],s=function(i){var s=i.ref_parent_section_node_id;if(s&&n.has(s)&&s!==(null==e?void 0:e.id)){var d=n.get(s);d.subsections||(d.subsections=[]),d.subsections.some(function(n){return n.id===i.id})||d.subsections.push(i)}else(null===(o=i.subsections)||void 0===o?void 0:o.length)&&(i.subsections=t(i.subsections,i)),l.push(i)},d=0,r=i;d<r.length;d++){s(r[d])}return l},o=t(i),l=function(i){i.forEach(function(i){i.subsections&&i.subsections.length>0&&(i.subsections.sort(function(i,n){return i.selfIndex<0&&n.selfIndex>=0?1:i.selfIndex>=0&&n.selfIndex<0?-1:(i.selfIndex||0)-(n.selfIndex||0)}),l(i.subsections))})};return l(o),o},I=function(n,e){var s,d,r,v,f,_=a[n]||c[n];if(!_||!1===_.display_node)return null;var p=_.comparison_inputs?Object.keys(_.comparison_inputs):[],b=g[0],h=g[1];p.length>0&&(b=p.includes(g[0])?g[0]:p[0],h=p.includes(g[1])?g[1]:p.length>1?p[1]:p[0]);var m=t(_,e,g),x=!1!==(null===(s=m.attributes)||void 0===s?void 0:s.display_title),E=!1!==(null===(d=m.attributes)||void 0===d?void 0:d.display_content),N=!!o(m.title).trim(),S=!!o(m.content).trim(),j=l(_),O=(null===(r=null==u?void 0:u[n])||void 0===r?void 0:r.evaluation_result)||_.evaluation_result||null,R=y(O,b,h),k=[];_.next&&Object.values(_.next).forEach(function(i){var n=c[i];if(n&&!1!==n.display_node){var t=I(i,e);t&&k.push(t)}});var P=!(!N&&!S);return i(i({id:n,title:N?m.title:"",content:S?m.content:"",change_history:S?m.change_history:"",displayTitle:x,displayContent:E,subsections:k},P?j:{score:void 0,relation:"not_defined"}),{evaluationResult:R,selfIndex:void 0!==(null===(v=m.attributes)||void 0===v?void 0:v.display_index)?Number(m.attributes.display_index):-1,ref_parent_section_node_id:null===(f=m.attributes)||void 0===f?void 0:f.ref_parent_section_node_id})};if(v){var E=function(e,o){var s,d,r,v,f,_,p,b,h,m,x,I,N,S,j,O,R,k,P,C,T,V,D,w,J,M,U,q,F,$,z,A;void 0===o&&(o=0);var B=[],G=[];if(!e)return{refSections:B,baseSections:G};var H={},K={},L=-1,Q=-1;for(var W in e){var X=e[W],Y=a[X]||c[X];if(Y&&!1!==Y.display_node){var Z=Y.comparison_inputs?Object.keys(Y.comparison_inputs):[],ii=g[0],ni=g[1];Z.length>0&&(ii=Z.includes(g[0])?g[0]:Z[0],ni=Z.includes(g[1])?g[1]:Z.length>1?Z[1]:Z[0]);var ei=l(Y),ti=(null===(s=null==u?void 0:u[X])||void 0===s?void 0:s.evaluation_result)||Y.evaluation_result||null,oi=y(ti,ii,ni),li=t(Y,"1",g),si=t(Y,"0",g),di=!1!==(null===(d=li.attributes)||void 0===d?void 0:d.display_title)&&((null===(v=null===(r=li.title)||void 0===r?void 0:r.trim)||void 0===v?void 0:v.call(r))||"")||!1!==(null===(f=li.attributes)||void 0===f?void 0:f.display_content)&&((null===(p=null===(_=li.content)||void 0===_?void 0:_.trim)||void 0===p?void 0:p.call(_))||""),ri=!1!==(null===(b=si.attributes)||void 0===b?void 0:b.display_title)&&((null===(m=null===(h=si.title)||void 0===h?void 0:h.trim)||void 0===m?void 0:m.call(h))||"")||!1!==(null===(x=si.attributes)||void 0===x?void 0:x.display_content)&&((null===(N=null===(I=si.content)||void 0===I?void 0:I.trim)||void 0===N?void 0:N.call(I))||""),ui=Number(null!==(j=null===(S=li.attributes)||void 0===S?void 0:S.display_index)&&void 0!==j?j:L--),ai=Number(null!==(R=null===(O=si.attributes)||void 0===O?void 0:O.display_index)&&void 0!==R?R:Q--),vi=0===o?String(ui):"".concat(ui,"_").concat(X),ci=0===o?String(ai):"".concat(ai,"_").concat(X),fi=H[vi]||i(i({id:X,title:!1!==(null===(k=li.attributes)||void 0===k?void 0:k.display_title)?li.title:"",content:!1!==(null===(P=li.attributes)||void 0===P?void 0:P.display_content)?li.content:"",change_history:!1!==(null===(C=li.attributes)||void 0===C?void 0:C.display_content)?li.change_history:"",subsections:[]},di?ei:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ui,evaluationResult:oi,displayContent:null===(T=li.attributes)||void 0===T?void 0:T.display_content,displayTitle:null===(V=li.attributes)||void 0===V?void 0:V.display_title,ref_parent_section_node_id:null===(D=li.attributes)||void 0===D?void 0:D.ref_parent_section_node_id}),_i=K[ci]||i(i({id:X,title:!1!==(null===(w=si.attributes)||void 0===w?void 0:w.display_title)?si.title:"",content:!1!==(null===(J=si.attributes)||void 0===J?void 0:J.display_content)?si.content:"",change_history:!1!==(null===(M=si.attributes)||void 0===M?void 0:M.display_content)?si.change_history:"",subsections:[]},ri?ei:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ai,evaluationResult:oi,displayContent:null===(U=si.attributes)||void 0===U?void 0:U.display_content,displayTitle:null===(q=si.attributes)||void 0===q?void 0:q.display_title});Number(ui)>=0&&Number(ai)>=0&&((null===(F=fi.refIndexes)||void 0===F?void 0:F.includes(Number(ai)))||null===($=fi.refIndexes)||void 0===$||$.push(Number(ai)),(null===(z=_i.refIndexes)||void 0===z?void 0:z.includes(Number(ui)))||null===(A=_i.refIndexes)||void 0===A||A.push(Number(ui))),H[vi]=fi,K[ci]=_i;var pi=E(Y.next,o+1),bi=pi.refSections,hi=pi.baseSections;bi.length>0&&(fi.subsections=n(n([],fi.subsections||[],!0),bi,!0)),hi.length>0&&(_i.subsections=n(n([],_i.subsections||[],!0),hi,!0))}}B=Object.values(H),G=Object.values(K);var gi=function(i,n){return i.selfIndex<0&&n.selfIndex>=0?1:i.selfIndex>=0&&n.selfIndex<0?-1:i.selfIndex-n.selfIndex};return B.sort(gi),G.sort(gi),{refSections:B,baseSections:G}},N=E(m.next),S=N.refSections,j=N.baseSections;b=x(S),f=j}else m.next&&Object.values(m.next).forEach(function(i){var n=a[i]||c[i];n&&!1!==n.display_node&&(f.push(I(i,"0")||{id:i,title:"",content:"",subsections:[]}),b.push(I(i,"1")||{id:i,title:"",content:"",subsections:[]}))}),b=x(b);return{activeProposed:{title:(null===(s=null===(e=m.comparison_inputs)||void 0===e?void 0:e[g[0]])||void 0===s?void 0:s.title)||"Uploaded Contract",description:m.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(r=null===(d=m.comparison_inputs)||void 0===d?void 0:d[g[1]])||void 0===r?void 0:r.title)||"Reference Template",similarity:0,sections:b,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(i){return console.error("Data Transformation Error: ",i),{activeProposed:{},activeVariants:[],parseError:i instanceof Error?i.message:"Unknown Parsing Error"}}},[a,v,p,_]),h=b.activeProposed,g=b.activeVariants,m=b.parseError,y=(null==g?void 0:g[0])||u,x=e(function(){return(null==h?void 0:h.sections)||[]},[null==h?void 0:h.sections]),I=e(function(){return y.sections||[]},[y.sections]),E=x.length>0||I.length>0,N=e(function(){return f.fields.filter(function(i){var n=i.key;return(!E||"description"!==n)&&(s(null==h?void 0:h[n])||s(y[n]))})},[h,y,E,f.fields]),S=e(function(){var i,n,e={},t={},o={},l=0,s=null===(i=null==a?void 0:a.input_index_map)||void 0===i?void 0:i[0],u=null===(n=null==a?void 0:a.input_index_map)||void 0===n?void 0:n[1],c=function(i,n,a,v,f,_){var p,b,h,g,m,y,x,I;if(i&&function(i,n){var e,l=(null===(e=null==i?void 0:i.evaluationResult)||void 0===e?void 0:e.deviations)||{};Object.keys(l).sort().forEach(function(e){var a=l[e];if(a){var v=!d(a[s]),c=!d(a[u]);if(v||c){var f="".concat(i.id).concat(r).concat(e);void 0===t[f]&&(void 0===o[n]&&(o[n]=1),t[f]=o[n]++)}}})}(i,v),i&&!f){var E=(null==_?void 0:_.id)||"fallback_parent_".concat(l++);e[E]||(e[E]=[]),e[E].push(i)}for(var N=Math.max((null===(p=null==n?void 0:n.subsections)||void 0===p?void 0:p.length)||0,(null===(b=null==a?void 0:a.subsections)||void 0===b?void 0:b.length)||0,(null===(h=null==i?void 0:i.subsections)||void 0===h?void 0:h.length)||0),S=0;S<N;S++)c((null===(g=null==i?void 0:i.subsections)||void 0===g?void 0:g[S])||(null===(m=null==n?void 0:n.subsections)||void 0===m?void 0:m[S])||(null===(y=null==a?void 0:a.subsections)||void 0===y?void 0:y[S]),null===(x=null==n?void 0:n.subsections)||void 0===x?void 0:x[S],null===(I=null==a?void 0:a.subsections)||void 0===I?void 0:I[S],v,!1,_)};return x.forEach(function(i,n){var e,t=n+1;v&&void 0!==i.selfIndex&&i.selfIndex>=0&&(t=i.selfIndex+1);var o=null;if(v){var l=null===(e=i.refIndexes)||void 0===e?void 0:e[0];o=I.find(function(i){return i.selfIndex===l})}else o=I[n];c(i,i,o,t,!0,i)}),I.forEach(function(i,n){var e,t=n+1,o=!1;if(v){var l=null===(e=i.refIndexes)||void 0===e?void 0:e[0],s=x.find(function(i){return i.selfIndex===l});s&&void 0!==s.selfIndex&&s.selfIndex>=0?t=s.selfIndex+1:(o=!0,void 0!==i.selfIndex&&i.selfIndex>=0&&(t=i.selfIndex+1))}else n>=x.length&&(o=!0);o&&c(i,null,i,t,!0,i)}),{parentDeviationRecord:e,registry:t}},[x,I,v,a]),j=S.parentDeviationRecord,O=S.registry;return{activeProposed:h,activeVariants:g,existingRule:y,proposedSections:x,existingSections:I,visibleFields:N,parentDeviationRecord:j,deviationNumberRegistry:O,parseError:m}};export{a as useCognitiveTreeData};
1
+ import{__assign as i,__spreadArray as t}from"tslib";import{useMemo as n}from"react";import{getSideData as e,safeStringify as o,getRationale as l,hasValue as r,isMissingStr as s,DEVIATION_BADGE_SEPARATOR as d}from"../CognitiveComparehelpers.js";var a={id:"",title:"",similarity:0,sections:[]},u=function(u,v,c,f,p){void 0===p&&(p=!0);var _="string"==typeof c?c:JSON.stringify(c||{}),b=n(function(){var n,r,s,d;if(!u||0===Object.keys(u).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var a=JSON.parse(_);try{var c=u.nodes||u,f=[],b=[],m=u.base_root_id,h=u.input_index_map||{0:"left",1:"right"},y=u[m]||c[m];if(!y||!1===y.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var g=function(t,n,e){if(!t||"object"!=typeof t)return t||null;if(t.deviations)return t;if(p)return t;var o=Object.keys(t).filter(function(i){return/^\d+$/.test(i)});if(!o.length)return t;var l=o.sort(function(i,t){return Number(i)-Number(t)}),r={},s={},d=null;return l.forEach(function(i){var o,l,a,u,v,c=t[i];if(c&&"object"==typeof c){d||(d=c);var f=!(null==c?void 0:c.status)||"pending"===c.status,p=f&&((null===(l=null==c?void 0:c.deviation_highlights)||void 0===l?void 0:l[n])||(null===(a=null==c?void 0:c.deviation_highlights)||void 0===a?void 0:a[h[0]]))||[],_=f&&((null===(u=null==c?void 0:c.deviation_highlights)||void 0===u?void 0:u[e])||(null===(v=null==c?void 0:c.deviation_highlights)||void 0===v?void 0:v[h[1]]))||[];r[i]=((o={})[h[0]]=p[0]||"",o[h[1]]=_[0]||"",o.deviation_summary=(null==c?void 0:c.deviation_summary)||"",o.deviation_title=null==c?void 0:c.deviation_title,o.deviation_impact=null==c?void 0:c.deviation_impact,o.deviation_explanation=null==c?void 0:c.deviation_explanation,o.evaluation_outputs=null==c?void 0:c.evaluation_outputs,o.cognitive_decisioning=null==c?void 0:c.cognitive_decisioning,o.deviation_highlights=null==c?void 0:c.deviation_highlights,o),s[i]=c}}),i(i({},t),{deviation_title:(null==d?void 0:d.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_summary:(null==d?void 0:d.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning),deviations:r,deviation_entries:s})},x=function(i){var t=new Map,n=function(i){i.forEach(function(i){var e;i.id&&t.set(i.id,i),(null===(e=i.subsections)||void 0===e?void 0:e.length)&&n(i.subsections)})};n(i);var e=function(i,n){for(var o,l=[],r=function(i){var r=i.ref_parent_section_node_id;if(r&&t.has(r)&&r!==(null==n?void 0:n.id)){var s=t.get(r);s.subsections||(s.subsections=[]),s.subsections.some(function(t){return t.id===i.id})||s.subsections.push(i)}else(null===(o=i.subsections)||void 0===o?void 0:o.length)&&(i.subsections=e(i.subsections,i)),l.push(i)},s=0,d=i;s<d.length;s++){r(d[s])}return l},o=e(i),l=function(i){i.forEach(function(i){i.subsections&&i.subsections.length>0&&(i.subsections.sort(function(i,t){return i.selfIndex<0&&t.selfIndex>=0?1:i.selfIndex>=0&&t.selfIndex<0?-1:(i.selfIndex||0)-(t.selfIndex||0)}),l(i.subsections))})};return l(o),o},I=function(t,n){var r,s,d,v,f,p=u[t]||c[t];if(!p||!1===p.display_node)return null;var _=p.comparison_inputs?Object.keys(p.comparison_inputs):[],b=h[0],m=h[1];_.length>0&&(b=_.includes(h[0])?h[0]:_[0],m=_.includes(h[1])?h[1]:_.length>1?_[1]:_[0]);var y=e(p,n,h),x=!1!==(null===(r=y.attributes)||void 0===r?void 0:r.display_title),N=!1!==(null===(s=y.attributes)||void 0===s?void 0:s.display_content),O=!!o(y.title).trim(),E=!!o(y.content).trim(),j=l(p),S=(null===(d=null==a?void 0:a[t])||void 0===d?void 0:d.evaluation_result)||p.evaluation_result||null,R=g(S,b,m),P=[];p.next&&Object.values(p.next).forEach(function(i){var t=c[i];if(t&&!1!==t.display_node){var e=I(i,n);e&&P.push(e)}});var k=!(!O&&!E);return i(i({id:t,title:O?y.title:"",content:E?y.content:"",change_history:E?y.change_history:"",displayTitle:x,displayContent:N,subsections:P},k?j:{score:void 0,relation:"not_defined"}),{evaluationResult:R,selfIndex:void 0!==(null===(v=y.attributes)||void 0===v?void 0:v.display_index)?Number(y.attributes.display_index):-1,ref_parent_section_node_id:null===(f=y.attributes)||void 0===f?void 0:f.ref_parent_section_node_id})};if(v){var N=function(n,o){var r,s,d,v,f,p,_,b,m,y,x,I,O,E,j,S,R,P,k,K,C,T,V,D,w,J,U,q,F,M,W,$;void 0===o&&(o=0);var z=[],A=[];if(!n)return{refSections:z,baseSections:A};var B={},G={},H=-1,L=-1;for(var Q in n){var X=n[Q],Y=u[X]||c[X];if(Y&&!1!==Y.display_node){var Z=Y.comparison_inputs?Object.keys(Y.comparison_inputs):[],ii=h[0],ti=h[1];Z.length>0&&(ii=Z.includes(h[0])?h[0]:Z[0],ti=Z.includes(h[1])?h[1]:Z.length>1?Z[1]:Z[0]);var ni=l(Y),ei=(null===(r=null==a?void 0:a[X])||void 0===r?void 0:r.evaluation_result)||Y.evaluation_result||null,oi=g(ei,ii,ti),li=e(Y,"1",h),ri=e(Y,"0",h),si=!1!==(null===(s=li.attributes)||void 0===s?void 0:s.display_title)&&((null===(v=null===(d=li.title)||void 0===d?void 0:d.trim)||void 0===v?void 0:v.call(d))||"")||!1!==(null===(f=li.attributes)||void 0===f?void 0:f.display_content)&&((null===(_=null===(p=li.content)||void 0===p?void 0:p.trim)||void 0===_?void 0:_.call(p))||""),di=!1!==(null===(b=ri.attributes)||void 0===b?void 0:b.display_title)&&((null===(y=null===(m=ri.title)||void 0===m?void 0:m.trim)||void 0===y?void 0:y.call(m))||"")||!1!==(null===(x=ri.attributes)||void 0===x?void 0:x.display_content)&&((null===(O=null===(I=ri.content)||void 0===I?void 0:I.trim)||void 0===O?void 0:O.call(I))||""),ai=Number(null!==(j=null===(E=li.attributes)||void 0===E?void 0:E.display_index)&&void 0!==j?j:H--),ui=Number(null!==(R=null===(S=ri.attributes)||void 0===S?void 0:S.display_index)&&void 0!==R?R:L--),vi=0===o?String(ai):"".concat(ai,"_").concat(X),ci=0===o?String(ui):"".concat(ui,"_").concat(X),fi=B[vi]||i(i({id:X,title:!1!==(null===(P=li.attributes)||void 0===P?void 0:P.display_title)?li.title:"",content:!1!==(null===(k=li.attributes)||void 0===k?void 0:k.display_content)?li.content:"",change_history:!1!==(null===(K=li.attributes)||void 0===K?void 0:K.display_content)?li.change_history:"",subsections:[]},si?ni:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ai,evaluationResult:oi,displayContent:null===(C=li.attributes)||void 0===C?void 0:C.display_content,displayTitle:null===(T=li.attributes)||void 0===T?void 0:T.display_title,ref_parent_section_node_id:null===(V=li.attributes)||void 0===V?void 0:V.ref_parent_section_node_id}),pi=G[ci]||i(i({id:X,title:!1!==(null===(D=ri.attributes)||void 0===D?void 0:D.display_title)?ri.title:"",content:!1!==(null===(w=ri.attributes)||void 0===w?void 0:w.display_content)?ri.content:"",change_history:!1!==(null===(J=ri.attributes)||void 0===J?void 0:J.display_content)?ri.change_history:"",subsections:[]},di?ni:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ui,evaluationResult:oi,displayContent:null===(U=ri.attributes)||void 0===U?void 0:U.display_content,displayTitle:null===(q=ri.attributes)||void 0===q?void 0:q.display_title});Number(ai)>=0&&Number(ui)>=0&&((null===(F=fi.refIndexes)||void 0===F?void 0:F.includes(Number(ui)))||null===(M=fi.refIndexes)||void 0===M||M.push(Number(ui)),(null===(W=pi.refIndexes)||void 0===W?void 0:W.includes(Number(ai)))||null===($=pi.refIndexes)||void 0===$||$.push(Number(ai))),B[vi]=fi,G[ci]=pi;var _i=N(Y.next,o+1),bi=_i.refSections,mi=_i.baseSections;bi.length>0&&(fi.subsections=t(t([],fi.subsections||[],!0),bi,!0)),mi.length>0&&(pi.subsections=t(t([],pi.subsections||[],!0),mi,!0))}}z=Object.values(B),A=Object.values(G);var hi=function(i,t){return i.selfIndex<0&&t.selfIndex>=0?1:i.selfIndex>=0&&t.selfIndex<0?-1:i.selfIndex-t.selfIndex};return z.sort(hi),A.sort(hi),{refSections:z,baseSections:A}},O=N(y.next),E=O.refSections,j=O.baseSections;b=x(E),f=j}else y.next&&Object.values(y.next).forEach(function(i){var t=u[i]||c[i];t&&!1!==t.display_node&&(f.push(I(i,"0")||{id:i,title:"",content:"",subsections:[]}),b.push(I(i,"1")||{id:i,title:"",content:"",subsections:[]}))}),b=x(b);return{activeProposed:{title:(null===(r=null===(n=y.comparison_inputs)||void 0===n?void 0:n[h[0]])||void 0===r?void 0:r.title)||"Uploaded Contract",description:y.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(d=null===(s=y.comparison_inputs)||void 0===s?void 0:s[h[1]])||void 0===d?void 0:d.title)||"Reference Template",similarity:0,sections:b,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:y.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(i){return console.error("Data Transformation Error: ",i),{activeProposed:{},activeVariants:[],parseError:i instanceof Error?i.message:"Unknown Parsing Error"}}},[u,v,_,p]),m=b.activeProposed,h=b.activeVariants,y=b.parseError,g=(null==h?void 0:h[0])||a,x=n(function(){return(null==m?void 0:m.sections)||[]},[null==m?void 0:m.sections]),I=n(function(){return g.sections||[]},[g.sections]),N=x.length>0||I.length>0,O=n(function(){return f.fields.filter(function(i){var t=i.key;return(!N||"description"!==t)&&(r(null==m?void 0:m[t])||r(g[t]))})},[m,g,N,f.fields]),E=n(function(){var i,t,n={},e={},o={},l=0,r=null===(i=null==u?void 0:u.input_index_map)||void 0===i?void 0:i[0],a=null===(t=null==u?void 0:u.input_index_map)||void 0===t?void 0:t[1],c=function(i,t){if(!v){var n="left"===t?x.indexOf(i):I.indexOf(i);return{rootKey:"".concat(t,":").concat(n),parentNum:n+1}}if("left"===t){var e=i.selfIndex,o=void 0!==e&&e>=0?e+1:x.indexOf(i)+1;return{rootKey:"left-root:".concat(i.id),parentNum:o}}var l=i.selfIndex,r=x.find(function(i){var t;return null===(t=i.refIndexes)||void 0===t?void 0:t.includes(l)});if(r){var s=r.selfIndex,d=void 0!==s&&s>=0?s+1:x.indexOf(r)+1;return{rootKey:"left-root:".concat(r.id),parentNum:d}}var a=void 0!==l&&l>=0?l+1:I.indexOf(i)+1;return{rootKey:"right-orphan-root:".concat(i.id),parentNum:a}},f=function(i,t){if(i&&t)return i.find(function(i){return i.id===t.id})||void 0},p=function(i,t,u,v,c,_,b){if(t&&function(i,t,n){var l,u=(null===(l=null==i?void 0:i.evaluationResult)||void 0===l?void 0:l.deviations)||{};Object.keys(u).sort().forEach(function(l){var v=u[l];if(v){var c=!s(v[r]),f=!s(v[a]);if(c||f){var p="".concat(i.id).concat(d).concat(l);void 0===e[p]&&(void 0===o[t]&&(o[t]=1),e[p]={index:o[t]++,rootKey:t,parentNum:n})}}})}(t,v,c),t&&!_){var m=(null==b?void 0:b.id)||"fallback_parent_".concat(l++);n[m]||(n[m]=[]),n[m].push(t)}((null==t?void 0:t.subsections)||(null==i?void 0:i.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(n){var e=f(null==i?void 0:i.subsections,n),o=f(null==u?void 0:u.subsections,n);p(n,e,o,v,c,!1,t||b)})};x.forEach(function(i){var t,n=c(i,"left"),e=n.rootKey,o=n.parentNum,l=null;if(v){var r=null===(t=i.refIndexes)||void 0===t?void 0:t[0];l=I.find(function(i){return i.selfIndex===r})}else l=I[x.indexOf(i)];p(i,i,l,e,o,!0,i)}),I.forEach(function(i){var t=c(i,"right"),n=t.rootKey,e=t.parentNum;n.startsWith("right-orphan-root:")&&p(i,null,i,n,e,!0,i)});var _=Object.fromEntries(Object.entries(e).map(function(i){return[i[0],i[1].index]})),b=Object.fromEntries(Object.entries(e).map(function(i){return[i[0],i[1].parentNum]}));return{parentDeviationRecord:n,registry:_,deviationParentRegistry:b}},[x,I,v,u]),j=E.parentDeviationRecord,S=E.registry,R=E.deviationParentRegistry;return{activeProposed:m,activeVariants:h,existingRule:g,proposedSections:x,existingSections:I,visibleFields:O,parentDeviationRecord:j,deviationNumberRegistry:S,deviationParentRegistry:R,parseError:y}};export{u as useCognitiveTreeData};
2
2
  //# sourceMappingURL=useCompareData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAwCA,OAAO,EAEL,qBAAqB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AA0BlC,QAAA,MAAM,gBAAgB,4SAyBnB,qBAAqB,4CA67EvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AA0CA,OAAO,EAEL,qBAAqB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AA0BlC,QAAA,MAAM,gBAAgB,4SAyBnB,qBAAqB,4CA6hFvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
@@ -59,5 +59,7 @@ export declare const resetClauseHighlight: (element: HTMLElement) => void;
59
59
  export declare const highlightClause: (element: HTMLElement) => void;
60
60
  export declare const scrollAndHighlightClause: (element: HTMLElement, scrollContainer: HTMLElement) => void;
61
61
  export declare const waitForElementVisible: (element: HTMLElement, onVisible: () => void) => void;
62
+ export declare const scrollAndWait: (container: HTMLElement, top: number, callback: () => void) => void;
63
+ export declare const waitForScrollIdle: (container: HTMLElement, idleMs?: number) => Promise<void>;
62
64
  export {};
63
65
  //# sourceMappingURL=CognitiveComparehelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveComparehelpers.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveComparehelpers.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EAEb,MAAM,yBAAyB,CAAC;AAGjC,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,MAM5C,CAAC;AAGF,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAKvC,CAAC;AAGF,eAAO,MAAM,WAAW,SAChB,GAAG,aACE,GAAG,GAAG,GAAG,YACV,OAAO,MAAM,EAAE,MAAM,CAAC;;;;;;CAWjC,CAAC;AAGF,eAAO,MAAM,YAAY,SAAU,GAAG;;;;;;;;;;;;;;;;;;;;CA2BrC,CAAC;AAGF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAOxD,CAAC;AAqDF,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAuD9D;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,GACZ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAQlC;AAED,eAAO,MAAM,mBAAmB,YAAa,MAAM,OAAO,MAAM,YAG/D,CAAA;AACD,eAAO,MAAM,qBAAqB,cAAe,GAAG,aAAa,GAAG,YAqCnE,CAAC;AAEF,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,eAAO,MAAM,YAAY,QAAS,MAAM,GAAG,SAAS,GAAG,IAAI,YAS1D,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAAa,OAAO,KAAG,OAU3D,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAAa,OAAO,KAAG,MAGnD,CAAC;AAEF,eAAO,MAAM,qBAAqB,qBAAsB,GAAG,kBAAkB,GAAG,QAO/E,CAAC;AAEF,eAAO,MAAM,gBAAgB,OACvB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,WACF,MAAM,KACb,MAyBF,CAAC;AAEF,eAAO,MAAM,cAAc,YAChB,WAAW,kBACJ,MAAM,aACZ,MAAM,eACH,MAAM,IAAI,eACV,MAAM,IAAI,SAgCxB,CAAC;AAEF,eAAO,MAAM,YAAY,WAAY,MAAM,WAQ1C,CAAC;AAWF,eAAO,MAAM,sBAAsB,qBAAsB,GAAG,KAAG,MAmC9D,CAAC;AAEF,eAAO,MAAM,4BAA4B,qBAAsB,GAAG,KAAG,MAAM,GAAG,IA4B7E,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,QAAQ,MAAM,KAAG,MA8BzD,CAAC;AAIF,eAAO,MAAM,gCAAgC,SACrC,GAAG,QACH,MAAM,YACF,MAAM,KACf,MAAM,GAAG,IAcX,CAAC;AAEF,eAAO,MAAM,mBAAmB,aACpB,YAAY,EAAE,UAChB,MAAM,KACb,MAAM,GAAG,IAUX,CAAC;AAIF,eAAO,MAAM,oBAAoB,YAAa,WAAW,SAkBxD,CAAC;AAEF,eAAO,MAAM,eAAe,YAAa,WAAW,SAiBnD,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAC1B,WAAW,mBACH,WAAW,SAiC7B,CAAC;AAGF,eAAO,MAAM,qBAAqB,YACvB,WAAW,aACT,MAAM,IAAI,SAkBtB,CAAC"}
1
+ {"version":3,"file":"CognitiveComparehelpers.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveComparehelpers.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EAEb,MAAM,yBAAyB,CAAC;AAGjC,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,MAM5C,CAAC;AAGF,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAKvC,CAAC;AAGF,eAAO,MAAM,WAAW,SAChB,GAAG,aACE,GAAG,GAAG,GAAG,YACV,OAAO,MAAM,EAAE,MAAM,CAAC;;;;;;CAWjC,CAAC;AAGF,eAAO,MAAM,YAAY,SAAU,GAAG;;;;;;;;;;;;;;;;;;;;CA2BrC,CAAC;AAGF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAOxD,CAAC;AAqDF,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAuD9D;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,GACZ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAQlC;AAED,eAAO,MAAM,mBAAmB,YAAa,MAAM,OAAO,MAAM,YAG/D,CAAA;AACD,eAAO,MAAM,qBAAqB,cAAe,GAAG,aAAa,GAAG,YAqCnE,CAAC;AAEF,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,eAAO,MAAM,YAAY,QAAS,MAAM,GAAG,SAAS,GAAG,IAAI,YAS1D,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAAa,OAAO,KAAG,OAU3D,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAAa,OAAO,KAAG,MAGnD,CAAC;AAEF,eAAO,MAAM,qBAAqB,qBAAsB,GAAG,kBAAkB,GAAG,QAO/E,CAAC;AAEF,eAAO,MAAM,gBAAgB,OACvB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,WACF,MAAM,KACb,MAyBF,CAAC;AAEF,eAAO,MAAM,cAAc,YAChB,WAAW,kBACJ,MAAM,aACZ,MAAM,eACH,MAAM,IAAI,eACV,MAAM,IAAI,SAgCxB,CAAC;AAEF,eAAO,MAAM,YAAY,WAAY,MAAM,WAQ1C,CAAC;AAWF,eAAO,MAAM,sBAAsB,qBAAsB,GAAG,KAAG,MAmC9D,CAAC;AAEF,eAAO,MAAM,4BAA4B,qBAAsB,GAAG,KAAG,MAAM,GAAG,IA4B7E,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,QAAQ,MAAM,KAAG,MA8BzD,CAAC;AAIF,eAAO,MAAM,gCAAgC,SACrC,GAAG,QACH,MAAM,YACF,MAAM,KACf,MAAM,GAAG,IAcX,CAAC;AAEF,eAAO,MAAM,mBAAmB,aACpB,YAAY,EAAE,UAChB,MAAM,KACb,MAAM,GAAG,IAUX,CAAC;AAIF,eAAO,MAAM,oBAAoB,YAAa,WAAW,SAkBxD,CAAC;AAEF,eAAO,MAAM,eAAe,YAAa,WAAW,SAiBnD,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAC1B,WAAW,mBACH,WAAW,SAiC7B,CAAC;AAGF,eAAO,MAAM,qBAAqB,YACvB,WAAW,aACT,MAAM,IAAI,SAkBtB,CAAC;AAGF,eAAO,MAAM,aAAa,cACb,WAAW,OACjB,MAAM,YACD,MAAM,IAAI,SAuBrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,cACf,WAAW,sBAErB,QAAQ,IAAI,CAmBb,CAAC"}
@@ -19,6 +19,7 @@ export type CompareContextValue = {
19
19
  proposedSections: SectionBlock[];
20
20
  existingSections: SectionBlock[];
21
21
  deviationNumberRegistry: Record<string, number>;
22
+ deviationParentRegistry: Record<string, unknown>;
22
23
  treeData: Record<string, any> | null | undefined;
23
24
  displayConfig: IDisplayConfig;
24
25
  resolvedMarkdownStyles: Record<string, any>;