@viswa-test/test-citation 0.0.378 → 0.0.379

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/utils/normalizeInlineMarkdown.js +2 -0
  8. package/dist/cjs/features/CognitiveCompare/utils/normalizeInlineMarkdown.js.map +1 -0
  9. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  10. package/dist/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
  11. package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
  12. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  13. package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
  14. package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
  15. package/dist/features/CognitiveCompare/utils/normalizeInlineMarkdown.js +2 -0
  16. package/dist/features/CognitiveCompare/utils/normalizeInlineMarkdown.js.map +1 -0
  17. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  18. package/dist/types/src/features/CognitiveCompare/CognitiveCompareConstants.d.ts +1 -1
  19. package/dist/types/src/features/CognitiveCompare/CognitiveCompareConstants.d.ts.map +1 -1
  20. package/dist/types/src/features/CognitiveCompare/CognitivePopup.d.ts.map +1 -1
  21. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  22. package/dist/types/src/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
  23. package/dist/types/src/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
  24. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +0 -1
  25. package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
  26. package/dist/types/src/features/CognitiveCompare/utils/normalizeInlineMarkdown.d.ts +25 -0
  27. package/dist/types/src/features/CognitiveCompare/utils/normalizeInlineMarkdown.d.ts.map +1 -0
  28. 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,Tabs as h,Tab as m}from"@mui/material";import{ChevronDown as S}from"lucide-react";import{ButtonCognitiveIcon as x}from"../../assests/svg/ButtonCognitiveIcon.js";import R from"./OverlayComponent.js";import{safeStringify as b,extractDeviationScore as y,generateColorPalette as C,findKeyPathByNodeId as w,DEVIATION_BADGE_SEPARATOR as B,hasMeaningfulRedlineTags as _,scrollAndHighlightClause as I,scrollAndWait as F,waitForScrollIdle as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as E,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as k}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as D,EMPTY_SUMMARY_POPUP_STATE as O,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import j from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import N from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as G}from"./hooks/useAccordionState.js";import{useDeviationNavigation as q}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import K from"./components/SubSectionAccordion.js";import J from"./components/LHSSectionRow.js";import Y from"./components/RHSSectionRow.js";import X from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as $}from"./CompareContext.js";import{useStyleHelpers as U}from"./hooks/useStyles.js";import{useResizeHandler as Q}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Z}from"./hooks/useLinesCalculator.js";import{useSideBySide as ee}from"./hooks/useSideBySide.js";import ne from"./components/SvgConnectors.js";import ie from"./Guidelines/components/GuidelinePanel.js";import te from"./Guidelines/components/WebGptPanel.js";import{GuidelineSkeleton as oe}from"./components/GuidelineSkeletonLoader.js";import{getVisibleGuidelineTargets as re}from"./Guidelines/utils/guidelineTargets.js";import{hasGptCitationObjects as le}from"./Guidelines/utils/hasGptCitationObjects.js";var ue=function(ue){var ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,be,ye,Ce,we,Be,_e,Ie,Fe,Te,Ee,Ae,ke,De,Oe,Pe,je,Le,Ne,Me,He,ze,We,Ge=ue.componentHeaderText,qe=void 0===Ge?P:Ge,Ve=ue.treeData,Ke=ue.comparisonConfig,Je=ue.leftColumnTitleText,Ye=ue.rightColumnTitleText,Xe=ue.markdownStyles,$e=ue.resetTrigger,Ue=ue.displayConfig,Qe=void 0===Ue?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Ue,Ze=ue.onMaintainRelativeOrderChange,en=ue.popupConfig,nn=ue.deviationData,tn=void 0===nn?{}:nn,on=ue.deviationNodeIdToView,rn=ue.resetDeviationNodeId,ln=ue.isProposingFix,un=void 0!==ln&&ln,cn=ue.proposingFixNodeId,an=ue.isRedlineFlow,sn=ue.badgeStyleOverride,dn=ue.guidelinesData,vn=ue.isGuidelineMode,fn=ue.gptWebCitationConfig,pn=l(Qe.maintainRelativeOrder),gn=pn[0],hn=pn[1],mn=null!==(ce=null==Qe?void 0:Qe.expandLevels)&&void 0!==ce?ce:0,Sn=!!(null==Qe?void 0:Qe.expandAllSections),xn=!!gn||!!(null==Qe?void 0:Qe.showDeviationBadges),Rn=l(!1),bn=Rn[0],yn=Rn[1],Cn=l(null),wn=Cn[0],Bn=Cn[1],_n=l(null===(se=null!==(ae=null==Ve?void 0:Ve.newEvaluationResult)&&void 0!==ae?ae:null==Qe?void 0:Qe.enableDeviationSchemaBackwardCompatibility)||void 0===se||se)[0],In=l(new Set),Fn=In[0],Tn=In[1],En=l([]),An=En[0],kn=En[1],Dn=l(!1),On=Dn[0],Pn=Dn[1],jn=l(0),Ln=jn[0],Nn=jn[1],Mn=u(null),Hn=u(null),zn=u(null),Wn=u(null),Gn=u(null),qn=u(!1),Vn=u(null),Kn=u({}),Jn=u([]),Yn=u(function(){}),Xn=u(null),$n=u(function(){}),Un=c(function(){return JSON.stringify(tn||{})},[JSON.stringify(tn)]),Qn=c(function(){return tn||{}},[Un]),Zn=c(function(){return le(Qn)},[Qn]),ei=c(function(){return(null==Ve?void 0:Ve.cognitive_decisioning)||{}},[Ve]),ni=c(function(){return e(e({},E),Xe)},[Xe]),ii=u(null),ti=u(null),oi=u(null),ri=u(null),li=u(null),ui=u(null),ci=u(null),ai=u(null),si=u(null),di=u(null),vi=z(ii),fi=vi.cognitivePopup,pi=vi.setCognitivePopup,gi=vi.moreFunctions,hi=vi.setMoreFunctions,mi=vi.position,Si=vi.setPosition,xi=vi.activeBadgeId,Ri=vi.summaryPopup,bi=vi.setSummaryPopup,yi=vi.closeSummaryPopup,Ci=vi.setActiveBadgeId,wi=vi.popupRef,Bi=vi.handleOpenCognitiveCompare,_i=vi.openCognitivePopupFromState,Ii=vi.closeCognitivePopup,Fi=vi.closeMoreFunctionsPopup,Ti=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==Ke?void 0:Ke.fields)&&void 0!==e?e:A,thresholds:{high:null!==(i=null===(n=null==Ke?void 0:Ke.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:k.thresholds.high,medium:null!==(o=null===(t=null==Ke?void 0:Ke.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:k.thresholds.medium,exact:null!==(l=null===(r=null==Ke?void 0:Ke.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:k.thresholds.exact}}},[Ke]),Ei=l(null),Ai=Ei[0];Ei[1];var ki=null===(fe=null===(de=null==Ve?void 0:Ve.documents)||void 0===de?void 0:de[null===(ve=null==Ve?void 0:Ve.input_index_map)||void 0===ve?void 0:ve[0]])||void 0===fe?void 0:fe.title,Di=null===(he=null===(pe=null==Ve?void 0:Ve.documents)||void 0===pe?void 0:pe[null===(ge=null==Ve?void 0:Ve.input_index_map)||void 0===ge?void 0:ge[1]])||void 0===he?void 0:he.title,Oi=b(Je||ki||"Uploaded Contract"),Pi=null===(Re=null===(xe=null===(me=null==Ve?void 0:Ve.documents)||void 0===me?void 0:me[null===(Se=null==Ve?void 0:Ve.input_index_map)||void 0===Se?void 0:Se[0]])||void 0===xe?void 0:xe.metadata)||void 0===Re?void 0:Re.file_name,ji=b(Pi),Li=null===(we=null===(Ce=null===(be=null==Ve?void 0:Ve.documents)||void 0===be?void 0:be[null===(ye=null==Ve?void 0:Ve.input_index_map)||void 0===ye?void 0:ye[1]])||void 0===Ce?void 0:Ce.metadata)||void 0===we?void 0:we.file_name,Ni=b(Li),Mi=b(Ye||Di||"Reference Template"),Hi=H(Ve,gn,Qn,Ti,_n,dn,vn),zi=Hi.isGuidelineMode,Wi=Hi.activeProposed,Gi=Hi.existingRule,qi=Hi.proposedSections,Vi=Hi.existingSections,Ki=Hi.visibleFields,Ji=Hi.parentDeviationRecord,Yi=Hi.deviationNumberRegistry,Xi=Hi.deviationParentRegistry,$i=Hi.parseError;a(function(){$i&&Bn("Failed to load comparison: ".concat($i))},[$i]);var Ui=qi.length>0||Vi.length>0,Qi=c(function(){if(!an)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)||"";_(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(qi),i(Vi),"".concat(e,":").concat(n)},[an,qi,Vi]);a(function(){if(qi.length||Vi.length)if(Sn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=gn?"".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(qi,"left"),i(Vi,"right"),Ot(e),jt(n)}else if(mn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=gn?"".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(qi,"left",mn),r(Vi,"right",mn),Ot(t),jt(o)}},[Sn,mn,qi,Vi,gn]);var Zi=W(Ki.map(function(e){return e.key}),Math.max(qi.length,Vi.length)),et=Zi.leftRefs,nt=Zi.rightRefs,it=Zi.sectionLeftRefs,tt=Zi.sectionRightRefs,ot=Zi.lhsBadgeRefs,rt=Zi.rhsBadgeRefs,lt=Zi.sectionRightRowRefs,ut=Zi.subSectionLeftRefs,ct=Zi.subSectionRightRefs,at=Zi.sectionRowRefs,st=Zi.getSectionRowRef,dt=Zi.getSubSectionRef,vt=Zi.getBadgeRef,ft=ee({isGuidelineMode:zi,maintainRelativeOrder:gn,proposedSections:qi,existingSections:Vi,leftContainerRef:ai,rightContainerRef:oi,scrollContainerRef:ii,sectionLeftRefs:it,sectionRightRefs:tt,subSectionLeftRefs:ut,subSectionRightRefs:ct,lhsBadgeRefs:ot,rhsBadgeRefs:rt,sectionRowRefs:at,sectionRightRowRefs:lt,rhsTopSpacerRef:ri,rhsBottomSpacerRef:li,lhsTopSpacerRef:ui,lhsBottomSpacerRef:ci,calculateLinesRef:Yn,setConnectedSections:Tn,setConnectedLines:kn,cachedConnectedPositions:Jn,closeMoreFunctionsPopup:Fi,setErrorToast:Bn,moreFunctions:gi,closeSummaryPopup:yi}),pt=ft.isSideBySide,gt=ft.isArrowVisible,ht=ft.setIsArrowVisible,mt=ft.isResizing,St=ft.setIsResizing,xt=ft.isSideBySideLoading,Rt=ft.activeSideBySideSection,bt=ft.scrollLock,yt=ft.sideBySideCacheRef,Ct=ft.isSideBySideRef,wt=ft.activeSideBySideRightSectionRef,Bt=ft.activeSideBySideSectionRef,_t=ft.sideBySideLineRef,It=ft.highlightedClauseRefs,Ft=ft.clearClauseHighlight,Tt=ft.resetSideBySide,Et=ft.activateSideBySide,At=u(Et);a(function(){At.current=Et},[Et]);var kt=G({maintainRelativeOrder:!!gn,proposedSections:qi,existingSections:Vi,activeSideBySideSection:Rt,connectedSections:Fn,resetSideBySide:Tt,setConnectedSections:Tn,setConnectedLines:kn,cachedConnectedPositions:Jn,svgContainerRef:Mn,isAnimatingRef:qn,animationTimerRef:Vn,calculateLinesRef:Yn,sectionLeftRefs:it,sectionRightRefs:tt,subSectionLeftRefs:ut,subSectionRightRefs:ct}),Dt=kt.expandedSections,Ot=kt.setExpandedSections,Pt=kt.expandedSubSections,jt=kt.setExpandedSubSections,Lt=kt.handleSubSectionToggle,Nt=kt.toggleSection,Mt=kt.forceExpandCrossWiredSections,Ht=function(){var e,n;if(null!=Rt){var i=null===(e=it.current[Rt])||void 0===e?void 0:e.current,t=null===(n=tt.current[Rt])||void 0===n?void 0:n.current,o=oi.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"})}}},zt=s(function(e){null==e||e.stopPropagation(),Pn(function(e){var n=!e;return n&&requestAnimationFrame(function(){Ht()}),n})},[Ht]);a(function(){an&&"off"!==Qi&&"0:0"!==Qi&&(yt.current=null,Jn.current=[],requestAnimationFrame(function(){var e;null===(e=Yn.current)||void 0===e||e.call(Yn)}))},[an,Qi]);var Wt=c(function(){var e=new Map,n=new Map,i=1;if(gn)qi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Vi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=qi.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(qi.length,Vi.length),o=0;o<t;o++){var r=qi[o],l=Vi[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}},[qi,Vi,gn]),Gt=Gi.analysis,qt=b(null===(_e=null===(Be=null==Gt?void 0:Gt.rule_difference_comparison)||void 0===Be?void 0:Be.summary)||void 0===_e?void 0:_e.overall_summary),Vt=!!qt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Kt=null!==(Ie=null==Ve?void 0:Ve.base_root_id)&&void 0!==Ie?Ie:"-1";null==Ve||Ve[Kt];var Jt=_n?null!==(Me=null!==(je=tn&&(null===(Pe=null==tn?void 0:tn[Kt])||void 0===Pe?void 0:Pe.evaluation_result))&&void 0!==je?je:null===(Ne=null===(Le=null==Ve?void 0:Ve.nodes)||void 0===Le?void 0:Le[Kt])||void 0===Ne?void 0:Ne.evaluation_result)&&void 0!==Me?Me:null:null!==(Oe=null!==(Ee=tn&&(null===(Te=null===(Fe=null==tn?void 0:tn[Kt])||void 0===Fe?void 0:Fe.evaluation_result)||void 0===Te?void 0:Te[0]))&&void 0!==Ee?Ee:null===(De=null===(ke=null===(Ae=null==Ve?void 0:Ve.nodes)||void 0===Ae?void 0:Ae[Kt])||void 0===ke?void 0:ke.evaluation_result)||void 0===De?void 0:De[0])&&void 0!==Oe?Oe:null,Yt=y(Jt),Xt=C(null!==(We=null===(ze=null===(He=null==Jt?void 0:Jt.evaluation_outputs)||void 0===He?void 0:He.metadata)||void 0===ze?void 0:ze.label_color)&&void 0!==We?We:D);if(sn){var $t=sn(Yt);$t&&(Xt=e(e({},Xt),{badgeBg:$t.bg,badgeText:$t.text,badgeBorder:$t.border}))}var Ut=u(Tt);a(function(){Ut.current=Tt},[Tt]);var Qt=u(Ii);a(function(){Qt.current=Ii},[Ii]);var Zt=s(function(e,n,i,t,o,r){return vr.current(e,n,i,t,o,r)},[]),eo=s(function(e,n,i,t,o){return pr.current(e,n,i,t,o)},[]),no=s(function(){return gr.current()},[]),io=s(function(e,n){return hr.current(e,n)},[]),to=s(function(e){return mr.current(e)},[]),oo=s(function(e){return Sr.current(e)},[]),ro=s(function(){return xr.current()},[]),lo=s(function(){var e,n;Ft(),null===(e=Ut.current)||void 0===e||e.call(Ut),Pn(!1),Tn(new Set),kn([]),Jn.current=[],Eo([]),ko(null),bi(O),null===(n=Qt.current)||void 0===n||n.call(Qt),requestAnimationFrame(function(){var e;null===(e=Yn.current)||void 0===e||e.call(Yn)})},[]),uo=u(lo);a(function(){uo.current=lo},[lo]),a(function(){$e&&uo.current()},[$e]);var co=c(function(){return{documents:null==Ve?void 0:Ve.documents,input_index_map:null==Ve?void 0:Ve.input_index_map}},[JSON.stringify(null==Ve?void 0:Ve.documents),JSON.stringify(null==Ve?void 0:Ve.input_index_map)]),ao=l(""),so=ao[0],vo=ao[1],fo=b(Di),po=u(Ve);a(function(){var e,n,i;po.current=Ve;var t=null===(e=null==Ve?void 0:Ve.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==Ve?void 0:Ve.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;vo(o)},[Ve]);var go=u(ei);a(function(){go.current=ei},[ei]);var ho=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=b(null==i?void 0:i.id)||b(null==t?void 0:t.id)||"",x=(S?null===(c=go.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},R=null!==(s=null===(a=at.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(B)))return u(l);var c=o.split(B)[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)}(),C=(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,w=null!==(m=null==Qe?void 0:Qe.isLoading)&&void 0!==m&&m,_=!0;if(zi){var I=null==y?void 0:y.deviation_highlights;if(I&&"object"==typeof I)_=Object.values(I).some(function(e){return Array.isArray(e)&&e.length>0});else _=!1}return{isLoading:w&&!C,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:x,anchorEl:n,sectionAnchorEl:R,badgeStyle:l||null,sectionIdx:o,docData:co,deviationData:y,isOrphan:!!r,hasGuidelineMatches:_}},[co,null==Qe?void 0:Qe.isLoading,zi]),mo=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),gi.open&&gi.sectionIdx===o)Fi();else{var u=e.currentTarget,c="left";(null===(l=oi.current)||void 0===l?void 0:l.contains(u))&&(c="right");Ft(),Ct.current&&Tt(),Tn(new Set),kn([]),Jn.current=[],Ii(),Ri.open?Jo():yi(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(B)){var r=o.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=rt.current[l])||void 0===e?void 0:e.current:null===(n=ot.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=rt.current[o])||void 0===i?void 0:i.current:null===(t=ot.current[o])||void 0===t?void 0:t.current}()||u;hi(ho(e,n,t,o,i,r))})}},[gi.open,gi.sectionIdx,Fi,yi,ho]),So=s(function(){var e=gi.sectionIdx;gi.isOrphan,Fi(),yi(),null!==e&&(Mt(e),Ft(),Ct.current&&Tt(),kn([]),Jn.current=[],zi&&null!==e&&Nn(Wo(e)),Tn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Yn.current&&Yn.current()},50))},[gi.sectionIdx,gi.isOrphan,Fi,yi,Tt]),xo=s(function(){var e=Gn.current;if(e){Gn.current=null;var n=qi.findIndex(function(n){return n.id===e}),i=Vi.findIndex(function(n){return n.id===e}),t=-1===n?w(qi,e):null,o=-1===i?w(Vi,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?(It.current.add(r),I(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(gn)-1!==r&&ai.current&&c(function(){return u(n,t,it,ut)},ai.current),-1!==l&&oi.current&&c(function(){return u(i,o,tt,ct)},oi.current);else{var a=ii.current;if(!a)return;c(function(){return-1!==r?u(n,t,it,ut):u(i,o,tt,ct)},a)}}},[qi,Vi,gn,it,tt,ut,ct,ai,oi,ii]),Ro=s(function(n){if(n){Ft(),Tt(),Tn(new Set),kn([]),Jn.current=[],yi(),Ii();var i=qi.findIndex(function(e){return e.id===n}),t=Vi.findIndex(function(e){return e.id===n}),o=-1===i?w(qi,n):null,r=-1===t?w(Vi,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;Gn.current=n,Ot(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=gn?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=gn?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),jt(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(){Gn.current===n&&bo.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[qi,Vi,gn,Ot,jt,Tt,yi,Ii]),bo=u(xo);a(function(){bo.current=xo},[xo]);var yo=u(null);a(function(){if(Ai){var e=Ti.fields.find(function(e){return e.analysisKey===Ai||e.key===Ai});if(e){var n=et.current[e.key]||nt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Ai,Ti.fields]);var Co=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Gt?void 0:Gt.rule_difference_comparison)||void 0===n?void 0:n.fields;if(!s||!s[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var d=s[e],v=(null==d?void 0:d.relation)||(null===(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}},[Gt]),wo=U({proposedSections:qi,existingSections:Vi,maintainRelativeOrder:gn,cognitiveMap:ei,deviationData:Qn,treeData:Ve,resolvedComparisonConfig:Ti,badgeStyleOverride:sn}),Bo=wo.getSectionCompareStyle,_o=wo.getSubSectionCompareStyle,Io=wo.getDeviationStyleByKey,Fo=Z({containerRef:Hn,leftContainerRef:ai,rightContainerRef:oi,svgContainerRef:Mn,pathRefs:Kn,leftHeaderRef:zn,rightHeaderRef:Wn,proposedSections:qi,existingSections:Vi,visibleFields:Ki,leftRefs:et,rightRefs:nt,sectionLeftRefs:it,sectionRightRefs:tt,subSectionLeftRefs:ut,subSectionRightRefs:ct,lhsBadgeRefs:ot,rhsBadgeRefs:rt,sectionRowRefs:at,expandedSections:Dt,expandedSubSections:Pt,connectedSections:Fn,isSideBySide:pt,activeSideBySideSection:Rt,maintainRelativeOrder:gn,isGuidelineMode:zi,cognitiveMap:ei,getSectionCompareStyle:Bo,getSubSectionCompareStyle:_o,getDeviationStyleByKey:Io,isArrowVisible:gt,isAnimatingRef:qn,isSideBySideRef:Ct,sideBySideCacheRef:yt,sideBySideLineRef:_t,activeSideBySideSectionRef:Bt,activeSideBySideRightSectionRef:wt,connectedLines:An,setConnectedLines:kn,cachedConnectedPositions:Jn,calculateLinesRef:Yn,resizeTimerRef:Xn,scrollLock:bt,scrollSyncLocked:On,handleResizeRef:$n,activeProposed:Wi,existingRule:Gi,analysisData:Gt,pendingScrollTargetRef:si,pendingScrollCallbackRef:di,resolvedComparisonConfig:Ti,getFieldData:Co}),To=Fo.lines,Eo=Fo.setLines,Ao=Fo.overallConnector,ko=Fo.setOverallConnector,Do=Fo.svgDimensions,Oo=Fo.handleColumnScroll;a(function(){Ri.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Yn.current)||void 0===e||e.call(Yn)})})},[Ri.anchorEl,On]);var Po=s(function(){Ft(),Pn(!1),Ot({}),jt({}),Tt(),Tn(new Set),kn([]),Jn.current=[],yi(),Ii(),Fi(),requestAnimationFrame(function(){Yn.current&&Yn.current()})},[Ot,jt,Tt,yi,Ii,Fi]);a(function(){pt||0!==Fn.size||Pn(!1)},[pt,Fn]);var jo=c(function(){return Object.values(Dt).some(Boolean)||Object.values(Pt).some(Boolean)},[Dt,Pt]),Lo=u(null),No=u(0),Mo=u(0),Ho=u(0),zo=Q({timerRef:Lo,ruleComponentRef:ti,scrollContainerRef:ii,containerRef:Hn,maintainRelativeOrder:gn,proposedSections:qi,existingSections:Vi,isSideBySideRef:Ct,activeSideBySideSectionRef:Bt,activeSideBySideRightSectionRef:wt,sectionRowRefs:at,sectionRightRowRefs:lt,sectionLeftRefs:it,sectionRightRefs:tt,subSectionLeftRefs:ut,subSectionRightRefs:ct,lhsBadgeRefs:ot,rhsBadgeRefs:rt,leftContainerRef:ai,rightContainerRef:oi,calculateLinesRef:Yn,handleResizeRef:$n,setIsResizing:St,setIsArrowVisible:ht,sideBySideCacheRef:yt,cachedConnectedPositions:Jn}).handleResize;a(function(){$n.current=zo},[zo,$n]),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 ti.current&&o.push(e(ti.current,No,n,function(){return $n.current()},function(){})),ii.current&&o.push(e(ii.current,Mo,i,function(){return $n.current()},function(){return Yn.current()})),Hn.current&&o.push(e(Hn.current,Ho,t,function(){return $n.current()},function(){return Yn.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=pt},[pt]),a(function(){Bt.current=Rt},[Rt]);var Wo=s(function(e){var n,i,t,o,r,l="",u="0";if("number"==typeof e)l=(null===(n=qi[e])||void 0===n?void 0:n.nodeId)||(null===(i=qi[e])||void 0===i?void 0:i.id)||"";else{var c=String(e).split(B);l=c[0],u=c[1]||"0"}var a=null===(t=null==Qn?void 0:Qn[l])||void 0===t?void 0:t.evaluation_result,s=Array.isArray(a)?a[parseInt(u,10)]:null==a?void 0:a[u];return!1===(null===(r=null===(o=null==s?void 0:s.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)&&le(s)?1:0},[qi,Qn]),Go=s(function(){Tt(),Tn(new Set),kn([]),Jn.current=[]},[Tt]),qo=s(function(e,n){n!==Ln&&(Go(),Nn(n))},[Ln,Go]);a(function(){Zn||0===Ln||(Go(),Nn(0))},[Ln,Zn,Go]);var Vo=s(function(e){var n,i,t=ai.current,o=oi.current,r=re(o);if(o){var l="string"==typeof e&&e.includes(B),u=e;if(l){var c=e.split(B);c.length>=2&&(u="".concat(c[0]).concat(B).concat(c[1]))}var a=(null===(n=ot.current[u])||void 0===n?void 0:n.current)||(null===(i=ot.current[e])||void 0===i?void 0:i.current);if(r.length>0&&a&&t&&o){var s=r[0];ui.current&&(ui.current.style.height="0px"),ri.current&&(ri.current.style.height="0px"),ci.current&&(ci.current.style.height="0px"),li.current&&(li.current.style.height="0px"),requestAnimationFrame(function(){var e=a.getBoundingClientRect(),n=s.getBoundingClientRect(),i=t.getBoundingClientRect(),r=o.getBoundingClientRect(),l=t.scrollTop+(e.top-i.top)+e.height/2,u=o.scrollTop+(n.top-r.top)+n.height/2,c=l-i.height/2,d=Math.max(0,c),v=t.scrollHeight-t.clientHeight,f=d>v?d-v:0,p=i.top+l-d,g=r.top+u-p,h=0;g<0&&(h=Math.abs(g),g=0);var m=o.scrollHeight-o.clientHeight+h,S=g>m?g-m:0;ci.current&&(ci.current.style.height="".concat(f,"px")),ri.current&&(ri.current.style.height="".concat(h,"px")),li.current&&(li.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){t.scrollTo({top:d,behavior:"smooth"}),o.scrollTo({top:g,behavior:"smooth"}),Yn.current&&setTimeout(function(){return Yn.current()},50)})})}}},[B]),Ko=s(function(){var e,n=gi.sectionIdx,i=gi.isOrphan;if(yi(),null!=n){var t="left";gi.anchorEl&&(null===(e=oi.current)||void 0===e?void 0:e.contains(gi.anchorEl))&&(t="right"),Mt(n),zi&&(Nn(Wo(n)),Tn(new Set([n]))),Et(n,i,{sourceSide:t,onReady:function(){zi&&setTimeout(function(){return Vo(String(n))},150)}})}},[Et,gi.isOrphan,gi.sectionIdx,gi.anchorEl,yi,Mt,zi,Vo,Wo]),Jo=s(function(){yi(),Tt(),Tn(new Set),kn([]),Jn.current=[]},[yi,Tt]),Yo=null!==gi.sectionIdx&&Fn.has(gi.sectionIdx),Xo=q({proposedSections:qi,existingSections:Vi,parentDeviationRecord:Ji,expandedSections:Dt,maintainRelativeOrder:!!gn,scrollContainerRef:ii,leftContainerRef:ai,rightContainerRef:oi,lhsBadgeRefs:ot,rhsBadgeRefs:rt}),$o=Xo.showDeviationNavigation,Uo=Xo.showOpenNodeRef,Qo=Xo.adjustScrollForPopup,Zo=s(function(e,n,i,t,o){var r,l="string"==typeof t?b(t).trim():b(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;Ii();var c="left";(null===(r=oi.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(B)){var r=n.split(B),l="".concat(r[0]).concat(B).concat(r[1]);return"right"===c?null===(e=rt.current[l])||void 0===e?void 0:e.current:null===(i=ot.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=rt.current[n])||void 0===t?void 0:t.current:null===(o=ot.current[n])||void 0===o?void 0:o.current};if(i&&!zi)return Tt(),Tn(new Set),kn([]),Jn.current=[],void(l&&(Mt(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));bi({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Mt(n),zi&&(Nn(Wo(n)),Tn(new Set([n]))),l?setTimeout(function(){Et(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,i,r,l=a()||u;if(zi)setTimeout(function(){return Vo(n)},150);else if(l){var c=l.getBoundingClientRect();if(c.top>.8*window.innerHeight||c.top<100){var s=c.top-window.innerHeight/2;gn?(null===(e=ai.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(i=oi.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})):null===(r=ii.current)||void 0===r||r.scrollBy({top:s,behavior:"smooth"})}}bi({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){Et(n,i,{toggleIfSame:!1,sourceSide:c}),zi&&setTimeout(function(){return Vo(n)},150)},350)},[Et,Ii,bi,Tt,Mt,zi,gn,Vo,Qn]),er=c(function(){var e;if(!on)return null;var n=null===(e=null==on?void 0:on.id)||void 0===e?void 0:e.split(":")[0];for(var i in Ji){if((Ji[i]||[]).some(function(e){return e.id===n}))return i}return null},[on,Ji]),nr=u({id:null,triggerMs:null}),ir=u(null);a(function(){if(null==on?void 0:on.id){var o=Number(on.trigger),r=nr.current;if((null==r?void 0:r.id)!==on.id||(null==r?void 0:r.triggerMs)!==o){if(on.id.includes(":")&&/:\d+$/.test(on.id)){var l=on.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0",s="".concat(on.id,":").concat(o);ir.current!==s&&(yi(),Ii(),Tt(),Tn(new Set),kn([]),Jn.current=[],ir.current=s);var d=!1,v=0,f=null,p=null,g=!1,h=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))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;if(!d){var s=function(){nr.current={id:on.id,triggerMs:o}},S=null,x=null;for(var R in Ji){var b=Ji[R].find(function(e){var n;return e.id===u||e.nodeId===u||e.contentId===u||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===u});if(b){S=R,x=b;break}}if(x&&S){var y=Array.from(new Set([u,x.id,x.nodeId,x.contentId,null===(r=x.evaluationResult)||void 0===r?void 0:r.nodeId].filter(Boolean))),C=qi.findIndex(function(e){return e.id===S}),w=Vi.findIndex(function(e){return e.id===S}),_=-1===C&&-1!==w,I=h(qi,y),E=h(Vi,y);if(I&&!E&&!_){var A=I.split("-"),k=Number(A[0]);if(gn){var D=null===(c=null===(l=qi[k])||void 0===l?void 0:l.refIndexes)||void 0===c?void 0:c[0],O=Vi.findIndex(function(e){return e.selfIndex===D});-1!==O&&(k=O)}E=n([k],A.slice(1),!0).join("-")}if(I||E){var P=I?Number(I.split("-")[0]):C,j=E?Number(E.split("-")[0]):w,L=j>=0?j:E?Number(E.split("-")[0]):-1,N=qi[P],M=Vi[L],H=N&&!N.title&&!N.content,z=M&&!M.title&&!M.content,W=_||(!I&&!!E||H&&!z);if(W){if(!(gn?!!fr.current["right-".concat(j)]:!!fr.current[String(j)])&&j>=0)return Nt(j,"right"),void(f=setTimeout(m,200))}else if(!(gn?!!fr.current["left-".concat(P)]:!!fr.current[String(P)])&&P>=0)return Nt(P,"left"),void(f=setTimeout(m,200));var G=I||"",q=E||"",V=y.map(function(e){return"".concat(e).concat(B).concat(a)}),K=V[0],J=function(){for(var e,n,i=0,t=V;i<t.length;i++){var o=t[i],r=(null===(e=ot.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=rt.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:K,left:null,right:null}},Y=function(e){return"".concat(e).concat(B).concat(G).concat(B).concat(q)};if(!g){Mt(Y(K)),g=!0,v=0;var X=function(){var e=J(),n=e.left,i=e.right;return W||!n&&!!i?i:n};return null==p||p(),void(f=setTimeout(function(){var e,n,i,t,o,r,l,u;d||(e=X,n=function(){d||(p=null,m())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!d)if(performance.now()-l>3e3)n();else{var c=e();if(c&&0!==c.getBoundingClientRect().height){var a=c.getBoundingClientRect(),s=a.top,v=a.height,f=null!==o&&Math.abs(s-o)<.5,p=null!==r&&Math.abs(v-r)<.5;if(f&&p){if(++t>=5)return void n()}else t=0;o=s,r=v,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),p=function(){return cancelAnimationFrame(i)})},300))}var $=J(),U=$.refId,Q=$.left,Z=$.right,ee=Y(U);if(Q||Z){var ne=W||!Q&&!!Z,ie=ne?Z:Q,te=gn?ne?oi.current:ai.current:ii.current;if(ie&&te){var oe=ie.getBoundingClientRect();if(0!==oe.height){var re=te.getBoundingClientRect(),le=oe.top-re.top+te.scrollTop-re.height/2+oe.height/2,ue=(null==I?void 0:I.includes("-"))||(null==E?void 0:E.includes("-")),ce=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,v,f,p;return t(this,function(t){switch(t.label){case 0:return d?[2]:(s(),n=ie instanceof Element?window.getComputedStyle(ie).color:"",[Q,Z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[Q,Z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=x.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||x,o=(null===(v=x.evaluationResult)||void 0===v?void 0:v.evaluation_outputs)||x.evaluation_outputs,!!Q&&!!Z||zi?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},gn?[4,Promise.all([ai.current?l(T(ai.current),600):Promise.resolve(),oi.current?l(T(oi.current),600):Promise.resolve()])]:[3,2]):(r=ne?(null===(f=rt.current[ue?U:j])||void 0===f?void 0:f.current)||Z:(null===(p=ot.current[ue?U:P])||void 0===p?void 0:p.current)||Q,Qo(r,function(){bi({open:!0,anchorEl:r,displayImpact:on.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==rn||rn(),[2]));case 1:t.sent(),t.label=2;case 2:return zi&&(Nn(Wo(ee)),Tn(new Set([ee]))),At.current(ee,!1,{toggleIfSame:!1,sourceSide:_?"right":"left",onReady:function(){var n,t,o,r;s();var l=ne?(null===(n=rt.current[U])||void 0===n?void 0:n.current)||Z:(null===(t=ot.current[U])||void 0===t?void 0:t.current)||Q;if(zi)setTimeout(function(){return Vo(ee)},150);else{var u=(null===(o=ot.current[U])||void 0===o?void 0:o.current)||Q,c=(null===(r=rt.current[U])||void 0===r?void 0:r.current)||Z;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"}))}bi({open:!0,anchorEl:l,displayImpact:on.displayImpact,summary:e({},i)}),null==rn||rn()}}),[2]}})})};Math.abs(te.scrollTop-le)<=2?ce():F(te,le,ce)}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}};return f=setTimeout(m,100),function(){d=!0,f&&clearTimeout(f),null==p||p()}}nr.current={id:on.id,triggerMs:o},Ro(on.id);var S=qi.findIndex(function(e){return e.id===on.id}),x=Vi.findIndex(function(e){return e.id===on.id});-1===S&&-1===x||setTimeout(function(){var e=-1!==S?S:x,n=-1===S;zi&&Nn(Wo(e)),Tn(new Set([e])),At.current(e,n,{sourceSide:n?"right":"left",onReady:function(){zi&&setTimeout(function(){return Vo(String(e))},150)}})},400)}}},[null==on?void 0:on.id,null==on?void 0:on.trigger,null==on?void 0:on.displayImpact,Ji,qi,Vi,gn,bi,Ro,zi,Wo,Vo]),a(function(){var n,i,t;if(Ri.open){var o=Ri.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(ot.current)||r(rt.current);if(l){var u=(null===(i=rt.current[l])||void 0===i?void 0:i.current)||(null===(t=ot.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&bi(function(n){return e(e({},n),{anchorEl:u})})}}}},[Ri.open,Ri.anchorEl,On,Fn,Dt]);var tr=fi.open,or=fi.sectionIdx,rr=fi.isOrphan,lr=fi.badgeStyle,ur=fi.anchorEl,cr=fi.sectionAnchorEl;a(function(){var n;if(Qe.isStreamingEnabled&&tr&&null!=or&&or!==Kt){var i="string"==typeof or?or.split(B)[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(qi,i):null,r=i&&"string"==typeof i?t(Vi,i):null,l="number"==typeof or?qi[or]||null:o||i&&((null===(n=null==Ve?void 0:Ve.nodes)||void 0===n?void 0:n[i])||(null==Ve?void 0:Ve[i]))||null,u="number"==typeof or?Vi[or]||null:r,c=ho(ur,l,u,or,rr,lr);pi(function(n){return n.open?b(n.cognitiveData)===b(c.cognitiveData)&&b(n.deviationData)===b(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})}},[tr,or,rr,lr,ur,cr,qi,Vi,ho]);var ar=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,d=e.rhsOrphanVisualIndexes;return o(K,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s,rhsOrphanVisualIndexes:d})},[]),sr=c(function(){return qi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&gn?null:o(J,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[qi,gn]),dr=c(function(){return Vi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&gn?null:o(Y,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Vi,gn]),vr=u(mo);a(function(){vr.current=mo},[mo]);var fr=u(Dt);a(function(){fr.current=Dt},[Dt]);var pr=u(Zo);a(function(){pr.current=Zo},[Zo]);var gr=u(Jo);a(function(){gr.current=Jo},[Jo]);var hr=u(Nt);a(function(){hr.current=Nt},[Nt]);var mr=u(Lt);a(function(){mr.current=Lt},[Lt]);var Sr=u(ar);a(function(){Sr.current=ar},[ar]);var xr=u(Tt);a(function(){xr.current=Tt},[Tt]);var Rr=c(function(){return{isGuidelineMode:zi,maintainRelativeOrder:!!gn,showDeviationBadges:xn,isProposingFix:un,proposingFixNodeId:cn,isRedlineFlow:an,isSideBySide:pt,activeSideBySideSection:Rt,scrollSyncLocked:On,toggleScrollSyncLocked:zt,summaryPopupAnchorEl:Ri.anchorEl,connectedSections:Fn,proposedSections:qi,existingSections:Vi,deviationNumberRegistry:Yi,deviationParentRegistry:Xi,treeData:Ve,displayConfig:Qe,resolvedMarkdownStyles:ni,unifiedNumbering:Wt,expandedSections:Dt,expandedSubSections:Pt,setExpandedSubSections:jt,getSectionCompareStyle:Bo,getSubSectionCompareStyle:_o,getBadgeRef:vt,getSectionRowRef:st,getSubSectionRef:dt,sectionLeftRefs:it,sectionRightRefs:tt,sectionRowRefs:at,sectionRightRowRefs:lt,subSectionLeftRefs:ut,subSectionRightRefs:ct,lhsBadgeRefs:ot,rhsBadgeRefs:rt,openMoreFunctionsPopup:Zt,handleOpenSummaryPopup:eo,openSummaryPopup:eo,handleCloseSummaryPopup:no,toggleSection:io,handleSubSectionToggle:to,renderSubSectionAccordion:oo,resetSideBySide:ro,setConnectedSections:Tn,setConnectedLines:kn,cachedConnectedPositions:Jn,showDeviationNavigation:$o,showOpenNodeRef:Uo,deviationNodeIdToView:null==on?void 0:on.id,deviationTargetParentId:er,guidelinesData:dn,gptWebCitationConfig:fn}},[zi,gn,xn,un,cn,an,pt,Rt,On,zt,Ri.anchorEl,Fn,qi,Vi,Yi,Qe,ni,Wt,Dt,Pt,jt,Bo,_o,vt,st,dt,$o,Uo,on,er,dn,fn]),br=b(fi.sectionTitle||ji||Oi),yr=b(zi?Ni||Mi||fi.refSectionTitle:fi.refSectionTitle||Ni||Mi);return o($,e({value:Rr},{children:r(d,e({ref:ti,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[bn&&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(N,{})})),Ri.open&&o(X,{open:Ri.open,anchorEl:Ri.anchorEl,containerEl:yo.current,clipTopEl:zn.current,scrollContainerEl:ii.current,onClose:Jo,summary:Ri.summary,displayImpact:Ri.displayImpact,isScrollLocked:On}),o(L,{open:gi.open,anchorEl:gi.anchorEl,maintainRelativeOrder:!!gn,sectionTitle:gi.sectionTitle,referenceSectionTitle:gi.refSectionTitle,onClose:Fi,onOpenCognitiveCompare:Bi,onOpenSideBySide:Ko,onConnect:So,isConnected:Yo,isOrphan:!zi&&!!gi.isOrphan,isGuidelineMode:zi,hasGuidelineMatches:gi.hasGuidelineMatches}),fi.open&&o(j,{open:fi.open,popupRef:wi,position:mi,popupConfig:en,onClose:function(){Si(null),pi(function(n){return e(e({},n),{open:!1})}),Ci(null)},markdownStyles:Xe,sectionTitle:br,referenceSectionTitle:yr,cognitiveData:fi.cognitiveData,anchorEl:fi.anchorEl,sectionAnchorEl:fi.sectionAnchorEl,scrollContainerEl:ii.current,badgeStyle:fi.badgeStyle,docData:fi.docData,deviationData:fi.deviationData,isLoading:fi.isLoading}),o(v,e({open:!!wn,autoHideDuration:8e3,onClose:function(){return Bn(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return Bn(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:wn}))})),o(V,{componentHeaderText:qe,displayConfig:Qe,maintainRelativeOrder:gn,onCollapseAll:Po,showCollapseAll:jo,onToggleView:function(e){yn(!0),setTimeout(function(){hn(!e),null==Ze||Ze(!e),Pn(!1),Tt(),yi(),Tn(new Set),kn([]),Jn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){yn(!1)},600)})})},50)}}),o(d,e({ref:ii,onScroll:Oo,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:gn?"visible":"auto",borderTop:qt&&Vt?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},gn?{flex:1}:{})},{children:r(d,e({ref:Hn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},gn?{flex:1,overflow:"visible"}:{})},{children:[o(ne,{svgContainerRef:Mn,svgDimensions:Do,isResizing:mt,overallConnector:Ao,rootDeviationStyle:Xt,lines:To,isSideBySide:pt,activeSideBySideSection:Rt,isArrowVisible:gt,maintainRelativeOrder:gn,proposedSections:qi,existingSections:Vi,cognitivePopup:fi,activeBadgeId:xi,closeCognitivePopup:Ii,setActiveBadgeId:Ci,openCognitivePopupFromState:_i,buildSectionPopupState:ho,connectedLines:An,isGuidelineMode:zi,pathRefs:Kn}),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)"},gn?{flex:1,overflow:"visible"}:{})},{children:[o(d,e({ref:zn,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:Oi,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:Oi}))}))})),r(d,e({ref:ai,onScroll:Oo,sx:e({p:"12px",display:"flex",flexDirection:"column"},gn?{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:ui,style:{width:"100%",height:"0px",flexShrink:0}}),Ui&&sr,o("div",{ref:ci,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:yo,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(),fi.open&&xi===Kt?Ii():(Ci(Kt),_i(ho(n.currentTarget,{title:so,content:"",evaluationResult:Jt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},{title:fo,content:""},Kt,!0,e(e({},Xt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Xt.badgeBg,color:Xt.badgeText,border:"1px solid ".concat(Xt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Yt?Yt:o(M,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(x,{})})),o(S,{size:11,style:{transform:fi.open&&xi===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},gn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[xt&&o(R,{sections:11}),o(d,e({ref:Wn,sx:e({p:"8px",bgcolor:zi?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center"},gn?e({maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0},zi?{"&::-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:zi?r(h,e({value:Ln,onChange:qo,variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[o(m,{label:o(p,e({title:Mi,placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),Zn&&o(m,{label:o(p,e({title:"Web & GPT Sources",placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):o(p,e({title:Mi,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:Mi}))}))})),r(d,e({ref:oi,onScroll:Oo,sx:e({p:zi?"0px":"12px",display:"flex",flexDirection:"column"},gn?e(e({maxHeight:"calc(100vh - 250px)"},!zi&&{flex:1}),{overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}):{})},{children:[o("div",{ref:ri,style:{width:"100%",height:"0px",flexShrink:0}}),zi?dn?0!==Ln&&Zn?o(te,{deviationData:tn,connectedSections:Fn,proposedSections:qi}):o(ie,{guidelinesData:dn,deviationData:tn,connectedSections:Fn,proposedSections:qi}):o(oe,{}):Ui&&dr,o("div",{ref:li,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{ue 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,Tabs as h,Tab as m}from"@mui/material";import{ChevronDown as S}from"lucide-react";import{ButtonCognitiveIcon as x}from"../../assests/svg/ButtonCognitiveIcon.js";import R from"./OverlayComponent.js";import{safeStringify as y,extractDeviationScore as b,generateColorPalette as C,findKeyPathByNodeId as w,DEVIATION_BADGE_SEPARATOR as _,hasMeaningfulRedlineTags as B,scrollAndHighlightClause as I,scrollAndWait as F,waitForScrollIdle as T}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as E,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{DEFAULT_DEVIAION_COLOR as O,EMPTY_SUMMARY_POPUP_STATE as k,DEFAULT_COMPONENT_HEADER_TEXT as P}from"./CognitiveCompareConstants.js";import j from"./CognitivePopup.js";import L from"./MoreFunctionsPopup.js";import N from"./LoaderComponent.js";import M from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as H}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as G}from"./hooks/useSectionRefs.js";import{useAccordionState as W}from"./hooks/useAccordionState.js";import{useDeviationNavigation as q}from"./hooks/useDeviationNavigation.js";import V from"./components/CompareHeader.js";import K from"./components/SubSectionAccordion.js";import J from"./components/LHSSectionRow.js";import Y from"./components/RHSSectionRow.js";import X from"./components/CognitiveSummaryPopup.js";import{CompareContextProvider as $}from"./CompareContext.js";import{useStyleHelpers as U}from"./hooks/useStyles.js";import{useResizeHandler as Q}from"./hooks/useResizeHandler.js";import{useLinesCalculator as Z}from"./hooks/useLinesCalculator.js";import{useSideBySide as ee}from"./hooks/useSideBySide.js";import ne from"./components/SvgConnectors.js";import ie from"./Guidelines/components/GuidelinePanel.js";import te from"./Guidelines/components/WebGptPanel.js";import{GuidelineSkeleton as oe}from"./components/GuidelineSkeletonLoader.js";import{getVisibleGuidelineTargets as re}from"./Guidelines/utils/guidelineTargets.js";import{hasGptCitationObjects as le}from"./Guidelines/utils/hasGptCitationObjects.js";var ue=function(ue){var ce,ae,se,de,ve,fe,pe,ge,he,me,Se,xe,Re,ye,be,Ce,we,_e,Be,Ie,Fe,Te,Ee,Ae,De,Oe,ke,Pe,je,Le,Ne,Me,He,ze,Ge,We=ue.componentHeaderText,qe=void 0===We?P:We,Ve=ue.treeData,Ke=ue.comparisonConfig,Je=ue.leftColumnTitleText,Ye=ue.rightColumnTitleText,Xe=ue.markdownStyles,$e=ue.resetTrigger,Ue=ue.displayConfig,Qe=void 0===Ue?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1}:Ue,Ze=ue.onMaintainRelativeOrderChange,en=ue.popupConfig,nn=ue.deviationData,tn=void 0===nn?{}:nn,on=ue.deviationNodeIdToView,rn=ue.resetDeviationNodeId,ln=ue.isProposingFix,un=void 0!==ln&&ln,cn=ue.proposingFixNodeId,an=ue.isRedlineFlow,sn=ue.badgeStyleOverride,dn=ue.guidelinesData,vn=ue.isGuidelineMode,fn=ue.gptWebCitationConfig,pn=l(Qe.maintainRelativeOrder),gn=pn[0],hn=pn[1],mn=null!==(ce=null==Qe?void 0:Qe.expandLevels)&&void 0!==ce?ce:0,Sn=!!(null==Qe?void 0:Qe.expandAllSections),xn=!!gn||!!(null==Qe?void 0:Qe.showDeviationBadges),Rn=l(!1),yn=Rn[0],bn=Rn[1],Cn=l(null),wn=Cn[0],_n=Cn[1],Bn=l(null===(se=null!==(ae=null==Ve?void 0:Ve.newEvaluationResult)&&void 0!==ae?ae:null==Qe?void 0:Qe.enableDeviationSchemaBackwardCompatibility)||void 0===se||se)[0],In=l(new Set),Fn=In[0],Tn=In[1],En=l([]),An=En[0],Dn=En[1],On=l(!1),kn=On[0],Pn=On[1],jn=l(0),Ln=jn[0],Nn=jn[1],Mn=u(null),Hn=u(null),zn=u(null),Gn=u(null),Wn=u(null),qn=u(!1),Vn=u(null),Kn=u({}),Jn=u([]),Yn=u(function(){}),Xn=u(null),$n=u(function(){}),Un=c(function(){return JSON.stringify(tn||{})},[JSON.stringify(tn)]),Qn=c(function(){return tn||{}},[Un]),Zn=c(function(){return le(Qn)},[Qn]),ei=c(function(){return(null==Ve?void 0:Ve.cognitive_decisioning)||{}},[Ve]),ni=c(function(){return e(e({},E),Xe)},[Xe]),ii=u(null),ti=u(null),oi=u(null),ri=u(null),li=u(null),ui=u(null),ci=u(null),ai=u(null),si=u(null),di=u(null),vi=z(ii),fi=vi.cognitivePopup,pi=vi.setCognitivePopup,gi=vi.moreFunctions,hi=vi.setMoreFunctions,mi=vi.position,Si=vi.setPosition,xi=vi.activeBadgeId,Ri=vi.summaryPopup,yi=vi.setSummaryPopup,bi=vi.closeSummaryPopup,Ci=vi.setActiveBadgeId,wi=vi.popupRef,_i=vi.handleOpenCognitiveCompare,Bi=vi.openCognitivePopupFromState,Ii=vi.closeCognitivePopup,Fi=vi.closeMoreFunctionsPopup,Ti=c(function(){var e,n,i,t,o,r,l;return{fields:null!==(e=null==Ke?void 0:Ke.fields)&&void 0!==e?e:A,thresholds:{high:null!==(i=null===(n=null==Ke?void 0:Ke.thresholds)||void 0===n?void 0:n.high)&&void 0!==i?i:D.thresholds.high,medium:null!==(o=null===(t=null==Ke?void 0:Ke.thresholds)||void 0===t?void 0:t.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(l=null===(r=null==Ke?void 0:Ke.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:D.thresholds.exact}}},[Ke]),Ei=l(null),Ai=Ei[0];Ei[1];var Di=null===(fe=null===(de=null==Ve?void 0:Ve.documents)||void 0===de?void 0:de[null===(ve=null==Ve?void 0:Ve.input_index_map)||void 0===ve?void 0:ve[0]])||void 0===fe?void 0:fe.title,Oi=null===(he=null===(pe=null==Ve?void 0:Ve.documents)||void 0===pe?void 0:pe[null===(ge=null==Ve?void 0:Ve.input_index_map)||void 0===ge?void 0:ge[1]])||void 0===he?void 0:he.title,ki=y(Je||Di||"Uploaded Contract"),Pi=null===(Re=null===(xe=null===(me=null==Ve?void 0:Ve.documents)||void 0===me?void 0:me[null===(Se=null==Ve?void 0:Ve.input_index_map)||void 0===Se?void 0:Se[0]])||void 0===xe?void 0:xe.metadata)||void 0===Re?void 0:Re.file_name,ji=y(Pi),Li=null===(we=null===(Ce=null===(ye=null==Ve?void 0:Ve.documents)||void 0===ye?void 0:ye[null===(be=null==Ve?void 0:Ve.input_index_map)||void 0===be?void 0:be[1]])||void 0===Ce?void 0:Ce.metadata)||void 0===we?void 0:we.file_name,Ni=y(Li),Mi=y(Ye||Oi||"Reference Template"),Hi=H(Ve,gn,Qn,Ti,Bn,dn,vn),zi=Hi.isGuidelineMode,Gi=Hi.activeProposed,Wi=Hi.existingRule,qi=Hi.proposedSections,Vi=Hi.existingSections,Ki=Hi.visibleFields,Ji=Hi.parentDeviationRecord,Yi=Hi.deviationNumberRegistry,Xi=Hi.deviationParentRegistry,$i=Hi.parseError;a(function(){$i&&_n("Failed to load comparison: ".concat($i))},[$i]);var Ui=qi.length>0||Vi.length>0,Qi=c(function(){if(!an)return"off";var e=0,n=0,i=function(t){Array.isArray(t)&&t.forEach(function(t){var o,r=(null==t?void 0:t.content)||"";B(r)&&(e+=1,n+=String(r).length),(null===(o=null==t?void 0:t.subsections)||void 0===o?void 0:o.length)&&i(t.subsections)})};return i(qi),i(Vi),"".concat(e,":").concat(n)},[an,qi,Vi]);a(function(){if(qi.length||Vi.length)if(Sn){var e={},n={},i=function(i,t){i.forEach(function(i,o){var r,l=gn?"".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(qi,"left"),i(Vi,"right"),kt(e),jt(n)}else if(mn>0){var t={},o={},r=function(e,n,i){e.forEach(function(e,r){var l;if(i>=1){var u=gn?"".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(qi,"left",mn),r(Vi,"right",mn),kt(t),jt(o)}},[Sn,mn,qi,Vi,gn]);var Zi=G(Ki.map(function(e){return e.key}),Math.max(qi.length,Vi.length)),et=Zi.leftRefs,nt=Zi.rightRefs,it=Zi.sectionLeftRefs,tt=Zi.sectionRightRefs,ot=Zi.lhsBadgeRefs,rt=Zi.rhsBadgeRefs,lt=Zi.sectionRightRowRefs,ut=Zi.subSectionLeftRefs,ct=Zi.subSectionRightRefs,at=Zi.sectionRowRefs,st=Zi.getSectionRowRef,dt=Zi.getSubSectionRef,vt=Zi.getBadgeRef,ft=ee({isGuidelineMode:zi,maintainRelativeOrder:gn,proposedSections:qi,existingSections:Vi,leftContainerRef:ai,rightContainerRef:oi,scrollContainerRef:ii,sectionLeftRefs:it,sectionRightRefs:tt,subSectionLeftRefs:ut,subSectionRightRefs:ct,lhsBadgeRefs:ot,rhsBadgeRefs:rt,sectionRowRefs:at,sectionRightRowRefs:lt,rhsTopSpacerRef:ri,rhsBottomSpacerRef:li,lhsTopSpacerRef:ui,lhsBottomSpacerRef:ci,calculateLinesRef:Yn,setConnectedSections:Tn,setConnectedLines:Dn,cachedConnectedPositions:Jn,closeMoreFunctionsPopup:Fi,setErrorToast:_n,moreFunctions:gi,closeSummaryPopup:bi}),pt=ft.isSideBySide,gt=ft.isArrowVisible,ht=ft.setIsArrowVisible,mt=ft.isResizing,St=ft.setIsResizing,xt=ft.isSideBySideLoading,Rt=ft.activeSideBySideSection,yt=ft.scrollLock,bt=ft.sideBySideCacheRef,Ct=ft.isSideBySideRef,wt=ft.activeSideBySideRightSectionRef,_t=ft.activeSideBySideSectionRef,Bt=ft.sideBySideLineRef,It=ft.highlightedClauseRefs,Ft=ft.clearClauseHighlight,Tt=ft.resetSideBySide,Et=ft.activateSideBySide,At=u(Et);a(function(){At.current=Et},[Et]);var Dt=W({maintainRelativeOrder:!!gn,proposedSections:qi,existingSections:Vi,activeSideBySideSection:Rt,connectedSections:Fn,resetSideBySide:Tt,setConnectedSections:Tn,setConnectedLines:Dn,cachedConnectedPositions:Jn,svgContainerRef:Mn,isAnimatingRef:qn,animationTimerRef:Vn,calculateLinesRef:Yn,sectionLeftRefs:it,sectionRightRefs:tt,subSectionLeftRefs:ut,subSectionRightRefs:ct}),Ot=Dt.expandedSections,kt=Dt.setExpandedSections,Pt=Dt.expandedSubSections,jt=Dt.setExpandedSubSections,Lt=Dt.handleSubSectionToggle,Nt=Dt.toggleSection,Mt=Dt.forceExpandCrossWiredSections,Ht=function(){var e,n;if(null!=Rt){var i=null===(e=it.current[Rt])||void 0===e?void 0:e.current,t=null===(n=tt.current[Rt])||void 0===n?void 0:n.current,o=oi.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"})}}},zt=s(function(e){null==e||e.stopPropagation(),Pn(function(e){var n=!e;return n&&requestAnimationFrame(function(){Ht()}),n})},[Ht]);a(function(){an&&"off"!==Qi&&"0:0"!==Qi&&(bt.current=null,Jn.current=[],requestAnimationFrame(function(){var e;null===(e=Yn.current)||void 0===e||e.call(Yn)}))},[an,Qi]);var Gt=c(function(){var e=new Map,n=new Map,i=1;if(gn)qi.forEach(function(n){!n.title&&!n.content||n.id&&e.set(n.id,i++)}),Vi.forEach(function(t){if(t.id&&!(!t.title&&!t.content)){var o=qi.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(qi.length,Vi.length),o=0;o<t;o++){var r=qi[o],l=Vi[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}},[qi,Vi,gn]),Wt=Wi.analysis,qt=y(null===(Be=null===(_e=null==Wt?void 0:Wt.rule_difference_comparison)||void 0===_e?void 0:_e.summary)||void 0===Be?void 0:Be.overall_summary),Vt=!!qt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Kt=null!==(Ie=null==Ve?void 0:Ve.base_root_id)&&void 0!==Ie?Ie:"-1";null==Ve||Ve[Kt];var Jt=Bn?null!==(Me=null!==(je=tn&&(null===(Pe=null==tn?void 0:tn[Kt])||void 0===Pe?void 0:Pe.evaluation_result))&&void 0!==je?je:null===(Ne=null===(Le=null==Ve?void 0:Ve.nodes)||void 0===Le?void 0:Le[Kt])||void 0===Ne?void 0:Ne.evaluation_result)&&void 0!==Me?Me:null:null!==(ke=null!==(Ee=tn&&(null===(Te=null===(Fe=null==tn?void 0:tn[Kt])||void 0===Fe?void 0:Fe.evaluation_result)||void 0===Te?void 0:Te[0]))&&void 0!==Ee?Ee:null===(Oe=null===(De=null===(Ae=null==Ve?void 0:Ve.nodes)||void 0===Ae?void 0:Ae[Kt])||void 0===De?void 0:De.evaluation_result)||void 0===Oe?void 0:Oe[0])&&void 0!==ke?ke:null,Yt=b(Jt),Xt=C(null!==(Ge=null===(ze=null===(He=null==Jt?void 0:Jt.evaluation_outputs)||void 0===He?void 0:He.metadata)||void 0===ze?void 0:ze.label_color)&&void 0!==Ge?Ge:O);if(sn){var $t=sn(Yt);$t&&(Xt=e(e({},Xt),{badgeBg:$t.bg,badgeText:$t.text,badgeBorder:$t.border}))}var Ut=u(Tt);a(function(){Ut.current=Tt},[Tt]);var Qt=u(Ii);a(function(){Qt.current=Ii},[Ii]);var Zt=s(function(e,n,i,t,o,r){return vr.current(e,n,i,t,o,r)},[]),eo=s(function(e,n,i,t,o){return pr.current(e,n,i,t,o)},[]),no=s(function(){return gr.current()},[]),io=s(function(e,n){return hr.current(e,n)},[]),to=s(function(e){return mr.current(e)},[]),oo=s(function(e){return Sr.current(e)},[]),ro=s(function(){return xr.current()},[]),lo=s(function(){var e,n;Ft(),null===(e=Ut.current)||void 0===e||e.call(Ut),Pn(!1),Tn(new Set),Dn([]),Jn.current=[],Eo([]),Do(null),yi(k),null===(n=Qt.current)||void 0===n||n.call(Qt),requestAnimationFrame(function(){var e;null===(e=Yn.current)||void 0===e||e.call(Yn)})},[]),uo=u(lo);a(function(){uo.current=lo},[lo]),a(function(){$e&&uo.current()},[$e]);var co=c(function(){return{documents:null==Ve?void 0:Ve.documents,input_index_map:null==Ve?void 0:Ve.input_index_map}},[JSON.stringify(null==Ve?void 0:Ve.documents),JSON.stringify(null==Ve?void 0:Ve.input_index_map)]),ao=l(""),so=ao[0],vo=ao[1],fo=y(Oi),po=u(Ve);a(function(){var e,n,i;po.current=Ve;var t=null===(e=null==Ve?void 0:Ve.input_index_map)||void 0===e?void 0:e[0],o=null===(i=null===(n=null==Ve?void 0:Ve.documents)||void 0===n?void 0:n[t])||void 0===i?void 0:i.title;vo(o)},[Ve]);var go=u(ei);a(function(){go.current=ei},[ei]);var ho=s(function(n,i,t,o,r,l,u){var c,a,s,d,v,f,p,g,h,m,S=y(null==i?void 0:i.id)||y(null==t?void 0:t.id)||"",x=(S?null===(c=go.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},R=null!==(s=null===(a=at.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(_)))return u(l);var c=o.split(_)[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)}(),C=(null!==(f=null===(v=null===(d=null==b?void 0:b.cognitive_decisioning)||void 0===d?void 0:d.decisioning_factors)||void 0===v?void 0:v.length)&&void 0!==f?f:0)>0||(null!==(h=null===(g=null===(p=null==b?void 0:b.cognitive_decisioning)||void 0===p?void 0:p.gaps_in_decision)||void 0===g?void 0:g.length)&&void 0!==h?h:0)>0,w=null!==(m=null==Qe?void 0:Qe.isLoading)&&void 0!==m&&m,B=!0;if(zi){var I=null==b?void 0:b.deviation_highlights;if(I&&"object"==typeof I)B=Object.values(I).some(function(e){return Array.isArray(e)&&e.length>0});else B=!1}return{isLoading:w&&!C,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:x,anchorEl:n,sectionAnchorEl:R,badgeStyle:l||null,sectionIdx:o,docData:co,deviationData:b,isOrphan:!!r,hasGuidelineMatches:B}},[co,null==Qe?void 0:Qe.isLoading,zi]),mo=s(function(e,n,i,t,o,r){var l;if(e.stopPropagation(),gi.open&&gi.sectionIdx===o)Fi();else{var u=e.currentTarget,c="left";(null===(l=oi.current)||void 0===l?void 0:l.contains(u))&&(c="right");Ft(),Ct.current&&Tt(),Tn(new Set),Dn([]),Jn.current=[],Ii(),Ri.open?Jo():bi(),requestAnimationFrame(function(){var e=function(){var e,n,i,t;if("string"==typeof o&&o.includes(_)){var r=o.split(_),l="".concat(r[0]).concat(_).concat(r[1]);return"right"===c?null===(e=rt.current[l])||void 0===e?void 0:e.current:null===(n=ot.current[l])||void 0===n?void 0:n.current}return"right"===c?null===(i=rt.current[o])||void 0===i?void 0:i.current:null===(t=ot.current[o])||void 0===t?void 0:t.current}()||u;hi(ho(e,n,t,o,i,r))})}},[gi.open,gi.sectionIdx,Fi,bi,ho]),So=s(function(){var e=gi.sectionIdx;gi.isOrphan,Fi(),bi(),null!==e&&(Mt(e),Ft(),Ct.current&&Tt(),Dn([]),Jn.current=[],zi&&null!==e&&Nn(Go(e)),Tn(function(n){return n.has(e)?new Set:new Set([e])}),setTimeout(function(){Yn.current&&Yn.current()},50))},[gi.sectionIdx,gi.isOrphan,Fi,bi,Tt]),xo=s(function(){var e=Wn.current;if(e){Wn.current=null;var n=qi.findIndex(function(n){return n.id===e}),i=Vi.findIndex(function(n){return n.id===e}),t=-1===n?w(qi,e):null,o=-1===i?w(Vi,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?(It.current.add(r),I(r,n)):t++<i&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(gn)-1!==r&&ai.current&&c(function(){return u(n,t,it,ut)},ai.current),-1!==l&&oi.current&&c(function(){return u(i,o,tt,ct)},oi.current);else{var a=ii.current;if(!a)return;c(function(){return-1!==r?u(n,t,it,ut):u(i,o,tt,ct)},a)}}},[qi,Vi,gn,it,tt,ut,ct,ai,oi,ii]),Ro=s(function(n){if(n){Ft(),Tt(),Tn(new Set),Dn([]),Jn.current=[],bi(),Ii();var i=qi.findIndex(function(e){return e.id===n}),t=Vi.findIndex(function(e){return e.id===n}),o=-1===i?w(qi,n):null,r=-1===t?w(Vi,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;Wn.current=n,kt(function(n){var i,t=e({},n),o=!1;-1!==l&&(t[i=gn?"left-".concat(l):String(l)]||(t[i]=!0,o=!0));-1!==u&&(t[i=gn?"right-".concat(u):String(u)]||(t[i]=!0,o=!0));return o?t:n}),jt(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(){Wn.current===n&&yo.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(n,'" not found'))}},[qi,Vi,gn,kt,jt,Tt,bi,Ii]),yo=u(xo);a(function(){yo.current=xo},[xo]);var bo=u(null);a(function(){if(Ai){var e=Ti.fields.find(function(e){return e.analysisKey===Ai||e.key===Ai});if(e){var n=et.current[e.key]||nt.current[e.key];(null==n?void 0:n.current)&&setTimeout(function(){return n.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[Ai,Ti.fields]);var Co=s(function(e){var n,i,t,o,r,l,u,c,a,s=null===(n=null==Wt?void 0:Wt.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}},[Wt]),wo=U({proposedSections:qi,existingSections:Vi,maintainRelativeOrder:gn,cognitiveMap:ei,deviationData:Qn,treeData:Ve,resolvedComparisonConfig:Ti,badgeStyleOverride:sn}),_o=wo.getSectionCompareStyle,Bo=wo.getSubSectionCompareStyle,Io=wo.getDeviationStyleByKey,Fo=Z({containerRef:Hn,leftContainerRef:ai,rightContainerRef:oi,svgContainerRef:Mn,pathRefs:Kn,leftHeaderRef:zn,rightHeaderRef:Gn,proposedSections:qi,existingSections:Vi,visibleFields:Ki,leftRefs:et,rightRefs:nt,sectionLeftRefs:it,sectionRightRefs:tt,subSectionLeftRefs:ut,subSectionRightRefs:ct,lhsBadgeRefs:ot,rhsBadgeRefs:rt,sectionRowRefs:at,expandedSections:Ot,expandedSubSections:Pt,connectedSections:Fn,isSideBySide:pt,activeSideBySideSection:Rt,maintainRelativeOrder:gn,isGuidelineMode:zi,cognitiveMap:ei,getSectionCompareStyle:_o,getSubSectionCompareStyle:Bo,getDeviationStyleByKey:Io,isArrowVisible:gt,isAnimatingRef:qn,isSideBySideRef:Ct,sideBySideCacheRef:bt,sideBySideLineRef:Bt,activeSideBySideSectionRef:_t,activeSideBySideRightSectionRef:wt,connectedLines:An,setConnectedLines:Dn,cachedConnectedPositions:Jn,calculateLinesRef:Yn,resizeTimerRef:Xn,scrollLock:yt,scrollSyncLocked:kn,handleResizeRef:$n,activeProposed:Gi,existingRule:Wi,analysisData:Wt,pendingScrollTargetRef:si,pendingScrollCallbackRef:di,resolvedComparisonConfig:Ti,getFieldData:Co}),To=Fo.lines,Eo=Fo.setLines,Ao=Fo.overallConnector,Do=Fo.setOverallConnector,Oo=Fo.svgDimensions,ko=Fo.handleColumnScroll;a(function(){Ri.anchorEl&&requestAnimationFrame(function(){requestAnimationFrame(function(){var e;null===(e=Yn.current)||void 0===e||e.call(Yn)})})},[Ri.anchorEl,kn]);var Po=s(function(){Ft(),Pn(!1),kt({}),jt({}),Tt(),Tn(new Set),Dn([]),Jn.current=[],bi(),Ii(),Fi(),requestAnimationFrame(function(){Yn.current&&Yn.current()})},[kt,jt,Tt,bi,Ii,Fi]);a(function(){pt||0!==Fn.size||Pn(!1)},[pt,Fn]);var jo=c(function(){return Object.values(Ot).some(Boolean)||Object.values(Pt).some(Boolean)},[Ot,Pt]),Lo=u(null),No=u(0),Mo=u(0),Ho=u(0),zo=Q({timerRef:Lo,ruleComponentRef:ti,scrollContainerRef:ii,containerRef:Hn,maintainRelativeOrder:gn,proposedSections:qi,existingSections:Vi,isSideBySideRef:Ct,activeSideBySideSectionRef:_t,activeSideBySideRightSectionRef:wt,sectionRowRefs:at,sectionRightRowRefs:lt,sectionLeftRefs:it,sectionRightRefs:tt,subSectionLeftRefs:ut,subSectionRightRefs:ct,lhsBadgeRefs:ot,rhsBadgeRefs:rt,leftContainerRef:ai,rightContainerRef:oi,calculateLinesRef:Yn,handleResizeRef:$n,setIsResizing:St,setIsArrowVisible:ht,sideBySideCacheRef:bt,cachedConnectedPositions:Jn}).handleResize;a(function(){$n.current=zo},[zo,$n]),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 ti.current&&o.push(e(ti.current,No,n,function(){return $n.current()},function(){})),ii.current&&o.push(e(ii.current,Mo,i,function(){return $n.current()},function(){return Yn.current()})),Hn.current&&o.push(e(Hn.current,Ho,t,function(){return $n.current()},function(){return Yn.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=pt},[pt]),a(function(){_t.current=Rt},[Rt]);var Go=s(function(e){var n,i,t,o,r,l="",u="0";if("number"==typeof e)l=(null===(n=qi[e])||void 0===n?void 0:n.nodeId)||(null===(i=qi[e])||void 0===i?void 0:i.id)||"";else{var c=String(e).split(_);l=c[0],u=c[1]||"0"}var a=null===(t=null==Qn?void 0:Qn[l])||void 0===t?void 0:t.evaluation_result,s=Array.isArray(a)?a[parseInt(u,10)]:null==a?void 0:a[u];return!1===(null===(r=null===(o=null==s?void 0:s.evaluation_outputs)||void 0===o?void 0:o.guideline_flag)||void 0===r?void 0:r.rulebook_used)&&le(s)?1:0},[qi,Qn]),Wo=s(function(){Tt(),Tn(new Set),Dn([]),Jn.current=[]},[Tt]),qo=s(function(e,n){n!==Ln&&(Wo(),Nn(n))},[Ln,Wo]);a(function(){Zn||0===Ln||(Wo(),Nn(0))},[Ln,Zn,Wo]);var Vo=s(function(e){var n,i,t=ai.current,o=oi.current,r=re(o);if(o){var l="string"==typeof e&&e.includes(_),u=e;if(l){var c=e.split(_);c.length>=2&&(u="".concat(c[0]).concat(_).concat(c[1]))}var a=(null===(n=ot.current[u])||void 0===n?void 0:n.current)||(null===(i=ot.current[e])||void 0===i?void 0:i.current);if(r.length>0&&a&&t&&o){var s=r[0];ui.current&&(ui.current.style.height="0px"),ri.current&&(ri.current.style.height="0px"),ci.current&&(ci.current.style.height="0px"),li.current&&(li.current.style.height="0px"),requestAnimationFrame(function(){var e=a.getBoundingClientRect(),n=s.getBoundingClientRect(),i=t.getBoundingClientRect(),r=o.getBoundingClientRect(),l=t.scrollTop+(e.top-i.top)+e.height/2,u=o.scrollTop+(n.top-r.top)+n.height/2,c=l-i.height/2,d=Math.max(0,c),v=t.scrollHeight-t.clientHeight,f=d>v?d-v:0,p=i.top+l-d,g=r.top+u-p,h=0;g<0&&(h=Math.abs(g),g=0);var m=o.scrollHeight-o.clientHeight+h,S=g>m?g-m:0;ci.current&&(ci.current.style.height="".concat(f,"px")),ri.current&&(ri.current.style.height="".concat(h,"px")),li.current&&(li.current.style.height="".concat(S,"px")),requestAnimationFrame(function(){t.scrollTo({top:d,behavior:"smooth"}),o.scrollTo({top:g,behavior:"smooth"}),Yn.current&&setTimeout(function(){return Yn.current()},50)})})}}},[_]),Ko=s(function(){var e,n=gi.sectionIdx,i=gi.isOrphan;if(bi(),null!=n){var t="left";gi.anchorEl&&(null===(e=oi.current)||void 0===e?void 0:e.contains(gi.anchorEl))&&(t="right"),Mt(n),zi&&(Nn(Go(n)),Tn(new Set([n]))),Et(n,i,{sourceSide:t,onReady:function(){zi&&setTimeout(function(){return Vo(String(n))},150)}})}},[Et,gi.isOrphan,gi.sectionIdx,gi.anchorEl,bi,Mt,zi,Vo,Go]),Jo=s(function(){bi(),Tt(),Tn(new Set),Dn([]),Jn.current=[]},[bi,Tt]),Yo=null!==gi.sectionIdx&&Fn.has(gi.sectionIdx),Xo=q({proposedSections:qi,existingSections:Vi,parentDeviationRecord:Ji,expandedSections:Ot,maintainRelativeOrder:!!gn,scrollContainerRef:ii,leftContainerRef:ai,rightContainerRef:oi,lhsBadgeRefs:ot,rhsBadgeRefs:rt}),$o=Xo.showDeviationNavigation,Uo=Xo.showOpenNodeRef,Qo=Xo.adjustScrollForPopup,Zo=s(function(e,n,i,t,o){var r,l="string"==typeof t?y(t).trim():y(null==t?void 0:t.deviation_summary).trim(),u=e.currentTarget;Ii();var c="left";(null===(r=oi.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(_)){var r=n.split(_),l="".concat(r[0]).concat(_).concat(r[1]);return"right"===c?null===(e=rt.current[l])||void 0===e?void 0:e.current:null===(i=ot.current[l])||void 0===i?void 0:i.current}return"right"===c?null===(t=rt.current[n])||void 0===t?void 0:t.current:null===(o=ot.current[n])||void 0===o?void 0:o.current};if(i&&!zi)return Tt(),Tn(new Set),Dn([]),Jn.current=[],void(l&&(Mt(n),requestAnimationFrame(function(){var e=a()||u;e&&(e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"}));yi({open:!0,anchorEl:e,summary:t,displayImpact:o})})));Mt(n),zi&&(Nn(Go(n)),Tn(new Set([n]))),l?setTimeout(function(){Et(n,i,{toggleIfSame:!1,sourceSide:c,onReady:function(){var e,i,r,l=a()||u;if(zi)setTimeout(function(){return Vo(n)},150);else if(l){var c=l.getBoundingClientRect();if(c.top>.8*window.innerHeight||c.top<100){var s=c.top-window.innerHeight/2;gn?(null===(e=ai.current)||void 0===e||e.scrollBy({top:s,behavior:"smooth"}),null===(i=oi.current)||void 0===i||i.scrollBy({top:s,behavior:"smooth"})):null===(r=ii.current)||void 0===r||r.scrollBy({top:s,behavior:"smooth"})}}yi({open:!0,anchorEl:l,summary:t,displayImpact:o})}})},350):setTimeout(function(){Et(n,i,{toggleIfSame:!1,sourceSide:c}),zi&&setTimeout(function(){return Vo(n)},150)},350)},[Et,Ii,yi,Tt,Mt,zi,gn,Vo,Qn]),er=c(function(){var e;if(!on)return null;var n=null===(e=null==on?void 0:on.id)||void 0===e?void 0:e.split(":")[0];for(var i in Ji){if((Ji[i]||[]).some(function(e){return e.id===n}))return i}return null},[on,Ji]),nr=u({id:null,triggerMs:null}),ir=u(null);a(function(){if(null==on?void 0:on.id){var o=Number(on.trigger),r=nr.current;if((null==r?void 0:r.id)!==on.id||(null==r?void 0:r.triggerMs)!==o){if(on.id.includes(":")&&/:\d+$/.test(on.id)){var l=on.id.split(":"),u=l[0],c=l[1],a=null!=c?c:"0",s="".concat(on.id,":").concat(o);ir.current!==s&&(bi(),Ii(),Tt(),Tn(new Set),Dn([]),Jn.current=[],ir.current=s);var d=!1,v=0,f=null,p=null,g=!1,h=function(e,n){for(var i=function(e,t){if(!e)return null;if(n.includes(e.id)||n.includes(e.nodeId)||n.includes(e.contentId))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;if(!d){var s=function(){nr.current={id:on.id,triggerMs:o}},S=null,x=null;for(var R in Ji){var y=Ji[R].find(function(e){var n;return e.id===u||e.nodeId===u||e.contentId===u||(null===(n=e.evaluationResult)||void 0===n?void 0:n.nodeId)===u});if(y){S=R,x=y;break}}if(x&&S){var b=Array.from(new Set([u,x.id,x.nodeId,x.contentId,null===(r=x.evaluationResult)||void 0===r?void 0:r.nodeId].filter(Boolean))),C=qi.findIndex(function(e){return e.id===S}),w=Vi.findIndex(function(e){return e.id===S}),B=-1===C&&-1!==w,I=h(qi,b),E=h(Vi,b);if(I&&!E&&!B){var A=I.split("-"),D=Number(A[0]);if(gn){var O=null===(c=null===(l=qi[D])||void 0===l?void 0:l.refIndexes)||void 0===c?void 0:c[0],k=Vi.findIndex(function(e){return e.selfIndex===O});-1!==k&&(D=k)}E=n([D],A.slice(1),!0).join("-")}if(I||E){var P=I?Number(I.split("-")[0]):C,j=E?Number(E.split("-")[0]):w,L=j>=0?j:E?Number(E.split("-")[0]):-1,N=qi[P],M=Vi[L],H=N&&!N.title&&!N.content,z=M&&!M.title&&!M.content,G=B||(!I&&!!E||H&&!z);if(G){if(!(gn?!!fr.current["right-".concat(j)]:!!fr.current[String(j)])&&j>=0)return Nt(j,"right"),void(f=setTimeout(m,200))}else if(!(gn?!!fr.current["left-".concat(P)]:!!fr.current[String(P)])&&P>=0)return Nt(P,"left"),void(f=setTimeout(m,200));var W=I||"",q=E||"",V=b.map(function(e){return"".concat(e).concat(_).concat(a)}),K=V[0],J=function(){for(var e,n,i=0,t=V;i<t.length;i++){var o=t[i],r=(null===(e=ot.current[o])||void 0===e?void 0:e.current)||null,l=(null===(n=rt.current[o])||void 0===n?void 0:n.current)||null;if(r||l)return{refId:o,left:r,right:l}}return{refId:K,left:null,right:null}},Y=function(e){return"".concat(e).concat(_).concat(W).concat(_).concat(q)};if(!g){Mt(Y(K)),g=!0,v=0;var X=function(){var e=J(),n=e.left,i=e.right;return G||!n&&!!i?i:n};return null==p||p(),void(f=setTimeout(function(){var e,n,i,t,o,r,l,u;d||(e=X,n=function(){d||(p=null,m())},t=0,o=null,r=null,l=performance.now(),u=function(){if(!d)if(performance.now()-l>3e3)n();else{var c=e();if(c&&0!==c.getBoundingClientRect().height){var a=c.getBoundingClientRect(),s=a.top,v=a.height,f=null!==o&&Math.abs(s-o)<.5,p=null!==r&&Math.abs(v-r)<.5;if(f&&p){if(++t>=5)return void n()}else t=0;o=s,r=v,i=requestAnimationFrame(u)}else i=requestAnimationFrame(u)}},i=requestAnimationFrame(u),p=function(){return cancelAnimationFrame(i)})},300))}var $=J(),U=$.refId,Q=$.left,Z=$.right,ee=Y(U);if(Q||Z){var ne=G||!Q&&!!Z,ie=ne?Z:Q,te=gn?ne?oi.current:ai.current:ii.current;if(ie&&te){var oe=ie.getBoundingClientRect();if(0!==oe.height){var re=te.getBoundingClientRect(),le=oe.top-re.top+te.scrollTop-re.height/2+oe.height/2,ue=(null==I?void 0:I.includes("-"))||(null==E?void 0:E.includes("-")),ce=function(){return i(void 0,void 0,void 0,function(){var n,i,o,r,l,u,c,v,f,p;return t(this,function(t){switch(t.label){case 0:return d?[2]:(s(),n=ie instanceof Element?window.getComputedStyle(ie).color:"",[Q,Z].forEach(function(e){e&&(e.style.transition="box-shadow 300ms ease-in-out",e.style.boxShadow="0 0 10px ".concat(n))}),setTimeout(function(){[Q,Z].forEach(function(e){e&&(e.style.boxShadow="")})},2e3),i=(null===(c=null===(u=x.evaluationResult)||void 0===u?void 0:u.deviations)||void 0===c?void 0:c[a])||x,o=(null===(v=x.evaluationResult)||void 0===v?void 0:v.evaluation_outputs)||x.evaluation_outputs,!!Q&&!!Z||zi?(l=function(e,n){return Promise.race([e,new Promise(function(e){return setTimeout(e,n)})])},gn?[4,Promise.all([ai.current?l(T(ai.current),600):Promise.resolve(),oi.current?l(T(oi.current),600):Promise.resolve()])]:[3,2]):(r=ne?(null===(f=rt.current[ue?U:j])||void 0===f?void 0:f.current)||Z:(null===(p=ot.current[ue?U:P])||void 0===p?void 0:p.current)||Q,Qo(r,function(){yi({open:!0,anchorEl:r,displayImpact:on.displayImpact,summary:e(e({},i),{evaluation_outputs:o})})},{skipScroll:!0}),null==rn||rn(),[2]));case 1:t.sent(),t.label=2;case 2:return zi&&(Nn(Go(ee)),Tn(new Set([ee]))),At.current(ee,!1,{toggleIfSame:!1,sourceSide:B?"right":"left",onReady:function(){var n,t,o,r;s();var l=ne?(null===(n=rt.current[U])||void 0===n?void 0:n.current)||Z:(null===(t=ot.current[U])||void 0===t?void 0:t.current)||Q;if(zi)setTimeout(function(){return Vo(ee)},150);else{var u=(null===(o=ot.current[U])||void 0===o?void 0:o.current)||Q,c=(null===(r=rt.current[U])||void 0===r?void 0:r.current)||Z;u&&(u.style.scrollMarginTop="150px",u.scrollIntoView({behavior:"smooth",block:"start"})),c&&(c.style.scrollMarginTop="150px",c.scrollIntoView({behavior:"smooth",block:"start"}))}yi({open:!0,anchorEl:l,displayImpact:on.displayImpact,summary:e({},i)}),null==rn||rn()}}),[2]}})})};Math.abs(te.scrollTop-le)<=2?ce():F(te,le,ce)}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}else++v<30&&(f=setTimeout(m,100))}};return f=setTimeout(m,100),function(){d=!0,f&&clearTimeout(f),null==p||p()}}nr.current={id:on.id,triggerMs:o},Ro(on.id);var S=qi.findIndex(function(e){return e.id===on.id}),x=Vi.findIndex(function(e){return e.id===on.id});-1===S&&-1===x||setTimeout(function(){var e=-1!==S?S:x,n=-1===S;zi&&Nn(Go(e)),Tn(new Set([e])),At.current(e,n,{sourceSide:n?"right":"left",onReady:function(){zi&&setTimeout(function(){return Vo(String(e))},150)}})},400)}}},[null==on?void 0:on.id,null==on?void 0:on.trigger,null==on?void 0:on.displayImpact,Ji,qi,Vi,gn,yi,Ro,zi,Go,Vo]),a(function(){var n,i,t;if(Ri.open){var o=Ri.anchorEl;if(o&&!o.isConnected){var r=function(e){for(var n,i=0,t=Object.entries(e);i<t.length;i++){var r=t[i],l=r[0];if((null===(n=r[1].current)||void 0===n?void 0:n.textContent)===o.textContent)return l}return null},l=(null===(n=o.dataset)||void 0===n?void 0:n.deviationRefId)||r(ot.current)||r(rt.current);if(l){var u=(null===(i=rt.current[l])||void 0===i?void 0:i.current)||(null===(t=ot.current[l])||void 0===t?void 0:t.current);u&&u.isConnected&&yi(function(n){return e(e({},n),{anchorEl:u})})}}}},[Ri.open,Ri.anchorEl,kn,Fn,Ot]);var tr=fi.open,or=fi.sectionIdx,rr=fi.isOrphan,lr=fi.badgeStyle,ur=fi.anchorEl,cr=fi.sectionAnchorEl;a(function(){var n;if(Qe.isStreamingEnabled&&tr&&null!=or&&or!==Kt){var i="string"==typeof or?or.split(_)[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(qi,i):null,r=i&&"string"==typeof i?t(Vi,i):null,l="number"==typeof or?qi[or]||null:o||i&&((null===(n=null==Ve?void 0:Ve.nodes)||void 0===n?void 0:n[i])||(null==Ve?void 0:Ve[i]))||null,u="number"==typeof or?Vi[or]||null:r,c=ho(ur,l,u,or,rr,lr);pi(function(n){return n.open?y(n.cognitiveData)===y(c.cognitiveData)&&y(n.deviationData)===y(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})}},[tr,or,rr,lr,ur,cr,qi,Vi,ho]);var ar=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,d=e.rhsOrphanVisualIndexes;return o(K,{section:n,keyPath:i,depth:r,columnKey:u,parentNodeId:a,sectionOffset:s,rhsOrphanVisualIndexes:d})},[]),sr=c(function(){return qi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&gn?null:o(J,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"left-row-".concat(n))})},[qi,gn]),dr=c(function(){return Vi.map(function(e,n){var i,t,r=!(null==e?void 0:e.title)&&!(null==e?void 0:e.content),l=!(null==e?void 0:e.refIndexes)||0===e.refIndexes.length;return r&&l&&gn?null:o(Y,{section:e,idx:n},null!==(t=null!==(i=null==e?void 0:e.layoutKey)&&void 0!==i?i:null==e?void 0:e.id)&&void 0!==t?t:"right-row-".concat(n))})},[Vi,gn]),vr=u(mo);a(function(){vr.current=mo},[mo]);var fr=u(Ot);a(function(){fr.current=Ot},[Ot]);var pr=u(Zo);a(function(){pr.current=Zo},[Zo]);var gr=u(Jo);a(function(){gr.current=Jo},[Jo]);var hr=u(Nt);a(function(){hr.current=Nt},[Nt]);var mr=u(Lt);a(function(){mr.current=Lt},[Lt]);var Sr=u(ar);a(function(){Sr.current=ar},[ar]);var xr=u(Tt);a(function(){xr.current=Tt},[Tt]);var Rr=c(function(){return{isGuidelineMode:zi,maintainRelativeOrder:!!gn,showDeviationBadges:xn,isProposingFix:un,proposingFixNodeId:cn,isRedlineFlow:an,isSideBySide:pt,activeSideBySideSection:Rt,scrollSyncLocked:kn,toggleScrollSyncLocked:zt,summaryPopupAnchorEl:Ri.anchorEl,connectedSections:Fn,proposedSections:qi,existingSections:Vi,deviationNumberRegistry:Yi,deviationParentRegistry:Xi,treeData:Ve,displayConfig:Qe,resolvedMarkdownStyles:ni,unifiedNumbering:Gt,expandedSections:Ot,expandedSubSections:Pt,setExpandedSubSections:jt,getSectionCompareStyle:_o,getSubSectionCompareStyle:Bo,getBadgeRef:vt,getSectionRowRef:st,getSubSectionRef:dt,sectionLeftRefs:it,sectionRightRefs:tt,sectionRowRefs:at,sectionRightRowRefs:lt,subSectionLeftRefs:ut,subSectionRightRefs:ct,lhsBadgeRefs:ot,rhsBadgeRefs:rt,openMoreFunctionsPopup:Zt,handleOpenSummaryPopup:eo,openSummaryPopup:eo,handleCloseSummaryPopup:no,toggleSection:io,handleSubSectionToggle:to,renderSubSectionAccordion:oo,resetSideBySide:ro,setConnectedSections:Tn,setConnectedLines:Dn,cachedConnectedPositions:Jn,showDeviationNavigation:$o,showOpenNodeRef:Uo,deviationNodeIdToView:null==on?void 0:on.id,deviationTargetParentId:er,guidelinesData:dn,gptWebCitationConfig:fn}},[zi,gn,xn,un,cn,an,pt,Rt,kn,zt,Ri.anchorEl,Fn,qi,Vi,Yi,Qe,ni,Gt,Ot,Pt,jt,_o,Bo,vt,st,dt,$o,Uo,on,er,dn,fn]),yr=y(fi.sectionTitle||ji||ki),br=y(zi?Ni||Mi||fi.refSectionTitle:fi.refSectionTitle||Ni||Mi);return o($,e({value:Rr},{children:r(d,e({ref:ti,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"}},{children:[yn&&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(N,{})})),Ri.open&&o(X,{open:Ri.open,anchorEl:Ri.anchorEl,containerEl:bo.current,clipTopEl:zn.current,scrollContainerEl:ii.current,onClose:Jo,summary:Ri.summary,displayImpact:Ri.displayImpact,isScrollLocked:kn}),o(L,{open:gi.open,anchorEl:gi.anchorEl,maintainRelativeOrder:!!gn,sectionTitle:gi.sectionTitle,referenceSectionTitle:gi.refSectionTitle,onClose:Fi,onOpenCognitiveCompare:_i,onOpenSideBySide:Ko,onConnect:So,isConnected:Yo,isOrphan:!zi&&!!gi.isOrphan,isGuidelineMode:zi,hasGuidelineMatches:gi.hasGuidelineMatches}),fi.open&&o(j,{open:fi.open,popupRef:wi,position:mi,popupConfig:en,onClose:function(){Si(null),pi(function(n){return e(e({},n),{open:!1})}),Ci(null)},markdownStyles:Xe,sectionTitle:yr,referenceSectionTitle:br,cognitiveData:fi.cognitiveData,anchorEl:fi.anchorEl,sectionAnchorEl:fi.sectionAnchorEl,scrollContainerEl:ii.current,badgeStyle:fi.badgeStyle,docData:fi.docData,deviationData:fi.deviationData,isLoading:fi.isLoading}),o(v,e({open:!!wn,autoHideDuration:8e3,onClose:function(){return _n(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:o(f,e({onClose:function(){return _n(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:wn}))})),o(V,{componentHeaderText:qe,displayConfig:Qe,maintainRelativeOrder:gn,onCollapseAll:Po,showCollapseAll:jo,onToggleView:function(e){bn(!0),setTimeout(function(){hn(!e),null==Ze||Ze(!e),Pn(!1),Tt(),bi(),Tn(new Set),Dn([]),Jn.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){bn(!1)},600)})})},50)}}),o(d,e({ref:ii,onScroll:ko,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:gn?"stretch":"flex-start",bgcolor:"#FFFFFF",overflowY:gn?"visible":"auto",borderTop:qt&&Vt?"none":"1.5px solid #EEF0F4"}},{children:o(d,e({sx:e({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px",minHeight:0},gn?{flex:1}:{})},{children:r(d,e({ref:Hn,sx:e({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},gn?{flex:1,overflow:"visible"}:{})},{children:[o(ne,{svgContainerRef:Mn,svgDimensions:Oo,isResizing:mt,overallConnector:Ao,rootDeviationStyle:Xt,lines:To,isSideBySide:pt,activeSideBySideSection:Rt,isArrowVisible:gt,maintainRelativeOrder:gn,proposedSections:qi,existingSections:Vi,cognitivePopup:fi,activeBadgeId:xi,closeCognitivePopup:Ii,setActiveBadgeId:Ci,openCognitivePopupFromState:Bi,buildSectionPopupState:ho,connectedLines:An,isGuidelineMode:zi,pathRefs:Kn}),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)"},gn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[o(d,e({ref:zn,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:ki,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:ki}))}))})),r(d,e({ref:ai,onScroll:ko,sx:e({p:"12px",display:"flex",flexDirection:"column"},gn?{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:ui,style:{width:"100%",height:"0px",flexShrink:0}}),Ui&&sr,o("div",{ref:ci,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),o(d,e({ref:bo,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(),fi.open&&xi===Kt?Ii():(Ci(Kt),Bi(ho(n.currentTarget,{title:so,content:"",evaluationResult:Jt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},{title:fo,content:""},Kt,!0,e(e({},Xt),{label:""}))))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:Xt.badgeBg,color:Xt.badgeText,border:"1px solid ".concat(Xt.badgeBorder),fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"}},{children:[null!=Yt?Yt:o(M,{}),o(d,e({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:o(x,{})})),o(S,{size:11,style:{transform:fi.open&&xi===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},gn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[xt&&o(R,{sections:11}),o(d,e({ref:Gn,sx:{p:"8px",bgcolor:zi?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",flexShrink:0}},{children:zi?r(h,e({value:Ln,onChange:qo,variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}}},{children:[o(m,{label:o(p,e({title:Mi,placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Redline Guidelines"}))}))}),Zn&&o(m,{label:o(p,e({title:"Web & GPT Sources",placement:"top"},{children:o(d,e({component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"}},{children:"Web & GPT Sources"}))}))})]})):o(p,e({title:Mi,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:Mi}))}))})),r(d,e({ref:oi,onScroll:ko,sx:e({p:zi?"0px":"12px",display:"flex",flexDirection:"column"},gn?{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[o("div",{ref:ri,style:{width:"100%",height:"0px",flexShrink:0}}),zi?dn?0!==Ln&&Zn?o(te,{deviationData:tn,connectedSections:Fn,proposedSections:qi}):o(ie,{guidelinesData:dn,deviationData:tn,connectedSections:Fn,proposedSections:qi}):o(oe,{}):Ui&&dr,o("div",{ref:li,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))}))};export{ue as default};
2
2
  //# sourceMappingURL=CognitiveCompare.js.map
@@ -1,2 +1,2 @@
1
- var l="#3730A3",n=12,a=680,o=12,t=10,e="Contract Comparison",i={isLoading:!1,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},c={open:!1,anchorEl:null,summary:"",markdownStyles:{},displayImpact:!1};export{t as ARROW_SIZE,e as DEFAULT_COMPONENT_HEADER_TEXT,l as DEFAULT_DEVIAION_COLOR,i as EMPTY_SECTION_POPUP_STATE,c as EMPTY_SUMMARY_POPUP_STATE,n as POPUP_GAP,a as POPUP_WIDTH,o as VIEWPORT_MARGIN};
1
+ var l="#3730A3",n=12,a=1050,o=12,t=10,e="Contract Comparison",i={isLoading:!1,open:!1,sectionTitle:"",refSectionTitle:"",cognitiveData:null,anchorEl:null,sectionAnchorEl:null,badgeStyle:null,sectionIdx:null,isOrphan:!1,docData:null,deviationData:null},c={open:!1,anchorEl:null,summary:"",markdownStyles:{},displayImpact:!1};export{t as ARROW_SIZE,e as DEFAULT_COMPONENT_HEADER_TEXT,l as DEFAULT_DEVIAION_COLOR,i as EMPTY_SECTION_POPUP_STATE,c as EMPTY_SUMMARY_POPUP_STATE,n as POPUP_GAP,a as POPUP_WIDTH,o as VIEWPORT_MARGIN};
2
2
  //# sourceMappingURL=CognitiveCompareConstants.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as o}from"tslib";import{jsxs as i,Fragment as n,jsx as e}from"react/jsx-runtime";import{useMemo as t,useState as r,useCallback as a,useEffect as l}from"react";import{Box as c,Typography as s,IconButton as d,Tooltip as p}from"@mui/material";import{X as v}from"lucide-react";import x from"react-dom";import h from"../../assests/svg/SparkleIcon.js";import{SHARED_MARKDOWN_STYLES as u,DEFAULT_POPUP_CONFIG as g}from"./CognitiveCompareConfig.js";import b from"./CitationRenderer.js";var f=10,m=function(m){var y,w,F,k,C,S,D,_,E,R,z,W,I,T,j,A,B,L,H,M,O=m.open,G=m.onClose,N=m.sectionTitle,P=m.referenceSectionTitle,Y=m.cognitiveData,q=m.relevanceScore,J=m.anchorEl,K=m.badgeStyle,Q=m.popupRef,U=m.position,V=m.markdownStyles,X=m.docData,Z=m.popupConfig,$=m.deviationData,oo=void 0===$?null:$,io=m.isLoading,no=o(o({},u),V),eo=t(function(){var i,n;return o(o(o({},g),Z),{tabs:{deviation:o(o({},g.tabs.deviation),null===(i=null==Z?void 0:Z.tabs)||void 0===i?void 0:i.deviation),association:o(o({},g.tabs.association),null===(n=null==Z?void 0:Z.tabs)||void 0===n?void 0:n.association)},sectionTitles:o(o({},g.sectionTitles),null==Z?void 0:Z.sectionTitles)})},[Z]),to=null==Y?void 0:Y.isMissingRationale,ro=r(to?eo.tabs.deviation.key:eo.tabs.association.key),ao=ro[0],lo=ro[1],co=r(!1),so=co[0],po=co[1],vo=a(function(o){po(o)},[]);l(function(){O?lo(to?eo.tabs.deviation.key:eo.tabs.association.key):po(!1)},[O,to,eo.tabs.deviation.key,eo.tabs.association.key]);var xo=t(function(){if(!K)return{border:eo.accentColor,shadow:"".concat(eo.accentColor,"2E")};var o=K.badgeText;return"#9F1239"===o||"#B42318"===o?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===o?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===o?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:eo.accentColor,shadow:"".concat(eo.accentColor,"2E")}},[K,eo.accentColor]);l(function(){if(O&&!so){var o=function(o){var i;(null===(i=Q.current)||void 0===i?void 0:i.contains(o.target))||(null==J?void 0:J.contains(o.target))||G()};return document.addEventListener("mousedown",o),function(){return document.removeEventListener("mousedown",o)}}},[O,G,J,Q,so]);var ho=to?[]:[eo.tabs.deviation,eo.tabs.association];if(1===ho.length&&ho[0].key===eo.tabs.deviation.key)return null;if(!O||!Y)return null;var uo=null!==(F=null!==(w=ao===eo.tabs.deviation.key?null===(y=null==oo?void 0:oo.cognitive_decisioning)||void 0===y?void 0:y.decision_strength:Y.relevance_score)&&void 0!==w?w:q)&&void 0!==F?F:0,go=Y.decisioning,bo=Array.isArray(go)?go:"string"==typeof go&&go.trim()?[go]:[],fo=Y.gap,mo=Array.isArray(fo)?fo:"string"==typeof fo&&fo.trim()?[fo]:[],yo=U?U.left-150:-9999,wo=(null!==(k=null==U?void 0:U.arrowLeft)&&void 0!==k?k:60)+150,Fo=i(c,o({ref:Q,sx:{position:"fixed",top:null!==(C=null==U?void 0:U.top)&&void 0!==C?C:-9999,left:yo,zIndex:9999,width:"".concat(1050,"px"),maxWidth:"min(".concat(1050,"px, calc(100vw - ").concat(yo>0?yo:0,"px - ").concat(12,"px))"),bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(xo.border),boxShadow:"0px 8px 32px ".concat(xo.shadow,", 0px 0px 0px 3px ").concat(xo.shadow),overflow:"visible",display:so?"none":"flex",flexDirection:"column",maxHeight:(null==U?void 0:U.maxHeight)?"min(60vh, ".concat(U.maxHeight,"px)"):"60vh",visibility:U?"visible":"hidden",pointerEvents:so?"none":"auto"}},{children:[U&&(U.openAbove?i(n,{children:[e(c,{sx:{position:"absolute",bottom:-11,left:wo-f,width:0,height:0,borderLeft:"".concat(f,"px solid transparent"),borderRight:"".concat(f,"px solid transparent"),borderTop:"".concat(11,"px solid ").concat(xo.border),zIndex:1}}),e(c,{sx:{position:"absolute",bottom:-9,left:wo-f+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderTop:"".concat(f,"px solid #FFFFFF"),zIndex:2}})]}):i(n,{children:[e(c,{sx:{position:"absolute",top:-11,left:wo-f,width:0,height:0,borderLeft:"".concat(f,"px solid transparent"),borderRight:"".concat(f,"px solid transparent"),borderBottom:"".concat(11,"px solid ").concat(xo.border),zIndex:1}}),e(c,{sx:{position:"absolute",top:-9,left:wo-f+1,width:0,height:0,borderLeft:"".concat(9,"px solid transparent"),borderRight:"".concat(9,"px solid transparent"),borderBottom:"".concat(f,"px solid #FFFFFF"),zIndex:2}})]})),i(c,o({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0}},{children:[i(c,o({sx:{flex:1,minWidth:0}},{children:[("no counterpart"!==N||"no counterpart"!==P)&&i(s,o({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[e(c,o({component:"span",title:N,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:N})),e(c,o({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),e(c,o({component:"span",title:P||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:P||"Reference Section"}))]})),e(c,o({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:e(s,o({sx:{fontSize:"no counterpart"!==N||"no counterpart"!==P?"13px":"16px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:null===(S=Object.values(eo.tabs).find(function(o){return o.key===ao}))||void 0===S?void 0:S.subtitle}))}))]})),i(c,o({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0}},{children:[i(c,o({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED"}},{children:[e(h,{}),eo.decisionStrengthLabel," ",uo,"%"]})),e(d,o({onClick:G,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:e(v,{size:22})}))]}))]})),e(c,o({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0}},{children:ho.map(function(i){var n=ao===i.key,t=i.key===eo.tabs.deviation.key,r=ho.length>1&&t&&io,a=e(c,o({onClick:function(){r||lo(i.key)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:r?"not-allowed":"pointer",opacity:r?.5:1,fontSize:"14px",fontWeight:n?600:400,color:n?eo.accentColor:"#667085",backgroundColor:n?"".concat(eo.accentColor,"14"):"transparent",borderBottom:n?"2px solid ".concat(eo.accentColor):"2px solid transparent",transition:"all 0.15s",userSelect:"none"}},{children:i.label}),i.key);return r?e(p,o({title:"Fetching deviation data",arrow:!0,placement:"top"},{children:e("span",{children:a})}),i.key):a})})),e(c,o({sx:{flex:1,minHeight:0,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(xo.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:xo.border},scrollbarWidth:"thin",scrollbarColor:"".concat(xo.border,"55 transparent")}},{children:ao===eo.tabs.deviation.key?oo?i(n,{children:[(null===(_=(null===(D=null==oo?void 0:oo.cognitive_decisioning)||void 0===D?void 0:D.decisioning_factors)||[])||void 0===_?void 0:_.length)>0&&e(b,{title:"Decision Making Factors",content:null===(R=null===(E=null==oo?void 0:oo.cognitive_decisioning)||void 0===E?void 0:E.decisioning_factors)||void 0===R?void 0:R.join("\n\n"),citations:null===(z=null==oo?void 0:oo.cognitive_decisioning)||void 0===z?void 0:z.citations,styles:no,docData:X,deviationData:oo,open:O,onCitationFullscreenChange:vo}),(null===(I=(null===(W=null==oo?void 0:oo.cognitive_decisioning)||void 0===W?void 0:W.gaps_in_decision)||[])||void 0===I?void 0:I.length)>0&&e(b,{title:"Gaps in Decision",content:null===(j=null===(T=null==oo?void 0:oo.cognitive_decisioning)||void 0===T?void 0:T.gaps_in_decision)||void 0===j?void 0:j.join("\n\n"),citations:null===(A=null==oo?void 0:oo.cognitive_decisioning)||void 0===A?void 0:A.citations,styles:no,docData:X,deviationData:oo,open:O,onCitationFullscreenChange:vo}),0===(null===(L=(null===(B=null==oo?void 0:oo.cognitive_decisioning)||void 0===B?void 0:B.decisioning_factors)||[])||void 0===L?void 0:L.length)&&0===(null===(M=(null===(H=null==oo?void 0:oo.cognitive_decisioning)||void 0===H?void 0:H.gaps_in_decision)||[])||void 0===M?void 0:M.length)&&e(c,o({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:e(s,o({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]}):e(b,{title:"Deviation Analysis",content:"Deviation analysis content will appear here. This tab shows\n structural and semantic deviations identified between the two\n sections being compared.",citations:{},styles:no,docData:X,open:O,onCitationFullscreenChange:vo}):i(n,{children:[bo.length>0&&e(b,{title:eo.sectionTitles.decisioningFactors,content:bo.join("\n\n"),citations:Y.citations,styles:no,open:O,docData:X,onCitationFullscreenChange:vo}),mo.length>0&&e(b,{title:eo.sectionTitles.gaps,content:mo.join("\n\n"),citations:Y.citations,styles:no,open:O,docData:X,onCitationFullscreenChange:vo}),0===bo.length&&0===mo.length&&e(c,o({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:e(s,o({sx:{fontSize:"13px",color:"#64748B"}},{children:eo.emptyStateMessage}))}))]})}))]}));return x.createPortal(Fo,document.body)};export{m as default};
1
+ import{__assign as o}from"tslib";import{jsxs as i,Fragment as n,jsx as e}from"react/jsx-runtime";import{useMemo as t,useState as r,useCallback as a,useEffect as l}from"react";import{Box as s,Typography as c,IconButton as d,Tooltip as p}from"@mui/material";import{X as v}from"lucide-react";import x from"react-dom";import h from"../../assests/svg/SparkleIcon.js";import{SHARED_MARKDOWN_STYLES as u,DEFAULT_POPUP_CONFIG as g}from"./CognitiveCompareConfig.js";import b from"./CitationRenderer.js";import{POPUP_WIDTH as f,VIEWPORT_MARGIN as m,ARROW_SIZE as w}from"./CognitiveCompareConstants.js";var y=function(y){var F,k,C,S,D,_,E,W,z,R,j,I,T,A,B,L,H,M,O,X,G,N=y.open,P=y.onClose,Y=y.sectionTitle,q=y.referenceSectionTitle,J=y.cognitiveData,K=y.relevanceScore,Q=y.anchorEl,U=y.badgeStyle,V=y.popupRef,Z=y.position,$=y.markdownStyles,oo=y.docData,io=y.popupConfig,no=y.deviationData,eo=void 0===no?null:no,to=y.isLoading,ro=o(o({},u),$),ao=t(function(){var i,n;return o(o(o({},g),io),{tabs:{deviation:o(o({},g.tabs.deviation),null===(i=null==io?void 0:io.tabs)||void 0===i?void 0:i.deviation),association:o(o({},g.tabs.association),null===(n=null==io?void 0:io.tabs)||void 0===n?void 0:n.association)},sectionTitles:o(o({},g.sectionTitles),null==io?void 0:io.sectionTitles)})},[io]),lo=null==J?void 0:J.isMissingRationale,so=r(lo?ao.tabs.deviation.key:ao.tabs.association.key),co=so[0],po=so[1],vo=r(!1),xo=vo[0],ho=vo[1],uo=a(function(o){ho(o)},[]);l(function(){N?po(lo?ao.tabs.deviation.key:ao.tabs.association.key):ho(!1)},[N,lo,ao.tabs.deviation.key,ao.tabs.association.key]);var go=t(function(){if(!U)return{border:ao.accentColor,shadow:"".concat(ao.accentColor,"2E")};var o=U.badgeText;return"#9F1239"===o||"#B42318"===o?{border:"#E11D48",shadow:"rgba(225,29,72,0.15)"}:"#1D4ED8"===o?{border:"#3B82F6",shadow:"rgba(59,130,246,0.15)"}:"#A16207"===o?{border:"#F59E0B",shadow:"rgba(245,158,11,0.15)"}:{border:ao.accentColor,shadow:"".concat(ao.accentColor,"2E")}},[U,ao.accentColor]);l(function(){if(N&&!xo){var o=function(o){var i;(null===(i=V.current)||void 0===i?void 0:i.contains(o.target))||(null==Q?void 0:Q.contains(o.target))||P()};return document.addEventListener("mousedown",o),function(){return document.removeEventListener("mousedown",o)}}},[N,P,Q,V,xo]);var bo=lo?[]:[ao.tabs.deviation,ao.tabs.association];if(1===bo.length&&bo[0].key===ao.tabs.deviation.key)return null;if(!N||!J)return null;var fo=null!==(C=null!==(k=co===ao.tabs.deviation.key?null===(F=null==eo?void 0:eo.cognitive_decisioning)||void 0===F?void 0:F.decision_strength:J.relevance_score)&&void 0!==k?k:K)&&void 0!==C?C:0,mo=J.decisioning,wo=Array.isArray(mo)?mo:"string"==typeof mo&&mo.trim()?[mo]:[],yo=J.gap,Fo=Array.isArray(yo)?yo:"string"==typeof yo&&yo.trim()?[yo]:[],ko=null!==(S=null==Z?void 0:Z.arrowLeft)&&void 0!==S?S:60,Co=i(s,o({ref:V,sx:{position:"fixed",top:null!==(D=null==Z?void 0:Z.top)&&void 0!==D?D:-9999,left:null!==(_=null==Z?void 0:Z.left)&&void 0!==_?_:-9999,zIndex:9999,width:"min(".concat(f,"px, calc(100vw - ").concat(2*m,"px))"),maxWidth:"calc(100vw - ".concat(2*m,"px)"),boxSizing:"border-box",bgcolor:"#FFFFFF",borderRadius:"14px",border:"1.5px solid ".concat(go.border),boxShadow:"0px 8px 32px ".concat(go.shadow,", 0px 0px 0px 3px ").concat(go.shadow),overflow:"visible",display:xo?"none":"flex",flexDirection:"column",maxHeight:(null==Z?void 0:Z.maxHeight)?"min(60vh, ".concat(Z.maxHeight,"px)"):"60vh",visibility:Z?"visible":"hidden",pointerEvents:xo?"none":"auto"}},{children:[Z&&(Z.openAbove?i(n,{children:[e(s,{sx:{position:"absolute",bottom:-(w+1),left:ko-w,width:0,height:0,borderLeft:"".concat(w,"px solid transparent"),borderRight:"".concat(w,"px solid transparent"),borderTop:"".concat(w+1,"px solid ").concat(go.border),zIndex:1}}),e(s,{sx:{position:"absolute",bottom:-(w-1),left:ko-w+1,width:0,height:0,borderLeft:"".concat(w-1,"px solid transparent"),borderRight:"".concat(w-1,"px solid transparent"),borderTop:"".concat(w,"px solid #FFFFFF"),zIndex:2}})]}):i(n,{children:[e(s,{sx:{position:"absolute",top:-(w+1),left:ko-w,width:0,height:0,borderLeft:"".concat(w,"px solid transparent"),borderRight:"".concat(w,"px solid transparent"),borderBottom:"".concat(w+1,"px solid ").concat(go.border),zIndex:1}}),e(s,{sx:{position:"absolute",top:-(w-1),left:ko-w+1,width:0,height:0,borderLeft:"".concat(w-1,"px solid transparent"),borderRight:"".concat(w-1,"px solid transparent"),borderBottom:"".concat(w,"px solid #FFFFFF"),zIndex:2}})]})),i(s,o({sx:{px:2.5,pt:2,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexWrap:{xs:"wrap",sm:"nowrap"},flexShrink:0}},{children:[i(s,o({sx:{flex:{xs:"1 1 100%",sm:1},minWidth:0}},{children:[("no counterpart"!==Y||"no counterpart"!==q)&&i(c,o({sx:{fontSize:"16px",fontWeight:600,color:"#101828",lineHeight:1.3,display:"flex",alignItems:"center",gap:1,flexWrap:"nowrap",overflow:"hidden",width:"100%"}},{children:[e(s,o({component:"span",title:Y,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",maxWidth:"calc(50% - 16px)",minWidth:0}},{children:Y})),e(s,o({component:"span",sx:{color:"#667085",fontWeight:400,flexShrink:0,mx:.5}},{children:"↔"})),e(s,o({component:"span",title:q||"Reference Section",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0}},{children:q||"Reference Section"}))]})),e(s,o({sx:{mt:.75,display:"inline-flex",alignItems:"center",gap:.75}},{children:e(c,o({sx:{fontSize:"no counterpart"!==Y||"no counterpart"!==q?"13px":"16px",fontWeight:400,color:"#5928ED",lineHeight:1}},{children:null===(E=Object.values(ao.tabs).find(function(o){return o.key===co}))||void 0===E?void 0:E.subtitle}))}))]})),i(s,o({sx:{display:"flex",alignItems:"center",gap:1.5,flexShrink:0,maxWidth:"100%",ml:{xs:"auto",sm:0}}},{children:[i(s,o({sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:.5,borderRadius:"20px",bgcolor:"#FFFFFF",border:"1px solid #5928ED",fontSize:"12px",fontWeight:600,color:"#5928ED",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden"}},{children:[e(h,{}),ao.decisionStrengthLabel," ",fo,"%"]})),e(d,o({onClick:P,size:"small",sx:{color:"#667085",width:24,height:24,"&:hover":{bgcolor:"transparent",color:"#101828"}}},{children:e(v,{size:22})}))]}))]})),e(s,o({sx:{display:"flex",borderBottom:"1px solid #E4E7EC",px:2.5,flexShrink:0,maxWidth:"100%",overflowX:"auto"}},{children:bo.map(function(i){var n=co===i.key,t=i.key===ao.tabs.deviation.key,r=bo.length>1&&t&&to,a=e(s,o({onClick:function(){r||po(i.key)},sx:{pb:"10px",pt:"4px",mr:3,px:2,cursor:r?"not-allowed":"pointer",opacity:r?.5:1,fontSize:"14px",fontWeight:n?600:400,color:n?ao.accentColor:"#667085",backgroundColor:n?"".concat(ao.accentColor,"14"):"transparent",borderBottom:n?"2px solid ".concat(ao.accentColor):"2px solid transparent",transition:"all 0.15s",userSelect:"none",flexShrink:0}},{children:i.label}),i.key);return r?e(p,o({title:"Fetching deviation data",arrow:!0,placement:"top"},{children:e("span",{children:a})}),i.key):a})})),e(s,o({sx:{flex:1,minHeight:0,overflowY:"auto",overflowX:"auto",maxWidth:"100%",boxSizing:"border-box",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.5,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"".concat(go.border,"55"),borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:go.border},scrollbarWidth:"thin",scrollbarColor:"".concat(go.border,"55 transparent")}},{children:co===ao.tabs.deviation.key?eo?i(n,{children:[(null===(z=(null===(W=null==eo?void 0:eo.cognitive_decisioning)||void 0===W?void 0:W.decisioning_factors)||[])||void 0===z?void 0:z.length)>0&&e(b,{title:"Decision Making Factors",content:null===(j=null===(R=null==eo?void 0:eo.cognitive_decisioning)||void 0===R?void 0:R.decisioning_factors)||void 0===j?void 0:j.join("\n\n"),citations:null===(I=null==eo?void 0:eo.cognitive_decisioning)||void 0===I?void 0:I.citations,styles:ro,docData:oo,deviationData:eo,open:N,onCitationFullscreenChange:uo}),(null===(A=(null===(T=null==eo?void 0:eo.cognitive_decisioning)||void 0===T?void 0:T.gaps_in_decision)||[])||void 0===A?void 0:A.length)>0&&e(b,{title:"Gaps in Decision",content:null===(L=null===(B=null==eo?void 0:eo.cognitive_decisioning)||void 0===B?void 0:B.gaps_in_decision)||void 0===L?void 0:L.join("\n\n"),citations:null===(H=null==eo?void 0:eo.cognitive_decisioning)||void 0===H?void 0:H.citations,styles:ro,docData:oo,deviationData:eo,open:N,onCitationFullscreenChange:uo}),0===(null===(O=(null===(M=null==eo?void 0:eo.cognitive_decisioning)||void 0===M?void 0:M.decisioning_factors)||[])||void 0===O?void 0:O.length)&&0===(null===(G=(null===(X=null==eo?void 0:eo.cognitive_decisioning)||void 0===X?void 0:X.gaps_in_decision)||[])||void 0===G?void 0:G.length)&&e(s,o({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:e(c,o({sx:{fontSize:"13px",color:"#64748B"}},{children:"No cognitive decisioning data available for this section."}))}))]}):e(b,{title:"Deviation Analysis",content:"Deviation analysis content will appear here. This tab shows\n structural and semantic deviations identified between the two\n sections being compared.",citations:{},styles:ro,docData:oo,open:N,onCitationFullscreenChange:uo}):i(n,{children:[wo.length>0&&e(b,{title:ao.sectionTitles.decisioningFactors,content:wo.join("\n\n"),citations:J.citations,styles:ro,open:N,docData:oo,onCitationFullscreenChange:uo}),Fo.length>0&&e(b,{title:ao.sectionTitles.gaps,content:Fo.join("\n\n"),citations:J.citations,styles:ro,open:N,docData:oo,onCitationFullscreenChange:uo}),0===wo.length&&0===Fo.length&&e(s,o({sx:{p:2,bgcolor:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"}},{children:e(c,o({sx:{fontSize:"13px",color:"#64748B"}},{children:ao.emptyStateMessage}))}))]})}))]}));return x.createPortal(Co,document.body)};export{y as default};
2
2
  //# sourceMappingURL=CognitivePopup.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as i,jsx as o}from"react/jsx-runtime";import t,{useEffect as l}from"react";import{Box as r,Accordion as d,AccordionSummary as a,Tooltip as u,Typography as c,AccordionDetails as s}from"@mui/material";import{ChevronUp as v,ChevronDown as f}from"lucide-react";import{MemoizedMarkdown as p}from"../hooks/memoizedMarkdown.js";import{useCompareContext as h}from"../CompareContext.js";import{hasValue as g,hasMeaningfulRedlineTags as m,safeStringify as x,stripRedlineTags as I,hasSingleMappedLhsSection as y,generateColorPalette as b,getLhsDeviationDisplayIndexes as w,DEVIATION_BADGE_SEPARATOR as S,isMissingStr as R,getRhsMappedSectionNumber as _,findTextMatchRange as M}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as F}from"../CognitiveCompareConstants.js";import{normalizeRedlineMarkdown as k}from"../utils/normalizeRedlineMarkdown.js";var N=function(N){var B,C,E,A,O,j,W,T,D,P,z,K,G,L,X,H=N.section,V=N.idx,Y=N.columnKey,q=N.colRef,J=N.mb,Q=void 0===J?1:J,U=N.isExpanded,Z=N.onToggle,$=N.navigation,nn=N.parentNodeId,en=void 0===nn?"":nn,on=h(),tn=on.showOpenNodeRef,ln=on.resolvedMarkdownStyles,rn=on.maintainRelativeOrder,dn=on.showDeviationBadges,an=void 0!==dn&&dn,un=on.renderSubSectionAccordion,cn=on.treeData,sn=on.proposedSections,vn=on.existingSections,fn=on.deviationNumberRegistry,pn=on.deviationParentRegistry,hn=on.getBadgeRef,gn=on.openSummaryPopup,mn=on.getSectionCompareStyle,xn=on.connectedSections,In=on.openMoreFunctionsPopup,yn=on.isProposingFix,bn=on.proposingFixNodeId,wn=on.isRedlineFlow,Sn=on.isSideBySide,Rn=on.activeSideBySideSection,_n=on.scrollSyncLocked,Mn=on.unifiedNumbering,Fn=on.toggleScrollSyncLocked,kn=on.summaryPopupAnchorEl,Nn="".concat(Sn?"1":"0","-").concat(String(null!=Rn?Rn:"")),Bn=(null===(B=H.displayTitle)||void 0===B||B)&&g(H.title),Cn=!(!yn||!bn||"left"!==Y||H.id!==bn&&H.nodeId!==bn&&H.contentId!==bn),En=m(H.content),An="boolean"==typeof wn?wn:En,On=En,jn=H.change_history,Wn=An&&En,Tn=t.useMemo(function(){return Wn?k(x(H.content)):x(H.content)},[H.content,Wn]),Dn=Wn?I(Tn):H.content,Pn=Wn?Tn:void 0,zn=En&&g(jn)?x(jn):void 0,Kn=(null===(C=H.displayContent)||void 0===C||C||En)&&g(H.content),Gn=!Bn&&!Kn,Ln=H.title;Bn||(Ln=Kn?"No Title Found":"No Matching Section Found");var Xn="left"===Y&&(H.isMultipleMapping||(null!==(A=null===(E=H.refContentIds)||void 0===E?void 0:E.length)&&void 0!==A?A:1)>1),Hn="left"===Y&&Ln.length>29?"".concat(Ln.slice(0,29).trimEnd(),"..."):Ln,Vn=H.evaluationResult;if(!Vn&&"right"===Y)if(rn){var Yn=null===(O=H.refIndexes)||void 0===O?void 0:O[0],qn=sn.find(function(n){return n.selfIndex===Yn});Vn=null==qn?void 0:qn.evaluationResult}else Vn=null===(j=sn[V])||void 0===j?void 0:j.evaluationResult;var Jn=null===(W=null==cn?void 0:cn.input_index_map)||void 0===W?void 0:W[0],Qn=null===(T=null==cn?void 0:cn.input_index_map)||void 0===T?void 0:T[1],Un="left"===Y?Qn:Jn,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 r=Zn(l.subsections,e);if(r)return r}}return null},$n="left"===Y?H:Zn(sn,H.id),ne="right"===Y?H:Zn(vn,H.id),ee=t.useMemo(function(){if(!rn)return 0;var n=1/0,e=function(n){var e=x(n||"").replace(/\\n/g,"\n");return m(e)?I(k(e)):e},i=function(o,t,l,r){if(o){var d=o.nodeId||o.id;if(r&&"right"===Y){var a=sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(o.selfIndex)});a.length>0&&(d=a[0].nodeId||a[0].id)}var u=o.nodeId||o.id||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=o.evaluationResult||(null==t?void 0:t.evaluationResult)||(null==l?void 0:l.evaluationResult),s=(null==c?void 0:c.deviations)||{};Object.keys(s).forEach(function(i){var r,a=null===(r=s[i])||void 0===r?void 0:r[en];if(function(n,i){if("string"!=typeof i||R(i))return!1;var o=e(null==n?void 0:n.content),t=e(i);return!!t&&!!M(o,t)}("left"===Y?t||o:l||o,a)){var c="".concat(d).concat(S).concat(i),v=null==fn?void 0:fn[c];null!=v&&v<n&&(n=v);var f="".concat(u).concat(S).concat(i),p=null==fn?void 0:fn[f];null!=p&&p<n&&(n=p)}});for(var v=o.subsections||[],f=(null==t?void 0:t.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(v.length,f.length,p.length),g=0;g<h;g++)i(v[g],f[g],p[g],!1)}},o="right"===Y?sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(H.selfIndex)}):[];if(1===o.length){var t=o[0];(t.refIndexes||[]).map(function(n){return vn.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,t,n,!0)})}else i(H,$n,ne,!0);return n!==1/0?n-1:0},[H,$n,ne,Y,en,fn,rn,sn,vn]);if(rn)if("left"===Y){var ie=null===(D=H.refIndexes)||void 0===D?void 0:D[0],oe=vn.findIndex(function(n){return n.selfIndex===ie});ne=-1!==oe?vn[oe]:Zn(vn,H.id)}else{var te=null===(P=H.refIndexes)||void 0===P?void 0:P[0],le=sn.findIndex(function(n){return n.selfIndex===te});$n=-1!==le?sn[le]:Zn(sn,H.id)}var re="left"===Y?!ne:!$n,de=rn&&"right"===Y&&y(H,sn),ae=Vn||(null==$n?void 0:$n.evaluationResult)||(null==ne?void 0:ne.evaluationResult),ue=null!==(G=null===(K=null===(z=null==ae?void 0:ae.evaluation_outputs)||void 0===z?void 0:z.metadata)||void 0===K?void 0:K.label_color)&&void 0!==G?G:F,ce=b(ue).highlightBg,se=(null==ae?void 0:ae.deviations)||{},ve=t.useMemo(function(){return rn&&"right"===Y?w(sn,Jn,fn):new Map},[rn,Y,sn,Jn,fn]),fe=H.nodeId||H.id;if(rn&&"left"!==Y){var pe=sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(H.selfIndex)});pe.length>0?fe=pe[0].nodeId||pe[0].id:(null==$n?void 0:$n.id)&&(fe=$n.nodeId||$n.id)}var he=t.useMemo(function(){var n,e=new Map;if(!rn||"right"!==Y)return e;var i=1,o=sn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(H.selfIndex)}),t=1===o.length&&1===(null===(n=o[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return x(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?o[0]:Zn(sn,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(t){var d=function(n,e){if(void 0===e&&(e=!1),n){var o=r(n,e),t=o.lhsNode,a=o.evalResult,u=o.registryNodeId,c=l(n.content);Object.entries((null==a?void 0:a.deviations)||{}).forEach(function(n){var e=n[0],o=n[1],r=o[en],d=l(r);if(!!t&&!R(o[Un])&&d&&M(c,d)){var a="".concat(u).concat(S).concat(e),s=fn[a];null!=s&&(i=Math.max(i,Math.max(1,s-(ee||0))+1))}}),(n.subsections||[]).forEach(function(n){return d(n)})}};d(H,!0)}var a=function(n,o){if(void 0===o&&(o=!1),n){var t=r(n,o),d=t.lhsNode,u=t.evalResult,c=t.registryNodeId,s=(null==u?void 0:u.deviations)||{},v=l(n.content);Object.entries(s).map(function(n){var e,i,o,t=n[0],r=n[1],a=r[en],u=!d||R(r[Un]),s=l(a),f=s&&null!==(i=null===(e=M(v,s))||void 0===e?void 0:e.start)&&void 0!==i?i:-1,p="".concat(c).concat(S).concat(t);return{refId:p,isRenderable:u&&!!s&&!R(a),position:f,registryIndex:null!==(o=fn[p])&&void 0!==o?o:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return a(n)})}};return a(H,!0),e},[rn,Y,H,sn,en,Un,fn,ee]),ge=Object.keys(se)[0],me=ge?"".concat(fe).concat(S).concat(ge):null,xe=me?null==pn?void 0:pn[me]:null,Ie=V+1;if(rn&&Mn){var ye="left"===Y?Mn.leftNums.get(null==H?void 0:H.id):Mn.rightNums.get(null==H?void 0:H.id);re&&void 0!==ye?Ie=ye:null!=xe&&xe>=0?Ie=xe:void 0!==ye&&(Ie=ye)}else null!=xe&&xe>=0&&(Ie=xe);var be=Math.max.apply(Math,n([0],Object.keys(se).map(function(n){return fn["".concat(fe).concat(S).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,we=Object.entries(se).map(function(n){var e,i=n[0],o=n[1],t="".concat(fe).concat(S).concat(i);return{deviationKey:i,deviationMap:o,refId:t,currentIndex:null!==(e=fn[t])&&void 0!==e?e:be++}});we.sort(function(n,e){return n.currentIndex-e.currentIndex});var Se,Re,_e=we.map(function(n){var i,o,t,l,r,d,a=n.deviationKey,u=n.deviationMap,c=n.refId,s=n.currentIndex,v=u[en],f=R(v);if(f)v="";else if(!v)return null;var p=V,h=V;if(rn)if("left"===Y){var g=null===(i=H.refIndexes)||void 0===i?void 0:i[0],m=vn.findIndex(function(n){return n.selfIndex===g});if(-1!==m)h=m;else{var x=vn.findIndex(function(n){return n.id===H.id||n.nodeId===H.nodeId||n.contentId===H.contentId});h=-1!==x?x:V}}else{var I=null===(o=H.refIndexes)||void 0===o?void 0:o[0],y=sn.findIndex(function(n){return n.selfIndex===I});if(-1!==y)p=y;else p=-1!==(A=sn.findIndex(function(n){return n.id===H.id||n.nodeId===H.nodeId||n.contentId===H.contentId}))?A:V}var w="".concat(fe).concat(S).concat(a).concat(S).concat(p).concat(S).concat(h),M=u[Un],F=re||R(M),k=he.get(c),N=ve.get(c);rn&&"right"===Y&&F&&void 0!==k?s=k:rn&&"right"===Y&&!F&&void 0!==N?s=N:rn&&void 0!==ee&&("right"!==Y||F||de)&&(s-=ee),s=Math.max(1,s);var B=rn&&"right"===Y&&F&&Mn?_({section:H,proposedSections:sn,leftNums:Mn.leftNums,fallbackNumber:String(Ie),firstOnly:!0}):Ie,C="".concat(B,".").concat(s),E=V;if("right"===Y&&rn){var A,O=null===(t=H.refIndexes)||void 0===t?void 0:t[0],j=sn.findIndex(function(n){return n.selfIndex===O});if(-1!==j)E=j;else-1!==(A=sn.findIndex(function(n){return n.id===H.id||n.nodeId===H.nodeId||n.contentId===H.contentId}))&&(E=A)}var W=mn?mn(E):null,T=(null==u?void 0:u.evaluation_outputs)||(null==ae?void 0:ae.evaluation_outputs),D=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,P=null!==(d=null===(r=null==T?void 0:T.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:ue,z=b(P),K=W?e(e({},W),{badgeBg:z.badgeBg,badgeBorder:z.badgeBorder,badgeText:z.badgeText}):e({},z),G=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==ae?void 0:ae.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==ae?void 0:ae.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==ae?void 0:ae.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==ae?void 0:ae.cognitive_decisioning)}:null,L=0,X=Dn||"";if(v&&X){var q=X.split(/\n{2,}/),J=q.findIndex(function(n){return n.includes(v)});if(-1!==J){var Q=Object.entries(se).filter(function(n){n[0];var e=n[1][en];return e&&q[J].includes(e)}).sort(function(n,e){return q[J].indexOf(n[1][en])-q[J].indexOf(e[1][en])}),U=Q.filter(function(n){n[0];var e=n[1][en];return e&&(e.includes(v)||v.includes(e))});U.length>1&&(L=Math.max(0,U.findIndex(function(n){return n[0]===a})))}}var Z=hn(Y,c);return{id:c,actionId:w,label:C,highlight:v,side:Y,style:K,stackIndex:L,score:D,isConnected:null==xn?void 0:xn.has(w),showScrollLockToggle:(null==xn?void 0:xn.has(w))||Sn&&Rn===w||!!kn&&kn===Z.current,scrollSyncLocked:_n,toggleScrollSyncLocked:Fn,isOrphan:F,isMissingClause:f,badgeRef:Z,onClick:function(n){n.stopPropagation(),In&&In(n,$n||{id:"orphan-left",title:"",content:""},F,ne||{id:"orphan-right",title:"",content:""},w,K)},onSummaryClick:function(n){n.stopPropagation(),gn(n,w,F,G)}}}).filter(Boolean),Me=an||Cn?_e:[],Fe=_e.map(function(n){return n.highlight}).filter(Boolean),ke=H.id&&Y===(null==$?void 0:$.columnKey)?$:null,Ne=t.useRef(!1);return l(function(){U||(Ne.current=!1)},[U]),i(r,e({ref:q,sx:{mb:Q,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[U&&(null==ke?void 0:ke.showAbove)&&o("div",e({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ke?void 0:ke.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===Y?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===Y?{right:"-20px"}:{left:"-20px"})},{children:o(v,{color:(null===(L=null==ke?void 0:ke.showAboveRef)||void 0===L?void 0:L.current)?window.getComputedStyle(ke.showAboveRef.current).color:void 0})}))})),i(d,e({disableGutters:!0,expanded:!Gn&&U,onChange:function(){Gn||(Z(),tn.current=H.id)},sx:{boxShadow:"none",border:Gn?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Gn?"#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:[o(a,e({expandIcon:Gn?null:o(f,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Gn?"default":"pointer","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"},"& .MuiAccordionSummary-expandIconWrapper":{transition:"transform 0.2s ease"},"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded":{transform:"rotate(180deg)"}}},{children:Bn&&o(u,e({title:Ln,placement:"top"},{children:o(c,e({component:"div",sx:{fontSize:"12px",color:Gn?"#94A3B8":"#19213D",fontWeight:Gn?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Se=Hn,Re=Xn,void 0===Re&&(Re=!1),Se?x(Se).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,t){return n.startsWith("**")&&n.endsWith("**")?o("strong",{children:n.slice(2,-2)},t):i("div",e({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[o("span",e({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:n})),Re&&o("span",e({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",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!Gn&&i(s,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Kn&&o(p,{content:Dn,overlayContent:Pn,fallbackContent:zn,sxStyles:ln,highlights:Fe,maintainRelativeOrder:rn,highlightBg:ce,suppressHighlightBg:On,deviationBadges:Me,collisionKey:Nn}),(H.subsections||[]).map(function(n,e){return un({section:n,keyPath:"".concat(V,"-").concat(e),depth:0,columnKey:Y,parentNodeId:en,sectionOffset:ee,rhsOrphanVisualIndexes:he})})]}))]})),U&&(null==ke?void 0:ke.showBelow)&&o("div",e({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==ke?void 0:ke.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===Y?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===Y?{right:"-20px"}:{left:"-20px"})},{children:o(f,{color:(null===(X=null==ke?void 0:ke.showBelowRef)||void 0===X?void 0:X.current)?window.getComputedStyle(ke.showBelowRef.current).color:void 0})}))}))]}),"".concat(Y,"-sec-").concat(V))};export{N as default};
1
+ import{__spreadArray as n,__assign as e}from"tslib";import{jsxs as i,jsx as o}from"react/jsx-runtime";import t,{useEffect as l}from"react";import{Box as r,Accordion as d,AccordionSummary as a,Tooltip as u,Typography as c,AccordionDetails as s}from"@mui/material";import{ChevronUp as v,ChevronDown as f}from"lucide-react";import{MemoizedMarkdown as p}from"../hooks/memoizedMarkdown.js";import{useCompareContext as h}from"../CompareContext.js";import{hasValue as g,hasMeaningfulRedlineTags as m,safeStringify as x,stripRedlineTags as I,hasSingleMappedLhsSection as y,generateColorPalette as b,getLhsDeviationDisplayIndexes as w,DEVIATION_BADGE_SEPARATOR as S,isMissingStr as R,getRhsMappedSectionNumber as M,findTextMatchRange as _}from"../CognitiveComparehelpers.js";import{findTextRangeWithFormatting as k}from"../utils/normalizeInlineMarkdown.js";import{DEFAULT_DEVIAION_COLOR as F}from"../CognitiveCompareConstants.js";import{normalizeRedlineMarkdown as N}from"../utils/normalizeRedlineMarkdown.js";var B=function(B){var C,E,A,O,j,W,T,D,P,z,K,G,L,X,H,V=B.section,Y=B.idx,q=B.columnKey,J=B.colRef,Q=B.mb,U=void 0===Q?1:Q,Z=B.isExpanded,$=B.onToggle,nn=B.navigation,en=B.parentNodeId,on=void 0===en?"":en,tn=h(),ln=tn.showOpenNodeRef,rn=tn.resolvedMarkdownStyles,dn=tn.maintainRelativeOrder,an=tn.showDeviationBadges,un=void 0!==an&&an,cn=tn.renderSubSectionAccordion,sn=tn.treeData,vn=tn.proposedSections,fn=tn.existingSections,pn=tn.deviationNumberRegistry,hn=tn.deviationParentRegistry,gn=tn.getBadgeRef,mn=tn.openSummaryPopup,xn=tn.getSectionCompareStyle,In=tn.connectedSections,yn=tn.openMoreFunctionsPopup,bn=tn.isProposingFix,wn=tn.proposingFixNodeId,Sn=tn.isRedlineFlow,Rn=tn.isSideBySide,Mn=tn.activeSideBySideSection,_n=tn.scrollSyncLocked,kn=tn.unifiedNumbering,Fn=tn.toggleScrollSyncLocked,Nn=tn.summaryPopupAnchorEl,Bn="".concat(Rn?"1":"0","-").concat(String(null!=Mn?Mn:"")),Cn=(null===(C=V.displayTitle)||void 0===C||C)&&g(V.title),En=!(!bn||!wn||"left"!==q||V.id!==wn&&V.nodeId!==wn&&V.contentId!==wn),An=m(V.content),On="boolean"==typeof Sn?Sn:An,jn=An,Wn=V.change_history,Tn=On&&An,Dn=t.useMemo(function(){return Tn?N(x(V.content)):x(V.content)},[V.content,Tn]),Pn=Tn?I(Dn):V.content,zn=Tn?Dn:void 0,Kn=An&&g(Wn)?x(Wn):void 0,Gn=(null===(E=V.displayContent)||void 0===E||E||An)&&g(V.content),Ln=!Cn&&!Gn,Xn=V.title;Cn||(Xn=Gn?"No Title Found":"No Matching Section Found");var Hn="left"===q&&(V.isMultipleMapping||(null!==(O=null===(A=V.refContentIds)||void 0===A?void 0:A.length)&&void 0!==O?O:1)>1),Vn="left"===q&&Xn.length>29?"".concat(Xn.slice(0,29).trimEnd(),"..."):Xn,Yn=V.evaluationResult;if(!Yn&&"right"===q)if(dn){var qn=null===(j=V.refIndexes)||void 0===j?void 0:j[0],Jn=vn.find(function(n){return n.selfIndex===qn});Yn=null==Jn?void 0:Jn.evaluationResult}else Yn=null===(W=vn[Y])||void 0===W?void 0:W.evaluationResult;var Qn=null===(T=null==sn?void 0:sn.input_index_map)||void 0===T?void 0:T[0],Un=null===(D=null==sn?void 0:sn.input_index_map)||void 0===D?void 0:D[1],Zn="left"===q?Un:Qn,$n=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 r=$n(l.subsections,e);if(r)return r}}return null},ne="left"===q?V:$n(vn,V.id),ee="right"===q?V:$n(fn,V.id),ie=t.useMemo(function(){if(!dn)return 0;var n=1/0,e=function(n){var e=x(n||"").replace(/\\n/g,"\n");return m(e)?I(N(e)):e},i=function(o,t,l,r){if(o){var d=o.nodeId||o.id;if(r&&"right"===q){var a=vn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(o.selfIndex)});a.length>0&&(d=a[0].nodeId||a[0].id)}var u=o.nodeId||o.id||(null==t?void 0:t.nodeId)||(null==t?void 0:t.id)||(null==l?void 0:l.nodeId)||(null==l?void 0:l.id),c=o.evaluationResult||(null==t?void 0:t.evaluationResult)||(null==l?void 0:l.evaluationResult),s=(null==c?void 0:c.deviations)||{};Object.keys(s).forEach(function(i){var r,a=null===(r=s[i])||void 0===r?void 0:r[on];if(function(n,i){if("string"!=typeof i||R(i))return!1;var o=e(null==n?void 0:n.content),t=e(i);return!!t&&!!_(o,t)}("left"===q?t||o:l||o,a)){var c="".concat(d).concat(S).concat(i),v=null==pn?void 0:pn[c];null!=v&&v<n&&(n=v);var f="".concat(u).concat(S).concat(i),p=null==pn?void 0:pn[f];null!=p&&p<n&&(n=p)}});for(var v=o.subsections||[],f=(null==t?void 0:t.subsections)||[],p=(null==l?void 0:l.subsections)||[],h=Math.max(v.length,f.length,p.length),g=0;g<h;g++)i(v[g],f[g],p[g],!1)}},o="right"===q?vn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(V.selfIndex)}):[];if(1===o.length){var t=o[0];(t.refIndexes||[]).map(function(n){return fn.find(function(e){return e.selfIndex===n})}).filter(Boolean).forEach(function(n){i(n,t,n,!0)})}else i(V,ne,ee,!0);return n!==1/0?n-1:0},[V,ne,ee,q,on,pn,dn,vn,fn]);if(dn)if("left"===q){var oe=null===(P=V.refIndexes)||void 0===P?void 0:P[0],te=fn.findIndex(function(n){return n.selfIndex===oe});ee=-1!==te?fn[te]:$n(fn,V.id)}else{var le=null===(z=V.refIndexes)||void 0===z?void 0:z[0],re=vn.findIndex(function(n){return n.selfIndex===le});ne=-1!==re?vn[re]:$n(vn,V.id)}var de="left"===q?!ee:!ne,ae=dn&&"right"===q&&y(V,vn),ue=Yn||(null==ne?void 0:ne.evaluationResult)||(null==ee?void 0:ee.evaluationResult),ce=null!==(L=null===(G=null===(K=null==ue?void 0:ue.evaluation_outputs)||void 0===K?void 0:K.metadata)||void 0===G?void 0:G.label_color)&&void 0!==L?L:F,se=b(ce).highlightBg,ve=(null==ue?void 0:ue.deviations)||{},fe=t.useMemo(function(){return dn&&"right"===q?w(vn,Qn,pn):new Map},[dn,q,vn,Qn,pn]),pe=V.nodeId||V.id;if(dn&&"left"!==q){var he=vn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(V.selfIndex)});he.length>0?pe=he[0].nodeId||he[0].id:(null==ne?void 0:ne.id)&&(pe=ne.nodeId||ne.id)}var ge=t.useMemo(function(){var n,e=new Map;if(!dn||"right"!==q)return e;var i=1,o=vn.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(V.selfIndex)}),t=1===o.length&&1===(null===(n=o[0].refIndexes)||void 0===n?void 0:n.length),l=function(n){return x(n||"").replace(/\\n/g,"\n")},r=function(n,e){var i=e?o[0]:$n(vn,n.nodeId||n.id||n.contentId);return{lhsNode:i,evalResult:n.evaluationResult||(null==i?void 0:i.evaluationResult),registryNodeId:i?i.nodeId||i.id:n.nodeId||n.id}};if(t){var d=function(n,e){if(void 0===e&&(e=!1),n){var o=r(n,e),t=o.lhsNode,a=o.evalResult,u=o.registryNodeId,c=l(n.content);Object.entries((null==a?void 0:a.deviations)||{}).forEach(function(n){var e=n[0],o=n[1],r=o[on],d=l(r);if(!!t&&!R(o[Zn])&&d&&_(c,d)){var a="".concat(u).concat(S).concat(e),s=pn[a];null!=s&&(i=Math.max(i,Math.max(1,s-(ie||0))+1))}}),(n.subsections||[]).forEach(function(n){return d(n)})}};d(V,!0)}var a=function(n,o){if(void 0===o&&(o=!1),n){var t=r(n,o),d=t.lhsNode,u=t.evalResult,c=t.registryNodeId,s=(null==u?void 0:u.deviations)||{},v=l(n.content);Object.entries(s).map(function(n){var e,i,o,t,r,a=n[0],u=n[1],s=u[on],f=!d||R(u[Zn]),p=l(s),h=-1;p&&-1===(h=null!==(i=null===(e=_(v,p))||void 0===e?void 0:e.start)&&void 0!==i?i:-1)&&(h=null!==(t=null===(o=k(v,p))||void 0===o?void 0:o.start)&&void 0!==t?t:-1);var g="".concat(c).concat(S).concat(a);return{refId:g,isRenderable:f&&!!p&&!R(s),position:h,registryIndex:null!==(r=pn[g])&&void 0!==r?r:Number.MAX_SAFE_INTEGER}}).filter(function(n){return n.isRenderable}).sort(function(n,e){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===e.position?Number.MAX_SAFE_INTEGER:e.position)||n.registryIndex-e.registryIndex}).forEach(function(n){e.set(n.refId,i++)}),(n.subsections||[]).forEach(function(n){return a(n)})}};return a(V,!0),e},[dn,q,V,vn,on,Zn,pn,ie]),me=Object.keys(ve)[0],xe=me?"".concat(pe).concat(S).concat(me):null,Ie=xe?null==hn?void 0:hn[xe]:null,ye=Y+1;if(dn&&kn){var be="left"===q?kn.leftNums.get(null==V?void 0:V.id):kn.rightNums.get(null==V?void 0:V.id);de&&void 0!==be?ye=be:null!=Ie&&Ie>=0?ye=Ie:void 0!==be&&(ye=be)}else null!=Ie&&Ie>=0&&(ye=Ie);var we=Math.max.apply(Math,n([0],Object.keys(ve).map(function(n){return pn["".concat(pe).concat(S).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,Se=Object.entries(ve).map(function(n){var e,i=n[0],o=n[1],t="".concat(pe).concat(S).concat(i);return{deviationKey:i,deviationMap:o,refId:t,currentIndex:null!==(e=pn[t])&&void 0!==e?e:we++}});Se.sort(function(n,e){return n.currentIndex-e.currentIndex});var Re,Me,_e=Se.map(function(n){var i,o,t,l,r,d,a=n.deviationKey,u=n.deviationMap,c=n.refId,s=n.currentIndex,v=u[on],f=R(v);if(f)v="";else if(!v)return null;var p=Y,h=Y;if(dn)if("left"===q){var g=null===(i=V.refIndexes)||void 0===i?void 0:i[0],m=fn.findIndex(function(n){return n.selfIndex===g});if(-1!==m)h=m;else{var x=fn.findIndex(function(n){return n.id===V.id||n.nodeId===V.nodeId||n.contentId===V.contentId});h=-1!==x?x:Y}}else{var I=null===(o=V.refIndexes)||void 0===o?void 0:o[0],y=vn.findIndex(function(n){return n.selfIndex===I});if(-1!==y)p=y;else p=-1!==(A=vn.findIndex(function(n){return n.id===V.id||n.nodeId===V.nodeId||n.contentId===V.contentId}))?A:Y}var w="".concat(pe).concat(S).concat(a).concat(S).concat(p).concat(S).concat(h),_=u[Zn],k=de||R(_),F=ge.get(c),N=fe.get(c);dn&&"right"===q&&k&&void 0!==F?s=F:dn&&"right"===q&&!k&&void 0!==N?s=N:dn&&void 0!==ie&&("right"!==q||k||ae)&&(s-=ie),s=Math.max(1,s);var B=dn&&"right"===q&&k&&kn?M({section:V,proposedSections:vn,leftNums:kn.leftNums,fallbackNumber:String(ye),firstOnly:!0}):ye,C="".concat(B,".").concat(s),E=Y;if("right"===q&&dn){var A,O=null===(t=V.refIndexes)||void 0===t?void 0:t[0],j=vn.findIndex(function(n){return n.selfIndex===O});if(-1!==j)E=j;else-1!==(A=vn.findIndex(function(n){return n.id===V.id||n.nodeId===V.nodeId||n.contentId===V.contentId}))&&(E=A)}var W=xn?xn(E):null,T=(null==u?void 0:u.evaluation_outputs)||(null==ue?void 0:ue.evaluation_outputs),D=null!==(l=null==T?void 0:T.output_value)&&void 0!==l?l:null,P=null!==(d=null===(r=null==T?void 0:T.metadata)||void 0===r?void 0:r.label_color)&&void 0!==d?d:ce,z=b(P),K=W?e(e({},W),{badgeBg:z.badgeBg,badgeBorder:z.badgeBorder,badgeText:z.badgeText}):e({},z),G=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==ue?void 0:ue.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==ue?void 0:ue.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==ue?void 0:ue.deviation_explanation),evaluation_outputs:T,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==ue?void 0:ue.cognitive_decisioning)}:null,L=0,X=Pn||"";if(v&&X){var H=X.split(/\n{2,}/),J=H.findIndex(function(n){return n.includes(v)});if(-1!==J){var Q=Object.entries(ve).filter(function(n){n[0];var e=n[1][on];return e&&H[J].includes(e)}).sort(function(n,e){return H[J].indexOf(n[1][on])-H[J].indexOf(e[1][on])}),U=Q.filter(function(n){n[0];var e=n[1][on];return e&&(e.includes(v)||v.includes(e))});U.length>1&&(L=Math.max(0,U.findIndex(function(n){return n[0]===a})))}}var Z=gn(q,c);return{id:c,actionId:w,label:C,highlight:v,side:q,style:K,stackIndex:L,score:D,isConnected:null==In?void 0:In.has(w),showScrollLockToggle:(null==In?void 0:In.has(w))||Rn&&Mn===w||!!Nn&&Nn===Z.current,scrollSyncLocked:_n,toggleScrollSyncLocked:Fn,isOrphan:k,isMissingClause:f,badgeRef:Z,onClick:function(n){n.stopPropagation(),yn&&yn(n,ne||{id:"orphan-left",title:"",content:""},k,ee||{id:"orphan-right",title:"",content:""},w,K)},onSummaryClick:function(n){n.stopPropagation(),mn(n,w,k,G)}}}).filter(Boolean),ke=un||En?_e:[],Fe=_e.map(function(n){return n.highlight}).filter(Boolean),Ne=V.id&&q===(null==nn?void 0:nn.columnKey)?nn:null,Be=t.useRef(!1);return l(function(){Z||(Be.current=!1)},[Z]),i(r,e({ref:J,sx:{mb:U,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[Z&&(null==Ne?void 0:Ne.showAbove)&&o("div",e({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==Ne?void 0:Ne.showAboveRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===q?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===q?{right:"-20px"}:{left:"-20px"})},{children:o(v,{color:(null===(X=null==Ne?void 0:Ne.showAboveRef)||void 0===X?void 0:X.current)?window.getComputedStyle(Ne.showAboveRef.current).color:void 0})}))})),i(d,e({disableGutters:!0,expanded:!Ln&&Z,onChange:function(){Ln||($(),ln.current=V.id)},sx:{boxShadow:"none",border:Ln?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Ln?"#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:[o(a,e({expandIcon:Ln?null:o(f,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Ln?"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:Cn&&o(u,e({title:Xn,placement:"top"},{children:o(c,e({component:"div",sx:{fontSize:"12px",color:Ln?"#94A3B8":"#19213D",fontWeight:Ln?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Re=Vn,Me=Hn,void 0===Me&&(Me=!1),Re?x(Re).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(n,t){return n.startsWith("**")&&n.endsWith("**")?o("strong",{children:n.slice(2,-2)},t):i("div",e({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",width:"100%"}},{children:[o("span",e({style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:n})),Me&&o("span",e({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",flexShrink:0,lineHeight:1.4,marginRight:"4px"}},{children:"Multiple"}))]}),t)}):null)}))}))})),!Ln&&i(s,e({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[Gn&&o(p,{content:Pn,overlayContent:zn,fallbackContent:Kn,sxStyles:rn,highlights:Fe,maintainRelativeOrder:dn,highlightBg:se,suppressHighlightBg:jn,deviationBadges:ke,collisionKey:Bn}),(V.subsections||[]).map(function(n,e){return cn({section:n,keyPath:"".concat(Y,"-").concat(e),depth:0,columnKey:q,parentNodeId:on,sectionOffset:ie,rhsOrphanVisualIndexes:ge})})]}))]})),Z&&(null==Ne?void 0:Ne.showBelow)&&o("div",e({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var n,e;return null===(e=null===(n=null==Ne?void 0:Ne.showBelowRef)||void 0===n?void 0:n.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})}},{children:o("div",e({style:e({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===q?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===q?{right:"-20px"}:{left:"-20px"})},{children:o(f,{color:(null===(H=null==Ne?void 0:Ne.showBelowRef)||void 0===H?void 0:H.current)?window.getComputedStyle(Ne.showBelowRef.current).color:void 0})}))}))]}),"".concat(q,"-sec-").concat(Y))};export{B as default};
2
2
  //# sourceMappingURL=SectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as n,__assign as i}from"tslib";import{jsx as e,jsxs as t}from"react/jsx-runtime";import o,{useMemo as l}from"react";import{Box as d,Accordion as r,AccordionSummary as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronDown as s}from"lucide-react";import{MemoizedMarkdown as v}from"../hooks/memoizedMarkdown.js";import{useCompareContext as f}from"../CompareContext.js";import{hasValue as p,hasMeaningfulRedlineTags as h,safeStringify as m,stripRedlineTags as g,hasSingleMappedLhsSection as x,getLhsDeviationDisplayIndexes as y,generateColorPalette as S,DEVIATION_BADGE_SEPARATOR as b,isMissingStr as I,findTextMatchRange as _,getRhsMappedSectionNumber as k}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";import{normalizeRedlineMarkdown as C}from"../utils/normalizeRedlineMarkdown.js";var N=o.memo(function(o){var F,M,O,P,B,R,E,j,A,K,W=o.section,L=o.keyPath,T=o.depth,z=void 0===T?0:T,D=o.columnKey,G=void 0===D?"left":D,H=o.parentNodeId,V=void 0===H?"":H,X=o.sectionOffset,U=o.rhsOrphanVisualIndexes,q=f(),J=q.expandedSubSections,Q=q.setExpandedSubSections,Y=q.maintainRelativeOrder,Z=q.showDeviationBadges,$=void 0!==Z&&Z,nn=q.proposedSections,en=q.existingSections,tn=q.treeData,on=q.deviationNumberRegistry,ln=q.deviationParentRegistry,dn=q.connectedSections,rn=q.activeSideBySideSection,an=q.isSideBySide,un=q.scrollSyncLocked,cn=q.toggleScrollSyncLocked,sn=q.summaryPopupAnchorEl,vn=q.resolvedMarkdownStyles,fn=q.getSubSectionRef,pn=q.getSubSectionCompareStyle,hn=q.getBadgeRef,mn=q.openMoreFunctionsPopup,gn=q.openSummaryPopup,xn=q.resetSideBySide,yn=q.setConnectedSections,Sn=q.setConnectedLines,bn=q.cachedConnectedPositions,In=q.isProposingFix,_n=q.proposingFixNodeId,kn=q.isRedlineFlow,wn=q.unifiedNumbering,Cn=null!=rn?rn:"",Nn=(null===(F=W.displayTitle)||void 0===F||F)&&p(W.title),Fn=!(!In||!_n||"left"!==G||W.id!==_n&&W.nodeId!==_n&&W.contentId!==_n),Mn=h(W.content),On="boolean"==typeof kn?kn:Mn,Pn=Mn,Bn=W.change_history,Rn=On&&Mn,En=l(function(){return Rn?C(m(W.content)):m(W.content)},[W.content,Rn]),jn=Rn?g(En):W.content,An=Rn?En:void 0,Kn=Mn&&p(Bn)?m(Bn):void 0,Wn=(null===(M=W.displayContent)||void 0===M||M||Mn)&&p(W.content),Ln=!Nn&&!Wn,Tn=Nn?W.title:Wn?"No Title Found":"No Matching Section Found",zn=!!J[L],Dn=fn(G,L),Gn=L.split("-").map(Number)[0],Hn=nn[Gn],Vn=en[Gn],Xn=Gn,Un=Gn,qn=!1,Jn=function(n,i,e){if(!n||!i)return null;if(n.id===i||n.nodeId===i||n.contentId===i)return{section:n,keyPath:e};for(var t=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(e,"-").concat(i)}}),o=function(){var n=t.shift();return(null==n?void 0:n.section)?n.section.id===i||n.section.nodeId===i||n.section.contentId===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,e){t.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(e)})}):"continue"};t.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(Y)if("left"===G){var Qn=null===(O=null==Hn?void 0:Hn.refIndexes)||void 0===O?void 0:O[0],Yn=en.findIndex(function(n){return n.selfIndex===Qn});-1!==Yn?(Vn=en[Yn],Un=Yn):qn=!0}else{var Zn=null===(P=null==Vn?void 0:Vn.refIndexes)||void 0===P?void 0:P[0],$n=nn.findIndex(function(n){return n.selfIndex===Zn});-1!==$n?(Hn=nn[$n],Xn=$n):qn=!0}var ni=function(n,i){if(!i||!n)return null;for(var e=0;e<n.length;e++){var t=Jn(n[e],i,String(e));if(t)return t}return null},ii=null,ei=null,ti="",oi="";if(Y)"left"===G?(ii=W,ti=L,(li=Jn(Vn,W.nodeId||W.id,String(Un)))||(li=ni(en,W.nodeId||W.id)),ei=(null==li?void 0:li.section)||null,oi=(null==li?void 0:li.keyPath)||""):(ei=W,oi=L,(di=Jn(Hn,W.nodeId||W.id,String(Xn)))||(di=ni(nn,W.nodeId||W.id)),ii=(null==di?void 0:di.section)||null,ti=(null==di?void 0:di.keyPath)||"");else if("left"===G){ii=W,ti=L;var li=ni(en,W.nodeId||W.id);ei=(null==li?void 0:li.section)||null,oi=(null==li?void 0:li.keyPath)||""}else{ei=W,oi=L;var di=ni(nn,W.nodeId||W.id);ii=(null==di?void 0:di.section)||null,ti=(null==di?void 0:di.keyPath)||""}var ri=(ti?pn(ti):null)||pn(L),ai=null===(B=null==tn?void 0:tn.input_index_map)||void 0===B?void 0:B[0],ui=null===(R=null==tn?void 0:tn.input_index_map)||void 0===R?void 0:R[1],ci="left"===G?ui:ai,si="left"===G?!ei:!ii,vi=Y&&"right"===G&&x(Vn,nn),fi=W.evaluationResult||(null==ii?void 0:ii.evaluationResult)||(null==ei?void 0:ei.evaluationResult),pi=(null==fi?void 0:fi.deviations)||{},hi=l(function(){return Y&&"right"===G?y(nn,ai,on):new Map},[Y,G,nn,ai,on]),mi=W.nodeId||W.id||(null==ii?void 0:ii.nodeId)||(null==ii?void 0:ii.id)||(null==ei?void 0:ei.nodeId)||(null==ei?void 0:ei.id);Y&&"left"!==G&&(null==ii?void 0:ii.id)&&(mi=ii.nodeId||ii.id);var gi=Object.keys(pi)[0],xi=gi?"".concat(mi).concat(b).concat(gi):null,yi=xi?null==ln?void 0:ln[xi]:null,Si=Gn+1;if(Y&&wn){var bi="left"===G?wn.leftNums.get(null==Hn?void 0:Hn.id):wn.rightNums.get(null==Vn?void 0:Vn.id);qn&&void 0!==bi?Si=bi:null!=yi&&yi>=0?Si=yi:void 0!==bi&&(Si=bi)}else null!=yi&&yi>=0&&(Si=yi);var Ii=null!==(A=null===(j=null===(E=null==fi?void 0:fi.evaluation_outputs)||void 0===E?void 0:E.metadata)||void 0===j?void 0:j.label_color)&&void 0!==A?A:w,_i=S(Ii).highlightBg,ki=Math.max.apply(Math,n([0],Object.keys(pi).map(function(n){return on["".concat(mi).concat(b).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,wi=Object.entries(pi).map(function(n){var i,e=n[0],t=n[1],o="".concat(mi).concat(b).concat(e);return{deviationKey:e,deviationMap:t,refId:o,currentIndex:null!==(i=on[o])&&void 0!==i?i:ki++}});wi.sort(function(n,i){return n.currentIndex-i.currentIndex});var Ci=new Map;if(!U&&Y&&"right"===G){var Ni=m(jn||"").replace(/\\n/g,"\n");wi.filter(function(n){var i=n.deviationMap,e=i[V];return(si||I(i[ci]))&&!!e&&!I(e)}).map(function(n){var e,t,o=m(n.deviationMap[V]||"").replace(/\\n/g,"\n"),l=o&&null!==(t=null===(e=_(Ni,o))||void 0===e?void 0:e.start)&&void 0!==t?t:-1;return i(i({},n),{position:l})}).sort(function(n,i){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===i.position?Number.MAX_SAFE_INTEGER:i.position)||n.currentIndex-i.currentIndex}).forEach(function(n,i){Ci.set(n.refId,i+1)})}var Fi=wi.map(function(n){var e,t,o,l,d=n.deviationKey,r=n.deviationMap,a=n.refId,u=n.currentIndex,c=r[V],s=I(c);if(s)c="";else if(!c)return null;var v=r[ci],f=si||I(v),p=null!==(e=null==U?void 0:U.get(a))&&void 0!==e?e:Ci.get(a),h=hi.get(a);Y&&"right"===G&&f&&void 0!==p?u=p:Y&&"right"===G&&!f&&void 0!==h?u=h:Y&&void 0!==X&&("right"!==G||f||vi)&&(u-=X),u=Math.max(1,u);var m=Y&&"right"===G&&f&&wn?k({section:Vn,proposedSections:nn,leftNums:wn.leftNums,fallbackNumber:String(Si),firstOnly:!0}):Si,g="".concat(m,".").concat(u),x="".concat(mi).concat(b).concat(d).concat(b).concat(ti).concat(b).concat(oi),y=(null==r?void 0:r.evaluation_outputs)||(null==fi?void 0:fi.evaluation_outputs),_=null!==(t=null==y?void 0:y.output_value)&&void 0!==t?t:null,w=null!==(l=null===(o=null==y?void 0:y.metadata)||void 0===o?void 0:o.label_color)&&void 0!==l?l:Ii,C=S(w),N=i({},C),F=(null==r?void 0:r.deviation_summary)?{deviation_summary:r.deviation_summary||(null==fi?void 0:fi.deviation_summary),deviation_title:(null==r?void 0:r.deviation_title)||(null==fi?void 0:fi.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==fi?void 0:fi.deviation_impact),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==fi?void 0:fi.deviation_explanation),evaluation_outputs:y,cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==fi?void 0:fi.cognitive_decisioning)}:null,M=0,O=jn||"";if(c&&O){var P=O.split(/\n{2,}/),B=P.findIndex(function(n){return n.includes(c)});if(-1!==B){var R=Object.entries(pi).filter(function(n){n[0];var i=n[1][V];return i&&P[B].includes(i)}).sort(function(n,i){return P[B].indexOf(n[1][V])-P[B].indexOf(i[1][V])}),E=R.filter(function(n){n[0];var i=n[1][V];return i&&(i.includes(c)||c.includes(i))});E.length>1&&(M=Math.max(0,E.findIndex(function(n){return n[0]===d})))}}var j=hn(G,a);return{id:a,actionId:x,label:g,highlight:c,side:G,style:N,stackIndex:M,score:_,isConnected:dn.has(x),showScrollLockToggle:dn.has(x)||an&&rn===x||!!sn&&sn===j.current,scrollSyncLocked:un,toggleScrollSyncLocked:cn,isOrphan:f,isMissingClause:s,badgeRef:j,onClick:function(n){n.stopPropagation();var e=ti&&nn[Number(ti.split("-")[0])]||Hn,t=oi&&en[Number(oi.split("-")[0])]||Vn,o=ii?i(i({},ii),{title:(null==e?void 0:e.title)||(null==ii?void 0:ii.title)||""}):{id:"orphan-left",title:"",content:""},l=ei?i(i({},ei),{title:(null==t?void 0:t.title)||(null==ei?void 0:ei.title)||""}):{id:"orphan-right",title:"",content:""};mn(n,o,f,l,x,N)},onSummaryClick:function(n){n.stopPropagation(),gn(n,x,f,F)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),Mi=l(function(){var n=new Set;return Fi.filter(function(i){return!n.has(i.id)&&(n.add(i.id),!0)})},[Fi]),Oi=$||Fn?Mi:[],Pi=Mi.map(function(n){return n.highlight}).filter(Boolean),Bi=Fi.find(function(n){return dn.has(n.actionId)}),Ri=!!Bi;if(!(Nn||Wn||W.subsections&&0!==W.subsections.length))return null;var Ei=(null===(K=null==Bi?void 0:Bi.style)||void 0===K?void 0:K.badgeBorder)||(null==ri?void 0:ri.badgeBorder),ji=Ri&&Ei?{borderRadius:"4px",outline:"2px solid ".concat(Ei),outlineOffset:"1px"}:{};return e(d,Nn?i({ref:Dn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:e(d,i({sx:i({width:"100%"},ji)},{children:t(r,i({disableGutters:!0,expanded:!Ln&&zn,onChange:function(){if(!Ln){if(zn){var n=String(rn||""),e=n.includes(ti)||n.includes(oi);e||dn.forEach(function(n){(String(n).includes(ti)||String(n).includes(oi))&&(e=!0)}),e&&(xn(),yn(new Set),Sn([]),bn.current=[])}Q(function(n){var e;return i(i({},n),((e={})[L]=!n[L],e))})}},sx:{mt:0,boxShadow:"none",border:Ln?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[e(a,i({expandIcon:Ln?null:e(s,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:e(u,i({component:"div",sx:{fontSize:"11px",fontWeight:600,color:Ln?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Tn||"Untitled Subsection"}))})),!Ln&&t(c,i({sx:{pt:0,pb:1,minWidth:0}},{children:[Wn&&e(v,{content:jn,overlayContent:An,fallbackContent:Kn,sxStyles:vn,deviationBadges:Oi,maintainRelativeOrder:Y,highlightBg:_i,suppressHighlightBg:Pn,highlights:Pi,collisionKey:Cn}),(W.subsections||[]).map(function(n,i){return e(N,{section:n,keyPath:"".concat(L,"-").concat(i),depth:z+1,columnKey:G,parentNodeId:V,sectionOffset:X,rhsOrphanVisualIndexes:U},"".concat(L,"-").concat(i))})]}))]}))}))}):i({ref:Dn,sx:{mt:0===z?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!Ln&&t(d,i({sx:i({width:"100%"},ji)},{children:[Wn&&e(v,{content:jn,overlayContent:An,fallbackContent:Kn,sxStyles:vn,deviationBadges:Oi,maintainRelativeOrder:Y,highlightBg:_i,suppressHighlightBg:Pn,highlights:Pi,collisionKey:Cn}),(W.subsections||[]).map(function(n,i){return e(N,{section:n,keyPath:"".concat(L,"-").concat(i),depth:z+1,columnKey:G,parentNodeId:V,sectionOffset:X,rhsOrphanVisualIndexes:U},"".concat(L,"-").concat(i))})]}))}))});export{N as default};
1
+ import{__spreadArray as n,__assign as i}from"tslib";import{jsx as t,jsxs as e}from"react/jsx-runtime";import o,{useMemo as l}from"react";import{Box as d,Accordion as r,AccordionSummary as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronDown as s}from"lucide-react";import{MemoizedMarkdown as v}from"../hooks/memoizedMarkdown.js";import{useCompareContext as f}from"../CompareContext.js";import{hasValue as p,hasMeaningfulRedlineTags as h,safeStringify as m,stripRedlineTags as g,hasSingleMappedLhsSection as x,getLhsDeviationDisplayIndexes as y,generateColorPalette as S,DEVIATION_BADGE_SEPARATOR as I,isMissingStr as b,findTextMatchRange as _,getRhsMappedSectionNumber as k}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as w}from"../CognitiveCompareConstants.js";import{normalizeRedlineMarkdown as C}from"../utils/normalizeRedlineMarkdown.js";import{findTextRangeWithFormatting as N}from"../utils/normalizeInlineMarkdown.js";var F=o.memo(function(o){var M,O,P,B,R,E,j,A,K,W,L=o.section,z=o.keyPath,T=o.depth,D=void 0===T?0:T,G=o.columnKey,H=void 0===G?"left":G,V=o.parentNodeId,X=void 0===V?"":V,U=o.sectionOffset,q=o.rhsOrphanVisualIndexes,J=f(),Q=J.expandedSubSections,Y=J.setExpandedSubSections,Z=J.maintainRelativeOrder,$=J.showDeviationBadges,nn=void 0!==$&&$,tn=J.proposedSections,en=J.existingSections,on=J.treeData,ln=J.deviationNumberRegistry,dn=J.deviationParentRegistry,rn=J.connectedSections,an=J.activeSideBySideSection,un=J.isSideBySide,cn=J.scrollSyncLocked,sn=J.toggleScrollSyncLocked,vn=J.summaryPopupAnchorEl,fn=J.resolvedMarkdownStyles,pn=J.getSubSectionRef,hn=J.getSubSectionCompareStyle,mn=J.getBadgeRef,gn=J.openMoreFunctionsPopup,xn=J.openSummaryPopup,yn=J.resetSideBySide,Sn=J.setConnectedSections,In=J.setConnectedLines,bn=J.cachedConnectedPositions,_n=J.isProposingFix,kn=J.proposingFixNodeId,wn=J.isRedlineFlow,Cn=J.unifiedNumbering,Nn=null!=an?an:"",Fn=(null===(M=L.displayTitle)||void 0===M||M)&&p(L.title),Mn=!(!_n||!kn||"left"!==H||L.id!==kn&&L.nodeId!==kn&&L.contentId!==kn),On=h(L.content),Pn="boolean"==typeof wn?wn:On,Bn=On,Rn=L.change_history,En=Pn&&On,jn=l(function(){return En?C(m(L.content)):m(L.content)},[L.content,En]),An=En?g(jn):L.content,Kn=En?jn:void 0,Wn=On&&p(Rn)?m(Rn):void 0,Ln=(null===(O=L.displayContent)||void 0===O||O||On)&&p(L.content),zn=!Fn&&!Ln,Tn=Fn?L.title:Ln?"No Title Found":"No Matching Section Found",Dn=!!Q[z],Gn=pn(H,z),Hn=z.split("-").map(Number)[0],Vn=tn[Hn],Xn=en[Hn],Un=Hn,qn=Hn,Jn=!1,Qn=function(n,i,t){if(!n||!i)return null;if(n.id===i||n.nodeId===i||n.contentId===i)return{section:n,keyPath:t};for(var e=(n.subsections||[]).map(function(n,i){return{section:n,keyPath:"".concat(t,"-").concat(i)}}),o=function(){var n=e.shift();return(null==n?void 0:n.section)?n.section.id===i||n.section.nodeId===i||n.section.contentId===i?{value:n}:void(n.section.subsections||[]).forEach(function(i,t){e.push({section:i,keyPath:"".concat(n.keyPath,"-").concat(t)})}):"continue"};e.length>0;){var l=o();if("object"==typeof l)return l.value}return null};if(Z)if("left"===H){var Yn=null===(P=null==Vn?void 0:Vn.refIndexes)||void 0===P?void 0:P[0],Zn=en.findIndex(function(n){return n.selfIndex===Yn});-1!==Zn?(Xn=en[Zn],qn=Zn):Jn=!0}else{var $n=null===(B=null==Xn?void 0:Xn.refIndexes)||void 0===B?void 0:B[0],ni=tn.findIndex(function(n){return n.selfIndex===$n});-1!==ni?(Vn=tn[ni],Un=ni):Jn=!0}var ii=function(n,i){if(!i||!n)return null;for(var t=0;t<n.length;t++){var e=Qn(n[t],i,String(t));if(e)return e}return null},ti=null,ei=null,oi="",li="";if(Z)"left"===H?(ti=L,oi=z,(di=Qn(Xn,L.nodeId||L.id,String(qn)))||(di=ii(en,L.nodeId||L.id)),ei=(null==di?void 0:di.section)||null,li=(null==di?void 0:di.keyPath)||""):(ei=L,li=z,(ri=Qn(Vn,L.nodeId||L.id,String(Un)))||(ri=ii(tn,L.nodeId||L.id)),ti=(null==ri?void 0:ri.section)||null,oi=(null==ri?void 0:ri.keyPath)||"");else if("left"===H){ti=L,oi=z;var di=ii(en,L.nodeId||L.id);ei=(null==di?void 0:di.section)||null,li=(null==di?void 0:di.keyPath)||""}else{ei=L,li=z;var ri=ii(tn,L.nodeId||L.id);ti=(null==ri?void 0:ri.section)||null,oi=(null==ri?void 0:ri.keyPath)||""}var ai=(oi?hn(oi):null)||hn(z),ui=null===(R=null==on?void 0:on.input_index_map)||void 0===R?void 0:R[0],ci=null===(E=null==on?void 0:on.input_index_map)||void 0===E?void 0:E[1],si="left"===H?ci:ui,vi="left"===H?!ei:!ti,fi=Z&&"right"===H&&x(Xn,tn),pi=L.evaluationResult||(null==ti?void 0:ti.evaluationResult)||(null==ei?void 0:ei.evaluationResult),hi=(null==pi?void 0:pi.deviations)||{},mi=l(function(){return Z&&"right"===H?y(tn,ui,ln):new Map},[Z,H,tn,ui,ln]),gi=L.nodeId||L.id||(null==ti?void 0:ti.nodeId)||(null==ti?void 0:ti.id)||(null==ei?void 0:ei.nodeId)||(null==ei?void 0:ei.id);Z&&"left"!==H&&(null==ti?void 0:ti.id)&&(gi=ti.nodeId||ti.id);var xi=Object.keys(hi)[0],yi=xi?"".concat(gi).concat(I).concat(xi):null,Si=yi?null==dn?void 0:dn[yi]:null,Ii=Hn+1;if(Z&&Cn){var bi="left"===H?Cn.leftNums.get(null==Vn?void 0:Vn.id):Cn.rightNums.get(null==Xn?void 0:Xn.id);Jn&&void 0!==bi?Ii=bi:null!=Si&&Si>=0?Ii=Si:void 0!==bi&&(Ii=bi)}else null!=Si&&Si>=0&&(Ii=Si);var _i=null!==(K=null===(A=null===(j=null==pi?void 0:pi.evaluation_outputs)||void 0===j?void 0:j.metadata)||void 0===A?void 0:A.label_color)&&void 0!==K?K:w,ki=S(_i).highlightBg,wi=Math.max.apply(Math,n([0],Object.keys(hi).map(function(n){return ln["".concat(gi).concat(I).concat(n)]}).filter(function(n){return"number"==typeof n&&Number.isFinite(n)}),!1))+1,Ci=Object.entries(hi).map(function(n){var i,t=n[0],e=n[1],o="".concat(gi).concat(I).concat(t);return{deviationKey:t,deviationMap:e,refId:o,currentIndex:null!==(i=ln[o])&&void 0!==i?i:wi++}});Ci.sort(function(n,i){return n.currentIndex-i.currentIndex});var Ni=new Map;if(!q&&Z&&"right"===H){var Fi=m(An||"").replace(/\\n/g,"\n");Ci.filter(function(n){var i=n.deviationMap,t=i[X];return(vi||b(i[si]))&&!!t&&!b(t)}).map(function(n){var t,e,o,l,d=m(n.deviationMap[X]||"").replace(/\\n/g,"\n"),r=-1;return d&&-1===(r=null!==(e=null===(t=_(Fi,d))||void 0===t?void 0:t.start)&&void 0!==e?e:-1)&&(r=null!==(l=null===(o=N(Fi,d))||void 0===o?void 0:o.start)&&void 0!==l?l:-1),i(i({},n),{position:r})}).sort(function(n,i){return(-1===n.position?Number.MAX_SAFE_INTEGER:n.position)-(-1===i.position?Number.MAX_SAFE_INTEGER:i.position)||n.currentIndex-i.currentIndex}).forEach(function(n,i){Ni.set(n.refId,i+1)})}var Mi=Ci.map(function(n){var t,e,o,l,d=n.deviationKey,r=n.deviationMap,a=n.refId,u=n.currentIndex,c=r[X],s=b(c);if(s)c="";else if(!c)return null;var v=r[si],f=vi||b(v),p=null!==(t=null==q?void 0:q.get(a))&&void 0!==t?t:Ni.get(a),h=mi.get(a);Z&&"right"===H&&f&&void 0!==p?u=p:Z&&"right"===H&&!f&&void 0!==h?u=h:Z&&void 0!==U&&("right"!==H||f||fi)&&(u-=U),u=Math.max(1,u);var m=Z&&"right"===H&&f&&Cn?k({section:Xn,proposedSections:tn,leftNums:Cn.leftNums,fallbackNumber:String(Ii),firstOnly:!0}):Ii,g="".concat(m,".").concat(u),x="".concat(gi).concat(I).concat(d).concat(I).concat(oi).concat(I).concat(li),y=(null==r?void 0:r.evaluation_outputs)||(null==pi?void 0:pi.evaluation_outputs),_=null!==(e=null==y?void 0:y.output_value)&&void 0!==e?e:null,w=null!==(l=null===(o=null==y?void 0:y.metadata)||void 0===o?void 0:o.label_color)&&void 0!==l?l:_i,C=S(w),N=i({},C),F=(null==r?void 0:r.deviation_summary)?{deviation_summary:r.deviation_summary||(null==pi?void 0:pi.deviation_summary),deviation_title:(null==r?void 0:r.deviation_title)||(null==pi?void 0:pi.deviation_title),deviation_impact:(null==r?void 0:r.deviation_impact)||(null==pi?void 0:pi.deviation_impact),deviation_explanation:(null==r?void 0:r.deviation_explanation)||(null==pi?void 0:pi.deviation_explanation),evaluation_outputs:y,cognitive_decisioning:(null==r?void 0:r.cognitive_decisioning)||(null==pi?void 0:pi.cognitive_decisioning)}:null,M=0,O=An||"";if(c&&O){var P=O.split(/\n{2,}/),B=P.findIndex(function(n){return n.includes(c)});if(-1!==B){var R=Object.entries(hi).filter(function(n){n[0];var i=n[1][X];return i&&P[B].includes(i)}).sort(function(n,i){return P[B].indexOf(n[1][X])-P[B].indexOf(i[1][X])}),E=R.filter(function(n){n[0];var i=n[1][X];return i&&(i.includes(c)||c.includes(i))});E.length>1&&(M=Math.max(0,E.findIndex(function(n){return n[0]===d})))}}var j=mn(H,a);return{id:a,actionId:x,label:g,highlight:c,side:H,style:N,stackIndex:M,score:_,isConnected:rn.has(x),showScrollLockToggle:rn.has(x)||un&&an===x||!!vn&&vn===j.current,scrollSyncLocked:cn,toggleScrollSyncLocked:sn,isOrphan:f,isMissingClause:s,badgeRef:j,onClick:function(n){n.stopPropagation();var t=oi&&tn[Number(oi.split("-")[0])]||Vn,e=li&&en[Number(li.split("-")[0])]||Xn,o=ti?i(i({},ti),{title:(null==t?void 0:t.title)||(null==ti?void 0:ti.title)||""}):{id:"orphan-left",title:"",content:""},l=ei?i(i({},ei),{title:(null==e?void 0:e.title)||(null==ei?void 0:ei.title)||""}):{id:"orphan-right",title:"",content:""};gn(n,o,f,l,x,N)},onSummaryClick:function(n){n.stopPropagation(),xn(n,x,f,F)}}}).filter(Boolean).sort(function(n,i){return parseFloat(n.label)-parseFloat(i.label)}),Oi=l(function(){var n=new Set;return Mi.filter(function(i){return!n.has(i.id)&&(n.add(i.id),!0)})},[Mi]),Pi=nn||Mn?Oi:[],Bi=Oi.map(function(n){return n.highlight}).filter(Boolean),Ri=Mi.find(function(n){return rn.has(n.actionId)}),Ei=!!Ri;if(!(Fn||Ln||L.subsections&&0!==L.subsections.length))return null;var ji=(null===(W=null==Ri?void 0:Ri.style)||void 0===W?void 0:W.badgeBorder)||(null==ai?void 0:ai.badgeBorder),Ai=Ei&&ji?{borderRadius:"4px",outline:"2px solid ".concat(ji),outlineOffset:"1px"}:{};return t(d,Fn?i({ref:Gn,sx:{mt:1,width:"100%",minWidth:0,position:"relative"}},{children:t(d,i({sx:i({width:"100%"},Ai)},{children:e(r,i({disableGutters:!0,expanded:!zn&&Dn,onChange:function(){if(!zn){if(Dn){var n=String(an||""),t=n.includes(oi)||n.includes(li);t||rn.forEach(function(n){(String(n).includes(oi)||String(n).includes(li))&&(t=!0)}),t&&(yn(),Sn(new Set),In([]),bn.current=[])}Y(function(n){var t;return i(i({},n),((t={})[z]=!n[z],t))})}},sx:{mt:0,boxShadow:"none",border:zn?"1px dashed #E2E8F0":"1px solid #EEF2F7",borderRadius:"4px !important",bgcolor:"#FFFFFF",minWidth:0,"&:before":{display:"none"}}},{children:[t(a,i({expandIcon:zn?null:t(s,{size:14}),sx:{minHeight:"32px","& .MuiAccordionSummary-content":{my:.5,display:"grid",alignItems:"center",minWidth:0,width:"100%"}}},{children:t(u,i({component:"div",sx:{fontSize:"11px",fontWeight:600,color:zn?"#94A3B8":"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:Tn||"Untitled Subsection"}))})),!zn&&e(c,i({sx:{pt:0,pb:1,minWidth:0}},{children:[Ln&&t(v,{content:An,overlayContent:Kn,fallbackContent:Wn,sxStyles:fn,deviationBadges:Pi,maintainRelativeOrder:Z,highlightBg:ki,suppressHighlightBg:Bn,highlights:Bi,collisionKey:Nn}),(L.subsections||[]).map(function(n,i){return t(F,{section:n,keyPath:"".concat(z,"-").concat(i),depth:D+1,columnKey:H,parentNodeId:X,sectionOffset:U,rhsOrphanVisualIndexes:q},"".concat(z,"-").concat(i))})]}))]}))}))}):i({ref:Gn,sx:{mt:0===D?1:.75,width:"100%",minWidth:0,position:"relative"}},{children:!zn&&e(d,i({sx:i({width:"100%"},Ai)},{children:[Ln&&t(v,{content:An,overlayContent:Kn,fallbackContent:Wn,sxStyles:fn,deviationBadges:Pi,maintainRelativeOrder:Z,highlightBg:ki,suppressHighlightBg:Bn,highlights:Bi,collisionKey:Nn}),(L.subsections||[]).map(function(n,i){return t(F,{section:n,keyPath:"".concat(z,"-").concat(i),depth:D+1,columnKey:H,parentNodeId:X,sectionOffset:U,rhsOrphanVisualIndexes:q},"".concat(z,"-").concat(i))})]}))}))});export{F as default};
2
2
  //# sourceMappingURL=SubSectionAccordion.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__rest as n}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{findRedlineTextAnchorRange as f,findTextMatchRange as g,mixHexColors as v,areMarkdownPropsEqual as m}from"../CognitiveComparehelpers.js";import b from"rehype-raw";import x from"remark-gfm";import{normalizeRedlineMarkdown as y}from"../utils/normalizeRedlineMarkdown.js";var S=function(e){return"function"==typeof e?e:(null==e?void 0:e.default)||e},E=[S(x)],k=[S(b)],C=l.memo(function(m){var b=m.content,x=m.overlayContent,S=m.fallbackContent,C=m.sxStyles,w=m.deviationBadges,B=void 0===w?[]:w,F=m.highlights,A=void 0===F?[]:F;m.maintainRelativeOrder;var z=m.highlightBg,T=m.suppressHighlightBg,W=void 0!==T&&T,I=m.collisionKey,M=c(null),j=!!x,q=d(function(){return B.reduce(function(n,t){var r;return e(e({},n),((r={})[t.id]=t,r))},{})},[B]),$=c({badgeMap:q,highlightBg:z,hideHighlightBg:j,suppressHighlightBg:W});$.current={badgeMap:q,highlightBg:z,hideHighlightBg:j,suppressHighlightBg:W};var H=function(n,t){return l.Children.map(n,function(n){var r;if(!l.isValidElement(n))return n;var i=(null===(r=n.props)||void 0===r?void 0:r.children)?H(n.props.children,t):n.props.children,o=l.cloneElement(n,e(e({},n.props),{children:i}));return t(o)})},O=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=n(r,["children"]),s=$.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,f=s.suppressHighlightBg,g=d["data-badge-id"],v=g?u[g]:null,m=d["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===d["data-is-suggested-deviation-fix"]||f;return t("span",e({style:e(e(e({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,f=i.children,g=n(i,["children"]),v=$.current.badgeMap,m=g["data-badge-id"];if(!m)return t("span",e({},g,{children:f}));var b=v[m];if(!b)return t("span",e({},g,{children:f}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,e({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,e({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:e(e({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,e({onClick:function(e){e.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,e({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,e({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,e({onClick:function(e){e.stopPropagation(),b.onClick&&b.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),f]}))},table:function(n){var r=n.children;return t(o,e({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:t(o,e({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(n){var r=n.children;return t(o,e({component:"thead"},{children:r}))},tbody:function(n){var r=n.children;return t(o,e({component:"tbody"},{children:r}))},tr:function(n){var r=n.children;return t(o,e({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(n){var r=n.children;return t(o,e({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(n){var r=n.children;return t(o,e({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(n){var r=n.children;return t("span",e({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(n){var r=n.children;return t("span",e({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(e){var n=e.children;return t(i,{children:n})},deleted:function(n){var r=n.children,i=H(r,function(e){return l.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return t("span",e({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(n){var r=n.children,i=H(r,function(e){return l.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return t("span",e({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),P=function(e){if(!e||"string"!=typeof e)return"";var n=e,t=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(e,n,t,r){return"".concat(n).concat(t.slice(0,-1),"\\.").concat(r)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(e,n,t,r){return"".concat(n," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(e){return e.replace(/ /g," ").replace(/\t/g,"    ")})).split(/(\n{2,})/);return(n=t.map(function(e){return/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,function(n,t){var r=e.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},R=d(function(){return B.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[B]),D=function(e){return P(y(e||""))},N=d(function(){var n=P(y(b||"")),t=S?P(y(S)):"",r=(B||[]).map(function(e){var n,t;return{id:null==e?void 0:e.id,highlight:D((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.badgeBg)||z}}).filter(function(e){return e.id&&e.highlight});if(t&&r.length>0){var i=function(e,n){return W?f(e,n):g(e,n,!1)},o=r.some(function(e){var t=e.highlight;return!i(n,t)}),a=r.every(function(e){var n=e.highlight;return!!i(t,n)});o&&a&&(n=t)}var l={};r.forEach(function(e){l[e.highlight]||(l[e.highlight]=[]),l[e.highlight].push(e)});var c=function(e,n,t,r){void 0===n&&(n=""),void 0===r&&(r=[]);var i=!1,o=function(e){var o=function(e,n,t){var r,i,o;void 0===n&&(n="");var a=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return e;var l=null!==(r=a[1])&&void 0!==r?r:"",c=null!==(i=a[2])&&void 0!==i?i:"",d=null!==(o=a[3])&&void 0!==o?o:"";return c?l+function(e,n){void 0===e&&(e="");var t=n?' data-highlight-color="'.concat(n,'"'):"",r=e?' data-badge-id="'.concat(e,'"'):"";return"<mark".concat(r).concat(t,">")}(n,t)+c+"</mark>"+d:e}(e,n,t),a=o;if(!i&&r.length>0){i=!0;var l="",c="";r.forEach(function(e){l+=function(e){return'<span data-badge-id="'.concat(e,'">')}(e.id),c="</span>"+c}),a=l+o+c}return"​"+a};return e.split(/(\n+)/).map(function(e){return/^\n+$/.test(e)?e:e.trim()?""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(function(e){return"|"!==e&&e.trim()?o(e):e}).join(""):o(e):e}).join("")},d=[];Object.entries(l).forEach(function(e){var t=e[0],r=e[1],i=W?f(n,t):g(n,t,!1);if(i){for(var o=n.slice(i.start,i.end)!==t,a=r[0].highlightColor,l=1;l<r.length;l++)a=v(a,r[l].highlightColor||"");d.push({highlight:t,start:i.start,end:i.end,badges:r,color:a,usedLooseMatch:o})}});var s=new Set(Object.keys(l));(A||[]).forEach(function(e){if(e){var t=D(e);if(t&&!s.has(t)){var r=W?f(n,t):g(n,t,!1);if(r){var i=n.slice(r.start,r.end)!==t,o=n.slice(0,r.start);(o.match(/</g)||[]).length===(o.match(/>/g)||[]).length&&d.push({highlight:t,start:r.start,end:r.end,badges:[],color:z||"",usedLooseMatch:i})}}}}),d.sort(function(e,n){return e.start-n.start||n.end-e.end});var u=[],h={};d.forEach(function(e,n){for(var t=e.start,r=e.end,i=0,o=u;i<o.length;i++){var a=o[i],l=a.start,c=a.end,d=t<c&&r>c&&t>=l,s=t<l&&r>l&&r<=c;if(t>=l&&r<=c){e.orphaned=!0,h[n]=a.matchIdx;break}d&&(t=c),s&&(r=l)}e.trimmedStart=t,e.trimmedEnd=r,!e.orphaned&&t<r&&u.push({start:t,end:r,matchIdx:n})});var p={};Object.entries(h).forEach(function(e){var n=e[0],t=e[1],r=Number(n);p[t]||(p[t]=[]),p[t].push(r)});var m=d.map(function(n,t){return e(e({},n),{idx:t})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var t,r;return(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)-(null!==(r=e.trimmedStart)&&void 0!==r?r:e.start)});return m.forEach(function(e){var t,r,i,o,a=null!==(t=e.trimmedStart)&&void 0!==t?t:e.start,l=null!==(r=e.trimmedEnd)&&void 0!==r?r:e.end;if(!(a>=l)){var s=n.slice(a,l),u=function(e,n,t,r){if(!t.length)return e;var i=t.map(function(e){return d[e]}).sort(function(e,n){return e.start-n.start}),o="",a=0;return i.forEach(function(t){var i,l,d=Math.max(a,t.start-n),s=Math.max(d,t.end-n);if(!(d>=s)){var u=v(r,t.color||"");o+=e.slice(a,d),o+=c(e.slice(d,s),(null===(l=null===(i=t.badges)||void 0===i?void 0:i[0])||void 0===l?void 0:l.id)||"",u,t.badges||[]),a=s}}),o+=e.slice(a)}(e.usedLooseMatch||a!==e.start||l!==e.end?s:e.highlight,e.start,p[e.idx]||[],e.color),h=c(u,(null===(o=null===(i=e.badges)||void 0===i?void 0:i[0])||void 0===o?void 0:o.id)||"",e.color,e.badges||[]);n=n.slice(0,a)+h+n.slice(l)}}),n},[b,S,B,A,z,W]),L=d(function(){return x?P(y(x||"")):""},[x]),X=!!x,Y=e(e(e({},C),{"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap",lineHeight:"1.5"}}),{position:"relative",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"inherit",fontWeight:"400",lineHeight:"1.5",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"}),K=e(e(e({},Y),{zIndex:2}),X?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}),V=e(e({},Y),{zIndex:1,pointerEvents:"auto"});return s(function(){if(M.current){var e=function(){var e,n,t=Array.from(M.current.querySelectorAll(".deviation-badge"));if(0!==t.length){t.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var r=M.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=M.current.querySelector('div[data-layer="base"]')||(null===(e=M.current.querySelector("div"))||void 0===e?void 0:e.firstElementChild),l=X?M.current.querySelector('div[data-layer="overlay"]')||(null===(n=M.current.querySelector("div"))||void 0===n?void 0:n.lastElementChild):null,c=a?Array.from(a.querySelectorAll(".deviation-badge")):[],d=l?Array.from(l.querySelectorAll(".deviation-badge")):[],s=t.length>0?t.filter(function(e){return"left"===e.dataset.side}):c.filter(function(e){return"left"===e.dataset.side}),u=t.length>0?t.filter(function(e){return"left"!==e.dataset.side}):c.filter(function(e){return"left"!==e.dataset.side}),h=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,naturalTop:n.top,height:n.height,currentTop:n.top}});n.sort(function(e,n){return e.naturalTop-n.naturalTop});var t=[],r=[];n.forEach(function(e){if(0===r.length)r.push(e);else{var n=r[r.length-1],i=n.currentTop+n.height;e.naturalTop<i+8?(e.currentTop=i+8,r.push(e)):(t.push(r),r=[e])}}),r.length>0&&t.push(r),t.forEach(function(e){var n=e[e.length-1],t=n.currentTop+n.height;if(t>i){var r=t-i,a=e[0].currentTop-o,l=Math.max(0,Math.min(r,a));e.forEach(function(e){e.currentTop-=l})}}),t.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};if(X&&(c.length>0||d.length>0)){var p=c.filter(function(e){return"left"===e.dataset.side}),f=c.filter(function(e){return"left"!==e.dataset.side}),g=d.filter(function(e){return"left"===e.dataset.side}),v=d.filter(function(e){return"left"!==e.dataset.side});h(p),h(f),h(g),h(v)}else h(s),h(u)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),t=new ResizeObserver(function(){requestAnimationFrame(e)});return t.observe(M.current),function(){t.disconnect(),cancelAnimationFrame(n)}}},[N,I,R]),r(o,e({ref:M,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,e({component:"div",sx:K},{children:t(p,e({components:O,remarkPlugins:E,rehypePlugins:k},{children:N.replace(/#{3}/g,"")}))})),X&&t(a,e({component:"div",sx:V},{children:t(p,e({components:O,remarkPlugins:E,rehypePlugins:k},{children:L}))}))]}))},m);export{C as MemoizedMarkdown};
1
+ import{__assign as e,__rest as n}from"tslib";import{jsx as t,jsxs as r,Fragment as i}from"react/jsx-runtime";import{Box as o,Typography as a}from"@mui/material";import l,{useRef as c,useMemo as d,useLayoutEffect as s}from"react";import{DEFAULT_DEVIAION_COLOR as u}from"../CognitiveCompareConstants.js";import{EllipsisVertical as h}from"lucide-react";import p from"react-markdown";import{findRedlineTextAnchorRange as f,findTextMatchRange as g,mixHexColors as v,areMarkdownPropsEqual as m}from"../CognitiveComparehelpers.js";import{findTextRangeWithFormatting as b}from"../utils/normalizeInlineMarkdown.js";import x from"rehype-raw";import y from"remark-gfm";import{normalizeRedlineMarkdown as S}from"../utils/normalizeRedlineMarkdown.js";var E=function(e){return"function"==typeof e?e:(null==e?void 0:e.default)||e},k=[E(y)],w=[E(x)],C=l.memo(function(m){var x=m.content,y=m.overlayContent,E=m.fallbackContent,C=m.sxStyles,B=m.deviationBadges,F=void 0===B?[]:B,z=m.highlights,A=void 0===z?[]:z;m.maintainRelativeOrder;var T=m.highlightBg,W=m.suppressHighlightBg,I=void 0!==W&&W,M=m.collisionKey,j=c(null),q=!!y,$=d(function(){return F.reduce(function(n,t){var r;return e(e({},n),((r={})[t.id]=t,r))},{})},[F]),H=c({badgeMap:$,highlightBg:T,hideHighlightBg:q,suppressHighlightBg:I});H.current={badgeMap:$,highlightBg:T,hideHighlightBg:q,suppressHighlightBg:I};var O=function(n,t){return l.Children.map(n,function(n){var r;if(!l.isValidElement(n))return n;var i=(null===(r=n.props)||void 0===r?void 0:r.children)?O(n.props.children,t):n.props.children,o=l.cloneElement(n,e(e({},n.props),{children:i}));return t(o)})},P=d(function(){return{mark:function(r){var i,o,a,l,c=r.children,d=n(r,["children"]),s=H.current,u=s.badgeMap,h=s.highlightBg,p=s.hideHighlightBg,f=s.suppressHighlightBg,g=d["data-badge-id"],v=g?u[g]:null,m=d["data-highlight-color"],b=null!==(l=null!==(o=null!=m?m:null===(i=null==v?void 0:v.style)||void 0===i?void 0:i.highlightBg)&&void 0!==o?o:null===(a=null==v?void 0:v.style)||void 0===a?void 0:a.badgeBg)&&void 0!==l?l:h,x="true"===d["data-is-suggested-deviation-fix"]||f;return t("span",e({style:e(e(e({},x?{}:{backgroundColor:b}),{borderRadius:"2px",display:"inline",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundClip:"padding-box",padding:"0 1px"}),p?{color:"transparent"}:{})},{children:c}))},span:function(i){var a,l,c,d,s,p,f=i.children,g=n(i,["children"]),v=H.current.badgeMap,m=g["data-badge-id"];if(!m)return t("span",e({},g,{children:f}));var b=v[m];if(!b)return t("span",e({},g,{children:f}));var x="number"==typeof b.stackIndex?b.stackIndex:0,y="translateY(calc(-20% + ".concat(12*x,"px + var(--badge-nudge, 0px)))");return r(o,e({component:"span",sx:{position:"static",display:"inline"}},{children:[r(o,e({ref:b.badgeRef,className:"deviation-badge","data-side":b.side||"right",sx:e(e({fontStyle:"normal",position:"absolute",zIndex:30+x,display:"inline-flex",alignItems:"stretch",fontSize:"10px",bgcolor:(null===(a=b.style)||void 0===a?void 0:a.badgeBg)||"#EEF2FF",color:(null===(l=b.style)||void 0===l?void 0:l.badgeText)||u,border:"1px solid ".concat((null===(c=b.style)||void 0===c?void 0:c.badgeBorder)||"#C7D2FE"),borderRadius:"12px",fontWeight:600,whiteSpace:"nowrap",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",overflow:"hidden",transition:"none"},"left"===b.side?{right:"-16px",transform:"".concat(y," translateX(calc(100% + 8px))")}:{left:"-16px",transform:"".concat(y," translateX(calc(-100% - 8px))")}),b.isConnected&&b.style&&{outline:"2px solid ".concat(b.style.badgeBorder),outlineOffset:"1px"})},{children:[r(o,e({onClick:function(e){e.stopPropagation(),b.onSummaryClick&&b.onSummaryClick(e)},sx:{display:"flex",alignItems:"center",px:1,py:.3,cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.04)"}}},{children:[t(o,e({component:"span",sx:{fontSize:"10px",fontWeight:700}},{children:b.label})),("left"===b.side||b.isOrphan)&&t(o,e({component:"span",sx:{fontSize:"10px",pl:.5,ml:.5,borderLeft:"1px solid ".concat((null===(d=b.style)||void 0===d?void 0:d.badgeBorder)||"#C7D2FE")}},{children:null!=b.score&&"N/A"!==b.score&&"NA"!==b.score&&0!==b.score?"".concat(b.score):"N/A"===b.score||"NA"===b.score?"N/A":"Same"}))]})),("left"===b.side||b.isOrphan)&&t(o,e({onClick:function(e){e.stopPropagation(),b.onClick&&b.onClick(e)},sx:{display:"flex",alignItems:"center",px:.5,borderLeft:"1px solid ".concat((null===(s=b.style)||void 0===s?void 0:s.badgeBorder)||"#C7D2FE"),cursor:"pointer","&:hover":{bgcolor:"rgba(0,0,0,0.06)"}}},{children:t(h,{size:12,color:(null===(p=b.style)||void 0===p?void 0:p.badgeText)||"#3730A3"})}))]})),f]}))},table:function(n){var r=n.children;return t(o,e({sx:{display:"block",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",contain:"inline-size",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",WebkitOverflowScrolling:"touch",my:1}},{children:t(o,e({component:"table",sx:{width:"600px",minWidth:"600px",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"inherit"}},{children:r}))}))},thead:function(n){var r=n.children;return t(o,e({component:"thead"},{children:r}))},tbody:function(n){var r=n.children;return t(o,e({component:"tbody"},{children:r}))},tr:function(n){var r=n.children;return t(o,e({component:"tr",sx:{borderBottom:"1px solid #E5E7EB"}},{children:r}))},th:function(n){var r=n.children;return t(o,e({component:"th",sx:{border:"1px solid #E5E7EB",padding:"8px",textAlign:"left",verticalAlign:"top",fontWeight:600,backgroundColor:"#F9FAFB",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},td:function(n){var r=n.children;return t(o,e({component:"td",sx:{border:"1px solid #E5E7EB",padding:"8px",verticalAlign:"top",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere"}},{children:r}))},code:function(n){var r=n.children;return t("span",e({style:{fontFamily:"inherit",fontSize:"inherit"}},{children:r}))},pre:function(n){var r=n.children;return t("span",e({style:{fontFamily:"inherit",fontSize:"inherit",display:"block",whiteSpace:"pre-wrap"}},{children:r}))},updated:function(e){var n=e.children;return t(i,{children:n})},deleted:function(n){var r=n.children,i=O(r,function(e){return l.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return t("span",e({style:{boxShadow:"inset 0 1px 0 #EF4444, inset 0 -1px 0 #EF4444",backgroundColor:"#FCCCCC",textDecoration:"line-through"}},{children:i}))},changed:function(n){var r=n.children,i=O(r,function(e){return l.cloneElement(e,{"data-is-suggested-deviation-fix":"true"})});return t("span",e({style:{boxShadow:"inset 0 1px 0 #2F59FF, inset 0 -1px 0 #2F59FF",backgroundColor:"#D5E8FF"}},{children:i}))},ul:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"ul",sx:{mt:1,mb:1,pl:3,listStyleType:"disc"}},a,{children:i}))},ol:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"ol",sx:{mt:1,mb:1,pl:3,listStyleType:"decimal"}},a,{children:i}))},li:function(r){var i=r.children,a=n(r,["children"]);return t(o,e({component:"li",sx:{mb:.5,display:"list-item"}},a,{children:i}))}}},[]),R=function(e){if(!e||"string"!=typeof e)return"";var n=e,t=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/((?:<\/?[a-z]+[^>]*>\s*)+)([*+\-] |\d+\. )/gi,"$2$1")).replace(/\\(['"])/g,"$1").replace(/\\n/g,"\n").replace(/\\\./g,".").replace(/\r\n/g,"\n")).replace(/^([ \t]*)(\d+\.)(\s{2,})/gm,function(e,n,t,r){return"".concat(n).concat(t.slice(0,-1),"\\.").concat(r)})).replace(/^(\d+\.)\s*\n+(\s+)(\S)/gm,function(e,n,t,r){return"".concat(n," ").concat(r)})).replace(/([^\n])\n(#{1,6} )/g,"$1\n\n$2")).replace(/([^\n])\n([ \t]*(?:[#*+\-] |\d+\. ))/g,"$1\n\n$2")).replace(/\n{3,}/g,"\n\n")).replace(/^[ \t]+(?![ \t]*([\*\-\+] |\d+\. ))/gm,function(e){return e.replace(/ /g," ").replace(/\t/g,"    ")})).split(/(\n{2,})/);return(n=t.map(function(e){return/^\n+$/.test(e)||/\|.*\|/.test(e)&&/\|[\s:|-]+\|/.test(e)||/^#{1,6} /.test(e.trimStart())?e:e.replace(/\n(?=[^\n])/g,function(n,t){var r=e.slice(t+1);return/^[ \t]*([#>|\-*+]|\d+\.)/.test(r)?"\n":" "})}).join("")).trim()},D=d(function(){return F.map(function(e){return{id:e.id,connected:e.isConnected,stackIndex:e.stackIndex,size:e.size}})},[F]),N=function(e){return R(S(e||""))},L=d(function(){var n=R(S(x||"")),t=E?R(S(E)):"",r=(F||[]).map(function(e){var n,t;return{id:null==e?void 0:e.id,highlight:N((null==e?void 0:e.highlight)||""),highlightColor:(null===(n=null==e?void 0:e.style)||void 0===n?void 0:n.highlightBg)||(null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.badgeBg)||T}}).filter(function(e){return e.id&&e.highlight});if(t&&r.length>0){var i=function(e,n){return I?f(e,n):g(e,n,!1)},o=r.some(function(e){var t=e.highlight;return!i(n,t)}),a=r.every(function(e){var n=e.highlight;return!!i(t,n)});o&&a&&(n=t)}var l={};r.forEach(function(e){l[e.highlight]||(l[e.highlight]=[]),l[e.highlight].push(e)});var c=function(e,n,t,r){void 0===n&&(n=""),void 0===r&&(r=[]);var i=!1,o=function(e){var o=function(e,n,t){var r,i,o;void 0===n&&(n="");var a=e.match(/^(\s*)([\s\S]*?)(\s*)$/);if(!a)return e;var l=null!==(r=a[1])&&void 0!==r?r:"",c=null!==(i=a[2])&&void 0!==i?i:"",d=null!==(o=a[3])&&void 0!==o?o:"";return c?l+function(e,n){void 0===e&&(e="");var t=n?' data-highlight-color="'.concat(n,'"'):"",r=e?' data-badge-id="'.concat(e,'"'):"";return"<mark".concat(r).concat(t,">")}(n,t)+c+"</mark>"+d:e}(e,n,t),a=o;if(!i&&r.length>0){i=!0;var l="",c="";r.forEach(function(e){l+=function(e){return'<span data-badge-id="'.concat(e,'">')}(e.id),c="</span>"+c}),a=l+o+c}return"​"+a};return e.split(/(\n+)/).map(function(e){return/^\n+$/.test(e)?e:e.trim()?""===e.replace(/[|:\-\s]/g,"")&&e.includes("-")?e:e.includes("|")?e.split(/(\|)/).map(function(e){return"|"!==e&&e.trim()?o(e):e}).join(""):o(e):e}).join("")},d=[];Object.entries(l).forEach(function(e){var t=e[0],r=e[1],i=I?f(n,t):g(n,t,!1);if(i||I||(i=b(n,t)),i){for(var o=n.slice(i.start,i.end)!==t,a=r[0].highlightColor,l=1;l<r.length;l++)a=v(a,r[l].highlightColor||"");d.push({highlight:t,start:i.start,end:i.end,badges:r,color:a,usedLooseMatch:o})}});var s=new Set(Object.keys(l));(A||[]).forEach(function(e){if(e){var t=N(e);if(t&&!s.has(t)){var r=I?f(n,t):g(n,t,!1);if(r){var i=n.slice(r.start,r.end)!==t,o=n.slice(0,r.start);(o.match(/</g)||[]).length===(o.match(/>/g)||[]).length&&d.push({highlight:t,start:r.start,end:r.end,badges:[],color:T||"",usedLooseMatch:i})}}}}),d.sort(function(e,n){return e.start-n.start||n.end-e.end});var u=[],h={};d.forEach(function(e,n){for(var t=e.start,r=e.end,i=0,o=u;i<o.length;i++){var a=o[i],l=a.start,c=a.end,d=t<c&&r>c&&t>=l,s=t<l&&r>l&&r<=c;if(t>=l&&r<=c){e.orphaned=!0,h[n]=a.matchIdx;break}d&&(t=c),s&&(r=l)}e.trimmedStart=t,e.trimmedEnd=r,!e.orphaned&&t<r&&u.push({start:t,end:r,matchIdx:n})});var p={};Object.entries(h).forEach(function(e){var n=e[0],t=e[1],r=Number(n);p[t]||(p[t]=[]),p[t].push(r)});var m=d.map(function(n,t){return e(e({},n),{idx:t})}).filter(function(e){return!e.orphaned}).sort(function(e,n){var t,r;return(null!==(t=n.trimmedStart)&&void 0!==t?t:n.start)-(null!==(r=e.trimmedStart)&&void 0!==r?r:e.start)});return m.forEach(function(e){var t,r,i,o,a=null!==(t=e.trimmedStart)&&void 0!==t?t:e.start,l=null!==(r=e.trimmedEnd)&&void 0!==r?r:e.end;if(!(a>=l)){var s=n.slice(a,l),u=function(e,n,t,r){if(!t.length)return e;var i=t.map(function(e){return d[e]}).sort(function(e,n){return e.start-n.start}),o="",a=0;return i.forEach(function(t){var i,l,d=Math.max(a,t.start-n),s=Math.max(d,t.end-n);if(!(d>=s)){var u=v(r,t.color||"");o+=e.slice(a,d),o+=c(e.slice(d,s),(null===(l=null===(i=t.badges)||void 0===i?void 0:i[0])||void 0===l?void 0:l.id)||"",u,t.badges||[]),a=s}}),o+=e.slice(a)}(e.usedLooseMatch||a!==e.start||l!==e.end?s:e.highlight,e.start,p[e.idx]||[],e.color),h=c(u,(null===(o=null===(i=e.badges)||void 0===i?void 0:i[0])||void 0===o?void 0:o.id)||"",e.color,e.badges||[]);n=n.slice(0,a)+h+n.slice(l)}}),n},[x,E,F,A,T,I]),X=d(function(){return y?R(S(y||"")):""},[y]),Y=!!y,K=e(e(e({},C),{"& *":{fontFamily:"inherit"},"& code, & pre, & kbd, & samp":{fontFamily:"inherit !important",fontSize:"inherit",background:"none",padding:0,border:"none",whiteSpace:"pre-wrap"},"& p, & li, & ul, & ol":{position:"static",overflow:"visible",whiteSpace:"pre-wrap",lineHeight:"1.5"}}),{position:"relative",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"inherit",fontWeight:"400",lineHeight:"1.5",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box",overflow:"visible",whiteSpace:"normal",gridArea:"1 / 1",padding:"3px"}),V=e(e(e({},K),{zIndex:2}),Y?{color:"transparent",userSelect:"none",pointerEvents:"none","& .deviation-badge":{pointerEvents:"auto",visibility:"visible"},"& table":{visibility:"hidden"}}:{}),G=e(e({},K),{zIndex:1,pointerEvents:"auto"});return s(function(){if(j.current){var e=function(){var e,n,t=Array.from(j.current.querySelectorAll(".deviation-badge"));if(0!==t.length){t.forEach(function(e){e.style.setProperty("--badge-nudge","0px")});var r=j.current.getBoundingClientRect(),i=r.bottom-4,o=r.top+4,a=j.current.querySelector('div[data-layer="base"]')||(null===(e=j.current.querySelector("div"))||void 0===e?void 0:e.firstElementChild),l=Y?j.current.querySelector('div[data-layer="overlay"]')||(null===(n=j.current.querySelector("div"))||void 0===n?void 0:n.lastElementChild):null,c=a?Array.from(a.querySelectorAll(".deviation-badge")):[],d=l?Array.from(l.querySelectorAll(".deviation-badge")):[],s=t.length>0?t.filter(function(e){return"left"===e.dataset.side}):c.filter(function(e){return"left"===e.dataset.side}),u=t.length>0?t.filter(function(e){return"left"!==e.dataset.side}):c.filter(function(e){return"left"!==e.dataset.side}),h=function(e){if(0!==e.length){var n=e.map(function(e){var n=e.getBoundingClientRect();return{el:e,naturalTop:n.top,height:n.height,currentTop:n.top}});n.sort(function(e,n){return e.naturalTop-n.naturalTop});var t=[],r=[];n.forEach(function(e){if(0===r.length)r.push(e);else{var n=r[r.length-1],i=n.currentTop+n.height;e.naturalTop<i+8?(e.currentTop=i+8,r.push(e)):(t.push(r),r=[e])}}),r.length>0&&t.push(r),t.forEach(function(e){var n=e[e.length-1],t=n.currentTop+n.height;if(t>i){var r=t-i,a=e[0].currentTop-o,l=Math.max(0,Math.min(r,a));e.forEach(function(e){e.currentTop-=l})}}),t.flat().forEach(function(e){var n=e.currentTop-e.naturalTop;e.el.style.setProperty("--badge-nudge","".concat(n,"px"))})}};if(Y&&(c.length>0||d.length>0)){var p=c.filter(function(e){return"left"===e.dataset.side}),f=c.filter(function(e){return"left"!==e.dataset.side}),g=d.filter(function(e){return"left"===e.dataset.side}),v=d.filter(function(e){return"left"!==e.dataset.side});h(p),h(f),h(g),h(v)}else h(s),h(u)}},n=requestAnimationFrame(function(){requestAnimationFrame(function(){e()})}),t=new ResizeObserver(function(){requestAnimationFrame(e)});return t.observe(j.current),function(){t.disconnect(),cancelAnimationFrame(n)}}},[L,M,D]),r(o,e({ref:j,sx:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",width:"100%",maxWidth:"100%",minWidth:0}},{children:[t(a,e({component:"div",sx:V},{children:t(p,e({components:P,remarkPlugins:k,rehypePlugins:w},{children:L.replace(/#{3}/g,"")}))})),Y&&t(a,e({component:"div",sx:G},{children:t(p,e({components:P,remarkPlugins:k,rehypePlugins:w},{children:X}))}))]}))},m);export{C as MemoizedMarkdown};
2
2
  //# sourceMappingURL=memoizedMarkdown.js.map
@@ -0,0 +1,2 @@
1
+ var e=function(e){if(!e||"string"!=typeof e)return e;var r=e;return(r=(r=(r=(r=(r=(r=(r=(r=(r=r.replace(/\*\*([^*]*?)\*\*/g,"$1")).replace(/__([^_]*?)__/g,"$1")).replace(/\*([^*]*?)\*/g,"$1")).replace(/_([^_]*?)_/g,"$1")).replace(/~~([^~]*?)~~/g,"$1")).replace(/`([^`]*?)`/g,"$1")).replace(/\[([^\]]*?)\]\([^)]*?\)/g,"$1")).replace(/<[^>]*?>/g,"")).replace(/\s+/g," ")).trim()},r=function(r,n){if(!r||!n)return null;var f=r.indexOf(n);if(-1!==f)return{start:f,end:f+n.length};var l=e(r),t=e(n);if(!l||!t)return null;var a=l.indexOf(t);if(-1===a)return null;var i=function(e,r,n){var f=0,l=0,t=-1,a=-1;for(;f<e.length;){var i=e[f],u=i+e[f+1],g=0;if("**"===u||"__"===u||"~~"===u)g=2;else if("<["===u){if("<"===i){var c=e.indexOf(">",f);-1!==c&&(g=c-f+1)}else if("["===i){var v=e.indexOf("]",f);if(-1!==v&&"("===e[v+1]){var p=e.indexOf(")",v);if(-1!==p){for(var _=f+1;_<v;_++)if(l===r&&-1===t&&(t=f+1),++l===r+n)return a=_+1,-1!==t&&-1!==a?{start:t,end:a}:null;f=p,g=1}}}}else"*"!==i&&"_"!==i&&"`"!==i&&"<"!==i||(g=1);if(g>0)f+=g;else{if(l===r&&-1===t&&(t=f),++l===r+n){a=f+1;break}f++}}if(-1===t||-1===a)return null;return{start:t,end:a}}(r,a,t.length);return i};export{r as findTextRangeWithFormatting,e as stripMarkdownFormatting};
2
+ //# sourceMappingURL=normalizeInlineMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeInlineMarkdown.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AA4CA,OAAO,EAEL,qBAAqB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAgClC,QAAA,MAAM,gBAAgB,iZA8BnB,qBAAqB,4CAg/FvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AA4CA,OAAO,EAEL,qBAAqB,EAOtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAgClC,QAAA,MAAM,gBAAgB,iZA8BnB,qBAAqB,4CAy9FvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}