@viswa-test/test-citation 0.0.212 → 0.0.214
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/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
- package/dist/types/src/CommonConstants/CommonConstants.d.ts +2916 -2068
- 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/CompareContext.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
- 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/useCompareData.d.ts +6 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts +1 -1
- package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as n}from"tslib";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as c}from"react";import{Box as a,Snackbar as s,Alert as d,Tooltip as v,Typography as f}from"@mui/material";import{ChevronDown as p}from"lucide-react";import{ButtonCognitiveIcon as g}from"../../assests/svg/ButtonCognitiveIcon.js";import h from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as S,generateColorPalette as x,findKeyPathByNodeId as R,DEVIATION_BADGE_SEPARATOR as y,hasMeaningfulRedlineTags as b,scrollAndHighlightClause as C}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as w,DEFAULT_FIELD_CONFIG as B,DEFAULT_COMPARISON_CONFIG as _}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as E,EMPTY_SUMMARY_POPUP_STATE as F,DEFAULT_COMPONENT_HEADER_TEXT as I}from"./CognitiveCompareConstants.js";import T from"./CognitivePopup.js";import A from"./MoreFunctionsPopup.js";import D from"./LoaderComponent.js";import O from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as k}from"./hooks/useCompareData.js";import{useComparePopups as L}from"./hooks/useComparePopups.js";import{useSectionRefs as j}from"./hooks/useSectionRefs.js";import{useAccordionState as P}from"./hooks/useAccordionState.js";import{useDeviationNavigation as N}from"./hooks/useDeviationNavigation.js";import H from"./components/CompareHeader.js";import z from"./components/SubSectionAccordion.js";import M from"./components/LHSSectionRow.js";import q from"./components/RHSSectionRow.js";import W from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as V}from"./CompareContext.js";import{useStyleHelpers as K}from"./hooks/useStyles.js";import{useResizeHandler as J}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Y}from"./hooks/useLinesCalculator.js";import{useSideBySide as X}from"./hooks/useSideBySide.js";import $ from"./components/SvgConnectors.js";var U=function(U){var G,Q,Z,ee,ne,ie,te,oe,re,le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,ye,be,Ce,we,Be,_e,Ee,Fe,Ie,Te,Ae,De=U.componentHeaderText,Oe=void 0===De?I:De,ke=U.treeData,Le=U.comparisonConfig,je=U.leftColumnTitleText,Pe=U.rightColumnTitleText,Ne=U.markdownStyles,He=U.resetTrigger,ze=U.displayConfig,Me=void 0===ze?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0}:ze,qe=U.onMaintainRelativeOrderChange,We=U.popupConfig,Ve=U.deviationData,Ke=void 0===Ve?{}:Ve,Je=U.deviationNodeIdToView,Ye=U.resetDeviationNodeId,Xe=U.isProposingFix,$e=void 0!==Xe&&Xe,Ue=U.proposingFixNodeId,Ge=U.isRedlineFlow,Qe=o(Me.maintainRelativeOrder),Ze=Qe[0],en=Qe[1],nn=null!==(G=null==Me?void 0:Me.expandLevels)&&void 0!==G?G:0,tn=!!(null==Me?void 0:Me.expandAllSections),on=!!Ze||!!(null==Me?void 0:Me.showDeviationBadges),rn=o(!1),ln=rn[0],un=rn[1],cn=o(null),an=cn[0],sn=cn[1],dn=o(null===(Z=null!==(Q=null==ke?void 0:ke.newEvaluationResult)&&void 0!==Q?Q:null==Me?void 0:Me.enableDeviationSchemaBackwardCompatibility)||void 0===Z||Z)[0],vn=o(new Set),fn=vn[0],pn=vn[1],gn=o([]),hn=gn[0],mn=gn[1],Sn=o(!1),xn=Sn[0],Rn=Sn[1],yn=r(null),bn=r(null),Cn=r(null),wn=r(null),Bn=r(null),_n=r(!1),En=r(null),Fn=r({}),In=r([]),Tn=r(function(){}),An=r(null),Dn=r(function(){}),On=l(function(){return JSON.stringify(Ke||{})},[JSON.stringify(Ke)]),kn=l(function(){return Ke||{}},[On]),Ln=l(function(){return(null==ke?void 0:ke.cognitive_decisioning)||{}},[ke]),jn=l(function(){return e(e({},w),Ne)},[Ne]),Pn=r(null),Nn=r(null),Hn=r(null),zn=r(null),Mn=r(null),qn=r(null),Wn=r(null),Vn=r(null),Kn=r(null),Jn=r(null),Yn=L(Pn),Xn=Yn.cognitivePopup,$n=Yn.setCognitivePopup,Un=Yn.moreFunctions,Gn=Yn.setMoreFunctions,Qn=Yn.position,Zn=Yn.setPosition,ei=Yn.activeBadgeId,ni=Yn.summaryPopup,ii=Yn.setSummaryPopup,ti=Yn.closeSummaryPopup,oi=Yn.setActiveBadgeId,ri=Yn.popupRef,li=Yn.handleOpenCognitiveCompare,ui=Yn.openCognitivePopupFromState,ci=Yn.closeCognitivePopup,ai=Yn.closeMoreFunctionsPopup,si=l(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==Le?void 0:Le.fields)&&void 0!==e?e:B,thresholds:{high:null!==(i=null===(n=null==Le?void 0:Le.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:_.thresholds.high,medium:null!==(o=null===(t=null==Le?void 0:Le.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:_.thresholds.medium,exact:null!==(l=null===(r=null==Le?void 0:Le.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:_.thresholds.exact}}},[Le]),di=o(null),vi=di[0];di[1];var fi=null===(ie=null===(ee=null==ke?void 0:ke.documents)||void 0===ee?void 0:ee[null===(ne=null==ke?void 0:ke.input_index_map)||void 0===ne?void 0:ne[0]])||void 0===ie?void 0:ie.title,pi=null===(re=null===(te=null==ke?void 0:ke.documents)||void 0===te?void 0:te[null===(oe=null==ke?void 0:ke.input_index_map)||void 0===oe?void 0:oe[1]])||void 0===re?void 0:re.title,gi=m(je||fi||"Uploaded Contract"),hi=null===(ae=null===(ce=null===(le=null==ke?void 0:ke.documents)||void 0===le?void 0:le[null===(ue=null==ke?void 0:ke.input_index_map)||void 0===ue?void 0:ue[0]])||void 0===ce?void 0:ce.metadata)||void 0===ae?void 0:ae.file_name,mi=m(hi),Si=null===(fe=null===(ve=null===(se=null==ke?void 0:ke.documents)||void 0===se?void 0:se[null===(de=null==ke?void 0:ke.input_index_map)||void 0===de?void 0:de[1]])||void 0===ve?void 0:ve.metadata)||void 0===fe?void 0:fe.file_name,xi=m(Si),Ri=m(Pe||pi||"Reference Template"),yi=k(ke,Ze,kn,si,dn),bi=yi.activeProposed,Ci=yi.existingRule,wi=yi.proposedSections,Bi=yi.existingSections,_i=yi.visibleFields,Ei=yi.parentDeviationRecord,Fi=yi.deviationNumberRegistry,Ii=yi.parseError;u(function(){Ii&&sn("Failed to load comparison: ".concat(Ii))},[Ii]);var Ti=wi.length>0||Bi.length>0,Ai=l(function(){if(!Ge)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";b(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(wi),i(Bi),"".concat(e,":").concat(n)},[Ge,wi,Bi]);u(function(){if(wi.length||Bi.length)if(tn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Ze?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(wi,"left"),i(Bi,"right"),vt(e),pt(n)}else if(nn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=Ze?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(wi,"left",nn),r(Bi,"right",nn),vt(t),pt(o)}},[tn,nn,wi,Bi,Ze]);var Di=j(_i.map(function(e){return e.key}),Math.max(wi.length,Bi.length)),Oi=Di.leftRefs,ki=Di.rightRefs,Li=Di.sectionLeftRefs,ji=Di.sectionRightRefs,Pi=Di.lhsBadgeRefs,Ni=Di.rhsBadgeRefs,Hi=Di.sectionRightRowRefs,zi=Di.subSectionLeftRefs,Mi=Di.subSectionRightRefs,qi=Di.sectionRowRefs,Wi=Di.getSectionRowRef,Vi=Di.getSubSectionRef,Ki=Di.getBadgeRef,Ji=X({maintainRelativeOrder:Ze,proposedSections:wi,existingSections:Bi,leftContainerRef:Vn,rightContainerRef:Hn,scrollContainerRef:Pn,sectionLeftRefs:Li,sectionRightRefs:ji,subSectionLeftRefs:zi,subSectionRightRefs:Mi,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni,sectionRowRefs:qi,sectionRightRowRefs:Hi,rhsTopSpacerRef:zn,rhsBottomSpacerRef:Mn,lhsTopSpacerRef:qn,lhsBottomSpacerRef:Wn,calculateLinesRef:Tn,setConnectedSections:pn,setConnectedLines:mn,cachedConnectedPositions:In,closeMoreFunctionsPopup:ai,setErrorToast:sn,moreFunctions:Un,closeSummaryPopup:ti}),Yi=Ji.isSideBySide,Xi=Ji.isArrowVisible,$i=Ji.setIsArrowVisible,Ui=Ji.isResizing,Gi=Ji.setIsResizing,Qi=Ji.isSideBySideLoading,Zi=Ji.activeSideBySideSection,et=Ji.scrollLock,nt=Ji.sideBySideCacheRef,it=Ji.isSideBySideRef,tt=Ji.activeSideBySideRightSectionRef,ot=Ji.activeSideBySideSectionRef,rt=Ji.sideBySideLineRef,lt=Ji.highlightedClauseRefs,ut=Ji.clearClauseHighlight,ct=Ji.resetSideBySide,at=Ji.activateSideBySide,st=P({maintainRelativeOrder:!!Ze,proposedSections:wi,existingSections:Bi,activeSideBySideSection:Zi,connectedSections:fn,resetSideBySide:ct,setConnectedSections:pn,setConnectedLines:mn,cachedConnectedPositions:In,svgContainerRef:yn,isAnimatingRef:_n,animationTimerRef:En,calculateLinesRef:Tn,sectionLeftRefs:Li,sectionRightRefs:ji,subSectionLeftRefs:zi,subSectionRightRefs:Mi}),dt=st.expandedSections,vt=st.setExpandedSections,ft=st.expandedSubSections,pt=st.setExpandedSubSections,gt=st.handleSubSectionToggle,ht=st.toggleSection,mt=st.forceExpandCrossWiredSections,St=function(){var e,n;if(null!=Zi){var i=null===(e=Li.current[Zi])||void 0===e?void 0:e.current,t=null===(n=ji.current[Zi])||void 0===n?void 0:n.current,o=Hn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},xt=c(function(e){null==e||e.stopPropagation(),Rn(function(e){var n=!e;return n&&requestAnimationFrame(function(){St()}),n})},[St]);u(function(){Ge&&"off"!==Ai&&"0:0"!==Ai&&(nt.current=null,In.current=[],requestAnimationFrame(function(){var e;null===(e=Tn.current)||void 0===e||e.call(Tn)}))},[Ge,Ai]);var Rt=l(function(){var e=new Map,n=new Map,i=1;if(Ze)wi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Bi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=wi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(wi.length,Bi.length),o=0;o<t;o++){var r=wi[o],l=Bi[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[wi,Bi,Ze]),yt=Ci.analysis,bt=m(null===(ge=null===(pe=null==yt?void 0:yt.rule_difference_comparison)||void 0===pe?void 0:pe.summary)||void 0===ge?void 0:ge.overall_summary),Ct=!!bt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),wt=null!==(he=null==ke?void 0:ke.base_root_id)&&void 0!==he?he:"-1";null==ke||ke[wt];var Bt=dn?null!==(Fe=null!==(Be=Ke&&(null===(we=null==Ke?void 0:Ke[wt])||void 0===we?void 0:we.evaluation_result))&&void 0!==Be?Be:null===(Ee=null===(_e=null==ke?void 0:ke.nodes)||void 0===_e?void 0:_e[wt])||void 0===Ee?void 0:Ee.evaluation_result)&&void 0!==Fe?Fe:null:null!==(Ce=null!==(xe=Ke&&(null===(Se=null===(me=null==Ke?void 0:Ke[wt])||void 0===me?void 0:me.evaluation_result)||void 0===Se?void 0:Se[0]))&&void 0!==xe?xe:null===(be=null===(ye=null===(Re=null==ke?void 0:ke.nodes)||void 0===Re?void 0:Re[wt])||void 0===ye?void 0:ye.evaluation_result)||void 0===be?void 0:be[0])&&void 0!==Ce?Ce:null,_t=S(Bt),Et=x(null!==(Ae=null===(Te=null===(Ie=null==Bt?void 0:Bt.evaluation_outputs)||void 0===Ie?void 0:Ie.metadata)||void 0===Te?void 0:Te.label_color)&&void 0!==Ae?Ae:E),Ft=r(ct);u(function(){Ft.current=ct},[ct]);var It=r(ci);u(function(){It.current=ci},[ci]);var Tt=c(function(e,n,i,t,o,r){return Lo.current(e,n,i,t,o,r)},[]),At=c(function(e,n,i,t,o){return jo.current(e,n,i,t,o)},[]),Dt=c(function(){return Po.current()},[]),Ot=c(function(e,n){return No.current(e,n)},[]),kt=c(function(e){return Ho.current(e)},[]),Lt=c(function(e){return zo.current(e)},[]),jt=c(function(){return Mo.current()},[]),Pt=c(function(){var e,n;ut(),null===(e=Ft.current)||void 0===e||e.call(Ft),Rn(!1),pn(new Set),mn([]),In.current=[],io([]),oo(null),ii(F),null===(n=It.current)||void 0===n||n.call(It),requestAnimationFrame(function(){var e;null===(e=Tn.current)||void 0===e||e.call(Tn)})},[]),Nt=r(Pt);u(function(){Nt.current=Pt},[Pt]),u(function(){He&&Nt.current()},[He]);var Ht=l(function(){return{documents:null==ke?void 0:ke.documents,input_index_map:null==ke?void 0:ke.input_index_map}},[JSON.stringify(null==ke?void 0:ke.documents),JSON.stringify(null==ke?void 0:ke.input_index_map)]),zt=r(ke);u(function(){zt.current=ke},[ke]);var Mt=r(Ln);u(function(){Mt.current=Ln},[Ln]);var qt=c(function(n,i,t,o,r,l,u){var c,a,s,d,v=m(null==i?void 0:i.id)||m(null==t?void 0:t.id)||"",f=(v?null===(c=Mt.current)||void 0===c?void 0:c[v]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:v,decisioning:[],gap:[],relevance_score:0},p=null!==(s=null===(a=qi.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null;return{isLoading:null!==(d=null==Me?void 0:Me.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:f,anchorEl:n,sectionAnchorEl:p,badgeStyle:l||null,sectionIdx:o,docData:Ht,deviationData:function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(y)))return u(l);var c=o.split(y)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[Ht]),Wt=c(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Un.open&&Un.sectionIdx===o)ai();else{var u=e.currentTarget,c="left";(null===(l=Hn.current)||void 0===l?void 0:l.contains(u))&&(c="right");ut(),it.current&&ct(),pn(new Set),mn([]),In.current=[],ci(),ni.open?ho():ti(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(y)){var r=o.split(y),l="".concat(r[0]).concat(y).concat(r[1]);return"right"===c?null===(e=Ni.current[l])||void 0===e?void 0:e.current:null===(n=Pi.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=Ni.current[o])||void 0===i?void 0:i.current:null===(t=Pi.current[o])||void 0===t?void 0:t.current}()||u;Gn(qt(e,n,t,o,i,r))})}},[Un.open,Un.sectionIdx,ai,ti,qt]),Vt=c(function(){var e=Un.sectionIdx;Un.isOrphan,ai(),ti(),null!==e&&(mt(e),ut(),it.current&&ct(),mn([]),In.current=[],pn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Tn.current&&Tn.current()},50))},[Un.sectionIdx,Un.isOrphan,ai,ti,ct]),Kt=c(function(){var e=Bn.current;if(e){Bn.current=null;var n=wi.findIndex(function(n){return n.id===e}),i=Bi.findIndex(function(n){return n.id===e}),t=-1===n?R(wi,e):null,o=-1===i?R(Bi,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(lt.current.add(r),C(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Ze)-1!==r&&Vn.current&&c(function(){return u(n,t,Li,zi)},Vn.current),-1!==l&&Hn.current&&c(function(){return u(i,o,ji,Mi)},Hn.current);else{var a=Pn.current;if(!a)return;c(function(){return-1!==r?u(n,t,Li,zi):u(i,o,ji,Mi)},a)}}},[wi,Bi,Ze,Li,ji,zi,Mi,Vn,Hn,Pn]),Jt=c(function(n){if(n){ut(),ct(),pn(new Set),mn([]),In.current=[],ti(),ci();var i=wi.findIndex(function(e){return e.id===n}),t=Bi.findIndex(function(e){return e.id===n}),o=-1===i?R(wi,n):null,r=-1===t?R(Bi,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;Bn.current=n,vt(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=Ze?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=Ze?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),pt(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){Bn.current===n&&Yt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[wi,Bi,Ze,vt,pt,ct,ti,ci]),Yt=r(Kt);u(function(){Yt.current=Kt},[Kt]);var Xt=r(null);u(function(){if(vi){var e=si.fields.find(function(e){return e.analysisKey===vi||e.key===vi});if(e){var n=Oi.current[e.key]||ki.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[vi,si.fields]);var $t=c(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==yt?void 0:yt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[yt]),Ut=K({proposedSections:wi,existingSections:Bi,maintainRelativeOrder:Ze,cognitiveMap:Ln,deviationData:kn,treeData:ke,resolvedComparisonConfig:si}),Gt=Ut.getSectionCompareStyle,Qt=Ut.getSubSectionCompareStyle,Zt=Ut.getDeviationStyleByKey,eo=Y({containerRef:bn,leftContainerRef:Vn,rightContainerRef:Hn,svgContainerRef:yn,pathRefs:Fn,leftHeaderRef:Cn,rightHeaderRef:wn,proposedSections:wi,existingSections:Bi,visibleFields:_i,leftRefs:Oi,rightRefs:ki,sectionLeftRefs:Li,sectionRightRefs:ji,subSectionLeftRefs:zi,subSectionRightRefs:Mi,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni,sectionRowRefs:qi,expandedSections:dt,expandedSubSections:ft,connectedSections:fn,isSideBySide:Yi,activeSideBySideSection:Zi,maintainRelativeOrder:Ze,cognitiveMap:Ln,getSectionCompareStyle:Gt,getSubSectionCompareStyle:Qt,getDeviationStyleByKey:Zt,isArrowVisible:Xi,isAnimatingRef:_n,isSideBySideRef:it,sideBySideCacheRef:nt,sideBySideLineRef:rt,activeSideBySideSectionRef:ot,activeSideBySideRightSectionRef:tt,connectedLines:hn,setConnectedLines:mn,cachedConnectedPositions:In,calculateLinesRef:Tn,resizeTimerRef:An,scrollLock:et,scrollSyncLocked:xn,handleResizeRef:Dn,activeProposed:bi,existingRule:Ci,analysisData:yt,pendingScrollTargetRef:Kn,pendingScrollCallbackRef:Jn,resolvedComparisonConfig:si,getFieldData:$t}),no=eo.lines,io=eo.setLines,to=eo.overallConnector,oo=eo.setOverallConnector,ro=eo.svgDimensions,lo=eo.handleColumnScroll;u(function(){ni.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Tn.current)||void 0===e||e.call(Tn)})})},[ni.anchorEl,xn]);var uo=c(function(){ut(),Rn(!1),vt({}),pt({}),ct(),pn(new Set),mn([]),In.current=[],ti(),ci(),ai(),requestAnimationFrame(function(){Tn.current&&Tn.current()})},[vt,pt,ct,ti,ci,ai]);u(function(){Yi||0!==fn.size||Rn(!1)},[Yi,fn]);var co=l(function(){return Object.values(dt).some(Boolean)||Object.values(ft).some(Boolean)},[dt,ft]),ao=r(null),so=r(0),vo=r(0),fo=r(0),po=J({timerRef:ao,ruleComponentRef:Nn,scrollContainerRef:Pn,containerRef:bn,maintainRelativeOrder:Ze,proposedSections:wi,existingSections:Bi,isSideBySideRef:it,activeSideBySideSectionRef:ot,activeSideBySideRightSectionRef:tt,sectionRowRefs:qi,sectionRightRowRefs:Hi,sectionLeftRefs:Li,sectionRightRefs:ji,subSectionLeftRefs:zi,subSectionRightRefs:Mi,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni,leftContainerRef:Vn,rightContainerRef:Hn,calculateLinesRef:Tn,handleResizeRef:Dn,setIsResizing:Gi,setIsArrowVisible:$i,sideBySideCacheRef:nt,cachedConnectedPositions:In}).handleResize;u(function(){Dn.current=po},[po,Dn]),u(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Nn.current&&o.push(e(Nn.current,so,n,function(){return Dn.current()},function(){})),Pn.current&&o.push(e(Pn.current,vo,i,function(){return Dn.current()},function(){return Tn.current()})),bn.current&&o.push(e(bn.current,fo,t,function(){return Dn.current()},function(){return Tn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),u(function(){it.current=Yi},[Yi]),u(function(){ot.current=Zi},[Zi]);var go=c(function(){var e,n=Un.sectionIdx,i=Un.isOrphan;if(ti(),null!=n){var t="left";Un.anchorEl&&(null===(e=Hn.current)||void 0===e?void 0:e.contains(Un.anchorEl))&&(t="right"),mt(n),at(n,i,{sourceSide:t})}},[at,Un.isOrphan,Un.sectionIdx,Un.anchorEl,ti]),ho=c(function(){ti(),ct(),pn(new Set),mn([]),In.current=[]},[ti,ct]),mo=null!==Un.sectionIdx&&fn.has(Un.sectionIdx),So=N({proposedSections:wi,existingSections:Bi,parentDeviationRecord:Ei,expandedSections:dt,maintainRelativeOrder:!!Ze,scrollContainerRef:Pn,leftContainerRef:Vn,rightContainerRef:Hn,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni}),xo=So.showDeviationNavigation,Ro=So.showOpenNodeRef,yo=So.adjustScrollForPopup,bo=c(function(e,n,i,t,o){var r,l="string"==typeof t?m(t).trim():m(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;ci();var c="left";(null===(r=Hn.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(y)){var r=n.split(y),l="".concat(r[0]).concat(y).concat(r[1]);return"right"===c?null===(e=Ni.current[l])||void 0===e?void 0:e.current:null===(i=Pi.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=Ni.current[n])||void 0===t?void 0:t.current:null===(o=Pi.current[n])||void 0===o?void 0:o.current};if(i)return ct(),pn(new Set),mn([]),In.current=[],void(l&&(mt(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));ii({open:!0,anchorEl:e,summary:t,displayImpact:o})})));mt(n),l?setTimeout(function(){at(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,n,i,r=a()||u;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var c=l.top-window.innerHeight/2;Ze?(null===(e=Vn.current)||void 0===e||e.scrollBy({top:c,behavior:"smooth"}),null===(n=Hn.current)||void 0===n||n.scrollBy({top:c,behavior:"smooth"})):null===(i=Pn.current)||void 0===i||i.scrollBy({top:c,behavior:"smooth"})}}ii({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){at(n,i,{toggleIfSame:!1,sourceSide:c})},350)},[at,ci,ii,ct,mt]),Co=l(function(){var e;if(!Je)return null;var n=null===(e=null==Je?void 0:Je.id)||void 0===e?void 0:e.split(":")[0];for(var i in Ei){if((Ei[i]||[]).some(function(e){return e.id===n}))return i}return null},[Je,Ei]),wo=r({id:null,triggerMs:null}),Bo=r(null);u(function(){var i;if(null==Je?void 0:Je.id){var t=Number(Je.trigger),o=wo.current;if((null==o?void 0:o.triggerMs)!==t){if(!(Je.id.includes(":")&&/:\d+$/.test(Je.id)))return wo.current={id:Je.id,triggerMs:t},void Jt(Je.id);var r=null===(i=null==Je?void 0:Je.id)||void 0===i?void 0:i.split(":"),l=r[0],u=r[1],c=null!=u?u:"0";Bo.current!==Je.id&&(ti(),ci(),ct(),pn(new Set),mn([]),In.current=[],Bo.current=Je.id);var a=!1,s=0,d=null,v=450,f=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},p=function(){var i,o,r,u;if(!a){var g=function(){wo.current={id:Je.id,triggerMs:t}},h=null,m=null;for(var S in Ei){var x=Ei[S].find(function(e){return e.id===l});if(x){h=S,m=x;break}}if(m&&h){var R=wi.findIndex(function(e){return e.id===h}),b=Bi.findIndex(function(e){return e.id===h}),C=-1===R&&-1!==b,w=f(wi,m.id),B=f(Bi,m.id);if(w&&!B&&!C){var _=w.split("-"),E=Number(_[0]);if(Ze){var F=null===(o=null===(i=wi[E])||void 0===i?void 0:i.refIndexes)||void 0===o?void 0:o[0],I=Bi.findIndex(function(e){return e.selfIndex===F});-1!==I&&(E=I)}B=n([E],_.slice(1),!0).join("-")}if(w||B){var T=w?Number(w.split("-")[0]):R,A=B?Number(B.split("-")[0]):b,D=A>=0?A:B?Number(B.split("-")[0]):-1,O=wi[T],k=Bi[D],L=O&&!O.title&&!O.content,j=k&&!k.title&&!k.content,P=C||(!w&&!!B||L&&!j);if(P){if(!(Ze?!!dt["right-".concat(A)]:!!dt[String(A)])&&A>=0)return ht(A,"right"),s+=1,void(d=setTimeout(p,450))}else if(!(Ze?!!dt["left-".concat(T)]:!!dt[String(T)])&&T>=0)return ht(T,"left"),s+=1,void(d=setTimeout(p,450));var N=w||"",H=B||"",z="".concat(m.id).concat(y).concat(c).concat(y).concat(N).concat(y).concat(H),M="".concat(m.id).concat(y).concat(c);mt(z);var q,W=null===(r=Pi.current[M])||void 0===r?void 0:r.current,V=null===(u=Ni.current[M])||void 0===u?void 0:u.current,K=P||!W&&!!V,J=K?V:W;if(q=Ze?K?Hn.current:Vn.current:Pn.current,J&&q){var Y=J.getBoundingClientRect();if(0===Y.height)return void((s+=1)<2?d=setTimeout(p,v):g());var X=q.getBoundingClientRect(),$=Y.top-X.top+q.scrollTop-X.height/2+Y.height/2,U=w&&w.includes("-")||B&&B.includes("-"),G=function(){var n,i,t,o,r;if(!a){g();var l=J instanceof Element?window.getComputedStyle(J).color:"";W&&(W.style.transition="box-shadow 300ms ease-in-out",W.style.boxShadow="0 0 10px ".concat(l)),V&&(V.style.transition="box-shadow 300ms ease-in-out",V.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){W&&(W.style.boxShadow=""),V&&(V.style.boxShadow="")},2e3);var u=(null===(i=null===(n=m.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===i?void 0:i[c])||m,s=(null===(t=m.evaluationResult)||void 0===t?void 0:t.evaluation_outputs)||m.evaluation_outputs;if(!(!!W&&!!V)){var d=K?(null===(o=Ni.current[U?M:A])||void 0===o?void 0:o.current)||V:(null===(r=Pi.current[U?M:T])||void 0===r?void 0:r.current)||W;return yo(d,function(){ii({open:!0,anchorEl:d,displayImpact:Je.displayImpact,summary:e(e({},u),{evaluation_outputs:s})})},{skipScroll:!0}),void(null==Ye||Ye())}at(z,!1,{toggleIfSame:!1,sourceSide:C?"right":"left",onReady:function(){var n,i;g();var t=K?(null===(n=Ni.current[M])||void 0===n?void 0:n.current)||V:(null===(i=Pi.current[M])||void 0===i?void 0:i.current)||W;ii({open:!0,anchorEl:t,displayImpact:Je.displayImpact,summary:e({},u)}),null==Ye||Ye()}})}};Math.abs(q.scrollTop-$)<=2?G():(Kn.current=$,Jn.current=G,q.scrollTo({top:$,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(Jn.current){Kn.current=null;var e=Jn.current;Jn.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(p,v):g()}else(s+=1)<2?d=setTimeout(p,v):g()}else(s+=1)<2?d=setTimeout(p,v):g()}};return d=setTimeout(p,v),function(){a=!0,d&&clearTimeout(d)}}}},[Je,Ei,wi,Bi,Ze,dt,ht,at,ii,Jt]),u(function(){var n,i,t;if(ni.open){var o=ni.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Pi.current)||r(Ni.current);if(l){var u=(null===(i=Ni.current[l])||void 0===i?void 0:i.current)||(null===(t=Pi.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&ii(function(n){return e(e({},n),{anchorEl:u})})}}}},[ni.open,ni.anchorEl,xn,fn,dt]);var _o=Xn.open,Eo=Xn.sectionIdx,Fo=Xn.isOrphan,Io=Xn.badgeStyle,To=Xn.anchorEl,Ao=Xn.sectionAnchorEl;u(function(){var n;if(_o&&null!=Eo&&Eo!==wt){var i="string"==typeof Eo?Eo.split(y)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(wi,i):null,r=i&&"string"==typeof i?t(Bi,i):null,l="number"==typeof Eo?wi[Eo]||null:o||i&&((null===(n=null==ke?void 0:ke.nodes)||void 0===n?void 0:n[i])||(null==ke?void 0:ke[i]))||null,u="number"==typeof Eo?Bi[Eo]||null:r,c=qt(To,l,u,Eo,Fo,Io);$n(function(n){return n.open?m(n.cognitiveData)===m(c.cognitiveData)&&m(n.deviationData)===m(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[_o,Eo,Fo,Io,To,Ao,wi,Bi,qt]);var Do=c(function(e){var n=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset;return i(z,{section:n,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s})},[]),Oo=l(function(){return wi.map(function(e,n){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Ze?null:i(M,{section:e,idx:n},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[wi]),ko=l(function(){return Bi.map(function(e,n){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Ze?null:i(q,{section:e,idx:n},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Bi]),Lo=r(Wt);u(function(){Lo.current=Wt},[Wt]);var jo=r(bo);u(function(){jo.current=bo},[bo]);var Po=r(ho);u(function(){Po.current=ho},[ho]);var No=r(ht);u(function(){No.current=ht},[ht]);var Ho=r(gt);u(function(){Ho.current=gt},[gt]);var zo=r(Do);u(function(){zo.current=Do},[Do]);var Mo=r(ct);u(function(){Mo.current=ct},[ct]);var qo=l(function(){return{maintainRelativeOrder:!!Ze,showDeviationBadges:on,isProposingFix:$e,proposingFixNodeId:Ue,isRedlineFlow:Ge,isSideBySide:Yi,activeSideBySideSection:Zi,scrollSyncLocked:xn,toggleScrollSyncLocked:xt,summaryPopupAnchorEl:ni.anchorEl,connectedSections:fn,proposedSections:wi,existingSections:Bi,deviationNumberRegistry:Fi,treeData:ke,displayConfig:Me,resolvedMarkdownStyles:jn,unifiedNumbering:Rt,expandedSections:dt,expandedSubSections:ft,setExpandedSubSections:pt,getSectionCompareStyle:Gt,getSubSectionCompareStyle:Qt,getBadgeRef:Ki,getSectionRowRef:Wi,getSubSectionRef:Vi,sectionLeftRefs:Li,sectionRightRefs:ji,sectionRowRefs:qi,sectionRightRowRefs:Hi,subSectionLeftRefs:zi,subSectionRightRefs:Mi,lhsBadgeRefs:Pi,rhsBadgeRefs:Ni,openMoreFunctionsPopup:Tt,handleOpenSummaryPopup:At,openSummaryPopup:At,handleCloseSummaryPopup:Dt,toggleSection:Ot,handleSubSectionToggle:kt,renderSubSectionAccordion:Lt,resetSideBySide:jt,setConnectedSections:pn,setConnectedLines:mn,cachedConnectedPositions:In,showDeviationNavigation:xo,showOpenNodeRef:Ro,deviationNodeIdToView:null==Je?void 0:Je.id,deviationTargetParentId:Co}},[Ze,on,$e,Ue,Ge,Yi,Zi,xn,xt,ni.anchorEl,fn,wi,Bi,Fi,Me,jn,Rt,dt,ft,pt,Gt,Qt,Ki,Wi,Vi,xo,Ro,Je,Co]);return i(V,e({value:qo},{children:t(a,e({ref:Nn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[ln&&i(a,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(D,{})})),ni.open&&i(W,{open:ni.open,anchorEl:ni.anchorEl,containerEl:Xt.current,clipTopEl:Cn.current,scrollContainerEl:Pn.current,onClose:ho,summary:ni.summary,displayImpact:ni.displayImpact,isScrollLocked:xn}),i(A,{open:Un.open,anchorEl:Un.anchorEl,maintainRelativeOrder:!!Ze,sectionTitle:Un.sectionTitle,referenceSectionTitle:Un.refSectionTitle,onClose:ai,onOpenCognitiveCompare:li,onOpenSideBySide:go,onConnect:Vt,isConnected:mo,isOrphan:Un.isOrphan}),Xn.open&&i(T,{open:Xn.open,popupRef:ri,position:Qn,popupConfig:We,onClose:function(){Zn(null),$n(function(n){return e(e({},n),{open:!1})}),oi(null)},markdownStyles:Ne,sectionTitle:mi,referenceSectionTitle:xi,cognitiveData:Xn.cognitiveData,anchorEl:Xn.anchorEl,sectionAnchorEl:Xn.sectionAnchorEl,scrollContainerEl:Pn.current,badgeStyle:Xn.badgeStyle,docData:Xn.docData,deviationData:Xn.deviationData,isLoading:Xn.isLoading}),i(s,e({open:!!an,autoHideDuration:8e3,onClose:function(){return sn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(d,e({onClose:function(){return sn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:an}))})),i(H,{componentHeaderText:Oe,displayConfig:Me,maintainRelativeOrder:Ze,onCollapseAll:uo,showCollapseAll:co,onToggleView:function(e){un(!0),setTimeout(function(){en(!e),null==qe||qe(!e),Rn(!1),ct(),ti(),pn(new Set),mn([]),In.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){un(!1)},600)})})},50)}}),i(a,e({ref:Pn,onScroll:lo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Ze?"visible":"auto",borderTop:bt&&Ct?"none":"1.5px solid #EEF0F4"}},{children:i(a,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Ze?{flex:1}:{})},{children:t(a,e({ref:bn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Ze?{flex:1,overflow:"visible"}:{})},{children:[i($,{svgContainerRef:yn,svgDimensions:ro,isResizing:Ui,overallConnector:to,rootDeviationStyle:Et,lines:no,isSideBySide:Yi,activeSideBySideSection:Zi,isArrowVisible:Xi,maintainRelativeOrder:Ze,proposedSections:wi,existingSections:Bi,cognitivePopup:Xn,activeBadgeId:ei,closeCognitivePopup:ci,setActiveBadgeId:oi,openCognitivePopupFromState:ui,buildSectionPopupState:qt,connectedLines:hn,pathRefs:Fn}),t(a,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Ze?{flex:1,overflow:"visible"}:{})},{children:[i(a,e({ref:Cn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:i(v,e({title:gi,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:gi}))}))})),t(a,e({ref:Vn,onScroll:lo,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ze?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:qn,style:{width:"100%",height:"0px",flexShrink:0}}),Ti&&Oo,i("div",{ref:Wn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(a,e({ref:Xt,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(a,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(a,e({onClick:function(n){n.stopPropagation(),Xn.open&&ei===wt?ci():(oi(wt),ui(qt(n.currentTarget,{title:"",content:"",evaluationResult:Bt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,wt,!0,e(e({},Et),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Et.badgeBg,color:Et.badgeText,border:"1px solid ".concat(Et.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=_t?_t:i(O,{}),i(a,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(g,{})})),i(p,{size:11,style:{transform:Xn.open&&ei===wt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(a,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Ze?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Qi&&i(h,{sections:11}),i(a,e({ref:wn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(v,e({title:Ri,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ri}))}))})),t(a,e({ref:Hn,onScroll:lo,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ze?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:zn,style:{width:"100%",height:"0px",flexShrink:0}}),Ti&&ko,i("div",{ref:Mn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{U as default};
|
|
1
|
+
import{__assign as e,__spreadArray as n}from"tslib";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as c}from"react";import{Box as a,Snackbar as s,Alert as d,Tooltip as v,Typography as f}from"@mui/material";import{ChevronDown as p}from"lucide-react";import{ButtonCognitiveIcon as g}from"../../assests/svg/ButtonCognitiveIcon.js";import h from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as S,generateColorPalette as x,findKeyPathByNodeId as R,DEVIATION_BADGE_SEPARATOR as y,hasMeaningfulRedlineTags as b,scrollAndHighlightClause as C}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as w,DEFAULT_FIELD_CONFIG as _,DEFAULT_COMPARISON_CONFIG as B}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as E,EMPTY_SUMMARY_POPUP_STATE as F,DEFAULT_COMPONENT_HEADER_TEXT as I}from"./CognitiveCompareConstants.js";import T from"./CognitivePopup.js";import A from"./MoreFunctionsPopup.js";import D from"./LoaderComponent.js";import O from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as k}from"./hooks/useCompareData.js";import{useComparePopups as L}from"./hooks/useComparePopups.js";import{useSectionRefs as P}from"./hooks/useSectionRefs.js";import{useAccordionState as j}from"./hooks/useAccordionState.js";import{useDeviationNavigation as N}from"./hooks/useDeviationNavigation.js";import H from"./components/CompareHeader.js";import z from"./components/SubSectionAccordion.js";import M from"./components/LHSSectionRow.js";import q from"./components/RHSSectionRow.js";import W from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as V}from"./CompareContext.js";import{useStyleHelpers as K}from"./hooks/useStyles.js";import{useResizeHandler as J}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Y}from"./hooks/useLinesCalculator.js";import{useSideBySide as X}from"./hooks/useSideBySide.js";import $ from"./components/SvgConnectors.js";var U=function(U){var G,Q,Z,ee,ne,ie,te,oe,re,le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,ye,be,Ce,we,_e,Be,Ee,Fe,Ie,Te,Ae,De=U.componentHeaderText,Oe=void 0===De?I:De,ke=U.treeData,Le=U.comparisonConfig,Pe=U.leftColumnTitleText,je=U.rightColumnTitleText,Ne=U.markdownStyles,He=U.resetTrigger,ze=U.displayConfig,Me=void 0===ze?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0}:ze,qe=U.onMaintainRelativeOrderChange,We=U.popupConfig,Ve=U.deviationData,Ke=void 0===Ve?{}:Ve,Je=U.deviationNodeIdToView,Ye=U.resetDeviationNodeId,Xe=U.isProposingFix,$e=void 0!==Xe&&Xe,Ue=U.proposingFixNodeId,Ge=U.isRedlineFlow,Qe=o(Me.maintainRelativeOrder),Ze=Qe[0],en=Qe[1],nn=null!==(G=null==Me?void 0:Me.expandLevels)&&void 0!==G?G:0,tn=!!(null==Me?void 0:Me.expandAllSections),on=!!Ze||!!(null==Me?void 0:Me.showDeviationBadges),rn=o(!1),ln=rn[0],un=rn[1],cn=o(null),an=cn[0],sn=cn[1],dn=o(null===(Z=null!==(Q=null==ke?void 0:ke.newEvaluationResult)&&void 0!==Q?Q:null==Me?void 0:Me.enableDeviationSchemaBackwardCompatibility)||void 0===Z||Z)[0],vn=o(new Set),fn=vn[0],pn=vn[1],gn=o([]),hn=gn[0],mn=gn[1],Sn=o(!1),xn=Sn[0],Rn=Sn[1],yn=r(null),bn=r(null),Cn=r(null),wn=r(null),_n=r(null),Bn=r(!1),En=r(null),Fn=r({}),In=r([]),Tn=r(function(){}),An=r(null),Dn=r(function(){}),On=l(function(){return JSON.stringify(Ke||{})},[JSON.stringify(Ke)]),kn=l(function(){return Ke||{}},[On]),Ln=l(function(){return(null==ke?void 0:ke.cognitive_decisioning)||{}},[ke]),Pn=l(function(){return e(e({},w),Ne)},[Ne]),jn=r(null),Nn=r(null),Hn=r(null),zn=r(null),Mn=r(null),qn=r(null),Wn=r(null),Vn=r(null),Kn=r(null),Jn=r(null),Yn=L(jn),Xn=Yn.cognitivePopup,$n=Yn.setCognitivePopup,Un=Yn.moreFunctions,Gn=Yn.setMoreFunctions,Qn=Yn.position,Zn=Yn.setPosition,ei=Yn.activeBadgeId,ni=Yn.summaryPopup,ii=Yn.setSummaryPopup,ti=Yn.closeSummaryPopup,oi=Yn.setActiveBadgeId,ri=Yn.popupRef,li=Yn.handleOpenCognitiveCompare,ui=Yn.openCognitivePopupFromState,ci=Yn.closeCognitivePopup,ai=Yn.closeMoreFunctionsPopup,si=l(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==Le?void 0:Le.fields)&&void 0!==e?e:_,thresholds:{high:null!==(i=null===(n=null==Le?void 0:Le.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:B.thresholds.high,medium:null!==(o=null===(t=null==Le?void 0:Le.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:B.thresholds.medium,exact:null!==(l=null===(r=null==Le?void 0:Le.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:B.thresholds.exact}}},[Le]),di=o(null),vi=di[0];di[1];var fi=null===(ie=null===(ee=null==ke?void 0:ke.documents)||void 0===ee?void 0:ee[null===(ne=null==ke?void 0:ke.input_index_map)||void 0===ne?void 0:ne[0]])||void 0===ie?void 0:ie.title,pi=null===(re=null===(te=null==ke?void 0:ke.documents)||void 0===te?void 0:te[null===(oe=null==ke?void 0:ke.input_index_map)||void 0===oe?void 0:oe[1]])||void 0===re?void 0:re.title,gi=m(Pe||fi||"Uploaded Contract"),hi=null===(ae=null===(ce=null===(le=null==ke?void 0:ke.documents)||void 0===le?void 0:le[null===(ue=null==ke?void 0:ke.input_index_map)||void 0===ue?void 0:ue[0]])||void 0===ce?void 0:ce.metadata)||void 0===ae?void 0:ae.file_name,mi=m(hi),Si=null===(fe=null===(ve=null===(se=null==ke?void 0:ke.documents)||void 0===se?void 0:se[null===(de=null==ke?void 0:ke.input_index_map)||void 0===de?void 0:de[1]])||void 0===ve?void 0:ve.metadata)||void 0===fe?void 0:fe.file_name,xi=m(Si),Ri=m(je||pi||"Reference Template"),yi=k(ke,Ze,kn,si,dn),bi=yi.activeProposed,Ci=yi.existingRule,wi=yi.proposedSections,_i=yi.existingSections,Bi=yi.visibleFields,Ei=yi.parentDeviationRecord,Fi=yi.deviationNumberRegistry,Ii=yi.deviationParentRegistry,Ti=yi.parseError;u(function(){Ti&&sn("Failed to load comparison: ".concat(Ti))},[Ti]);var Ai=wi.length>0||_i.length>0,Di=l(function(){if(!Ge)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";b(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(wi),i(_i),"".concat(e,":").concat(n)},[Ge,wi,_i]);u(function(){if(wi.length||_i.length)if(tn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=Ze?"".concat(t,"-").concat(o):String(o);e[l]=!0;var u=function(e,i){null==e||e.forEach(function(e,t){var o,r="".concat(i,"-").concat(t);n[r]=!0,(null===(o=e.subsections)||void 0===o?void 0:o.length)&&u(e.subsections,r)})};(null===(r=i.subsections)||void 0===r?void 0:r.length)&&u(i.subsections,String(o))})};i(wi,"left"),i(_i,"right"),ft(e),gt(n)}else if(nn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=Ze?"".concat(n,"-").concat(r):String(r);t[u]=!0}var c=function(e,n,t){t>i||null==e||e.forEach(function(e,i){var r,l="".concat(n,"-").concat(i);o[l]=!0,(null===(r=e.subsections)||void 0===r?void 0:r.length)&&c(e.subsections,l,t+1)})};(null===(l=e.subsections)||void 0===l?void 0:l.length)&&i>=2&&c(e.subsections,String(r),2)})};r(wi,"left",nn),r(_i,"right",nn),ft(t),gt(o)}},[tn,nn,wi,_i,Ze]);var Oi=P(Bi.map(function(e){return e.key}),Math.max(wi.length,_i.length)),ki=Oi.leftRefs,Li=Oi.rightRefs,Pi=Oi.sectionLeftRefs,ji=Oi.sectionRightRefs,Ni=Oi.lhsBadgeRefs,Hi=Oi.rhsBadgeRefs,zi=Oi.sectionRightRowRefs,Mi=Oi.subSectionLeftRefs,qi=Oi.subSectionRightRefs,Wi=Oi.sectionRowRefs,Vi=Oi.getSectionRowRef,Ki=Oi.getSubSectionRef,Ji=Oi.getBadgeRef,Yi=X({maintainRelativeOrder:Ze,proposedSections:wi,existingSections:_i,leftContainerRef:Vn,rightContainerRef:Hn,scrollContainerRef:jn,sectionLeftRefs:Pi,sectionRightRefs:ji,subSectionLeftRefs:Mi,subSectionRightRefs:qi,lhsBadgeRefs:Ni,rhsBadgeRefs:Hi,sectionRowRefs:Wi,sectionRightRowRefs:zi,rhsTopSpacerRef:zn,rhsBottomSpacerRef:Mn,lhsTopSpacerRef:qn,lhsBottomSpacerRef:Wn,calculateLinesRef:Tn,setConnectedSections:pn,setConnectedLines:mn,cachedConnectedPositions:In,closeMoreFunctionsPopup:ai,setErrorToast:sn,moreFunctions:Un,closeSummaryPopup:ti}),Xi=Yi.isSideBySide,$i=Yi.isArrowVisible,Ui=Yi.setIsArrowVisible,Gi=Yi.isResizing,Qi=Yi.setIsResizing,Zi=Yi.isSideBySideLoading,et=Yi.activeSideBySideSection,nt=Yi.scrollLock,it=Yi.sideBySideCacheRef,tt=Yi.isSideBySideRef,ot=Yi.activeSideBySideRightSectionRef,rt=Yi.activeSideBySideSectionRef,lt=Yi.sideBySideLineRef,ut=Yi.highlightedClauseRefs,ct=Yi.clearClauseHighlight,at=Yi.resetSideBySide,st=Yi.activateSideBySide,dt=j({maintainRelativeOrder:!!Ze,proposedSections:wi,existingSections:_i,activeSideBySideSection:et,connectedSections:fn,resetSideBySide:at,setConnectedSections:pn,setConnectedLines:mn,cachedConnectedPositions:In,svgContainerRef:yn,isAnimatingRef:Bn,animationTimerRef:En,calculateLinesRef:Tn,sectionLeftRefs:Pi,sectionRightRefs:ji,subSectionLeftRefs:Mi,subSectionRightRefs:qi}),vt=dt.expandedSections,ft=dt.setExpandedSections,pt=dt.expandedSubSections,gt=dt.setExpandedSubSections,ht=dt.handleSubSectionToggle,mt=dt.toggleSection,St=dt.forceExpandCrossWiredSections,xt=function(){var e,n;if(null!=et){var i=null===(e=Pi.current[et])||void 0===e?void 0:e.current,t=null===(n=ji.current[et])||void 0===n?void 0:n.current,o=Hn.current;if(i&&t&&o){var r=i.getBoundingClientRect(),l=t.getBoundingClientRect(),u=o.getBoundingClientRect(),c=r.top-u.top,a=l.top-u.top-c;o.scrollBy({top:a,behavior:"smooth"})}}},Rt=c(function(e){null==e||e.stopPropagation(),Rn(function(e){var n=!e;return n&&requestAnimationFrame(function(){xt()}),n})},[xt]);u(function(){Ge&&"off"!==Di&&"0:0"!==Di&&(it.current=null,In.current=[],requestAnimationFrame(function(){var e;null===(e=Tn.current)||void 0===e||e.call(Tn)}))},[Ge,Di]);var yt=l(function(){var e=new Map,n=new Map,i=1;if(Ze)wi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),_i.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=wi.filter(function(e){var n;return null===(n=e.refIndexes)||void 0===n?void 0:n.includes(t.selfIndex)});if(o.length>0){var r=o.map(function(n){return e.get(n.id)}).filter(Boolean);n.set(t.id,r.join(", "))}else n.set(t.id,String(i++))}});else for(var t=Math.max(wi.length,_i.length),o=0;o<t;o++){var r=wi[o],l=_i[o];r?(e.set(r.id,i),l&&n.set(l.id,String(i)),i++):l&&n.set(l.id,String(i++))}return{leftNums:e,rightNums:n}},[wi,_i,Ze]),bt=Ci.analysis,Ct=m(null===(ge=null===(pe=null==bt?void 0:bt.rule_difference_comparison)||void 0===pe?void 0:pe.summary)||void 0===ge?void 0:ge.overall_summary),wt=!!Ct.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),_t=null!==(he=null==ke?void 0:ke.base_root_id)&&void 0!==he?he:"-1";null==ke||ke[_t];var Bt=dn?null!==(Fe=null!==(_e=Ke&&(null===(we=null==Ke?void 0:Ke[_t])||void 0===we?void 0:we.evaluation_result))&&void 0!==_e?_e:null===(Ee=null===(Be=null==ke?void 0:ke.nodes)||void 0===Be?void 0:Be[_t])||void 0===Ee?void 0:Ee.evaluation_result)&&void 0!==Fe?Fe:null:null!==(Ce=null!==(xe=Ke&&(null===(Se=null===(me=null==Ke?void 0:Ke[_t])||void 0===me?void 0:me.evaluation_result)||void 0===Se?void 0:Se[0]))&&void 0!==xe?xe:null===(be=null===(ye=null===(Re=null==ke?void 0:ke.nodes)||void 0===Re?void 0:Re[_t])||void 0===ye?void 0:ye.evaluation_result)||void 0===be?void 0:be[0])&&void 0!==Ce?Ce:null,Et=S(Bt),Ft=x(null!==(Ae=null===(Te=null===(Ie=null==Bt?void 0:Bt.evaluation_outputs)||void 0===Ie?void 0:Ie.metadata)||void 0===Te?void 0:Te.label_color)&&void 0!==Ae?Ae:E),It=r(at);u(function(){It.current=at},[at]);var Tt=r(ci);u(function(){Tt.current=ci},[ci]);var At=c(function(e,n,i,t,o,r){return Po.current(e,n,i,t,o,r)},[]),Dt=c(function(e,n,i,t,o){return jo.current(e,n,i,t,o)},[]),Ot=c(function(){return No.current()},[]),kt=c(function(e,n){return Ho.current(e,n)},[]),Lt=c(function(e){return zo.current(e)},[]),Pt=c(function(e){return Mo.current(e)},[]),jt=c(function(){return qo.current()},[]),Nt=c(function(){var e,n;ct(),null===(e=It.current)||void 0===e||e.call(It),Rn(!1),pn(new Set),mn([]),In.current=[],to([]),ro(null),ii(F),null===(n=Tt.current)||void 0===n||n.call(Tt),requestAnimationFrame(function(){var e;null===(e=Tn.current)||void 0===e||e.call(Tn)})},[]),Ht=r(Nt);u(function(){Ht.current=Nt},[Nt]),u(function(){He&&Ht.current()},[He]);var zt=l(function(){return{documents:null==ke?void 0:ke.documents,input_index_map:null==ke?void 0:ke.input_index_map}},[JSON.stringify(null==ke?void 0:ke.documents),JSON.stringify(null==ke?void 0:ke.input_index_map)]),Mt=r(ke);u(function(){Mt.current=ke},[ke]);var qt=r(Ln);u(function(){qt.current=Ln},[Ln]);var Wt=c(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,S,x=m(null==i?void 0:i.id)||m(null==t?void 0:t.id)||"",R=(x?null===(c=qt.current)||void 0===c?void 0:c[x]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:x,decisioning:[],gap:[],relevance_score:0},b=null!==(s=null===(a=Wi.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,C=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(y)))return u(l);var c=o.split(y)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),w=(null!==(f=null===(v=null===(d=null==C?void 0:C.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(h=null===(g=null===(p=null==C?void 0:C.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0;return{isLoading:null!==(S=null==Me?void 0:Me.isLoading)&&void 0!==S&&S&&!w,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:R,anchorEl:n,sectionAnchorEl:b,badgeStyle:l||null,sectionIdx:o,docData:zt,deviationData:C,isOrphan:!!r}},[zt,null==Me?void 0:Me.isLoading]),Vt=c(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),Un.open&&Un.sectionIdx===o)ai();else{var u=e.currentTarget,c="left";(null===(l=Hn.current)||void 0===l?void 0:l.contains(u))&&(c="right");ct(),tt.current&&at(),pn(new Set),mn([]),In.current=[],ci(),ni.open?mo():ti(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(y)){var r=o.split(y),l="".concat(r[0]).concat(y).concat(r[1]);return"right"===c?null===(e=Hi.current[l])||void 0===e?void 0:e.current:null===(n=Ni.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=Hi.current[o])||void 0===i?void 0:i.current:null===(t=Ni.current[o])||void 0===t?void 0:t.current}()||u;Gn(Wt(e,n,t,o,i,r))})}},[Un.open,Un.sectionIdx,ai,ti,Wt]),Kt=c(function(){var e=Un.sectionIdx;Un.isOrphan,ai(),ti(),null!==e&&(St(e),ct(),tt.current&&at(),mn([]),In.current=[],pn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Tn.current&&Tn.current()},50))},[Un.sectionIdx,Un.isOrphan,ai,ti,at]),Jt=c(function(){var e=_n.current;if(e){_n.current=null;var n=wi.findIndex(function(n){return n.id===e}),i=_i.findIndex(function(n){return n.id===e}),t=-1===n?R(wi,e):null,o=-1===i?R(_i,e):null,r=-1!==n?n:t?Number(t.split("-")[0]):-1,l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=function(e,n,i,t){var o,r,l,u;return-1!==e?null!==(r=null===(o=i.current[e])||void 0===o?void 0:o.current)&&void 0!==r?r:null:n&&null!==(u=null===(l=t.current[n])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(e,n,i){void 0===i&&(i=30);var t=0,o=function(){var r=e();r&&0!==r.getBoundingClientRect().height?(ut.current.add(r),C(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(Ze)-1!==r&&Vn.current&&c(function(){return u(n,t,Pi,Mi)},Vn.current),-1!==l&&Hn.current&&c(function(){return u(i,o,ji,qi)},Hn.current);else{var a=jn.current;if(!a)return;c(function(){return-1!==r?u(n,t,Pi,Mi):u(i,o,ji,qi)},a)}}},[wi,_i,Ze,Pi,ji,Mi,qi,Vn,Hn,jn]),Yt=c(function(n){if(n){ct(),at(),pn(new Set),mn([]),In.current=[],ti(),ci();var i=wi.findIndex(function(e){return e.id===n}),t=_i.findIndex(function(e){return e.id===n}),o=-1===i?R(wi,n):null,r=-1===t?R(_i,n):null;if(-1!==i||o||-1!==t||r){var l=-1!==i?i:o?Number(o.split("-")[0]):-1,u=-1!==t?t:r?Number(r.split("-")[0]):-1;_n.current=n,ft(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=Ze?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=Ze?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),gt(function(n){var i=e({},n),t=!1,l=function(e){for(var n=e.split("-"),o=n[0],r=1;r<n.length;r++)o+="-".concat(n[r]),i[o]||(i[o]=!0,t=!0)};return o&&l(o),r&&l(r),t?i:n}),setTimeout(function(){requestAnimationFrame(function(){_n.current===n&&Xt.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[wi,_i,Ze,ft,gt,at,ti,ci]),Xt=r(Jt);u(function(){Xt.current=Jt},[Jt]);var $t=r(null);u(function(){if(vi){var e=si.fields.find(function(e){return e.analysisKey===vi||e.key===vi});if(e){var n=ki.current[e.key]||Li.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[vi,si.fields]);var Ut=c(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==bt?void 0:bt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(t=null===(i=null==d?void 0:d.highlights)||void 0===i?void 0:i.ruleA_spans)||void 0===t?void 0:t.length)||(null===(r=null===(o=null==d?void 0:d.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==d?void 0:d.mappings)&&d.mappings.length>0;if(d.mappings){var f=d.mappings[0]||{};return{score:d.score,relation:f.relation||"",highlightsA:(null===(l=f.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=f.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:d.score,relation:d.relation||"",highlightsA:(null===(c=d.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=d.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[bt]),Gt=K({proposedSections:wi,existingSections:_i,maintainRelativeOrder:Ze,cognitiveMap:Ln,deviationData:kn,treeData:ke,resolvedComparisonConfig:si}),Qt=Gt.getSectionCompareStyle,Zt=Gt.getSubSectionCompareStyle,eo=Gt.getDeviationStyleByKey,no=Y({containerRef:bn,leftContainerRef:Vn,rightContainerRef:Hn,svgContainerRef:yn,pathRefs:Fn,leftHeaderRef:Cn,rightHeaderRef:wn,proposedSections:wi,existingSections:_i,visibleFields:Bi,leftRefs:ki,rightRefs:Li,sectionLeftRefs:Pi,sectionRightRefs:ji,subSectionLeftRefs:Mi,subSectionRightRefs:qi,lhsBadgeRefs:Ni,rhsBadgeRefs:Hi,sectionRowRefs:Wi,expandedSections:vt,expandedSubSections:pt,connectedSections:fn,isSideBySide:Xi,activeSideBySideSection:et,maintainRelativeOrder:Ze,cognitiveMap:Ln,getSectionCompareStyle:Qt,getSubSectionCompareStyle:Zt,getDeviationStyleByKey:eo,isArrowVisible:$i,isAnimatingRef:Bn,isSideBySideRef:tt,sideBySideCacheRef:it,sideBySideLineRef:lt,activeSideBySideSectionRef:rt,activeSideBySideRightSectionRef:ot,connectedLines:hn,setConnectedLines:mn,cachedConnectedPositions:In,calculateLinesRef:Tn,resizeTimerRef:An,scrollLock:nt,scrollSyncLocked:xn,handleResizeRef:Dn,activeProposed:bi,existingRule:Ci,analysisData:bt,pendingScrollTargetRef:Kn,pendingScrollCallbackRef:Jn,resolvedComparisonConfig:si,getFieldData:Ut}),io=no.lines,to=no.setLines,oo=no.overallConnector,ro=no.setOverallConnector,lo=no.svgDimensions,uo=no.handleColumnScroll;u(function(){ni.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Tn.current)||void 0===e||e.call(Tn)})})},[ni.anchorEl,xn]);var co=c(function(){ct(),Rn(!1),ft({}),gt({}),at(),pn(new Set),mn([]),In.current=[],ti(),ci(),ai(),requestAnimationFrame(function(){Tn.current&&Tn.current()})},[ft,gt,at,ti,ci,ai]);u(function(){Xi||0!==fn.size||Rn(!1)},[Xi,fn]);var ao=l(function(){return Object.values(vt).some(Boolean)||Object.values(pt).some(Boolean)},[vt,pt]),so=r(null),vo=r(0),fo=r(0),po=r(0),go=J({timerRef:so,ruleComponentRef:Nn,scrollContainerRef:jn,containerRef:bn,maintainRelativeOrder:Ze,proposedSections:wi,existingSections:_i,isSideBySideRef:tt,activeSideBySideSectionRef:rt,activeSideBySideRightSectionRef:ot,sectionRowRefs:Wi,sectionRightRowRefs:zi,sectionLeftRefs:Pi,sectionRightRefs:ji,subSectionLeftRefs:Mi,subSectionRightRefs:qi,lhsBadgeRefs:Ni,rhsBadgeRefs:Hi,leftContainerRef:Vn,rightContainerRef:Hn,calculateLinesRef:Tn,handleResizeRef:Dn,setIsResizing:Qi,setIsArrowVisible:Ui,sideBySideCacheRef:it,cachedConnectedPositions:In}).handleResize;u(function(){Dn.current=go},[go,Dn]),u(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Nn.current&&o.push(e(Nn.current,vo,n,function(){return Dn.current()},function(){})),jn.current&&o.push(e(jn.current,fo,i,function(){return Dn.current()},function(){return Tn.current()})),bn.current&&o.push(e(bn.current,po,t,function(){return Dn.current()},function(){return Tn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),u(function(){tt.current=Xi},[Xi]),u(function(){rt.current=et},[et]);var ho=c(function(){var e,n=Un.sectionIdx,i=Un.isOrphan;if(ti(),null!=n){var t="left";Un.anchorEl&&(null===(e=Hn.current)||void 0===e?void 0:e.contains(Un.anchorEl))&&(t="right"),St(n),st(n,i,{sourceSide:t})}},[st,Un.isOrphan,Un.sectionIdx,Un.anchorEl,ti]),mo=c(function(){ti(),at(),pn(new Set),mn([]),In.current=[]},[ti,at]),So=null!==Un.sectionIdx&&fn.has(Un.sectionIdx),xo=N({proposedSections:wi,existingSections:_i,parentDeviationRecord:Ei,expandedSections:vt,maintainRelativeOrder:!!Ze,scrollContainerRef:jn,leftContainerRef:Vn,rightContainerRef:Hn,lhsBadgeRefs:Ni,rhsBadgeRefs:Hi}),Ro=xo.showDeviationNavigation,yo=xo.showOpenNodeRef,bo=xo.adjustScrollForPopup,Co=c(function(e,n,i,t,o){var r,l="string"==typeof t?m(t).trim():m(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;ci();var c="left";(null===(r=Hn.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(y)){var r=n.split(y),l="".concat(r[0]).concat(y).concat(r[1]);return"right"===c?null===(e=Hi.current[l])||void 0===e?void 0:e.current:null===(i=Ni.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=Hi.current[n])||void 0===t?void 0:t.current:null===(o=Ni.current[n])||void 0===o?void 0:o.current};if(i)return at(),pn(new Set),mn([]),In.current=[],void(l&&(St(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));ii({open:!0,anchorEl:e,summary:t,displayImpact:o})})));St(n),l?setTimeout(function(){st(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,n,i,r=a()||u;if(r){var l=r.getBoundingClientRect();if(l.top>.8*window.innerHeight||l.top<100){var c=l.top-window.innerHeight/2;Ze?(null===(e=Vn.current)||void 0===e||e.scrollBy({top:c,behavior:"smooth"}),null===(n=Hn.current)||void 0===n||n.scrollBy({top:c,behavior:"smooth"})):null===(i=jn.current)||void 0===i||i.scrollBy({top:c,behavior:"smooth"})}}ii({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){st(n,i,{toggleIfSame:!1,sourceSide:c})},350)},[st,ci,ii,at,St]),wo=l(function(){var e;if(!Je)return null;var n=null===(e=null==Je?void 0:Je.id)||void 0===e?void 0:e.split(":")[0];for(var i in Ei){if((Ei[i]||[]).some(function(e){return e.id===n}))return i}return null},[Je,Ei]),_o=r({id:null,triggerMs:null}),Bo=r(null);u(function(){var i;if(null==Je?void 0:Je.id){var t=Number(Je.trigger),o=_o.current;if((null==o?void 0:o.triggerMs)!==t){if(!(Je.id.includes(":")&&/:\d+$/.test(Je.id)))return _o.current={id:Je.id,triggerMs:t},void Yt(Je.id);var r=null===(i=null==Je?void 0:Je.id)||void 0===i?void 0:i.split(":"),l=r[0],u=r[1],c=null!=u?u:"0";Bo.current!==Je.id&&(ti(),ci(),at(),pn(new Set),mn([]),In.current=[],Bo.current=Je.id);var a=!1,s=0,d=null,v=450,f=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},p=function(){var i,o,r,u;if(!a){var g=function(){_o.current={id:Je.id,triggerMs:t}},h=null,m=null;for(var S in Ei){var x=Ei[S].find(function(e){return e.id===l});if(x){h=S,m=x;break}}if(m&&h){var R=wi.findIndex(function(e){return e.id===h}),b=_i.findIndex(function(e){return e.id===h}),C=-1===R&&-1!==b,w=f(wi,m.id),_=f(_i,m.id);if(w&&!_&&!C){var B=w.split("-"),E=Number(B[0]);if(Ze){var F=null===(o=null===(i=wi[E])||void 0===i?void 0:i.refIndexes)||void 0===o?void 0:o[0],I=_i.findIndex(function(e){return e.selfIndex===F});-1!==I&&(E=I)}_=n([E],B.slice(1),!0).join("-")}if(w||_){var T=w?Number(w.split("-")[0]):R,A=_?Number(_.split("-")[0]):b,D=A>=0?A:_?Number(_.split("-")[0]):-1,O=wi[T],k=_i[D],L=O&&!O.title&&!O.content,P=k&&!k.title&&!k.content,j=C||(!w&&!!_||L&&!P);if(j){if(!(Ze?!!vt["right-".concat(A)]:!!vt[String(A)])&&A>=0)return mt(A,"right"),s+=1,void(d=setTimeout(p,450))}else if(!(Ze?!!vt["left-".concat(T)]:!!vt[String(T)])&&T>=0)return mt(T,"left"),s+=1,void(d=setTimeout(p,450));var N=w||"",H=_||"",z="".concat(m.id).concat(y).concat(c).concat(y).concat(N).concat(y).concat(H),M="".concat(m.id).concat(y).concat(c);St(z);var q,W=null===(r=Ni.current[M])||void 0===r?void 0:r.current,V=null===(u=Hi.current[M])||void 0===u?void 0:u.current,K=j||!W&&!!V,J=K?V:W;if(q=Ze?K?Hn.current:Vn.current:jn.current,J&&q){var Y=J.getBoundingClientRect();if(0===Y.height)return void((s+=1)<2?d=setTimeout(p,v):g());var X=q.getBoundingClientRect(),$=Y.top-X.top+q.scrollTop-X.height/2+Y.height/2,U=w&&w.includes("-")||_&&_.includes("-"),G=function(){var n,i,t,o,r;if(!a){g();var l=J instanceof Element?window.getComputedStyle(J).color:"";W&&(W.style.transition="box-shadow 300ms ease-in-out",W.style.boxShadow="0 0 10px ".concat(l)),V&&(V.style.transition="box-shadow 300ms ease-in-out",V.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){W&&(W.style.boxShadow=""),V&&(V.style.boxShadow="")},2e3);var u=(null===(i=null===(n=m.evaluationResult)||void 0===n?void 0:n.deviations)||void 0===i?void 0:i[c])||m,s=(null===(t=m.evaluationResult)||void 0===t?void 0:t.evaluation_outputs)||m.evaluation_outputs;if(!(!!W&&!!V)){var d=K?(null===(o=Hi.current[U?M:A])||void 0===o?void 0:o.current)||V:(null===(r=Ni.current[U?M:T])||void 0===r?void 0:r.current)||W;return bo(d,function(){ii({open:!0,anchorEl:d,displayImpact:Je.displayImpact,summary:e(e({},u),{evaluation_outputs:s})})},{skipScroll:!0}),void(null==Ye||Ye())}st(z,!1,{toggleIfSame:!1,sourceSide:C?"right":"left",onReady:function(){var n,i;g();var t=K?(null===(n=Hi.current[M])||void 0===n?void 0:n.current)||V:(null===(i=Ni.current[M])||void 0===i?void 0:i.current)||W;ii({open:!0,anchorEl:t,displayImpact:Je.displayImpact,summary:e({},u)}),null==Ye||Ye()}})}};Math.abs(q.scrollTop-$)<=2?G():(Kn.current=$,Jn.current=G,q.scrollTo({top:$,behavior:"smooth"}),d&&clearTimeout(d),d=setTimeout(function(){if(Jn.current){Kn.current=null;var e=Jn.current;Jn.current=null,e()}},800))}else(s+=1)<2?d=setTimeout(p,v):g()}else(s+=1)<2?d=setTimeout(p,v):g()}else(s+=1)<2?d=setTimeout(p,v):g()}};return d=setTimeout(p,v),function(){a=!0,d&&clearTimeout(d)}}}},[Je,Ei,wi,_i,Ze,vt,mt,st,ii,Yt]),u(function(){var n,i,t;if(ni.open){var o=ni.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(Ni.current)||r(Hi.current);if(l){var u=(null===(i=Hi.current[l])||void 0===i?void 0:i.current)||(null===(t=Ni.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&ii(function(n){return e(e({},n),{anchorEl:u})})}}}},[ni.open,ni.anchorEl,xn,fn,vt]);var Eo=Xn.open,Fo=Xn.sectionIdx,Io=Xn.isOrphan,To=Xn.badgeStyle,Ao=Xn.anchorEl,Do=Xn.sectionAnchorEl;u(function(){var n;if(Eo&&null!=Fo&&Fo!==_t){var i="string"==typeof Fo?Fo.split(y)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(wi,i):null,r=i&&"string"==typeof i?t(_i,i):null,l="number"==typeof Fo?wi[Fo]||null:o||i&&((null===(n=null==ke?void 0:ke.nodes)||void 0===n?void 0:n[i])||(null==ke?void 0:ke[i]))||null,u="number"==typeof Fo?_i[Fo]||null:r,c=Wt(Ao,l,u,Fo,Io,To);$n(function(n){return n.open?m(n.cognitiveData)===m(c.cognitiveData)&&m(n.deviationData)===m(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Eo,Fo,Io,To,Ao,Do,wi,_i,Wt]);var Oo=c(function(e){var n=e.section,t=e.keyPath,o=e.depth,r=void 0===o?0:o,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset;return i(z,{section:n,keyPath:t,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s})},[]),ko=l(function(){return wi.map(function(e,n){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Ze?null:i(M,{section:e,idx:n},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[wi]),Lo=l(function(){return _i.map(function(e,n){var t,o=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return o&&r&&Ze?null:i(q,{section:e,idx:n},null!==(t=null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[_i]),Po=r(Vt);u(function(){Po.current=Vt},[Vt]);var jo=r(Co);u(function(){jo.current=Co},[Co]);var No=r(mo);u(function(){No.current=mo},[mo]);var Ho=r(mt);u(function(){Ho.current=mt},[mt]);var zo=r(ht);u(function(){zo.current=ht},[ht]);var Mo=r(Oo);u(function(){Mo.current=Oo},[Oo]);var qo=r(at);u(function(){qo.current=at},[at]);var Wo=l(function(){return{maintainRelativeOrder:!!Ze,showDeviationBadges:on,isProposingFix:$e,proposingFixNodeId:Ue,isRedlineFlow:Ge,isSideBySide:Xi,activeSideBySideSection:et,scrollSyncLocked:xn,toggleScrollSyncLocked:Rt,summaryPopupAnchorEl:ni.anchorEl,connectedSections:fn,proposedSections:wi,existingSections:_i,deviationNumberRegistry:Fi,deviationParentRegistry:Ii,treeData:ke,displayConfig:Me,resolvedMarkdownStyles:Pn,unifiedNumbering:yt,expandedSections:vt,expandedSubSections:pt,setExpandedSubSections:gt,getSectionCompareStyle:Qt,getSubSectionCompareStyle:Zt,getBadgeRef:Ji,getSectionRowRef:Vi,getSubSectionRef:Ki,sectionLeftRefs:Pi,sectionRightRefs:ji,sectionRowRefs:Wi,sectionRightRowRefs:zi,subSectionLeftRefs:Mi,subSectionRightRefs:qi,lhsBadgeRefs:Ni,rhsBadgeRefs:Hi,openMoreFunctionsPopup:At,handleOpenSummaryPopup:Dt,openSummaryPopup:Dt,handleCloseSummaryPopup:Ot,toggleSection:kt,handleSubSectionToggle:Lt,renderSubSectionAccordion:Pt,resetSideBySide:jt,setConnectedSections:pn,setConnectedLines:mn,cachedConnectedPositions:In,showDeviationNavigation:Ro,showOpenNodeRef:yo,deviationNodeIdToView:null==Je?void 0:Je.id,deviationTargetParentId:wo}},[Ze,on,$e,Ue,Ge,Xi,et,xn,Rt,ni.anchorEl,fn,wi,_i,Fi,Me,Pn,yt,vt,pt,gt,Qt,Zt,Ji,Vi,Ki,Ro,yo,Je,wo]);return i(V,e({value:Wo},{children:t(a,e({ref:Nn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[ln&&i(a,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(D,{})})),ni.open&&i(W,{open:ni.open,anchorEl:ni.anchorEl,containerEl:$t.current,clipTopEl:Cn.current,scrollContainerEl:jn.current,onClose:mo,summary:ni.summary,displayImpact:ni.displayImpact,isScrollLocked:xn}),i(A,{open:Un.open,anchorEl:Un.anchorEl,maintainRelativeOrder:!!Ze,sectionTitle:Un.sectionTitle,referenceSectionTitle:Un.refSectionTitle,onClose:ai,onOpenCognitiveCompare:li,onOpenSideBySide:ho,onConnect:Kt,isConnected:So,isOrphan:Un.isOrphan}),Xn.open&&i(T,{open:Xn.open,popupRef:ri,position:Qn,popupConfig:We,onClose:function(){Zn(null),$n(function(n){return e(e({},n),{open:!1})}),oi(null)},markdownStyles:Ne,sectionTitle:mi,referenceSectionTitle:xi,cognitiveData:Xn.cognitiveData,anchorEl:Xn.anchorEl,sectionAnchorEl:Xn.sectionAnchorEl,scrollContainerEl:jn.current,badgeStyle:Xn.badgeStyle,docData:Xn.docData,deviationData:Xn.deviationData,isLoading:Xn.isLoading}),i(s,e({open:!!an,autoHideDuration:8e3,onClose:function(){return sn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(d,e({onClose:function(){return sn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:an}))})),i(H,{componentHeaderText:Oe,displayConfig:Me,maintainRelativeOrder:Ze,onCollapseAll:co,showCollapseAll:ao,onToggleView:function(e){un(!0),setTimeout(function(){en(!e),null==qe||qe(!e),Rn(!1),at(),ti(),pn(new Set),mn([]),In.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){un(!1)},600)})})},50)}}),i(a,e({ref:jn,onScroll:uo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:Ze?"visible":"auto",borderTop:Ct&&wt?"none":"1.5px solid #EEF0F4"}},{children:i(a,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},Ze?{flex:1}:{})},{children:t(a,e({ref:bn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},Ze?{flex:1,overflow:"visible"}:{})},{children:[i($,{svgContainerRef:yn,svgDimensions:lo,isResizing:Gi,overallConnector:oo,rootDeviationStyle:Ft,lines:io,isSideBySide:Xi,activeSideBySideSection:et,isArrowVisible:$i,maintainRelativeOrder:Ze,proposedSections:wi,existingSections:_i,cognitivePopup:Xn,activeBadgeId:ei,closeCognitivePopup:ci,setActiveBadgeId:oi,openCognitivePopupFromState:ui,buildSectionPopupState:Wt,connectedLines:hn,pathRefs:Fn}),t(a,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},Ze?{flex:1,overflow:"visible"}:{})},{children:[i(a,e({ref:Cn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:i(v,e({title:gi,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:gi}))}))})),t(a,e({ref:Vn,onScroll:uo,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ze?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:qn,style:{width:"100%",height:"0px",flexShrink:0}}),Ai&&ko,i("div",{ref:Wn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(a,e({ref:$t,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(a,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(a,e({onClick:function(n){n.stopPropagation(),Xn.open&&ei===_t?ci():(oi(_t),ui(Wt(n.currentTarget,{title:"",content:"",evaluationResult:Bt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,_t,!0,e(e({},Ft),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Ft.badgeBg,color:Ft.badgeText,border:"1px solid ".concat(Ft.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Et?Et:i(O,{}),i(a,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(g,{})})),i(p,{size:11,style:{transform:Xn.open&&ei===_t?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(a,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},Ze?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Zi&&i(h,{sections:11}),i(a,e({ref:wn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(v,e({title:Ri,placement:"top"},{children:i(f,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ri}))}))})),t(a,e({ref:Hn,onScroll:uo,sx:e({p:"12px",display:"flex",flexDirection:"column"},Ze?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:zn,style:{width:"100%",height:"0px",flexShrink:0}}),Ai&&Lo,i("div",{ref:Mn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{U as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n}from"tslib";import{jsxs as e,jsx as i}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as r,AccordionSummary as d,Tooltip as a,Typography as c,AccordionDetails as u}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{useCompareContext as p}from"../CompareContext.js";import{hasValue as h,hasMeaningfulRedlineTags as g,stripRedlineTags as m,generateColorPalette as x,isMissingStr as I,safeStringify as b,DEVIATION_BADGE_SEPARATOR as y}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";var S=function(S){var _,k,F,R,B,C,M,A,O,W,T,j,E,N=S.section,P=S.idx,D=S.columnKey,K=S.colRef,L=S.mb,z=void 0===L?1:L,V=S.isExpanded,G=S.onToggle,H=S.navigation,X=S.parentNodeId,Y=void 0===X?"":X,q=p(),J=q.showOpenNodeRef,Q=q.resolvedMarkdownStyles,U=q.maintainRelativeOrder,Z=q.showDeviationBadges,$=void 0!==Z&&Z,nn=q.renderSubSectionAccordion,en=q.treeData,on=q.proposedSections,tn=q.existingSections,ln=q.deviationNumberRegistry,rn=q.getBadgeRef,dn=q.openSummaryPopup,an=q.getSectionCompareStyle,cn=q.connectedSections,un=q.openMoreFunctionsPopup;q.deviationNodeIdToView,q.deviationTargetParentId;var sn=q.isProposingFix,vn=q.proposingFixNodeId,fn=q.isRedlineFlow,pn=q.isSideBySide,hn=q.activeSideBySideSection,gn=q.scrollSyncLocked,mn=q.toggleScrollSyncLocked,xn=q.summaryPopupAnchorEl,In="".concat(pn?"1":"0","-").concat(String(null!=hn?hn:"")),bn=(null===(_=N.displayTitle)||void 0===_||_)&&h(N.title),yn=!!sn&&!!vn&&"left"===D&&N.id===vn,wn=g(N.content),Sn="boolean"==typeof fn?fn:wn,_n=wn,kn=Sn&&wn,Fn=kn?m(N.content):N.content,Rn=kn?N.content:void 0,Bn=(null===(k=N.displayContent)||void 0===k||k||wn)&&h(N.content),Cn=!bn&&!Bn,Mn=N.title;bn||(Mn=Bn?"No Title Found":"No Matching Section Found");var An=N.evaluationResult;if(!An&&"right"===D)if(U){var On=null===(F=N.refIndexes)||void 0===F?void 0:F[0],Wn=on.find(function(n){return n.selfIndex===On});An=null==Wn?void 0:Wn.evaluationResult}else An=null===(R=on[P])||void 0===R?void 0:R.evaluationResult;var Tn=null===(B=null==en?void 0:en.input_index_map)||void 0===B?void 0:B[0],jn=null===(C=null==en?void 0:en.input_index_map)||void 0===C?void 0:C[1],En="left"===D?jn:Tn,Nn=function(n,e){var i;if(!e||!n)return null;for(var o=0,t=n;o<t.length;o++){var l=t[o];if(l.id===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var r=Nn(l.subsections,e);if(r)return r}}return null},Pn="left"===D?N:Nn(on,N.id),Dn="right"===D?N:Nn(tn,N.id),Kn=o.useMemo(function(){if(!U)return 0;var n=1/0,e=function(i,o,t,l){var r;if(i){var d=i.id;if(l&&"right"===D){var a=on.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(i.selfIndex)});a.length>0&&(d=a[0].id)}var c=i.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),u=(null===(r=i.evaluationResult)||void 0===r?void 0:r.deviations)||{};Object.keys(u).forEach(function(e){var i="".concat(d).concat(y).concat(e),o=null==ln?void 0:ln[i];null!=o&&o<n&&(n=o);var t="".concat(c).concat(y).concat(e),l=null==ln?void 0:ln[t];null!=l&&l<n&&(n=l)});for(var s=i.subsections||[],v=(null==o?void 0:o.subsections)||[],f=(null==t?void 0:t.subsections)||[],p=Math.max(s.length,v.length,f.length),h=0;h<p;h++)e(s[h],v[h],f[h],!1)}};return e(N,Pn,Dn,!0),n!==1/0?n-1:0},[N,Pn,Dn,D,ln,U,on]);if(U)if("left"===D){var Ln=null===(M=N.refIndexes)||void 0===M?void 0:M[0],zn=tn.findIndex(function(n){return n.selfIndex===Ln});Dn=-1!==zn?tn[zn]:Nn(tn,N.id)}else{var Vn=null===(A=N.refIndexes)||void 0===A?void 0:A[0],Gn=on.findIndex(function(n){return n.selfIndex===Vn});Pn=-1!==Gn?on[Gn]:Nn(on,N.id)}var Hn="left"===D?!Dn:!Pn,Xn=An||(null==Pn?void 0:Pn.evaluationResult)||(null==Dn?void 0:Dn.evaluationResult),Yn=null!==(T=null===(W=null===(O=null==Xn?void 0:Xn.evaluation_outputs)||void 0===O?void 0:O.metadata)||void 0===W?void 0:W.label_color)&&void 0!==T?T:w,qn=x(Yn).highlightBg,Jn=(null==Xn?void 0:Xn.deviations)||{},Qn=P+1,Un=N.id;if(U){var Zn=1,$n=new Map;if(on.forEach(function(n){!n.title&&!n.content||n.id&&$n.set(n.id,Zn++)}),"left"===D)Qn=$n.get(N.id)||P+1;else{var ne=on.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(N.selfIndex)});if(ne.length>0)Qn=$n.get(ne[0].id)||P+1,Un=ne[0].id;else for(var ee=Zn,ie=function(n){if(!n.title&&!n.content)return"continue";var e=on.some(function(e){var i;return null===(i=e.refIndexes)||void 0===i?void 0:i.includes(n.selfIndex)});if(!e){if(n.id===N.id)return Qn=ee,"break";ee++}},oe=0,te=tn;oe<te.length;oe++){if("break"===ie(te[oe]))break}}}var le=Object.entries(Jn).map(function(n){var e=n[0],i=n[1],o="".concat(Un).concat(y).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:ln[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});le.sort(function(n,e){return n.currentIndex-e.currentIndex});var re,de=le.map(function(e){var i,o,t,l,r,d,a=e.deviationKey,c=e.deviationMap,u=e.refId,s=e.currentIndex;U&&void 0!==Kn&&(s-=Kn);var v=c[Y],f=I(v);if(f)v="";else if(!v)return null;var p=P,h=P;if(U)if("left"===D){var g=null===(i=N.refIndexes)||void 0===i?void 0:i[0],m=tn.findIndex(function(n){return n.selfIndex===g});if(-1!==m)h=m;else{var b=tn.findIndex(function(n){return n.id===N.id});h=-1!==b?b:P}}else{var w=null===(o=N.refIndexes)||void 0===o?void 0:o[0],S=on.findIndex(function(n){return n.selfIndex===w});if(-1!==S)p=S;else{var _=on.findIndex(function(n){return n.id===N.id});p=-1!==_?_:P}}var k="".concat(Un).concat(y).concat(a).concat(y).concat(p).concat(y).concat(h),F=c[En],R=Hn||I(F),B="".concat(Qn,".").concat(s),C=P;if("right"===D&&U){var M=null===(t=N.refIndexes)||void 0===t?void 0:t[0],A=on.findIndex(function(n){return n.selfIndex===M});if(-1!==A)C=A;else{_=on.findIndex(function(n){return n.id===N.id});-1!==_&&(C=_)}}var O=an?an(C):null,W=(null==c?void 0:c.evaluation_outputs)||(null==Xn?void 0:Xn.evaluation_outputs),T=null!==(l=null==W?void 0:W.output_value)&&void 0!==l?l:null,j=null!==(d=null===(r=null==W?void 0:W.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:Yn,E=x(j),K=O?n(n({},O),{badgeBg:E.badgeBg,badgeBorder:E.badgeBorder,badgeText:E.badgeText}):n({},E),L=(null==c?void 0:c.deviation_summary)?{deviation_summary:c.deviation_summary,deviation_title:(null==c?void 0:c.deviation_title)||(null==Xn?void 0:Xn.deviation_title),deviation_impact:(null==c?void 0:c.deviation_impact)||(null==Xn?void 0:Xn.deviation_impact),deviation_explanation:(null==c?void 0:c.deviation_explanation)||(null==Xn?void 0:Xn.deviation_explanation),evaluation_outputs:W,cognitive_decisioning:(null==c?void 0:c.cognitive_decisioning)||(null==Xn?void 0:Xn.cognitive_decisioning)}:null,z=0,V=Fn||"";if(v&&V){var G=V.split(/\n{2,}/),H=G.findIndex(function(n){return n.includes(v)});if(-1!==H){var X=Object.entries(Jn).filter(function(n){n[0];var e=n[1][Y];return e&&G[H].includes(e)}).sort(function(n,e){return G[H].indexOf(n[1][Y])-G[H].indexOf(e[1][Y])}),q=X.filter(function(n){n[0];var e=n[1][Y];return e&&(e.includes(v)||v.includes(e))});q.length>1&&(z=Math.max(0,q.findIndex(function(n){return n[0]===a})))}}var J=rn(D,u);return{id:u,actionId:k,label:B,highlight:v,side:D,style:K,stackIndex:z,score:T,isConnected:null==cn?void 0:cn.has(k),showScrollLockToggle:(null==cn?void 0:cn.has(k))||pn&&hn===k||!!xn&&xn===J.current,scrollSyncLocked:gn,toggleScrollSyncLocked:mn,isOrphan:R,isMissingClause:f,badgeRef:J,onClick:function(n){n.stopPropagation(),un&&un(n,Pn||{id:"orphan-left",title:"",content:""},R,Dn||{id:"orphan-right",title:"",content:""},k,K)},onSummaryClick:function(n){n.stopPropagation(),dn(n,k,R,L)}}}).filter(Boolean),ae=$||!Sn&&yn?de:[],ce=de.map(function(n){return n.highlight}).filter(Boolean),ue=N.id&&D===(null==H?void 0:H.columnKey)?H:null,se=o.useRef(!1);return t(function(){V||(se.current=!1)},[V]),e(l,n({ref:K,sx:{mb:z,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[V&&(null==ue?void 0:ue.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ue?void 0:ue.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===D?{right:"0px"}:{left:"0px"})},{children:i(s,{color:(null===(j=null==ue?void 0:ue.showAboveRef)||void 0===j?void 0:j.current)?window.getComputedStyle(ue.showAboveRef.current).color:void 0})}))})),e(r,n({disableGutters:!0,expanded:!Cn&&V,onChange:function(){Cn||(G(),J.current=N.id)},sx:{boxShadow:"none",border:Cn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Cn?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[i(d,n({expandIcon:Cn?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Cn?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:bn&&i(a,n({title:Mn,placement:"top"},{children:i(c,n({component:"div",sx:{fontSize:"12px",color:Cn?"#94A3B8":"#19213D",fontWeight:Cn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(re=Mn,re?b(re).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,e){return n.startsWith("**")&&n.endsWith("**")?i("strong",{children:n.slice(2,-2)},e):i(o.Fragment,{children:n},e)}):null)}))}))})),!Cn&&e(u,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Bn&&i(f,{content:Fn,overlayContent:Rn,sxStyles:Q,highlights:ce,maintainRelativeOrder:U,highlightBg:qn,suppressHighlightBg:_n,deviationBadges:ae,collisionKey:In}),(N.subsections||[]).map(function(n,e){return nn({section:n,keyPath:"".concat(P,"-").concat(e),depth:0,columnKey:D,parentNodeId:Y,sectionOffset:Kn})})]}))]})),V&&(null==ue?void 0:ue.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ue?void 0:ue.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:i("div",n({style:n({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===D?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===D?{right:"0px"}:{left:"0px"})},{children:i(v,{color:(null===(E=null==ue?void 0:ue.showBelowRef)||void 0===E?void 0:E.current)?window.getComputedStyle(ue.showBelowRef.current).color:void 0})}))}))]}),"".concat(D,"-sec-").concat(P))};export{S as default};
|
|
1
|
+
import{__assign as n}from"tslib";import{jsxs as e,jsx as i}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as d,AccordionSummary as r,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 x,hasMeaningfulRedlineTags as h,stripRedlineTags as g,generateColorPalette as m,isMissingStr as I,safeStringify as y,DEVIATION_BADGE_SEPARATOR as b}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";var S=function(S){var _,F,k,R,B,C,M,A,O,W,j,P,E,N=S.section,T=S.idx,D=S.columnKey,K=S.colRef,L=S.mb,z=void 0===L?1:L,G=S.isExpanded,H=S.onToggle,V=S.navigation,X=S.parentNodeId,Y=void 0===X?"":X,q=p(),J=q.showOpenNodeRef,Q=q.resolvedMarkdownStyles,U=q.maintainRelativeOrder,Z=q.showDeviationBadges,$=void 0!==Z&&Z,nn=q.renderSubSectionAccordion,en=q.treeData,on=q.proposedSections,tn=q.existingSections,ln=q.deviationNumberRegistry,dn=q.deviationParentRegistry,rn=q.getBadgeRef,an=q.openSummaryPopup,cn=q.getSectionCompareStyle,un=q.connectedSections,sn=q.openMoreFunctionsPopup,vn=q.isProposingFix,fn=q.proposingFixNodeId,pn=q.isRedlineFlow,xn=q.isSideBySide,hn=q.activeSideBySideSection,gn=q.scrollSyncLocked,mn=q.toggleScrollSyncLocked,In=q.summaryPopupAnchorEl,yn="".concat(xn?"1":"0","-").concat(String(null!=hn?hn:"")),bn=(null===(_=N.displayTitle)||void 0===_||_)&&x(N.title),wn=!!vn&&!!fn&&"left"===D&&N.id===fn,Sn=h(N.content),_n="boolean"==typeof pn?pn:Sn,Fn=Sn,kn=_n&&Sn,Rn=kn?g(N.content):N.content,Bn=kn?N.content:void 0,Cn=(null===(F=N.displayContent)||void 0===F||F||Sn)&&x(N.content),Mn=!bn&&!Cn,An=N.title;bn||(An=Cn?"No Title Found":"No Matching Section Found");var On=N.evaluationResult;if(!On&&"right"===D)if(U){var Wn=null===(k=N.refIndexes)||void 0===k?void 0:k[0],jn=on.find(function(n){return n.selfIndex===Wn});On=null==jn?void 0:jn.evaluationResult}else On=null===(R=on[T])||void 0===R?void 0:R.evaluationResult;var Pn=null===(B=null==en?void 0:en.input_index_map)||void 0===B?void 0:B[0],En=null===(C=null==en?void 0:en.input_index_map)||void 0===C?void 0:C[1],Nn="left"===D?En:Pn,Tn=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 d=Tn(l.subsections,e);if(d)return d}}return null},Dn="left"===D?N:Tn(on,N.id),Kn="right"===D?N:Tn(tn,N.id),Ln=o.useMemo(function(){if(!U)return 0;var n=1/0,e=function(i,o,t,l){var d;if(i){var r=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&&(r=a[0].id)}var c=i.id||(null==o?void 0:o.id)||(null==t?void 0:t.id),u=(null===(d=i.evaluationResult)||void 0===d?void 0:d.deviations)||{};Object.keys(u).forEach(function(e){var i="".concat(r).concat(b).concat(e),o=null==ln?void 0:ln[i];null!=o&&o<n&&(n=o);var t="".concat(c).concat(b).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),x=0;x<p;x++)e(s[x],v[x],f[x],!1)}};return e(N,Dn,Kn,!0),n!==1/0?n-1:0},[N,Dn,Kn,D,ln,U,on]);if(U)if("left"===D){var zn=null===(M=N.refIndexes)||void 0===M?void 0:M[0],Gn=tn.findIndex(function(n){return n.selfIndex===zn});Kn=-1!==Gn?tn[Gn]:Tn(tn,N.id)}else{var Hn=null===(A=N.refIndexes)||void 0===A?void 0:A[0],Vn=on.findIndex(function(n){return n.selfIndex===Hn});Dn=-1!==Vn?on[Vn]:Tn(on,N.id)}var Xn="left"===D?!Kn:!Dn,Yn=On||(null==Dn?void 0:Dn.evaluationResult)||(null==Kn?void 0:Kn.evaluationResult),qn=null!==(j=null===(W=null===(O=null==Yn?void 0:Yn.evaluation_outputs)||void 0===O?void 0:O.metadata)||void 0===W?void 0:W.label_color)&&void 0!==j?j:w,Jn=m(qn).highlightBg,Qn=(null==Yn?void 0:Yn.deviations)||{},Un=N.id;if(U&&"left"!==D){var Zn=on.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(N.selfIndex)});Zn.length>0?Un=Zn[0].id:(null==Dn?void 0:Dn.id)&&(Un=Dn.id)}var $n=Object.keys(Qn)[0],ne=$n?"".concat(Un).concat(b).concat($n):null,ee=ne?null==dn?void 0:dn[ne]:null,ie=null!=ee?ee:T+1;if(null==ee&&U)if("left"===D)ie=void 0!==N.selfIndex&&N.selfIndex>=0?N.selfIndex+1:T+1;else{Zn=on.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(N.selfIndex)});ie=Zn.length>0?void 0!==Zn[0].selfIndex&&Zn[0].selfIndex>=0?Zn[0].selfIndex+1:T+1:void 0!==N.selfIndex&&N.selfIndex>=0?N.selfIndex+1:T+1}var oe=Object.entries(Qn).map(function(n){var e=n[0],i=n[1],o="".concat(Un).concat(b).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:ln[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});oe.sort(function(n,e){return n.currentIndex-e.currentIndex});var te,le=oe.map(function(e){var i,o,t,l,d,r,a=e.deviationKey,c=e.deviationMap,u=e.refId,s=e.currentIndex;U&&void 0!==Ln&&(s-=Ln);var v=c[Y],f=I(v);if(f)v="";else if(!v)return null;var p=T,x=T;if(U)if("left"===D){var h=null===(i=N.refIndexes)||void 0===i?void 0:i[0],g=tn.findIndex(function(n){return n.selfIndex===h});if(-1!==g)x=g;else{var y=tn.findIndex(function(n){return n.id===N.id});x=-1!==y?y:T}}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 p=-1!==(C=on.findIndex(function(n){return n.id===N.id}))?C:T}var _="".concat(Un).concat(b).concat(a).concat(b).concat(p).concat(b).concat(x),F=c[Nn],k=Xn||I(F),R="".concat(ie,".").concat(s),B=T;if("right"===D&&U){var C,M=null===(t=N.refIndexes)||void 0===t?void 0:t[0],A=on.findIndex(function(n){return n.selfIndex===M});if(-1!==A)B=A;else-1!==(C=on.findIndex(function(n){return n.id===N.id}))&&(B=C)}var O=cn?cn(B):null,W=(null==c?void 0:c.evaluation_outputs)||(null==Yn?void 0:Yn.evaluation_outputs),j=null!==(l=null==W?void 0:W.output_value)&&void 0!==l?l:null,P=null!==(r=null===(d=null==W?void 0:W.metadata)||void 0===d?void 0:d.label_color)&&void 0!==r?r:qn,E=m(P),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==Yn?void 0:Yn.deviation_title),deviation_impact:(null==c?void 0:c.deviation_impact)||(null==Yn?void 0:Yn.deviation_impact),deviation_explanation:(null==c?void 0:c.deviation_explanation)||(null==Yn?void 0:Yn.deviation_explanation),evaluation_outputs:W,cognitive_decisioning:(null==c?void 0:c.cognitive_decisioning)||(null==Yn?void 0:Yn.cognitive_decisioning)}:null,z=0,G=Rn||"";if(v&&G){var H=G.split(/\n{2,}/),V=H.findIndex(function(n){return n.includes(v)});if(-1!==V){var X=Object.entries(Qn).filter(function(n){n[0];var e=n[1][Y];return e&&H[V].includes(e)}).sort(function(n,e){return H[V].indexOf(n[1][Y])-H[V].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:_,label:R,highlight:v,side:D,style:K,stackIndex:z,score:j,isConnected:null==un?void 0:un.has(_),showScrollLockToggle:(null==un?void 0:un.has(_))||xn&&hn===_||!!In&&In===J.current,scrollSyncLocked:gn,toggleScrollSyncLocked:mn,isOrphan:k,isMissingClause:f,badgeRef:J,onClick:function(n){n.stopPropagation(),sn&&sn(n,Dn||{id:"orphan-left",title:"",content:""},k,Kn||{id:"orphan-right",title:"",content:""},_,K)},onSummaryClick:function(n){n.stopPropagation(),an(n,_,k,L)}}}).filter(Boolean),de=$||!_n&&wn?le:[],re=le.map(function(n){return n.highlight}).filter(Boolean),ae=N.id&&D===(null==V?void 0:V.columnKey)?V:null,ce=o.useRef(!1);return t(function(){G||(ce.current=!1)},[G]),e(l,n({ref:K,sx:{mb:z,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[G&&(null==ae?void 0:ae.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ae?void 0:ae.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:"-20px"}:{left:"-20px"})},{children:i(s,{color:(null===(P=null==ae?void 0:ae.showAboveRef)||void 0===P?void 0:P.current)?window.getComputedStyle(ae.showAboveRef.current).color:void 0})}))})),e(d,n({disableGutters:!0,expanded:!Mn&&G,onChange:function(){Mn||(H(),J.current=N.id)},sx:{boxShadow:"none",border:Mn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Mn?"#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(r,n({expandIcon:Mn?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Mn?"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:An,placement:"top"},{children:i(c,n({component:"div",sx:{fontSize:"12px",color:Mn?"#94A3B8":"#19213D",fontWeight:Mn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(te=An,te?y(te).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)}))}))})),!Mn&&e(u,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Cn&&i(f,{content:Rn,overlayContent:Bn,sxStyles:Q,highlights:re,maintainRelativeOrder:U,highlightBg:Jn,suppressHighlightBg:Fn,deviationBadges:de,collisionKey:yn}),(N.subsections||[]).map(function(n,e){return nn({section:n,keyPath:"".concat(T,"-").concat(e),depth:0,columnKey:D,parentNodeId:Y,sectionOffset:Ln})})]}))]})),G&&(null==ae?void 0:ae.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ae?void 0:ae.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:"-20px"}:{left:"-20px"})},{children:i(v,{color:(null===(E=null==ae?void 0:ae.showBelowRef)||void 0===E?void 0:E.current)?window.getComputedStyle(ae.showBelowRef.current).color:void 0})}))}))]}),"".concat(D,"-sec-").concat(T))};export{S as default};
|
|
2
2
|
//# sourceMappingURL=SectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n}from"tslib";import{jsx as i,jsxs as e}from"react/jsx-runtime";import t from"react";import{Box as o,Accordion as l,AccordionSummary as d,Typography as r,AccordionDetails as a}from"@mui/material";import{ChevronDown as u}from"lucide-react";import{MemoizedMarkdown as c}from"../hooks/memoizedMarkdown.js";import{useCompareContext as s}from"../CompareContext.js";import{hasValue as v,hasMeaningfulRedlineTags as f,stripRedlineTags as p,generateColorPalette as h,isMissingStr as m,DEVIATION_BADGE_SEPARATOR as g}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as x}from"../CognitiveCompareConstants.js";var y=t.memo(function(t){var S,b,
|
|
1
|
+
import{__assign as n}from"tslib";import{jsx as i,jsxs as e}from"react/jsx-runtime";import t from"react";import{Box as o,Accordion as l,AccordionSummary as d,Typography as r,AccordionDetails as a}from"@mui/material";import{ChevronDown as u}from"lucide-react";import{MemoizedMarkdown as c}from"../hooks/memoizedMarkdown.js";import{useCompareContext as s}from"../CompareContext.js";import{hasValue as v,hasMeaningfulRedlineTags as f,stripRedlineTags as p,generateColorPalette as h,isMissingStr as m,DEVIATION_BADGE_SEPARATOR as g}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as x}from"../CognitiveCompareConstants.js";var y=t.memo(function(t){var S,I,b,_,k,C,P,w,B,F,R=t.section,O=t.keyPath,j=t.depth,M=void 0===j?0:j,E=t.columnKey,N=void 0===E?"left":E,K=t.parentNodeId,W=void 0===K?"":K,L=t.sectionOffset,z=s(),A=z.expandedSubSections,D=z.setExpandedSubSections,H=z.maintainRelativeOrder,T=z.showDeviationBadges,G=void 0!==T&&T,U=z.proposedSections,q=z.existingSections,J=z.treeData,Q=z.deviationNumberRegistry,V=z.deviationParentRegistry,X=z.connectedSections,Y=z.activeSideBySideSection,Z=z.isSideBySide,$=z.scrollSyncLocked,nn=z.toggleScrollSyncLocked,en=z.summaryPopupAnchorEl,tn=z.resolvedMarkdownStyles,on=z.getSubSectionRef,ln=z.getSubSectionCompareStyle,dn=z.getBadgeRef,rn=z.openMoreFunctionsPopup,an=z.openSummaryPopup,un=z.resetSideBySide,cn=z.setConnectedSections,sn=z.setConnectedLines,vn=z.cachedConnectedPositions,fn=z.isProposingFix,pn=z.proposingFixNodeId,hn=z.isRedlineFlow,mn=null!=Y?Y:"",gn=(null===(S=R.displayTitle)||void 0===S||S)&&v(R.title),xn=!!fn&&!!pn&&"left"===N&&R.id===pn,yn=f(R.content),Sn="boolean"==typeof hn?hn:yn,In=yn,bn=Sn&&yn,_n=bn?p(R.content):R.content,kn=bn?R.content:void 0,Cn=(null===(I=R.displayContent)||void 0===I||I||yn)&&v(R.content),Pn=!gn&&!Cn,wn=gn?R.title:Cn?"No Title Found":"No Matching Section Found",Bn=!!A[O],Fn=on(N,O),Rn=O.split("-").map(Number)[0],On=U[Rn],jn=q[Rn],Mn=Rn,En=Rn,Nn=function(n,i,e){if(!n||!i)return null;if(n.id===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(H)if("left"===N){var Kn=null===(b=null==On?void 0:On.refIndexes)||void 0===b?void 0:b[0],Wn=q.findIndex(function(n){return n.selfIndex===Kn});-1!==Wn&&(jn=q[Wn],En=Wn)}else{var Ln=null===(_=null==jn?void 0:jn.refIndexes)||void 0===_?void 0:_[0],zn=U.findIndex(function(n){return n.selfIndex===Ln});-1!==zn&&(On=U[zn],Mn=zn)}var An=function(n,i){if(!i||!n)return null;for(var e=0;e<n.length;e++){var t=Nn(n[e],i,String(e));if(t)return t}return null},Dn=null,Hn=null,Tn="",Gn="";if(H)"left"===N?(Dn=R,Tn=O,(Un=Nn(jn,R.id,String(En)))||(Un=An(q,R.id)),Hn=(null==Un?void 0:Un.section)||null,Gn=(null==Un?void 0:Un.keyPath)||""):(Hn=R,Gn=O,(qn=Nn(On,R.id,String(Mn)))||(qn=An(U,R.id)),Dn=(null==qn?void 0:qn.section)||null,Tn=(null==qn?void 0:qn.keyPath)||"");else if("left"===N){Dn=R,Tn=O;var Un=An(q,R.id);Hn=(null==Un?void 0:Un.section)||null,Gn=(null==Un?void 0:Un.keyPath)||""}else{Hn=R,Gn=O;var qn=An(U,R.id);Dn=(null==qn?void 0:qn.section)||null,Tn=(null==qn?void 0:qn.keyPath)||""}var Jn=(Tn?ln(Tn):null)||ln(O),Qn=null===(k=null==J?void 0:J.input_index_map)||void 0===k?void 0:k[0],Vn=null===(C=null==J?void 0:J.input_index_map)||void 0===C?void 0:C[1],Xn="left"===N?Vn:Qn,Yn="left"===N?!Hn:!Dn,Zn=R.evaluationResult||(null==Dn?void 0:Dn.evaluationResult)||(null==Hn?void 0:Hn.evaluationResult),$n=(null==Zn?void 0:Zn.deviations)||{},ni=R.id||(null==Dn?void 0:Dn.id)||(null==Hn?void 0:Hn.id);H&&"left"!==N&&(null==Dn?void 0:Dn.id)&&(ni=Dn.id);var ii=Object.keys($n)[0],ei=ii?"".concat(ni).concat(g).concat(ii):null,ti=ei?null==V?void 0:V[ei]:null,oi=null!=ti?ti:Rn+1;if(null==ti&&H)if("left"===N)oi=void 0!==(null==On?void 0:On.selfIndex)&&On.selfIndex>=0?On.selfIndex+1:Rn+1;else{var li=U.filter(function(n){var i;return null===(i=n.refIndexes)||void 0===i?void 0:i.includes(null==jn?void 0:jn.selfIndex)});oi=li.length>0?void 0!==li[0].selfIndex&&li[0].selfIndex>=0?li[0].selfIndex+1:Rn+1:void 0!==(null==jn?void 0:jn.selfIndex)&&jn.selfIndex>=0?jn.selfIndex+1:Rn+1}var di=null!==(B=null===(w=null===(P=null==Zn?void 0:Zn.evaluation_outputs)||void 0===P?void 0:P.metadata)||void 0===w?void 0:w.label_color)&&void 0!==B?B:x,ri=h(di).highlightBg,ai=Object.entries($n).map(function(n){var i=n[0],e=n[1],t="".concat(ni).concat(g).concat(i);return{deviationKey:i,deviationMap:e,refId:t,currentIndex:Q[t]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});ai.sort(function(n,i){return n.currentIndex-i.currentIndex});var ui=ai.map(function(i){var e,t,o,l=i.deviationKey,d=i.deviationMap,r=i.refId,a=i.currentIndex;H&&void 0!==L&&(a-=L);var u=d[W],c=m(u);if(c)u="";else if(!u)return null;var s=d[Xn],v=Yn||m(s),f="".concat(oi,".").concat(a),p="".concat(ni).concat(g).concat(l).concat(g).concat(Tn).concat(g).concat(Gn),x=(null==d?void 0:d.evaluation_outputs)||(null==Zn?void 0:Zn.evaluation_outputs),y=null!==(e=null==x?void 0:x.output_value)&&void 0!==e?e:null,S=null!==(o=null===(t=null==x?void 0:x.metadata)||void 0===t?void 0:t.label_color)&&void 0!==o?o:di,I=h(S),b=n({},I),_=(null==d?void 0:d.deviation_summary)?{deviation_summary:d.deviation_summary||(null==Zn?void 0:Zn.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==Zn?void 0:Zn.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==Zn?void 0:Zn.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==Zn?void 0:Zn.deviation_explanation),evaluation_outputs:x,cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==Zn?void 0:Zn.cognitive_decisioning)}:null,k=0,C=_n||"";if(u&&C){var P=C.split(/\n{2,}/),w=P.findIndex(function(n){return n.includes(u)});if(-1!==w){var B=Object.entries($n).filter(function(n){n[0];var i=n[1][W];return i&&P[w].includes(i)}).sort(function(n,i){return P[w].indexOf(n[1][W])-P[w].indexOf(i[1][W])}),F=B.filter(function(n){n[0];var i=n[1][W];return i&&(i.includes(u)||u.includes(i))});F.length>1&&(k=Math.max(0,F.findIndex(function(n){return n[0]===l})))}}var R=dn(N,r);return{id:r,actionId:p,label:f,highlight:u,side:N,style:b,stackIndex:k,score:y,isConnected:X.has(p),showScrollLockToggle:X.has(p)||Z&&Y===p||!!en&&en===R.current,scrollSyncLocked:$,toggleScrollSyncLocked:nn,isOrphan:v,isMissingClause:c,badgeRef:R,onClick:function(i){i.stopPropagation();var e=Dn?n(n({},Dn),{title:(null==On?void 0:On.title)||(null==Dn?void 0:Dn.title)||""}):{id:"orphan-left",title:"",content:""},t=Hn?n(n({},Hn),{title:(null==jn?void 0:jn.title)||(null==Hn?void 0:Hn.title)||""}):{id:"orphan-right",title:"",content:""};rn(i,e,v,t,p,b)},onSummaryClick:function(n){n.stopPropagation(),an(n,p,v,_)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),ci=new Set,si=ui.filter(function(n){return!ci.has(n.id)&&(ci.add(n.id),!0)}),vi=G||!Sn&&xn?si:[],fi=si.map(function(n){return n.highlight}).filter(Boolean),pi=ui.find(function(n){return X.has(n.actionId)}),hi=!!pi;if(!(gn||Cn||R.subsections&&0!==R.subsections.length))return null;var mi=(null===(F=null==pi?void 0:pi.style)||void 0===F?void 0:F.badgeBorder)||(null==Jn?void 0:Jn.badgeBorder),gi=hi&&mi?{borderRadius:"4px",outline:"2px solid ".concat(mi),outlineOffset:"1px"}:{};return i(o,gn?n({ref:Fn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:i(o,n({sx:n({width:"100%"},gi)},{children:e(l,n({disableGutters:!0,expanded:!Pn&&Bn,onChange:function(){if(!Pn){if(Bn){var i=String(Y||""),e=i.includes(Tn)||i.includes(Gn);e||X.forEach(function(n){(String(n).includes(Tn)||String(n).includes(Gn))&&(e=!0)}),e&&(un(),cn(new Set),sn([]),vn.current=[])}D(function(i){var e;return n(n({},i),((e={})[O]=!i[O],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(d,n({expandIcon:Pn?null:i(u,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:i(r,n({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Pn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:wn||"Untitled Subsection"}))})),!Pn&&e(a,n({sx:{pt:0,pb:1,minWidth:0}},{children:[Cn&&i(c,{content:_n,overlayContent:kn,sxStyles:tn,deviationBadges:vi,maintainRelativeOrder:H,highlightBg:ri,suppressHighlightBg:In,highlights:fi,collisionKey:mn}),(R.subsections||[]).map(function(n,e){return i(y,{section:n,keyPath:"".concat(O,"-").concat(e),depth:M+1,columnKey:N,parentNodeId:W},"".concat(O,"-").concat(e))})]}))]}))}))}):n({ref:Fn,sx:{mt:0===M?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Pn&&e(o,n({sx:n({width:"100%"},gi)},{children:[Cn&&i(c,{content:_n,overlayContent:kn,sxStyles:tn,deviationBadges:vi,maintainRelativeOrder:H,highlightBg:ri,suppressHighlightBg:In,highlights:fi,collisionKey:mn}),(R.subsections||[]).map(function(n,e){return i(y,{section:n,keyPath:"".concat(O,"-").concat(e),depth:M+1,columnKey:N,parentNodeId:W,sectionOffset:L},"".concat(O,"-").concat(e))})]}))}))});export{y as default};
|
|
2
2
|
//# sourceMappingURL=SubSectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i,__spreadArray as n}from"tslib";import{useMemo as e}from"react";import{getSideData as t,safeStringify as o,getRationale as l,hasValue as s,isMissingStr as d,DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";var u={id:"",title:"",similarity:0,sections:[]},a=function(a,v,c,f,_){void 0===_&&(_=!0);var p="string"==typeof c?c:JSON.stringify(c||{}),b=e(function(){var e,s,d,r;if(!a||0===Object.keys(a).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var u=JSON.parse(p);try{var c=a.nodes||a,f=[],b=[],h=a.base_root_id,g=a.input_index_map||{0:"left",1:"right"},m=a[h]||c[h];if(!m||!1===m.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var y=function(n,e,t){if(!n||"object"!=typeof n)return n||null;if(n.deviations)return n;if(_)return n;var o=Object.keys(n).filter(function(i){return/^\d+$/.test(i)});if(!o.length)return n;var l=o.sort(function(i,n){return Number(i)-Number(n)}),s={},d={},r=null;return l.forEach(function(i){var o,l,u,a,v,c=n[i];if(c&&"object"==typeof c){r||(r=c);var f=!(null==c?void 0:c.status)||"pending"===c.status,_=f&&((null===(l=null==c?void 0:c.deviation_highlights)||void 0===l?void 0:l[e])||(null===(u=null==c?void 0:c.deviation_highlights)||void 0===u?void 0:u[g[0]]))||[],p=f&&((null===(a=null==c?void 0:c.deviation_highlights)||void 0===a?void 0:a[t])||(null===(v=null==c?void 0:c.deviation_highlights)||void 0===v?void 0:v[g[1]]))||[];s[i]=((o={})[g[0]]=_[0]||"",o[g[1]]=p[0]||"",o.deviation_summary=(null==c?void 0:c.deviation_summary)||"",o.deviation_title=null==c?void 0:c.deviation_title,o.deviation_impact=null==c?void 0:c.deviation_impact,o.deviation_explanation=null==c?void 0:c.deviation_explanation,o.evaluation_outputs=null==c?void 0:c.evaluation_outputs,o.cognitive_decisioning=null==c?void 0:c.cognitive_decisioning,o.deviation_highlights=null==c?void 0:c.deviation_highlights,o),d[i]=c}}),i(i({},n),{deviation_title:(null==r?void 0:r.deviation_title)||(null==n?void 0:n.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==n?void 0:n.deviation_impact),deviation_summary:(null==r?void 0:r.deviation_summary)||(null==n?void 0:n.deviation_summary),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==n?void 0:n.deviation_explanation),evaluation_outputs:(null==r?void 0:r.evaluation_outputs)||(null==n?void 0:n.evaluation_outputs),cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==n?void 0:n.cognitive_decisioning),deviations:s,deviation_entries:d})},x=function(i){var n=new Map,e=function(i){i.forEach(function(i){var t;i.id&&n.set(i.id,i),(null===(t=i.subsections)||void 0===t?void 0:t.length)&&e(i.subsections)})};e(i);var t=function(i,e){for(var o,l=[],s=function(i){var s=i.ref_parent_section_node_id;if(s&&n.has(s)&&s!==(null==e?void 0:e.id)){var d=n.get(s);d.subsections||(d.subsections=[]),d.subsections.some(function(n){return n.id===i.id})||d.subsections.push(i)}else(null===(o=i.subsections)||void 0===o?void 0:o.length)&&(i.subsections=t(i.subsections,i)),l.push(i)},d=0,r=i;d<r.length;d++){s(r[d])}return l},o=t(i),l=function(i){i.forEach(function(i){i.subsections&&i.subsections.length>0&&(i.subsections.sort(function(i,n){return i.selfIndex<0&&n.selfIndex>=0?1:i.selfIndex>=0&&n.selfIndex<0?-1:(i.selfIndex||0)-(n.selfIndex||0)}),l(i.subsections))})};return l(o),o},I=function(n,e){var s,d,r,v,f,_=a[n]||c[n];if(!_||!1===_.display_node)return null;var p=_.comparison_inputs?Object.keys(_.comparison_inputs):[],b=g[0],h=g[1];p.length>0&&(b=p.includes(g[0])?g[0]:p[0],h=p.includes(g[1])?g[1]:p.length>1?p[1]:p[0]);var m=t(_,e,g),x=!1!==(null===(s=m.attributes)||void 0===s?void 0:s.display_title),E=!1!==(null===(d=m.attributes)||void 0===d?void 0:d.display_content),N=!!o(m.title).trim(),S=!!o(m.content).trim(),j=l(_),O=(null===(r=null==u?void 0:u[n])||void 0===r?void 0:r.evaluation_result)||_.evaluation_result||null,R=y(O,b,h),k=[];_.next&&Object.values(_.next).forEach(function(i){var n=c[i];if(n&&!1!==n.display_node){var t=I(i,e);t&&k.push(t)}});var P=!(!N&&!S);return i(i({id:n,title:N?m.title:"",content:S?m.content:"",change_history:S?m.change_history:"",displayTitle:x,displayContent:E,subsections:k},P?j:{score:void 0,relation:"not_defined"}),{evaluationResult:R,selfIndex:void 0!==(null===(v=m.attributes)||void 0===v?void 0:v.display_index)?Number(m.attributes.display_index):-1,ref_parent_section_node_id:null===(f=m.attributes)||void 0===f?void 0:f.ref_parent_section_node_id})};if(v){var E=function(e,o){var s,d,r,v,f,_,p,b,h,m,x,I,N,S,j,O,R,k,P,C,T,V,D,w,J,M,U,q,F,$,z,A;void 0===o&&(o=0);var B=[],G=[];if(!e)return{refSections:B,baseSections:G};var H={},K={},L=-1,Q=-1;for(var W in e){var X=e[W],Y=a[X]||c[X];if(Y&&!1!==Y.display_node){var Z=Y.comparison_inputs?Object.keys(Y.comparison_inputs):[],ii=g[0],ni=g[1];Z.length>0&&(ii=Z.includes(g[0])?g[0]:Z[0],ni=Z.includes(g[1])?g[1]:Z.length>1?Z[1]:Z[0]);var ei=l(Y),ti=(null===(s=null==u?void 0:u[X])||void 0===s?void 0:s.evaluation_result)||Y.evaluation_result||null,oi=y(ti,ii,ni),li=t(Y,"1",g),si=t(Y,"0",g),di=!1!==(null===(d=li.attributes)||void 0===d?void 0:d.display_title)&&((null===(v=null===(r=li.title)||void 0===r?void 0:r.trim)||void 0===v?void 0:v.call(r))||"")||!1!==(null===(f=li.attributes)||void 0===f?void 0:f.display_content)&&((null===(p=null===(_=li.content)||void 0===_?void 0:_.trim)||void 0===p?void 0:p.call(_))||""),ri=!1!==(null===(b=si.attributes)||void 0===b?void 0:b.display_title)&&((null===(m=null===(h=si.title)||void 0===h?void 0:h.trim)||void 0===m?void 0:m.call(h))||"")||!1!==(null===(x=si.attributes)||void 0===x?void 0:x.display_content)&&((null===(N=null===(I=si.content)||void 0===I?void 0:I.trim)||void 0===N?void 0:N.call(I))||""),ui=Number(null!==(j=null===(S=li.attributes)||void 0===S?void 0:S.display_index)&&void 0!==j?j:L--),ai=Number(null!==(R=null===(O=si.attributes)||void 0===O?void 0:O.display_index)&&void 0!==R?R:Q--),vi=0===o?String(ui):"".concat(ui,"_").concat(X),ci=0===o?String(ai):"".concat(ai,"_").concat(X),fi=H[vi]||i(i({id:X,title:!1!==(null===(k=li.attributes)||void 0===k?void 0:k.display_title)?li.title:"",content:!1!==(null===(P=li.attributes)||void 0===P?void 0:P.display_content)?li.content:"",change_history:!1!==(null===(C=li.attributes)||void 0===C?void 0:C.display_content)?li.change_history:"",subsections:[]},di?ei:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ui,evaluationResult:oi,displayContent:null===(T=li.attributes)||void 0===T?void 0:T.display_content,displayTitle:null===(V=li.attributes)||void 0===V?void 0:V.display_title,ref_parent_section_node_id:null===(D=li.attributes)||void 0===D?void 0:D.ref_parent_section_node_id}),_i=K[ci]||i(i({id:X,title:!1!==(null===(w=si.attributes)||void 0===w?void 0:w.display_title)?si.title:"",content:!1!==(null===(J=si.attributes)||void 0===J?void 0:J.display_content)?si.content:"",change_history:!1!==(null===(M=si.attributes)||void 0===M?void 0:M.display_content)?si.change_history:"",subsections:[]},ri?ei:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ai,evaluationResult:oi,displayContent:null===(U=si.attributes)||void 0===U?void 0:U.display_content,displayTitle:null===(q=si.attributes)||void 0===q?void 0:q.display_title});Number(ui)>=0&&Number(ai)>=0&&((null===(F=fi.refIndexes)||void 0===F?void 0:F.includes(Number(ai)))||null===($=fi.refIndexes)||void 0===$||$.push(Number(ai)),(null===(z=_i.refIndexes)||void 0===z?void 0:z.includes(Number(ui)))||null===(A=_i.refIndexes)||void 0===A||A.push(Number(ui))),H[vi]=fi,K[ci]=_i;var pi=E(Y.next,o+1),bi=pi.refSections,hi=pi.baseSections;bi.length>0&&(fi.subsections=n(n([],fi.subsections||[],!0),bi,!0)),hi.length>0&&(_i.subsections=n(n([],_i.subsections||[],!0),hi,!0))}}B=Object.values(H),G=Object.values(K);var gi=function(i,n){return i.selfIndex<0&&n.selfIndex>=0?1:i.selfIndex>=0&&n.selfIndex<0?-1:i.selfIndex-n.selfIndex};return B.sort(gi),G.sort(gi),{refSections:B,baseSections:G}},N=E(m.next),S=N.refSections,j=N.baseSections;b=x(S),f=j}else m.next&&Object.values(m.next).forEach(function(i){var n=a[i]||c[i];n&&!1!==n.display_node&&(f.push(I(i,"0")||{id:i,title:"",content:"",subsections:[]}),b.push(I(i,"1")||{id:i,title:"",content:"",subsections:[]}))}),b=x(b);return{activeProposed:{title:(null===(s=null===(e=m.comparison_inputs)||void 0===e?void 0:e[g[0]])||void 0===s?void 0:s.title)||"Uploaded Contract",description:m.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(r=null===(d=m.comparison_inputs)||void 0===d?void 0:d[g[1]])||void 0===r?void 0:r.title)||"Reference Template",similarity:0,sections:b,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:m.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(i){return console.error("Data Transformation Error: ",i),{activeProposed:{},activeVariants:[],parseError:i instanceof Error?i.message:"Unknown Parsing Error"}}},[a,v,p,_]),h=b.activeProposed,g=b.activeVariants,m=b.parseError,y=(null==g?void 0:g[0])||u,x=e(function(){return(null==h?void 0:h.sections)||[]},[null==h?void 0:h.sections]),I=e(function(){return y.sections||[]},[y.sections]),E=x.length>0||I.length>0,N=e(function(){return f.fields.filter(function(i){var n=i.key;return(!E||"description"!==n)&&(s(null==h?void 0:h[n])||s(y[n]))})},[h,y,E,f.fields]),S=e(function(){var i,n,e={},t={},o={},l=0,s=null===(i=null==a?void 0:a.input_index_map)||void 0===i?void 0:i[0],u=null===(n=null==a?void 0:a.input_index_map)||void 0===n?void 0:n[1],c=function(i,n,a,v,f,_){var p,b,h,g,m,y,x,I;if(i&&function(i,n){var e,l=(null===(e=null==i?void 0:i.evaluationResult)||void 0===e?void 0:e.deviations)||{};Object.keys(l).sort().forEach(function(e){var a=l[e];if(a){var v=!d(a[s]),c=!d(a[u]);if(v||c){var f="".concat(i.id).concat(r).concat(e);void 0===t[f]&&(void 0===o[n]&&(o[n]=1),t[f]=o[n]++)}}})}(i,v),i&&!f){var E=(null==_?void 0:_.id)||"fallback_parent_".concat(l++);e[E]||(e[E]=[]),e[E].push(i)}for(var N=Math.max((null===(p=null==n?void 0:n.subsections)||void 0===p?void 0:p.length)||0,(null===(b=null==a?void 0:a.subsections)||void 0===b?void 0:b.length)||0,(null===(h=null==i?void 0:i.subsections)||void 0===h?void 0:h.length)||0),S=0;S<N;S++)c((null===(g=null==i?void 0:i.subsections)||void 0===g?void 0:g[S])||(null===(m=null==n?void 0:n.subsections)||void 0===m?void 0:m[S])||(null===(y=null==a?void 0:a.subsections)||void 0===y?void 0:y[S]),null===(x=null==n?void 0:n.subsections)||void 0===x?void 0:x[S],null===(I=null==a?void 0:a.subsections)||void 0===I?void 0:I[S],v,!1,_)};return x.forEach(function(i,n){var e,t=n+1;v&&void 0!==i.selfIndex&&i.selfIndex>=0&&(t=i.selfIndex+1);var o=null;if(v){var l=null===(e=i.refIndexes)||void 0===e?void 0:e[0];o=I.find(function(i){return i.selfIndex===l})}else o=I[n];c(i,i,o,t,!0,i)}),I.forEach(function(i,n){var e,t=n+1,o=!1;if(v){var l=null===(e=i.refIndexes)||void 0===e?void 0:e[0],s=x.find(function(i){return i.selfIndex===l});s&&void 0!==s.selfIndex&&s.selfIndex>=0?t=s.selfIndex+1:(o=!0,void 0!==i.selfIndex&&i.selfIndex>=0&&(t=i.selfIndex+1))}else n>=x.length&&(o=!0);o&&c(i,null,i,t,!0,i)}),{parentDeviationRecord:e,registry:t}},[x,I,v,a]),j=S.parentDeviationRecord,O=S.registry;return{activeProposed:h,activeVariants:g,existingRule:y,proposedSections:x,existingSections:I,visibleFields:N,parentDeviationRecord:j,deviationNumberRegistry:O,parseError:m}};export{a as useCognitiveTreeData};
|
|
1
|
+
import{__assign as i,__spreadArray as t}from"tslib";import{useMemo as n}from"react";import{getSideData as e,safeStringify as o,getRationale as l,hasValue as r,isMissingStr as s,DEVIATION_BADGE_SEPARATOR as d}from"../CognitiveComparehelpers.js";var a={id:"",title:"",similarity:0,sections:[]},u=function(u,v,c,f,p){void 0===p&&(p=!0);var _="string"==typeof c?c:JSON.stringify(c||{}),b=n(function(){var n,r,s,d;if(!u||0===Object.keys(u).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var a=JSON.parse(_);try{var c=u.nodes||u,f=[],b=[],m=u.base_root_id,h=u.input_index_map||{0:"left",1:"right"},y=u[m]||c[m];if(!y||!1===y.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var g=function(t,n,e){if(!t||"object"!=typeof t)return t||null;if(t.deviations)return t;if(p)return t;var o=Object.keys(t).filter(function(i){return/^\d+$/.test(i)});if(!o.length)return t;var l=o.sort(function(i,t){return Number(i)-Number(t)}),r={},s={},d=null;return l.forEach(function(i){var o,l,a,u,v,c=t[i];if(c&&"object"==typeof c){d||(d=c);var f=!(null==c?void 0:c.status)||"pending"===c.status,p=f&&((null===(l=null==c?void 0:c.deviation_highlights)||void 0===l?void 0:l[n])||(null===(a=null==c?void 0:c.deviation_highlights)||void 0===a?void 0:a[h[0]]))||[],_=f&&((null===(u=null==c?void 0:c.deviation_highlights)||void 0===u?void 0:u[e])||(null===(v=null==c?void 0:c.deviation_highlights)||void 0===v?void 0:v[h[1]]))||[];r[i]=((o={})[h[0]]=p[0]||"",o[h[1]]=_[0]||"",o.deviation_summary=(null==c?void 0:c.deviation_summary)||"",o.deviation_title=null==c?void 0:c.deviation_title,o.deviation_impact=null==c?void 0:c.deviation_impact,o.deviation_explanation=null==c?void 0:c.deviation_explanation,o.evaluation_outputs=null==c?void 0:c.evaluation_outputs,o.cognitive_decisioning=null==c?void 0:c.cognitive_decisioning,o.deviation_highlights=null==c?void 0:c.deviation_highlights,o),s[i]=c}}),i(i({},t),{deviation_title:(null==d?void 0:d.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_summary:(null==d?void 0:d.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning),deviations:r,deviation_entries:s})},x=function(i){var t=new Map,n=function(i){i.forEach(function(i){var e;i.id&&t.set(i.id,i),(null===(e=i.subsections)||void 0===e?void 0:e.length)&&n(i.subsections)})};n(i);var e=function(i,n){for(var o,l=[],r=function(i){var r=i.ref_parent_section_node_id;if(r&&t.has(r)&&r!==(null==n?void 0:n.id)){var s=t.get(r);s.subsections||(s.subsections=[]),s.subsections.some(function(t){return t.id===i.id})||s.subsections.push(i)}else(null===(o=i.subsections)||void 0===o?void 0:o.length)&&(i.subsections=e(i.subsections,i)),l.push(i)},s=0,d=i;s<d.length;s++){r(d[s])}return l},o=e(i),l=function(i){i.forEach(function(i){i.subsections&&i.subsections.length>0&&(i.subsections.sort(function(i,t){return i.selfIndex<0&&t.selfIndex>=0?1:i.selfIndex>=0&&t.selfIndex<0?-1:(i.selfIndex||0)-(t.selfIndex||0)}),l(i.subsections))})};return l(o),o},I=function(t,n){var r,s,d,v,f,p=u[t]||c[t];if(!p||!1===p.display_node)return null;var _=p.comparison_inputs?Object.keys(p.comparison_inputs):[],b=h[0],m=h[1];_.length>0&&(b=_.includes(h[0])?h[0]:_[0],m=_.includes(h[1])?h[1]:_.length>1?_[1]:_[0]);var y=e(p,n,h),x=!1!==(null===(r=y.attributes)||void 0===r?void 0:r.display_title),N=!1!==(null===(s=y.attributes)||void 0===s?void 0:s.display_content),E=!!o(y.title).trim(),O=!!o(y.content).trim(),j=l(p),S=(null===(d=null==a?void 0:a[t])||void 0===d?void 0:d.evaluation_result)||p.evaluation_result||null,R=g(S,b,m),P=[];p.next&&Object.values(p.next).forEach(function(i){var t=c[i];if(t&&!1!==t.display_node){var e=I(i,n);e&&P.push(e)}});var k=!(!E&&!O);return i(i({id:t,title:E?y.title:"",content:O?y.content:"",change_history:O?y.change_history:"",displayTitle:x,displayContent:N,subsections:P},k?j:{score:void 0,relation:"not_defined"}),{evaluationResult:R,selfIndex:void 0!==(null===(v=y.attributes)||void 0===v?void 0:v.display_index)?Number(y.attributes.display_index):-1,ref_parent_section_node_id:null===(f=y.attributes)||void 0===f?void 0:f.ref_parent_section_node_id})};if(v){var N=function(n,o){var r,s,d,v,f,p,_,b,m,y,x,I,E,O,j,S,R,P,k,K,C,T,V,D,w,J,U,q,F,M,W,$;void 0===o&&(o=0);var z=[],A=[];if(!n)return{refSections:z,baseSections:A};var B={},G={},H=-1,L=-1;for(var Q in n){var X=n[Q],Y=u[X]||c[X];if(Y&&!1!==Y.display_node){var Z=Y.comparison_inputs?Object.keys(Y.comparison_inputs):[],ii=h[0],ti=h[1];Z.length>0&&(ii=Z.includes(h[0])?h[0]:Z[0],ti=Z.includes(h[1])?h[1]:Z.length>1?Z[1]:Z[0]);var ni=l(Y),ei=(null===(r=null==a?void 0:a[X])||void 0===r?void 0:r.evaluation_result)||Y.evaluation_result||null,oi=g(ei,ii,ti),li=e(Y,"1",h),ri=e(Y,"0",h),si=!1!==(null===(s=li.attributes)||void 0===s?void 0:s.display_title)&&((null===(v=null===(d=li.title)||void 0===d?void 0:d.trim)||void 0===v?void 0:v.call(d))||"")||!1!==(null===(f=li.attributes)||void 0===f?void 0:f.display_content)&&((null===(_=null===(p=li.content)||void 0===p?void 0:p.trim)||void 0===_?void 0:_.call(p))||""),di=!1!==(null===(b=ri.attributes)||void 0===b?void 0:b.display_title)&&((null===(y=null===(m=ri.title)||void 0===m?void 0:m.trim)||void 0===y?void 0:y.call(m))||"")||!1!==(null===(x=ri.attributes)||void 0===x?void 0:x.display_content)&&((null===(E=null===(I=ri.content)||void 0===I?void 0:I.trim)||void 0===E?void 0:E.call(I))||""),ai=Number(null!==(j=null===(O=li.attributes)||void 0===O?void 0:O.display_index)&&void 0!==j?j:H--),ui=Number(null!==(R=null===(S=ri.attributes)||void 0===S?void 0:S.display_index)&&void 0!==R?R:L--),vi=0===o?String(ai):"".concat(ai,"_").concat(X),ci=0===o?String(ui):"".concat(ui,"_").concat(X),fi=B[vi]||i(i({id:X,title:!1!==(null===(P=li.attributes)||void 0===P?void 0:P.display_title)?li.title:"",content:!1!==(null===(k=li.attributes)||void 0===k?void 0:k.display_content)?li.content:"",change_history:!1!==(null===(K=li.attributes)||void 0===K?void 0:K.display_content)?li.change_history:"",subsections:[]},si?ni:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ai,evaluationResult:oi,displayContent:null===(C=li.attributes)||void 0===C?void 0:C.display_content,displayTitle:null===(T=li.attributes)||void 0===T?void 0:T.display_title,ref_parent_section_node_id:null===(V=li.attributes)||void 0===V?void 0:V.ref_parent_section_node_id}),pi=G[ci]||i(i({id:X,title:!1!==(null===(D=ri.attributes)||void 0===D?void 0:D.display_title)?ri.title:"",content:!1!==(null===(w=ri.attributes)||void 0===w?void 0:w.display_content)?ri.content:"",change_history:!1!==(null===(J=ri.attributes)||void 0===J?void 0:J.display_content)?ri.change_history:"",subsections:[]},di?ni:{score:void 0,relation:"not_defined"}),{refIndexes:[],selfIndex:ui,evaluationResult:oi,displayContent:null===(U=ri.attributes)||void 0===U?void 0:U.display_content,displayTitle:null===(q=ri.attributes)||void 0===q?void 0:q.display_title});Number(ai)>=0&&Number(ui)>=0&&((null===(F=fi.refIndexes)||void 0===F?void 0:F.includes(Number(ui)))||null===(M=fi.refIndexes)||void 0===M||M.push(Number(ui)),(null===(W=pi.refIndexes)||void 0===W?void 0:W.includes(Number(ai)))||null===($=pi.refIndexes)||void 0===$||$.push(Number(ai))),B[vi]=fi,G[ci]=pi;var _i=N(Y.next,o+1),bi=_i.refSections,mi=_i.baseSections;bi.length>0&&(fi.subsections=t(t([],fi.subsections||[],!0),bi,!0)),mi.length>0&&(pi.subsections=t(t([],pi.subsections||[],!0),mi,!0))}}z=Object.values(B),A=Object.values(G);var hi=function(i,t){return i.selfIndex<0&&t.selfIndex>=0?1:i.selfIndex>=0&&t.selfIndex<0?-1:i.selfIndex-t.selfIndex};return z.sort(hi),A.sort(hi),{refSections:z,baseSections:A}},E=N(y.next),O=E.refSections,j=E.baseSections;b=x(O),f=j}else y.next&&Object.values(y.next).forEach(function(i){var t=u[i]||c[i];t&&!1!==t.display_node&&(f.push(I(i,"0")||{id:i,title:"",content:"",subsections:[]}),b.push(I(i,"1")||{id:i,title:"",content:"",subsections:[]}))}),b=x(b);return{activeProposed:{title:(null===(r=null===(n=y.comparison_inputs)||void 0===n?void 0:n[h[0]])||void 0===r?void 0:r.title)||"Uploaded Contract",description:y.decision_scope_description||"",sections:f},activeVariants:[{id:"tree-variant-1",title:(null===(d=null===(s=y.comparison_inputs)||void 0===s?void 0:s[h[1]])||void 0===d?void 0:d.title)||"Reference Template",similarity:0,sections:b,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:y.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(i){return console.error("Data Transformation Error: ",i),{activeProposed:{},activeVariants:[],parseError:i instanceof Error?i.message:"Unknown Parsing Error"}}},[u,v,_,p]),m=b.activeProposed,h=b.activeVariants,y=b.parseError,g=(null==h?void 0:h[0])||a,x=n(function(){return(null==m?void 0:m.sections)||[]},[null==m?void 0:m.sections]),I=n(function(){return g.sections||[]},[g.sections]),N=x.length>0||I.length>0,E=n(function(){return f.fields.filter(function(i){var t=i.key;return(!N||"description"!==t)&&(r(null==m?void 0:m[t])||r(g[t]))})},[m,g,N,f.fields]),O=n(function(){var i,t,n={},e={},o={},l=0,r=null===(i=null==u?void 0:u.input_index_map)||void 0===i?void 0:i[0],a=null===(t=null==u?void 0:u.input_index_map)||void 0===t?void 0:t[1],c=function(i,t){if(!v){var n="left"===t?x.indexOf(i):I.indexOf(i);return{rootKey:"".concat(t,":").concat(n),parentNum:n+1}}if("left"===t){var e=i.selfIndex,o=void 0!==e&&e>=0?e+1:-1;return{rootKey:"left-root:".concat(i.id),parentNum:o}}var l=i.selfIndex,r=x.find(function(i){var t;return null===(t=i.refIndexes)||void 0===t?void 0:t.includes(l)});if(r){var s=r.selfIndex,d=void 0!==s&&s>=0?s+1:-1;return{rootKey:"left-root:".concat(r.id),parentNum:d}}var a=void 0!==l&&l>=0?l+1:-1;return{rootKey:"right-orphan-root:".concat(i.id),parentNum:a}},f=function(i,t){if(i&&t)return i.find(function(i){return i.id===t.id})||void 0},p=function(i,t,u,v,c,_,b){if(i&&function(i,t,n){var l,u=(null===(l=null==i?void 0:i.evaluationResult)||void 0===l?void 0:l.deviations)||{};Object.keys(u).sort().forEach(function(l){var v=u[l];if(v){var c=!s(v[r]),f=!s(v[a]);if(c||f){var p="".concat(i.id).concat(d).concat(l);void 0===e[p]&&(void 0===o[t]&&(o[t]=1),e[p]={index:o[t]++,rootKey:t,parentNum:n})}}})}(i,v,c),i&&!_){var m=(null==b?void 0:b.id)||"fallback_parent_".concat(l++);n[m]||(n[m]=[]),n[m].push(i)}((null==i?void 0:i.subsections)||(null==t?void 0:t.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(n){var e=f(null==t?void 0:t.subsections,n),o=f(null==u?void 0:u.subsections,n);p(n,e,o,v,c,!1,i||b)})};x.forEach(function(i){var t,n=c(i,"left"),e=n.rootKey,o=n.parentNum,l=null;if(v){var r=null===(t=i.refIndexes)||void 0===t?void 0:t[0];l=I.find(function(i){return i.selfIndex===r})}else l=I[x.indexOf(i)];p(i,i,l,e,o,!0,i)}),I.forEach(function(i){var t=c(i,"right"),n=t.rootKey,e=t.parentNum;n.startsWith("right-orphan-root:")&&p(i,null,i,n,e,!0,i)});var _=Object.fromEntries(Object.entries(e).map(function(i){return[i[0],i[1].index]})),b=Object.fromEntries(Object.entries(e).map(function(i){return[i[0],i[1].parentNum]}));return{parentDeviationRecord:n,registry:_,deviationParentRegistry:b}},[x,I,v,u]),j=O.parentDeviationRecord,S=O.registry,R=O.deviationParentRegistry;return{activeProposed:m,activeVariants:h,existingRule:g,proposedSections:x,existingSections:I,visibleFields:E,parentDeviationRecord:j,deviationNumberRegistry:S,deviationParentRegistry:R,parseError:y}};export{u as useCognitiveTreeData};
|
|
2
2
|
//# sourceMappingURL=useCompareData.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as i}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{SpecialZoomLevel as r}from"@react-pdf-viewer/core";import a from"./PdfContainer.js";import l from"./PdfToolbar.js";import{pdfStyles as s}from"./PdfStyle.js";import{PdfHighlightControls as c}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import{useRef as u,useMemo as d,useEffect as g}from"react";import f from"../ScannedDocCitation/ScannedDocCitation.js";var h=function(e){switch(e){case"ActualSize":return r.ActualSize;case"PageFit":return r.PageFit;case"PageWidth":return r.PageWidth;default:return null!=e?e:r.PageWidth}},m=function(m){var v,p=m.pdfUrl,x=m.highlightText,C=m.highlightPages,P=m.highlightCordinatePages,w=m.highlightColor,T=void 0===w?"yellow":w,S=m.activeHighlightColor,y=void 0===S?"#f7dc51":S,A=m.jumpToPageValue,b=void 0===A?0:A,H=m.pdfName,I=m.onClose,j=m.customStyles,F=m.customClasses,z=m.customIcons,N=m.useCoordinates,_=m.fallbackPages,R=m.activeCitationIndex,V=m.onActiveCitationChange,W=m.headerAction,q=m.isZoomEnabled,D=void 0===q||q,E=m.showHighlightsAction,B=void 0===E||E,O=m.defaultScale,U=void 0===O?r.ActualSize:O,k=m.useRange,Z=void 0!==k&&k,J=m.rangeOfPages,K=void 0===J?null:J,L=m.showFullScreenAction,G=void 0===L||L,M=u(null),Q=d(function(){if(N)return new Set(P.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(C).forEach(function(t){t>0&&e.add(t-1)}),e},[C]),X=(v=x)&&0!==v.length?v.filter(function(e){return!v.some(function(t){return t!==e&&t.includes(e)})}):v,Y=c(X,N?{}:C,M,Q,N,N?P:[],T,y),$=Y.highlightIndex,ee=Y.cursorIndex,te=Y.setCursorIndex,ie=Y.orderedKeys,oe=Y.totalHighlights,ne=Y.getValidPosition,re=Y.tryJump,ae=Y.jumpToPage,le=Y.zoomTo,se=Y.plugins,ce=Y.controls,ue=Y.hideNonTargetHighlights,de=Y.deduplicateHighlights,ge=ne(ee);g(function(){void 0!==R&&R!==ee&&te(R)},[R]);var fe=e(e({},ce),{goToNext:function(){ce.goToNext(),V&&V(ee+1)},goToPrevious:function(){ce.goToPrevious(),V&&V(ee-1)}});if(!p)return o(f,{pages:_,activeCitationIndex:R,onActiveCitationChange:V,headerAction:W});return n("div",e({ref:M,className:(null==F?void 0:F.pdfViewerWrapper)||"",style:e(e(e({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},s.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==j?void 0:j.pdfViewer)},{children:[o(l,{highlightIndex:$,totalHighlights:oe,controls:fe,currentPosition:ge,pdfName:H,onClose:I,pdfUrl:p,viewerRef:M,customStyles:j,customClasses:F,customIcons:z,headerAction:W,isZoomEnabled:D,showHighlightsAction:B,showFullScreenAction:G}),o(a,{defaultScale:h(U),pdfUrl:p,plugins:se,customStyles:j,onLoad:function(){var e=!N&&!Z&&b<=0;if(le(r.ActualSize),b>0&&!Z){var o=b-1,n=ie[o],a=C[n],l=P[o];te(o),console.log(l,"cordinateTargetHighlight"),N&&l.pageIndex>0&&ae(l.pageIndex),a>0&&(setTimeout(function(){ue(Q),de(a-1)},1e3),N||ae(a-1))}else if(Z&&K&&2===K.length){t(void 0,void 0,void 0,function(){var e,t,o,n,r;return i(this,function(i){switch(i.label){case 0:e=K[0],t=K[1],o=e,i.label=1;case 1:return o<=t?(ae(n=o-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(i.sent(),ue(Q),(r=de(n))&&r>0)return[3,4];i.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}else if(!N&&C){var s=ie.find(function(e){return C[e]>0});if(void 0!==s){var c=C[s]-1;ae(c),setTimeout(function(){ue(Q),de(c)},1e3)}}requestAnimationFrame(function(){e&&re(),!N&&b>0&&!Z&&function(){if(M.current){var e=b-1,t=ie[e],i=C[t],o=i>0?i-1:0,n={};ie.forEach(function(e,t){var i=C[e];i>0&&(n[i]||(n[i]=[]),n[i].push(t))});var r=(n[i]||[]).indexOf(e),a=0,l=function(){var e,t;if(!(++a>40)){var i=null===(e=M.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(i){var n=null===(t=M.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(o,'"]'));if(n){var s=i.getBoundingClientRect(),c=n.getBoundingClientRect();if(c.top<s.bottom&&c.bottom>s.top){var u=n.querySelectorAll(".rpv-search__highlight")[r];if(u){var d=u.getBoundingClientRect(),g=i.scrollTop+(d.top-s.top)-i.clientHeight/2+d.height/2;i.scrollTo({top:g,behavior:"smooth"})}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}};setTimeout(l,500)}}()})},onPageChange:function(e){var t=e.currentPage;Q.has(t)?(de(t),ue(Q)):ue(Q)}})]}))};export{m as default};
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as i}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{SpecialZoomLevel as r}from"@react-pdf-viewer/core";import a from"./PdfContainer.js";import l from"./PdfToolbar.js";import{pdfStyles as s}from"./PdfStyle.js";import{PdfHighlightControls as c}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import{useRef as u,useMemo as d,useEffect as g}from"react";import f from"../ScannedDocCitation/ScannedDocCitation.js";var h=function(e){switch(e){case"ActualSize":return r.ActualSize;case"PageFit":return r.PageFit;case"PageWidth":return r.PageWidth;default:return null!=e?e:r.PageWidth}},m=function(m){var v,p=m.pdfUrl,x=m.highlightText,C=m.highlightPages,P=m.highlightCordinatePages,w=m.highlightColor,T=void 0===w?"yellow":w,S=m.activeHighlightColor,y=void 0===S?"#f7dc51":S,A=m.jumpToPageValue,b=void 0===A?0:A,H=m.pdfName,I=m.onClose,j=m.customStyles,F=m.customClasses,z=m.customIcons,N=m.useCoordinates,_=m.fallbackPages,R=m.activeCitationIndex,V=m.onActiveCitationChange,W=m.headerAction,q=m.isZoomEnabled,D=void 0===q||q,E=m.showHighlightsAction,B=void 0===E||E,O=m.defaultScale,U=void 0===O?r.ActualSize:O,k=m.useRange,Z=void 0!==k&&k,J=m.rangeOfPages,K=void 0===J?null:J,L=m.showFullScreenAction,G=void 0===L||L,M=u(null),Q=d(function(){if(N)return new Set(P.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(C).forEach(function(t){t>0&&e.add(t-1)}),e},[P,C,N]),X=(v=x)&&0!==v.length?v.filter(function(e){return!v.some(function(t){return t!==e&&t.includes(e)})}):v,Y=c(X,N?{}:C,M,Q,N,N?P:[],T,y),$=Y.highlightIndex,ee=Y.cursorIndex,te=Y.setCursorIndex,ie=Y.orderedKeys,oe=Y.totalHighlights,ne=Y.getValidPosition,re=Y.tryJump,ae=Y.jumpToPage,le=Y.zoomTo,se=Y.plugins,ce=Y.controls,ue=Y.hideNonTargetHighlights,de=Y.deduplicateHighlights,ge=ne(ee);g(function(){void 0!==R&&R!==ee&&te(R)},[R]);var fe=e(e({},ce),{goToNext:function(){ee>=oe-1||(ce.goToNext(),V&&V(ee+1))},goToPrevious:function(){ee<=0||(ce.goToPrevious(),V&&V(ee-1))}});if(!p)return o(f,{pages:_,activeCitationIndex:R,onActiveCitationChange:V,headerAction:W});return n("div",e({ref:M,className:(null==F?void 0:F.pdfViewerWrapper)||"",style:e(e(e({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},s.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==j?void 0:j.pdfViewer)},{children:[o(l,{highlightIndex:$,totalHighlights:oe,controls:fe,currentPosition:ge,pdfName:H,onClose:I,pdfUrl:p,viewerRef:M,customStyles:j,customClasses:F,customIcons:z,headerAction:W,isZoomEnabled:D,showHighlightsAction:B,showFullScreenAction:G}),o(a,{defaultScale:h(U),pdfUrl:p,plugins:se,customStyles:j,onLoad:function(){var e=!N&&!Z&&b<=0;if(le(r.ActualSize),b>0&&!Z){var o=b-1,n=ie[o],a=C[n],l=P[o];te(o),console.log(l,"cordinateTargetHighlight"),N&&l.pageIndex>0&&ae(l.pageIndex),a>0&&(setTimeout(function(){ue(Q),de(a-1)},1e3),N||ae(a-1))}else if(Z&&K&&2===K.length){t(void 0,void 0,void 0,function(){var e,t,o,n,r;return i(this,function(i){switch(i.label){case 0:e=K[0],t=K[1],o=e,i.label=1;case 1:return o<=t?(ae(n=o-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(i.sent(),ue(Q),(r=de(n))&&r>0)return[3,4];i.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}else if(!N&&C){var s=ie.find(function(e){return C[e]>0});if(void 0!==s){var c=C[s]-1;ae(c),setTimeout(function(){ue(Q),de(c)},1e3)}}requestAnimationFrame(function(){e&&re(),!N&&b>0&&!Z&&function(){if(M.current){var e=b-1,t=ie[e],i=C[t],o=i>0?i-1:0,n={};ie.forEach(function(e,t){var i=C[e];i>0&&(n[i]||(n[i]=[]),n[i].push(t))});var r=(n[i]||[]).indexOf(e),a=0,l=function(){var e,t;if(!(++a>40)){var i=null===(e=M.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(i){var n=null===(t=M.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(o,'"]'));if(n){var s=i.getBoundingClientRect(),c=n.getBoundingClientRect();if(c.top<s.bottom&&c.bottom>s.top){var u=n.querySelectorAll(".rpv-search__highlight")[r];if(u){var d=u.getBoundingClientRect(),g=i.scrollTop+(d.top-s.top)-i.clientHeight/2+d.height/2;i.scrollTo({top:g,behavior:"smooth"})}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}};setTimeout(l,500)}}()})},onPageChange:function(e){var t=e.currentPage;Q.has(t)?(de(t),ue(Q)):ue(Q)}})]}))};export{m as default};
|
|
2
2
|
//# sourceMappingURL=PdfViewer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as e,__assign as t}from"tslib";import{jsx as r,Fragment as n}from"react/jsx-runtime";import{useState as o,useRef as i,useMemo as a}from"react";import{searchPlugin as l}from"@react-pdf-viewer/search";import{pageNavigationPlugin as u}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as c}from"@react-pdf-viewer/zoom";import{highlightPlugin as f}from"@react-pdf-viewer/highlight";var g=function(g,h,s,p,v,d,m,x){void 0===m&&(m="yellow"),void 0===x&&(x="#F6D739");var T=o(0),y=T[0],b=T[1],w=i(!1),I=o(0),M=I[0],_=I[1];i([]);var S=function(e){return e.replace(/[^\S\n]+/g," ").trim()},E=function(e){return(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},A=function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t},B=function(e){var t=E(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},k=function(e){return e.replace(/\\([''])/g,"$1").replace(/\]\s*\n\s*\(/g,"](").replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/`([^`]+)`/g,"$1")},q=function(e){return e?k(e).split(/\n+/).map(A).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return S(function(e){return e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2")}(e))}).filter(Boolean):[]},z=Object.keys(h).map(Number).sort(function(e,t){return e-t}),j=a(function(){return v?d.length:v?0:Object.values(h).filter(function(e){return e>0}).length},[d,h]),C=function(r){if(s.current){var n=s.current.querySelector('[data-testid="search__highlights-'.concat(r,'"]'));if(n){var o=Array.from(n.querySelectorAll(".rpv-search__highlight"));if(0!==o.length){var i=P.map(B),a=Z.map(B);if(0!==i.length||0!==a.length){var l=o.map(function(e){var r=function(e){var t=e.getBoundingClientRect();if(t.height>0||t.width>0)return{top:t.top,left:t.left,right:t.right};var r=e.offsetTop,n=e.offsetLeft;return{top:r,left:n,right:n+e.offsetWidth}}(e),n=(e.textContent||"").trim(),o=(e.getAttribute("title")||"").trim();return t({el:e,text:n||o},r)}).filter(function(e){return e.text.length>0}).sort(function(e,t){return e.top-t.top||e.left-t.left});if(0!==l.length){var u=[],c=null,f=[],h=function(){if(c){var e=f.join(" ");c.title=E(e),c.title&&u.push(c),c=null,f=[]}};if(l.forEach(function(e){if(!c)return c={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(f=[e.text]);var t=Math.abs(e.top-c.lastTop)<=5,r=e.left<=c.lastRight+28;t&&r?(c.elements.push(e.el),c.lastTop=e.top,c.lastRight=Math.max(c.lastRight,e.right),f.push(e.text)):(h(),c={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},f=[e.text])}),h(),0!==u.length){for(var p=function(e,t){if(!e)return!1;if(t.has(e))return!0;for(var r=e.replace(/\s+/g,""),n=0,o=Array.from(t);n<o.length;n++){var i=o[n];if(i){var a=i.replace(/\s+/g,"");if(a===r)return!0;if(i.length>=8&&e.length>=5&&i.includes(e))return!0;if(a.length>=8&&r.length>=5&&a.includes(r))return!0;if(e.length>=10&&i.length>=8&&e.includes(i))return!0;if(r.length>=10&&a.length>=8&&r.includes(a))return!0}}return!1},v=0,d=new Set,m=function(e){if(!e||e.length<8)return null;for(var t=e.replace(/\s+/g,""),r=0;r<u.length;r++)for(var n="",o="",i=new Set,a=r;a<u.length&&a<r+20;a++){var l=u[a].title;if(n=n?"".concat(n," ").concat(l):l,o=o?"".concat(o).concat(l.replace(/\s+/g,"")):l.replace(/\s+/g,""),i.add(a),n.includes(e)||o.includes(t))return i;if(n.length>=15&&(e.includes(n)||t.includes(o)))return i;if(n.length>e.length+150)break}return null},x=0,T=Array.from(new Set(e(e([],P,!0),Z,!0).map(E).filter(function(e){return e.length>=8}))).sort(function(e,t){return t.length-e.length});x<T.length;x++){var y=m(T[x]);y&&y.size>0&&(y.forEach(function(e){return d.add(e)}),v=d.size)}if(0===v){var b=function(e){if(0===e.length)return null;for(var t=null,r=0,n=e;r<n.length;r++)for(var o=n[r],i=0,a=Array.from(o);i<a.length;i++){var l=a[i];if(l&&!(l.length<5))for(var c=l.replace(/\s+/g,""),f=0;f<u.length;f++)for(var g="",h="",s=new Set,p=f;p<u.length&&p<f+15;p++){var v=u[p].title;if(g=g?"".concat(g," ").concat(v):v,h=h?"".concat(h).concat(v.replace(/\s+/g,"")):v.replace(/\s+/g,""),s.add(p),g.includes(l)||h.includes(c)){var d=Math.max(0,g.length-l.length);(!t||d<t.extra)&&(t={blocks:new Set(s),extra:d});break}if(g.length>l.length+120)break}}return t?t.blocks:null}(i);b&&b.size>0&&(b.forEach(function(e){return d.add(e)}),v=d.size)}var w=function(e){if(e.length<2)return 40;for(var t=[],r=1;r<e.length;r++){var n=Math.abs(e[r].lastTop-e[r-1].lastTop);n>0&&t.push(n)}if(0===t.length)return 40;t.sort(function(e,t){return e-t});var o=t[Math.floor(t.length/2)],i=Math.round(2.25*o);return Math.min(60,Math.max(24,i))}(u),I=Z.map(E).filter(function(e){return e.length>=8}),M=I.map(function(e){return e.split(/\s+/).filter(function(e){return e.length>=2})});if(0===v)for(var _=a,S=0;S<u.length;S++)for(var A=u[S].title,k=0;k<_.length;k++)if(p(A,_[k])){for(var q=0,z=new Set,j=k,C=S-1,R=S;R<u.length&&j<_.length;R++){if(p(u[R].title,_[j])){if(C>=0){var N=u[C].lastTop,F=u[R].lastTop;if(Math.abs(F-N)>w)break}q++,z.add(R),C=R,j++}else if(j>0&&p(u[R].title,_[j-1])){N=u[C].lastTop,F=u[R].lastTop;Math.abs(F-N)<=3&&(z.add(R),C=R)}if(R-C>6)break}q>v&&(v=q,d=z)}if(v<Math.min(3,I.length)&&I.length>0){var $=new Set;u.forEach(function(e,t){var r=e.title.split(/\s+/).filter(function(e){return e.length>=2});if(!(r.length<2))for(var n=new Set(r),o=0,i=M;o<i.length;o++){var a=i[o];if(!(a.length<2)){for(var l=0,u=0,c=a;u<c.length;u++){var f=c[u];n.has(f)&&l++}var g=l/a.length;if(l>=3||g>=.5){$.add(t);break}}}}),$.size>0&&(d=$,v=Math.max(v,$.size))}var H=new Set;if(O.forEach(function(e){var t=E(e);t&&(H.add(t),H.add(t.replace(/\s+/g,"")))}),0===v){var L=new Set;if(u.forEach(function(e,t){var r=e.title.replace(/\s+/g,"");if(H.has(e.title)||H.has(r))L.add(t);else for(var n=Array.from(H),o=0;o<n.length;o++){var i=n[o];if(i.length>=10&&i.includes(e.title)&&e.title.length>=5){L.add(t);break}}}),0===L.size)return 0;d=L}u.forEach(function(e,t){var r=d.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})});var D=[];return u.forEach(function(e,t){d.has(t)&&e.elements.forEach(function(e){return D.push(e)})}),requestAnimationFrame(function(){var e=D.map(function(e){return{el:e,rect:e.getBoundingClientRect()}}).filter(function(e){return e.rect.width>0&&e.rect.height>0}).sort(function(e,t){return t.rect.width*t.rect.height-e.rect.width*e.rect.height}),t=[];e.forEach(function(e){var r=e.el,n=e.rect;t.some(function(e){return t=e.rect,r=n,o=Math.max(0,Math.min(t.right,r.right)-Math.max(t.left,r.left))*Math.max(0,Math.min(t.bottom,r.bottom)-Math.max(t.top,r.top)),((i=Math.min(t.width*t.height,r.width*r.height))>0?o/i:0)>.5;var t,r,o,i})?(r.style.display="none",r.classList.remove("verified-match")):t.push({el:r,rect:n})})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(r,"]")),console.log("input->",g),console.log("processed sentences->",P),console.log("processed lines->",Z),console.log("Expected sentence count:",i.length),console.log("Expected line count:",a.length),console.log("Matched sequence length:",v),console.log("blocksToKeep",d,"size",d.size),console.groupEnd(),d.size}}}}}}},R=function(e){s.current&&s.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(function(e){e.style.display="none"})})},N=g.map(function(e){return function(e){return e?k(e).split(/\n{2,}/).map(function(e){return q(e).join(" ")}).map(function(e){return S(e)}).filter(Boolean):[]}(e)}).flat(),F=g.map(function(e){return q(e)}).flat(),$=N.some(function(e){return e.length>=3})?3:1,P=N.filter(function(e){return e.length>=$}),Z=F.filter(function(e){return e.length>=$}),H=Z.flatMap(function(e){return function(e,t,r){void 0===t&&(t=6),void 0===r&&(r=4);var n=e.split(/\s+/).filter(Boolean);if(n.length<=t)return[];for(var o=[],i=0;i+t<=n.length;i+=r)o.push(n.slice(i,i+t).join(" "));return n.length>t&&(n.length-t)%r!==0&&o.push(n.slice(n.length-t).join(" ")),o}(e)}),O=Array.from(new Set(e(e(e([],P,!0),Z,!0),H,!0).flatMap(function(e){var t=S(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];var r=t.replace(/[\u2013\u2014]/g,"-"),n=S(r.replace(/(\w)-\s+(\w)/g,"$1$2")),o=S(r.replace(/-/g," ")),i=S(r.replace(/-/g,"")),a=S(t.replace(/[^\w\s]/g,"")),l=new Set([t,r,n,o,i,a]);return Array.from(l).filter(Boolean)}))).filter(function(e){var t=e.split(/\s+/).filter(Boolean);return!(e.length<$)&&(t.length>=3||e.length>=12)}),L=l({keyword:O}),D=u(),W=c(),K=L.jumpToMatch,J=D.jumpToPage,V=W.zoomTo,G=W.ZoomInButton,Q=W.ZoomOutButton,U=W.ZoomPopover,X=a(function(){return function(r){if(0===r.length)return[];var n=new Map;r.forEach(function(e,r){var o=null!=e.pageNumber?e.pageNumber-1:e.pageIndex;n.has(o)||n.set(o,[]),n.get(o).push(t(t({},e),{originalIndex:r}))});var o=[];return n.forEach(function(t){for(var r=e([],t,!0).sort(function(e,t){return e.top!==t.top?e.top-t.top:e.left-t.left}),n=new Array(r.length).fill(!1),i=0;i<r.length;i++)if(!n[i]){var a=r[i],l=a.left,u=a.top,c=a.width,f=a.height,g=a.pageIndex,h=a.pageNumber,s=l+c,p=u+f;n[i]=!0;for(var v=!0;v;){v=!1;for(var d=i+1;d<r.length;d++)if(!n[d]){var m=r[d],x=m.left+m.width,T=m.top+m.height;l<=x+1&&s>=m.left-1&&u<=T+1&&p>=m.top-1&&(l=Math.min(l,m.left),u=Math.min(u,m.top),c=(s=Math.max(s,x))-l,f=(p=Math.max(p,T))-u,n[d]=!0,v=!0)}}o.push({pageIndex:g,pageNumber:h,left:l,top:u,width:c,height:f})}}),o}(d)},[d]),Y=f({renderHighlights:function(e){return r(n,{children:X.map(function(e,r){return t(t({},e),{mergedIndex:r})}).filter(function(t){return null!=t.pageNumber?t.pageNumber-1===e.pageIndex:t.pageIndex===e.pageIndex}).map(function(t){var n=d[M],o=null!=n&&(null!=n.pageNumber?n.pageNumber-1===e.pageIndex:n.pageIndex===e.pageIndex)&&n.left>=t.left-1&&n.left<=t.left+t.width+1&&n.top>=t.top-1&&n.top<=t.top+t.height+1;return r("div",{style:{position:"absolute",left:"".concat(t.left,"%"),top:"".concat(t.top,"%"),width:"".concat(t.width,"%"),height:"".concat(t.height,"%"),background:o?x:m,opacity:o?.7:.4,transition:"background 0.2s, opacity 0.2s"}},t.mergedIndex)})})}}),ee=function(){if(!w.current)try{K(0),w.current=!0;var e=d[0];e&&v&&re(e.pageIndex,e.top)}catch(e){requestAnimationFrame(ee)}},te=function(e,t){if(s.current&&s.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var o,i,a=null===(o=s.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(i=s.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.querySelectorAll(".rpv-search__highlight")[t];if(u){var c=a.getBoundingClientRect(),f=u.getBoundingClientRect(),g=a.scrollTop+(f.top-c.top)-a.clientHeight/2+f.height/2;a.scrollTo({top:g,behavior:"smooth"})}}}};setTimeout(n,300)}},re=function(e,t){if(s.current){var r=0,n=function(){var o,i;if(!(++r>60)){var a=null===(o=s.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){var l=null===(i=s.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.getBoundingClientRect();if(0!==u.height){var c=a.getBoundingClientRect(),f=t/100*u.height,g=u.top-c.top+f;a.scrollTo({top:a.scrollTop+g-40,behavior:"smooth"})}else setTimeout(n,100)}else setTimeout(n,100)}else setTimeout(n,100)}};setTimeout(n,100)}},ne=a(function(){var e={};return z.forEach(function(t,r){var n=h[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[z,h]),oe=function(e){var t=h[z[e]];return(ne[t]||[]).indexOf(e)},ie=function(e,t){if(s.current){var r=-1,n=0,o=function(){var i,a;if(!(++n>60)){var l=null===(i=s.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(l){if(l.scrollTop!==r)return r=l.scrollTop,void setTimeout(o,100);var u=null===(a=s.current)||void 0===a?void 0:a.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(u){var c=u.getBoundingClientRect();if(0!==c.height){var f=l.getBoundingClientRect(),g=t/100*c.height,h=c.top-f.top+g;l.scrollTo({top:l.scrollTop+h-40,behavior:"instant"})}else setTimeout(o,100)}else setTimeout(o,100)}else setTimeout(o,100)}};setTimeout(o,100)}};return{setHighlightIndex:b,highlightIndex:y,cursorIndex:M,setCursorIndex:_,orderedKeys:z,totalHighlights:j,getValidPosition:function(e){if(v)return e+1;if(!h)return 0;for(var t=0,r=0;r<=e;r++)h[z[r]]>0&&t++;return t},tryJump:ee,jumpToPage:J,zoomTo:V,hideNonTargetHighlights:R,deduplicateHighlights:C,scrollToCoord:re,plugins:[v?Y:L,D,W],controls:{ZoomInButton:G,ZoomOutButton:Q,ZoomPopover:U,goToNext:function(){if(v&&d)for(var e=M+1;e<d.length;e++){var t=d[e],r=d[M];return _(e),J(t.pageIndex),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),ie(t.pageIndex,t.top)):re(t.pageIndex,t.top))}else{var n=function(e){var t=z[e];if(h[t]>0){var r=h[t]-1,n=oe(e);return _(e),J(h[t]-1),te(r,n),setTimeout(function(){C(r)},500),1===Object.keys(h).length&&R(p),{value:void 0}}};for(e=M+1;e<z.length;e++){var o=n(e);if("object"==typeof o)return o.value}}},goToPrevious:function(){if(v&&d)for(var e=M-1;e>=0;e--){var t=d[e],r=d[M];return _(e),J(t.pageIndex),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),ie(t.pageIndex,t.top)):re(t.pageIndex,t.top))}else{var n=function(e){var t=z[e];if(h[t]>0){var r=h[t]-1,n=oe(e);return _(e),J(h[t]-1),te(r,n),setTimeout(function(){C(r)},500),1===Object.keys(h).length&&R(p),{value:void 0}}};for(e=M-1;e>=0;e--){var o=n(e);if("object"==typeof o)return o.value}}}}}};export{g as PdfHighlightControls};
|
|
1
|
+
import{__spreadArray as e,__assign as t}from"tslib";import{jsx as r,Fragment as n}from"react/jsx-runtime";import{useState as i,useRef as o,useMemo as a}from"react";import{searchPlugin as l}from"@react-pdf-viewer/search";import{pageNavigationPlugin as c}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as u}from"@react-pdf-viewer/zoom";import{highlightPlugin as h}from"@react-pdf-viewer/highlight";var f=function(f,g,s,p,v,d,m,x){void 0===m&&(m="yellow"),void 0===x&&(x="#F6D739");var T=i(0),y=T[0],b=T[1],w=o(!1),M=i(0),I=M[0],_=M[1];o([]);var S=function(e){return e.replace(/[^\S\n]+/g," ").trim()},E=function(e){return(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},A=function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t},B=function(e){var t=E(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},k=function(e){return e.replace(/\\([''])/g,"$1").replace(/\]\s*\n\s*\(/g,"](").replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/`([^`]+)`/g,"$1")},j=function(e){return e?k(e).split(/\n+/).map(A).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return S(function(e){return e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2")}(e))}).filter(Boolean):[]},q=Object.keys(g).map(Number).sort(function(e,t){return e-t}),z=a(function(){return v?d.length:v?0:Object.values(g).filter(function(e){return e>0}).length},[d,g]),C=function(r){if(s.current){var n=s.current.querySelector('[data-testid="search__highlights-'.concat(r,'"]'));if(n){var i=Array.from(n.querySelectorAll(".rpv-search__highlight"));if(0!==i.length){var o=$.map(B),a=P.map(B);if(0!==o.length||0!==a.length){var l=i.map(function(e){var r=function(e){var t=e.getBoundingClientRect();if(t.height>0||t.width>0)return{top:t.top,left:t.left,right:t.right};var r=e.offsetTop,n=e.offsetLeft;return{top:r,left:n,right:n+e.offsetWidth}}(e),n=(e.textContent||"").trim(),i=(e.getAttribute("title")||"").trim();return t({el:e,text:n||i},r)}).filter(function(e){return e.text.length>0}).sort(function(e,t){return e.top-t.top||e.left-t.left});if(0!==l.length){var c=[],u=null,h=[],g=function(){if(u){var e=h.join(" ");u.title=E(e),u.title&&c.push(u),u=null,h=[]}};if(l.forEach(function(e){if(!u)return u={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(h=[e.text]);var t=Math.abs(e.top-u.lastTop)<=5,r=e.left<=u.lastRight+28;t&&r?(u.elements.push(e.el),u.lastTop=e.top,u.lastRight=Math.max(u.lastRight,e.right),h.push(e.text)):(g(),u={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},h=[e.text])}),g(),0!==c.length){for(var p=function(e,t){if(!e)return!1;if(t.has(e))return!0;for(var r=e.replace(/\s+/g,""),n=0,i=Array.from(t);n<i.length;n++){var o=i[n];if(o){var a=o.replace(/\s+/g,"");if(a===r)return!0;if(o.length>=8&&e.length>=5&&o.includes(e))return!0;if(a.length>=8&&r.length>=5&&a.includes(r))return!0;if(e.length>=10&&o.length>=8&&e.includes(o))return!0;if(r.length>=10&&a.length>=8&&r.includes(a))return!0}}return!1},v=0,d=new Set,m=function(e){if(!e||e.length<8)return null;for(var t=e.replace(/\s+/g,""),r=0;r<c.length;r++)for(var n="",i="",o=new Set,a=r;a<c.length&&a<r+20;a++){var l=c[a].title;if(n=n?"".concat(n," ").concat(l):l,i=i?"".concat(i).concat(l.replace(/\s+/g,"")):l.replace(/\s+/g,""),o.add(a),n.includes(e)||i.includes(t))return o;if(n.length>=15&&(e.includes(n)||t.includes(i)))return o;if(n.length>e.length+150)break}return null},x=0,T=Array.from(new Set(e(e([],$,!0),P,!0).map(E).filter(function(e){return e.length>=8}))).sort(function(e,t){return t.length-e.length});x<T.length;x++){var y=m(T[x]);y&&y.size>0&&(y.forEach(function(e){return d.add(e)}),v=d.size)}if(0===v){var b=function(e){if(0===e.length)return null;for(var t=null,r=0,n=e;r<n.length;r++)for(var i=n[r],o=0,a=Array.from(i);o<a.length;o++){var l=a[o];if(l&&!(l.length<5))for(var u=l.replace(/\s+/g,""),h=0;h<c.length;h++)for(var f="",g="",s=new Set,p=h;p<c.length&&p<h+15;p++){var v=c[p].title;if(f=f?"".concat(f," ").concat(v):v,g=g?"".concat(g).concat(v.replace(/\s+/g,"")):v.replace(/\s+/g,""),s.add(p),f.includes(l)||g.includes(u)){var d=Math.max(0,f.length-l.length);(!t||d<t.extra)&&(t={blocks:new Set(s),extra:d});break}if(f.length>l.length+120)break}}return t?t.blocks:null}(o);b&&b.size>0&&(b.forEach(function(e){return d.add(e)}),v=d.size)}var w=function(e){if(e.length<2)return 40;for(var t=[],r=1;r<e.length;r++){var n=Math.abs(e[r].lastTop-e[r-1].lastTop);n>0&&t.push(n)}if(0===t.length)return 40;t.sort(function(e,t){return e-t});var i=t[Math.floor(t.length/2)],o=Math.round(2.25*i);return Math.min(60,Math.max(24,o))}(c),M=P.map(E).filter(function(e){return e.length>=8}),I=M.map(function(e){return e.split(/\s+/).filter(function(e){return e.length>=2})});if(0===v)for(var _=a,S=0;S<c.length;S++)for(var A=c[S].title,k=0;k<_.length;k++)if(p(A,_[k])){for(var j=0,q=new Set,z=k,C=S-1,R=S;R<c.length&&z<_.length;R++){if(p(c[R].title,_[z])){if(C>=0){var H=c[C].lastTop,F=c[R].lastTop;if(Math.abs(F-H)>w)break}j++,q.add(R),C=R,z++}else if(z>0&&p(c[R].title,_[z-1])){H=c[C].lastTop,F=c[R].lastTop;Math.abs(F-H)<=3&&(q.add(R),C=R)}if(R-C>6)break}j>v&&(v=j,d=q)}if(v<Math.min(3,M.length)&&M.length>0){var N=new Set;c.forEach(function(e,t){var r=e.title.split(/\s+/).filter(function(e){return e.length>=2});if(!(r.length<2))for(var n=new Set(r),i=0,o=I;i<o.length;i++){var a=o[i];if(!(a.length<2)){for(var l=0,c=0,u=a;c<u.length;c++){var h=u[c];n.has(h)&&l++}var f=l/a.length;if(l>=3||f>=.5){N.add(t);break}}}}),N.size>0&&(d=N,v=Math.max(v,N.size))}var Z=new Set;if(O.forEach(function(e){var t=E(e);t&&(Z.add(t),Z.add(t.replace(/\s+/g,"")))}),0===v){var L=new Set;if(c.forEach(function(e,t){var r=e.title.replace(/\s+/g,"");if(Z.has(e.title)||Z.has(r))L.add(t);else for(var n=Array.from(Z),i=0;i<n.length;i++){var o=n[i];if(o.length>=10&&o.includes(e.title)&&e.title.length>=5){L.add(t);break}}}),0===L.size)return 0;d=L}c.forEach(function(e,t){var r=d.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})});var D=[];return c.forEach(function(e,t){d.has(t)&&e.elements.forEach(function(e){return D.push(e)})}),requestAnimationFrame(function(){var e=D.map(function(e){return{el:e,rect:e.getBoundingClientRect()}}).filter(function(e){return e.rect.width>0&&e.rect.height>0}).sort(function(e,t){return t.rect.width*t.rect.height-e.rect.width*e.rect.height}),t=[];e.forEach(function(e){var r=e.el,n=e.rect;t.some(function(e){return t=e.rect,r=n,i=Math.max(0,Math.min(t.right,r.right)-Math.max(t.left,r.left))*Math.max(0,Math.min(t.bottom,r.bottom)-Math.max(t.top,r.top)),((o=Math.min(t.width*t.height,r.width*r.height))>0?i/o:0)>.5;var t,r,i,o})?(r.style.display="none",r.classList.remove("verified-match")):t.push({el:r,rect:n})})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(r,"]")),console.log("input->",f),console.log("processed sentences->",$),console.log("processed lines->",P),console.log("Expected sentence count:",o.length),console.log("Expected line count:",a.length),console.log("Matched sequence length:",v),console.log("blocksToKeep",d,"size",d.size),console.groupEnd(),d.size}}}}}}},R=function(e){s.current&&s.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),i=t.querySelectorAll(".rpv-search__highlight");e.has(n)||i.forEach(function(e){e.style.display="none"})})},H=f.map(function(e){return function(e){return e?k(e).split(/\n{2,}/).map(function(e){return j(e).join(" ")}).map(function(e){return S(e)}).filter(Boolean):[]}(e)}).flat(),F=f.map(function(e){return j(e)}).flat(),N=H.some(function(e){return e.length>=3})?3:1,$=H.filter(function(e){return e.length>=N}),P=F.filter(function(e){return e.length>=N}),Z=P.flatMap(function(e){return function(e,t,r){void 0===t&&(t=6),void 0===r&&(r=4);var n=e.split(/\s+/).filter(Boolean);if(n.length<=t)return[];for(var i=[],o=0;o+t<=n.length;o+=r)i.push(n.slice(o,o+t).join(" "));return n.length>t&&(n.length-t)%r!==0&&i.push(n.slice(n.length-t).join(" ")),i}(e)}),O=Array.from(new Set(e(e(e([],$,!0),P,!0),Z,!0).flatMap(function(e){var t=S(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];var r=t.replace(/[\u2013\u2014]/g,"-"),n=S(r.replace(/(\w)-\s+(\w)/g,"$1$2")),i=S(r.replace(/-/g," ")),o=S(r.replace(/-/g,"")),a=S(t.replace(/[^\w\s]/g,"")),l=new Set([t,r,n,i,o,a]);return Array.from(l).filter(Boolean)}))).filter(function(e){var t=e.split(/\s+/).filter(Boolean);return!(e.length<N)&&(t.length>=3||e.length>=12)}),L=l({keyword:O}),D=c(),W=u(),K=L.jumpToMatch,J=D.jumpToPage,V=W.zoomTo,G=W.ZoomInButton,Q=W.ZoomOutButton,U=W.ZoomPopover,X=a(function(){return function(r){if(0===r.length)return[];var n=new Map;r.forEach(function(e,r){var i=null!=e.pageNumber?e.pageNumber-1:e.pageIndex;n.has(i)||n.set(i,[]),n.get(i).push(t(t({},e),{originalIndex:r}))});var i=[];return n.forEach(function(t){for(var r=e([],t,!0).sort(function(e,t){return e.top!==t.top?e.top-t.top:e.left-t.left}),n=new Array(r.length).fill(!1),o=0;o<r.length;o++)if(!n[o]){var a=r[o],l=a.left,c=a.top,u=a.width,h=a.height,f=a.pageIndex,g=a.pageNumber,s=l+u,p=c+h,v=[r[o].originalIndex];n[o]=!0;for(var d=!0;d;){d=!1;for(var m=o+1;m<r.length;m++)if(!n[m]){var x=r[m],T=x.left+x.width,y=x.top+x.height,b=Math.max(0,Math.min(s,T)-Math.max(l,x.left))*Math.max(0,Math.min(p,y)-Math.max(c,x.top)),w=Math.max(u*h,1e-4),M=Math.max(x.width*x.height,1e-4),I=Math.min(w,M);(I>0?b/I:0)>=.8&&(l=Math.min(l,x.left),c=Math.min(c,x.top),u=(s=Math.max(s,T))-l,h=(p=Math.max(p,y))-c,v.push(x.originalIndex),n[m]=!0,d=!0)}}i.push({pageIndex:f,pageNumber:g,left:l,top:c,width:u,height:h,originalIndexes:v})}}),i}(d)},[d]),Y=h({renderHighlights:function(e){return r(n,{children:X.filter(function(t){return null!=t.pageNumber?t.pageNumber-1===e.pageIndex:t.pageIndex===e.pageIndex}).map(function(e){var t=e.originalIndexes.includes(I);return r("div",{style:{position:"absolute",left:"".concat(e.left,"%"),top:"".concat(e.top+.08*e.height,"%"),width:"".concat(e.width,"%"),height:"".concat(.95*e.height,"%"),background:t?x:m,opacity:t?.7:.4,transition:"background 0.2s, opacity 0.2s",border:t?"1px solid ".concat("red"):"1px solid transparent"}},e.originalIndexes.join("-"))})})}}),ee=function(){if(!w.current)try{K(0),w.current=!0;var e=d[0];e&&v&&re(e.pageIndex,e.top)}catch(e){requestAnimationFrame(ee)}},te=function(e,t){if(s.current&&s.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var i,o,a=null===(i=s.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(o=s.current)||void 0===o?void 0:o.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var c=l.querySelectorAll(".rpv-search__highlight")[t];if(c){var u=a.getBoundingClientRect(),h=c.getBoundingClientRect(),f=a.scrollTop+(h.top-u.top)-a.clientHeight/2+h.height/2;a.scrollTo({top:f,behavior:"smooth"})}}}};setTimeout(n,300)}},re=function(e,t,r){if(void 0===r&&(r=0),s.current){var n=0,i=function(){var o,a;if(!(++n>60)){var l=null===(o=s.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(l){var c=null===(a=s.current)||void 0===a?void 0:a.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(c){var u=c.getBoundingClientRect();if(0!==u.height){var h=l.getBoundingClientRect(),f=t/100*u.height,g=r/100*u.height,p=u.top-h.top+f,v=p+g;if(!(p>=80&&v<=l.clientHeight-80)){var d=p<80?l.scrollTop+p-80:l.scrollTop+v-l.clientHeight+80;l.scrollTo({top:d,behavior:"smooth"})}}else setTimeout(i,100)}else setTimeout(i,100)}else setTimeout(i,100)}};setTimeout(i,100)}},ne=a(function(){var e={};return q.forEach(function(t,r){var n=g[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[q,g]),ie=function(e){var t=g[q[e]];return(ne[t]||[]).indexOf(e)},oe=function(e,t,r){if(void 0===r&&(r=0),s.current){var n=-1,i=0,o=function(){var a,l;if(!(++i>60)){var c=null===(a=s.current)||void 0===a?void 0:a.querySelector(".rpv-core__inner-pages");if(c){if(c.scrollTop!==n)return n=c.scrollTop,void setTimeout(o,100);var u=null===(l=s.current)||void 0===l?void 0:l.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(u){var h=u.getBoundingClientRect();if(0!==h.height){var f=c.getBoundingClientRect(),g=t/100*h.height,p=r/100*h.height,v=h.top-f.top+g,d=v+p;if(!(v>=80&&d<=c.clientHeight-80)){var m=v<80?c.scrollTop+v-80:c.scrollTop+d-c.clientHeight+80;c.scrollTo({top:m,behavior:"instant"})}}else setTimeout(o,100)}else setTimeout(o,100)}else setTimeout(o,100)}};setTimeout(o,100)}};return{setHighlightIndex:b,highlightIndex:y,cursorIndex:I,setCursorIndex:_,orderedKeys:q,totalHighlights:z,getValidPosition:function(e){if(v)return e+1;if(!g)return 0;for(var t=0,r=0;r<=e;r++)g[q[r]]>0&&t++;return t},tryJump:ee,jumpToPage:J,zoomTo:V,hideNonTargetHighlights:R,deduplicateHighlights:C,scrollToCoord:re,plugins:[v?Y:L,D,W],controls:{ZoomInButton:G,ZoomOutButton:Q,ZoomPopover:U,goToNext:function(){if(v&&d)for(var e=I+1;e<d.length;e++){var t=d[e],r=d[I];return _(e),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),oe(t.pageIndex,t.top,t.height)):re(t.pageIndex,t.top,t.height))}else{var n=function(e){var t=q[e];if(g[t]>0){var r=g[t]-1,n=ie(e);return _(e),J(g[t]-1),te(r,n),setTimeout(function(){C(r)},500),1===Object.keys(g).length&&R(p),{value:void 0}}};for(e=I+1;e<q.length;e++){var i=n(e);if("object"==typeof i)return i.value}}},goToPrevious:function(){if(v&&d)for(var e=I-1;e>=0;e--){var t=d[e],r=d[I];return _(e),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),oe(t.pageIndex,t.top,t.height)):re(t.pageIndex,t.top,t.height))}else{var n=function(e){var t=q[e];if(g[t]>0){var r=g[t]-1,n=ie(e);return _(e),J(g[t]-1),te(r,n),setTimeout(function(){C(r)},500),1===Object.keys(g).length&&R(p),{value:void 0}}};for(e=I-1;e>=0;e--){var i=n(e);if("object"==typeof i)return i.value}}}}}};export{f as PdfHighlightControls};
|
|
2
2
|
//# sourceMappingURL=usePdfHighlight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,oBAAoB,+
|
|
1
|
+
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,oBAAoB,+CA4MzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|