@viswa-test/test-citation 0.0.159 → 0.0.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/ScrollLockToggle.js +2 -0
- package/dist/cjs/features/CognitiveCompare/components/ScrollLockToggle.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/ScrollLockToggle.js +2 -0
- package/dist/features/CognitiveCompare/components/ScrollLockToggle.js.map +1 -0
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts +5777 -6561
- package/dist/types/src/CommonConstants/CommonConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts +3 -0
- package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/LHSSectionRow.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/RHSSectionRow.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/ScrollLockToggle.d.ts +11 -0
- package/dist/types/src/features/CognitiveCompare/components/ScrollLockToggle.d.ts.map +1 -0
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/types/src/AutopilotStyle.d.ts +0 -2
- package/dist/types/src/AutopilotStyle.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
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 x,stripRedlineTags as m,generateColorPalette as g,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 _,F,R,k,B,C,M,A,O,W,j,N,T,E=S.section,P=S.idx,D=S.columnKey,K=S.colRef,z=S.mb,V=void 0===z?1:z,G=S.isExpanded,H=S.onToggle,X=S.navigation,Y=S.parentNodeId,q=void 0===Y?"":Y,J=p(),L=J.showOpenNodeRef,Q=J.resolvedMarkdownStyles,U=J.maintainRelativeOrder,Z=J.showDeviationBadges,$=void 0!==Z&&Z,nn=J.renderSubSectionAccordion,en=J.treeData,on=J.proposedSections,tn=J.existingSections,ln=J.deviationNumberRegistry,rn=J.getBadgeRef,dn=J.openSummaryPopup,an=J.getSectionCompareStyle,un=J.connectedSections,cn=J.openMoreFunctionsPopup;J.deviationNodeIdToView,J.deviationTargetParentId;var sn=J.isProposingFix,vn=J.proposingFixNodeId,fn=J.isRedlineFlow,pn=J.isSideBySide,hn=J.activeSideBySideSection,xn="".concat(pn?"1":"0","-").concat(String(null!=hn?hn:"")),mn=(null===(_=E.displayTitle)||void 0===_||_)&&h(E.title),gn=!!sn&&!!vn&&"left"===D&&E.id===vn,In=x(E.content),bn="boolean"==typeof fn?fn:In,yn=In,wn=bn&&In,Sn=wn?m(E.content):E.content,_n=wn?E.content:void 0,Fn=(null===(F=E.displayContent)||void 0===F||F||In)&&h(E.content),Rn=!mn&&!Fn,kn=E.title;mn||(kn=Fn?"No Title Found":"No Matching Section Found");var Bn=E.evaluationResult;if(!Bn&&"right"===D)if(U){var Cn=null===(R=E.refIndexes)||void 0===R?void 0:R[0],Mn=on.find(function(n){return n.selfIndex===Cn});Bn=null==Mn?void 0:Mn.evaluationResult}else Bn=null===(k=on[P])||void 0===k?void 0:k.evaluationResult;var An=null===(B=null==en?void 0:en.input_index_map)||void 0===B?void 0:B[0],On=null===(C=null==en?void 0:en.input_index_map)||void 0===C?void 0:C[1],Wn="left"===D?On:An,jn=function(n,i){return n.find(function(n){return(null==n?void 0:n.id)&&i&&n.id===i})},Nn="left"===D?E:on[P],Tn="right"===D?E:tn[P],En=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(y).concat(i),o=null==ln?void 0:ln[e];null!=o&&o<n&&(n=o);var t="".concat(u).concat(y).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,Nn,Tn,!0),n!==1/0?n-1:0},[E,Nn,Tn,D,ln,U,on]);if(U)if("left"===D){var Pn=null===(M=E.refIndexes)||void 0===M?void 0:M[0],Dn=tn.findIndex(function(n){return n.selfIndex===Pn});Tn=-1!==Dn?tn[Dn]:jn(tn,E.id)}else{var Kn=null===(A=E.refIndexes)||void 0===A?void 0:A[0],zn=on.findIndex(function(n){return n.selfIndex===Kn});Nn=-1!==zn?on[zn]:jn(on,E.id)}var Vn="left"===D?!Tn:!Nn,Gn=Bn||(null==Nn?void 0:Nn.evaluationResult)||(null==Tn?void 0:Tn.evaluationResult),Hn=null!==(j=null===(W=null===(O=null==Gn?void 0:Gn.evaluation_outputs)||void 0===O?void 0:O.metadata)||void 0===W?void 0:W.label_color)&&void 0!==j?j:w,Xn=g(Hn).highlightBg,Yn=(null==Gn?void 0:Gn.deviations)||{},qn=P+1,Jn=E.id;if(U){var Ln=1,Qn=new Map;if(on.forEach(function(n){!n.title&&!n.content||n.id&&Qn.set(n.id,Ln++)}),"left"===D)qn=Qn.get(E.id)||P+1;else{var Un=on.filter(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(E.selfIndex)});if(Un.length>0)qn=Qn.get(Un[0].id)||P+1,Jn=Un[0].id;else for(var Zn=Ln,$n=function(n){if(!n.title&&!n.content)return"continue";var i=on.some(function(i){var e;return null===(e=i.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});if(!i){if(n.id===E.id)return qn=Zn,"break";Zn++}},ni=0,ii=tn;ni<ii.length;ni++){if("break"===$n(ii[ni]))break}}}var ei=Object.entries(Yn).map(function(n){var i=n[0],e=n[1],o="".concat(Jn).concat(y).concat(i);return{deviationKey:i,deviationMap:e,refId:o,currentIndex:ln[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});ei.sort(function(n,i){return n.currentIndex-i.currentIndex});var oi,ti=ei.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!==En&&(s-=En);var v=u[q],f=I(v);if(f)v="";else if(!v)return null;var p=P,h=P;if(U)if("left"===D){var x=null===(e=E.refIndexes)||void 0===e?void 0:e[0],m=tn.findIndex(function(n){return n.selfIndex===x});if(-1!==m)h=m;else{var b=tn.findIndex(function(n){return n.id===E.id});h=-1!==b?b:P}}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{var _=on.findIndex(function(n){return n.id===E.id});p=-1!==_?_:P}}var F="".concat(Jn).concat(y).concat(a).concat(y).concat(p).concat(y).concat(h),R=u[Wn],k=Vn||I(R),B="".concat(qn,".").concat(s),C=P;if("right"===D&&U){var M=null===(t=E.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===E.id});-1!==_&&(C=_)}}var O=an?an(C):null,W=(null==u?void 0:u.evaluation_outputs)||(null==Gn?void 0:Gn.evaluation_outputs),j=null!==(l=null==W?void 0:W.output_value)&&void 0!==l?l:null,N=null!==(d=null===(r=null==W?void 0:W.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:Hn,T=g(N),K=O?n(n({},O),{badgeBg:T.badgeBg,badgeBorder:T.badgeBorder,badgeText:T.badgeText}):n({},T),z=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Gn?void 0:Gn.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Gn?void 0:Gn.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Gn?void 0:Gn.deviation_explanation),evaluation_outputs:W,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Gn?void 0:Gn.cognitive_decisioning)}:null,V=0,G=Sn||"";if(v&&G){var H=G.split(/\n{2,}/),X=H.findIndex(function(n){return n.includes(v)});if(-1!==X){var Y=Object.entries(Yn).filter(function(n){n[0];var i=n[1][q];return i&&H[X].includes(i)}).sort(function(n,i){return H[X].indexOf(n[1][q])-H[X].indexOf(i[1][q])}),J=Y.filter(function(n){n[0];var i=n[1][q];return i&&(i.includes(v)||v.includes(i))});J.length>1&&(V=Math.max(0,J.findIndex(function(n){return n[0]===a})))}}return{id:c,actionId:F,label:B,highlight:v,side:D,style:K,stackIndex:V,score:j,isConnected:null==un?void 0:un.has(F),isOrphan:k,isMissingClause:f,badgeRef:rn(D,c),onClick:function(n){n.stopPropagation(),cn&&cn(n,Nn||{id:"orphan-left",title:"",content:""},k,Tn||{id:"orphan-right",title:"",content:""},F,K)},onSummaryClick:function(n){n.stopPropagation(),dn(n,F,k,z)}}}).filter(Boolean),li=$||!bn&&gn,ri=li?ti:[],di=li?ri.map(function(n){return n.highlight}).filter(Boolean):[],ai=E.id&&D===(null==X?void 0:X.columnKey)?X:null,ui=o.useRef(!1);return t(function(){G||(ui.current=!1)},[G]),i(l,n({ref:K,sx:{mb:V,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[G&&(null==ai?void 0:ai.showAbove)&&e("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,i;return null===(i=null===(n=null==ai?void 0:ai.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:"0px"}:{left:"0px"})},{children:e(s,{color:(null===(N=null==ai?void 0:ai.showAboveRef)||void 0===N?void 0:N.current)?window.getComputedStyle(ai.showAboveRef.current).color:void 0})}))})),i(r,n({disableGutters:!0,expanded:!Rn&&G,onChange:function(){Rn||(H(),L.current=E.id)},sx:{boxShadow:"none",border:Rn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Rn?"#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:Rn?null:e(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Rn?"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:mn&&e(a,n({title:kn,placement:"top"},{children:e(u,n({component:"div",sx:{fontSize:"12px",color:Rn?"#94A3B8":"#19213D",fontWeight:Rn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(oi=kn,oi?b(oi).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)}))}))})),!Rn&&i(c,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Fn&&e(f,{content:Sn,overlayContent:_n,sxStyles:Q,highlights:di,maintainRelativeOrder:U,highlightBg:Xn,suppressHighlightBg:yn,deviationBadges:ri,collisionKey:xn}),(E.subsections||[]).map(function(n,i){return nn({section:n,keyPath:"".concat(P,"-").concat(i),depth:0,columnKey:D,parentNodeId:q,sectionOffset:En})})]}))]})),G&&(null==ai?void 0:ai.showBelow)&&e("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,i;return null===(i=null===(n=null==ai?void 0:ai.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:"0px"}:{left:"0px"})},{children:e(v,{color:(null===(T=null==ai?void 0:ai.showBelowRef)||void 0===T?void 0:T.current)?window.getComputedStyle(ai.showBelowRef.current).color:void 0})}))}))]}),"".concat(D,"-sec-").concat(P))};export{S as default};
|
|
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,ce=ae?de:[],ue=ae?ce.map(function(n){return n.highlight}).filter(Boolean):[],se=N.id&&D===(null==H?void 0:H.columnKey)?H:null,ve=o.useRef(!1);return t(function(){V||(ve.current=!1)},[V]),e(l,n({ref:K,sx:{mb:z,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[V&&(null==se?void 0:se.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==se?void 0:se.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==se?void 0:se.showAboveRef)||void 0===j?void 0:j.current)?window.getComputedStyle(se.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:ue,maintainRelativeOrder:U,highlightBg:qn,suppressHighlightBg:_n,deviationBadges:ce,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==se?void 0:se.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==se?void 0:se.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==se?void 0:se.showBelowRef)||void 0===E?void 0:E.current)?window.getComputedStyle(se.showBelowRef.current).color:void 0})}))}))]}),"".concat(D,"-sec-").concat(P))};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,{useRef as o,useEffect as l}from"react";import{Box as r,Accordion as d,AccordionSummary as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronDown as s}from"lucide-react";import{MemoizedMarkdown as v}from"../hooks/memoizedMarkdown.js";import{useCompareContext as f}from"../CompareContext.js";import{hasValue as p,hasMeaningfulRedlineTags as h,stripRedlineTags as m,generateColorPalette as g,isMissingStr as x,DEVIATION_BADGE_SEPARATOR as
|
|
1
|
+
import{__assign as n}from"tslib";import{jsx as i,jsxs as e}from"react/jsx-runtime";import t,{useRef as o,useEffect as l}from"react";import{Box as r,Accordion as d,AccordionSummary as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronDown as s}from"lucide-react";import{MemoizedMarkdown as v}from"../hooks/memoizedMarkdown.js";import{useCompareContext as f}from"../CompareContext.js";import{hasValue as p,hasMeaningfulRedlineTags as h,stripRedlineTags as m,generateColorPalette as g,isMissingStr as x,DEVIATION_BADGE_SEPARATOR as y}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as S}from"../CognitiveCompareConstants.js";var b=t.memo(function(t){var I,_,k,w,C,P,B,F,R,O,M=t.section,E=t.keyPath,j=t.depth,N=void 0===j?0:j,K=t.columnKey,W=void 0===K?"left":K,L=t.parentNodeId,T=void 0===L?"":L,z=t.sectionOffset,A=f(),D=A.expandedSubSections,H=A.setExpandedSubSections,G=A.maintainRelativeOrder,U=A.showDeviationBadges,V=void 0!==U&&U,q=A.proposedSections,J=A.existingSections,Q=A.treeData,X=A.deviationNumberRegistry,Y=A.connectedSections,Z=A.activeSideBySideSection,$=A.isSideBySide,nn=A.scrollSyncLocked,en=A.toggleScrollSyncLocked,tn=A.summaryPopupAnchorEl,on=A.resolvedMarkdownStyles,ln=A.getSubSectionRef,rn=A.getSubSectionCompareStyle,dn=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=null!=Z?Z:"",xn=(null===(I=M.displayTitle)||void 0===I||I)&&p(M.title),yn=!!pn&&!!hn&&"left"===W&&M.id===hn,Sn=h(M.content),bn="boolean"==typeof mn?mn:Sn,In=Sn,_n=bn&&Sn,kn=_n?m(M.content):M.content,wn=_n?M.content:void 0,Cn=(null===(_=M.displayContent)||void 0===_||_||Sn)&&p(M.content),Pn=!xn&&!Cn,Bn=xn?M.title:Cn?"No Title Found":"No Matching Section Found",Fn=!!D[E],Rn=ln(W,E),On=E.split("-").map(Number)[0],Mn=q[On],En=J[On],jn=On,Nn=On,Kn=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(G)if("left"===W){var Wn=null===(k=null==Mn?void 0:Mn.refIndexes)||void 0===k?void 0:k[0],Ln=J.findIndex(function(n){return n.selfIndex===Wn});-1!==Ln&&(En=J[Ln],Nn=Ln)}else{var Tn=null===(w=null==En?void 0:En.refIndexes)||void 0===w?void 0:w[0],zn=q.findIndex(function(n){return n.selfIndex===Tn});-1!==zn&&(Mn=q[zn],jn=zn)}var An=function(n,i){if(!i||!n)return null;for(var e=0;e<n.length;e++){var t=Kn(n[e],i,String(e));if(t)return t}return null},Dn=null,Hn=null,Gn="",Un="";if(G)"left"===W?(Dn=M,Gn=E,(Vn=Kn(En,M.id,String(Nn)))||(Vn=An(J,M.id)),Hn=(null==Vn?void 0:Vn.section)||null,Un=(null==Vn?void 0:Vn.keyPath)||""):(Hn=M,Un=E,(qn=Kn(Mn,M.id,String(jn)))||(qn=An(q,M.id)),Dn=(null==qn?void 0:qn.section)||null,Gn=(null==qn?void 0:qn.keyPath)||"");else if("left"===W){Dn=M,Gn=E;var Vn=An(J,M.id);Hn=(null==Vn?void 0:Vn.section)||null,Un=(null==Vn?void 0:Vn.keyPath)||""}else{Hn=M,Un=E;var qn=An(q,M.id);Dn=(null==qn?void 0:qn.section)||null,Gn=(null==qn?void 0:qn.keyPath)||""}var Jn=(Gn?rn(Gn):null)||rn(E),Qn=null===(C=null==Q?void 0:Q.input_index_map)||void 0===C?void 0:C[0],Xn=null===(P=null==Q?void 0:Q.input_index_map)||void 0===P?void 0:P[1],Yn="left"===W?Xn:Qn,Zn="left"===W?!Hn:!Dn,$n=M.evaluationResult||(null==Dn?void 0:Dn.evaluationResult)||(null==Hn?void 0:Hn.evaluationResult),ni=On+1,ii=M.id||(null==Dn?void 0:Dn.id)||(null==Hn?void 0:Hn.id);if(G){var ei=1,ti=new Map;if(q.forEach(function(n){!n.title&&!n.content||n.id&&ti.set(n.id,ei++)}),"left"===W)ni=ti.get(null==Mn?void 0:Mn.id)||On+1;else{var oi=q.filter(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(null==En?void 0:En.selfIndex)});if(oi.length>0)ni=ti.get(oi[0].id)||On+1;else for(var li=ei,ri=function(n){if(!n.title&&!n.content)return"continue";var i=q.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==En?void 0:En.id))return ni=li,"break";li++}},di=0,ai=J;di<ai.length;di++){if("break"===ri(ai[di]))break}}}var ui=null!==(R=null===(F=null===(B=null==$n?void 0:$n.evaluation_outputs)||void 0===B?void 0:B.metadata)||void 0===F?void 0:F.label_color)&&void 0!==R?R:S,ci=g(ui).highlightBg,si=(null==$n?void 0:$n.deviations)||{},vi=Object.entries(si).map(function(n){var i=n[0],e=n[1],t="".concat(ii).concat(y).concat(i);return{deviationKey:i,deviationMap:e,refId:t,currentIndex:X[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});vi.sort(function(n,i){return n.currentIndex-i.currentIndex});var fi=vi.map(function(i){var e,t,o,l=i.deviationKey,r=i.deviationMap,d=i.refId,a=i.currentIndex;G&&void 0!==z&&(a-=z);var u=r[T],c=x(u);if(c)u="";else if(!u)return null;var s=r[Yn],v=Zn||x(s),f="".concat(ni,".").concat(a),p="".concat(ii).concat(y).concat(l).concat(y).concat(Gn).concat(y).concat(Un),h=(null==r?void 0:r.evaluation_outputs)||(null==$n?void 0:$n.evaluation_outputs),m=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=g(S),I=n({},b),_=(null==r?void 0:r.deviation_summary)?{deviation_summary:r.deviation_summary||(null==$n?void 0:$n.deviation_summary),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_explanation:(null==r?void 0:r.deviation_explanation)||(null==$n?void 0:$n.deviation_explanation),evaluation_outputs:h,cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==$n?void 0:$n.cognitive_decisioning)}:null,k=0,w=kn||"";if(u&&w){var C=w.split(/\n{2,}/),P=C.findIndex(function(n){return n.includes(u)});if(-1!==P){var B=Object.entries(si).filter(function(n){n[0];var i=n[1][T];return i&&C[P].includes(i)}).sort(function(n,i){return C[P].indexOf(n[1][T])-C[P].indexOf(i[1][T])}),F=B.filter(function(n){n[0];var i=n[1][T];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=dn(W,d);return{id:d,actionId:p,label:f,highlight:u,side:W,style:I,stackIndex:k,score:m,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=Dn?n(n({},Dn),{title:(null==Mn?void 0:Mn.title)||(null==Dn?void 0:Dn.title)||""}):{id:"orphan-left",title:"",content:""},t=Hn?n(n({},Hn),{title:(null==En?void 0:En.title)||(null==Hn?void 0:Hn.title)||""}):{id:"orphan-right",title:"",content:""};an(i,e,v,t,p,I)},onSummaryClick:function(n){n.stopPropagation(),un(n,p,v,_)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),pi=V||!bn&&yn,hi=pi?fi:[],mi=pi?hi.map(function(n){return n.highlight}).filter(Boolean):[],gi=o(!1);l(function(){Fn||(gi.current=!1)},[Fn]),l(function(){if(Fn&&!gi.current){var n=setTimeout(function(){var n,i;gi.current=!0;var e=null===(i=null===(n=fi[0])||void 0===n?void 0:n.badgeRef)||void 0===i?void 0:i.current;e&&e.scrollIntoView({behavior:"smooth",block:"center"})},350);return function(){return clearTimeout(n)}}},[Fn,fi]);var xi=fi.find(function(n){return Y.has(n.actionId)}),yi=!!xi;if(!(xn||Cn||M.subsections&&0!==M.subsections.length))return null;var Si=(null===(O=null==xi?void 0:xi.style)||void 0===O?void 0:O.badgeBorder)||(null==Jn?void 0:Jn.badgeBorder),bi=yi&&Si?{borderRadius:"4px",outline:"2px solid ".concat(Si),outlineOffset:"1px"}:{};return i(r,xn?n({ref:Rn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(r,n({sx:n({width:"100%"},bi)},{children:e(d,n({disableGutters:!0,expanded:!Pn&&Fn,onChange:function(){if(!Pn){if(Fn){var i=String(Z||""),e=i.includes(Gn)||i.includes(Un);e||Y.forEach(function(n){(String(n).includes(Gn)||String(n).includes(Un))&&(e=!0)}),e&&(cn(),sn(new Set),vn([]),fn.current=[])}H(function(i){var e;return n(n({},i),((e={})[E]=!i[E],e))})}},sx:{mt:0,boxShadow:"none",border:Pn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[i(a,n({expandIcon:Pn?null:i(s,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i(u,n({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Pn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Bn||"Untitled Subsection"}))})),!Pn&&e(c,n({sx:{pt:0,pb:1,minWidth:0}},{children:[Cn&&i(v,{content:kn,overlayContent:wn,sxStyles:on,deviationBadges:hi,maintainRelativeOrder:G,highlightBg:ci,suppressHighlightBg:In,highlights:mi,collisionKey:gn}),(M.subsections||[]).map(function(n,e){return i(b,{section:n,keyPath:"".concat(E,"-").concat(e),depth:N+1,columnKey:W,parentNodeId:T},"".concat(E,"-").concat(e))})]}))]}))}))}):n({ref:Rn,sx:{mt:0===N?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Pn&&e(r,n({sx:n({width:"100%"},bi)},{children:[Cn&&i(v,{content:kn,overlayContent:wn,sxStyles:on,deviationBadges:hi,maintainRelativeOrder:G,highlightBg:ci,suppressHighlightBg:In,highlights:mi,collisionKey:gn}),(M.subsections||[]).map(function(n,e){return i(b,{section:n,keyPath:"".concat(E,"-").concat(e),depth:N+1,columnKey:W,parentNodeId:T,sectionOffset:z},"".concat(E,"-").concat(e))})]}))}))});export{b 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{safeStringify as f,mixHexColors as g,areMarkdownPropsEqual as v}from"../CognitiveComparehelpers.js";import m from"rehype-raw";var x=l.memo(function(v){var x=v.content,b=v.overlayContent,y=v.sxStyles,C=v.deviationBadges,E=void 0===C?[]:C,F=v.highlights,S=void 0===F?[]:F,k=v.maintainRelativeOrder,w=void 0===k||k,B=v.highlightBg,A=v.suppressHighlightBg,T=void 0!==A&&A,I=v.collisionKey,O=c(null),z=!!b,D=d(function(){return E.reduce(function(e,t){var r;return n(n({},e),((r={})[t.id]=t,r))},{})},[E]),j=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)?j(e.props.children,t):e.props.children,o=l.cloneElement(e,n(n({},e.props),{children:i}));return t(o)})},N=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=e(r,["children"]),s=d["data-badge-id"],u=s?D[s]:null,h=d["data-highlight-color"],p=null!==(l=null!==(o=null!=h?h:null===(i=null==u?void 0:u.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==u?void 0:u.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:B,f=d.isSuggestedDeviationFix||T;return t("span",n({style:n(n(n({},f?{}:{backgroundColor:p}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),z?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,f=i.children,g=e(i,["children"]),v=g["data-badge-id"];if(!v)return t("span",n({},g,{children:f}));var m=D[v];if(!m)return t("span",n({},g,{children:f}));var x="number"==typeof m.stackIndex?m.stackIndex:0,b="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:m.badgeRef,className:"deviation-badge","data-side":m.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=m.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=m.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=m.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"===m.side?{right:"-16px",transform:"".concat(b," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(b," translateX(calc(-100% - 8px))")}),m.isConnected&&m.style&&{outline:"2px solid ".concat(m.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,n({onClick:function(n){n.stopPropagation(),m.onSummaryClick&&m.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:m.label})),("left"===m.side||m.isOrphan)&&t(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=m.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=m.score&&"N/A"!==m.score&&"NA"!==m.score&&0!==m.score?"".concat(m.score):"N/A"===m.score||"NA"===m.score?"N/A":"Same"}))]})),("left"===m.side||m.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),m.onClick&&m.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=m.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=m.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),f]}))},updated:function(n){var r=n.children;return e(n,["children"]),t(i,{children:r})},deleted:function(r){var i=r.children;e(r,["children"]),console.log("nitish: ",i);var o=j(i,function(n){return l.cloneElement(n,{isSuggestedDeviationFix:!0})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:o}))},changed:function(r){var i=r.children;e(r,["children"]);var o=j(i,function(n){return l.cloneElement(n,{isSuggestedDeviationFix:!0})});return t("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:o}))}}},[D,w,B,z,T]),R=function(n){return n?n.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n").split(/(\n{2,})/).map(function(n){return n.startsWith("\n")?n:n.replace(/\n/g," ")}).join(""):""},P=d(function(){return E.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[E]),W=function(n){return n.replace(/[\.,;:]/g," ")},$=d(function(){var e=R(f(x||"")),t=T?W(e):e,r=(E||[]).map(function(n){var e,t;return{id:null==n?void 0:n.id,highlight:R((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){void 0===n&&(n="");var t=e?' data-highlight-color="'.concat(e,'"'):"";return'<mark data-badge-id="'.concat(n,'"').concat(t,">")},a=function(n){return'<span data-badge-id="'.concat(n,'">')},l=[];Object.entries(i).forEach(function(n){var r=n[0],i=n[1],o=e.indexOf(r),a=!1;if(-1===o&&T){var c=W(r);-1!==(o=t.indexOf(c))&&(a=!0)}if(-1!==o){for(var d=i[0].highlightColor,s=1;s<i.length;s++)d=g(d,i[s].highlightColor);l.push({highlight:r,start:o,end:o+r.length,badges:i,color:d,usedLooseMatch:a})}}),l.sort(function(n,e){return n.start-e.start||e.end-n.end});var c=[],d={};l.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=function(n,e,t){void 0===e&&(e="");var r=n.startsWith("\n\n"),i=n.endsWith("\n\n"),a=n.split(/(\n{2,})/).map(function(n,a,l){if(/^\n{2,}$/.test(n))return n;if(!n.trim())return n;var c=0===a||1===a&&/^\n{2,}$/.test(l[0]),d=a===l.length-1||a===l.length-2&&/^\n{2,}$/.test(l[l.length-1]);return r&&c||i&&d?n:function(n,e,t){var r,i,a;void 0===e&&(e="");var l=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!l)return n;var c=null!==(r=l[1])&&void 0!==r?r:"",d=null!==(i=l[2])&&void 0!==i?i:"",s=null!==(a=l[3])&&void 0!==a?a:"";return d?c+o(e,t)+d+"</mark>"+s:n}(n,e,t)}).join("");return a.replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")},h=l.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)});h.forEach(function(n){var t,r,i=null!==(t=n.trimmedStart)&&void 0!==t?t:n.start,o=null!==(r=n.trimmedEnd)&&void 0!==r?r:n.end;if(!(i>=o)){var c=e.slice(i,o),d=function(n,e,t,r){if(!t.length)return n;var i=t.map(function(n){return l[n]}).sort(function(n,e){return n.start-e.start}),o="",c=0;return i.forEach(function(t){var i=t.start-e,l=t.end-e,d=g(r,t.color);o+=n.slice(c,i);var s="",h="";t.badges.forEach(function(n){s+=a(n.id),h="</span>"+h}),o+=s+u(n.slice(i,l),t.badges[0].id,d)+h,c=l}),o+=n.slice(c)}(n.usedLooseMatch||i!==n.start||o!==n.end?c:n.highlight,n.start,s[n.idx]||[],n.color),h=u(d,n.badges[0].id,n.color),p="",f="";n.badges.forEach(function(n){p+=a(n.id),f="</span>"+f});var v=p+h+f;e=e.slice(0,i)+v+e.slice(o)}});var p=new Set(Object.keys(i));return S.forEach(function(n){if(n){var r=R(n);if(r&&!p.has(r)){var i=T?t.indexOf(W(r)):e.indexOf(r);if(-1!==i){var a=e.slice(0,i);if((a.match(/</g)||[]).length===(a.match(/>/g)||[]).length){var l=o("","")+r+"</mark>";e=e.slice(0,i)+l+e.slice(i+r.length)}}}}}),e},[x,E,S,B,T]),q=d(function(){return b?R(f(b||"")):""},[b]),L=!!b,M=n(n(n(n({},y),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap",gridArea:"1 / 1",zIndex:2}),L?{color:"transparent"}:{}),{"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}}),X=n(n({},y),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap",gridArea:"1 / 1",zIndex:1,pointerEvents:"none","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}});return s(function(){if(O.current){var n=function(){var n=Array.from(O.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=O.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(O.current),function(){t.disconnect(),cancelAnimationFrame(e)}}},[$,I,P]),r(o,n({ref:O,sx:{position:"relative",display:"grid"}},{children:[t(a,n({component:"div",sx:n(n({},M),{padding:"3px"})},{children:t(p,n({components:N,rehypePlugins:[m]},{children:f($).replace(/\\n/g,"\n")}))})),L&&t(a,n({component:"div",sx:X},{children:t(p,n({components:N,rehypePlugins:[m]},{children:f(q).replace(/\\n/g,"\n")}))}))]}))},v);export{x as MemoizedMarkdown};
|
|
1
|
+
import{__assign as n,__rest as e}from"tslib";import{jsx as r,jsxs as t,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as l}from"@mui/material";import a,{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{safeStringify as g,mixHexColors as f,areMarkdownPropsEqual as v}from"../CognitiveComparehelpers.js";import m from"rehype-raw";import x from"remark-gfm";import b from"../components/ScrollLockToggle.js";var y=a.memo(function(v){var y=v.content,E=v.overlayContent,C=v.sxStyles,k=v.deviationBadges,S=void 0===k?[]:k,F=v.highlights,w=void 0===F?[]:F,B=v.maintainRelativeOrder,A=void 0===B||B,T=v.highlightBg,z=v.suppressHighlightBg,I=void 0!==z&&z,O=v.collisionKey,D=c(null),j=!!E,L=d(function(){return S.reduce(function(e,r){var t;return n(n({},e),((t={})[r.id]=r,t))},{})},[S]),P=function(e,r){return a.Children.map(e,function(e){var t;if(!a.isValidElement(e))return e;var i=(null===(t=e.props)||void 0===t?void 0:t.children)?P(e.props.children,r):e.props.children,o=a.cloneElement(e,n(n({},e.props),{children:i}));return r(o)})},N=d(function(){return{mark:function(t){var i,o,l,a,c=t.children,d=e(t,["children"]),s=d["data-badge-id"],u=s?L[s]:null,h=d["data-highlight-color"],p=null!==(a=null!==(o=null!=h?h:null===(i=null==u?void 0:u.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(l=null==u?void 0:u.style)||void 0===l?void 0:l.badgeBg)&&void 0!==a?a:T,g=d.isSuggestedDeviationFix||I;return r("span",n({style:n(n(n({},g?{}:{backgroundColor:p}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),j?{color:"transparent"}:{})},{children:c}))},span:function(i){var l,a,c,d,s,p,g,f,v=i.children,m=e(i,["children"]),x=m["data-badge-id"];if(!x)return r("span",n({},m,{children:v}));var y=L[x];if(!y)return r("span",n({},m,{children:v}));var E="number"==typeof y.stackIndex?y.stackIndex:0,C="translateY(calc(-20% + ".concat(12*E,"px + var(--badge-nudge, 0px)))");return t(o,n({component:"span",sx:{position:"static",display:"inline"}},{children:[t(o,n({ref:y.badgeRef,className:"deviation-badge","data-side":y.side||"right",sx:n(n({fontStyle:"normal",position:"absolute",zIndex:30+E,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(l=y.style)||void 0===l?void 0:l.badgeBg)||"#EEF2FF",color:(null===(a=y.style)||void 0===a?void 0:a.badgeText)||u,border:"1px solid ".concat((null===(c=y.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"===y.side?{right:"-16px",transform:"".concat(C," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(C," translateX(calc(-100% - 8px))")}),y.isConnected&&y.style&&{outline:"2px solid ".concat(y.style.badgeBorder),outlineOffset:"1px"})},{children:[t(o,n({onClick:function(n){n.stopPropagation(),y.onSummaryClick&&y.onSummaryClick(n)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[r(o,n({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:y.label})),("left"===y.side||y.isOrphan)&&r(o,n({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=y.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=y.score&&"N/A"!==y.score&&"NA"!==y.score&&0!==y.score?"".concat(y.score):"N/A"===y.score||"NA"===y.score?"N/A":"Same"}))]})),("left"===y.side||y.isOrphan)&&t(o,n({onClick:function(n){n.stopPropagation(),y.onClick&&y.onClick(n)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=y.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:[r(h,{size:12,color:(null===(p=y.style)||void 0===p?void 0:p.badgeText)||"#3730A3"}),y.showScrollLockToggle&&r(b,{locked:!!y.scrollSyncLocked,onToggle:y.toggleScrollSyncLocked,color:(null===(g=y.style)||void 0===g?void 0:g.badgeText)||"#3730A3",borderColor:(null===(f=y.style)||void 0===f?void 0:f.badgeBorder)||"#C7D2FE",size:12})]}))]})),v]}))},table:function(e){var t=e.children;return r(o,n({component:"table",sx:{width:"100%",borderCollapse:"collapse",my:1,fontSize:"inherit"}},{children:t}))},thead:function(e){var t=e.children;return r(o,n({component:"thead"},{children:t}))},tbody:function(e){var t=e.children;return r(o,n({component:"tbody"},{children:t}))},tr:function(e){var t=e.children;return r(o,n({component:"tr",sx:{borderBotttom:"1px solid #E5E7EB"}},{children:t}))},th:function(e){var t=e.children;return r(o,n({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",fontWeight:600,backgroundColor:"#F9FAFB"}},{children:t}))},td:function(e){var t=e.children;return r(o,n({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top"}},{children:t}))},updated:function(n){var t=n.children;return e(n,["children"]),r(i,{children:t})},deleted:function(t){var i=t.children;e(t,["children"]),console.log("nitish: ",i);var o=P(i,function(n){return a.cloneElement(n,{isSuggestedDeviationFix:!0})});return r("span",n({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:o}))},changed:function(t){var i=t.children;e(t,["children"]);var o=P(i,function(n){return a.cloneElement(n,{isSuggestedDeviationFix:!0})});return r("span",n({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:o}))}}},[L,A,T,j,I]),R=function(n){if(!n)return"";var e=n.replace(/\\([''])/g,"$1").replace(/\\n/g,"\n").replace(/\r\n/g,"\n");return/\|.*\|/.test(e)&&/\|[-:\s]+\|/.test(e)?e.replace(/(\|.*\|)\n\s*\n(?=\|)/g,"$1\n"):e.split(/(\n{2,})/).map(function(n){return n.startsWith("\n")?n:n.replace(/\n/g," ")}).join("")},W=d(function(){return S.map(function(n){return{id:n.id,connected:n.isConnected,stackIndex:n.stackIndex,size:n.size}})},[S]),$=function(n){return n.replace(/[\.,;:]/g," ")},q=d(function(){var e=R(g(y||"")),r=I?$(e):e,t=(S||[]).map(function(n){var e,r;return{id:null==n?void 0:n.id,highlight:R((null==n?void 0:n.highlight)||""),highlightColor:(null===(e=null==n?void 0:n.style)||void 0===e?void 0:e.highlightBg)||(null===(r=null==n?void 0:n.style)||void 0===r?void 0:r.badgeBg)||T}}).filter(function(n){return n.id&&n.highlight}),i={};t.forEach(function(n){i[n.highlight]||(i[n.highlight]=[]),i[n.highlight].push(n)});var o=function(n,e){void 0===n&&(n="");var r=e?' data-highlight-color="'.concat(e,'"'):"";return'<mark data-badge-id="'.concat(n,'"').concat(r,">")},l=function(n){return'<span data-badge-id="'.concat(n,'">')},a=[];Object.entries(i).forEach(function(n){var t=n[0],i=n[1],o=e.indexOf(t),l=!1;if(-1===o&&I){var c=$(t);-1!==(o=r.indexOf(c))&&(l=!0)}if(-1!==o){for(var d=i[0].highlightColor,s=1;s<i.length;s++)d=f(d,i[s].highlightColor);a.push({highlight:t,start:o,end:o+t.length,badges:i,color:d,usedLooseMatch:l})}}),a.sort(function(n,e){return n.start-e.start||e.end-n.end});var c=[],d={};a.forEach(function(n,e){for(var r=n.start,t=n.end,i=0,o=c;i<o.length;i++){var l=o[i],a=l.start,s=l.end,u=r<s&&t>s&&r>=a,h=r<a&&t>a&&t<=s;if(r>=a&&t<=s){n.orphaned=!0,d[e]=l.matchIdx;break}u&&(r=s),h&&(t=a)}n.trimmedStart=r,n.trimmedEnd=t,!n.orphaned&&r<t&&c.push({start:r,end:t,matchIdx:e})});var s={};Object.entries(d).forEach(function(n){var e=n[0],r=n[1],t=Number(e);s[r]||(s[r]=[]),s[r].push(t)});var u=function(n,e,r){void 0===e&&(e="");var t=n.startsWith("\n\n"),i=n.endsWith("\n\n"),l=n.split(/(\n{2,})/).map(function(n,l,a){if(/^\n{2,}$/.test(n))return n;if(!n.trim())return n;var c=0===l||1===l&&/^\n{2,}$/.test(a[0]),d=l===a.length-1||l===a.length-2&&/^\n{2,}$/.test(a[a.length-1]);return t&&c||i&&d?n:function(n,e,r){var t,i,l;void 0===e&&(e="");var a=n.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return n;var c=null!==(t=a[1])&&void 0!==t?t:"",d=null!==(i=a[2])&&void 0!==i?i:"",s=null!==(l=a[3])&&void 0!==l?l:"";return d?c+o(e,r)+d+"</mark>"+s:n}(n,e,r)}).join("");return l.replace(/^\n{2,}/,"").replace(/\n{2,}$/,"")},h=a.map(function(e,r){return n(n({},e),{idx:r})}).filter(function(n){return!n.orphaned}).sort(function(n,e){var r,t;return(null!==(r=e.trimmedStart)&&void 0!==r?r:e.start)-(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)});h.forEach(function(n){var r,t,i=null!==(r=n.trimmedStart)&&void 0!==r?r:n.start,o=null!==(t=n.trimmedEnd)&&void 0!==t?t:n.end;if(!(i>=o)){var c=e.slice(i,o),d=function(n,e,r,t){if(!r.length)return n;var i=r.map(function(n){return a[n]}).sort(function(n,e){return n.start-e.start}),o="",c=0;return i.forEach(function(r){var i=r.start-e,a=r.end-e,d=f(t,r.color);o+=n.slice(c,i);var s="",h="";r.badges.forEach(function(n){s+=l(n.id),h="</span>"+h}),o+=s+u(n.slice(i,a),r.badges[0].id,d)+h,c=a}),o+=n.slice(c)}(n.usedLooseMatch||i!==n.start||o!==n.end?c:n.highlight,n.start,s[n.idx]||[],n.color),h=u(d,n.badges[0].id,n.color),p="",g="";n.badges.forEach(function(n){p+=l(n.id),g="</span>"+g});var v=p+h+g;e=e.slice(0,i)+v+e.slice(o)}});var p=new Set(Object.keys(i));return w.forEach(function(n){if(n){var t=R(n);if(t&&!p.has(t)){var i=I?r.indexOf($(t)):e.indexOf(t);if(-1!==i){var l=e.slice(0,i);if((l.match(/</g)||[]).length===(l.match(/>/g)||[]).length){var a=o("","")+t+"</mark>";e=e.slice(0,i)+a+e.slice(i+t.length)}}}}}),e},[y,S,w,T,I]),M=d(function(){return E?R(g(E||"")):""},[E]),X=!!E,H=n(n(n(n({},C),{position:"relative",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",zIndex:2}),X?{color:"transparent"}:{}),{"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}}),K=n(n({},C),{position:"relative",overflow:"visible",whiteSpace:"pre-wrap",gridArea:"1 / 1",zIndex:1,pointerEvents:"none","& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap"},"& *":{fontFamily:"inherit"}});return s(function(){if(D.current){var n=function(){var n=Array.from(D.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}),r=n.filter(function(n){return"left"!==n.dataset.side}),t=D.current.getBoundingClientRect(),i=t.bottom-4,o=t.top+4,l=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 r=[],t=[];e.forEach(function(n){if(0===t.length)t.push(n);else{var e=t[t.length-1],i=e.currentTop+e.height;n.naturalTop<i+8?(n.currentTop=i+8,t.push(n)):(r.push(t),t=[n])}}),t.length>0&&r.push(t),r.forEach(function(n){var e=n[n.length-1],r=e.currentTop+e.height;if(r>i){var t=r-i,l=n[0].currentTop-o,a=Math.max(0,Math.min(t,l));n.forEach(function(n){n.currentTop-=a})}}),r.flat().forEach(function(n){var e=n.currentTop-n.naturalTop;n.el.style.setProperty("--badge-nudge","".concat(e,"px"))})}};l(e),l(r)}},e=requestAnimationFrame(function(){requestAnimationFrame(function(){n()})}),r=new ResizeObserver(function(){requestAnimationFrame(n)});return r.observe(D.current),function(){r.disconnect(),cancelAnimationFrame(e)}}},[q,O,W]),t(o,n({ref:D,sx:{position:"relative",display:"grid"}},{children:[r(l,n({component:"div",sx:n(n({},H),{padding:"3px"})},{children:r(p,n({components:N,remarkPlugins:[x],rehypePlugins:[m]},{children:g(q).replace(/\\n/g,"\n")}))})),X&&r(l,n({component:"div",sx:K},{children:r(p,n({components:N,remarkPlugins:[x],rehypePlugins:[m]},{children:g(M).replace(/\\n/g,"\n")}))}))]}))},v);export{y 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 t}from"react";import{getSideData as e,safeStringify as o,getRationale as l,hasValue as s,isMissingStr as d,DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";var a={id:"",title:"",similarity:0,sections:[]},u=function(u,v,c,f,_){void 0===_&&(_=!0);var p=JSON.stringify(c||{}),b=t(function(){var t,s,d,r;if(!u||0===Object.keys(u).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var a=JSON.parse(p);try{var c=u.nodes||u,f=[],b=[],h=u.base_root_id,m=u.input_index_map||{0:"left",1:"right"},g=u[h]||c[h];if(!g||!1===g.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var y=function(n,t,e){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,a,u,v,c=n[i];if(c&&"object"==typeof c){r||(r=c);var f=(null===(l=null==c?void 0:c.deviation_highlights)||void 0===l?void 0:l[t])||(null===(a=null==c?void 0:c.deviation_highlights)||void 0===a?void 0:a[m[0]])||[],_=(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[m[1]])||[];s[i]=((o={})[m[0]]=f[0]||"",o[m[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),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(n,t){var s,d,r,v=u[n]||c[n];if(!v||!1===v.display_node)return null;var f=v.comparison_inputs?Object.keys(v.comparison_inputs):[],_=m[0],p=m[1];f.length>0&&(_=f.includes(m[0])?m[0]:f[0],p=f.includes(m[1])?m[1]:f.length>1?f[1]:f[0]);var b=e(v,t,m),h=!1!==(null===(s=b.attributes)||void 0===s?void 0:s.display_title),g=!1!==(null===(d=b.attributes)||void 0===d?void 0:d.display_content),I=!!o(b.title).trim(),E=!!o(b.content).trim(),N=l(v),S=(null===(r=null==a?void 0:a[n])||void 0===r?void 0:r.evaluation_result)||v.evaluation_result||null,j=y(S,_,p),O=[];v.next&&Object.values(v.next).forEach(function(i){var n=c[i];if(n&&!1!==n.display_node){var e=x(i,t);e&&O.push(e)}});var R=!(!I&&!E);return i(i({id:n,title:I?b.title:"",content:E?b.content:"",change_history:E?b.change_history:"",displayTitle:h,displayContent:g,subsections:O},R?N:{score:void 0,relation:"not_defined"}),{evaluationResult:j})};if(v){var I=function(t,o){var s,d,r,v,f,_,p,b,h,g,x,E,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(!t)return{refSections:B,baseSections:G};var H={},K={},L=-1,Q=-1;for(var W in t){var X=t[W],Y=u[X]||c[X];if(Y&&!1!==Y.display_node){var Z=Y.comparison_inputs?Object.keys(Y.comparison_inputs):[],ii=m[0],ni=m[1];Z.length>0&&(ii=Z.includes(m[0])?m[0]:Z[0],ni=Z.includes(m[1])?m[1]:Z.length>1?Z[1]:Z[0]);var ti=l(Y),ei=(null===(s=null==a?void 0:a[X])||void 0===s?void 0:s.evaluation_result)||Y.evaluation_result||null,oi=y(ei,ii,ni),li=e(Y,"1",m),si=e(Y,"0",m),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===(g=null===(h=si.title)||void 0===h?void 0:h.trim)||void 0===g?void 0:g.call(h))||"")||!1!==(null===(x=si.attributes)||void 0===x?void 0:x.display_content)&&((null===(N=null===(E=si.content)||void 0===E?void 0:E.trim)||void 0===N?void 0:N.call(E))||""),ai=Number(null!==(j=null===(S=li.attributes)||void 0===S?void 0:S.display_index)&&void 0!==j?j:L--),ui=Number(null!==(R=null===(O=si.attributes)||void 0===O?void 0:O.display_index)&&void 0!==R?R:Q--),vi=0===o?String(ai):"".concat(ai,"_").concat(X),ci=0===o?String(ui):"".concat(ui,"_").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?ti:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ai,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?ti:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ui,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(ai)>=0&&Number(ui)>=0&&((null===(F=fi.refIndexes)||void 0===F?void 0:F.includes(Number(ui)))||null===($=fi.refIndexes)||void 0===$||$.push(Number(ui)),(null===(z=_i.refIndexes)||void 0===z?void 0:z.includes(Number(ai)))||null===(A=_i.refIndexes)||void 0===A||A.push(Number(ai))),H[vi]=fi,K[ci]=_i;var pi=I(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 mi=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(mi),G.sort(mi),{refSections:B,baseSections:G}},E=I(g.next),N=E.refSections,S=E.baseSections;b=function(i){var n=new Map,t=function(i){i.forEach(function(i){var e;i.id&&n.set(i.id,i),(null===(e=i.subsections)||void 0===e?void 0:e.length)&&t(i.subsections)})};t(i);var e=function(i,t){for(var o,l=[],s=function(i){var s=i.ref_parent_section_node_id;if(s&&n.has(s)&&s!==(null==t?void 0:t.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=e(i.subsections,i)),l.push(i)},d=0,r=i;d<r.length;d++){s(r[d])}return l};return e(i)}(N),f=S}else g.next&&Object.values(g.next).forEach(function(i){var n=u[i]||c[i];n&&!1!==n.display_node&&(f.push(x(i,"0")||{id:i,title:"",content:"",subsections:[]}),b.push(x(i,"1")||{id:i,title:"",content:"",subsections:[]}))});return{activeProposed:{title:(null===(s=null===(t=g.comparison_inputs)||void 0===t?void 0:t[m[0]])||void 0===s?void 0:s.title)||"Uploaded Contract",description:g.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(r=null===(d=g.comparison_inputs)||void 0===d?void 0:d[m[1]])||void 0===r?void 0:r.title)||"Reference Template",similarity:0,sections:b,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:g.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,_]),h=b.activeProposed,m=b.activeVariants,g=b.parseError,y=(null==m?void 0:m[0])||a,x=t(function(){return(null==h?void 0:h.sections)||[]},[null==h?void 0:h.sections]),I=t(function(){return y.sections||[]},[y.sections]),E=x.length>0||I.length>0,N=t(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=t(function(){var i,n,t={},e={},o={},l=0,s=null===(i=null==u?void 0:u.input_index_map)||void 0===i?void 0:i[0],a=null===(n=null==u?void 0:u.input_index_map)||void 0===n?void 0:n[1],c=function(i,n,u,v,f,_){var p,b,h,m,g,y,x,I;if(i&&function(i,n){var t,l=(null===(t=null==i?void 0:i.evaluationResult)||void 0===t?void 0:t.deviations)||{};Object.keys(l).sort().forEach(function(t){var u=l[t];if(u){var v=!d(u[s]),c=!d(u[a]);if(v||c){var f="".concat(i.id).concat(r).concat(t);void 0===e[f]&&(void 0===o[n]&&(o[n]=1),e[f]=o[n]++)}}})}(i,v),i&&!f){var E=(null==_?void 0:_.id)||"fallback_parent_".concat(l++);t[E]||(t[E]=[]),t[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==u?void 0:u.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===(m=null==i?void 0:i.subsections)||void 0===m?void 0:m[S])||(null===(g=null==n?void 0:n.subsections)||void 0===g?void 0:g[S])||(null===(y=null==u?void 0:u.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==u?void 0:u.subsections)||void 0===I?void 0:I[S],v,!1,_)};return x.forEach(function(i,n){var t,e=n+1;v&&void 0!==i.selfIndex&&i.selfIndex>=0&&(e=i.selfIndex+1);var o=null;if(v){var l=null===(t=i.refIndexes)||void 0===t?void 0:t[0];o=I.find(function(i){return i.selfIndex===l})}else o=I[n];c(i,i,o,e,!0,i)}),I.forEach(function(i,n){var t,e=n+1,o=!1;if(v){var l=null===(t=i.refIndexes)||void 0===t?void 0:t[0],s=x.find(function(i){return i.selfIndex===l});s&&void 0!==s.selfIndex&&s.selfIndex>=0?e=s.selfIndex+1:(o=!0,void 0!==i.selfIndex&&i.selfIndex>=0&&(e=i.selfIndex+1))}else n>=x.length&&(o=!0);o&&c(i,null,i,e,!0,i)}),{parentDeviationRecord:t,registry:e}},[x,I,v,u]),j=S.parentDeviationRecord,O=S.registry;return{activeProposed:h,activeVariants:m,existingRule:y,proposedSections:x,existingSections:I,visibleFields:N,parentDeviationRecord:j,deviationNumberRegistry:O,parseError:g}};export{u as useCognitiveTreeData};
|
|
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=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,m=a.input_index_map||{0:"left",1:"right"},y=a[h]||c[h];if(!y||!1===y.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var g=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===(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[m[0]])||[],_=(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[m[1]])||[];s[i]=((o={})[m[0]]=f[0]||"",o[m[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),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=m[0],h=m[1];p.length>0&&(b=p.includes(m[0])?m[0]:p[0],h=p.includes(m[1])?m[1]:p.length>1?p[1]:p[0]);var y=t(_,e,m),x=!1!==(null===(s=y.attributes)||void 0===s?void 0:s.display_title),E=!1!==(null===(d=y.attributes)||void 0===d?void 0:d.display_content),N=!!o(y.title).trim(),S=!!o(y.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=g(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?y.title:"",content:S?y.content:"",change_history:S?y.change_history:"",displayTitle:x,displayContent:E,subsections:k},P?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 E=function(e,o){var s,d,r,v,f,_,p,b,h,y,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=m[0],ni=m[1];Z.length>0&&(ii=Z.includes(m[0])?m[0]:Z[0],ni=Z.includes(m[1])?m[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=g(ti,ii,ni),li=t(Y,"1",m),si=t(Y,"0",m),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===(y=null===(h=si.title)||void 0===h?void 0:h.trim)||void 0===y?void 0:y.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 mi=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(mi),G.sort(mi),{refSections:B,baseSections:G}},N=E(y.next),S=N.refSections,j=N.baseSections;b=x(S),f=j}else y.next&&Object.values(y.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=y.comparison_inputs)||void 0===e?void 0:e[m[0]])||void 0===s?void 0:s.title)||"Uploaded Contract",description:y.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(r=null===(d=y.comparison_inputs)||void 0===d?void 0:d[m[1]])||void 0===r?void 0:r.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"}}},[a,v,p,_]),h=b.activeProposed,m=b.activeVariants,y=b.parseError,g=(null==m?void 0:m[0])||u,x=e(function(){return(null==h?void 0:h.sections)||[]},[null==h?void 0:h.sections]),I=e(function(){return g.sections||[]},[g.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(g[n]))})},[h,g,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,m,y,g,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===(m=null==i?void 0:i.subsections)||void 0===m?void 0:m[S])||(null===(y=null==n?void 0:n.subsections)||void 0===y?void 0:y[S])||(null===(g=null==a?void 0:a.subsections)||void 0===g?void 0:g[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:m,existingRule:g,proposedSections:x,existingSections:I,visibleFields:N,parentDeviationRecord:j,deviationNumberRegistry:O,parseError:y}};export{a as useCognitiveTreeData};
|
|
2
2
|
//# sourceMappingURL=useCompareData.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as t,useRef as e,useCallback as n,useEffect as i}from"react";import{DEVIATION_BADGE_SEPARATOR as r,hasValue as c,getBentArrowPath as o}from"../CognitiveComparehelpers.js";var l=function(l){var u=l.containerRef,a=l.leftContainerRef,d=l.rightContainerRef;l.svgContainerRef;var v=l.pathRefs,s=l.leftHeaderRef,h=l.rightHeaderRef,g=l.proposedSections,f=l.existingSections,p=l.visibleFields,y=l.leftRefs,x=l.rightRefs,R=l.sectionLeftRefs,m=l.sectionRightRefs,C=l.subSectionLeftRefs,B=l.subSectionRightRefs,S=l.lhsBadgeRefs,b=l.rhsBadgeRefs;l.sectionRowRefs;var M=l.expandedSections,L=l.expandedSubSections,I=l.connectedSections,T=l.isSideBySide,H=l.activeSideBySideSection,E=l.maintainRelativeOrder,A=l.cognitiveMap,D=l.getSectionCompareStyle,k=l.getSubSectionCompareStyle,Y=l.getDeviationStyleByKey,w=l.isArrowVisible,O=l.isAnimatingRef,j=l.isSideBySideRef,P=l.sideBySideCacheRef,F=l.sideBySideLineRef,z=l.activeSideBySideSectionRef;l.activeSideBySideRightSectionRef;var N=l.connectedLines,K=l.setConnectedLines,q=l.cachedConnectedPositions,V=l.calculateLinesRef,G=l.resizeTimerRef,J=l.scrollLock,Q=l.handleResizeRef,U=l.activeProposed,W=l.existingRule,X=l.analysisData,Z=l.pendingScrollTargetRef,$=l.pendingScrollCallbackRef,_=l.resolvedComparisonConfig,tt=l.getFieldData,et=t([]),nt=et[0],it=et[1],rt=t(null),ct=rt[0],ot=rt[1],lt=t([]),ut=lt[0],at=lt[1],dt=null!=N?N:ut,vt=null!=K?K:at,st=t({width:0,height:0}),ht=st[0],gt=st[1],ft=e(!1),pt=e(!1),yt=e(null),xt=e([]),Rt=null!=q?q:xt,mt=n(function(){var t,e,n,i,l,v,w,j,P,F,z,N,K,q,V,G,J,Q,U,W,X,Z,$;if(!ft.current&&!O.current){ft.current=!0;try{if(!u.current)return;var _=function(t){var e=t.split("-"),n=e[0];if(!M[n]&&!1===E)return!1;if(E&&!M["left-".concat(n)]&&!M["right-".concat(n)]&&!M[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!L[i])return!1;return!0},tt=u.current.getBoundingClientRect();gt({width:tt.width,height:tt.height});var et=[];if(p.forEach(function(t){var e,n,i=t.key,r=null===(e=y.current[i])||void 0===e?void 0:e.current,c=null===(n=x.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!O.current){for(var nt=0;nt<Math.max(g.length,f.length);nt++){var rt=null===(t=R.current[nt])||void 0===t?void 0:t.current,ct=null===(e=m.current[nt])||void 0===e?void 0:e.current;rt&&(rt.style.height="auto",rt.style.minHeight="0px"),ct&&(ct.style.height="auto",ct.style.minHeight="0px")}E||Object.keys(C.current).forEach(function(t){var e,n;if(_(t)){var i=null===(e=C.current[t])||void 0===e?void 0:e.current,r=null===(n=B.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var lt={};p.forEach(function(t){var e,n,i=t.key,r=null===(e=y.current[i])||void 0===e?void 0:e.current,c=null===(n=x.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=r.getBoundingClientRect(),l=c.getBoundingClientRect();lt[i]=Math.max(o.height,l.height)}});var ut={left:{},right:{}},at={};if(!O.current)if(E){if(T&&null!==H)if("number"==typeof H){var dt=H,st=g[dt],ht=null===(l=R.current[dt])||void 0===l?void 0:l.current;ht&&st&&(st.refIndexes||[]).forEach(function(t){var e,n=f.findIndex(function(e){return e.selfIndex===t}),i=null===(e=m.current[n])||void 0===e?void 0:e.current;if(i&&(M["left-".concat(dt)]||M["right-".concat(n)])){var r=Math.max(ht.getBoundingClientRect().height,i.getBoundingClientRect().height);ut.left[dt]=Math.max(ut.left[dt]||0,r),ut.right[n]=Math.max(ut.right[n]||0,r)}})}else{var pt=H.split(r)[2];if(pt){rt=null===(v=C.current[pt])||void 0===v?void 0:v.current,ct=null===(w=B.current[pt])||void 0===w?void 0:w.current;if(rt&&ct){yt=Math.max(rt.getBoundingClientRect().height,ct.getBoundingClientRect().height);at[pt]=Math.max(at[pt]||0,yt)}}}}else{Object.keys(C.current).forEach(function(t){var e,n;if(_(t)){var i=null===(e=C.current[t])||void 0===e?void 0:e.current,r=null===(n=B.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),o=r.getBoundingClientRect(),l=Math.max(c.height,o.height);at[t]=l,i.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}});for(nt=0;nt<Math.min(g.length,f.length);nt++){var rt=null===(n=R.current[nt])||void 0===n?void 0:n.current,ct=null===(i=m.current[nt])||void 0===i?void 0:i.current;if(rt&&ct){var yt=Math.max(rt.getBoundingClientRect().height,ct.getBoundingClientRect().height);ut.left[nt]=yt,ut.right[nt]=yt}}}if(p.forEach(function(t){var e,n,i=t.key,r=null===(e=y.current[i])||void 0===e?void 0:e.current,c=null===(n=x.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=lt[i];r.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),O.current||(Object.entries(ut.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=R.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(ut.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=m.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),E||Object.keys(at).forEach(function(t){var e,n,i=null===(e=C.current[t])||void 0===e?void 0:e.current,r=null===(n=B.current[t])||void 0===n?void 0:n.current;if(i&&r&&at[t]){var c=at[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),E)g.forEach(function(t,e){var n;(null===(n=R.current[e])||void 0===n?void 0:n.current)&&(t.refIndexes||[]).forEach(function(t){var n,i,r,c,o,l,u,v,s,h,g=f.findIndex(function(e){return e.selfIndex===t});if(-1!==g){var p=null===(n=S.current[e])||void 0===n?void 0:n.current,y=null===(i=b.current[g])||void 0===i?void 0:i.current;if(p&&y){var x=p.getBoundingClientRect(),R=y.getBoundingClientRect(),m=x.right-tt.left,C=R.left-tt.left,B=x.top+x.height/2-tt.top,M=R.top+R.height/2-tt.top;if(T&&H===e){var L=null!==(c=null===(r=a.current)||void 0===r?void 0:r.getBoundingClientRect().top)&&void 0!==c?c:0,I=null!==(l=null===(o=d.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,E=L+(null!==(v=null===(u=a.current)||void 0===u?void 0:u.clientHeight)&&void 0!==v?v:1/0),A=I+(null!==(h=null===(s=d.current)||void 0===s?void 0:s.clientHeight)&&void 0!==h?h:1/0),k=x.top+x.height/2,Y=R.top+R.height/2,w=function(t,e,n){return Math.max(e,Math.min(n,t))};B=w(k,L,E)-tt.top,M=w(Y,I,A)-tt.top}var O=D(e);O&&et.push({id:"line-".concat(e,"-").concat(g),x1:m,y1:B,x2:C,y2:M,style:O,sectionIdx:e,targetRightIdx:g})}}})});else{for(nt=0;nt<Math.min(g.length,f.length);nt++){var xt=null===(j=R.current[nt])||void 0===j?void 0:j.current,mt=null===(P=m.current[nt])||void 0===P?void 0:P.current;if(xt&&mt){var Ct=xt.getBoundingClientRect(),Bt=mt.getBoundingClientRect(),St=Math.max(Ct.top,Bt.top)+18-tt.top,bt=(null===(F=f[nt])||void 0===F?void 0:F.id)||"sec-".concat(nt);(Dt=D(nt))&&et.push({id:bt,x1:Ct.right-tt.left,y1:St,x2:Bt.left-tt.left,y2:St,style:Dt,sectionIdx:nt,hasCognitive:!!((null===(z=g[nt])||void 0===z?void 0:z.cognitiveData)||(null===(N=f[nt])||void 0===N?void 0:N.cognitiveData)||bt&&A[bt]),isSubSection:!1})}}Object.keys(C.current).forEach(function(t){var e,n,i,r,o,l;if(_(t)){var u=null===(e=C.current[t])||void 0===e?void 0:e.current,a=null===(n=B.current[t])||void 0===n?void 0:n.current;if(u&&a){for(var d=t.split("-").map(Number),v=g[d[0]],s=f[d[0]],h=1;h<d.length;h++)(null==v?void 0:v.subsections)&&(v=v.subsections[d[h]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[h]]);var p=!!v&&((null===(i=v.displayTitle)||void 0===i||i)&&c(v.title)),y=!!v&&((null===(r=v.displayContent)||void 0===r||r)&&c(v.content)),x=!!s&&((null===(o=s.displayTitle)||void 0===o||o)&&c(s.title)),R=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&c(s.content));if(p&&y||x&&R){var m=u.getBoundingClientRect(),S=a.getBoundingClientRect(),b=Math.max(m.top,S.top)+16-tt.top,M=k(t);M&&"Not Defined"!==M.label&&et.push({id:"subsec-".concat(t),x1:m.right-tt.left,y1:b,x2:S.left-tt.left,y2:b,style:M,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:!(!(null==v?void 0:v.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(T&&"string"==typeof H&&H.includes(r)){var Mt=H.split(r),Lt=Mt[0],It=Mt[1],Tt=Mt[2],Ht=(Mt[3],"".concat(Lt).concat(r).concat(It)),Et=null===(K=S.current[Ht])||void 0===K?void 0:K.current,At=null===(q=b.current[Ht])||void 0===q?void 0:q.current;if(Et&&At){var Dt,kt=Et.getBoundingClientRect(),Yt=At.getBoundingClientRect(),wt=kt.right-tt.left,Ot=Yt.left-tt.left,jt=kt.top+kt.height/2-tt.top,Pt=Yt.top+Yt.height/2-tt.top;if(E){var Ft=null!==(G=null===(V=a.current)||void 0===V?void 0:V.getBoundingClientRect().top)&&void 0!==G?G:0,zt=null!==(Q=null===(J=d.current)||void 0===J?void 0:J.getBoundingClientRect().top)&&void 0!==Q?Q:0,Nt=Ft+(null!==(W=null===(U=a.current)||void 0===U?void 0:U.clientHeight)&&void 0!==W?W:1/0),Kt=zt+(null!==(Z=null===(X=d.current)||void 0===X?void 0:X.clientHeight)&&void 0!==Z?Z:1/0),qt=function(t,e,n){return Math.max(e,Math.min(n,t))};jt=qt(kt.top+kt.height/2,Ft,Nt)-tt.top,Pt=qt(Yt.top+Yt.height/2,zt,Kt)-tt.top}(Dt=null!==($=Y(Lt,It))&&void 0!==$?$:k(Tt))&&et.push({id:"line-subsec-".concat(Ht),x1:wt,y1:jt,x2:Ot,y2:Pt,style:Dt,sectionIdx:Number(Tt.split("-")[0]),isSubSection:!0,subSectionKeyPath:H})}}if(it(et),s.current&&h.current){var Vt=s.current.getBoundingClientRect(),Gt=h.current.getBoundingClientRect(),Jt=(Vt.top+Vt.height/2-tt.top+Gt.top+Gt.height/2-tt.top)/2;ot({x1:Vt.right-tt.left,x2:Gt.left-tt.left,y:Jt})}else ot(null);if(I.size>0){var Qt=[],Ut=a.current,Wt=d.current;if(Ut&&Wt){var Xt=[],Zt=Ut.getBoundingClientRect().top,$t=Wt.getBoundingClientRect().top,_t=Zt+Ut.clientHeight,te=$t+Wt.clientHeight,ee=Ut.scrollTop,ne=Wt.scrollTop,ie=tt.top,re=function(t,e,n){return Math.max(e,Math.min(n,t))};I.forEach(function(t){var e,n,i,c,l,u;if("string"==typeof t&&t.includes(r)){var a=t.split(r),d=a[0],v=a[1],s=a[2],h=(a[3],"".concat(d).concat(r).concat(v)),p=null===(e=S.current[h])||void 0===e?void 0:e.current,y=null===(n=b.current[h])||void 0===n?void 0:n.current;if(!p||!y)return;var x=p.getBoundingClientRect(),R=y.getBoundingClientRect(),m=null!==(i=Y(d,v))&&void 0!==i?i:k(s),C=(q=x.right-tt.left)+.5*((V=R.left-tt.left-0)-q),B=x.top+x.height/2,M=R.top+R.height/2,L=B-Zt+ee,I=M-$t+ne,T="conn-subsec-".concat(h);Xt.push({lhsScrollY:L,rhsScrollY:I,x1:q,x2:V,containerTop:ie,leftIdx:t,rhsArrayIdx:t,styleColor:(null==m?void 0:m.badgeBorder)||"#6366F1",styleId:T});var H=re(B,Zt,_t),A=re(M,$t,te),w=H-ie,O=A-ie,j=M>=$t-4&&M<=te+4,P="";P=(G=B>=Zt-4&&B<=_t+4)&&j?o(q,w,V,O):G&&!j?"M ".concat(q,",").concat(w," L ").concat(C,",").concat(w," L ").concat(C,",").concat(O):!G&&j?"M ".concat(C,",").concat(w," L ").concat(C,",").concat(O," L ").concat(V,",").concat(O):"M ".concat(C,",").concat(w," L ").concat(C,",").concat(O),Qt.push({id:T,pathD:P,style:m,leftIdx:t,rhsArrayIdx:t})}else if(E){var F=t,z=g[F];if(!(null===(u=null==z?void 0:z.refIndexes)||void 0===u?void 0:u.length))return;z.refIndexes.forEach(function(t){var e,n,i=f.findIndex(function(e){return e.selfIndex===t});if(-1!==i){var r=null===(e=S.current[F])||void 0===e?void 0:e.current,c=null===(n=b.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),u=c.getBoundingClientRect(),a=D(F),d=l.right-tt.left,v=u.left-tt.left-0,s=d+.5*(v-d),h=l.top+l.height/2,g=u.top+u.height/2,p=h-Zt+ee,y=g-$t+ne,x="conn-".concat(F,"-").concat(i);Xt.push({lhsScrollY:p,rhsScrollY:y,x1:d,x2:v,containerTop:ie,leftIdx:F,rhsArrayIdx:i,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var R=re(h,Zt,_t),m=re(g,$t,te),C=R-ie,B=m-ie,M=h>=Zt-4&&h<=_t+4,L=g>=$t-4&&g<=te+4,I="";I=M&&L?o(d,C,v,B):M&&!L?"M ".concat(d,",").concat(C," L ").concat(s,",").concat(C," L ").concat(s,",").concat(B):!M&&L?"M ".concat(s,",").concat(C," L ").concat(s,",").concat(B," L ").concat(v,",").concat(B):"M ".concat(s,",").concat(C," L ").concat(s,",").concat(B),Qt.push({id:x,pathD:I,style:a,leftIdx:F,rhsArrayIdx:i})}}})}else{var N=t,K=N;p=null===(c=S.current[N])||void 0===c?void 0:c.current,y=null===(l=b.current[K])||void 0===l?void 0:l.current;if(!p||!y)return;var q,V;x=p.getBoundingClientRect(),R=y.getBoundingClientRect(),m=D(N),C=(q=x.right-tt.left)+.5*((V=R.left-tt.left-0)-q),B=x.top+x.height/2,M=R.top+R.height/2,L=B-Zt+ee,I=M-$t+ne,T="conn-".concat(N,"-").concat(K);Xt.push({lhsScrollY:L,rhsScrollY:I,x1:q,x2:V,containerTop:ie,leftIdx:N,rhsArrayIdx:K,styleColor:(null==m?void 0:m.badgeBorder)||"#6366F1",styleId:T});var G;H=re(B,Zt,_t),A=re(M,$t,te),w=H-ie,O=A-ie,j=M>=$t-4&&M<=te+4,P="";P=(G=B>=Zt-4&&B<=_t+4)&&j?o(q,w,V,O):G&&!j?"M ".concat(q,",").concat(w," L ").concat(C,",").concat(w," L ").concat(C,",").concat(O):!G&&j?"M ".concat(C,",").concat(w," L ").concat(C,",").concat(O," L ").concat(V,",").concat(O):"M ".concat(C,",").concat(w," L ").concat(C,",").concat(O),Qt.push({id:T,pathD:P,style:m,leftIdx:N,rhsArrayIdx:K})}}),Rt.current=Xt}vt(Qt)}else vt([]),Rt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{ft.current=!1}}},[p,g,f,A,_,tt,D,Y,E,T,H,I,M,L]),Ct=n(function(){var t,e,n,i,r,c,l,s,h,g,f,p,y,x,R=Rt.current;if(R.length&&!O.current){var m=null!==(e=null===(t=a.current)||void 0===t?void 0:t.scrollTop)&&void 0!==e?e:0,C=null!==(i=null===(n=d.current)||void 0===n?void 0:n.scrollTop)&&void 0!==i?i:0,B=null!==(c=null===(r=a.current)||void 0===r?void 0:r.clientHeight)&&void 0!==c?c:1/0,S=null!==(s=null===(l=d.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,b=null!==(g=null===(h=a.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==g?g:0,M=null!==(p=null===(f=d.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==p?p:0,L=b+B,I=M+S,T=null!==(x=null===(y=u.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,H=function(t,e,n){return Math.max(e,Math.min(n,t))};R.forEach(function(t){var e=t.lhsScrollY-m+b,n=t.rhsScrollY-C+M,i=v.current[t.styleId+"-stroke"],r=v.current[t.styleId+"-bg"];if(i||r){var c,l=H(e,b,L),u=H(n,M,I),a=l-T,d=u-T,s=e>=b-4&&e<=L+4,h=n>=M-4&&n<=I+4,g=t.x1+.5*(t.x2-t.x1);c=s&&h?o(t.x1,a,t.x2,d):s&&!h?"M ".concat(t.x1,",").concat(a," L ").concat(g,",").concat(a," L ").concat(g,",").concat(d):!s&&h?"M ".concat(g,",").concat(a," L ").concat(g,",").concat(d," L ").concat(t.x2,",").concat(d):"M ".concat(g,",").concat(a," L ").concat(g,",").concat(d),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",c)),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",c))}})}},[]),Bt=n(function(){Rt.current.length>0&&!O.current||(null!==yt.current&&clearTimeout(yt.current),yt.current=setTimeout(function(){V.current(),yt.current=null},50))},[]),St=n(function(t){if(null!==Z.current&&$.current&&Math.abs(t.currentTarget.scrollTop-Z.current)<=2){var e=$.current;Z.current=null,$.current=null,e()}J.current||(E||Bt(),pt.current||(pt.current=!0,requestAnimationFrame(function(){var t,e,n,i,c,o,l;if(j.current){var v=a.current,s=d.current;if(v&&s&&F.current){if(!P.current){var h=z.current,g=void 0;if("string"==typeof h&&h.includes(r)){var f=h.split(r),p="".concat(f[0]).concat(r).concat(f[1]);g=null===(t=S.current[p])||void 0===t?void 0:t.current}else g=null===(e=S.current[h])||void 0===e?void 0:e.current;if(g){var y=g.getBoundingClientRect();P.current={badgeScreenY:y.top+y.height/2,initialScrollTop:v.scrollTop,leftTop:v.getBoundingClientRect().top,leftBottom:v.getBoundingClientRect().top+v.clientHeight,cTop:null!==(i=null===(n=u.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(P.current){var x=P.current,R=v.scrollTop-x.initialScrollTop,m=x.badgeScreenY-R,C=((c=m,o=x.leftTop,l=x.leftBottom,Math.max(o,Math.min(l,c)))-x.cTop).toString(),B=m>=x.leftTop-4&&m<=x.leftBottom+4;F.current.setAttribute("y1",C),F.current.setAttribute("y2",C),F.current.setAttribute("visibility",B?"visible":"hidden")}}}Rt.current.length>0&&Ct(),pt.current=!1})))},[Ct,E,Bt]);return i(function(){V.current=mt},[mt]),i(function(){var t=setTimeout(Bt,250),e=function(){return Q.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==yt.current&&clearTimeout(yt.current),null!==G.current&&clearTimeout(G.current),window.removeEventListener("resize",e)}},[U,W,X,p,M,L,g,f,_,Bt,T,H,w,I]),{lines:nt,setLines:it,overallConnector:ct,setOverallConnector:ot,connectedLines:dt,setConnectedLines:vt,svgDimensions:ht,cachedConnectedPositions:Rt,calculateLines:mt,calculateLinesRef:V,calculateLinesDebounced:Bt,handleColumnScroll:St}};export{l as useLinesCalculator};
|
|
1
|
+
import{useState as t,useRef as e,useCallback as n,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,hasValue as c,getBentArrowPath as o}from"../CognitiveComparehelpers.js";var l=function(l){var u=l.containerRef,a=l.leftContainerRef,d=l.rightContainerRef;l.svgContainerRef;var v=l.pathRefs,s=l.leftHeaderRef,h=l.rightHeaderRef,g=l.proposedSections,f=l.existingSections,p=l.visibleFields,x=l.leftRefs,y=l.rightRefs,m=l.sectionLeftRefs,R=l.sectionRightRefs,C=l.subSectionLeftRefs,B=l.subSectionRightRefs,b=l.lhsBadgeRefs,S=l.rhsBadgeRefs,M=l.sectionRowRefs,L=l.expandedSections,T=l.expandedSubSections,I=l.connectedSections,H=l.isSideBySide,A=l.activeSideBySideSection,E=l.maintainRelativeOrder,D=l.cognitiveMap,k=l.getSectionCompareStyle,Y=l.getSubSectionCompareStyle,w=l.getDeviationStyleByKey,N=l.isArrowVisible,O=l.isAnimatingRef,j=l.isSideBySideRef,F=l.sideBySideCacheRef,P=l.sideBySideLineRef,z=l.activeSideBySideSectionRef,K=l.activeSideBySideRightSectionRef,q=l.connectedLines,V=l.setConnectedLines,G=l.cachedConnectedPositions,J=l.calculateLinesRef,Q=l.resizeTimerRef,U=l.scrollLock,W=l.scrollSyncLocked,X=l.handleResizeRef,Z=l.activeProposed,$=l.existingRule,_=l.analysisData,tt=l.pendingScrollTargetRef,et=l.pendingScrollCallbackRef,nt=l.resolvedComparisonConfig,rt=l.getFieldData,it=t([]),ct=it[0],ot=it[1],lt=t(null),ut=lt[0],at=lt[1],dt=t([]),vt=dt[0],st=dt[1],ht=null!=q?q:vt,gt=null!=V?V:st,ft=t({width:0,height:0}),pt=ft[0],xt=ft[1],yt=e(!1),mt=e(!1),Rt=e(!1),Ct=e(null),Bt=e([]),bt=null!=G?G:Bt,St=n(function(){var t,e,n,r,l,v,M,N,j,F,P,z,K,q,V,G,J,Q,U,W,X,Z,$;if(!yt.current&&!O.current){yt.current=!0;try{if(!u.current)return;var _=function(t){var e=t.split("-"),n=e[0];if(!L[n]&&!1===E)return!1;if(E&&!L["left-".concat(n)]&&!L["right-".concat(n)]&&!L[n])return!1;for(var r=n,i=1;i<e.length-1;i++)if(r+="-".concat(e[i]),!T[r])return!1;return!0},tt=u.current.getBoundingClientRect();xt({width:tt.width,height:tt.height});var et=[];if(p.forEach(function(t){var e,n,r=t.key,i=null===(e=x.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;i&&c&&(i.style.height="auto",c.style.height="auto",i.style.minHeight="0px",c.style.minHeight="0px")}),!O.current){for(var nt=0;nt<Math.max(g.length,f.length);nt++){var rt=null===(t=m.current[nt])||void 0===t?void 0:t.current,it=null===(e=R.current[nt])||void 0===e?void 0:e.current;rt&&(rt.style.height="auto",rt.style.minHeight="0px"),it&&(it.style.height="auto",it.style.minHeight="0px")}E||Object.keys(C.current).forEach(function(t){var e,n;if(_(t)){var r=null===(e=C.current[t])||void 0===e?void 0:e.current,i=null===(n=B.current[t])||void 0===n?void 0:n.current;r&&i&&(r.style.height="auto",i.style.height="auto",r.style.minHeight="0px",i.style.minHeight="0px")}})}var ct={};p.forEach(function(t){var e,n,r=t.key,i=null===(e=x.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=i.getBoundingClientRect(),l=c.getBoundingClientRect();ct[r]=Math.max(o.height,l.height)}});var lt={left:{},right:{}},ut={};if(!O.current)if(E){if(H&&null!==A)if("number"==typeof A){var dt=A,vt=g[dt],st=null===(l=m.current[dt])||void 0===l?void 0:l.current;st&&vt&&(vt.refIndexes||[]).forEach(function(t){var e,n=f.findIndex(function(e){return e.selfIndex===t}),r=null===(e=R.current[n])||void 0===e?void 0:e.current;if(r&&(L["left-".concat(dt)]||L["right-".concat(n)])){var i=Math.max(st.getBoundingClientRect().height,r.getBoundingClientRect().height);lt.left[dt]=Math.max(lt.left[dt]||0,i),lt.right[n]=Math.max(lt.right[n]||0,i)}})}else{var ht=A.split(i)[2];if(ht){rt=null===(v=C.current[ht])||void 0===v?void 0:v.current,it=null===(M=B.current[ht])||void 0===M?void 0:M.current;if(rt&&it){ft=Math.max(rt.getBoundingClientRect().height,it.getBoundingClientRect().height);ut[ht]=Math.max(ut[ht]||0,ft)}}}}else{Object.keys(C.current).forEach(function(t){var e,n;if(_(t)){var r=null===(e=C.current[t])||void 0===e?void 0:e.current,i=null===(n=B.current[t])||void 0===n?void 0:n.current;if(r&&i&&null!==r.offsetParent&&null!==i.offsetParent){var c=r.getBoundingClientRect(),o=i.getBoundingClientRect(),l=Math.max(c.height,o.height);ut[t]=l,r.style.minHeight="".concat(l,"px"),i.style.minHeight="".concat(l,"px")}}});for(nt=0;nt<Math.min(g.length,f.length);nt++){var rt=null===(n=m.current[nt])||void 0===n?void 0:n.current,it=null===(r=R.current[nt])||void 0===r?void 0:r.current;if(rt&&it){var ft=Math.max(rt.getBoundingClientRect().height,it.getBoundingClientRect().height);lt.left[nt]=ft,lt.right[nt]=ft}}}if(p.forEach(function(t){var e,n,r=t.key,i=null===(e=x.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=ct[r];i.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),O.current||(Object.entries(lt.left).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=m.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),Object.entries(lt.right).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=R.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),E||Object.keys(ut).forEach(function(t){var e,n,r=null===(e=C.current[t])||void 0===e?void 0:e.current,i=null===(n=B.current[t])||void 0===n?void 0:n.current;if(r&&i&&ut[t]){var c=ut[t];r.style.minHeight="".concat(c,"px"),i.style.minHeight="".concat(c,"px")}})),E)g.forEach(function(t,e){var n;(null===(n=m.current[e])||void 0===n?void 0:n.current)&&(t.refIndexes||[]).forEach(function(t){var n,r,i,c,o,l,u,v,s,h,g=f.findIndex(function(e){return e.selfIndex===t});if(-1!==g){var p=null===(n=b.current[e])||void 0===n?void 0:n.current,x=null===(r=S.current[g])||void 0===r?void 0:r.current;if(p&&x){var y=p.getBoundingClientRect(),m=x.getBoundingClientRect(),R=y.right-tt.left,C=m.left-tt.left,B=y.top+y.height/2-tt.top,M=m.top+m.height/2-tt.top;if(H&&A===e){var L=null!==(c=null===(i=a.current)||void 0===i?void 0:i.getBoundingClientRect().top)&&void 0!==c?c:0,T=null!==(l=null===(o=d.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==l?l:0,I=L+(null!==(v=null===(u=a.current)||void 0===u?void 0:u.clientHeight)&&void 0!==v?v:1/0),E=T+(null!==(h=null===(s=d.current)||void 0===s?void 0:s.clientHeight)&&void 0!==h?h:1/0),D=y.top+y.height/2,Y=m.top+m.height/2,w=function(t,e,n){return Math.max(e,Math.min(n,t))};B=w(D,L,I)-tt.top,M=w(Y,T,E)-tt.top}var N=k(e);N&&et.push({id:"line-".concat(e,"-").concat(g),x1:R,y1:B,x2:C,y2:M,style:N,sectionIdx:e,targetRightIdx:g})}}})});else{for(nt=0;nt<Math.min(g.length,f.length);nt++){var pt=null===(N=m.current[nt])||void 0===N?void 0:N.current,mt=null===(j=R.current[nt])||void 0===j?void 0:j.current;if(pt&&mt){var Rt=pt.getBoundingClientRect(),Ct=mt.getBoundingClientRect(),Bt=Math.max(Rt.top,Ct.top)+18-tt.top,St=(null===(F=f[nt])||void 0===F?void 0:F.id)||"sec-".concat(nt);(Dt=k(nt))&&et.push({id:St,x1:Rt.right-tt.left,y1:Bt,x2:Ct.left-tt.left,y2:Bt,style:Dt,sectionIdx:nt,hasCognitive:!!((null===(P=g[nt])||void 0===P?void 0:P.cognitiveData)||(null===(z=f[nt])||void 0===z?void 0:z.cognitiveData)||St&&D[St]),isSubSection:!1})}}Object.keys(C.current).forEach(function(t){var e,n,r,i,o,l;if(_(t)){var u=null===(e=C.current[t])||void 0===e?void 0:e.current,a=null===(n=B.current[t])||void 0===n?void 0:n.current;if(u&&a){for(var d=t.split("-").map(Number),v=g[d[0]],s=f[d[0]],h=1;h<d.length;h++)(null==v?void 0:v.subsections)&&(v=v.subsections[d[h]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[h]]);var p=!!v&&((null===(r=v.displayTitle)||void 0===r||r)&&c(v.title)),x=!!v&&((null===(i=v.displayContent)||void 0===i||i)&&c(v.content)),y=!!s&&((null===(o=s.displayTitle)||void 0===o||o)&&c(s.title)),m=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&c(s.content));if(p&&x||y&&m){var R=u.getBoundingClientRect(),b=a.getBoundingClientRect(),S=Math.max(R.top,b.top)+16-tt.top,M=Y(t);M&&"Not Defined"!==M.label&&et.push({id:"subsec-".concat(t),x1:R.right-tt.left,y1:S,x2:b.left-tt.left,y2:S,style:M,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:t,hasCognitive:!(!(null==v?void 0:v.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(H&&"string"==typeof A&&A.includes(i)){var Mt=A.split(i),Lt=Mt[0],Tt=Mt[1],It=Mt[2],Ht=(Mt[3],"".concat(Lt).concat(i).concat(Tt)),At=null===(K=b.current[Ht])||void 0===K?void 0:K.current,Et=null===(q=S.current[Ht])||void 0===q?void 0:q.current;if(At&&Et){var Dt,kt=At.getBoundingClientRect(),Yt=Et.getBoundingClientRect(),wt=kt.right-tt.left,Nt=Yt.left-tt.left,Ot=kt.top+kt.height/2-tt.top,jt=Yt.top+Yt.height/2-tt.top;if(E){var Ft=null!==(G=null===(V=a.current)||void 0===V?void 0:V.getBoundingClientRect().top)&&void 0!==G?G:0,Pt=null!==(Q=null===(J=d.current)||void 0===J?void 0:J.getBoundingClientRect().top)&&void 0!==Q?Q:0,zt=Ft+(null!==(W=null===(U=a.current)||void 0===U?void 0:U.clientHeight)&&void 0!==W?W:1/0),Kt=Pt+(null!==(Z=null===(X=d.current)||void 0===X?void 0:X.clientHeight)&&void 0!==Z?Z:1/0),qt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ot=qt(kt.top+kt.height/2,Ft,zt)-tt.top,jt=qt(Yt.top+Yt.height/2,Pt,Kt)-tt.top}(Dt=null!==($=w(Lt,Tt))&&void 0!==$?$:Y(It))&&et.push({id:"line-subsec-".concat(Ht),x1:wt,y1:Ot,x2:Nt,y2:jt,style:Dt,sectionIdx:Number(It.split("-")[0]),isSubSection:!0,subSectionKeyPath:A})}}if(ot(et),s.current&&h.current){var Vt=s.current.getBoundingClientRect(),Gt=h.current.getBoundingClientRect(),Jt=(Vt.top+Vt.height/2-tt.top+Gt.top+Gt.height/2-tt.top)/2;at({x1:Vt.right-tt.left,x2:Gt.left-tt.left,y:Jt})}else at(null);if(I.size>0){var Qt=[],Ut=a.current,Wt=d.current;if(Ut&&Wt){var Xt=[],Zt=Ut.getBoundingClientRect().top,$t=Wt.getBoundingClientRect().top,_t=Zt+Ut.clientHeight,te=$t+Wt.clientHeight,ee=Ut.scrollTop,ne=Wt.scrollTop,re=tt.top,ie=function(t,e,n){return Math.max(e,Math.min(n,t))};I.forEach(function(t){var e,n,r,c,l,u;if("string"==typeof t&&t.includes(i)){var a=t.split(i),d=a[0],v=a[1],s=a[2],h=(a[3],"".concat(d).concat(i).concat(v)),p=null===(e=b.current[h])||void 0===e?void 0:e.current,x=null===(n=S.current[h])||void 0===n?void 0:n.current;if(!p||!x)return;var y=p.getBoundingClientRect(),m=x.getBoundingClientRect(),R=null!==(r=w(d,v))&&void 0!==r?r:Y(s),C=(q=y.right-tt.left)+.5*((V=m.left-tt.left-0)-q),B=y.top+y.height/2,M=m.top+m.height/2,L=B-Zt+ee,T=M-$t+ne,I="conn-subsec-".concat(h);Xt.push({lhsScrollY:L,rhsScrollY:T,x1:q,x2:V,containerTop:re,leftIdx:t,rhsArrayIdx:t,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:I});var H=ie(B,Zt,_t),A=ie(M,$t,te),D=H-re,N=A-re,O=M>=$t-4&&M<=te+4,j="";j=(G=B>=Zt-4&&B<=_t+4)&&O?o(q,D,V,N):G&&!O?"M ".concat(q,",").concat(D," L ").concat(C,",").concat(D," L ").concat(C,",").concat(N):!G&&O?"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N," L ").concat(V,",").concat(N):"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N),Qt.push({id:I,pathD:j,style:R,leftIdx:t,rhsArrayIdx:t})}else if(E){var F=t,P=g[F];if(!(null===(u=null==P?void 0:P.refIndexes)||void 0===u?void 0:u.length))return;P.refIndexes.forEach(function(t){var e,n,r=f.findIndex(function(e){return e.selfIndex===t});if(-1!==r){var i=null===(e=b.current[F])||void 0===e?void 0:e.current,c=null===(n=S.current[r])||void 0===n?void 0:n.current;if(i&&c){var l=i.getBoundingClientRect(),u=c.getBoundingClientRect(),a=k(F),d=l.right-tt.left,v=u.left-tt.left-0,s=d+.5*(v-d),h=l.top+l.height/2,g=u.top+u.height/2,p=h-Zt+ee,x=g-$t+ne,y="conn-".concat(F,"-").concat(r);Xt.push({lhsScrollY:p,rhsScrollY:x,x1:d,x2:v,containerTop:re,leftIdx:F,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:y});var m=ie(h,Zt,_t),R=ie(g,$t,te),C=m-re,B=R-re,M=h>=Zt-4&&h<=_t+4,L=g>=$t-4&&g<=te+4,T="";T=M&&L?o(d,C,v,B):M&&!L?"M ".concat(d,",").concat(C," L ").concat(s,",").concat(C," L ").concat(s,",").concat(B):!M&&L?"M ".concat(s,",").concat(C," L ").concat(s,",").concat(B," L ").concat(v,",").concat(B):"M ".concat(s,",").concat(C," L ").concat(s,",").concat(B),Qt.push({id:y,pathD:T,style:a,leftIdx:F,rhsArrayIdx:r})}}})}else{var z=t,K=z;p=null===(c=b.current[z])||void 0===c?void 0:c.current,x=null===(l=S.current[K])||void 0===l?void 0:l.current;if(!p||!x)return;var q,V;y=p.getBoundingClientRect(),m=x.getBoundingClientRect(),R=k(z),C=(q=y.right-tt.left)+.5*((V=m.left-tt.left-0)-q),B=y.top+y.height/2,M=m.top+m.height/2,L=B-Zt+ee,T=M-$t+ne,I="conn-".concat(z,"-").concat(K);Xt.push({lhsScrollY:L,rhsScrollY:T,x1:q,x2:V,containerTop:re,leftIdx:z,rhsArrayIdx:K,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:I});var G;H=ie(B,Zt,_t),A=ie(M,$t,te),D=H-re,N=A-re,O=M>=$t-4&&M<=te+4,j="";j=(G=B>=Zt-4&&B<=_t+4)&&O?o(q,D,V,N):G&&!O?"M ".concat(q,",").concat(D," L ").concat(C,",").concat(D," L ").concat(C,",").concat(N):!G&&O?"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N," L ").concat(V,",").concat(N):"M ".concat(C,",").concat(D," L ").concat(C,",").concat(N),Qt.push({id:I,pathD:j,style:R,leftIdx:z,rhsArrayIdx:K})}}),bt.current=Xt}gt(Qt)}else gt([]),bt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{yt.current=!1}}},[p,g,f,D,nt,rt,k,w,E,H,A,I,L,T]),Mt=n(function(){var t,e,n,r,i,c,l,s,h,g,f,p,x,y,m=bt.current;if(m.length&&!O.current){var R=null!==(e=null===(t=a.current)||void 0===t?void 0:t.scrollTop)&&void 0!==e?e:0,C=null!==(r=null===(n=d.current)||void 0===n?void 0:n.scrollTop)&&void 0!==r?r:0,B=null!==(c=null===(i=a.current)||void 0===i?void 0:i.clientHeight)&&void 0!==c?c:1/0,b=null!==(s=null===(l=d.current)||void 0===l?void 0:l.clientHeight)&&void 0!==s?s:1/0,S=null!==(g=null===(h=a.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==g?g:0,M=null!==(p=null===(f=d.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==p?p:0,L=S+B,T=M+b,I=null!==(y=null===(x=u.current)||void 0===x?void 0:x.getBoundingClientRect().top)&&void 0!==y?y:0,H=function(t,e,n){return Math.max(e,Math.min(n,t))};m.forEach(function(t){var e=t.lhsScrollY-R+S,n=t.rhsScrollY-C+M,r=v.current[t.styleId+"-stroke"],i=v.current[t.styleId+"-bg"];if(r||i){var c,l=H(e,S,L),u=H(n,M,T),a=l-I,d=u-I,s=e>=S-4&&e<=L+4,h=n>=M-4&&n<=T+4,g=t.x1+.5*(t.x2-t.x1);c=s&&h?o(t.x1,a,t.x2,d):s&&!h?"M ".concat(t.x1,",").concat(a," L ").concat(g,",").concat(a," L ").concat(g,",").concat(d):!s&&h?"M ".concat(g,",").concat(a," L ").concat(g,",").concat(d," L ").concat(t.x2,",").concat(d):"M ".concat(g,",").concat(a," L ").concat(g,",").concat(d),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",c)),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",c))}})}},[]),Lt=n(function(){bt.current.length>0&&!O.current||(null!==Ct.current&&clearTimeout(Ct.current),Ct.current=setTimeout(function(){J.current(),Ct.current=null},50))},[]),Tt=n(function(t){if(null!==tt.current&&et.current&&Math.abs(t.currentTarget.scrollTop-tt.current)<=2){var e=et.current;tt.current=null,et.current=null,e()}if(!Rt.current&&!U.current){if(E&&W&&(j.current||I.size>0)){var n=t.currentTarget,r=a.current,c=d.current,o=n===r?c:n===c?r:null;if(n&&o){var l=function(){var t,e,n,r,c,o,l,u,a,d,v,s=z.current,h=K.current;if(null===s)return{leftAnchor:null,rightAnchor:null};if("string"==typeof s&&s.includes(i)){var g=s.split(i),f="".concat(g[0]).concat(i).concat(g[1]);return{leftAnchor:(null===(t=b.current[f])||void 0===t?void 0:t.current)||(null===(e=C.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=m.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(r=S.current[f])||void 0===r?void 0:r.current)||(null===(c=B.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=R.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(s),x=null!==h?Number(h):p;return{leftAnchor:(null===(l=b.current[p])||void 0===l?void 0:l.current)||(null===(u=M.current[p])||void 0===u?void 0:u.current)||(null===(a=m.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=S.current[x])||void 0===d?void 0:d.current)||(null===(v=R.current[x])||void 0===v?void 0:v.current)||null}}(),v=l.leftAnchor,s=l.rightAnchor,h=n===r?v:s,g=n===r?s:v,f=null;if(h&&g){var p=h.getBoundingClientRect(),x=g.getBoundingClientRect(),y=o.getBoundingClientRect(),L=p.top+p.height/2;f=x.top-y.top+o.scrollTop+x.height/2-(L-y.top)}else{var T=Math.max(0,n.scrollHeight-n.clientHeight),H=Math.max(0,o.scrollHeight-o.clientHeight);f=T>0?n.scrollTop/T*H:n.scrollTop}var A=Math.max(0,o.scrollHeight-o.clientHeight);f=Math.max(0,Math.min(f,A)),Math.abs(o.scrollTop-f)>1&&(Rt.current=!0,o.scrollTop=f,requestAnimationFrame(function(){Rt.current=!1}))}}E||Lt(),mt.current||(mt.current=!0,requestAnimationFrame(function(){var t,e,n,r,c,o,l;if(j.current){var v=a.current,s=d.current;if(v&&s&&P.current){if(!F.current){var h=z.current,g=void 0;if("string"==typeof h&&h.includes(i)){var f=h.split(i),p="".concat(f[0]).concat(i).concat(f[1]);g=null===(t=b.current[p])||void 0===t?void 0:t.current}else g=null===(e=b.current[h])||void 0===e?void 0:e.current;if(g){var x=g.getBoundingClientRect();F.current={badgeScreenY:x.top+x.height/2,initialScrollTop:v.scrollTop,leftTop:v.getBoundingClientRect().top,leftBottom:v.getBoundingClientRect().top+v.clientHeight,cTop:null!==(r=null===(n=u.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==r?r:0}}}if(F.current){var y=F.current,m=v.scrollTop-y.initialScrollTop,R=y.badgeScreenY-m,C=((c=R,o=y.leftTop,l=y.leftBottom,Math.max(o,Math.min(l,c)))-y.cTop).toString(),B=R>=y.leftTop-4&&R<=y.leftBottom+4;P.current.setAttribute("y1",C),P.current.setAttribute("y2",C),P.current.setAttribute("visibility",B?"visible":"hidden")}}}bt.current.length>0&&Mt(),mt.current=!1}))}},[Mt,E,W,I,Lt]);return r(function(){J.current=St},[St]),r(function(){var t=setTimeout(Lt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==Ct.current&&clearTimeout(Ct.current),null!==Q.current&&clearTimeout(Q.current),window.removeEventListener("resize",e)}},[Z,$,_,p,L,T,g,f,nt,Lt,H,A,N,I]),{lines:ct,setLines:ot,overallConnector:ut,setOverallConnector:at,connectedLines:ht,setConnectedLines:gt,svgDimensions:pt,cachedConnectedPositions:bt,calculateLines:St,calculateLinesRef:J,calculateLinesDebounced:Lt,handleColumnScroll:Tt}};export{l as useLinesCalculator};
|
|
2
2
|
//# sourceMappingURL=useLinesCalculator.js.map
|