@viswa-test/test-citation 0.0.230 → 0.0.232
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/Guidelines/components/GuidelinePanel.js +2 -0
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -0
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/connectedLines.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js +2 -0
- package/dist/cjs/features/GptWebCitation/GptWebCitationMarkdown.js.map +1 -0
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
- package/dist/cjs/features/RequirementAI/components/RichTextEditor/Editor/theme/theme.css.js +1 -1
- package/dist/cjs/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
- package/dist/cjs/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
- package/dist/cjs/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
- package/dist/cjs/features/RequirementAI/utils/helpers.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +2 -0
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -0
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/connectedLines.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/features/GptWebCitation/GptWebCitationMarkdown.js +2 -0
- package/dist/features/GptWebCitation/GptWebCitationMarkdown.js.map +1 -0
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/Editor.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.js +1 -1
- package/dist/features/RequirementAI/components/RichTextEditor/Editor/theme/theme.css.js +1 -1
- package/dist/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.js +1 -1
- package/dist/features/RequirementAI/components/UserStoryCard/UserStoryCard.js +1 -1
- package/dist/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.js +1 -1
- package/dist/features/RequirementAI/utils/helpers.js +1 -1
- package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
- package/dist/types/src/RedlineApprovalCardTest.d.ts +1 -0
- package/dist/types/src/RedlineApprovalCardTest.d.ts.map +1 -0
- package/dist/types/src/RedlineEditorTest.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +5 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.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/Guidelines/components/GuidelinePanel.d.ts +3 -0
- package/dist/types/src/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -0
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +3379 -0
- package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -0
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/connectedLines.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +2 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/Editor.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.d.ts +2 -6
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/ManualNode.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.d.ts +2 -6
- package/dist/types/src/features/RequirementAI/components/RichTextEditor/Editor/plugins/UpdateNode.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts +6 -12
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/Popups/DeviationSummary.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts +2 -1
- package/dist/types/src/features/RequirementAI/components/UserStoryCard/UserStoryCard.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts +0 -4
- package/dist/types/src/features/RequirementAI/components/userstory-with-citation/UserStoryWithCitation.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/components/userstory-with-citation/components/InlineUpdatedComponent.d.ts.map +1 -1
- package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts +0 -1
- package/dist/types/src/features/RequirementAI/types/aiReasoning.type.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as n,__awaiter as i,__generator as t}from"tslib";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{useState as l,useRef as u,useMemo as c,useEffect as a,useCallback as s}from"react";import{Box as d,Snackbar as v,Alert as f,Tooltip as p,Typography as g}from"@mui/material";import{ChevronDown as m}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import S from"./OverlayComponent.js";import{safeStringify as x,extractDeviationScore as R,generateColorPalette as y,findKeyPathByNodeId as b,DEVIATION_BADGE_SEPARATOR as C,hasMeaningfulRedlineTags as w,scrollAndHighlightClause as _,scrollAndWait as B,waitForScrollIdle as E}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as F,DEFAULT_FIELD_CONFIG as I,DEFAULT_COMPARISON_CONFIG as T}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as A,EMPTY_SUMMARY_POPUP_STATE as D,DEFAULT_COMPONENT_HEADER_TEXT as O}from"./CognitiveCompareConstants.js";import P from"./CognitivePopup.js";import k from"./MoreFunctionsPopup.js";import L from"./LoaderComponent.js";import j from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as N}from"./hooks/useCompareData.js";import{useComparePopups as H}from"./hooks/useComparePopups.js";import{useSectionRefs as M}from"./hooks/useSectionRefs.js";import{useAccordionState as z}from"./hooks/useAccordionState.js";import{useDeviationNavigation as q}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import W from"./components/SubSectionAccordion.js";import K from"./components/LHSSectionRow.js";import J from"./components/RHSSectionRow.js";import Y from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as X}from"./CompareContext.js";import{useStyleHelpers as $}from"./hooks/useStyles.js";import{useResizeHandler as U}from"./hooks/useResizeHandler.js";import{useLinesCalculator as G}from"./hooks/useLinesCalculator.js";import{useSideBySide as Q}from"./hooks/useSideBySide.js";import Z from"./components/SvgConnectors.js";var ee=function(ee){var ne,ie,te,oe,re,le,ue,ce,ae,se,de,ve,fe,pe,ge,me,he,Se,xe,Re,ye,be,Ce,we,_e,Be,Ee,Fe,Ie,Te,Ae,De,Oe,Pe,ke,Le=ee.componentHeaderText,je=void 0===Le?O:Le,Ne=ee.treeData,He=ee.comparisonConfig,Me=ee.leftColumnTitleText,ze=ee.rightColumnTitleText,qe=ee.markdownStyles,Ve=ee.resetTrigger,We=ee.displayConfig,Ke=void 0===We?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:We,Je=ee.onMaintainRelativeOrderChange,Ye=ee.popupConfig,Xe=ee.deviationData,$e=void 0===Xe?{}:Xe,Ue=ee.deviationNodeIdToView,Ge=ee.resetDeviationNodeId,Qe=ee.isProposingFix,Ze=void 0!==Qe&&Qe,en=ee.proposingFixNodeId,nn=ee.isRedlineFlow,tn=ee.badgeStyleOverride,on=l(Ke.maintainRelativeOrder),rn=on[0],ln=on[1],un=null!==(ne=null==Ke?void 0:Ke.expandLevels)&&void 0!==ne?ne:0,cn=!!(null==Ke?void 0:Ke.expandAllSections),an=!!rn||!!(null==Ke?void 0:Ke.showDeviationBadges),sn=l(!1),dn=sn[0],vn=sn[1],fn=l(null),pn=fn[0],gn=fn[1],mn=l(null===(te=null!==(ie=null==Ne?void 0:Ne.newEvaluationResult)&&void 0!==ie?ie:null==Ke?void 0:Ke.enableDeviationSchemaBackwardCompatibility)||void 0===te||te)[0],hn=l(new Set),Sn=hn[0],xn=hn[1],Rn=l([]),yn=Rn[0],bn=Rn[1],Cn=l(!1),wn=Cn[0],_n=Cn[1],Bn=u(null),En=u(null),Fn=u(null),In=u(null),Tn=u(null),An=u(!1),Dn=u(null),On=u({}),Pn=u([]),kn=u(function(){}),Ln=u(null),jn=u(function(){}),Nn=c(function(){return JSON.stringify($e||{})},[JSON.stringify($e)]),Hn=c(function(){return $e||{}},[Nn]),Mn=c(function(){return(null==Ne?void 0:Ne.cognitive_decisioning)||{}},[Ne]),zn=c(function(){return e(e({},F),qe)},[qe]),qn=u(null),Vn=u(null),Wn=u(null),Kn=u(null),Jn=u(null),Yn=u(null),Xn=u(null),$n=u(null),Un=u(null),Gn=u(null),Qn=H(qn),Zn=Qn.cognitivePopup,ei=Qn.setCognitivePopup,ni=Qn.moreFunctions,ii=Qn.setMoreFunctions,ti=Qn.position,oi=Qn.setPosition,ri=Qn.activeBadgeId,li=Qn.summaryPopup,ui=Qn.setSummaryPopup,ci=Qn.closeSummaryPopup,ai=Qn.setActiveBadgeId,si=Qn.popupRef,di=Qn.handleOpenCognitiveCompare,vi=Qn.openCognitivePopupFromState,fi=Qn.closeCognitivePopup,pi=Qn.closeMoreFunctionsPopup,gi=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==He?void 0:He.fields)&&void 0!==e?e:I,thresholds:{high:null!==(i=null===(n=null==He?void 0:He.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:T.thresholds.high,medium:null!==(o=null===(t=null==He?void 0:He.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:T.thresholds.medium,exact:null!==(l=null===(r=null==He?void 0:He.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:T.thresholds.exact}}},[He]),mi=l(null),hi=mi[0];mi[1];var Si=null===(le=null===(oe=null==Ne?void 0:Ne.documents)||void 0===oe?void 0:oe[null===(re=null==Ne?void 0:Ne.input_index_map)||void 0===re?void 0:re[0]])||void 0===le?void 0:le.title,xi=null===(ae=null===(ue=null==Ne?void 0:Ne.documents)||void 0===ue?void 0:ue[null===(ce=null==Ne?void 0:Ne.input_index_map)||void 0===ce?void 0:ce[1]])||void 0===ae?void 0:ae.title,Ri=x(Me||Si||"Uploaded Contract"),yi=null===(fe=null===(ve=null===(se=null==Ne?void 0:Ne.documents)||void 0===se?void 0:se[null===(de=null==Ne?void 0:Ne.input_index_map)||void 0===de?void 0:de[0]])||void 0===ve?void 0:ve.metadata)||void 0===fe?void 0:fe.file_name,bi=x(yi),Ci=null===(he=null===(me=null===(pe=null==Ne?void 0:Ne.documents)||void 0===pe?void 0:pe[null===(ge=null==Ne?void 0:Ne.input_index_map)||void 0===ge?void 0:ge[1]])||void 0===me?void 0:me.metadata)||void 0===he?void 0:he.file_name,wi=x(Ci),_i=x(ze||xi||"Reference Template"),Bi=N(Ne,rn,Hn,gi,mn),Ei=Bi.activeProposed,Fi=Bi.existingRule,Ii=Bi.proposedSections,Ti=Bi.existingSections,Ai=Bi.visibleFields,Di=Bi.parentDeviationRecord,Oi=Bi.deviationNumberRegistry,Pi=Bi.deviationParentRegistry,ki=Bi.parseError;a(function(){ki&&gn("Failed to load comparison: ".concat(ki))},[ki]);var Li=Ii.length>0||Ti.length>0,ji=c(function(){if(!nn)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";w(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(Ii),i(Ti),"".concat(e,":").concat(n)},[nn,Ii,Ti]);a(function(){if(Ii.length||Ti.length)if(cn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=rn?"".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(Ii,"left"),i(Ti,"right"),St(e),Rt(n)}else if(un>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=rn?"".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(Ii,"left",un),r(Ti,"right",un),St(t),Rt(o)}},[cn,un,Ii,Ti,rn]);var Ni=M(Ai.map(function(e){return e.key}),Math.max(Ii.length,Ti.length)),Hi=Ni.leftRefs,Mi=Ni.rightRefs,zi=Ni.sectionLeftRefs,qi=Ni.sectionRightRefs,Vi=Ni.lhsBadgeRefs,Wi=Ni.rhsBadgeRefs,Ki=Ni.sectionRightRowRefs,Ji=Ni.subSectionLeftRefs,Yi=Ni.subSectionRightRefs,Xi=Ni.sectionRowRefs,$i=Ni.getSectionRowRef,Ui=Ni.getSubSectionRef,Gi=Ni.getBadgeRef,Qi=Q({maintainRelativeOrder:rn,proposedSections:Ii,existingSections:Ti,leftContainerRef:$n,rightContainerRef:Wn,scrollContainerRef:qn,sectionLeftRefs:zi,sectionRightRefs:qi,subSectionLeftRefs:Ji,subSectionRightRefs:Yi,lhsBadgeRefs:Vi,rhsBadgeRefs:Wi,sectionRowRefs:Xi,sectionRightRowRefs:Ki,rhsTopSpacerRef:Kn,rhsBottomSpacerRef:Jn,lhsTopSpacerRef:Yn,lhsBottomSpacerRef:Xn,calculateLinesRef:kn,setConnectedSections:xn,setConnectedLines:bn,cachedConnectedPositions:Pn,closeMoreFunctionsPopup:pi,setErrorToast:gn,moreFunctions:ni,closeSummaryPopup:ci}),Zi=Qi.isSideBySide,et=Qi.isArrowVisible,nt=Qi.setIsArrowVisible,it=Qi.isResizing,tt=Qi.setIsResizing,ot=Qi.isSideBySideLoading,rt=Qi.activeSideBySideSection,lt=Qi.scrollLock,ut=Qi.sideBySideCacheRef,ct=Qi.isSideBySideRef,at=Qi.activeSideBySideRightSectionRef,st=Qi.activeSideBySideSectionRef,dt=Qi.sideBySideLineRef,vt=Qi.highlightedClauseRefs,ft=Qi.clearClauseHighlight,pt=Qi.resetSideBySide,gt=Qi.activateSideBySide,mt=z({maintainRelativeOrder:!!rn,proposedSections:Ii,existingSections:Ti,activeSideBySideSection:rt,connectedSections:Sn,resetSideBySide:pt,setConnectedSections:xn,setConnectedLines:bn,cachedConnectedPositions:Pn,svgContainerRef:Bn,isAnimatingRef:An,animationTimerRef:Dn,calculateLinesRef:kn,sectionLeftRefs:zi,sectionRightRefs:qi,subSectionLeftRefs:Ji,subSectionRightRefs:Yi}),ht=mt.expandedSections,St=mt.setExpandedSections,xt=mt.expandedSubSections,Rt=mt.setExpandedSubSections,yt=mt.handleSubSectionToggle,bt=mt.toggleSection,Ct=mt.forceExpandCrossWiredSections,wt=function(){var e,n;if(null!=rt){var i=null===(e=zi.current[rt])||void 0===e?void 0:e.current,t=null===(n=qi.current[rt])||void 0===n?void 0:n.current,o=Wn.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"})}}},_t=s(function(e){null==e||e.stopPropagation(),_n(function(e){var n=!e;return n&&requestAnimationFrame(function(){wt()}),n})},[wt]);a(function(){nn&&"off"!==ji&&"0:0"!==ji&&(ut.current=null,Pn.current=[],requestAnimationFrame(function(){var e;null===(e=kn.current)||void 0===e||e.call(kn)}))},[nn,ji]);var Bt=c(function(){var e=new Map,n=new Map,i=1;if(rn)Ii.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Ti.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=Ii.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(Ii.length,Ti.length),o=0;o<t;o++){var r=Ii[o],l=Ti[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}},[Ii,Ti,rn]),Et=Fi.analysis,Ft=x(null===(xe=null===(Se=null==Et?void 0:Et.rule_difference_comparison)||void 0===Se?void 0:Se.summary)||void 0===xe?void 0:xe.overall_summary),It=!!Ft.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Tt=null!==(Re=null==Ne?void 0:Ne.base_root_id)&&void 0!==Re?Re:"-1";null==Ne||Ne[Tt];var At=mn?null!==(De=null!==(Ie=$e&&(null===(Fe=null==$e?void 0:$e[Tt])||void 0===Fe?void 0:Fe.evaluation_result))&&void 0!==Ie?Ie:null===(Ae=null===(Te=null==Ne?void 0:Ne.nodes)||void 0===Te?void 0:Te[Tt])||void 0===Ae?void 0:Ae.evaluation_result)&&void 0!==De?De:null:null!==(Ee=null!==(Ce=$e&&(null===(be=null===(ye=null==$e?void 0:$e[Tt])||void 0===ye?void 0:ye.evaluation_result)||void 0===be?void 0:be[0]))&&void 0!==Ce?Ce:null===(Be=null===(_e=null===(we=null==Ne?void 0:Ne.nodes)||void 0===we?void 0:we[Tt])||void 0===_e?void 0:_e.evaluation_result)||void 0===Be?void 0:Be[0])&&void 0!==Ee?Ee:null,Dt=R(At),Ot=y(null!==(ke=null===(Pe=null===(Oe=null==At?void 0:At.evaluation_outputs)||void 0===Oe?void 0:Oe.metadata)||void 0===Pe?void 0:Pe.label_color)&&void 0!==ke?ke:A);if(tn){var Pt=tn(Dt);Pt&&(Ot=e(e({},Ot),{badgeBg:Pt.bg,badgeText:Pt.text,badgeBorder:Pt.border}))}var kt=u(pt);a(function(){kt.current=pt},[pt]);var Lt=u(fi);a(function(){Lt.current=fi},[fi]);var jt=s(function(e,n,i,t,o,r){return qo.current(e,n,i,t,o,r)},[]),Nt=s(function(e,n,i,t,o){return Wo.current(e,n,i,t,o)},[]),Ht=s(function(){return Ko.current()},[]),Mt=s(function(e,n){return Jo.current(e,n)},[]),zt=s(function(e){return Yo.current(e)},[]),qt=s(function(e){return Xo.current(e)},[]),Vt=s(function(){return $o.current()},[]),Wt=s(function(){var e,n;ft(),null===(e=kt.current)||void 0===e||e.call(kt),_n(!1),xn(new Set),bn([]),Pn.current=[],ao([]),vo(null),ui(D),null===(n=Lt.current)||void 0===n||n.call(Lt),requestAnimationFrame(function(){var e;null===(e=kn.current)||void 0===e||e.call(kn)})},[]),Kt=u(Wt);a(function(){Kt.current=Wt},[Wt]),a(function(){Ve&&Kt.current()},[Ve]);var Jt=c(function(){return{documents:null==Ne?void 0:Ne.documents,input_index_map:null==Ne?void 0:Ne.input_index_map}},[JSON.stringify(null==Ne?void 0:Ne.documents),JSON.stringify(null==Ne?void 0:Ne.input_index_map)]),Yt=u(Ne);a(function(){Yt.current=Ne},[Ne]);var Xt=u(Mn);a(function(){Xt.current=Mn},[Mn]);var $t=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,m,h,S=x(null==i?void 0:i.id)||x(null==t?void 0:t.id)||"",R=(S?null===(c=Xt.current)||void 0===c?void 0:c[S]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:S,decisioning:[],gap:[],relevance_score:0},y=null!==(s=null===(a=Xi.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,b=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(C)))return u(l);var c=o.split(C)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),w=(null!==(f=null===(v=null===(d=null==b?void 0:b.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(m=null===(g=null===(p=null==b?void 0:b.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==m?m:0)>0;return{isLoading:null!==(h=null==Ke?void 0:Ke.isLoading)&&void 0!==h&&h&&!w,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:R,anchorEl:n,sectionAnchorEl:y,badgeStyle:l||null,sectionIdx:o,docData:Jt,deviationData:b,isOrphan:!!r}},[Jt,null==Ke?void 0:Ke.isLoading]),Ut=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),ni.open&&ni.sectionIdx===o)pi();else{var u=e.currentTarget,c="left";(null===(l=Wn.current)||void 0===l?void 0:l.contains(u))&&(c="right");ft(),ct.current&&pt(),xn(new Set),bn([]),Pn.current=[],fi(),li.open?Co():ci(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(C)){var r=o.split(C),l="".concat(r[0]).concat(C).concat(r[1]);return"right"===c?null===(e=Wi.current[l])||void 0===e?void 0:e.current:null===(n=Vi.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=Wi.current[o])||void 0===i?void 0:i.current:null===(t=Vi.current[o])||void 0===t?void 0:t.current}()||u;ii($t(e,n,t,o,i,r))})}},[ni.open,ni.sectionIdx,pi,ci,$t]),Gt=s(function(){var e=ni.sectionIdx;ni.isOrphan,pi(),ci(),null!==e&&(Ct(e),ft(),ct.current&&pt(),bn([]),Pn.current=[],xn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){kn.current&&kn.current()},50))},[ni.sectionIdx,ni.isOrphan,pi,ci,pt]),Qt=s(function(){var e=Tn.current;if(e){Tn.current=null;var n=Ii.findIndex(function(n){return n.id===e}),i=Ti.findIndex(function(n){return n.id===e}),t=-1===n?b(Ii,e):null,o=-1===i?b(Ti,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?(vt.current.add(r),_(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(rn)-1!==r&&$n.current&&c(function(){return u(n,t,zi,Ji)},$n.current),-1!==l&&Wn.current&&c(function(){return u(i,o,qi,Yi)},Wn.current);else{var a=qn.current;if(!a)return;c(function(){return-1!==r?u(n,t,zi,Ji):u(i,o,qi,Yi)},a)}}},[Ii,Ti,rn,zi,qi,Ji,Yi,$n,Wn,qn]),Zt=s(function(n){if(n){ft(),pt(),xn(new Set),bn([]),Pn.current=[],ci(),fi();var i=Ii.findIndex(function(e){return e.id===n}),t=Ti.findIndex(function(e){return e.id===n}),o=-1===i?b(Ii,n):null,r=-1===t?b(Ti,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;Tn.current=n,St(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=rn?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=rn?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),Rt(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(){Tn.current===n&&eo.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Ii,Ti,rn,St,Rt,pt,ci,fi]),eo=u(Qt);a(function(){eo.current=Qt},[Qt]);var no=u(null);a(function(){if(hi){var e=gi.fields.find(function(e){return e.analysisKey===hi||e.key===hi});if(e){var n=Hi.current[e.key]||Mi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[hi,gi.fields]);var io=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Et?void 0:Et.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}},[Et]),to=$({proposedSections:Ii,existingSections:Ti,maintainRelativeOrder:rn,cognitiveMap:Mn,deviationData:Hn,treeData:Ne,resolvedComparisonConfig:gi,badgeStyleOverride:tn}),oo=to.getSectionCompareStyle,ro=to.getSubSectionCompareStyle,lo=to.getDeviationStyleByKey,uo=G({containerRef:En,leftContainerRef:$n,rightContainerRef:Wn,svgContainerRef:Bn,pathRefs:On,leftHeaderRef:Fn,rightHeaderRef:In,proposedSections:Ii,existingSections:Ti,visibleFields:Ai,leftRefs:Hi,rightRefs:Mi,sectionLeftRefs:zi,sectionRightRefs:qi,subSectionLeftRefs:Ji,subSectionRightRefs:Yi,lhsBadgeRefs:Vi,rhsBadgeRefs:Wi,sectionRowRefs:Xi,expandedSections:ht,expandedSubSections:xt,connectedSections:Sn,isSideBySide:Zi,activeSideBySideSection:rt,maintainRelativeOrder:rn,cognitiveMap:Mn,getSectionCompareStyle:oo,getSubSectionCompareStyle:ro,getDeviationStyleByKey:lo,isArrowVisible:et,isAnimatingRef:An,isSideBySideRef:ct,sideBySideCacheRef:ut,sideBySideLineRef:dt,activeSideBySideSectionRef:st,activeSideBySideRightSectionRef:at,connectedLines:yn,setConnectedLines:bn,cachedConnectedPositions:Pn,calculateLinesRef:kn,resizeTimerRef:Ln,scrollLock:lt,scrollSyncLocked:wn,handleResizeRef:jn,activeProposed:Ei,existingRule:Fi,analysisData:Et,pendingScrollTargetRef:Un,pendingScrollCallbackRef:Gn,resolvedComparisonConfig:gi,getFieldData:io}),co=uo.lines,ao=uo.setLines,so=uo.overallConnector,vo=uo.setOverallConnector,fo=uo.svgDimensions,po=uo.handleColumnScroll;a(function(){li.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=kn.current)||void 0===e||e.call(kn)})})},[li.anchorEl,wn]);var go=s(function(){ft(),_n(!1),St({}),Rt({}),pt(),xn(new Set),bn([]),Pn.current=[],ci(),fi(),pi(),requestAnimationFrame(function(){kn.current&&kn.current()})},[St,Rt,pt,ci,fi,pi]);a(function(){Zi||0!==Sn.size||_n(!1)},[Zi,Sn]);var mo=c(function(){return Object.values(ht).some(Boolean)||Object.values(xt).some(Boolean)},[ht,xt]),ho=u(null),So=u(0),xo=u(0),Ro=u(0),yo=U({timerRef:ho,ruleComponentRef:Vn,scrollContainerRef:qn,containerRef:En,maintainRelativeOrder:rn,proposedSections:Ii,existingSections:Ti,isSideBySideRef:ct,activeSideBySideSectionRef:st,activeSideBySideRightSectionRef:at,sectionRowRefs:Xi,sectionRightRowRefs:Ki,sectionLeftRefs:zi,sectionRightRefs:qi,subSectionLeftRefs:Ji,subSectionRightRefs:Yi,lhsBadgeRefs:Vi,rhsBadgeRefs:Wi,leftContainerRef:$n,rightContainerRef:Wn,calculateLinesRef:kn,handleResizeRef:jn,setIsResizing:tt,setIsArrowVisible:nt,sideBySideCacheRef:ut,cachedConnectedPositions:Pn}).handleResize;a(function(){jn.current=yo},[yo,jn]),a(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Vn.current&&o.push(e(Vn.current,So,n,function(){return jn.current()},function(){})),qn.current&&o.push(e(qn.current,xo,i,function(){return jn.current()},function(){return kn.current()})),En.current&&o.push(e(En.current,Ro,t,function(){return jn.current()},function(){return kn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){ct.current=Zi},[Zi]),a(function(){st.current=rt},[rt]);var bo=s(function(){var e,n=ni.sectionIdx,i=ni.isOrphan;if(ci(),null!=n){var t="left";ni.anchorEl&&(null===(e=Wn.current)||void 0===e?void 0:e.contains(ni.anchorEl))&&(t="right"),Ct(n),gt(n,i,{sourceSide:t})}},[gt,ni.isOrphan,ni.sectionIdx,ni.anchorEl,ci]),Co=s(function(){ci(),pt(),xn(new Set),bn([]),Pn.current=[]},[ci,pt]),wo=null!==ni.sectionIdx&&Sn.has(ni.sectionIdx),_o=q({proposedSections:Ii,existingSections:Ti,parentDeviationRecord:Di,expandedSections:ht,maintainRelativeOrder:!!rn,scrollContainerRef:qn,leftContainerRef:$n,rightContainerRef:Wn,lhsBadgeRefs:Vi,rhsBadgeRefs:Wi}),Bo=_o.showDeviationNavigation,Eo=_o.showOpenNodeRef,Fo=_o.adjustScrollForPopup,Io=s(function(e,n,i,t,o){var r,l="string"==typeof t?x(t).trim():x(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;fi();var c="left";(null===(r=Wn.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(C)){var r=n.split(C),l="".concat(r[0]).concat(C).concat(r[1]);return"right"===c?null===(e=Wi.current[l])||void 0===e?void 0:e.current:null===(i=Vi.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=Wi.current[n])||void 0===t?void 0:t.current:null===(o=Vi.current[n])||void 0===o?void 0:o.current};if(i)return pt(),xn(new Set),bn([]),Pn.current=[],void(l&&(Ct(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));ui({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Ct(n),l?setTimeout(function(){gt(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;rn?(null===(e=$n.current)||void 0===e||e.scrollBy({top:c,behavior:"smooth"}),null===(n=Wn.current)||void 0===n||n.scrollBy({top:c,behavior:"smooth"})):null===(i=qn.current)||void 0===i||i.scrollBy({top:c,behavior:"smooth"})}}ui({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){gt(n,i,{toggleIfSame:!1,sourceSide:c})},350)},[gt,fi,ui,pt,Ct]),To=c(function(){var e;if(!Ue)return null;var n=null===(e=null==Ue?void 0:Ue.id)||void 0===e?void 0:e.split(":")[0];for(var i in Di){if((Di[i]||[]).some(function(e){return e.id===n}))return i}return null},[Ue,Di]),Ao=u({id:null,triggerMs:null}),Do=u(null);a(function(){if(null==Ue?void 0:Ue.id){var o=Number(Ue.trigger),r=Ao.current;if((null==r?void 0:r.triggerMs)!==o){if(!(Ue.id.includes(":")&&/:\d+$/.test(Ue.id)))return Ao.current={id:Ue.id,triggerMs:o},void Zt(Ue.id);var l=Ue.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0";Do.current!==Ue.id&&(ci(),fi(),pt(),xn(new Set),bn([]),Pn.current=[],Do.current=Ue.id);var s=!1,d=0,v=null,f=null,p=!1,g=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},m=function(){var r,l,c,h;if(!s){var S=function(){Ao.current={id:Ue.id,triggerMs:o}},x=null,R=null;for(var y in Di){var b=Di[y].find(function(e){return e.id===u});if(b){x=y,R=b;break}}if(R&&x){var w=Ii.findIndex(function(e){return e.id===x}),_=Ti.findIndex(function(e){return e.id===x}),F=-1===w&&-1!==_,I=g(Ii,R.id),T=g(Ti,R.id);if(I&&!T&&!F){var A=I.split("-"),D=Number(A[0]);if(rn){var O=null===(l=null===(r=Ii[D])||void 0===r?void 0:r.refIndexes)||void 0===l?void 0:l[0],P=Ti.findIndex(function(e){return e.selfIndex===O});-1!==P&&(D=P)}T=n([D],A.slice(1),!0).join("-")}if(I||T){var k=I?Number(I.split("-")[0]):w,L=T?Number(T.split("-")[0]):_,j=L>=0?L:T?Number(T.split("-")[0]):-1,N=Ii[k],H=Ti[j],M=N&&!N.title&&!N.content,z=H&&!H.title&&!H.content,q=F||(!I&&!!T||M&&!z);if(q){if(!(rn?!!Vo.current["right-".concat(L)]:!!Vo.current[String(L)])&&L>=0)return bt(L,"right"),void(v=setTimeout(m,200))}else if(!(rn?!!Vo.current["left-".concat(k)]:!!Vo.current[String(k)])&&k>=0)return bt(k,"left"),void(v=setTimeout(m,200));var V=I||"",W=T||"",K="".concat(R.id).concat(C).concat(a).concat(C).concat(V).concat(C).concat(W),J="".concat(R.id).concat(C).concat(a);if(!p){Ct(K),p=!0,d=0;var Y=function(){var e,n,i=null===(e=Vi.current[J])||void 0===e?void 0:e.current,t=null===(n=Wi.current[J])||void 0===n?void 0:n.current;return q||!i&&!!t?t:i};return null==f||f(),void(v=setTimeout(function(){var e,n,i,t,o,r,l;s||(e=Y,n=function(){s||(f=null,m())},t=0,o=null,r=null,l=function(){if(!s){var u=e();if(u&&0!==u.getBoundingClientRect().height){var c=u.getBoundingClientRect(),a=c.top,d=c.height,v=null!==o&&Math.abs(a-o)<.5,f=null!==r&&Math.abs(d-r)<.5;if(v&&f){if(++t>=5)return void n()}else t=0;o=a,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),f=function(){return cancelAnimationFrame(i)})},300))}var X=null===(c=Vi.current[J])||void 0===c?void 0:c.current,$=null===(h=Wi.current[J])||void 0===h?void 0:h.current;if(X||$){var U=q||!X&&!!$,G=U?$:X,Q=rn?U?Wn.current:$n.current:qn.current;if(G&&Q){var Z=G.getBoundingClientRect();if(0!==Z.height){var ee=Q.getBoundingClientRect(),ne=Z.top-ee.top+Q.scrollTop-ee.height/2+Z.height/2,ie=(null==I?void 0:I.includes("-"))||(null==T?void 0:T.includes("-")),te=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,d,v,f;return t(this,function(t){switch(t.label){case 0:return s?[2]:(S(),n=G instanceof Element?window.getComputedStyle(G).color:"",[X,$].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[X,$].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=R.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||R,o=(null===(d=R.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||R.evaluation_outputs,!!X&&!!$?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},rn?[4,Promise.all([$n.current?l(E($n.current),600):Promise.resolve(),Wn.current?l(E(Wn.current),600):Promise.resolve()])]:[3,2]):(r=U?(null===(v=Wi.current[ie?J:L])||void 0===v?void 0:v.current)||$:(null===(f=Vi.current[ie?J:k])||void 0===f?void 0:f.current)||X,Fo(r,function(){ui({open:!0,anchorEl:r,displayImpact:Ue.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==Ge||Ge(),[2]));case 1:t.sent(),t.label=2;case 2:return gt(K,!1,{toggleIfSame:!1,sourceSide:F?"right":"left",onReady:function(){var n,t,o,r;S();var l=U?(null===(n=Wi.current[J])||void 0===n?void 0:n.current)||$:(null===(t=Vi.current[J])||void 0===t?void 0:t.current)||X,u=(null===(o=Vi.current[J])||void 0===o?void 0:o.current)||X,c=(null===(r=Wi.current[J])||void 0===r?void 0:r.current)||$;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"})),ui({open:!0,anchorEl:l,displayImpact:Ue.displayImpact,summary:e({},i)}),null==Ge||Ge()}}),[2]}})})};Math.abs(Q.scrollTop-ne)<=2?te():B(Q,ne,te)}else++d<2?v=setTimeout(m,100):S()}else++d<2?v=setTimeout(m,100):S()}else++d<2?v=setTimeout(m,100):S()}else++d<2?v=setTimeout(m,100):S()}else++d<2?v=setTimeout(m,100):S()}};return v=setTimeout(m,100),function(){s=!0,v&&clearTimeout(v),null==f||f()}}}},[Ue,Di,Ii,Ti,rn,ht,gt,ui,Zt]),a(function(){var n,i,t;if(li.open){var o=li.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(Vi.current)||r(Wi.current);if(l){var u=(null===(i=Wi.current[l])||void 0===i?void 0:i.current)||(null===(t=Vi.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&ui(function(n){return e(e({},n),{anchorEl:u})})}}}},[li.open,li.anchorEl,wn,Sn,ht]);var Oo=Zn.open,Po=Zn.sectionIdx,ko=Zn.isOrphan,Lo=Zn.badgeStyle,jo=Zn.anchorEl,No=Zn.sectionAnchorEl;a(function(){var n;if(Ke.isStreamingEnabled&&Oo&&null!=Po&&Po!==Tt){var i="string"==typeof Po?Po.split(C)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(Ii,i):null,r=i&&"string"==typeof i?t(Ti,i):null,l="number"==typeof Po?Ii[Po]||null:o||i&&((null===(n=null==Ne?void 0:Ne.nodes)||void 0===n?void 0:n[i])||(null==Ne?void 0:Ne[i]))||null,u="number"==typeof Po?Ti[Po]||null:r,c=$t(jo,l,u,Po,ko,Lo);ei(function(n){return n.open?x(n.cognitiveData)===x(c.cognitiveData)&&x(n.deviationData)===x(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Oo,Po,ko,Lo,jo,No,Ii,Ti,$t]);var Ho=s(function(e){var n=e.section,i=e.keyPath,t=e.depth,r=void 0===t?0:t,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset;return o(W,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s})},[]),Mo=c(function(){return Ii.map(function(e,n){var i,t=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return t&&r&&rn?null:o(K,{section:e,idx:n},null!==(i=null==e?void 0:e.id)&&void 0!==i?i:"left-row-".concat(n))})},[Ii]),zo=c(function(){return Ti.map(function(e,n){var i,t=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return t&&r&&rn?null:o(J,{section:e,idx:n},null!==(i=null==e?void 0:e.id)&&void 0!==i?i:"right-row-".concat(n))})},[Ti]),qo=u(Ut);a(function(){qo.current=Ut},[Ut]);var Vo=u(ht);a(function(){Vo.current=ht},[ht]);var Wo=u(Io);a(function(){Wo.current=Io},[Io]);var Ko=u(Co);a(function(){Ko.current=Co},[Co]);var Jo=u(bt);a(function(){Jo.current=bt},[bt]);var Yo=u(yt);a(function(){Yo.current=yt},[yt]);var Xo=u(Ho);a(function(){Xo.current=Ho},[Ho]);var $o=u(pt);a(function(){$o.current=pt},[pt]);var Uo=c(function(){return{maintainRelativeOrder:!!rn,showDeviationBadges:an,isProposingFix:Ze,proposingFixNodeId:en,isRedlineFlow:nn,isSideBySide:Zi,activeSideBySideSection:rt,scrollSyncLocked:wn,toggleScrollSyncLocked:_t,summaryPopupAnchorEl:li.anchorEl,connectedSections:Sn,proposedSections:Ii,existingSections:Ti,deviationNumberRegistry:Oi,deviationParentRegistry:Pi,treeData:Ne,displayConfig:Ke,resolvedMarkdownStyles:zn,unifiedNumbering:Bt,expandedSections:ht,expandedSubSections:xt,setExpandedSubSections:Rt,getSectionCompareStyle:oo,getSubSectionCompareStyle:ro,getBadgeRef:Gi,getSectionRowRef:$i,getSubSectionRef:Ui,sectionLeftRefs:zi,sectionRightRefs:qi,sectionRowRefs:Xi,sectionRightRowRefs:Ki,subSectionLeftRefs:Ji,subSectionRightRefs:Yi,lhsBadgeRefs:Vi,rhsBadgeRefs:Wi,openMoreFunctionsPopup:jt,handleOpenSummaryPopup:Nt,openSummaryPopup:Nt,handleCloseSummaryPopup:Ht,toggleSection:Mt,handleSubSectionToggle:zt,renderSubSectionAccordion:qt,resetSideBySide:Vt,setConnectedSections:xn,setConnectedLines:bn,cachedConnectedPositions:Pn,showDeviationNavigation:Bo,showOpenNodeRef:Eo,deviationNodeIdToView:null==Ue?void 0:Ue.id,deviationTargetParentId:To}},[rn,an,Ze,en,nn,Zi,rt,wn,_t,li.anchorEl,Sn,Ii,Ti,Oi,Ke,zn,Bt,ht,xt,Rt,oo,ro,Gi,$i,Ui,Bo,Eo,Ue,To]);return o(X,e({value:Uo},{children:r(d,e({ref:Vn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[dn&&o(d,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:o(L,{})})),li.open&&o(Y,{open:li.open,anchorEl:li.anchorEl,containerEl:no.current,clipTopEl:Fn.current,scrollContainerEl:qn.current,onClose:Co,summary:li.summary,displayImpact:li.displayImpact,isScrollLocked:wn}),o(k,{open:ni.open,anchorEl:ni.anchorEl,maintainRelativeOrder:!!rn,sectionTitle:ni.sectionTitle,referenceSectionTitle:ni.refSectionTitle,onClose:pi,onOpenCognitiveCompare:di,onOpenSideBySide:bo,onConnect:Gt,isConnected:wo,isOrphan:ni.isOrphan}),Zn.open&&o(P,{open:Zn.open,popupRef:si,position:ti,popupConfig:Ye,onClose:function(){oi(null),ei(function(n){return e(e({},n),{open:!1})}),ai(null)},markdownStyles:qe,sectionTitle:bi,referenceSectionTitle:wi,cognitiveData:Zn.cognitiveData,anchorEl:Zn.anchorEl,sectionAnchorEl:Zn.sectionAnchorEl,scrollContainerEl:qn.current,badgeStyle:Zn.badgeStyle,docData:Zn.docData,deviationData:Zn.deviationData,isLoading:Zn.isLoading}),o(v,e({open:!!pn,autoHideDuration:8e3,onClose:function(){return gn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return gn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:pn}))})),o(V,{componentHeaderText:je,displayConfig:Ke,maintainRelativeOrder:rn,onCollapseAll:go,showCollapseAll:mo,onToggleView:function(e){vn(!0),setTimeout(function(){ln(!e),null==Je||Je(!e),_n(!1),pt(),ci(),xn(new Set),bn([]),Pn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){vn(!1)},600)})})},50)}}),o(d,e({ref:qn,onScroll:po,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:rn?"visible":"auto",borderTop:Ft&&It?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},rn?{flex:1}:{})},{children:r(d,e({ref:En,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},rn?{flex:1,overflow:"visible"}:{})},{children:[o(Z,{svgContainerRef:Bn,svgDimensions:fo,isResizing:it,overallConnector:so,rootDeviationStyle:Ot,lines:co,isSideBySide:Zi,activeSideBySideSection:rt,isArrowVisible:et,maintainRelativeOrder:rn,proposedSections:Ii,existingSections:Ti,cognitivePopup:Zn,activeBadgeId:ri,closeCognitivePopup:fi,setActiveBadgeId:ai,openCognitivePopupFromState:vi,buildSectionPopupState:$t,connectedLines:yn,pathRefs:On}),r(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},rn?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:Fn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:o(p,e({title:Ri,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ri}))}))})),r(d,e({ref:$n,onScroll:po,sx:e({p:"12px",display:"flex",flexDirection:"column"},rn?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:Yn,style:{width:"100%",height:"0px",flexShrink:0}}),Li&&Mo,o("div",{ref:Xn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:no,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(d,e({onClick:function(n){n.stopPropagation(),Zn.open&&ri===Tt?fi():(ai(Tt),vi($t(n.currentTarget,{title:"",content:"",evaluationResult:At,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Tt,!0,e(e({},Ot),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Ot.badgeBg,color:Ot.badgeText,border:"1px solid ".concat(Ot.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Dt?Dt:o(j,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(h,{})})),o(m,{size:11,style:{transform:Zn.open&&ri===Tt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},rn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[ot&&o(S,{sections:11}),o(d,e({ref:In,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:o(p,e({title:_i,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:_i}))}))})),r(d,e({ref:Wn,onScroll:po,sx:e({p:"12px",display:"flex",flexDirection:"column"},rn?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:Kn,style:{width:"100%",height:"0px",flexShrink:0}}),Li&&zo,o("div",{ref:Jn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{ee as default};
|
|
1
|
+
import{__assign as e,__spreadArray as n,__awaiter as i,__generator as t}from"tslib";import{jsx as o,jsxs as r}from"react/jsx-runtime";import{useState as l,useRef as u,useMemo as c,useEffect as a,useCallback as s}from"react";import{Box as d,Snackbar as v,Alert as f,Tooltip as p,Typography as g}from"@mui/material";import{ChevronDown as h}from"lucide-react";import{ButtonCognitiveIcon as m}from"../../assests/svg/ButtonCognitiveIcon.js";import S from"./OverlayComponent.js";import{safeStringify as x,extractDeviationScore as R,generateColorPalette as b,findKeyPathByNodeId as y,DEVIATION_BADGE_SEPARATOR as C,hasMeaningfulRedlineTags as w,scrollAndHighlightClause as B,scrollAndWait as _,waitForScrollIdle as E}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as F,DEFAULT_FIELD_CONFIG as I,DEFAULT_COMPARISON_CONFIG as T}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as A,EMPTY_SUMMARY_POPUP_STATE as D,DEFAULT_COMPONENT_HEADER_TEXT as k}from"./CognitiveCompareConstants.js";import P from"./CognitivePopup.js";import O from"./MoreFunctionsPopup.js";import L from"./LoaderComponent.js";import j from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as N}from"./hooks/useCompareData.js";import{useComparePopups as M}from"./hooks/useComparePopups.js";import{useSectionRefs as H}from"./hooks/useSectionRefs.js";import{useAccordionState as z}from"./hooks/useAccordionState.js";import{useDeviationNavigation as q}from"./hooks/useDeviationNavigation.js";import W from"./components/CompareHeader.js";import V from"./components/SubSectionAccordion.js";import G from"./components/LHSSectionRow.js";import K from"./components/RHSSectionRow.js";import J from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as Y}from"./CompareContext.js";import{useStyleHelpers as X}from"./hooks/useStyles.js";import{useResizeHandler as $}from"./hooks/useResizeHandler.js";import{useLinesCalculator as U}from"./hooks/useLinesCalculator.js";import{useSideBySide as Q}from"./hooks/useSideBySide.js";import Z from"./components/SvgConnectors.js";import ee from"./Guidelines/components/GuidelinePanel.js";var ne=function(ne){var ie,te,oe,re,le,ue,ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,be,ye,Ce,we,Be,_e,Ee,Fe,Ie,Te,Ae,De,ke,Pe,Oe,Le,je=ne.componentHeaderText,Ne=void 0===je?k:je,Me=ne.treeData,He=ne.comparisonConfig,ze=ne.leftColumnTitleText,qe=ne.rightColumnTitleText,We=ne.markdownStyles,Ve=ne.resetTrigger,Ge=ne.displayConfig,Ke=void 0===Ge?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Ge,Je=ne.onMaintainRelativeOrderChange,Ye=ne.popupConfig,Xe=ne.deviationData,$e=void 0===Xe?{}:Xe,Ue=ne.deviationNodeIdToView,Qe=ne.resetDeviationNodeId,Ze=ne.isProposingFix,en=void 0!==Ze&&Ze,nn=ne.proposingFixNodeId,tn=ne.isRedlineFlow,on=ne.badgeStyleOverride,rn=ne.guidelinesData,ln=l(Ke.maintainRelativeOrder),un=ln[0],cn=ln[1],an=null!==(ie=null==Ke?void 0:Ke.expandLevels)&&void 0!==ie?ie:0,sn=!!(null==Ke?void 0:Ke.expandAllSections),dn=!!un||!!(null==Ke?void 0:Ke.showDeviationBadges),vn=l(!1),fn=vn[0],pn=vn[1],gn=l(null),hn=gn[0],mn=gn[1],Sn=l(null===(oe=null!==(te=null==Me?void 0:Me.newEvaluationResult)&&void 0!==te?te:null==Ke?void 0:Ke.enableDeviationSchemaBackwardCompatibility)||void 0===oe||oe)[0],xn=l(new Set),Rn=xn[0],bn=xn[1],yn=l([]),Cn=yn[0],wn=yn[1],Bn=l(!1),_n=Bn[0],En=Bn[1],Fn=u(null),In=u(null),Tn=u(null),An=u(null),Dn=u(null),kn=u(!1),Pn=u(null),On=u({}),Ln=u([]),jn=u(function(){}),Nn=u(null),Mn=u(function(){}),Hn=c(function(){return JSON.stringify($e||{})},[JSON.stringify($e)]),zn=c(function(){return $e||{}},[Hn]),qn=c(function(){return(null==Me?void 0:Me.cognitive_decisioning)||{}},[Me]),Wn=c(function(){return e(e({},F),We)},[We]),Vn=u(null),Gn=u(null),Kn=u(null),Jn=u(null),Yn=u(null),Xn=u(null),$n=u(null),Un=u(null),Qn=u(null),Zn=u(null),ei=M(Vn),ni=ei.cognitivePopup,ii=ei.setCognitivePopup,ti=ei.moreFunctions,oi=ei.setMoreFunctions,ri=ei.position,li=ei.setPosition,ui=ei.activeBadgeId,ci=ei.summaryPopup,ai=ei.setSummaryPopup,si=ei.closeSummaryPopup,di=ei.setActiveBadgeId,vi=ei.popupRef,fi=ei.handleOpenCognitiveCompare,pi=ei.openCognitivePopupFromState,gi=ei.closeCognitivePopup,hi=ei.closeMoreFunctionsPopup,mi=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==He?void 0:He.fields)&&void 0!==e?e:I,thresholds:{high:null!==(i=null===(n=null==He?void 0:He.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:T.thresholds.high,medium:null!==(o=null===(t=null==He?void 0:He.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:T.thresholds.medium,exact:null!==(l=null===(r=null==He?void 0:He.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:T.thresholds.exact}}},[He]),Si=l(null),xi=Si[0];Si[1];var Ri=null===(ue=null===(re=null==Me?void 0:Me.documents)||void 0===re?void 0:re[null===(le=null==Me?void 0:Me.input_index_map)||void 0===le?void 0:le[0]])||void 0===ue?void 0:ue.title,bi=null===(se=null===(ce=null==Me?void 0:Me.documents)||void 0===ce?void 0:ce[null===(ae=null==Me?void 0:Me.input_index_map)||void 0===ae?void 0:ae[1]])||void 0===se?void 0:se.title,yi=x(ze||Ri||"Uploaded Contract"),Ci=null===(pe=null===(fe=null===(de=null==Me?void 0:Me.documents)||void 0===de?void 0:de[null===(ve=null==Me?void 0:Me.input_index_map)||void 0===ve?void 0:ve[0]])||void 0===fe?void 0:fe.metadata)||void 0===pe?void 0:pe.file_name,wi=x(Ci),Bi=null===(Se=null===(me=null===(ge=null==Me?void 0:Me.documents)||void 0===ge?void 0:ge[null===(he=null==Me?void 0:Me.input_index_map)||void 0===he?void 0:he[1]])||void 0===me?void 0:me.metadata)||void 0===Se?void 0:Se.file_name,_i=x(Bi),Ei=x(qe||bi||"Reference Template"),Fi=N(Me,un,zn,mi,Sn,rn),Ii=Fi.isGuidelineMode,Ti=Fi.activeProposed,Ai=Fi.existingRule,Di=Fi.proposedSections,ki=Fi.existingSections,Pi=Fi.visibleFields,Oi=Fi.parentDeviationRecord,Li=Fi.deviationNumberRegistry,ji=Fi.deviationParentRegistry,Ni=Fi.parseError;a(function(){Ni&&mn("Failed to load comparison: ".concat(Ni))},[Ni]);var Mi=Di.length>0||ki.length>0,Hi=c(function(){if(!tn)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";w(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(Di),i(ki),"".concat(e,":").concat(n)},[tn,Di,ki]);a(function(){if(Di.length||ki.length)if(sn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=un?"".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(Di,"left"),i(ki,"right"),bt(e),Ct(n)}else if(an>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=un?"".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(Di,"left",an),r(ki,"right",an),bt(t),Ct(o)}},[sn,an,Di,ki,un]);var zi=H(Pi.map(function(e){return e.key}),Math.max(Di.length,ki.length)),qi=zi.leftRefs,Wi=zi.rightRefs,Vi=zi.sectionLeftRefs,Gi=zi.sectionRightRefs,Ki=zi.lhsBadgeRefs,Ji=zi.rhsBadgeRefs,Yi=zi.sectionRightRowRefs,Xi=zi.subSectionLeftRefs,$i=zi.subSectionRightRefs,Ui=zi.sectionRowRefs,Qi=zi.getSectionRowRef,Zi=zi.getSubSectionRef,et=zi.getBadgeRef,nt=Q({isGuidelineMode:Ii,maintainRelativeOrder:un,proposedSections:Di,existingSections:ki,leftContainerRef:Un,rightContainerRef:Kn,scrollContainerRef:Vn,sectionLeftRefs:Vi,sectionRightRefs:Gi,subSectionLeftRefs:Xi,subSectionRightRefs:$i,lhsBadgeRefs:Ki,rhsBadgeRefs:Ji,sectionRowRefs:Ui,sectionRightRowRefs:Yi,rhsTopSpacerRef:Jn,rhsBottomSpacerRef:Yn,lhsTopSpacerRef:Xn,lhsBottomSpacerRef:$n,calculateLinesRef:jn,setConnectedSections:bn,setConnectedLines:wn,cachedConnectedPositions:Ln,closeMoreFunctionsPopup:hi,setErrorToast:mn,moreFunctions:ti,closeSummaryPopup:si}),it=nt.isSideBySide,tt=nt.isArrowVisible,ot=nt.setIsArrowVisible,rt=nt.isResizing,lt=nt.setIsResizing,ut=nt.isSideBySideLoading,ct=nt.activeSideBySideSection,at=nt.scrollLock,st=nt.sideBySideCacheRef,dt=nt.isSideBySideRef,vt=nt.activeSideBySideRightSectionRef,ft=nt.activeSideBySideSectionRef,pt=nt.sideBySideLineRef,gt=nt.highlightedClauseRefs,ht=nt.clearClauseHighlight,mt=nt.resetSideBySide,St=nt.activateSideBySide,xt=z({maintainRelativeOrder:!!un,proposedSections:Di,existingSections:ki,activeSideBySideSection:ct,connectedSections:Rn,resetSideBySide:mt,setConnectedSections:bn,setConnectedLines:wn,cachedConnectedPositions:Ln,svgContainerRef:Fn,isAnimatingRef:kn,animationTimerRef:Pn,calculateLinesRef:jn,sectionLeftRefs:Vi,sectionRightRefs:Gi,subSectionLeftRefs:Xi,subSectionRightRefs:$i}),Rt=xt.expandedSections,bt=xt.setExpandedSections,yt=xt.expandedSubSections,Ct=xt.setExpandedSubSections,wt=xt.handleSubSectionToggle,Bt=xt.toggleSection,_t=xt.forceExpandCrossWiredSections,Et=function(){var e,n;if(null!=ct){var i=null===(e=Vi.current[ct])||void 0===e?void 0:e.current,t=null===(n=Gi.current[ct])||void 0===n?void 0:n.current,o=Kn.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"})}}},Ft=s(function(e){null==e||e.stopPropagation(),En(function(e){var n=!e;return n&&requestAnimationFrame(function(){Et()}),n})},[Et]);a(function(){tn&&"off"!==Hi&&"0:0"!==Hi&&(st.current=null,Ln.current=[],requestAnimationFrame(function(){var e;null===(e=jn.current)||void 0===e||e.call(jn)}))},[tn,Hi]);var It=c(function(){var e=new Map,n=new Map,i=1;if(un)Di.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),ki.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=Di.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(Di.length,ki.length),o=0;o<t;o++){var r=Di[o],l=ki[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}},[Di,ki,un]),Tt=Ai.analysis,At=x(null===(Re=null===(xe=null==Tt?void 0:Tt.rule_difference_comparison)||void 0===xe?void 0:xe.summary)||void 0===Re?void 0:Re.overall_summary),Dt=!!At.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),kt=null!==(be=null==Me?void 0:Me.base_root_id)&&void 0!==be?be:"-1";null==Me||Me[kt];var Pt=Sn?null!==(ke=null!==(Te=$e&&(null===(Ie=null==$e?void 0:$e[kt])||void 0===Ie?void 0:Ie.evaluation_result))&&void 0!==Te?Te:null===(De=null===(Ae=null==Me?void 0:Me.nodes)||void 0===Ae?void 0:Ae[kt])||void 0===De?void 0:De.evaluation_result)&&void 0!==ke?ke:null:null!==(Fe=null!==(we=$e&&(null===(Ce=null===(ye=null==$e?void 0:$e[kt])||void 0===ye?void 0:ye.evaluation_result)||void 0===Ce?void 0:Ce[0]))&&void 0!==we?we:null===(Ee=null===(_e=null===(Be=null==Me?void 0:Me.nodes)||void 0===Be?void 0:Be[kt])||void 0===_e?void 0:_e.evaluation_result)||void 0===Ee?void 0:Ee[0])&&void 0!==Fe?Fe:null,Ot=R(Pt),Lt=b(null!==(Le=null===(Oe=null===(Pe=null==Pt?void 0:Pt.evaluation_outputs)||void 0===Pe?void 0:Pe.metadata)||void 0===Oe?void 0:Oe.label_color)&&void 0!==Le?Le:A);if(on){var jt=on(Ot);jt&&(Lt=e(e({},Lt),{badgeBg:jt.bg,badgeText:jt.text,badgeBorder:jt.border}))}var Nt=u(mt);a(function(){Nt.current=mt},[mt]);var Mt=u(gi);a(function(){Mt.current=gi},[gi]);var Ht=s(function(e,n,i,t,o,r){return Go.current(e,n,i,t,o,r)},[]),zt=s(function(e,n,i,t,o){return Jo.current(e,n,i,t,o)},[]),qt=s(function(){return Yo.current()},[]),Wt=s(function(e,n){return Xo.current(e,n)},[]),Vt=s(function(e){return $o.current(e)},[]),Gt=s(function(e){return Uo.current(e)},[]),Kt=s(function(){return Qo.current()},[]),Jt=s(function(){var e,n;ht(),null===(e=Nt.current)||void 0===e||e.call(Nt),En(!1),bn(new Set),wn([]),Ln.current=[],fo([]),go(null),ai(D),null===(n=Mt.current)||void 0===n||n.call(Mt),requestAnimationFrame(function(){var e;null===(e=jn.current)||void 0===e||e.call(jn)})},[]),Yt=u(Jt);a(function(){Yt.current=Jt},[Jt]),a(function(){Ve&&Yt.current()},[Ve]);var Xt=c(function(){return{documents:null==Me?void 0:Me.documents,input_index_map:null==Me?void 0:Me.input_index_map}},[JSON.stringify(null==Me?void 0:Me.documents),JSON.stringify(null==Me?void 0:Me.input_index_map)]),$t=u(Me);a(function(){$t.current=Me},[Me]);var Ut=u(qn);a(function(){Ut.current=qn},[qn]);var Qt=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=x(null==i?void 0:i.id)||x(null==t?void 0:t.id)||"",R=(S?null===(c=Ut.current)||void 0===c?void 0:c[S]:null)||(null==i?void 0:i.cognitiveData)||(null==t?void 0:t.cognitiveData)||{section_id:S,decisioning:[],gap:[],relevance_score:0},b=null!==(s=null===(a=Ui.current[o])||void 0===a?void 0:a.current)&&void 0!==s?s:null,y=function(){var n,r,l=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||null,u=function(n){var i=function(e){if(!e||"object"!=typeof e)return null;var n=null==e?void 0:e.deviation_entries;if(n&&"object"==typeof n){var i=Object.keys(n).sort(function(e,n){return Number(e)-Number(n)})[0];if(i&&n[i])return n[i]}var t=Object.keys(e).filter(function(e){return/^\d+$/.test(e)}).sort(function(e,n){return Number(e)-Number(n)});if(t.length&&e[t[0]])return e[t[0]];var o=null==e?void 0:e.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(e,n){return Number(e)-Number(n)})[0];if(r&&o[r])return o[r]}return null}(n);return i?e(e({},n),{deviation_summary:(null==n?void 0:n.deviation_summary)||(null==i?void 0:i.deviation_summary),deviation_title:(null==n?void 0:n.deviation_title)||(null==i?void 0:i.deviation_title),deviation_impact:(null==n?void 0:n.deviation_impact)||(null==i?void 0:i.deviation_impact),deviation_explanation:(null==n?void 0:n.deviation_explanation)||(null==i?void 0:i.deviation_explanation),evaluation_outputs:(null==n?void 0:n.evaluation_outputs)||(null==i?void 0:i.evaluation_outputs),cognitive_decisioning:(null==n?void 0:n.cognitive_decisioning)||(null==i?void 0:i.cognitive_decisioning)}):n};if(!("string"==typeof o&&o.includes(C)))return u(l);var c=o.split(C)[1];if(!c)return l;var a=(null==i?void 0:i.evaluationResult)||(null==t?void 0:t.evaluationResult)||{},s=(null===(n=null==a?void 0:a.deviation_entries)||void 0===n?void 0:n[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return s?e(e(e({},a),s),{deviation_summary:(null==s?void 0:s.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==s?void 0:s.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),w=(null!==(f=null===(v=null===(d=null==y?void 0:y.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==y?void 0:y.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0;return{isLoading:null!==(m=null==Ke?void 0:Ke.isLoading)&&void 0!==m&&m&&!w,open:!0,sectionTitle:(null==i?void 0:i.title)?null==i?void 0:i.title:"No Counterpart",refSectionTitle:(null==t?void 0:t.title)?null==t?void 0:t.title:"No Counterpart",cognitiveData:R,anchorEl:n,sectionAnchorEl:b,badgeStyle:l||null,sectionIdx:o,docData:Xt,deviationData:y,isOrphan:!!r}},[Xt,null==Ke?void 0:Ke.isLoading]),Zt=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),ti.open&&ti.sectionIdx===o)hi();else{var u=e.currentTarget,c="left";(null===(l=Kn.current)||void 0===l?void 0:l.contains(u))&&(c="right");ht(),dt.current&&mt(),bn(new Set),wn([]),Ln.current=[],gi(),ci.open?_o():si(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(C)){var r=o.split(C),l="".concat(r[0]).concat(C).concat(r[1]);return"right"===c?null===(e=Ji.current[l])||void 0===e?void 0:e.current:null===(n=Ki.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=Ji.current[o])||void 0===i?void 0:i.current:null===(t=Ki.current[o])||void 0===t?void 0:t.current}()||u;oi(Qt(e,n,t,o,i,r))})}},[ti.open,ti.sectionIdx,hi,si,Qt]),eo=s(function(){var e=ti.sectionIdx;ti.isOrphan,hi(),si(),null!==e&&(_t(e),ht(),dt.current&&mt(),wn([]),Ln.current=[],bn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){jn.current&&jn.current()},50))},[ti.sectionIdx,ti.isOrphan,hi,si,mt]),no=s(function(){var e=Dn.current;if(e){Dn.current=null;var n=Di.findIndex(function(n){return n.id===e}),i=ki.findIndex(function(n){return n.id===e}),t=-1===n?y(Di,e):null,o=-1===i?y(ki,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?(gt.current.add(r),B(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(un)-1!==r&&Un.current&&c(function(){return u(n,t,Vi,Xi)},Un.current),-1!==l&&Kn.current&&c(function(){return u(i,o,Gi,$i)},Kn.current);else{var a=Vn.current;if(!a)return;c(function(){return-1!==r?u(n,t,Vi,Xi):u(i,o,Gi,$i)},a)}}},[Di,ki,un,Vi,Gi,Xi,$i,Un,Kn,Vn]),io=s(function(n){if(n){ht(),mt(),bn(new Set),wn([]),Ln.current=[],si(),gi();var i=Di.findIndex(function(e){return e.id===n}),t=ki.findIndex(function(e){return e.id===n}),o=-1===i?y(Di,n):null,r=-1===t?y(ki,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;Dn.current=n,bt(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=un?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=un?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),Ct(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(){Dn.current===n&&to.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[Di,ki,un,bt,Ct,mt,si,gi]),to=u(no);a(function(){to.current=no},[no]);var oo=u(null);a(function(){if(xi){var e=mi.fields.find(function(e){return e.analysisKey===xi||e.key===xi});if(e){var n=qi.current[e.key]||Wi.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[xi,mi.fields]);var ro=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Tt?void 0:Tt.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}},[Tt]),lo=X({proposedSections:Di,existingSections:ki,maintainRelativeOrder:un,cognitiveMap:qn,deviationData:zn,treeData:Me,resolvedComparisonConfig:mi,badgeStyleOverride:on}),uo=lo.getSectionCompareStyle,co=lo.getSubSectionCompareStyle,ao=lo.getDeviationStyleByKey,so=U({containerRef:In,leftContainerRef:Un,rightContainerRef:Kn,svgContainerRef:Fn,pathRefs:On,leftHeaderRef:Tn,rightHeaderRef:An,proposedSections:Di,existingSections:ki,visibleFields:Pi,leftRefs:qi,rightRefs:Wi,sectionLeftRefs:Vi,sectionRightRefs:Gi,subSectionLeftRefs:Xi,subSectionRightRefs:$i,lhsBadgeRefs:Ki,rhsBadgeRefs:Ji,sectionRowRefs:Ui,expandedSections:Rt,expandedSubSections:yt,connectedSections:Rn,isSideBySide:it,activeSideBySideSection:ct,maintainRelativeOrder:un,isGuidelineMode:Ii,cognitiveMap:qn,getSectionCompareStyle:uo,getSubSectionCompareStyle:co,getDeviationStyleByKey:ao,isArrowVisible:tt,isAnimatingRef:kn,isSideBySideRef:dt,sideBySideCacheRef:st,sideBySideLineRef:pt,activeSideBySideSectionRef:ft,activeSideBySideRightSectionRef:vt,connectedLines:Cn,setConnectedLines:wn,cachedConnectedPositions:Ln,calculateLinesRef:jn,resizeTimerRef:Nn,scrollLock:at,scrollSyncLocked:_n,handleResizeRef:Mn,activeProposed:Ti,existingRule:Ai,analysisData:Tt,pendingScrollTargetRef:Qn,pendingScrollCallbackRef:Zn,resolvedComparisonConfig:mi,getFieldData:ro}),vo=so.lines,fo=so.setLines,po=so.overallConnector,go=so.setOverallConnector,ho=so.svgDimensions,mo=so.handleColumnScroll;a(function(){ci.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=jn.current)||void 0===e||e.call(jn)})})},[ci.anchorEl,_n]);var So=s(function(){ht(),En(!1),bt({}),Ct({}),mt(),bn(new Set),wn([]),Ln.current=[],si(),gi(),hi(),requestAnimationFrame(function(){jn.current&&jn.current()})},[bt,Ct,mt,si,gi,hi]);a(function(){it||0!==Rn.size||En(!1)},[it,Rn]);var xo=c(function(){return Object.values(Rt).some(Boolean)||Object.values(yt).some(Boolean)},[Rt,yt]),Ro=u(null),bo=u(0),yo=u(0),Co=u(0),wo=$({timerRef:Ro,ruleComponentRef:Gn,scrollContainerRef:Vn,containerRef:In,maintainRelativeOrder:un,proposedSections:Di,existingSections:ki,isSideBySideRef:dt,activeSideBySideSectionRef:ft,activeSideBySideRightSectionRef:vt,sectionRowRefs:Ui,sectionRightRowRefs:Yi,sectionLeftRefs:Vi,sectionRightRefs:Gi,subSectionLeftRefs:Xi,subSectionRightRefs:$i,lhsBadgeRefs:Ki,rhsBadgeRefs:Ji,leftContainerRef:Un,rightContainerRef:Kn,calculateLinesRef:jn,handleResizeRef:Mn,setIsResizing:lt,setIsArrowVisible:ot,sideBySideCacheRef:st,cachedConnectedPositions:Ln}).handleResize;a(function(){Mn.current=wo},[wo,Mn]),a(function(){var e=function(e,n,i,t,o){n.current=e.getBoundingClientRect().width;var r=new ResizeObserver(function(e){null!==i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(function(){var r,l,u;i.current=null;var c=e[e.length-1];if(c){var a=null!==(u=null===(l=null===(r=c.borderBoxSize)||void 0===r?void 0:r[0])||void 0===l?void 0:l.inlineSize)&&void 0!==u?u:c.contentRect.width;Math.abs(a-n.current)<1?o():(n.current=a,t())}})});return r.observe(e),r},n={current:null},i={current:null},t={current:null},o=[],r=[n,i,t];return Gn.current&&o.push(e(Gn.current,bo,n,function(){return Mn.current()},function(){})),Vn.current&&o.push(e(Vn.current,yo,i,function(){return Mn.current()},function(){return jn.current()})),In.current&&o.push(e(In.current,Co,t,function(){return Mn.current()},function(){return jn.current()})),function(){o.forEach(function(e){return e.disconnect()}),r.forEach(function(e){null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),a(function(){dt.current=it},[it]),a(function(){ft.current=ct},[ct]);var Bo=s(function(){var e,n=ti.sectionIdx,i=ti.isOrphan;if(si(),null!=n){var t="left";ti.anchorEl&&(null===(e=Kn.current)||void 0===e?void 0:e.contains(ti.anchorEl))&&(t="right"),_t(n),St(n,i,{sourceSide:t})}},[St,ti.isOrphan,ti.sectionIdx,ti.anchorEl,si]),_o=s(function(){si(),mt(),bn(new Set),wn([]),Ln.current=[]},[si,mt]),Eo=null!==ti.sectionIdx&&Rn.has(ti.sectionIdx),Fo=q({proposedSections:Di,existingSections:ki,parentDeviationRecord:Oi,expandedSections:Rt,maintainRelativeOrder:!!un,scrollContainerRef:Vn,leftContainerRef:Un,rightContainerRef:Kn,lhsBadgeRefs:Ki,rhsBadgeRefs:Ji}),Io=Fo.showDeviationNavigation,To=Fo.showOpenNodeRef,Ao=Fo.adjustScrollForPopup,Do=s(function(e,n,i,t,o){var r,l="string"==typeof t?x(t).trim():x(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;gi();var c="left";(null===(r=Kn.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var e,i,t,o;if("string"==typeof n&&n.includes(C)){var r=n.split(C),l="".concat(r[0]).concat(C).concat(r[1]);return"right"===c?null===(e=Ji.current[l])||void 0===e?void 0:e.current:null===(i=Ki.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=Ji.current[n])||void 0===t?void 0:t.current:null===(o=Ki.current[n])||void 0===o?void 0:o.current};if(i)return mt(),bn(new Set),wn([]),Ln.current=[],void(l&&(_t(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));ai({open:!0,anchorEl:e,summary:t,displayImpact:o})})));_t(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;un?(null===(e=Un.current)||void 0===e||e.scrollBy({top:c,behavior:"smooth"}),null===(n=Kn.current)||void 0===n||n.scrollBy({top:c,behavior:"smooth"})):null===(i=Vn.current)||void 0===i||i.scrollBy({top:c,behavior:"smooth"})}}ai({open:!0,anchorEl:r,summary:t,displayImpact:o})}})},350):setTimeout(function(){St(n,i,{toggleIfSame:!1,sourceSide:c})},350)},[St,gi,ai,mt,_t]),ko=c(function(){var e;if(!Ue)return null;var n=null===(e=null==Ue?void 0:Ue.id)||void 0===e?void 0:e.split(":")[0];for(var i in Oi){if((Oi[i]||[]).some(function(e){return e.id===n}))return i}return null},[Ue,Oi]),Po=u({id:null,triggerMs:null}),Oo=u(null);a(function(){if(null==Ue?void 0:Ue.id){var o=Number(Ue.trigger),r=Po.current;if((null==r?void 0:r.triggerMs)!==o){if(!(Ue.id.includes(":")&&/:\d+$/.test(Ue.id)))return Po.current={id:Ue.id,triggerMs:o},void io(Ue.id);var l=Ue.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0";Oo.current!==Ue.id&&(si(),gi(),mt(),bn(new Set),wn([]),Ln.current=[],Oo.current=Ue.id);var s=!1,d=0,v=null,f=null,p=!1,g=function(e,n){for(var i=function(e,t){if(!e)return null;if(e.id===n)return t;if(!Array.isArray(e.subsections))return null;for(var o=0;o<e.subsections.length;o++){var r=i(e.subsections[o],"".concat(t,"-").concat(o));if(r)return r}return null},t=0;t<e.length;t++){var o=i(e[t],String(t));if(o)return o}return null},h=function(){var r,l,c,m;if(!s){var S=function(){Po.current={id:Ue.id,triggerMs:o}},x=null,R=null;for(var b in Oi){var y=Oi[b].find(function(e){return e.id===u});if(y){x=b,R=y;break}}if(R&&x){var w=Di.findIndex(function(e){return e.id===x}),B=ki.findIndex(function(e){return e.id===x}),F=-1===w&&-1!==B,I=g(Di,R.id),T=g(ki,R.id);if(I&&!T&&!F){var A=I.split("-"),D=Number(A[0]);if(un){var k=null===(l=null===(r=Di[D])||void 0===r?void 0:r.refIndexes)||void 0===l?void 0:l[0],P=ki.findIndex(function(e){return e.selfIndex===k});-1!==P&&(D=P)}T=n([D],A.slice(1),!0).join("-")}if(I||T){var O=I?Number(I.split("-")[0]):w,L=T?Number(T.split("-")[0]):B,j=L>=0?L:T?Number(T.split("-")[0]):-1,N=Di[O],M=ki[j],H=N&&!N.title&&!N.content,z=M&&!M.title&&!M.content,q=F||(!I&&!!T||H&&!z);if(q){if(!(un?!!Ko.current["right-".concat(L)]:!!Ko.current[String(L)])&&L>=0)return Bt(L,"right"),void(v=setTimeout(h,200))}else if(!(un?!!Ko.current["left-".concat(O)]:!!Ko.current[String(O)])&&O>=0)return Bt(O,"left"),void(v=setTimeout(h,200));var W=I||"",V=T||"",G="".concat(R.id).concat(C).concat(a).concat(C).concat(W).concat(C).concat(V),K="".concat(R.id).concat(C).concat(a);if(!p){_t(G),p=!0,d=0;var J=function(){var e,n,i=null===(e=Ki.current[K])||void 0===e?void 0:e.current,t=null===(n=Ji.current[K])||void 0===n?void 0:n.current;return q||!i&&!!t?t:i};return null==f||f(),void(v=setTimeout(function(){var e,n,i,t,o,r,l;s||(e=J,n=function(){s||(f=null,h())},t=0,o=null,r=null,l=function(){if(!s){var u=e();if(u&&0!==u.getBoundingClientRect().height){var c=u.getBoundingClientRect(),a=c.top,d=c.height,v=null!==o&&Math.abs(a-o)<.5,f=null!==r&&Math.abs(d-r)<.5;if(v&&f){if(++t>=5)return void n()}else t=0;o=a,r=d,i=requestAnimationFrame(l)}else i=requestAnimationFrame(l)}},i=requestAnimationFrame(l),f=function(){return cancelAnimationFrame(i)})},300))}var Y=null===(c=Ki.current[K])||void 0===c?void 0:c.current,X=null===(m=Ji.current[K])||void 0===m?void 0:m.current;if(Y||X){var $=q||!Y&&!!X,U=$?X:Y,Q=un?$?Kn.current:Un.current:Vn.current;if(U&&Q){var Z=U.getBoundingClientRect();if(0!==Z.height){var ee=Q.getBoundingClientRect(),ne=Z.top-ee.top+Q.scrollTop-ee.height/2+Z.height/2,ie=(null==I?void 0:I.includes("-"))||(null==T?void 0:T.includes("-")),te=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,d,v,f;return t(this,function(t){switch(t.label){case 0:return s?[2]:(S(),n=U instanceof Element?window.getComputedStyle(U).color:"",[Y,X].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[Y,X].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=R.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||R,o=(null===(d=R.evaluationResult)||void 0===d?void 0:d.evaluation_outputs)||R.evaluation_outputs,!!Y&&!!X?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},un?[4,Promise.all([Un.current?l(E(Un.current),600):Promise.resolve(),Kn.current?l(E(Kn.current),600):Promise.resolve()])]:[3,2]):(r=$?(null===(v=Ji.current[ie?K:L])||void 0===v?void 0:v.current)||X:(null===(f=Ki.current[ie?K:O])||void 0===f?void 0:f.current)||Y,Ao(r,function(){ai({open:!0,anchorEl:r,displayImpact:Ue.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==Qe||Qe(),[2]));case 1:t.sent(),t.label=2;case 2:return St(G,!1,{toggleIfSame:!1,sourceSide:F?"right":"left",onReady:function(){var n,t,o,r;S();var l=$?(null===(n=Ji.current[K])||void 0===n?void 0:n.current)||X:(null===(t=Ki.current[K])||void 0===t?void 0:t.current)||Y,u=(null===(o=Ki.current[K])||void 0===o?void 0:o.current)||Y,c=(null===(r=Ji.current[K])||void 0===r?void 0:r.current)||X;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"})),ai({open:!0,anchorEl:l,displayImpact:Ue.displayImpact,summary:e({},i)}),null==Qe||Qe()}}),[2]}})})};Math.abs(Q.scrollTop-ne)<=2?te():_(Q,ne,te)}else++d<2?v=setTimeout(h,100):S()}else++d<2?v=setTimeout(h,100):S()}else++d<2?v=setTimeout(h,100):S()}else++d<2?v=setTimeout(h,100):S()}else++d<2?v=setTimeout(h,100):S()}};return v=setTimeout(h,100),function(){s=!0,v&&clearTimeout(v),null==f||f()}}}},[Ue,Oi,Di,ki,un,Rt,St,ai,io]),a(function(){var n,i,t;if(ci.open){var o=ci.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(Ki.current)||r(Ji.current);if(l){var u=(null===(i=Ji.current[l])||void 0===i?void 0:i.current)||(null===(t=Ki.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&ai(function(n){return e(e({},n),{anchorEl:u})})}}}},[ci.open,ci.anchorEl,_n,Rn,Rt]);var Lo=ni.open,jo=ni.sectionIdx,No=ni.isOrphan,Mo=ni.badgeStyle,Ho=ni.anchorEl,zo=ni.sectionAnchorEl;a(function(){var n;if(Ke.isStreamingEnabled&&Lo&&null!=jo&&jo!==kt){var i="string"==typeof jo?jo.split(C)[0]:null,t=function(e,n){var i;if(!e||!Array.isArray(e))return null;for(var o=0,r=e;o<r.length;o++){var l=r[o];if(l.id===n)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var u=t(l.subsections,n);if(u)return u}}return null},o=i&&"string"==typeof i?t(Di,i):null,r=i&&"string"==typeof i?t(ki,i):null,l="number"==typeof jo?Di[jo]||null:o||i&&((null===(n=null==Me?void 0:Me.nodes)||void 0===n?void 0:n[i])||(null==Me?void 0:Me[i]))||null,u="number"==typeof jo?ki[jo]||null:r,c=Qt(Ho,l,u,jo,No,Mo);ii(function(n){return n.open?x(n.cognitiveData)===x(c.cognitiveData)&&x(n.deviationData)===x(c.deviationData)&&n.sectionTitle===c.sectionTitle&&n.refSectionTitle===c.refSectionTitle?n:e(e(e({},n),c),{open:!0,anchorEl:n.anchorEl,sectionAnchorEl:n.sectionAnchorEl}):n})}},[Lo,jo,No,Mo,Ho,zo,Di,ki,Qt]);var qo=s(function(e){var n=e.section,i=e.keyPath,t=e.depth,r=void 0===t?0:t,l=e.columnKey,u=void 0===l?"left":l,c=e.parentNodeId,a=void 0===c?"":c,s=e.sectionOffset;return o(V,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s})},[]),Wo=c(function(){return Di.map(function(e,n){var i,t=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return t&&r&&un?null:o(G,{section:e,idx:n},null!==(i=null==e?void 0:e.id)&&void 0!==i?i:"left-row-".concat(n))})},[Di]),Vo=c(function(){return ki.map(function(e,n){var i,t=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),r=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return t&&r&&un?null:o(K,{section:e,idx:n},null!==(i=null==e?void 0:e.id)&&void 0!==i?i:"right-row-".concat(n))})},[ki]),Go=u(Zt);a(function(){Go.current=Zt},[Zt]);var Ko=u(Rt);a(function(){Ko.current=Rt},[Rt]);var Jo=u(Do);a(function(){Jo.current=Do},[Do]);var Yo=u(_o);a(function(){Yo.current=_o},[_o]);var Xo=u(Bt);a(function(){Xo.current=Bt},[Bt]);var $o=u(wt);a(function(){$o.current=wt},[wt]);var Uo=u(qo);a(function(){Uo.current=qo},[qo]);var Qo=u(mt);a(function(){Qo.current=mt},[mt]);var Zo=c(function(){return{isGuidelineMode:Ii,maintainRelativeOrder:!!un,showDeviationBadges:dn,isProposingFix:en,proposingFixNodeId:nn,isRedlineFlow:tn,isSideBySide:it,activeSideBySideSection:ct,scrollSyncLocked:_n,toggleScrollSyncLocked:Ft,summaryPopupAnchorEl:ci.anchorEl,connectedSections:Rn,proposedSections:Di,existingSections:ki,deviationNumberRegistry:Li,deviationParentRegistry:ji,treeData:Me,displayConfig:Ke,resolvedMarkdownStyles:Wn,unifiedNumbering:It,expandedSections:Rt,expandedSubSections:yt,setExpandedSubSections:Ct,getSectionCompareStyle:uo,getSubSectionCompareStyle:co,getBadgeRef:et,getSectionRowRef:Qi,getSubSectionRef:Zi,sectionLeftRefs:Vi,sectionRightRefs:Gi,sectionRowRefs:Ui,sectionRightRowRefs:Yi,subSectionLeftRefs:Xi,subSectionRightRefs:$i,lhsBadgeRefs:Ki,rhsBadgeRefs:Ji,openMoreFunctionsPopup:Ht,handleOpenSummaryPopup:zt,openSummaryPopup:zt,handleCloseSummaryPopup:qt,toggleSection:Wt,handleSubSectionToggle:Vt,renderSubSectionAccordion:Gt,resetSideBySide:Kt,setConnectedSections:bn,setConnectedLines:wn,cachedConnectedPositions:Ln,showDeviationNavigation:Io,showOpenNodeRef:To,deviationNodeIdToView:null==Ue?void 0:Ue.id,deviationTargetParentId:ko}},[Ii,un,dn,en,nn,tn,it,ct,_n,Ft,ci.anchorEl,Rn,Di,ki,Li,Ke,Wn,It,Rt,yt,Ct,uo,co,et,Qi,Zi,Io,To,Ue,ko]);return o(Y,e({value:Zo},{children:r(d,e({ref:Gn,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[fn&&o(d,e({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:o(L,{})})),ci.open&&o(J,{open:ci.open,anchorEl:ci.anchorEl,containerEl:oo.current,clipTopEl:Tn.current,scrollContainerEl:Vn.current,onClose:_o,summary:ci.summary,displayImpact:ci.displayImpact,isScrollLocked:_n}),o(O,{open:ti.open,anchorEl:ti.anchorEl,maintainRelativeOrder:!!un,sectionTitle:ti.sectionTitle,referenceSectionTitle:ti.refSectionTitle,onClose:hi,onOpenCognitiveCompare:fi,onOpenSideBySide:Bo,onConnect:eo,isConnected:Eo,isOrphan:!Ii&&ti.isOrphan}),ni.open&&o(P,{open:ni.open,popupRef:vi,position:ri,popupConfig:Ye,onClose:function(){li(null),ii(function(n){return e(e({},n),{open:!1})}),di(null)},markdownStyles:We,sectionTitle:wi,referenceSectionTitle:_i,cognitiveData:ni.cognitiveData,anchorEl:ni.anchorEl,sectionAnchorEl:ni.sectionAnchorEl,scrollContainerEl:Vn.current,badgeStyle:ni.badgeStyle,docData:ni.docData,deviationData:ni.deviationData,isLoading:ni.isLoading}),o(v,e({open:!!hn,autoHideDuration:8e3,onClose:function(){return mn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return mn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:hn}))})),o(W,{componentHeaderText:Ne,displayConfig:Ke,maintainRelativeOrder:un,onCollapseAll:So,showCollapseAll:xo,onToggleView:function(e){pn(!0),setTimeout(function(){cn(!e),null==Je||Je(!e),En(!1),mt(),si(),bn(new Set),wn([]),Ln.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){pn(!1)},600)})})},50)}}),o(d,e({ref:Vn,onScroll:mo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:un?"visible":"auto",borderTop:At&&Dt?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},un?{flex:1}:{})},{children:r(d,e({ref:In,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"60px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},un?{flex:1,overflow:"visible"}:{})},{children:[o(Z,{svgContainerRef:Fn,svgDimensions:ho,isResizing:rt,overallConnector:po,rootDeviationStyle:Lt,lines:vo,isSideBySide:it,activeSideBySideSection:ct,isArrowVisible:tt,maintainRelativeOrder:un,proposedSections:Di,existingSections:ki,cognitivePopup:ni,activeBadgeId:ui,closeCognitivePopup:gi,setActiveBadgeId:di,openCognitivePopupFromState:pi,buildSectionPopupState:Qt,connectedLines:Cn,pathRefs:On}),r(d,e({sx:e({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},un?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:Tn,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:o(p,e({title:yi,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:yi}))}))})),r(d,e({ref:Un,onScroll:mo,sx:e({p:"12px",display:"flex",flexDirection:"column"},un?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:Xn,style:{width:"100%",height:"0px",flexShrink:0}}),Mi&&Wo,o("div",{ref:$n,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:oo,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:o(d,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:r(d,e({onClick:function(n){n.stopPropagation(),ni.open&&ui===kt?gi():(di(kt),pi(Qt(n.currentTarget,{title:"",content:"",evaluationResult:Pt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,kt,!0,e(e({},Lt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Lt.badgeBg,color:Lt.badgeText,border:"1px solid ".concat(Lt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Ot?Ot:o(j,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(m,{})})),o(h,{size:11,style:{transform:ni.open&&ui===kt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),r(d,e({sx:e({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},un?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[ut&&o(S,{sections:11}),o(d,e({ref:An,sx:e({p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},un?e({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},Ii?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:o(p,e({title:Ei,placement:"top"},{children:o(g,e({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:Ei}))}))})),r(d,e({ref:Kn,onScroll:mo,sx:e({p:Ii?"0px":"12px",display:"flex",flexDirection:"column"},un?e(e({maxHeight:"calc(100vh - 250px)"},!Ii&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[o("div",{ref:Jn,style:{width:"100%",height:"0px",flexShrink:0}}),Ii?o(ee,{guidelinesData:rn,deviationData:$e,connectedSections:Rn,proposedSections:Di}):Mi&&Vo,o("div",{ref:Yn,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{ne as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__spreadArray as o,__assign as t}from"tslib";import{jsx as i}from"react/jsx-runtime";import{useMemo as e}from"react";import{Box as r}from"@mui/material";import l from"react-markdown";import a from"rehype-raw";import{SHARED_MARKDOWN_STYLES as n}from"../../CognitiveCompareConfig.js";import{DEVIATION_BADGE_SEPARATOR as u,generateColorPalette as d}from"../../CognitiveComparehelpers.js";var v=function(v){var c=v.guidelinesData,s=v.deviationData,g=v.connectedSections,p=v.proposedSections,f=Array.from(g)[0],m=e(function(){var t;if(null==f||!s)return{targetHighlights:[],labelColor:""};var i="";"number"==typeof f?i=(null===(t=p[f])||void 0===t?void 0:t.nodeId)||"":"string"==typeof f&&(i=f.includes(u)?f.split(u)[0]:f.split("::")[0].split(":")[0]);var e=s[i];if(!e)return{targetHighlights:[],labelColor:""};var r=[],l=e.evaluation_result||{},a="";return Object.values(l).forEach(function(t){var i,e,l,n,u;(null===(i=null==t?void 0:t.deviation_highlights)||void 0===i?void 0:i.rulebook_guidelines)&&(r=o(o([],r,!0),t.deviation_highlights.rulebook_guidelines,!0),a=(null===(l=null===(e=t.evaluation_outputs)||void 0===e?void 0:e.metadata)||void 0===l?void 0:l.label_color)?d(null===(u=null===(n=t.evaluation_outputs)||void 0===n?void 0:n.metadata)||void 0===u?void 0:u.label_color).bg:"")}),{targetHighlights:r.filter(Boolean),labelColor:a}},[f,s,p]),h=m.targetHighlights,b=m.labelColor,_=e(function(){var o,t,i=(null===(t=null===(o=null==c?void 0:c.data)||void 0===o?void 0:o.artifactData)||void 0===t?void 0:t.userStorySnapshot)||[],e="";return i.forEach(function(o){var t;o.title&&(e+="# ".concat(o.title,"\n\n")),o.value&&(e+="".concat(o.value,"\n\n")),(null===(t=o.sub_features)||void 0===t?void 0:t.length)&&o.sub_features.forEach(function(o){o.title&&(e+="#### ".concat(o.title,"\n\n")),o.value&&(e+="".concat(o.value,"\n\n"))})}),h.length>0&&h.forEach(function(o,t){var i=o.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),r=new RegExp("(".concat(i,")"),"g");e=e.replace(r,'<mark id="guideline-target-'.concat(t,'" style="background-color: ').concat(b.length?b:"#FEF08A",'; border-radius: 3px; padding: 2px;">$1</mark>'))}),e},[c,h]);return i(r,t({sx:t(t({padding:"0px 12px",backgroundColor:"#FFFFFF",borderRadius:"8px"},n),{overflow:"visible"})},{children:i(l,t({rehypePlugins:[a]},{children:_}))}))};export{v as default};
|
|
2
|
+
//# sourceMappingURL=GuidelinePanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuidelinePanel.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -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 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 h,hasMeaningfulRedlineTags as g,stripRedlineTags as m,generateColorPalette as x,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,N,W,j,P,E=S.section,T=S.idx,D=S.columnKey,K=S.colRef,L=S.mb,z=void 0===L?1:L,G=S.isExpanded,H=S.onToggle,V=S.navigation,X=S.parentNodeId,Y=void 0===X?"":X,q=p(),J=q.showOpenNodeRef,Q=q.resolvedMarkdownStyles,U=q.maintainRelativeOrder,Z=q.showDeviationBadges,$=void 0!==Z&&Z,nn=q.renderSubSectionAccordion,en=q.treeData,on=q.proposedSections,tn=q.existingSections,ln=q.deviationNumberRegistry,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,hn=q.isSideBySide,gn=q.activeSideBySideSection,mn=q.scrollSyncLocked,xn=q.unifiedNumbering,In=q.toggleScrollSyncLocked,yn=q.summaryPopupAnchorEl,bn="".concat(hn?"1":"0","-").concat(String(null!=gn?gn:"")),wn=(null===(_=E.displayTitle)||void 0===_||_)&&h(E.title),Sn=!(!vn||!fn||"left"!==D||E.id!==fn&&E.nodeId!==fn),_n=g(E.content),Fn="boolean"==typeof pn?pn:_n,kn=_n,Rn=Fn&&_n,Bn=Rn?m(E.content):E.content,Cn=Rn?E.content:void 0,Mn=(null===(F=E.displayContent)||void 0===F||F||_n)&&h(E.content),An=!wn&&!Mn,On=E.title;wn||(On=Mn?"No Title Found":"No Matching Section Found");var Nn=E.evaluationResult;if(!Nn&&"right"===D)if(U){var Wn=null===(k=E.refIndexes)||void 0===k?void 0:k[0],jn=on.find(function(n){return n.selfIndex===Wn});Nn=null==jn?void 0:jn.evaluationResult}else Nn=null===(R=on[T])||void 0===R?void 0:R.evaluationResult;var Pn=null===(B=null==en?void 0:en.input_index_map)||void 0===B?void 0:B[0],En=null===(C=null==en?void 0:en.input_index_map)||void 0===C?void 0:C[1],Tn="left"===D?En:Pn,Dn=function(n,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||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var d=Dn(l.subsections,e);if(d)return d}}return null},Kn="left"===D?E:Dn(on,E.id),Ln="right"===D?E:Dn(tn,E.id),zn=o.useMemo(function(){if(!U)return 0;var n=1/0,e=function(i,o,t,l){var d;if(i){var r=i.nodeId||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].nodeId||a[0].id)}var c=i.nodeId||i.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==t?void 0:t.nodeId)||(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),h=0;h<p;h++)e(s[h],v[h],f[h],!1)}};return e(E,Kn,Ln,!0),n!==1/0?n-1:0},[E,Kn,Ln,D,ln,U,on]);if(U)if("left"===D){var Gn=null===(M=E.refIndexes)||void 0===M?void 0:M[0],Hn=tn.findIndex(function(n){return n.selfIndex===Gn});Ln=-1!==Hn?tn[Hn]:Dn(tn,E.id)}else{var Vn=null===(A=E.refIndexes)||void 0===A?void 0:A[0],Xn=on.findIndex(function(n){return n.selfIndex===Vn});Kn=-1!==Xn?on[Xn]:Dn(on,E.id)}var Yn="left"===D?!Ln:!Kn,qn=Nn||(null==Kn?void 0:Kn.evaluationResult)||(null==Ln?void 0:Ln.evaluationResult),Jn=null!==(W=null===(N=null===(O=null==qn?void 0:qn.evaluation_outputs)||void 0===O?void 0:O.metadata)||void 0===N?void 0:N.label_color)&&void 0!==W?W:w,Qn=x(Jn).highlightBg,Un=(null==qn?void 0:qn.deviations)||{},Zn=E.nodeId||E.id;if(U&&"left"!==D){var $n=on.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(E.selfIndex)});$n.length>0?Zn=$n[0].nodeId||$n[0].id:(null==Kn?void 0:Kn.id)&&(Zn=Kn.nodeId||Kn.id)}var ne=Object.keys(Un)[0],ee=ne?"".concat(Zn).concat(b).concat(ne):null,ie=ee?null==dn?void 0:dn[ee]:null,oe=T+1;if(U&&xn){var te="left"===D?xn.leftNums.get(null==E?void 0:E.id):xn.rightNums.get(null==E?void 0:E.id);Yn&&void 0!==te?oe=te:null!=ie&&ie>=0?oe=ie:void 0!==te&&(oe=te)}else null!=ie&&ie>=0&&(oe=ie);var le=Object.entries(Un).map(function(n){var e=n[0],i=n[1],o="".concat(Zn).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});le.sort(function(n,e){return n.currentIndex-e.currentIndex});var de,re=le.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!==zn&&(s-=zn);var v=c[Y],f=I(v);if(f)v="";else if(!v)return null;var p=T,h=T;if(U)if("left"===D){var g=null===(i=E.refIndexes)||void 0===i?void 0:i[0],m=tn.findIndex(function(n){return n.selfIndex===g});if(-1!==m)h=m;else{var y=tn.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId});h=-1!==y?y:T}}else{var w=null===(o=E.refIndexes)||void 0===o?void 0:o[0],S=on.findIndex(function(n){return n.selfIndex===w});if(-1!==S)p=S;else p=-1!==(C=on.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))?C:T}var _="".concat(Zn).concat(b).concat(a).concat(b).concat(p).concat(b).concat(h),F=c[Tn],k=Yn||I(F),R="".concat(oe,".").concat(s),B=T;if("right"===D&&U){var C,M=null===(t=E.refIndexes)||void 0===t?void 0:t[0],A=on.findIndex(function(n){return n.selfIndex===M});if(-1!==A)B=A;else-1!==(C=on.findIndex(function(n){return n.id===E.id||n.nodeId===E.nodeId||n.contentId===E.contentId}))&&(B=C)}var O=cn?cn(B):null,N=(null==c?void 0:c.evaluation_outputs)||(null==qn?void 0:qn.evaluation_outputs),W=null!==(l=null==N?void 0:N.output_value)&&void 0!==l?l:null,j=null!==(r=null===(d=null==N?void 0:N.metadata)||void 0===d?void 0:d.label_color)&&void 0!==r?r:Jn,P=x(j),K=O?n(n({},O),{badgeBg:P.badgeBg,badgeBorder:P.badgeBorder,badgeText:P.badgeText}):n({},P),L=(null==c?void 0:c.deviation_summary)?{deviation_summary:c.deviation_summary,deviation_title:(null==c?void 0:c.deviation_title)||(null==qn?void 0:qn.deviation_title),deviation_impact:(null==c?void 0:c.deviation_impact)||(null==qn?void 0:qn.deviation_impact),deviation_explanation:(null==c?void 0:c.deviation_explanation)||(null==qn?void 0:qn.deviation_explanation),evaluation_outputs:N,cognitive_decisioning:(null==c?void 0:c.cognitive_decisioning)||(null==qn?void 0:qn.cognitive_decisioning)}:null,z=0,G=Bn||"";if(v&&G){var H=G.split(/\n{2,}/),V=H.findIndex(function(n){return n.includes(v)});if(-1!==V){var X=Object.entries(Un).filter(function(n){n[0];var 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:W,isConnected:null==un?void 0:un.has(_),showScrollLockToggle:(null==un?void 0:un.has(_))||hn&&gn===_||!!yn&&yn===J.current,scrollSyncLocked:mn,toggleScrollSyncLocked:In,isOrphan:k,isMissingClause:f,badgeRef:J,onClick:function(n){n.stopPropagation(),sn&&sn(n,Kn||{id:"orphan-left",title:"",content:""},k,Ln||{id:"orphan-right",title:"",content:""},_,K)},onSummaryClick:function(n){n.stopPropagation(),an(n,_,k,L)}}}).filter(Boolean),ae=$||!Fn&&Sn?re:[],ce=re.map(function(n){return n.highlight}).filter(Boolean),ue=E.id&&D===(null==V?void 0:V.columnKey)?V:null,se=o.useRef(!1);return t(function(){G||(se.current=!1)},[G]),e(l,n({ref:K,sx:{mb:z,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[G&&(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:"-20px"}:{left:"-20px"})},{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(d,n({disableGutters:!0,expanded:!An&&G,onChange:function(){An||(H(),J.current=E.id)},sx:{boxShadow:"none",border:An?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:An?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[i(r,n({expandIcon:An?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:An?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:wn&&i(a,n({title:On,placement:"top"},{children:i(c,n({component:"div",sx:{fontSize:"12px",color:An?"#94A3B8":"#19213D",fontWeight:An?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(de=On,de?y(de).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)}))}))})),!An&&e(u,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Mn&&i(f,{content:Bn,overlayContent:Cn,sxStyles:Q,highlights:ce,maintainRelativeOrder:U,highlightBg:Qn,suppressHighlightBg:kn,deviationBadges:ae,collisionKey:bn}),(E.subsections||[]).map(function(n,e){return nn({section:n,keyPath:"".concat(T,"-").concat(e),depth:0,columnKey:D,parentNodeId:Y,sectionOffset:zn})})]}))]})),G&&(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:"-20px"}:{left:"-20px"})},{children:i(v,{color:(null===(P=null==ue?void 0:ue.showBelowRef)||void 0===P?void 0:P.current)?window.getComputedStyle(ue.showBelowRef.current).color:void 0})}))}))]}),"".concat(D,"-sec-").concat(T))};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 h,hasMeaningfulRedlineTags as g,stripRedlineTags as x,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,_,R,k,B,C,M,A,O,j,W,N,D,P,E,T=S.section,K=S.idx,z=S.columnKey,L=S.colRef,H=S.mb,G=void 0===H?1:H,V=S.isExpanded,X=S.onToggle,Y=S.navigation,q=S.parentNodeId,J=void 0===q?"":q,Q=p(),U=Q.showOpenNodeRef,Z=Q.resolvedMarkdownStyles,$=Q.maintainRelativeOrder,nn=Q.showDeviationBadges,en=void 0!==nn&&nn,on=Q.renderSubSectionAccordion,tn=Q.treeData,ln=Q.proposedSections,dn=Q.existingSections,rn=Q.deviationNumberRegistry,an=Q.deviationParentRegistry,cn=Q.getBadgeRef,un=Q.openSummaryPopup,sn=Q.getSectionCompareStyle,vn=Q.connectedSections,fn=Q.openMoreFunctionsPopup,pn=Q.isProposingFix,hn=Q.proposingFixNodeId,gn=Q.isRedlineFlow,xn=Q.isSideBySide,mn=Q.activeSideBySideSection,In=Q.scrollSyncLocked,yn=Q.unifiedNumbering,bn=Q.toggleScrollSyncLocked,wn=Q.summaryPopupAnchorEl,Sn="".concat(xn?"1":"0","-").concat(String(null!=mn?mn:"")),Fn=(null===(F=T.displayTitle)||void 0===F||F)&&h(T.title),_n=!(!pn||!hn||"left"!==z||T.id!==hn&&T.nodeId!==hn),Rn=g(T.content),kn="boolean"==typeof gn?gn:Rn,Bn=Rn,Cn=kn&&Rn,Mn=Cn?x(T.content):T.content,An=Cn?T.content:void 0,On=(null===(_=T.displayContent)||void 0===_||_||Rn)&&h(T.content),jn=!Fn&&!On,Wn=T.title;Fn||(Wn=On?"No Title Found":"No Matching Section Found");var Nn=T.evaluationResult;if(!Nn&&"right"===z)if($){var Dn=null===(R=T.refIndexes)||void 0===R?void 0:R[0],Pn=ln.find(function(n){return n.selfIndex===Dn});Nn=null==Pn?void 0:Pn.evaluationResult}else Nn=null===(k=ln[K])||void 0===k?void 0:k.evaluationResult;var En=null===(B=null==tn?void 0:tn.input_index_map)||void 0===B?void 0:B[0],Tn=null===(C=null==tn?void 0:tn.input_index_map)||void 0===C?void 0:C[1],Kn="left"===z?Tn:En,zn=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||l.nodeId===e||l.contentId===e)return l;if(null===(i=l.subsections)||void 0===i?void 0:i.length){var d=zn(l.subsections,e);if(d)return d}}return null},Ln="left"===z?T:zn(ln,T.id),Hn="right"===z?T:zn(dn,T.id),Gn=o.useMemo(function(){if(!$)return 0;var n=1/0,e=function(i,o,t,l){var d;if(i){var r=i.nodeId||i.id;if(l&&"right"===z){var a=ln.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].nodeId||a[0].id)}var c=i.nodeId||i.id||(null==o?void 0:o.nodeId)||(null==o?void 0:o.id)||(null==t?void 0:t.nodeId)||(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==rn?void 0:rn[i];null!=o&&o<n&&(n=o);var t="".concat(c).concat(b).concat(e),l=null==rn?void 0:rn[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(T,Ln,Hn,!0),n!==1/0?n-1:0},[T,Ln,Hn,z,rn,$,ln]);if($)if("left"===z){var Vn=null===(M=T.refIndexes)||void 0===M?void 0:M[0],Xn=dn.findIndex(function(n){return n.selfIndex===Vn});Hn=-1!==Xn?dn[Xn]:zn(dn,T.id)}else{var Yn=null===(A=T.refIndexes)||void 0===A?void 0:A[0],qn=ln.findIndex(function(n){return n.selfIndex===Yn});Ln=-1!==qn?ln[qn]:zn(ln,T.id)}var Jn="left"===z?!Hn:!Ln,Qn=Nn||(null==Ln?void 0:Ln.evaluationResult)||(null==Hn?void 0:Hn.evaluationResult),Un=null!==(W=null===(j=null===(O=null==Qn?void 0:Qn.evaluation_outputs)||void 0===O?void 0:O.metadata)||void 0===j?void 0:j.label_color)&&void 0!==W?W:w,Zn=m(Un).highlightBg,$n=(null==Qn?void 0:Qn.deviations)||{},ne=T.nodeId||T.id;if($&&"left"!==z){var ee=ln.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(T.selfIndex)});ee.length>0?ne=ee[0].nodeId||ee[0].id:(null==Ln?void 0:Ln.id)&&(ne=Ln.nodeId||Ln.id)}var ie=Object.keys($n)[0],oe=ie?"".concat(ne).concat(b).concat(ie):null,te=oe?null==an?void 0:an[oe]:null,le=K+1;if($&&yn){var de="left"===z?yn.leftNums.get(null==T?void 0:T.id):yn.rightNums.get(null==T?void 0:T.id);Jn&&void 0!==de?le=de:null!=te&&te>=0?le=te:void 0!==de&&(le=de)}else null!=te&&te>=0&&(le=te);var re=Object.entries($n).map(function(n){var e=n[0],i=n[1],o="".concat(ne).concat(b).concat(e);return{deviationKey:e,deviationMap:i,refId:o,currentIndex:rn[o]}}).filter(function(n){return void 0!==n.currentIndex&&null!==n.currentIndex});re.sort(function(n,e){return n.currentIndex-e.currentIndex});var ae,ce,ue=re.map(function(e){var i,o,t,l,d,r,a=e.deviationKey,c=e.deviationMap,u=e.refId,s=e.currentIndex;$&&void 0!==Gn&&(s-=Gn);var v=c[J],f=I(v);if(f)v="";else if(!v)return null;var p=K,h=K;if($)if("left"===z){var g=null===(i=T.refIndexes)||void 0===i?void 0:i[0],x=dn.findIndex(function(n){return n.selfIndex===g});if(-1!==x)h=x;else{var y=dn.findIndex(function(n){return n.id===T.id||n.nodeId===T.nodeId||n.contentId===T.contentId});h=-1!==y?y:K}}else{var w=null===(o=T.refIndexes)||void 0===o?void 0:o[0],S=ln.findIndex(function(n){return n.selfIndex===w});if(-1!==S)p=S;else p=-1!==(C=ln.findIndex(function(n){return n.id===T.id||n.nodeId===T.nodeId||n.contentId===T.contentId}))?C:K}var F="".concat(ne).concat(b).concat(a).concat(b).concat(p).concat(b).concat(h),_=c[Kn],R=Jn||I(_),k="".concat(le,".").concat(s),B=K;if("right"===z&&$){var C,M=null===(t=T.refIndexes)||void 0===t?void 0:t[0],A=ln.findIndex(function(n){return n.selfIndex===M});if(-1!==A)B=A;else-1!==(C=ln.findIndex(function(n){return n.id===T.id||n.nodeId===T.nodeId||n.contentId===T.contentId}))&&(B=C)}var O=sn?sn(B):null,j=(null==c?void 0:c.evaluation_outputs)||(null==Qn?void 0:Qn.evaluation_outputs),W=null!==(l=null==j?void 0:j.output_value)&&void 0!==l?l:null,N=null!==(r=null===(d=null==j?void 0:j.metadata)||void 0===d?void 0:d.label_color)&&void 0!==r?r:Un,D=m(N),P=O?n(n({},O),{badgeBg:D.badgeBg,badgeBorder:D.badgeBorder,badgeText:D.badgeText}):n({},D),E=(null==c?void 0:c.deviation_summary)?{deviation_summary:c.deviation_summary,deviation_title:(null==c?void 0:c.deviation_title)||(null==Qn?void 0:Qn.deviation_title),deviation_impact:(null==c?void 0:c.deviation_impact)||(null==Qn?void 0:Qn.deviation_impact),deviation_explanation:(null==c?void 0:c.deviation_explanation)||(null==Qn?void 0:Qn.deviation_explanation),evaluation_outputs:j,cognitive_decisioning:(null==c?void 0:c.cognitive_decisioning)||(null==Qn?void 0:Qn.cognitive_decisioning)}:null,L=0,H=Mn||"";if(v&&H){var G=H.split(/\n{2,}/),V=G.findIndex(function(n){return n.includes(v)});if(-1!==V){var X=Object.entries($n).filter(function(n){n[0];var e=n[1][J];return e&&G[V].includes(e)}).sort(function(n,e){return G[V].indexOf(n[1][J])-G[V].indexOf(e[1][J])}),Y=X.filter(function(n){n[0];var e=n[1][J];return e&&(e.includes(v)||v.includes(e))});Y.length>1&&(L=Math.max(0,Y.findIndex(function(n){return n[0]===a})))}}var q=cn(z,u);return{id:u,actionId:F,label:k,highlight:v,side:z,style:P,stackIndex:L,score:W,isConnected:null==vn?void 0:vn.has(F),showScrollLockToggle:(null==vn?void 0:vn.has(F))||xn&&mn===F||!!wn&&wn===q.current,scrollSyncLocked:In,toggleScrollSyncLocked:bn,isOrphan:R,isMissingClause:f,badgeRef:q,onClick:function(n){n.stopPropagation(),fn&&fn(n,Ln||{id:"orphan-left",title:"",content:""},R,Hn||{id:"orphan-right",title:"",content:""},F,P)},onSummaryClick:function(n){n.stopPropagation(),un(n,F,R,E)}}}).filter(Boolean),se=en||!kn&&_n?ue:[],ve=ue.map(function(n){return n.highlight}).filter(Boolean),fe=T.id&&z===(null==Y?void 0:Y.columnKey)?Y:null,pe=o.useRef(!1);return t(function(){V||(pe.current=!1)},[V]),e(l,n({ref:L,sx:{mb:G,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[V&&(null==fe?void 0:fe.showAbove)&&i("div",n({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==fe?void 0:fe.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"===z?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===z?{right:"-20px"}:{left:"-20px"})},{children:i(s,{color:(null===(N=null==fe?void 0:fe.showAboveRef)||void 0===N?void 0:N.current)?window.getComputedStyle(fe.showAboveRef.current).color:void 0})}))})),e(d,n({disableGutters:!0,expanded:!jn&&V,onChange:function(){jn||(X(),U.current=T.id)},sx:{boxShadow:"none",border:jn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:jn?"#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:jn?null:i(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:jn?"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:Fn&&i(a,n({title:Wn,placement:"top"},{children:i(c,n({component:"div",sx:{fontSize:"12px",color:jn?"#94A3B8":"#19213D",fontWeight:jn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(ae=Wn,ce="left"===z&&(null!==(P=null===(D=null==T?void 0:T.refContentIds)||void 0===D?void 0:D.length)&&void 0!==P?P:1)>1,void 0===ce&&(ce=!1),ae?y(ae).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(o,t){return o.startsWith("**")&&o.endsWith("**")?i("strong",{children:o.slice(2,-2)},t):e("div",n({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[i("span",{children:o}),ce&&i("span",n({style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0px 6px",borderRadius:"9999px",background:"#F3F4F6",border:"1px solid #D1D5DB",color:"#6B7280",fontSize:"9px",fontWeight:500,whiteSpace:"nowrap",lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!jn&&e(u,n({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[On&&i(f,{content:Mn,overlayContent:An,sxStyles:Z,highlights:ve,maintainRelativeOrder:$,highlightBg:Zn,suppressHighlightBg:Bn,deviationBadges:se,collisionKey:Sn}),(T.subsections||[]).map(function(n,e){return on({section:n,keyPath:"".concat(K,"-").concat(e),depth:0,columnKey:z,parentNodeId:J,sectionOffset:Gn})})]}))]})),V&&(null==fe?void 0:fe.showBelow)&&i("div",n({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==fe?void 0:fe.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"===z?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===z?{right:"-20px"}:{left:"-20px"})},{children:i(v,{color:(null===(E=null==fe?void 0:fe.showBelowRef)||void 0===E?void 0:E.current)?window.getComputedStyle(fe.showBelowRef.current).color:void 0})}))}))]}),"".concat(z,"-sec-").concat(K))};export{S as default};
|
|
2
2
|
//# sourceMappingURL=SectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as t,Fragment as i,jsx as r}from"react/jsx-runtime";import{Box as n}from"@mui/material";import o from"./ScrollLockToggle.js";import{useCompareContext as l}from"../CompareContext.js";var d=function(d){var c=d.connectedLines,a=d.pathRefs,s=d.maintainRelativeOrder,u=l(),f=u.scrollSyncLocked,h=u.toggleScrollSyncLocked,g=u.isGuidelineMode;return t(i,{children:[c.map(function(i){var l,d,c,u,p=i.pathD,x=(null===(l=i.style)||void 0===l?void 0:l.badgeBorder)||"#6366F1",m="conn-marker-".concat(i.id),y="".concat(i.id,"-bg"),F="".concat(i.id,"-stroke"),b="".concat(i.id,"-btn"),k="".concat(i.id,"-number"),v=void 0!==i.x1?i.x1+40:0,w=void 0!==i.y1?i.y1:0;return t("g",{children:[r("defs",{children:r("clipPath",e({id:"connections-clip"},{children:r("marker",e({id:m,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto"},{children:r("polygon",{points:"0 0, 8 3, 0 6",fill:x})}))}))}),r("path",{ref:function(e){a.current[y]=e},d:p,fill:"none",stroke:"#FFFFFF",strokeWidth:"4",strokeOpacity:"0.7"}),r("path",{ref:function(e){a.current[F]=e},d:p,fill:"none",stroke:x,strokeWidth:"1.75",markerEnd:"url(#".concat(m,")")}),i.matchLabel&&t("g",e({ref:function(e){a.current[k]=e},transform:"translate(".concat(i.x2-42,", ").concat(i.y2,")"),style:{pointerEvents:"none",transition:"visibility 0ms"}},{children:[r("rect",{x:"-22",y:"-8",width:"44",height:"16",rx:"4",fill:"#FFFFFF"}),r("rect",{x:"-21",y:"-7",width:"42",height:"14",rx:"3",fill:(null===(d=i.style)||void 0===d?void 0:d.badgeBg)||"#FEF08A",stroke:x,strokeWidth:"1"}),r("text",e({x:"0",y:"3.5",fontSize:"9px",fontWeight:"bold",fontFamily:'"Plus Jakarta Sans", sans-serif',fill:(null===(c=i.style)||void 0===c?void 0:c.badgeText)||x,textAnchor:"middle"},{children:i.matchLabel}))]})),s&&void 0!==i.x1&&!g&&r("foreignObject",e({ref:function(e){a.current[b]=e},x:v-12,y:w-12,width:"24",height:"24",style:{pointerEvents:"auto",overflow:"visible"}},{children:r(n,e({onClick:function(e){e.stopPropagation(),h&&h(e)},sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",bgcolor:"#FFFFFF",borderRadius:"50%",border:"1px solid ".concat(x),cursor:"pointer",transition:"transform 0.2s ease","&:hover":{transform:"scale(1.05)",boxShadow:"0px 2px 4px rgba(0,0,0,0.1)"}}},{children:r(o,{locked:f,onToggle:h,color:(null===(u=i.style)||void 0===u?void 0:u.badgeText)||x,borderColor:"transparent",size:12})}))}))]},i.id)}),t("g",{children:[t("g",e({style:{transition:"visibility 0ms"}},{children:[r("path",{ref:function(e){return a.current["guideline-up-stroke"]=e},fill:"none",strokeWidth:"1.75",visibility:"hidden"}),t("g",e({ref:function(e){return a.current["guideline-up-badge"]=e},visibility:"hidden"},{children:[r("polygon",{ref:function(e){return a.current["guideline-up-arrow"]=e},points:"-4,0 0,-6 4,0"}),r("rect",{ref:function(e){return a.current["guideline-up-badge-rect"]=e},x:"-12",y:"3",width:"24",height:"15",rx:"4",fill:"#FFFFFF",strokeWidth:"1"}),r("text",{ref:function(e){return a.current["guideline-up-text"]=e},x:"0",y:"14",fontSize:"10px",fontWeight:"bold",fontFamily:'"Plus Jakarta Sans", sans-serif',textAnchor:"middle"})]}))]})),t("g",e({style:{transition:"visibility 0ms"}},{children:[r("path",{ref:function(e){return a.current["guideline-down-stroke"]=e},fill:"none",strokeWidth:"1.75",visibility:"hidden"}),t("g",e({ref:function(e){return a.current["guideline-down-badge"]=e},visibility:"hidden"},{children:[r("polygon",{ref:function(e){return a.current["guideline-down-arrow"]=e},points:"-4,0 0,6 4,0"}),r("rect",{ref:function(e){return a.current["guideline-down-badge-rect"]=e},x:"-12",y:"-18",width:"24",height:"15",rx:"4",fill:"#FFFFFF",strokeWidth:"1"}),r("text",{ref:function(e){return a.current["guideline-down-text"]=e},x:"0",y:"-7",fontSize:"10px",fontWeight:"bold",fontFamily:'"Plus Jakarta Sans", sans-serif',textAnchor:"middle"})]}))]}))]})]})};export{d as default};
|
|
2
2
|
//# sourceMappingURL=connectedLines.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{isMissingStr as i,safeStringify as o,getRationale as r,resolveComparisonInputItems as a,getSideData as d,hasValue as l,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";var u={id:"",title:"",similarity:0,sections:[]},v=function(v,c,f,p,I){void 0===I&&(I=!0);var _="string"==typeof f?f:JSON.stringify(f||{}),h=t(function(){if(!v||0===Object.keys(v).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var t=JSON.parse(_);try{var l=v.nodes||v,s=[],u=[],f=v.base_root_id,p=v.input_index_map||{0:"left",1:"right"},h=v[f]||l[f];if(!h||!1===h.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var g=v.content_mapping||{},m=function(n){return v[n]||l[n]},x=function(e,t,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(I)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),d={},l={},s=null;return a.forEach(function(n){var r,a,u,v,c,f=e[n];if(f&&"object"==typeof f){s||(s=f);var I=!(null==f?void 0:f.status)||"pending"===f.status,_=function(n){var e,t=(null===(e=null==f?void 0:f.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==f?void 0:f.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},h=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,o=n;t<o.length;t++){var r=o[t];if(Array.isArray(r)&&r.some(function(n){return!i(n)}))return r}return[]},g=I?h((null===(a=null==f?void 0:f.deviation_highlights)||void 0===a?void 0:a[t])||(null===(u=null==f?void 0:f.deviation_highlights)||void 0===u?void 0:u[p[0]]),_(t),_(p[0])):[],m=I?h((null===(v=null==f?void 0:f.deviation_highlights)||void 0===v?void 0:v[o])||(null===(c=null==f?void 0:f.deviation_highlights)||void 0===c?void 0:c[p[1]]),_(o),_(p[1])):[];d[n]=((r={})[p[0]]=g[0]||"",r[p[1]]=m[0]||"",r.deviation_summary=(null==f?void 0:f.deviation_summary)||"",r.deviation_title=null==f?void 0:f.deviation_title,r.deviation_impact=null==f?void 0:f.deviation_impact,r.deviation_explanation=null==f?void 0:f.deviation_explanation,r.evaluation_outputs=null==f?void 0:f.evaluation_outputs,r.cognitive_decisioning=null==f?void 0:f.cognitive_decisioning,r.deviation_highlights=null==f?void 0:f.deviation_highlights,r),l[n]=f}}),n(n({},e),{deviation_title:(null==s?void 0:s.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==s?void 0:s.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:d,deviation_entries:l})},b=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var d=e.get(a);d.subsections||(d.subsections=[]),d.subsections.some(function(e){return e.id===n.id})||d.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},d=0,l=n;d<l.length;d++){a(l[d])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},y=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=p[0],i=p[1];return e.length>0&&(t=e.includes(p[0])?p[0]:e[0],i=e.includes(p[1])?p[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},C=function(e,t,i,r){var a=t.attributes||{},d=t.data||{},l=!1!==a.display_title,s=!1!==a.display_content,u=l?o(d.title||""):"",v=s?o(d.content||""):"",c=s?o(d.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),I=!(!u.trim()&&!v.trim());return n(n({id:"".concat(e,"::").concat(t.contentId),nodeId:e,contentId:t.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:l,displayContent:s,subsections:[]},I?r:{score:void 0,relation:"not_defined"}),{evaluationResult:i,evaluationResults:i?[i]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},R=function(n,t){n.refIndexes=Array.from(new Set(e(e([],n.refIndexes||[],!0),t.refIndexes||[],!0))),n.refContentIds=Array.from(new Set(e(e([],n.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((n.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(n.subsections=e(e([],n.subsections||[],!0),[t],!1),i.add(o))});var o=e(e([],n.evaluationResults||(n.evaluationResult?[n.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return n.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!n.evaluationResult&&t.evaluationResult&&(n.evaluationResult=t.evaluationResult),!n.cognitiveData&&t.cognitiveData&&(n.cognitiveData=t.cognitiveData),n},E=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},O=function(e,i){var o,d=m(e);if(!d||!1===d.display_node)return[];var l=y(d),s=l.nodeLeftId,u=l.nodeRightId,v=r(d),c=(null===(o=null==t?void 0:t[e])||void 0===o?void 0:o.evaluation_result)||d.evaluation_result||null,f=x(c,s,u),I=f&&"object"==typeof f?n(n({},f),{nodeId:e}):f,_=a(d,i,p,g).map(function(n){return C(e,n,I,v)});if(d.next){var h=Object.values(d.next).flatMap(function(n){return O(n,i)});_.forEach(function(n){var e=h.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:h})}return _};if(c){var N=function(e,i){var o;void 0===i&&(i=0);var d=[],l=[];if(!e)return{refSections:d,baseSections:l};var s={},u={},v=-1,c=-1,f=function(d){var l=e[d],f=m(l);if(!f||!1===f.display_node)return"continue";var I=y(f),_=I.nodeLeftId,h=I.nodeRightId,b=r(f),E=(null===(o=null==t?void 0:t[l])||void 0===o?void 0:o.evaluation_result)||f.evaluation_result||null,O=x(E,_,h),j=O&&"object"==typeof O?n(n({},O),{nodeId:l}):O,S=N(f.next,i+1),P=S.refSections,D=S.baseSections,k=a(f,"1",p,g),K=a(f,"0",p,g),w=k.map(function(n){var e=C(l,n,j,b);return-1===e.selfIndex&&(e.selfIndex=v--),e}),V=K.map(function(n){var e=C(l,n,j,b);return-1===e.selfIndex&&(e.selfIndex=c--),e});V.forEach(function(n){w.forEach(function(e){var t,i,o,r,a,d,l,s;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(d=e.refContentIds)||void 0===d||d.push(n.contentId)),e.contentId&&!(null===(l=n.refContentIds)||void 0===l?void 0:l.includes(e.contentId))&&(null===(s=n.refContentIds)||void 0===s||s.push(e.contentId))})}),w.forEach(function(n){var e=P.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||l);s[t]=s[t]?R(s[t],n):n}),V.forEach(function(n){var e=D.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var t=0===i?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||l);u[t]=u[t]?R(u[t],n):n})};for(var I in e)f(I);return d=Object.values(s),l=Object.values(u),d.sort(E),l.sort(E),{refSections:d,baseSections:l}},j=N(h.next),S=j.refSections,P=j.baseSections;u=b(S),s=P}else h.next&&Object.values(h.next).forEach(function(n){var e=m(n);e&&!1!==e.display_node&&(s.push.apply(s,O(n,"0")),u.push.apply(u,O(n,"1")))}),u=b(u);var D=d(h,"0",p,g),k=d(h,"1",p,g);return{activeProposed:{title:D.title||"Uploaded Contract",description:h.decision_scope_description||"",sections:s},activeVariants:[{id:"tree-variant-1",title:k.title||"Reference Template",similarity:0,sections:u,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:h.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[v,c,_,I]),g=h.activeProposed,m=h.activeVariants,x=h.parseError,b=(null==m?void 0:m[0])||u,y=t(function(){return(null==g?void 0:g.sections)||[]},[null==g?void 0:g.sections]),C=t(function(){return b.sections||[]},[b.sections]),R=y.length>0||C.length>0,E=t(function(){return p.fields.filter(function(n){var e=n.key;return(!R||"description"!==e)&&(l(null==g?void 0:g[e])||l(b[e]))})},[g,b,R,p.fields]),O=t(function(){var n,e,t={},o={},r={},a=0,d=null===(n=null==v?void 0:v.input_index_map)||void 0===n?void 0:n[0],l=null===(e=null==v?void 0:v.input_index_map)||void 0===e?void 0:e[1],u=function(n,e){if(!c){var t="left"===e?y.indexOf(n):C.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:y.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,a=y.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(a){var d=a.selfIndex,l=void 0!==d&&d>=0?d+1:y.indexOf(a)+1;return{rootKey:"left-root:".concat(a.id),parentNum:l}}var s=void 0!==r&&r>=0?r+1:C.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:s}},f=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,u,v,c,I,_){if(e&&function(n,e,t){var a;((null===(a=null==n?void 0:n.evaluationResults)||void 0===a?void 0:a.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(a){var u=(null==a?void 0:a.deviations)||{};Object.keys(u).sort().forEach(function(v){var c=u[v];if(c){var f=!i(c[d]),p=!i(c[l]);if(f||p){var I=(null==a?void 0:a.nodeId)||n.nodeId||n.id,_="".concat(I).concat(s).concat(v);void 0===o[_]&&(void 0===r[e]&&(r[e]=1),o[_]={index:r[e]++,rootKey:e,parentNum:t})}}})})}(e,v,c),e&&!I){var h=(null==_?void 0:_.id)||"fallback_parent_".concat(a++);t[h]||(t[h]=[]),t[h].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(t){var i=f(null==n?void 0:n.subsections,t),o=f(null==u?void 0:u.subsections,t);p(t,i,o,v,c,!1,e||_)})};y.forEach(function(n){var e,t=u(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(c){var a=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=C.find(function(n){return n.selfIndex===a})}else r=C[y.indexOf(n)];p(n,n,r,i,o,!0,n)}),C.forEach(function(n){var e=u(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var I=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),_=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:t,registry:I,deviationParentRegistry:_}},[y,C,c,v]),N=O.parentDeviationRecord,j=O.registry,S=O.deviationParentRegistry;return{activeProposed:g,activeVariants:m,existingRule:b,proposedSections:y,existingSections:C,visibleFields:E,parentDeviationRecord:N,deviationNumberRegistry:j,deviationParentRegistry:S,parseError:x}};export{v as useCognitiveTreeData};
|
|
1
|
+
import{__assign as n,__spreadArray as e}from"tslib";import{useMemo as t}from"react";import{isMissingStr as i,safeStringify as o,getRationale as r,resolveComparisonInputItems as a,getSideData as d,hasValue as l,DEVIATION_BADGE_SEPARATOR as s}from"../CognitiveComparehelpers.js";var u={id:"",title:"",similarity:0,sections:[]},v=function(v,c,f,p,I,_){var h,g;void 0===I&&(I=!0);var m="string"==typeof f?f:JSON.stringify(f||{}),x=Boolean(_&&(null===(g=null===(h=_.data)||void 0===h?void 0:h.artifactData)||void 0===g?void 0:g.userStorySnapshot)),b=t(function(){var t;if(!v||0===Object.keys(v).length)return{activeProposed:{},activeVariants:[],parseError:"Tree data is required"};var l=JSON.parse(m);try{var s=v.nodes||v,u=[],f=[],p=v.base_root_id,h=v.input_index_map||{0:"left",1:"right"},g=v[p]||s[p];if(!g||!1===g.display_node)return{activeProposed:{title:"No Data",sections:[]},activeVariants:[],parseError:null};var b=v.content_mapping||{},y=function(n){return v[n]||s[n]},R=function(e,t,o){if(!e||"object"!=typeof e)return e||null;if(e.deviations)return e;if(I)return e;var r=Object.keys(e).filter(function(n){return/^\d+$/.test(n)});if(!r.length)return e;var a=r.sort(function(n,e){return Number(n)-Number(e)}),d={},l={},s=null;return a.forEach(function(n){var r,a,u,v,c,f=e[n];if(f&&"object"==typeof f){s||(s=f);var p=!(null==f?void 0:f.status)||"pending"===f.status,I=function(n){var e,t=(null===(e=null==f?void 0:f.cognitive_decisioning)||void 0===e?void 0:e.citations)||(null==f?void 0:f.citations)||{};return Object.values(t).map(function(e){var t;return null===(t=null==e?void 0:e[n])||void 0===t?void 0:t.highlighted_text}).filter(function(n){return"string"==typeof n&&n.trim().length>0})},_=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,o=n;t<o.length;t++){var r=o[t];if(Array.isArray(r)&&r.some(function(n){return!i(n)}))return r}return[]},g=p?_((null===(a=null==f?void 0:f.deviation_highlights)||void 0===a?void 0:a[t])||(null===(u=null==f?void 0:f.deviation_highlights)||void 0===u?void 0:u[h[0]]),I(t),I(h[0])):[],m=p?_((null===(v=null==f?void 0:f.deviation_highlights)||void 0===v?void 0:v[o])||(null===(c=null==f?void 0:f.deviation_highlights)||void 0===c?void 0:c[h[1]]),I(o),I(h[1])):[];d[n]=((r={})[h[0]]=g[0]||"",r[h[1]]=m[0]||"",r.deviation_summary=(null==f?void 0:f.deviation_summary)||"",r.deviation_title=null==f?void 0:f.deviation_title,r.deviation_impact=null==f?void 0:f.deviation_impact,r.deviation_explanation=null==f?void 0:f.deviation_explanation,r.evaluation_outputs=null==f?void 0:f.evaluation_outputs,r.cognitive_decisioning=null==f?void 0:f.cognitive_decisioning,r.deviation_highlights=null==f?void 0:f.deviation_highlights,r),l[n]=f}}),n(n({},e),{deviation_title:(null==s?void 0:s.deviation_title)||(null==e?void 0:e.deviation_title),deviation_impact:(null==s?void 0:s.deviation_impact)||(null==e?void 0:e.deviation_impact),deviation_summary:(null==s?void 0:s.deviation_summary)||(null==e?void 0:e.deviation_summary),deviation_explanation:(null==s?void 0:s.deviation_explanation)||(null==e?void 0:e.deviation_explanation),evaluation_outputs:(null==s?void 0:s.evaluation_outputs)||(null==e?void 0:e.evaluation_outputs),cognitive_decisioning:(null==s?void 0:s.cognitive_decisioning)||(null==e?void 0:e.cognitive_decisioning),deviations:d,deviation_entries:l})},C=function(n){var e=new Map,t=function(n){n.forEach(function(n){var i;n.id&&e.set(n.id,n),(null===(i=n.subsections)||void 0===i?void 0:i.length)&&t(n.subsections)})};t(n);var i=function(n,t){for(var o,r=[],a=function(n){var a=n.ref_parent_section_node_id;if(a&&e.has(a)&&a!==(null==t?void 0:t.id)){var d=e.get(a);d.subsections||(d.subsections=[]),d.subsections.some(function(e){return e.id===n.id})||d.subsections.push(n)}else(null===(o=n.subsections)||void 0===o?void 0:o.length)&&(n.subsections=i(n.subsections,n)),r.push(n)},d=0,l=n;d<l.length;d++){a(l[d])}return r},o=i(n),r=function(n){n.forEach(function(n){n.subsections&&n.subsections.length>0&&(n.subsections.sort(function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:(n.selfIndex||0)-(e.selfIndex||0)}),r(n.subsections))})};return r(o),o},E=function(n){var e=n.comparison_inputs?Object.keys(n.comparison_inputs):[],t=h[0],i=h[1];return e.length>0&&(t=e.includes(h[0])?h[0]:e[0],i=e.includes(h[1])?h[1]:e.length>1?e[1]:e[0]),{nodeLeftId:t,nodeRightId:i}},O=function(e,t,i,r){var a=t.attributes||{},d=t.data||{},l=!1!==a.display_title,s=!1!==a.display_content,u=l?o(d.title||""):"",v=s?o(d.content||""):"",c=s?o(d.change_history||""):"",f=void 0!==a.display_index&&null!==a.display_index?Number(a.display_index):-1,p=function(n){return(null==n?void 0:n.entity_id)||(null==n?void 0:n.ref_parent_section_node_id)||(null==n?void 0:n.parent_entity_id)||null}(a),I=!(!u.trim()&&!v.trim());return n(n({id:"".concat(e,"::").concat(t.contentId),nodeId:e,contentId:t.contentId,parentContentId:p,title:u,content:v,change_history:c,displayTitle:l,displayContent:s,subsections:[]},I?r:{score:void 0,relation:"not_defined"}),{evaluationResult:i,evaluationResults:i?[i]:[],selfIndex:f,refIndexes:[],refContentIds:[],ref_parent_section_node_id:p})},N=function(n,t){n.refIndexes=Array.from(new Set(e(e([],n.refIndexes||[],!0),t.refIndexes||[],!0))),n.refContentIds=Array.from(new Set(e(e([],n.refContentIds||[],!0),t.refContentIds||[],!0)));var i=new Set((n.subsections||[]).map(function(n){return n.id||n.contentId||n.nodeId}));(t.subsections||[]).forEach(function(t){var o=t.id||t.contentId||t.nodeId;i.has(o)||(n.subsections=e(e([],n.subsections||[],!0),[t],!1),i.add(o))});var o=e(e([],n.evaluationResults||(n.evaluationResult?[n.evaluationResult]:[]),!0),t.evaluationResults||(t.evaluationResult?[t.evaluationResult]:[]),!0).filter(Boolean),r=new Set;return n.evaluationResults=o.filter(function(n){var e=(null==n?void 0:n.nodeId)||JSON.stringify(Object.keys((null==n?void 0:n.deviations)||n||{}));return!r.has(e)&&(r.add(e),!0)}),!n.evaluationResult&&t.evaluationResult&&(n.evaluationResult=t.evaluationResult),!n.cognitiveData&&t.cognitiveData&&(n.cognitiveData=t.cognitiveData),n},S=function(n,e){return n.selfIndex<0&&e.selfIndex>=0?1:n.selfIndex>=0&&e.selfIndex<0?-1:n.selfIndex-e.selfIndex},j=function(e,t){var i,o=y(e);if(!o||!1===o.display_node)return[];if(x&&"1"===t)return[];var d=E(o),s=d.nodeLeftId,u=d.nodeRightId,v=r(o),c=(null===(i=null==l?void 0:l[e])||void 0===i?void 0:i.evaluation_result)||o.evaluation_result||null,f=R(c,s,u),p=f&&"object"==typeof f?n(n({},f),{nodeId:e}):f,I=a(o,t,h,b).map(function(n){return O(e,n,p,v)});if(o.next){var _=Object.values(o.next).flatMap(function(n){return j(n,t)});I.forEach(function(n){var e=_.filter(function(e){return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId});n.subsections=e.length?e:_})}return I};if(c){var D=function(e,t){var i;void 0===t&&(t=0);var o=[],d=[];if(!e)return{refSections:o,baseSections:d};var s={},u={},v=-1,c=-1,f=function(o){var d=e[o],f=y(d);if(!f||!1===f.display_node)return"continue";var p=E(f),I=p.nodeLeftId,_=p.nodeRightId,g=r(f),m=(null===(i=null==l?void 0:l[d])||void 0===i?void 0:i.evaluation_result)||f.evaluation_result||null,C=R(m,I,_),S=C&&"object"==typeof C?n(n({},C),{nodeId:d}):C,j=D(f.next,t+1),P=j.refSections,k=j.baseSections,K=a(f,"0",h,b).map(function(n){var e=O(d,n,S,g);return-1===e.selfIndex&&(e.selfIndex=c--),e}),w=[];if(!x){var V=a(f,"1",h,b);w=V.map(function(n){var e=O(d,n,S,g);return-1===e.selfIndex&&(e.selfIndex=v--),e})}K.forEach(function(n){w.forEach(function(e){var t,i,o,r,a,d,l,s;Number(e.selfIndex)>=0&&Number(n.selfIndex)>=0&&((null===(t=e.refIndexes)||void 0===t?void 0:t.includes(Number(n.selfIndex)))||null===(i=e.refIndexes)||void 0===i||i.push(Number(n.selfIndex)),(null===(o=n.refIndexes)||void 0===o?void 0:o.includes(Number(e.selfIndex)))||null===(r=n.refIndexes)||void 0===r||r.push(Number(e.selfIndex))),n.contentId&&!(null===(a=e.refContentIds)||void 0===a?void 0:a.includes(n.contentId))&&(null===(d=e.refContentIds)||void 0===d||d.push(n.contentId)),e.contentId&&!(null===(l=n.refContentIds)||void 0===l?void 0:l.includes(e.contentId))&&(null===(s=n.refContentIds)||void 0===s||s.push(e.contentId))})}),w.forEach(function(n){var e=P.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var i=0===t?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);s[i]=s[i]?N(s[i],n):n}),K.forEach(function(n){var e=k.filter(function(e){var t;return!e.parentContentId||e.parentContentId===n.contentId||e.parentContentId===n.parentContentId||(null===(t=n.refContentIds)||void 0===t?void 0:t.includes(e.parentContentId))});e.length>0&&(n.subsections=e);var i=0===t?String(n.selfIndex):"".concat(n.selfIndex,"_").concat(n.contentId||d);u[i]=u[i]?N(u[i],n):n})};for(var p in e)f(p);return o=Object.values(s),d=Object.values(u),o.sort(S),d.sort(S),{refSections:o,baseSections:d}},P=D(g.next),k=P.refSections,K=P.baseSections;x||(f=C(k)),u=K}else g.next&&Object.values(g.next).forEach(function(n){var e=y(n);e&&!1!==e.display_node&&(u.push.apply(u,j(n,"0")),x||f.push.apply(f,j(n,"1")))}),x||(f=C(f));var w=d(g,"0",h,b),V=d(g,"1",h,b);return{activeProposed:{title:w.title||"Uploaded Contract",description:g.decision_scope_description||"",sections:u},activeVariants:[{id:"tree-variant-1",title:x?(null===(t=null==_?void 0:_.data)||void 0===t?void 0:t.artifactTitle)||"Rulebook Guidelines":V.title||"Reference Template",similarity:0,sections:f,analysis:{rule_difference_comparison:{summary:{overall_score:0,overall_summary:g.decision_scope_description||""},fields:{}}}}],parseError:null}}catch(n){return console.error("Data Transformation Error: ",n),{activeProposed:{},activeVariants:[],parseError:n instanceof Error?n.message:"Unknown Parsing Error"}}},[v,c,m,I,_]),y=b.activeProposed,R=b.activeVariants,C=b.parseError,E=(null==R?void 0:R[0])||u,O=t(function(){return(null==y?void 0:y.sections)||[]},[null==y?void 0:y.sections]),N=t(function(){return E.sections||[]},[E.sections]),S=O.length>0||N.length>0,j=t(function(){return p.fields.filter(function(n){var e=n.key;return(!S||"description"!==e)&&(l(null==y?void 0:y[e])||l(E[e]))})},[y,E,S,p.fields]),D=t(function(){var n,e,t={},o={},r={},a=0,d=null===(n=null==v?void 0:v.input_index_map)||void 0===n?void 0:n[0],l=null===(e=null==v?void 0:v.input_index_map)||void 0===e?void 0:e[1],u=function(n,e){if(!c){var t="left"===e?O.indexOf(n):N.indexOf(n);return{rootKey:"".concat(e,":").concat(t),parentNum:t+1}}if("left"===e){var i=n.selfIndex,o=void 0!==i&&i>=0?i+1:O.indexOf(n)+1;return{rootKey:"left-root:".concat(n.id),parentNum:o}}var r=n.selfIndex,a=O.find(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(r)});if(a){var d=a.selfIndex,l=void 0!==d&&d>=0?d+1:O.indexOf(a)+1;return{rootKey:"left-root:".concat(a.id),parentNum:l}}var s=void 0!==r&&r>=0?r+1:N.indexOf(n)+1;return{rootKey:"right-orphan-root:".concat(n.id),parentNum:s}},f=function(n,e){if(n&&e)return n.find(function(n){return n.id===e.id||n.nodeId&&n.nodeId===e.nodeId||n.contentId&&n.contentId===e.contentId})||void 0},p=function(n,e,u,v,c,I,_){if(e&&function(n,e,t){var a;((null===(a=null==n?void 0:n.evaluationResults)||void 0===a?void 0:a.length)?n.evaluationResults:(null==n?void 0:n.evaluationResult)?[n.evaluationResult]:[]).forEach(function(a){var u=(null==a?void 0:a.deviations)||{};Object.keys(u).sort().forEach(function(v){var c=u[v];if(c){var f=!i(c[d]),p=!i(c[l]);if(f||p){var I=(null==a?void 0:a.nodeId)||n.nodeId||n.id,_="".concat(I).concat(s).concat(v);void 0===o[_]&&(void 0===r[e]&&(r[e]=1),o[_]={index:r[e]++,rootKey:e,parentNum:t})}}})})}(e,v,c),e&&!I){var h=(null==_?void 0:_.id)||"fallback_parent_".concat(a++);t[h]||(t[h]=[]),t[h].push(e)}((null==e?void 0:e.subsections)||(null==n?void 0:n.subsections)||(null==u?void 0:u.subsections)||[]).forEach(function(t){var i=f(null==n?void 0:n.subsections,t),o=f(null==u?void 0:u.subsections,t);p(t,i,o,v,c,!1,e||_)})};O.forEach(function(n){var e,t=u(n,"left"),i=t.rootKey,o=t.parentNum,r=null;if(c){var a=null===(e=n.refIndexes)||void 0===e?void 0:e[0];r=N.find(function(n){return n.selfIndex===a})}else r=N[O.indexOf(n)];p(n,n,r,i,o,!0,n)}),x||N.forEach(function(n){var e=u(n,"right"),t=e.rootKey,i=e.parentNum;t.startsWith("right-orphan-root:")&&p(n,null,n,t,i,!0,n)});var I=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].index]})),_=Object.fromEntries(Object.entries(o).map(function(n){return[n[0],n[1].parentNum]}));return{parentDeviationRecord:t,registry:I,deviationParentRegistry:_}},[O,N,c,v,x]),P=D.parentDeviationRecord,k=D.registry,K=D.deviationParentRegistry;return{isGuidelineMode:x,activeProposed:y,activeVariants:R,existingRule:E,proposedSections:O,existingSections:N,visibleFields:j,parentDeviationRecord:P,deviationNumberRegistry:k,deviationParentRegistry:K,parseError:C}};export{v as useCognitiveTreeData};
|
|
2
2
|
//# sourceMappingURL=useCompareData.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as t,useRef as e,useCallback as n,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,getBentArrowPath as c}from"../CognitiveComparehelpers.js";var o=function(o){var l=o.containerRef,u=o.leftContainerRef,a=o.rightContainerRef;o.svgContainerRef;var d=o.pathRefs,v=o.leftHeaderRef,h=o.rightHeaderRef,s=o.proposedSections,g=o.existingSections,f=o.visibleFields,p=o.leftRefs,y=o.rightRefs,x=o.sectionLeftRefs,m=o.sectionRightRefs,R=o.subSectionLeftRefs,C=o.subSectionRightRefs,B=o.lhsBadgeRefs,b=o.rhsBadgeRefs,S=o.sectionRowRefs,M=o.expandedSections,L=o.expandedSubSections,I=o.connectedSections,T=o.isSideBySide,H=o.activeSideBySideSection,A=o.maintainRelativeOrder,E=o.cognitiveMap,k=o.getSectionCompareStyle,w=o.getSubSectionCompareStyle,D=o.getDeviationStyleByKey,Y=o.isArrowVisible,F=o.isAnimatingRef,N=o.isSideBySideRef,O=o.sideBySideCacheRef,j=o.sideBySideLineRef,z=o.activeSideBySideSectionRef,P=o.activeSideBySideRightSectionRef,q=o.connectedLines,K=o.setConnectedLines,V=o.cachedConnectedPositions,G=o.calculateLinesRef,J=o.resizeTimerRef,Q=o.scrollLock,U=o.scrollSyncLocked,W=o.handleResizeRef,X=o.activeProposed,Z=o.existingRule,$=o.analysisData,_=o.pendingScrollTargetRef,tt=o.pendingScrollCallbackRef,et=o.resolvedComparisonConfig,nt=o.getFieldData,rt=t([]),it=rt[0],ct=rt[1],ot=t(null),lt=ot[0],ut=ot[1],at=t([]),dt=at[0],vt=at[1],ht=null!=q?q:dt,st=null!=K?K:vt,gt=t({width:0,height:0}),ft=gt[0],pt=gt[1],yt=e(!1),xt=e(!1),mt=e(!1),Rt=e(null),Ct=e([]),Bt=null!=V?V:Ct,bt=n(function(){var t,e,n,r,o,d,S,Y,N,O,j,z,P,q,K,V,G,J;if(!yt.current&&!F.current){yt.current=!0;try{if(!l.current)return;var Q=function(t){var e=t.split("-"),n=e[0];if(!M[n]&&!1===A)return!1;if(A&&!M["left-".concat(n)]&&!M["right-".concat(n)]&&!M[n])return!1;for(var r=n,i=1;i<e.length-1;i++)if(r+="-".concat(e[i]),!L[r])return!1;return!0},U=l.current.getBoundingClientRect();pt({width:U.width,height:U.height});var W=[];if(f.forEach(function(t){var e,n,r=t.key,i=null===(e=p.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;i&&c&&(i.style.height="auto",c.style.height="auto",i.style.minHeight="0px",c.style.minHeight="0px")}),!F.current){for(var X=0;X<Math.max(s.length,g.length);X++){var Z=null===(t=x.current[X])||void 0===t?void 0:t.current,$=null===(e=m.current[X])||void 0===e?void 0:e.current;Z&&(Z.style.height="auto",Z.style.minHeight="0px"),$&&($.style.height="auto",$.style.minHeight="0px")}A||Object.keys(R.current).forEach(function(t){var e,n;if(Q(t)){var r=null===(e=R.current[t])||void 0===e?void 0:e.current,i=null===(n=C.current[t])||void 0===n?void 0:n.current;r&&i&&(r.style.height="auto",i.style.height="auto",r.style.minHeight="0px",i.style.minHeight="0px")}})}var _={};f.forEach(function(t){var e,n,r=t.key,i=null===(e=p.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=i.getBoundingClientRect(),l=c.getBoundingClientRect();_[r]=Math.max(o.height,l.height)}});var tt={left:{},right:{}},et={};if(!F.current)if(A){if(T&&null!==H)if("number"==typeof H){var nt=H,rt=s[nt],it=null===(o=x.current[nt])||void 0===o?void 0:o.current;it&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=g.findIndex(function(e){return e.selfIndex===t}),r=null===(e=m.current[n])||void 0===e?void 0:e.current;if(r&&(M["left-".concat(nt)]||M["right-".concat(n)])){var i=Math.max(it.getBoundingClientRect().height,r.getBoundingClientRect().height);tt.left[nt]=Math.max(tt.left[nt]||0,i),tt.right[n]=Math.max(tt.right[n]||0,i)}})}else{var ot=H.split(i)[2];if(ot){Z=null===(d=R.current[ot])||void 0===d?void 0:d.current,$=null===(S=C.current[ot])||void 0===S?void 0:S.current;if(Z&&$){lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,lt)}}}}else{Object.keys(R.current).forEach(function(t){var e,n;if(Q(t)){var r=null===(e=R.current[t])||void 0===e?void 0:e.current,i=null===(n=C.current[t])||void 0===n?void 0:n.current;if(r&&i&&null!==r.offsetParent&&null!==i.offsetParent){var c=r.getBoundingClientRect(),o=i.getBoundingClientRect(),l=Math.max(c.height,o.height);et[t]=l,r.style.minHeight="".concat(l,"px"),i.style.minHeight="".concat(l,"px")}}});for(X=0;X<Math.min(s.length,g.length);X++){var Z=null===(n=x.current[X])||void 0===n?void 0:n.current,$=null===(r=m.current[X])||void 0===r?void 0:r.current;if(Z&&$){var lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);tt.left[X]=lt,tt.right[X]=lt}}}f.forEach(function(t){var e,n,r=t.key,i=null===(e=p.current[r])||void 0===e?void 0:e.current,c=null===(n=y.current[r])||void 0===n?void 0:n.current;if(i&&c){var o=_[r];i.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),F.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=x.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],r=t[1],i=null===(e=m.current[Number(n)])||void 0===e?void 0:e.current;i&&(i.style.minHeight="".concat(r,"px"))}),A||Object.keys(et).forEach(function(t){var e,n,r=null===(e=R.current[t])||void 0===e?void 0:e.current,i=null===(n=C.current[t])||void 0===n?void 0:n.current;if(r&&i&&et[t]){var c=et[t];r.style.minHeight="".concat(c,"px"),i.style.minHeight="".concat(c,"px")}}));if(s.forEach(function(t,e){var n,r=null===(n=x.current[e])||void 0===n?void 0:n.current;if(r){var i=function(t,e){var n=(t.refIndexes||[]).map(function(t){return g.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&g[e]?[e]:Array.from(new Set(n))}(t,e);i.forEach(function(n){var i,c,o,l,d,v,h,s,f,p,y=null===(i=m.current[n])||void 0===i?void 0:i.current;if(y){var x=r.getBoundingClientRect(),R=y.getBoundingClientRect(),C=x.right-U.left,B=R.left-U.left,b=x.top+18-U.top,S=R.top+18-U.top;if(A&&T&&H===e){var M=null!==(o=null===(c=u.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==o?o:0,L=null!==(d=null===(l=a.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==d?d:0,I=M+(null!==(h=null===(v=u.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0),w=L+(null!==(f=null===(s=a.current)||void 0===s?void 0:s.clientHeight)&&void 0!==f?f:1/0),D=function(t,e,n){return Math.max(e,Math.min(n,t))};b=D(x.top+18,M,I)-U.top,S=D(R.top+18,L,w)-U.top}var Y=k(e);Y&&W.push({id:"line-".concat(e,"-").concat(n),x1:C,y1:b,x2:B,y2:S,style:Y,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=g[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&E[t.nodeId])})}})}}),T&&"string"==typeof H&&H.includes(i)){var at=H.split(i),dt=at[0],vt=at[1],ht=at[2],gt=(at[3],"".concat(dt).concat(i).concat(vt)),ft=null===(Y=B.current[gt])||void 0===Y?void 0:Y.current,xt=null===(N=b.current[gt])||void 0===N?void 0:N.current;if(ft&&xt){var mt=ft.getBoundingClientRect(),Rt=xt.getBoundingClientRect(),Ct=mt.right-U.left,bt=Rt.left-U.left,St=mt.top+mt.height/2-U.top,Mt=Rt.top+Rt.height/2-U.top;if(A){var Lt=null!==(j=null===(O=u.current)||void 0===O?void 0:O.getBoundingClientRect().top)&&void 0!==j?j:0,It=null!==(P=null===(z=a.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==P?P:0,Tt=Lt+(null!==(K=null===(q=u.current)||void 0===q?void 0:q.clientHeight)&&void 0!==K?K:1/0),Ht=It+(null!==(G=null===(V=a.current)||void 0===V?void 0:V.clientHeight)&&void 0!==G?G:1/0),At=function(t,e,n){return Math.max(e,Math.min(n,t))};St=At(mt.top+mt.height/2,Lt,Tt)-U.top,Mt=At(Rt.top+Rt.height/2,It,Ht)-U.top}var Et=null!==(J=D(dt,vt))&&void 0!==J?J:w(ht);Et&&W.push({id:"line-subsec-".concat(gt),x1:Ct,y1:St,x2:bt,y2:Mt,style:Et,sectionIdx:Number(ht.split("-")[0]),isSubSection:!0,subSectionKeyPath:H})}}if(ct(W),v.current&&h.current){var kt=v.current.getBoundingClientRect(),wt=h.current.getBoundingClientRect(),Dt=(kt.top+kt.height/2-U.top+wt.top+wt.height/2-U.top)/2;ut({x1:kt.right-U.left,x2:wt.left-U.left,y:Dt})}else ut(null);if(I.size>0){var Yt=[],Ft=u.current,Nt=a.current;if(Ft&&Nt){var Ot=[],jt=Ft.getBoundingClientRect().top,zt=Nt.getBoundingClientRect().top,Pt=jt+Ft.clientHeight,qt=zt+Nt.clientHeight,Kt=Ft.scrollTop,Vt=Nt.scrollTop,Gt=U.top,Jt=function(t,e,n){return Math.max(e,Math.min(n,t))};I.forEach(function(t){var e,n,r,o,l,u;if("string"==typeof t&&t.includes(i)){var a=t.split(i),d=a[0],v=a[1],h=a[2],f=(a[3],"".concat(d).concat(i).concat(v)),p=null===(e=B.current[f])||void 0===e?void 0:e.current,y=null===(n=b.current[f])||void 0===n?void 0:n.current;if(!p||!y)return;var x=p.getBoundingClientRect(),m=y.getBoundingClientRect(),R=null!==(r=D(d,v))&&void 0!==r?r:w(h),C=(K=x.right-U.left)+.5*((V=m.left-U.left-0)-K),S=x.top+x.height/2,M=m.top+m.height/2,L=S-jt+Kt,I=M-zt+Vt,T="conn-subsec-".concat(f);Ot.push({lhsScrollY:L,rhsScrollY:I,x1:K,x2:V,containerTop:Gt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:T});var H=Jt(S,jt,Pt),E=Jt(M,zt,qt),Y=H-Gt,F=E-Gt,N=M>=zt-4&&M<=qt+4,O="";O=(G=S>=jt-4&&S<=Pt+4)&&N?c(K,Y,V,F):G&&!N?"M ".concat(K,",").concat(Y," L ").concat(C,",").concat(Y," L ").concat(C,",").concat(F):!G&&N?"M ".concat(C,",").concat(Y," L ").concat(C,",").concat(F," L ").concat(V,",").concat(F):"M ".concat(C,",").concat(Y," L ").concat(C,",").concat(F),Yt.push({id:T,pathD:O,style:R,leftIdx:t,rhsArrayIdx:t,x1:K,x2:V,y1:Y,y2:F})}else if(A){var j=t,z=s[j];if(!(null===(u=null==z?void 0:z.refIndexes)||void 0===u?void 0:u.length))return;z.refIndexes.forEach(function(t){var e,n,r=g.findIndex(function(e){return e.selfIndex===t});if(-1!==r){var i=null===(e=B.current[j])||void 0===e?void 0:e.current,o=null===(n=b.current[r])||void 0===n?void 0:n.current;if(i&&o){var l=i.getBoundingClientRect(),u=o.getBoundingClientRect(),a=k(j),d=l.right-U.left,v=u.left-U.left-0,h=d+.5*(v-d),s=l.top+l.height/2,f=u.top+u.height/2,p=s-jt+Kt,y=f-zt+Vt,x="conn-".concat(j,"-").concat(r);Ot.push({lhsScrollY:p,rhsScrollY:y,x1:d,x2:v,containerTop:Gt,leftIdx:j,rhsArrayIdx:r,styleColor:(null==a?void 0:a.badgeBorder)||"#6366F1",styleId:x});var m=Jt(s,jt,Pt),R=Jt(f,zt,qt),C=m-Gt,S=R-Gt,M=s>=jt-4&&s<=Pt+4,L=f>=zt-4&&f<=qt+4,I="";I=M&&L?c(d,C,v,S):M&&!L?"M ".concat(d,",").concat(C," L ").concat(h,",").concat(C," L ").concat(h,",").concat(S):!M&&L?"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S," L ").concat(v,",").concat(S):"M ".concat(h,",").concat(C," L ").concat(h,",").concat(S),Yt.push({id:x,pathD:I,style:a,leftIdx:j,rhsArrayIdx:r,x1:d,x2:v,y1:C,y2:S})}}})}else{var P=t,q=P;p=null===(o=B.current[P])||void 0===o?void 0:o.current,y=null===(l=b.current[q])||void 0===l?void 0:l.current;if(!p||!y)return;var K,V;x=p.getBoundingClientRect(),m=y.getBoundingClientRect(),R=k(P),C=(K=x.right-U.left)+.5*((V=m.left-U.left-0)-K),S=x.top+x.height/2,M=m.top+m.height/2,L=S-jt+Kt,I=M-zt+Vt,T="conn-".concat(P,"-").concat(q);Ot.push({lhsScrollY:L,rhsScrollY:I,x1:K,x2:V,containerTop:Gt,leftIdx:P,rhsArrayIdx:q,styleColor:(null==R?void 0:R.badgeBorder)||"#6366F1",styleId:T});var G;H=Jt(S,jt,Pt),E=Jt(M,zt,qt),Y=H-Gt,F=E-Gt,N=M>=zt-4&&M<=qt+4,O="";O=(G=S>=jt-4&&S<=Pt+4)&&N?c(K,Y,V,F):G&&!N?"M ".concat(K,",").concat(Y," L ").concat(C,",").concat(Y," L ").concat(C,",").concat(F):!G&&N?"M ".concat(C,",").concat(Y," L ").concat(C,",").concat(F," L ").concat(V,",").concat(F):"M ".concat(C,",").concat(Y," L ").concat(C,",").concat(F),Yt.push({id:T,pathD:O,style:R,leftIdx:P,rhsArrayIdx:q,x1:K,x2:V,y1:Y,y2:F})}}),Bt.current=Ot}st(Yt)}else st([]),Bt.current=[]}catch(t){console.error("Line render safe fail: ",t)}finally{yt.current=!1}}},[f,s,g,E,et,nt,k,D,A,T,H,I,M,L]),St=n(function(){var t,e,n,r,i,o,v,h,s,g,f,p,y,x,m=Bt.current;if(m.length&&!F.current){var R=null!==(e=null===(t=u.current)||void 0===t?void 0:t.scrollTop)&&void 0!==e?e:0,C=null!==(r=null===(n=a.current)||void 0===n?void 0:n.scrollTop)&&void 0!==r?r:0,B=null!==(o=null===(i=u.current)||void 0===i?void 0:i.clientHeight)&&void 0!==o?o:1/0,b=null!==(h=null===(v=a.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,S=null!==(g=null===(s=u.current)||void 0===s?void 0:s.getBoundingClientRect().top)&&void 0!==g?g:0,M=null!==(p=null===(f=a.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==p?p:0,L=S+B,I=M+b,T=null!==(x=null===(y=l.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,H=function(t,e,n){return Math.max(e,Math.min(n,t))};m.forEach(function(t){var e=t.lhsScrollY-R+S,n=t.rhsScrollY-C+M,r=d.current[t.styleId+"-stroke"],i=d.current[t.styleId+"-bg"],o=d.current[t.styleId+"-btn"];if(r||i){var l,u=H(e,S,L),a=H(n,M,I),v=u-T,h=a-T,s=e>=S-4&&e<=L+4,g=n>=M-4&&n<=I+4,f=t.x1+.5*(t.x2-t.x1);l=s&&g?c(t.x1,v,t.x2,h):s&&!g?"M ".concat(t.x1,",").concat(v," L ").concat(f,",").concat(v," L ").concat(f,",").concat(h):!s&&g?"M ".concat(f,",").concat(v," L ").concat(f,",").concat(h," L ").concat(t.x2,",").concat(h):"M ".concat(f,",").concat(v," L ").concat(f,",").concat(h),r&&(r.setAttribute("visibility","visible"),r.setAttribute("d",l)),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",l)),o&&(s?(o.setAttribute("visibility","visible"),o.setAttribute("y",String(v-12))):o.setAttribute("visibility","hidden"))}})}},[]),Mt=n(function(){Bt.current.length>0&&!F.current||(null!==Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(function(){G.current(),Rt.current=null},50))},[]),Lt=n(function(t){if(null!==_.current&&tt.current&&Math.abs(t.currentTarget.scrollTop-_.current)<=2){var e=tt.current;_.current=null,tt.current=null,e()}if(!mt.current&&!Q.current){if(A&&U&&(N.current||I.size>0)){var n=t.currentTarget,r=u.current,c=a.current,o=n===r?c:n===c?r:null;if(n&&o){var d=function(){var t,e,n,r,c,o,l,u,a,d,v,h=z.current,s=P.current;if(null===h)return{leftAnchor:null,rightAnchor:null};if("string"==typeof h&&h.includes(i)){var g=h.split(i),f="".concat(g[0]).concat(i).concat(g[1]);return{leftAnchor:(null===(t=B.current[f])||void 0===t?void 0:t.current)||(null===(e=R.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=x.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(r=b.current[f])||void 0===r?void 0:r.current)||(null===(c=C.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=m.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(h),y=null!==s?Number(s):p;return{leftAnchor:(null===(l=B.current[p])||void 0===l?void 0:l.current)||(null===(u=S.current[p])||void 0===u?void 0:u.current)||(null===(a=x.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=b.current[y])||void 0===d?void 0:d.current)||(null===(v=m.current[y])||void 0===v?void 0:v.current)||null}}(),v=d.leftAnchor,h=d.rightAnchor,s=n===r?v:h,g=n===r?h:v,f=null;if(s&&g){var p=s.getBoundingClientRect(),y=g.getBoundingClientRect(),M=o.getBoundingClientRect(),L=p.top+p.height/2;f=y.top-M.top+o.scrollTop+y.height/2-(L-M.top)}else{var T=Math.max(0,n.scrollHeight-n.clientHeight),H=Math.max(0,o.scrollHeight-o.clientHeight);f=T>0?n.scrollTop/T*H:n.scrollTop}var E=Math.max(0,o.scrollHeight-o.clientHeight);f=Math.max(0,Math.min(f,E)),Math.abs(o.scrollTop-f)>1&&(mt.current=!0,o.scrollTop=f,requestAnimationFrame(function(){mt.current=!1}))}}A||Mt(),xt.current||(xt.current=!0,requestAnimationFrame(function(){var t,e,n,r,c,o,d;if(N.current){var v=u.current,h=a.current;if(v&&h&&j.current){if(!O.current){var s=z.current,g=void 0;if("string"==typeof s&&s.includes(i)){var f=s.split(i),p="".concat(f[0]).concat(i).concat(f[1]);g=null===(t=B.current[p])||void 0===t?void 0:t.current}else g=null===(e=B.current[s])||void 0===e?void 0:e.current;if(g){var y=g.getBoundingClientRect();O.current={badgeScreenY:y.top+y.height/2,initialScrollTop:v.scrollTop,leftTop:v.getBoundingClientRect().top,leftBottom:v.getBoundingClientRect().top+v.clientHeight,cTop:null!==(r=null===(n=l.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==r?r:0}}}if(O.current){var x=O.current,m=v.scrollTop-x.initialScrollTop,R=x.badgeScreenY-m,C=((c=R,o=x.leftTop,d=x.leftBottom,Math.max(o,Math.min(d,c)))-x.cTop).toString(),b=R>=x.leftTop-4&&R<=x.leftBottom+4;j.current.setAttribute("y1",C),j.current.setAttribute("y2",C),j.current.setAttribute("visibility",b?"visible":"hidden")}}}Bt.current.length>0&&St(),xt.current=!1}))}},[St,A,U,I,Mt]);return r(function(){G.current=bt},[bt]),r(function(){var t=setTimeout(Mt,250),e=function(){return W.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==Rt.current&&clearTimeout(Rt.current),null!==J.current&&clearTimeout(J.current),window.removeEventListener("resize",e)}},[X,Z,$,f,M,L,s,g,et,Mt,T,H,Y,I]),{lines:it,setLines:ct,overallConnector:lt,setOverallConnector:ut,connectedLines:ht,setConnectedLines:st,svgDimensions:ft,cachedConnectedPositions:Bt,calculateLines:bt,calculateLinesRef:G,calculateLinesDebounced:Mt,handleColumnScroll:Lt}};export{o as useLinesCalculator};
|
|
1
|
+
import{useState as t,useRef as e,useCallback as n,useEffect as i}from"react";import{DEVIATION_BADGE_SEPARATOR as r}from"../CognitiveComparehelpers.js";var c=function(c){var o=c.containerRef,l=c.leftContainerRef,u=c.rightContainerRef;c.svgContainerRef;var a=c.pathRefs,d=c.leftHeaderRef,s=c.rightHeaderRef,v=c.proposedSections,h=c.existingSections,g=c.visibleFields,f=c.leftRefs,p=c.rightRefs,b=c.sectionLeftRefs,y=c.sectionRightRefs,x=c.subSectionLeftRefs,m=c.subSectionRightRefs,R=c.lhsBadgeRefs,C=c.rhsBadgeRefs,A=c.sectionRowRefs,B=c.expandedSections,S=c.expandedSubSections,M=c.connectedSections,T=c.isSideBySide,I=c.activeSideBySideSection,L=c.maintainRelativeOrder,F=c.isGuidelineMode,H=c.cognitiveMap,w=c.getSectionCompareStyle,k=c.getSubSectionCompareStyle,E=c.getDeviationStyleByKey,N=c.isArrowVisible,Y=c.isAnimatingRef,D=c.isSideBySideRef,j=c.sideBySideCacheRef,O=c.sideBySideLineRef,z=c.activeSideBySideSectionRef,P=c.activeSideBySideRightSectionRef,Q=c.connectedLines,X=c.setConnectedLines,q=c.cachedConnectedPositions,G=c.calculateLinesRef,K=c.resizeTimerRef,V=c.scrollLock,J=c.scrollSyncLocked,U=c.handleResizeRef,W=c.activeProposed,Z=c.existingRule,$=c.analysisData,_=c.pendingScrollTargetRef,tt=c.pendingScrollCallbackRef,et=c.resolvedComparisonConfig,nt=c.getFieldData,it=t([]),rt=it[0],ct=it[1],ot=t(null),lt=ot[0],ut=ot[1],at=t([]),dt=at[0],st=at[1],vt=null!=Q?Q:dt,ht=null!=X?X:st,gt=t({width:0,height:0}),ft=gt[0],pt=gt[1],bt=e(!1),yt=e(!1),xt=e(!1),mt=e(null),Rt=e([]),Ct=null!=q?q:Rt,At=function(t,e,n,i,r,c,o){if(Math.abs(i-e)<=1)return c&&o?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&o?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var l=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?l:-l,d=i>e?u:-u,s=n>r?u:-u;return c&&o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!o?"M ".concat(t,",").concat(e," L ").concat(r-l,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&o?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},Bt=n(function(){var t,e,n,i,c,a,A,N,D,j,O,z,P,Q,X,q,G,K;if(!bt.current&&!Y.current){bt.current=!0;try{if(!o.current)return;var V=function(t){var e=t.split("-"),n=e[0];if(!B[n]&&!1===L)return!1;if(L&&!B["left-".concat(n)]&&!B["right-".concat(n)]&&!B[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!S[i])return!1;return!0},J=o.current.getBoundingClientRect();pt({width:J.width,height:J.height});var U=[];if(g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!Y.current){for(var W=0;W<Math.max(v.length,h.length);W++){var Z=null===(t=b.current[W])||void 0===t?void 0:t.current,$=null===(e=y.current[W])||void 0===e?void 0:e.current;Z&&(Z.style.height="auto",Z.style.minHeight="0px"),$&&($.style.height="auto",$.style.minHeight="0px")}L||Object.keys(x.current).forEach(function(t){var e,n;if(V(t)){var i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var _={};g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=r.getBoundingClientRect(),l=c.getBoundingClientRect();_[i]=Math.max(o.height,l.height)}});var tt={left:{},right:{}},et={};if(!Y.current)if(L){if(T&&null!==I)if("number"==typeof I){var nt=I,it=v[nt],rt=null===(c=b.current[nt])||void 0===c?void 0:c.current;rt&&it&&(it.refIndexes||[]).forEach(function(t){var e,n=h.findIndex(function(e){return e.selfIndex===t}),i=null===(e=y.current[n])||void 0===e?void 0:e.current;if(i&&(B["left-".concat(nt)]||B["right-".concat(n)])){var r=Math.max(rt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[nt]=Math.max(tt.left[nt]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=I.split(r)[2];if(ot){Z=null===(a=x.current[ot])||void 0===a?void 0:a.current,$=null===(A=m.current[ot])||void 0===A?void 0:A.current;if(Z&&$){lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,lt)}}}}else{Object.keys(x.current).forEach(function(t){var e,n;if(V(t)){var i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),o=r.getBoundingClientRect(),l=Math.max(c.height,o.height);et[t]=l,i.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}});for(W=0;W<Math.min(v.length,h.length);W++){var Z=null===(n=b.current[W])||void 0===n?void 0:n.current,$=null===(i=y.current[W])||void 0===i?void 0:i.current;if(Z&&$){var lt=Math.max(Z.getBoundingClientRect().height,$.getBoundingClientRect().height);tt.left[W]=lt,tt.right[W]=lt}}}if(g.forEach(function(t){var e,n,i=t.key,r=null===(e=f.current[i])||void 0===e?void 0:e.current,c=null===(n=p.current[i])||void 0===n?void 0:n.current;if(r&&c){var o=_[i];r.style.minHeight="".concat(o,"px"),c.style.minHeight="".concat(o,"px")}}),Y.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=b.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=y.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),L||Object.keys(et).forEach(function(t){var e,n,i=null===(e=x.current[t])||void 0===e?void 0:e.current,r=null===(n=m.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!F){v.forEach(function(t,e){var n,i=null===(n=b.current[e])||void 0===n?void 0:n.current;if(i){var r=function(t,e){var n=(t.refIndexes||[]).map(function(t){return h.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&h[e]?[e]:Array.from(new Set(n))}(t,e);r.forEach(function(n){var r,c,o,a,d,s,v,g,f,p,b=null===(r=y.current[n])||void 0===r?void 0:r.current;if(b){var x=i.getBoundingClientRect(),m=b.getBoundingClientRect(),R=x.right-J.left,C=m.left-J.left,A=x.top+18-J.top,B=m.top+18-J.top;if(L&&T&&I===e){var S=null!==(o=null===(c=l.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==o?o:0,M=null!==(d=null===(a=u.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==d?d:0,F=S+(null!==(v=null===(s=l.current)||void 0===s?void 0:s.clientHeight)&&void 0!==v?v:1/0),k=M+(null!==(f=null===(g=u.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0),E=function(t,e,n){return Math.max(e,Math.min(n,t))};A=E(x.top+18,S,F)-J.top,B=E(m.top+18,M,k)-J.top}var N=w(e);N&&U.push({id:"line-".concat(e,"-").concat(n),x1:R,y1:A,x2:C,y2:B,style:N,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=h[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&H[t.nodeId])})}})}})}if(!F&&T&&"string"==typeof I&&I.includes(r)){var at=I.split(r),dt=at[0],st=at[1],vt=at[2],gt=(at[3],"".concat(dt).concat(r).concat(st)),ft=null===(N=R.current[gt])||void 0===N?void 0:N.current,yt=null===(D=C.current[gt])||void 0===D?void 0:D.current;if(ft&&yt){var xt=ft.getBoundingClientRect(),mt=yt.getBoundingClientRect(),Rt=xt.right-J.left,Bt=mt.left-J.left,Mt=xt.top+xt.height/2-J.top,Tt=mt.top+mt.height/2-J.top;if(L){var It=null!==(O=null===(j=l.current)||void 0===j?void 0:j.getBoundingClientRect().top)&&void 0!==O?O:0,Lt=null!==(P=null===(z=u.current)||void 0===z?void 0:z.getBoundingClientRect().top)&&void 0!==P?P:0,Ft=It+(null!==(X=null===(Q=l.current)||void 0===Q?void 0:Q.clientHeight)&&void 0!==X?X:1/0),Ht=Lt+(null!==(G=null===(q=u.current)||void 0===q?void 0:q.clientHeight)&&void 0!==G?G:1/0),wt=function(t,e,n){return Math.max(e,Math.min(n,t))};Mt=wt(xt.top+xt.height/2,It,Ft)-J.top,Tt=wt(mt.top+mt.height/2,Lt,Ht)-J.top}var kt=null!==(K=E(dt,st))&&void 0!==K?K:k(vt);kt&&U.push({id:"line-subsec-".concat(gt),x1:Rt,y1:Mt,x2:Bt,y2:Tt,style:kt,sectionIdx:Number(vt.split("-")[0]),isSubSection:!0,subSectionKeyPath:I})}}if(ct(U),d.current&&s.current){var Et=d.current.getBoundingClientRect(),Nt=s.current.getBoundingClientRect(),Yt=(Et.top+Et.height/2-J.top+Nt.top+Nt.height/2-J.top)/2;ut({x1:Et.right-J.left,x2:Nt.left-J.left,y:Yt})}else ut(null);if(M.size>0){var Dt=[],jt=l.current,Ot=u.current;if(jt&&Ot){var zt=[],Pt=jt.getBoundingClientRect().top,Qt=Ot.getBoundingClientRect().top,Xt=Pt+jt.clientHeight,qt=Qt+Ot.clientHeight,Gt=jt.scrollTop,Kt=Ot.scrollTop,Vt=J.top,Jt=function(t,e,n){return Math.max(e,Math.min(n,t))};M.forEach(function(t){var e,n,i,c,o,l,u,a,d;if(F){var s=null,g=null,f=null;if("string"==typeof t&&t.includes(r)){var p=t.split(r),b=p[0],y=p[1],x=p[2],m="".concat(b).concat(r).concat(y);s=null===(e=R.current[m])||void 0===e?void 0:e.current,f=null!==(n=E(b,y))&&void 0!==n?n:k(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),s=null===(i=R.current[g])||void 0===i?void 0:i.current,f=w(g);if(!s)return;document.querySelectorAll('[id^="guideline-target-"]').forEach(function(e,n){var i=s.getBoundingClientRect(),c=e.getBoundingClientRect(),o=i.right-J.left,l=c.left-J.left-0,u=o+75,a=i.top+i.height/2,d=c.top+c.height/2,v=a-Pt+Gt,h=d-Qt+Kt,g="conn-guide-".concat(t,"-").concat(n),p="";"string"==typeof t&&t.includes(r)?p=(t.split(r)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):p=String(Number(t)+1);var b=String.fromCharCode(97+n),y="".concat(p,"(").concat(b,")");zt.push({lhsScrollY:v,rhsScrollY:h,x1:o,x2:l,containerTop:Vt,leftIdx:t,rhsArrayIdx:n,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var x=Jt(a,Pt,Xt),m=Jt(d,Qt,qt),R=x-Vt,C=m-Vt,A=At(o,R,l,C,u,a>=Pt-4&&a<=Xt+4,d>=Qt-4&&d<=qt+4);Dt.push({id:g,pathD:A,style:f,leftIdx:t,rhsArrayIdx:n,x1:o,x2:l,y1:R,y2:C,centerX:u,matchLabel:y,isGuideline:!0})})}else if("string"==typeof t&&t.includes(r)){var A=t.split(r),B=(b=A[0],y=A[1],x=A[2],A[3],m="".concat(b).concat(r).concat(y),null===(c=R.current[m])||void 0===c?void 0:c.current),S=null===(o=C.current[m])||void 0===o?void 0:o.current;if(!B||!S)return;var M=B.getBoundingClientRect(),T=S.getBoundingClientRect(),I=null!==(l=E(b,y))&&void 0!==l?l:k(x),H=M.right-J.left,N=T.left-J.left-0,Y=H+75,D=M.top+M.height/2,j=T.top+T.height/2,O=D-Pt+Gt,z=j-Qt+Kt,P="conn-subsec-".concat(m),Q=(x||"").split("-").map(function(t){return Number(t)+1}).join("."),X="".concat(Q,"(a)");zt.push({lhsScrollY:O,rhsScrollY:z,x1:H,x2:N,containerTop:Vt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==I?void 0:I.badgeBorder)||"#6366F1",styleBg:(null==I?void 0:I.badgeBg)||"#FFFFFF",styleText:(null==I?void 0:I.badgeText)||"#A16207",styleId:P,centerX:Y});var q=Jt(D,Pt,Xt),G=Jt(j,Qt,qt),K=At(H,$=q-Vt,N,_=G-Vt,Y,D>=Pt-4&&D<=Xt+4,j>=Qt-4&&j<=qt+4);Dt.push({id:P,pathD:K,style:I,leftIdx:t,rhsArrayIdx:t,x1:H,x2:N,y1:$,y2:_,matchLabel:X})}else if(L){var V=t,U=v[V];if(!(null===(d=null==U?void 0:U.refIndexes)||void 0===d?void 0:d.length))return;U.refIndexes.forEach(function(e,n){var i,r,c=h.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var o=null===(i=R.current[V])||void 0===i?void 0:i.current,l=null===(r=C.current[c])||void 0===r?void 0:r.current;if(o&&l){var u=o.getBoundingClientRect(),a=l.getBoundingClientRect(),d=w(V),s=u.right-J.left,v=a.left-J.left-0,g=s+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Pt+Gt,y=p-Qt+Kt,x="conn-".concat(V,"-").concat(c),m=String(Number(t)+1),A=String.fromCharCode(97+n),B="".concat(m,"(").concat(A,")");zt.push({lhsScrollY:b,rhsScrollY:y,x1:s,x2:v,containerTop:Vt,leftIdx:V,rhsArrayIdx:c,styleColor:(null==d?void 0:d.badgeBorder)||"#6366F1",styleBg:(null==d?void 0:d.badgeBg)||"#FFFFFF",styleText:(null==d?void 0:d.badgeText)||"#A16207",styleId:x,centerX:g});var S=Jt(f,Pt,Xt),M=Jt(p,Qt,qt),T=S-Vt,I=M-Vt,L=At(s,T,v,I,g,f>=Pt-4&&f<=Xt+4,p>=Qt-4&&p<=qt+4);Dt.push({id:x,pathD:L,style:d,leftIdx:V,rhsArrayIdx:c,x1:s,x2:v,y1:T,y2:I,matchLabel:B})}}})}else{var W=t,Z=W;B=null===(u=R.current[W])||void 0===u?void 0:u.current,S=null===(a=C.current[Z])||void 0===a?void 0:a.current;if(!B||!S)return;M=B.getBoundingClientRect(),T=S.getBoundingClientRect(),I=w(W),H=M.right-J.left,N=T.left-J.left-0,Y=H+75,D=M.top+M.height/2,j=T.top+T.height/2,O=D-Pt+Gt,z=j-Qt+Kt,P="conn-".concat(W,"-").concat(Z),Q=String(Number(t)+1),X="".concat(Q,"(a)");zt.push({lhsScrollY:O,rhsScrollY:z,x1:H,x2:N,containerTop:Vt,leftIdx:W,rhsArrayIdx:Z,styleColor:(null==I?void 0:I.badgeBorder)||"#6366F1",styleBg:(null==I?void 0:I.badgeBg)||"#FFFFFF",styleText:(null==I?void 0:I.badgeText)||"#A16207",styleId:P,centerX:Y});var $,_;q=Jt(D,Pt,Xt),G=Jt(j,Qt,qt),K=At(H,$=q-Vt,N,_=G-Vt,Y,D>=Pt-4&&D<=Xt+4,j>=Qt-4&&j<=qt+4);Dt.push({id:P,pathD:K,style:I,leftIdx:W,rhsArrayIdx:Z,x1:H,x2:N,y1:$,y2:_,matchLabel:X})}}),Ct.current=zt}ht(Dt),setTimeout(function(){return St()},10)}else ht([]),Ct.current=[],setTimeout(function(){return St()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{bt.current=!1}}},[g,v,h,H,et,nt,w,E,L,T,I,M,B,S,F]),St=n(function(){var t,e,n,i,r,c,d,s,v,h,g,f,p,b,y,x,m,R,C,A=Ct.current;if(!A.length)return null===(t=a.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=a.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=a.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(i=a.current["guideline-down-badge"])||void 0===i||i.setAttribute("visibility","hidden"));if(!Y.current){var B=null!==(c=null===(r=l.current)||void 0===r?void 0:r.scrollTop)&&void 0!==c?c:0,S=null!==(s=null===(d=u.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,M=null!==(h=null===(v=l.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,T=null!==(f=null===(g=u.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,I=null!==(b=null===(p=l.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,L=null!==(x=null===(y=u.current)||void 0===y?void 0:y.getBoundingClientRect().top)&&void 0!==x?x:0,F=I+M,H=L+T,w=null===(m=o.current)||void 0===m?void 0:m.getBoundingClientRect(),k=null!==(R=null==w?void 0:w.top)&&void 0!==R?R:0,E=null!==(C=null==w?void 0:w.height)&&void 0!==C?C:1/0,N=function(t,e,n){return Math.max(e,Math.min(n,t))},D=0,j=0,O=0,z=0,P="#6366F1",Q="#A16207",X=!1;if(A.forEach(function(t){var e=t.lhsScrollY-B+I,n=t.rhsScrollY-S+L,i=a.current[t.styleId+"-stroke"],r=a.current[t.styleId+"-bg"],c=a.current[t.styleId+"-btn"],o=a.current[t.styleId+"-number"];if(i||r){var l=N(e,I,F),u=N(n,L,H),d=l-k,s=u-k,v=e>=I-4&&e<=F+4,h=n>=L-4&&n<=H+4,g=!0;X=!0;var f=t.centerX||t.x1+75;0===O&&(O=t.x1,z=d,P=t.styleColor,t.styleBg,Q=t.styleText||"#A16207"),n<L-4?(D++,g=!1):n>H+4&&(j++,g=!1);var p=At(t.x1,d,t.x2,s,f,v,h);i&&(g&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(g&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),X){var q=a.current["guideline-up-stroke"],G=a.current["guideline-up-badge"],K=a.current["guideline-up-arrow"],V=a.current["guideline-up-text"],J=a.current["guideline-up-badge-rect"],U=O+75;if(D>0){var W=Math.max(15,L-k+15),Z=Math.min(15,Math.abs(U-O),Math.max(0,z-W)),$="M ".concat(O,",").concat(z," L ").concat(U-Z,",").concat(z," Q ").concat(U,",").concat(z," ").concat(U,",").concat(z-Z," L ").concat(U,",").concat(W);null==q||q.setAttribute("visibility","visible"),null==q||q.setAttribute("d",$),null==q||q.setAttribute("stroke",P),null==G||G.setAttribute("visibility","visible"),null==G||G.setAttribute("transform","translate(".concat(U,", ").concat(W,")")),K&&K.setAttribute("fill",P),V&&(V.textContent="+".concat(D),V.setAttribute("fill",Q)),J&&J.setAttribute("stroke",P)}else null==q||q.setAttribute("visibility","hidden"),null==G||G.setAttribute("visibility","hidden");var _=a.current["guideline-down-stroke"],tt=a.current["guideline-down-badge"],et=a.current["guideline-down-arrow"],nt=a.current["guideline-down-text"],it=a.current["guideline-down-badge-rect"];if(j>0){var rt=Math.min(E-15,H-k-15);Z=Math.min(15,Math.abs(U-O),Math.max(0,rt-z)),$="M ".concat(O,",").concat(z," L ").concat(U-Z,",").concat(z," Q ").concat(U,",").concat(z," ").concat(U,",").concat(z+Z," L ").concat(U,",").concat(rt);null==_||_.setAttribute("visibility","visible"),null==_||_.setAttribute("d",$),null==_||_.setAttribute("stroke",P),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(U,", ").concat(rt,")")),et&&et.setAttribute("fill",P),nt&&(nt.textContent="+".concat(j),nt.setAttribute("fill",Q)),it&&it.setAttribute("stroke",P)}else null==_||_.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Mt=n(function(){Ct.current.length>0&&!Y.current||(null!==mt.current&&clearTimeout(mt.current),mt.current=setTimeout(function(){G.current(),mt.current=null},50))},[]),Tt=n(function(t){if(null!==_.current&&tt.current&&Math.abs(t.currentTarget.scrollTop-_.current)<=2){var e=tt.current;_.current=null,tt.current=null,e()}if(!xt.current&&!V.current){if(L&&J&&(D.current||M.size>0)){var n=t.currentTarget,i=l.current,c=u.current,a=n===i?c:n===c?i:null;if(n&&a){var d=function(){var t,e,n,i,c,o,l,u,a,d,s,v=z.current,h=P.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(r)){var g=v.split(r),f="".concat(g[0]).concat(r).concat(g[1]);return{leftAnchor:(null===(t=R.current[f])||void 0===t?void 0:t.current)||(null===(e=x.current[g[2]])||void 0===e?void 0:e.current)||(null===(n=b.current[Number(g[2])])||void 0===n?void 0:n.current)||null,rightAnchor:(null===(i=C.current[f])||void 0===i?void 0:i.current)||(null===(c=m.current[g[3]])||void 0===c?void 0:c.current)||(null===(o=y.current[Number(g[3])])||void 0===o?void 0:o.current)||null}}var p=Number(v),B=null!==h?Number(h):p;return{leftAnchor:(null===(l=R.current[p])||void 0===l?void 0:l.current)||(null===(u=A.current[p])||void 0===u?void 0:u.current)||(null===(a=b.current[p])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=C.current[B])||void 0===d?void 0:d.current)||(null===(s=y.current[B])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=n===i?s:v,g=n===i?v:s,f=null;if(h&&g){var p=h.getBoundingClientRect(),B=g.getBoundingClientRect(),S=a.getBoundingClientRect(),T=p.top+p.height/2;f=B.top-S.top+a.scrollTop+B.height/2-(T-S.top)}else{var I=Math.max(0,n.scrollHeight-n.clientHeight),F=Math.max(0,a.scrollHeight-a.clientHeight);f=I>0?n.scrollTop/I*F:n.scrollTop}var H=Math.max(0,a.scrollHeight-a.clientHeight);f=Math.max(0,Math.min(f,H)),Math.abs(a.scrollTop-f)>1&&(xt.current=!0,a.scrollTop=f,requestAnimationFrame(function(){xt.current=!1}))}}L||Mt(),yt.current||(yt.current=!0,requestAnimationFrame(function(){var t,e,n,i,c,a,d;if(D.current){var s=l.current,v=u.current;if(s&&v&&O.current){if(!j.current){var h=z.current,g=void 0;if("string"==typeof h&&h.includes(r)){var f=h.split(r),p="".concat(f[0]).concat(r).concat(f[1]);g=null===(t=R.current[p])||void 0===t?void 0:t.current}else g=null===(e=R.current[h])||void 0===e?void 0:e.current;if(g){var b=g.getBoundingClientRect();j.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(i=null===(n=o.current)||void 0===n?void 0:n.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(j.current){var y=j.current,x=s.scrollTop-y.initialScrollTop,m=y.badgeScreenY-x,C=((c=m,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,c)))-y.cTop).toString(),A=m>=y.leftTop-4&&m<=y.leftBottom+4;O.current.setAttribute("y1",C),O.current.setAttribute("y2",C),O.current.setAttribute("visibility",A?"visible":"hidden")}}}St(),yt.current=!1}))}},[St,L,J,M,Mt]);return i(function(){G.current=Bt},[Bt]),i(function(){var t=setTimeout(Mt,250),e=function(){return U.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==mt.current&&clearTimeout(mt.current),null!==K.current&&clearTimeout(K.current),window.removeEventListener("resize",e)}},[W,Z,$,g,B,S,v,h,et,Mt,T,I,N,M]),{lines:rt,setLines:ct,overallConnector:lt,setOverallConnector:ut,connectedLines:vt,setConnectedLines:ht,svgDimensions:ft,cachedConnectedPositions:Ct,calculateLines:Bt,calculateLinesRef:G,calculateLinesDebounced:Mt,handleColumnScroll:Tt}};export{c as useLinesCalculator};
|
|
2
2
|
//# sourceMappingURL=useLinesCalculator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as e,useRef as n,useCallback as t,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,
|
|
1
|
+
import{useState as e,useRef as n,useCallback as t,useEffect as r}from"react";import{DEVIATION_BADGE_SEPARATOR as i,resetClauseHighlight as l,smoothScrollTo as u}from"../CognitiveComparehelpers.js";var o=function(o){var c=o.isGuidelineMode,d=o.maintainRelativeOrder,s=o.proposedSections,v=o.existingSections,a=o.leftContainerRef,p=o.rightContainerRef,g=o.scrollContainerRef,f=o.sectionLeftRefs,h=o.sectionRightRefs,R=o.subSectionLeftRefs,S=o.subSectionRightRefs,y=o.lhsBadgeRefs,m=o.rhsBadgeRefs,B=o.sectionRowRefs,x=o.sectionRightRowRefs,C=o.rhsTopSpacerRef,T=o.rhsBottomSpacerRef,b=o.lhsTopSpacerRef,A=o.lhsBottomSpacerRef,I=o.calculateLinesRef,w=o.setConnectedSections,L=o.setConnectedLines,E=o.cachedConnectedPositions,F=o.closeMoreFunctionsPopup,N=o.setErrorToast;o.moreFunctions,o.closeSummaryPopup;var q=e(!1),H=q[0],M=q[1],P=e(!1),z=P[0],V=P[1],j=e(!1),k=j[0],G=j[1],O=e(!1),D=O[0],J=O[1],K=e(null),Q=K[0],U=K[1],W=n(!1),X=n(null),Y=n(!1),Z=n(null),$=n(null),_=n(null),ee=n(new Set),ne=function(){ee.current.forEach(function(e){l(e)}),ee.current.clear()},te=function(e,n,t){var r,l,u,o,c,d,s,v,g,C,T,b,A=null,I=null,w=null,L=null,E=null,F=null,N=function(e,n){if(!e||!n)return!0;var t=e.getBoundingClientRect(),r=n.getBoundingClientRect();return t.bottom>=r.top&&t.top<=r.bottom};if(e){var q=n.split(i),H="".concat(q[0]).concat(i).concat(q[1]);A=(null===(r=R.current[q[2]])||void 0===r?void 0:r.current)||(null===(l=f.current[Number(q[2])])||void 0===l?void 0:l.current)||null,I=(null===(u=S.current[q[3]])||void 0===u?void 0:u.current)||(null===(o=h.current[Number(q[3])])||void 0===o?void 0:o.current)||null,w=(null===(c=y.current[H])||void 0===c?void 0:c.current)||A,L=(null===(d=m.current[H])||void 0===d?void 0:d.current)||I}else{var M=Number(n),P=null!==t?Number(t):M;A=(null===(s=f.current[M])||void 0===s?void 0:s.current)||null,I=(null===(v=h.current[P])||void 0===v?void 0:v.current)||null,E=(null===(g=y.current[M])||void 0===g?void 0:g.current)||null,F=(null===(C=m.current[P])||void 0===C?void 0:C.current)||null,w=E||(null===(T=B.current[M])||void 0===T?void 0:T.current)||A,L=F||(null===(b=x.current[P])||void 0===b?void 0:b.current)||I}if(A&&(A.style.paddingTop="0px"),I&&(I.style.paddingTop="0px"),e||(E&&(E.style.marginTop="0px"),F&&(F.style.marginTop="0px")),!e&&E&&F){var z=a.current,V=p.current;if(!N(E,z)||!N(F,V))return;var j=E.getBoundingClientRect(),k=F.getBoundingClientRect(),G=j.top-k.top;if(Math.abs(G)>32)return;G>0&&(F.style.marginTop="".concat(G,"px"))}else if(w&&L&&A&&I){j=w.getBoundingClientRect(),k=L.getBoundingClientRect();(G=j.top-k.top)>0&&(I.style.paddingTop="".concat(G,"px"))}},re=t(function(){var e,n,t,r,l,u,o,c,d=Z.current,s=$.current;if(null!==d)if("string"==typeof d&&d.includes(i)){var v=d.split(i),a=(null===(e=R.current[v[2]])||void 0===e?void 0:e.current)||(null===(n=f.current[Number(v[2])])||void 0===n?void 0:n.current)||null,p=(null===(t=S.current[v[3]])||void 0===t?void 0:t.current)||(null===(r=h.current[Number(v[3])])||void 0===r?void 0:r.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px")}else{a=(null===(l=f.current[d])||void 0===l?void 0:l.current)||null,p=(null===(u=h.current[null!=s?s:d])||void 0===u?void 0:u.current)||null;a&&(a.style.paddingTop="0px"),p&&(p.style.paddingTop="0px");var g=(null===(o=y.current[d])||void 0===o?void 0:o.current)||null,B=(null===(c=m.current[null!=s?s:d])||void 0===c?void 0:c.current)||null;g&&(g.style.marginTop="0px"),B&&(B.style.marginTop="0px")}C.current&&(C.current.style.height="0px"),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px")},[]);r(function(){Y.current=H},[H]),r(function(){Z.current=Q},[Q]);var ie=t(function(){ne(),M(!1),Y.current=!1,X.current=null,re(),U(null),Z.current=null,$.current=null,V(!1),J(!1)},[re]),le=t(function(e,n,t){var r,l,o=null===(r=null==t?void 0:t.toggleIfSame)||void 0===r||r,R=null==t?void 0:t.onReady,S=null!==(l=null==t?void 0:t.sourceSide)&&void 0!==l?l:"left";if(F(),null!=e)if(!n||c){ne();var q=H&&Q===e;H&&null!==Q&&re(),q&&o?ie():(w(new Set([e])),L([]),E.current=[],J(!0),W.current=!0,U(e),Z.current=e,M(!0),Y.current=!0,V(!1),C.current&&(C.current.style.height="0px"),T.current&&(T.current.style.height="0px"),b.current&&(b.current.style.height="0px"),A.current&&(A.current.style.height="0px"),requestAnimationFrame(function(){var n=function(){var n,t,r,l,o,b,A,w,L,E,F,N="string"==typeof e&&e.includes(i),q=null,H=null,M=null;if(c){if(N){var P=e.split(i),z="".concat(P[0]).concat(i).concat(P[1]);q=(null===(n=y.current[z])||void 0===n?void 0:n.current)||null}else q=(null===(t=f.current[e])||void 0===t?void 0:t.current)||(null===(r=B.current[e])||void 0===r?void 0:r.current)||null;H=document.getElementById("guideline-target-0"),M=H?e:null}else if(N){P=e.split(i),z="".concat(P[0]).concat(i).concat(P[1]);q=(null===(l=y.current[z])||void 0===l?void 0:l.current)||null,H=(null===(o=m.current[z])||void 0===o?void 0:o.current)||null,M=H?e:null}else if(q=(null===(b=f.current[e])||void 0===b?void 0:b.current)||(null===(A=B.current[e])||void 0===A?void 0:A.current)||null,d){var j=s[e],k=(null==j?void 0:j.refIndexes)||[];if(k.length>0){var G=k[0],O=v.findIndex(function(e){return e.selfIndex===G});-1!==O&&(H=(null===(E=h.current[O])||void 0===E?void 0:E.current)||(null===(F=x.current[O])||void 0===F?void 0:F.current)||null,M=O)}}else H=(null===(w=h.current[e])||void 0===w?void 0:w.current)||(null===(L=x.current[e])||void 0===L?void 0:L.current)||null,M=H?e:null;$.current=M;var D=a.current,K=p.current,Q=function(){te(N,e,M),V(!0),I.current&&I.current(),W.current=!1,"right"===S&&K?K.dispatchEvent(new Event("scroll")):D&&D.dispatchEvent(new Event("scroll")),J(!1),null==R||R()};if(!q||!D)return W.current=!1,J(!1),void(null==R||R());if(H&&K){if(!d){var U=0;U="right"===S?H?H.getBoundingClientRect().top:0:q?q.getBoundingClientRect().top:0;var X=g.current,Y=(null==X?void 0:X.getBoundingClientRect().top)||0,Z=X?X.scrollTop+U-Y-150:0;return X?void u(X,Z,200,Q):void Q()}var _=q.getBoundingClientRect().top-D.getBoundingClientRect().top+D.scrollTop,ee=H.getBoundingClientRect().top-K.getBoundingClientRect().top+K.scrollTop,ne=200;if("left"===S){var re=ee-(_-D.scrollTop);re<0&&C.current&&!c&&(C.current.style.height="".concat(Math.abs(re),"px")),requestAnimationFrame(function(){var e,n=K.scrollHeight-K.clientHeight;if(re<0)e=0;else{if(re>n){var t=re-n;return T.current&&!c&&(T.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){u(K,re,ne,Q)})}e=re}u(K,e,ne,Q)})}else{var ie=_-(ee-K.scrollTop);requestAnimationFrame(function(){var e,n=D.scrollHeight-D.clientHeight;if(ie<0)e=0;else{if(ie>n)return void requestAnimationFrame(function(){return u(D,n,ne,Q)});e=ie}u(D,e,ne,Q)})}}else Q()};c?setTimeout(n,100):n()}))}else N("No counterpart exists for this section.")},[Q,F,v,H,d,s,re,ie,c]);return{isSideBySide:H,setIsSideBySide:M,isArrowVisible:z,setIsArrowVisible:V,isResizing:k,setIsResizing:G,isSideBySideLoading:D,setIsSideBySideLoading:J,activeSideBySideSection:Q,setActiveSideBySideSection:U,scrollLock:W,sideBySideCacheRef:X,isSideBySideRef:Y,activeSideBySideSectionRef:Z,activeSideBySideRightSectionRef:$,sideBySideLineRef:_,highlightedClauseRefs:ee,clearClauseHighlight:ne,applyAlignmentPadding:te,resetSideBySide:ie,activateSideBySide:le}};export{o as useSideBySide};
|
|
2
2
|
//# sourceMappingURL=useSideBySide.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__rest as r,__assign as n}from"tslib";import{jsx as t,Fragment as e}from"react/jsx-runtime";import{useRef as i,useMemo as c,useEffect as l}from"react";import o from"react-markdown";import a from"rehype-raw";import{sanitizeExternalUrl as h}from"./utils/citationData.utils.js";import u from"./GptWebCitation.module.css.js";var d=function(d){var f=d.content,s=d.activeHighlightIndex,v=d.onHighlightCountChange,m=i(null),g=c(function(){var r,n=f.match(/id=["']highlighted-\d+["']/g);if(null==n?void 0:n.length)return n.length;var t=f.match(/<a\b[^>]*>/gi);return null!==(r=null==t?void 0:t.length)&&void 0!==r?r:0},[f]),p=c(function(){return/id=["']highlighted-\d+["']/.test(f)},[f]);l(function(){null==v||v(g)},[g,v]),l(function(){var r;if(m.current){var n=m.current.querySelector("#highlighted-".concat(s));if(n)n.scrollIntoView({behavior:"smooth",block:"center"});else null===(r=m.current.querySelectorAll("a[href]")[s])||void 0===r||r.scrollIntoView({behavior:"smooth",block:"center"})}},[s,f]);var b=c(function(){var i=-1;return{span:function(e){e.node;var i=r(e,["node"]),c=i.id;if(null==c?void 0:c.startsWith("highlighted-")){var l=Number(c.replace("highlighted-",""))===s;return t("span",n({},i,{id:c,className:"".concat(u.highlight).concat(l?" ".concat(u.highlightActive):"")}))}return t("span",n({},i))},a:function(r){var c,l=r.children,o=r.href,a=r.title,d=r.className;if(!o)return t(e,{children:l});i+=1;var f=!p&&i===s,v=null!==(c=h(o))&&void 0!==c?c:"#";return t("a",n({href:v,title:a,target:"_blank",rel:"noreferrer",className:"".concat(u.citationLink).concat(f?" ".concat(u.citationLinkActive):"").concat(d?" ".concat(d):"")},{children:l}))},code:function(e){var i=e.children,c=r(e,["children"]);return t("code",n({},c,{children:i}))},ol:function(e){var i=e.children,c=r(e,["children"]);return t("ol",n({},c,{children:i}))},ul:function(e){var i=e.children,c=r(e,["children"]);return t("ul",n({},c,{children:i}))},li:function(e){var i=e.children,c=r(e,["children"]);return t("li",n({},c,{children:i}))},p:function(e){var i=e.children,c=r(e,["children"]);return t("p",n({},c,{children:i}))}}},[s,p,f]);return t("div",n({ref:m,className:u.markdownBody},{children:t(o,n({rehypePlugins:[a],components:b},{children:f}))}))};export{d as default};
|
|
2
|
+
//# sourceMappingURL=GptWebCitationMarkdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GptWebCitationMarkdown.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|