@viswa-test/test-citation 0.0.116 → 0.0.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/features/CognitiveCompare/components/CognitiveSummaryPopup.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareConstants.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +3 -0
- package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts +1 -1
- package/dist/types/src/features/CognitiveCompare/components/CognitiveSummaryPopup.d.ts.map +1 -1
- package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/src/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as n,__spreadArray as e}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as c}from"react";import{Box as d,Snackbar as a,Alert as s,Tooltip as v,Typography as f}from"@mui/material";import{ChevronDown as p,EllipsisVertical as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import x from"./OverlayComponent.js";import{safeStringify as m,extractDeviationScore as y,generateColorPalette as b,DEVIATION_BADGE_SEPARATOR as S,findKeyPathByNodeId as R,getFirstDeviationOutputValue as C,getFirstDeviationColor as I,hasValue as B,getBentArrowPath as w,smoothScrollTo as T,resetClauseHighlight as _,scrollAndHighlightClause as E}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as F,DEFAULT_FIELD_CONFIG as A,DEFAULT_COMPARISON_CONFIG as D}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{EMPTY_SUMMARY_POPUP_STATE as M,DEFAULT_DEVIAION_COLOR as N,DEFAULT_COMPONENT_HEADER_TEXT as k}from"./CognitiveCompareConstants.js";import P from"./CognitivePopup.js";import j from"./MoreFunctionsPopup.js";import H from"./LoaderComponent.js";import L from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as O}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as q}from"./hooks/useAccordionState.js";import{useDeviationNavigation as Y}from"./hooks/useDeviationNavigation.js";import K from"./components/CompareHeader.js";import V from"./components/SectionAccordion.js";import X from"./components/SubSectionAccordion.js";import $ from"./components/CognitiveSummaryPopup.js";import G from"./components/connectedLines.js";var J=function(J){var U,Q,Z,nn,en,tn,on,rn,ln,un,cn,dn,an,sn,vn,fn,pn,gn,hn,xn,mn,yn,bn,Sn,Rn,Cn,In=J.componentHeaderText,Bn=void 0===In?k:In,wn=J.treeData,Tn=J.comparisonConfig,_n=J.leftColumnTitleText,En=J.rightColumnTitleText,Fn=J.markdownStyles,An=J.resetTrigger,Dn=J.displayConfig,Mn=void 0===Dn?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:Dn,Nn=J.popupConfig,kn=J.deviationData,Pn=void 0===kn?{}:kn,jn=J.deviationNodeIdToView,Hn=J.resetDeviationNodeId,Ln=J.isProposingFix,On=void 0!==Ln&&Ln,zn=J.proposingFixNodeId,Wn=o(Mn.maintainRelativeOrder),qn=Wn[0],Yn=Wn[1],Kn=!!qn||!!(null==Mn?void 0:Mn.showDeviationBadges),Vn=o(!1),Xn=Vn[0],$n=Vn[1],Gn=o(!1),Jn=Gn[0],Un=Gn[1],Qn=o(null),Zn=Qn[0],ne=Qn[1],ee=o(!1),te=ee[0],ie=ee[1],oe=o(null===(Q=null!==(U=null==wn?void 0:wn.newEvaluationResult)&&void 0!==U?U:null==Mn?void 0:Mn.enableDeviationSchemaBackwardCompatibility)||void 0===Q||Q)[0],re=o(!1),le=re[0],ue=re[1],ce=o(!1),de=ce[0],ae=ce[1],se=o(null),ve=se[0],fe=se[1],pe=r(!1),ge=o(new Set),he=ge[0],xe=ge[1],me=o([]),ye=me[0],be=me[1],Se=r(null),Re=r(null),Ce=r(null),Ie=r(new Set),Be=r(!1),we=r(null),Te=r({}),_e=r([]),Ee=r(!1),Fe=r(!1),Ae=r(null),De=r(function(){}),Me=l(function(){return(null==wn?void 0:wn.cognitive_decisioning)||{}},[wn]),Ne=o({width:0,height:0}),ke=Ne[0],Pe=Ne[1],je=l(function(){return n(n({},F),Fn)},[Fn]),He=r(null),Le=r(null),Oe=r(null),ze=r(null),We=r(null),qe=r(null),Ye=r(null),Ke=r(null),Ve=r(!1),Xe=r(null),$e=r(null),Ge=z(He),Je=Ge.cognitivePopup,Ue=Ge.setCognitivePopup,Qe=Ge.moreFunctions,Ze=Ge.setMoreFunctions,nt=Ge.position,et=Ge.setPosition,tt=Ge.activeBadgeId,it=Ge.summaryPopup,ot=Ge.setSummaryPopup,rt=Ge.closeSummaryPopup,lt=Ge.setActiveBadgeId,ut=Ge.popupRef,ct=Ge.closeCognitivePopup,dt=Ge.closeMoreFunctionsPopup,at=l(function(){var n,e,t,i,o,r,l;return{fields:null!==(n=null==Tn?void 0:Tn.fields)&&void 0!==n?n:A,thresholds:{high:null!==(t=null===(e=null==Tn?void 0:Tn.thresholds)||void 0===e?void 0:e.high)&&void 0!==t?t:D.thresholds.high,medium:null!==(o=null===(i=null==Tn?void 0:Tn.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:D.thresholds.medium,exact:null!==(l=null===(r=null==Tn?void 0:Tn.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:D.thresholds.exact}}},[Tn]),st=o(null),vt=st[0];st[1];var ft=null===(en=null===(Z=null==wn?void 0:wn.documents)||void 0===Z?void 0:Z[null===(nn=null==wn?void 0:wn.input_index_map)||void 0===nn?void 0:nn[0]])||void 0===en?void 0:en.title,pt=null===(rn=null===(tn=null==wn?void 0:wn.documents)||void 0===tn?void 0:tn[null===(on=null==wn?void 0:wn.input_index_map)||void 0===on?void 0:on[1]])||void 0===rn?void 0:rn.title,gt=m(_n||ft||"Uploaded Contract"),ht=m(En||pt||"Reference Template"),xt=O(wn,qn,Pn,at,oe),mt=xt.activeProposed,yt=xt.existingRule,bt=xt.proposedSections,St=xt.existingSections,Rt=xt.visibleFields,Ct=xt.parentDeviationRecord,It=xt.deviationNumberRegistry,Bt=xt.parseError;u(function(){Bt&&ne("Failed to load comparison: ".concat(Bt))},[Bt]);var wt=bt.length>0||St.length>0,Tt=W(Rt.map(function(n){return n.key}),Math.max(bt.length,St.length)),_t=Tt.leftRefs,Et=Tt.rightRefs,Ft=Tt.sectionLeftRefs,At=Tt.sectionRightRefs,Dt=Tt.lhsBadgeRefs,Mt=Tt.rhsBadgeRefs,Nt=Tt.sectionRightRowRefs,kt=Tt.subSectionLeftRefs,Pt=Tt.subSectionRightRefs,jt=Tt.sectionRowRefs,Ht=Tt.getSectionRowRef,Lt=Tt.getSubSectionRef,Ot=Tt.getBadgeRef,zt=yt.analysis,Wt=m(null===(un=null===(ln=null==zt?void 0:zt.rule_difference_comparison)||void 0===ln?void 0:ln.summary)||void 0===un?void 0:un.overall_summary),qt=!!Wt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Yt=null!==(cn=null==wn?void 0:wn.base_root_id)&&void 0!==cn?cn:"-1";null==wn||wn[Yt];var Kt=oe?null!==(bn=null!==(xn=Pn&&(null===(hn=null==Pn?void 0:Pn[Yt])||void 0===hn?void 0:hn.evaluation_result))&&void 0!==xn?xn:null===(yn=null===(mn=null==wn?void 0:wn.nodes)||void 0===mn?void 0:mn[Yt])||void 0===yn?void 0:yn.evaluation_result)&&void 0!==bn?bn:null:null!==(gn=null!==(sn=Pn&&(null===(an=null===(dn=null==Pn?void 0:Pn[Yt])||void 0===dn?void 0:dn.evaluation_result)||void 0===an?void 0:an[0]))&&void 0!==sn?sn:null===(pn=null===(fn=null===(vn=null==wn?void 0:wn.nodes)||void 0===vn?void 0:vn[Yt])||void 0===fn?void 0:fn.evaluation_result)||void 0===pn?void 0:pn[0])&&void 0!==gn?gn:null,Vt=y(Kt),Xt=b(null!==(Cn=null===(Rn=null===(Sn=null==Kt?void 0:Kt.evaluation_outputs)||void 0===Sn?void 0:Sn.metadata)||void 0===Rn?void 0:Rn.label_color)&&void 0!==Cn?Cn:""),$t=function(){Ie.current.forEach(function(n){_(n)}),Ie.current.clear()},Gt=c(function(){var n,e,t,i,o,r;$t(),ie(!1),Fe.current=!1,Re.current=null;var l=Ae.current,u=pi.current;if(null!==l)if("string"==typeof l&&l.includes(S)){var c=l.split(S);(d=(null===(n=kt.current[c[2]])||void 0===n?void 0:n.current)||(null===(e=Ft.current[Number(c[2])])||void 0===e?void 0:e.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(t=Ft.current[l])||void 0===t?void 0:t.current)&&(d.style.paddingTop="0px")}if(null!==u)if("string"==typeof u&&u.includes(S)){c=u.split(S);(a=(null===(i=Pt.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=At.current[Number(c[3])])||void 0===o?void 0:o.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(r=At.current[u])||void 0===r?void 0:r.current)&&(a.style.paddingTop="0px")}fe(null),Ae.current=null,pi.current=null,ue(!1),Un(!1),ze.current&&(ze.current.style.height="0px"),We.current&&(We.current.style.height="0px"),qe.current&&(qe.current.style.height="0px"),Ye.current&&(Ye.current.style.height="0px")},[]),Jt=c(function(){$t(),Gt(),xe(new Set),be([]),_e.current=[],bi([]),Ci(null),ot(M),ct(),requestAnimationFrame(function(){var n;null===(n=De.current)||void 0===n||n.call(De)})},[]),Ut=r(Jt);u(function(){Ut.current=Jt},[Jt]),u(function(){An&&Ut.current()},[An]);var Qt=q({maintainRelativeOrder:!!qn,proposedSections:bt,existingSections:St,activeSideBySideSection:ve,connectedSections:he,resetSideBySide:Gt,setConnectedSections:xe,setConnectedLines:be,cachedConnectedPositions:_e,svgContainerRef:Se,isAnimatingRef:Be,animationTimerRef:we,calculateLinesRef:De,sectionLeftRefs:Ft,sectionRightRefs:At,subSectionLeftRefs:kt,subSectionRightRefs:Pt}),Zt=Qt.expandedSections,ni=Qt.setExpandedSections,ei=Qt.expandedSubSections,ti=Qt.setExpandedSubSections,ii=Qt.toggleSection,oi=c(function(e,t,i,o,r,l,u){var c,d,a,s=m(null==t?void 0:t.id)||m(null==i?void 0:i.id)||"",v=(s?Me[s]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:s,decisioning:[],gap:[],relevance_score:0},f=null!==(d=null===(c=jt.current[o])||void 0===c?void 0:c.current)&&void 0!==d?d:null;return{isLoading:null!==(a=null==Mn?void 0:Mn.isLoading)&&void 0!==a&&a,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:f,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==wn?void 0:wn.documents,input_index_map:null==wn?void 0:wn.input_index_map},deviationData:function(){var e,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,u=function(e){var t=function(n){if(!n||"object"!=typeof n)return null;var e=null==n?void 0:n.deviation_entries;if(e&&"object"==typeof e){var t=Object.keys(e).sort(function(n,e){return Number(n)-Number(e)})[0];if(t&&e[t])return e[t]}var i=Object.keys(n).filter(function(n){return/^\d+$/.test(n)}).sort(function(n,e){return Number(n)-Number(e)});if(i.length&&n[i[0]])return n[i[0]];var o=null==n?void 0:n.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(n,e){return Number(n)-Number(e)})[0];if(r&&o[r])return o[r]}return null}(e);return t?n(n({},e),{deviation_summary:(null==e?void 0:e.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==e?void 0:e.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==e?void 0:e.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==e?void 0:e.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==e?void 0:e.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==e?void 0:e.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):e};if(!("string"==typeof o&&o.includes(S)))return u(l);var c=o.split(S)[1];if(!c)return l;var d=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},a=(null===(e=null==d?void 0:d.deviation_entries)||void 0===e?void 0:e[c])||(null===(r=null==d?void 0:d.deviations)||void 0===r?void 0:r[c])||null;return a?n(n(n({},d),a),{deviation_summary:(null==a?void 0:a.deviation_summary)||(null==d?void 0:d.deviation_summary),deviation_title:(null==a?void 0:a.deviation_title)||(null==d?void 0:d.deviation_title),deviation_impact:(null==a?void 0:a.deviation_impact)||(null==d?void 0:d.deviation_impact),deviation_explanation:(null==a?void 0:a.deviation_explanation)||(null==d?void 0:d.deviation_explanation),evaluation_outputs:(null==a?void 0:a.evaluation_outputs)||(null==d?void 0:d.evaluation_outputs),cognitive_decisioning:(null==a?void 0:a.cognitive_decisioning)||(null==d?void 0:d.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[Me,wn]),ri=c(function(n){dt(),et(null),Ue(n)},[dt]),li=function(n,e,t,i,o,r){var l;if(n.stopPropagation(),Qe.open&&Qe.sectionIdx===o)dt();else{var u=n.currentTarget,c="left";(null===(l=Oe.current)||void 0===l?void 0:l.contains(u))&&(c="right");$t(),Fe.current&&Gt(),xe(new Set),be([]),_e.current=[],ct(),it.open?Yi():rt(),requestAnimationFrame(function(){var n=function(){var n,e,t,i;if("string"==typeof o&&o.includes(S)){var r=o.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===c?null===(n=Mt.current[l])||void 0===n?void 0:n.current:null===(e=Dt.current[l])||void 0===e?void 0:e.current}return"right"===c?null===(t=Mt.current[o])||void 0===t?void 0:t.current:null===(i=Dt.current[o])||void 0===i?void 0:i.current}()||u;Ze(oi(n,e,i,o,t,r))})}},ui=c(function(){null!==Qe.sectionIdx&&Qe.anchorEl?ri(n(n({},Qe),{open:!0})):dt()},[Qe,dt,ri]),ci=c(function(){var n=Qe.sectionIdx,e=Qe.isOrphan;dt(),rt(),null!==n&&(e?ne("No counterpart exists to connect to."):($t(),Fe.current&&Gt(),be([]),_e.current=[],xe(function(e){return e.has(n)?new Set:new Set([n])}),setTimeout(function(){De.current&&De.current()},50)))},[Qe.sectionIdx,Qe.isOrphan,dt,rt,Gt]),di=c(function(){var n=Ce.current;if(n){Ce.current=null;var e=bt.findIndex(function(e){return e.id===n}),t=St.findIndex(function(e){return e.id===n}),i=-1===e?R(bt,n):null,o=-1===t?R(St,n):null,r=-1!==e?e:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=function(n,e,t,i){var o,r,l,u;return-1!==n?null!==(r=null===(o=t.current[n])||void 0===o?void 0:o.current)&&void 0!==r?r:null:e&&null!==(u=null===(l=i.current[e])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(n,e,t){void 0===t&&(t=30);var i=0,o=function(){var r=n();r&&0!==r.getBoundingClientRect().height?(Ie.current.add(r),E(r,e)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(qn)-1!==r&&Ke.current&&c(function(){return u(e,i,Ft,kt)},Ke.current),-1!==l&&Oe.current&&c(function(){return u(t,o,At,Pt)},Oe.current);else{var d=He.current;if(!d)return;c(function(){return-1!==r?u(e,i,Ft,kt):u(t,o,At,Pt)},d)}}},[bt,St,qn,Ft,At,kt,Pt,Ke,Oe,He]),ai=c(function(e){if(e){$t(),Gt(),xe(new Set),be([]),_e.current=[],rt(),ct();var t=bt.findIndex(function(n){return n.id===e}),i=St.findIndex(function(n){return n.id===e}),o=-1===t?R(bt,e):null,r=-1===i?R(St,e):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=-1!==i?i:r?Number(r.split("-")[0]):-1;Ce.current=e,ni(function(e){var t,i=n({},e),o=!1;-1!==l&&(i[t=qn?"left-".concat(l):String(l)]||(i[t]=!0,o=!0));-1!==u&&(i[t=qn?"right-".concat(u):String(u)]||(i[t]=!0,o=!0));return o?i:e}),ti(function(e){var t=n({},e),i=!1,l=function(n){for(var e=n.split("-"),o=e[0],r=1;r<e.length;r++)o+="-".concat(e[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:e}),setTimeout(function(){requestAnimationFrame(function(){Ce.current===e&&si.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(e,'" not found'))}},[bt,St,qn,ni,ti,Gt,rt,ct]),si=r(di);u(function(){si.current=di},[di]);var vi=r(null),fi=r(null),pi=r(null),gi=r(null),hi=r(null),xi=r(null),mi=o([]),yi=mi[0],bi=mi[1];r(null);var Si=o(null),Ri=Si[0],Ci=Si[1];u(function(){if(vt){var n=at.fields.find(function(n){return n.analysisKey===vt||n.key===vt});if(n){var e=_t.current[n.key]||Et.current[n.key];(null==e?void 0:e.current)&&setTimeout(function(){return e.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[vt,at.fields]);var Ii=c(function(n){var e,t,i,o,r,l,u,c,d,a=null===(e=null==zt?void 0:zt.rule_difference_comparison)||void 0===e?void 0:e.fields;if(!a||!a[n])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=a[n],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var f=s.mappings[0]||{};return{score:s.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:s.score,relation:s.relation||"",highlightsA:(null===(c=s.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(d=s.highlights)||void 0===d?void 0:d.ruleB_spans)||[],hasContent:!!v}},[zt]),Bi=c(function(e,t){var i,o,r;void 0===t&&(t="left");var l=null,u=null;if("left"===t)if(l=bt[e],qn&&l){var c=St.filter(function(n){var e;return null===(e=l.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});u=c.find(function(n){return n.evaluationResult})||c[0]}else u=St[e];else if(u=St[e],qn&&u){var d=bt.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(u.selfIndex)});l=d.find(function(n){return n.evaluationResult})||d[0]}else l=bt[e];var a=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,s=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,v=!(!(null==l?void 0:l.cognitiveData)&&!(null==u?void 0:u.cognitiveData));if(!a&&!s&&!v)return n(n({},b(N)),{label:"Not Defined"});var f=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==u?void 0:u.evaluationResult)&&void 0!==o?o:null,p=C(f),g=I(f);return n(n({},b(g)),null!=f?{label:null!==(r=p)&&void 0!==r?r:""}:{label:null})},[bt,St,Me,at,qn]),wi=c(function(e){for(var t,i,o,r,l,u=e.split("-").map(Number),c=bt[u[0]],d=St[u[0]],a=1;a<u.length;a++)(null==c?void 0:c.subsections)&&(c=c.subsections[u[a]]),(null==d?void 0:d.subsections)&&(d=d.subsections[u[a]]);if(!c&&!d)return null;var s=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,v=(null==d?void 0:d.relation)&&"not_defined"!==d.relation,f=m(null==c?void 0:c.id)||m(null==d?void 0:d.id)||"",p=!(!(null==c?void 0:c.cognitiveData)&&!(null==d?void 0:d.cognitiveData));if(!s&&!v&&!p)return n(n({},b(N)),{label:"Not Defined"});null!==(i=null!==(t=null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==t?t:null==d?void 0:d.cognitiveRelevanceScore)&&void 0!==i||f&&(null===(o=Me[f])||void 0===o||o.relevance_score);var g=null!==(l=null!==(r=null==c?void 0:c.evaluationResult)&&void 0!==r?r:null==d?void 0:d.evaluationResult)&&void 0!==l?l:null,h=C(g),x=I(g);return n(n({},b(x)),null!=g?{label:null!=h?h:""}:{label:null})},[bt,St,Me,at]),Ti=c(function(e,t){var i,o,r,l,u,c,d,a,s,v,f,p,g,h,x,m,y;if(!e||null==t)return null;var S=null!==(d=null!==(u=null!==(o=null===(i=null==Pn?void 0:Pn[e])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==wn?void 0:wn.nodes)||void 0===r?void 0:r[e])||void 0===l?void 0:l.evaluation_result)&&void 0!==u?u:null===(c=null==wn?void 0:wn[e])||void 0===c?void 0:c.evaluation_result)&&void 0!==d?d:null;if(!S||"object"!=typeof S)return null;var R=null!==(f=null!==(s=null===(a=null==S?void 0:S.deviations)||void 0===a?void 0:a[t])&&void 0!==s?s:null===(v=null==S?void 0:S.deviation_entries)||void 0===v?void 0:v[t])&&void 0!==f?f:null==S?void 0:S[t],C=null!==(y=null!==(h=null===(g=null===(p=null==R?void 0:R.evaluation_outputs)||void 0===p?void 0:p.metadata)||void 0===g?void 0:g.label_color)&&void 0!==h?h:null===(m=null===(x=null==S?void 0:S.evaluation_outputs)||void 0===x?void 0:x.metadata)||void 0===m?void 0:m.label_color)&&void 0!==y?y:N;return n(n({},b(C)),{label:null})},[Pn,wn]),_i=c(function(){$t(),ni({}),ti({}),Gt(),xe(new Set),be([]),_e.current=[],rt(),ct(),dt(),requestAnimationFrame(function(){De.current&&De.current()})},[ni,ti,Gt,rt,ct,dt]),Ei=l(function(){return Object.values(Zt).some(Boolean)||Object.values(ei).some(Boolean)},[Zt,ei]),Fi=c(function(){var n,e,t,i,o,r,l,u,c,d,a,s,v,f,p,g,h,x,m,y,b,R,C;if(!Ve.current&&!Be.current){Ve.current=!0;try{if(!vi.current)return;var I=function(n){var e=n.split("-"),t=e[0];if(!Zt[t]&&!1===qn)return!1;if(qn&&!Zt["left-".concat(t)]&&!Zt["right-".concat(t)]&&!Zt[t])return!1;for(var i=t,o=1;o<e.length-1;o++)if(i+="-".concat(e[o]),!ei[i])return!1;return!0},T=vi.current.getBoundingClientRect();Pe({width:T.width,height:T.height});var _=[];if(Rt.forEach(function(n){var e,t,i=n.key,o=null===(e=_t.current[i])||void 0===e?void 0:e.current,r=null===(t=Et.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!Be.current){for(var E=0;E<Math.max(bt.length,St.length);E++){var F=null===(n=Ft.current[E])||void 0===n?void 0:n.current,A=null===(e=At.current[E])||void 0===e?void 0:e.current;F&&(F.style.height="auto",F.style.minHeight="0px"),A&&(A.style.height="auto",A.style.minHeight="0px")}qn||Object.keys(kt.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=kt.current[n])||void 0===e?void 0:e.current,o=null===(t=Pt.current[n])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var D={};Rt.forEach(function(n){var e,t,i=n.key,o=null===(e=_t.current[i])||void 0===e?void 0:e.current,r=null===(t=Et.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();D[i]=Math.max(l.height,u.height)}});var M={left:{},right:{}},N={};if(!Be.current)if(qn){if(te&&null!==ve)if("number"==typeof ve){var k=ve,P=bt[k],j=null===(o=Ft.current[k])||void 0===o?void 0:o.current;j&&P&&(P.refIndexes||[]).forEach(function(n){var e,t=St.findIndex(function(e){return e.selfIndex===n}),i=null===(e=At.current[t])||void 0===e?void 0:e.current;if(i&&(Zt["left-".concat(k)]||Zt["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);M.left[k]=Math.max(M.left[k]||0,o),M.right[t]=Math.max(M.right[t]||0,o)}})}else{var H=ve.split(S)[2];if(H){F=null===(r=kt.current[H])||void 0===r?void 0:r.current,A=null===(l=Pt.current[H])||void 0===l?void 0:l.current;if(F&&A){L=Math.max(F.getBoundingClientRect().height,A.getBoundingClientRect().height);N[H]=Math.max(N[H]||0,L)}}}}else{Object.keys(kt.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=kt.current[n])||void 0===e?void 0:e.current,o=null===(t=Pt.current[n])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);N[n]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(E=0;E<Math.min(bt.length,St.length);E++){var F=null===(t=Ft.current[E])||void 0===t?void 0:t.current,A=null===(i=At.current[E])||void 0===i?void 0:i.current;if(F&&A){var L=Math.max(F.getBoundingClientRect().height,A.getBoundingClientRect().height);M.left[E]=L,M.right[E]=L}}}if(Rt.forEach(function(n){var e,t,i=n.key,o=null===(e=_t.current[i])||void 0===e?void 0:e.current,r=null===(t=Et.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=D[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Be.current||(Object.entries(M.left).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=Ft.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(M.right).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=At.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),qn||Object.keys(N).forEach(function(n){var e,t,i=null===(e=kt.current[n])||void 0===e?void 0:e.current,o=null===(t=Pt.current[n])||void 0===t?void 0:t.current;if(i&&o&&N[n]){var r=N[n];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),qn)bt.forEach(function(n,e){var t;(null===(t=Ft.current[e])||void 0===t?void 0:t.current)&&(n.refIndexes||[]).forEach(function(n){var t,i,o,r,l,u,c,d,a,s,v=St.findIndex(function(e){return e.selfIndex===n});if(-1!==v){var f=null===(t=Dt.current[e])||void 0===t?void 0:t.current,p=null===(i=Mt.current[v])||void 0===i?void 0:i.current;if(f&&p){var g=f.getBoundingClientRect(),h=p.getBoundingClientRect(),x=g.right-T.left,m=h.left-T.left,y=g.top+g.height/2-T.top,b=h.top+h.height/2-T.top;if(te&&ve===e){var S=null!==(r=null===(o=Ke.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=Oe.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(d=null===(c=Ke.current)||void 0===c?void 0:c.clientHeight)&&void 0!==d?d:1/0),I=R+(null!==(s=null===(a=Oe.current)||void 0===a?void 0:a.clientHeight)&&void 0!==s?s:1/0),B=g.top+g.height/2,w=h.top+h.height/2,E=function(n,e,t){return Math.max(e,Math.min(t,n))};y=E(B,S,C)-T.top,b=E(w,R,I)-T.top}var F=Bi(e);F&&_.push({id:"line-".concat(e,"-").concat(v),x1:x,y1:y,x2:m,y2:b,style:F,sectionIdx:e,targetRightIdx:v})}}})});else{for(E=0;E<Math.min(bt.length,St.length);E++){var O=null===(u=Ft.current[E])||void 0===u?void 0:u.current,z=null===(c=At.current[E])||void 0===c?void 0:c.current;if(O&&z){var W=O.getBoundingClientRect(),q=z.getBoundingClientRect(),Y=Math.max(W.top,q.top)+18-T.top,K=(null===(d=St[E])||void 0===d?void 0:d.id)||"sec-".concat(E);(Z=Bi(E))&&_.push({id:K,x1:W.right-T.left,y1:Y,x2:q.left-T.left,y2:Y,style:Z,sectionIdx:E,hasCognitive:!!((null===(a=bt[E])||void 0===a?void 0:a.cognitiveData)||(null===(s=St[E])||void 0===s?void 0:s.cognitiveData)||K&&Me[K]),isSubSection:!1})}}Object.keys(kt.current).forEach(function(n){var e,t,i,o,r,l;if(I(n)){var u=null===(e=kt.current[n])||void 0===e?void 0:e.current,c=null===(t=Pt.current[n])||void 0===t?void 0:t.current;if(u&&c){for(var d=n.split("-").map(Number),a=bt[d[0]],s=St[d[0]],v=1;v<d.length;v++)(null==a?void 0:a.subsections)&&(a=a.subsections[d[v]]),(null==s?void 0:s.subsections)&&(s=s.subsections[d[v]]);var f=!!a&&((null===(i=a.displayTitle)||void 0===i||i)&&B(a.title)),p=!!a&&((null===(o=a.displayContent)||void 0===o||o)&&B(a.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&B(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&B(s.content));if(f&&p||g&&h){var x=u.getBoundingClientRect(),m=c.getBoundingClientRect(),y=Math.max(x.top,m.top)+16-T.top,b=wi(n);b&&"Not Defined"!==b.label&&_.push({id:"subsec-".concat(n),x1:x.right-T.left,y1:y,x2:m.left-T.left,y2:y,style:b,sectionIdx:d[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:!(!(null==a?void 0:a.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(te&&"string"==typeof ve&&ve.includes(S)){var V=ve.split(S),X=V[0],$=V[1],G=V[2],J=(V[3],"".concat(X).concat(S).concat($)),U=null===(v=Dt.current[J])||void 0===v?void 0:v.current,Q=null===(f=Mt.current[J])||void 0===f?void 0:f.current;if(U&&Q){var Z,nn=U.getBoundingClientRect(),en=Q.getBoundingClientRect(),tn=nn.right-T.left,on=en.left-T.left,rn=nn.top+nn.height/2-T.top,ln=en.top+en.height/2-T.top;if(qn){var un=null!==(g=null===(p=Ke.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==g?g:0,cn=null!==(x=null===(h=Oe.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==x?x:0,dn=un+(null!==(y=null===(m=Ke.current)||void 0===m?void 0:m.clientHeight)&&void 0!==y?y:1/0),an=cn+(null!==(R=null===(b=Oe.current)||void 0===b?void 0:b.clientHeight)&&void 0!==R?R:1/0),sn=function(n,e,t){return Math.max(e,Math.min(t,n))};rn=sn(nn.top+nn.height/2,un,dn)-T.top,ln=sn(en.top+en.height/2,cn,an)-T.top}(Z=null!==(C=Ti(X,$))&&void 0!==C?C:wi(G))&&_.push({id:"line-subsec-".concat(J),x1:tn,y1:rn,x2:on,y2:ln,style:Z,sectionIdx:Number(G.split("-")[0]),isSubSection:!0,subSectionKeyPath:ve})}}if(bi(_),hi.current&&xi.current){var vn=hi.current.getBoundingClientRect(),fn=xi.current.getBoundingClientRect(),pn=(vn.top+vn.height/2-T.top+fn.top+fn.height/2-T.top)/2;Ci({x1:vn.right-T.left,x2:fn.left-T.left,y:pn})}else Ci(null);if(he.size>0){var gn=[],hn=Ke.current,xn=Oe.current;if(hn&&xn){var mn=[],yn=hn.getBoundingClientRect().top,bn=xn.getBoundingClientRect().top,Sn=yn+hn.clientHeight,Rn=bn+xn.clientHeight,Cn=hn.scrollTop,In=xn.scrollTop,Bn=T.top,wn=function(n,e,t){return Math.max(e,Math.min(t,n))};he.forEach(function(n){var e,t,i,o,r,l;if("string"==typeof n&&n.includes(S)){var u=n.split(S),c=u[0],d=u[1],a=u[2],s=(u[3],"".concat(c).concat(S).concat(d)),v=null===(e=Dt.current[s])||void 0===e?void 0:e.current,f=null===(t=Mt.current[s])||void 0===t?void 0:t.current;if(!v||!f)return;var p=v.getBoundingClientRect(),g=f.getBoundingClientRect(),h=null!==(i=Ti(c,d))&&void 0!==i?i:wi(a),x=(P=p.right-T.left)+.5*((j=g.left-T.left-0)-P),m=p.top+p.height/2,y=g.top+g.height/2,b=m-yn+Cn,R=y-bn+In,C="conn-subsec-".concat(s);mn.push({lhsScrollY:b,rhsScrollY:R,x1:P,x2:j,containerTop:Bn,leftIdx:n,rhsArrayIdx:n,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var I=wn(m,yn,Sn),B=wn(y,bn,Rn),_=I-Bn,E=B-Bn,F=y>=bn-4&&y<=Rn+4,A="";A=(H=m>=yn-4&&m<=Sn+4)&&F?w(P,_,j,E):H&&!F?"M ".concat(P,",").concat(_," L ").concat(x,",").concat(_," L ").concat(x,",").concat(E):!H&&F?"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E," L ").concat(j,",").concat(E):"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E),gn.push({id:C,pathD:A,style:h,leftIdx:n,rhsArrayIdx:n})}else if(qn){var D=n,M=bt[D];if(!(null===(l=null==M?void 0:M.refIndexes)||void 0===l?void 0:l.length))return;M.refIndexes.forEach(function(n){var e,t,i=St.findIndex(function(e){return e.selfIndex===n});if(-1!==i){var o=null===(e=Dt.current[D])||void 0===e?void 0:e.current,r=null===(t=Mt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=Bi(D),d=l.right-T.left,a=u.left-T.left-0,s=d+.5*(a-d),v=l.top+l.height/2,f=u.top+u.height/2,p=v-yn+Cn,g=f-bn+In,h="conn-".concat(D,"-").concat(i);mn.push({lhsScrollY:p,rhsScrollY:g,x1:d,x2:a,containerTop:Bn,leftIdx:D,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var x=wn(v,yn,Sn),m=wn(f,bn,Rn),y=x-Bn,b=m-Bn,S=v>=yn-4&&v<=Sn+4,R=f>=bn-4&&f<=Rn+4,C="";C=S&&R?w(d,y,a,b):S&&!R?"M ".concat(d,",").concat(y," L ").concat(s,",").concat(y," L ").concat(s,",").concat(b):!S&&R?"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b," L ").concat(a,",").concat(b):"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b),gn.push({id:h,pathD:C,style:c,leftIdx:D,rhsArrayIdx:i})}}})}else{var N=n,k=N;v=null===(o=Dt.current[N])||void 0===o?void 0:o.current,f=null===(r=Mt.current[k])||void 0===r?void 0:r.current;if(!v||!f)return;var P,j;p=v.getBoundingClientRect(),g=f.getBoundingClientRect(),h=Bi(N),x=(P=p.right-T.left)+.5*((j=g.left-T.left-0)-P),m=p.top+p.height/2,y=g.top+g.height/2,b=m-yn+Cn,R=y-bn+In,C="conn-".concat(N,"-").concat(k);mn.push({lhsScrollY:b,rhsScrollY:R,x1:P,x2:j,containerTop:Bn,leftIdx:N,rhsArrayIdx:k,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var H;I=wn(m,yn,Sn),B=wn(y,bn,Rn),_=I-Bn,E=B-Bn,F=y>=bn-4&&y<=Rn+4,A="";A=(H=m>=yn-4&&m<=Sn+4)&&F?w(P,_,j,E):H&&!F?"M ".concat(P,",").concat(_," L ").concat(x,",").concat(_," L ").concat(x,",").concat(E):!H&&F?"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E," L ").concat(j,",").concat(E):"M ".concat(x,",").concat(_," L ").concat(x,",").concat(E),gn.push({id:C,pathD:A,style:h,leftIdx:N,rhsArrayIdx:k})}}),_e.current=mn}be(gn)}else be([]),_e.current=[]}catch(n){console.error("Line render safe fail: ",n)}finally{Ve.current=!1}}},[Rt,bt,St,Me,at,Ii,Bi,Ti,qn,te,ve,he,Zt,ei]),Ai=c(function(){var n,e,t,i,o,r,l,u,c,d,a,s,v,f,p=_e.current;if(p.length&&!Be.current){var g=null!==(e=null===(n=Ke.current)||void 0===n?void 0:n.scrollTop)&&void 0!==e?e:0,h=null!==(i=null===(t=Oe.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,x=null!==(r=null===(o=Ke.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,m=null!==(u=null===(l=Oe.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(d=null===(c=Ke.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==d?d:0,b=null!==(s=null===(a=Oe.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+x,R=b+m,C=null!==(f=null===(v=vi.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==f?f:0,I=function(n,e,t){return Math.max(e,Math.min(t,n))};p.forEach(function(n){var e=n.lhsScrollY-g+y,t=n.rhsScrollY-h+b,i=Te.current[n.styleId+"-stroke"],o=Te.current[n.styleId+"-bg"];if(i||o){var r,l=I(e,y,S),u=I(t,b,R),c=l-C,d=u-C,a=e>=y-4&&e<=S+4,s=t>=b-4&&t<=R+4,v=n.x1+.5*(n.x2-n.x1);r=a&&s?w(n.x1,c,n.x2,d):a&&!s?"M ".concat(n.x1,",").concat(c," L ").concat(v,",").concat(c," L ").concat(v,",").concat(d):!a&&s?"M ".concat(v,",").concat(c," L ").concat(v,",").concat(d," L ").concat(n.x2,",").concat(d):"M ".concat(v,",").concat(c," L ").concat(v,",").concat(d),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);u(function(){De.current=Fi},[Fi]);var Di=r(null),Mi=r(null),Ni=c(function(){_e.current.length>0&&!Be.current||(null!==Di.current&&clearTimeout(Di.current),Di.current=setTimeout(function(){De.current(),Di.current=null},50))},[]),ki=c(function(){ae(!0),ue(!1),Re.current=null,null!==Mi.current&&clearTimeout(Mi.current),null!==Di.current&&(clearTimeout(Di.current),Di.current=null),Mi.current=setTimeout(function(){var n,e,t,i,o,r,l,u,c,d,a;try{if(_e.current=[],Fe.current&&null!==Ae.current&&null!==pi.current){var s=Ae.current,v=pi.current,f="string"==typeof s&&s.includes(S),p=null,g=null,h=null,x=null;if(f){var m=s.split(S),y="".concat(m[0]).concat(S).concat(m[1]);p=(null===(n=Dt.current[y])||void 0===n?void 0:n.current)||null,g=(null===(e=Mt.current[y])||void 0===e?void 0:e.current)||null,h=(null===(t=kt.current[m[2]])||void 0===t?void 0:t.current)||(null===(i=Ft.current[Number(m[2])])||void 0===i?void 0:i.current)||null,x=(null===(o=Pt.current[m[3]])||void 0===o?void 0:o.current)||(null===(r=At.current[Number(m[3])])||void 0===r?void 0:r.current)||null}else p=(null===(l=jt.current[s])||void 0===l?void 0:l.current)||null,h=(null===(u=Ft.current[s])||void 0===u?void 0:u.current)||null,g=(null===(c=Nt.current[v])||void 0===c?void 0:c.current)||null,x=(null===(d=At.current[v])||void 0===d?void 0:d.current)||null;if(p&&g&&h&&x){if(h.style.paddingTop="0px",x.style.paddingTop="0px",!qn){var b=p.getBoundingClientRect(),R=g.getBoundingClientRect(),C=b.top-R.top;C>0?x.style.paddingTop="".concat(C,"px"):C<0&&(h.style.paddingTop="".concat(Math.abs(C),"px"))}var I=Ke.current,B=Oe.current;if(I&&B){var w=p.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop,T=g.getBoundingClientRect().top-B.getBoundingClientRect().top+B.scrollTop-(w-I.scrollTop);Math.abs(B.scrollTop-T)>1&&(B.scrollTop=T)}}}null===(a=De.current)||void 0===a||a.call(De),Fe.current&&ue(!0)}catch(n){console.error("Safely caught error during resize calculation:",n)}finally{ae(!1),Mi.current=null}},150)},[qn,bt,St]),Pi=c(function(n){if(null!==Xe.current&&$e.current&&Math.abs(n.currentTarget.scrollTop-Xe.current)<=2){var e=$e.current;Xe.current=null,$e.current=null,e()}pe.current||(qn||Ni(),Ee.current||(Ee.current=!0,requestAnimationFrame(function(){var n,e,t,i,o,r,l;if(Fe.current){var u=Ke.current,c=Oe.current;if(u&&c&&gi.current){if(!Re.current){var d=Ae.current,a=void 0;if("string"==typeof d&&d.includes(S)){var s=d.split(S),v="".concat(s[0]).concat(S).concat(s[1]);a=null===(n=Dt.current[v])||void 0===n?void 0:n.current}else a=null===(e=Dt.current[d])||void 0===e?void 0:e.current;if(a){var f=a.getBoundingClientRect();Re.current={badgeScreenY:f.top+f.height/2,initialScrollTop:u.scrollTop,leftTop:u.getBoundingClientRect().top,leftBottom:u.getBoundingClientRect().top+u.clientHeight,cTop:null!==(i=null===(t=vi.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(Re.current){var p=Re.current,g=u.scrollTop-p.initialScrollTop,h=p.badgeScreenY-g,x=((o=h,r=p.leftTop,l=p.leftBottom,Math.max(r,Math.min(l,o)))-p.cTop).toString(),m=h>=p.leftTop-4&&h<=p.leftBottom+4;gi.current.setAttribute("y1",x),gi.current.setAttribute("y2",x),gi.current.setAttribute("visibility",m?"visible":"hidden")}}}_e.current.length>0&&Ai(),Ee.current=!1})))},[Ai,qn,Ni]),ji=r(0),Hi=r(0),Li=r(0),Oi=r(function(){});r(null),u(function(){Oi.current=ki},[ki]),u(function(){var n=setTimeout(Ni,250),e=function(){return Oi.current()};return window.addEventListener("resize",e),function(){clearTimeout(n),null!==Di.current&&clearTimeout(Di.current),null!==Mi.current&&clearTimeout(Mi.current),window.removeEventListener("resize",e)}},[mt,yt,zt,Rt,Zt,ei,bt,St,at,Ni,te,ve,le,he]),u(function(){var n=function(n,e,t,i,o){e.current=n.getBoundingClientRect().width;var r=new ResizeObserver(function(n){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=n[n.length-1];if(c){var d=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(d-e.current)<1?o():(e.current=d,i())}})});return r.observe(n),r},e={current:null},t={current:null},i={current:null},o=[],r=[e,t,i];return Le.current&&o.push(n(Le.current,ji,e,function(){return Oi.current()},function(){})),He.current&&o.push(n(He.current,Hi,t,function(){return Oi.current()},function(){return De.current()})),vi.current&&o.push(n(vi.current,Li,i,function(){return Oi.current()},function(){return De.current()})),function(){o.forEach(function(n){return n.disconnect()}),r.forEach(function(n){null!==n.current&&(cancelAnimationFrame(n.current),n.current=null)})}},[]),u(function(){Fe.current=te},[te]),u(function(){Ae.current=ve},[ve]);var zi=c(function(n,e,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,u=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";dt(),null!=n&&(e?ne("No counterpart exists for this section."):($t(),te&&ve===n?r?Gt():null==l||l():(xe(new Set([n])),be([]),_e.current=[],Un(!0),pe.current=!0,fe(n),Ae.current=n,ie(!0),Fe.current=!0,ue(!1),ze.current&&(ze.current.style.height="0px"),We.current&&(We.current.style.height="0px"),qe.current&&(qe.current.style.height="0px"),Ye.current&&(Ye.current.style.height="0px"),requestAnimationFrame(function(){var e,t,i,o,r,c="string"==typeof n&&n.includes(S),d=null,a=null,s=null;if(c){var v=n.split(S),f="".concat(v[0]).concat(S).concat(v[1]);d=(null===(e=Dt.current[f])||void 0===e?void 0:e.current)||null,a=(null===(t=Mt.current[f])||void 0===t?void 0:t.current)||null,s=a?n:null}else if(d=(null===(i=jt.current[n])||void 0===i?void 0:i.current)||null,qn){var p=bt[n],g=(null==p?void 0:p.refIndexes)||[];if(g.length>0){var h=g[0],x=St.findIndex(function(n){return n.selfIndex===h});-1!==x&&(a=(null===(r=Nt.current[x])||void 0===r?void 0:r.current)||null,s=x)}}else a=(null===(o=Nt.current[n])||void 0===o?void 0:o.current)||null,s=a?n:null;pi.current=s;var m=Ke.current,y=Oe.current,b=function(){!function(){var e,t,i,o,r,l,u,d,a,v,f,p,g=null,h=null,x=null,m=null;if(c){var y=n.split(S),b="".concat(y[0]).concat(S).concat(y[1]);g=(null===(e=kt.current[y[2]])||void 0===e?void 0:e.current)||(null===(t=Ft.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=Pt.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=At.current[Number(y[3])])||void 0===o?void 0:o.current)||null,x=(null===(r=Dt.current[b])||void 0===r?void 0:r.current)||g,m=(null===(l=Mt.current[b])||void 0===l?void 0:l.current)||h}else{var R=Number(n),C=null!==s?Number(s):R;g=(null===(u=Ft.current[R])||void 0===u?void 0:u.current)||null,h=(null===(d=At.current[C])||void 0===d?void 0:d.current)||null,x=(null===(a=Dt.current[R])||void 0===a?void 0:a.current)||(null===(v=jt.current[R])||void 0===v?void 0:v.current)||g,m=(null===(f=Mt.current[C])||void 0===f?void 0:f.current)||(null===(p=Nt.current[C])||void 0===p?void 0:p.current)||h}if(x&&m&&g&&h){g.style.paddingTop="0px",h.style.paddingTop="0px";var I=x.getBoundingClientRect(),B=m.getBoundingClientRect(),w=I.top-B.top;w>0?h.style.paddingTop="".concat(w,"px"):w<0&&(g.style.paddingTop="".concat(Math.abs(w),"px"))}}(),ue(!0),De.current&&De.current(),pe.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):m&&m.dispatchEvent(new Event("scroll")),Un(!1),null==l||l()};if(!d||!m)return pe.current=!1,Un(!1),void(null==l||l());if(a&&y){if(!qn){var R=0;R="right"===u?a?a.getBoundingClientRect().top:0:d?d.getBoundingClientRect().top:0;var C=He.current,I=(null==C?void 0:C.getBoundingClientRect().top)||0,B=C?C.scrollTop+R-I-150:0;return C?void T(C,B,200,b):void b()}var w=d.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop,_=a.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,E=200;if("left"===u){var F=_-(w-m.scrollTop);F<0&&ze.current&&(ze.current.style.height="".concat(Math.abs(F),"px")),requestAnimationFrame(function(){var n,e=y.scrollHeight-y.clientHeight;if(F<0)n=0;else{if(F>e){var t=F-e;return We.current&&(We.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(y,F,E,b)})}n=F}T(y,n,E,b)})}else{var A=w-(_-y.scrollTop);A<0&&qe.current&&(qe.current.style.height="".concat(Math.abs(A),"px")),requestAnimationFrame(function(){var n,e=m.scrollHeight-m.clientHeight;if(A<0)n=0;else{if(A>e){var t=A-e;return Ye.current&&(Ye.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(m,A,E,b)})}n=A}T(m,n,E,b)})}}else b()}))))},[ve,dt,St,te,qn,bt,Gt]),Wi=c(function(n,e,t,i){var o,r="string"==typeof i?m(i).trim():m(null==i?void 0:i.deviation_summary).trim(),l=n.currentTarget;ct();var u="left";(null===(o=Oe.current)||void 0===o?void 0:o.contains(l))&&(u="right");var c=function(){var n,t,i,o;if("string"==typeof e&&e.includes(S)){var r=e.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===u?null===(n=Mt.current[l])||void 0===n?void 0:n.current:null===(t=Dt.current[l])||void 0===t?void 0:t.current}return"right"===u?null===(i=Mt.current[e])||void 0===i?void 0:i.current:null===(o=Dt.current[e])||void 0===o?void 0:o.current};if(t)return Gt(),xe(new Set),be([]),_e.current=[],void(r&&requestAnimationFrame(function(){var n=c()||l;ot({open:!0,anchorEl:n,summary:i})}));zi(e,t,r?{toggleIfSame:!1,sourceSide:u,onReady:function(){var n=c()||l;ot({open:!0,anchorEl:n,summary:i})}}:{toggleIfSame:!1,sourceSide:u})},[zi,ct,ot,Gt]),qi=c(function(){var n,e=Qe.sectionIdx,t=Qe.isOrphan;if(rt(),null!=e){var i="left";Qe.anchorEl&&(null===(n=Oe.current)||void 0===n?void 0:n.contains(Qe.anchorEl))&&(i="right"),zi(e,t,{sourceSide:i})}},[zi,Qe.isOrphan,Qe.sectionIdx,Qe.anchorEl,rt]),Yi=c(function(){rt(),Gt(),xe(new Set),be([]),_e.current=[]},[rt,Gt]),Ki=null!==Qe.sectionIdx&&he.has(Qe.sectionIdx),Vi=Y({proposedSections:bt,existingSections:St,parentDeviationRecord:Ct,expandedSections:Zt,maintainRelativeOrder:!!qn,scrollContainerRef:He,leftContainerRef:Ke,lhsBadgeRefs:Dt,rhsBadgeRefs:Mt}),Xi=Vi.showDeviationNavigation,$i=Vi.showOpenNodeRef,Gi=l(function(){var n;if(!jn)return null;var e=null===(n=null==jn?void 0:jn.id)||void 0===n?void 0:n.split(":")[0];for(var t in Ct){if((Ct[t]||[]).some(function(n){return n.id===e}))return t}return null},[jn,Ct]),Ji=r({id:null,triggerMs:null}),Ui=r(null);u(function(){var t;if(null==jn?void 0:jn.id){var i=Number(jn.trigger),o=Ji.current;if((null==o?void 0:o.triggerMs)!==i){if(!(jn.id.includes(":")&&/:\d+$/.test(jn.id)))return Ji.current={id:jn.id,triggerMs:i},void ai(jn.id);var r=null===(t=null==jn?void 0:jn.id)||void 0===t?void 0:t.split(":"),l=r[0],u=r[1],c=null!=u?u:"0";Ui.current!==jn.id&&(rt(),ct(),Gt(),xe(new Set),be([]),_e.current=[],Ui.current=jn.id);var d=!1,a=0,s=null,v=150,f=function(n,e){for(var t=function(n,i){if(!n)return null;if(n.id===e)return i;if(!Array.isArray(n.subsections))return null;for(var o=0;o<n.subsections.length;o++){var r=t(n.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<n.length;i++){var o=t(n[i],String(i));if(o)return o}return null},p=function(){var t,o,r,u;if(!d){var g=function(){Ji.current={id:jn.id,triggerMs:i}},h=null,x=null;for(var m in Ct){var y=Ct[m].find(function(n){return n.id===l});if(y){h=m,x=y;break}}if(x&&h){var b=bt.findIndex(function(n){return n.id===h}),R=St.findIndex(function(n){return n.id===h}),C=-1===b&&-1!==R,I=f(bt,x.id),B=f(St,x.id);if(I&&!B&&!C){var w=I.split("-"),T=Number(w[0]);if(qn){var _=null===(o=null===(t=bt[T])||void 0===t?void 0:t.refIndexes)||void 0===o?void 0:o[0],E=St.findIndex(function(n){return n.selfIndex===_});-1!==E&&(T=E)}B=e([T],w.slice(1),!0).join("-")}if(I||B){var F=C||!I&&!!B,A=I?Number(I.split("-")[0]):b,D=B?Number(B.split("-")[0]):R;if(F){if(!(qn?!!Zt["right-".concat(D)]:!!Zt[String(D)])&&D>=0)return ii(D,"right"),a+=1,void(s=setTimeout(p,450))}else if(!(qn?!!Zt["left-".concat(A)]:!!Zt[String(A)])&&A>=0)return ii(A,"left"),a+=1,void(s=setTimeout(p,450));var M,N=I||"",k=B||"",P="".concat(x.id).concat(S).concat(c).concat(S).concat(N).concat(S).concat(k),j="".concat(x.id).concat(S).concat(c),H=null===(r=Dt.current[j])||void 0===r?void 0:r.current,L=null===(u=Mt.current[j])||void 0===u?void 0:u.current,O=F||!H&&!!L,z=O?L:H;if(M=qn?O?Oe.current:Ke.current:He.current,z&&M){var W=z.getBoundingClientRect();if(0===W.height)return void((a+=1)<2?s=setTimeout(p,v):g());var q=M.getBoundingClientRect(),Y=W.top-q.top+M.scrollTop-q.height/2+W.height/2+150,K=function(){var e,t,i,o,r;if(!d){g();var l=window.getComputedStyle(z).color;H&&(H.style.transition="box-shadow 300ms ease-in-out",H.style.boxShadow="0 0 10px ".concat(l)),L&&(L.style.transition="box-shadow 300ms ease-in-out",L.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){H&&(H.style.boxShadow=""),L&&(L.style.boxShadow="")},2e3);var u=(null===(t=null===(e=x.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[c])||x,a=(null===(i=x.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||x.evaluation_outputs;if(!(!!H&&!!L)){var s=O?(null===(o=Mt.current[j])||void 0===o?void 0:o.current)||L:(null===(r=Dt.current[j])||void 0===r?void 0:r.current)||H;return ot({open:!0,anchorEl:s,summary:n(n({},u),{evaluation_outputs:a})}),void(null==Hn||Hn())}zi(P,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,t=(null===(e=Dt.current[j])||void 0===e?void 0:e.current)||H;console.log("Summary data",a,u),ot({open:!0,anchorEl:t,summary:n({},u)})}})}};Math.abs(M.scrollTop-Y)<=2?K():(Xe.current=Y,$e.current=K,M.scrollTo({top:Y,behavior:"smooth"}),s&&clearTimeout(s),s=setTimeout(function(){if($e.current){Xe.current=null;var n=$e.current;$e.current=null,n()}},800))}else(a+=1)<2?s=setTimeout(p,v):g()}else(a+=1)<2?s=setTimeout(p,v):g()}else(a+=1)<2?s=setTimeout(p,v):g()}};return s=setTimeout(p,v),function(){d=!0,s&&clearTimeout(s)}}}},[jn,Ct,bt,St,qn,Zt,ii,zi,ot,ai]);var Qi=function(n){var e=n.section,t=n.keyPath,o=n.depth,r=void 0===o?0:o,l=n.columnKey,u=void 0===l?"left":l,c=n.parentNodeId;return i(X,{section:e,keyPath:t,depth:r,columnKey:u,parentNodeId:void 0===c?"":c,expandedSubSections:ei,setExpandedSubSections:ti,maintainRelativeOrder:qn||!1,proposedSections:bt,existingSections:St,treeData:wn,deviationNumberRegistry:It,connectedSections:he,activeSideBySideSection:ve,resolvedMarkdownStyles:je,getSubSectionRef:Lt,getSubSectionCompareStyle:wi,getBadgeRef:Ot,openMoreFunctionsPopup:li,openSummaryPopup:Wi,showDeviationBadges:Kn,resetSideBySide:Gt,setConnectedSections:xe,setConnectedLines:be,cachedConnectedPositions:_e,isProposingFix:On,proposingFixNodeId:zn})};return t(d,n({ref:Le,sx:n(n({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},qn?{}:{overflow:"visible"}),{position:"relative"})},{children:[Xn&&i(d,n({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(H,{})})),it.open&&i($,{open:it.open,anchorEl:it.anchorEl,containerEl:fi.current,clipTopEl:hi.current,scrollContainerEl:He.current,onClose:Yi,summary:it.summary}),i(j,{open:Qe.open,anchorEl:Qe.anchorEl,sectionTitle:Qe.sectionTitle,referenceSectionTitle:Qe.refSectionTitle,onClose:dt,onOpenCognitiveCompare:ui,onOpenSideBySide:qi,onConnect:ci,isConnected:Ki,isOrphan:Qe.isOrphan}),Je.open&&i(P,{open:Je.open,popupRef:ut,position:nt,popupConfig:Nn,onClose:function(){et(null),Ue(function(e){return n(n({},e),{open:!1})}),lt(null)},markdownStyles:Fn,sectionTitle:Je.sectionTitle,referenceSectionTitle:Je.refSectionTitle,cognitiveData:Je.cognitiveData,anchorEl:Je.anchorEl,sectionAnchorEl:Je.sectionAnchorEl,scrollContainerEl:He.current,badgeStyle:Je.badgeStyle,docData:Je.docData,deviationData:Je.deviationData,isLoading:Je.isLoading}),i(a,n({open:!!Zn,autoHideDuration:8e3,onClose:function(){return ne(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,n({onClose:function(){return ne(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Zn}))})),i(K,{componentHeaderText:Bn,displayConfig:Mn,maintainRelativeOrder:qn,onCollapseAll:_i,showCollapseAll:Ei,onToggleView:function(n){$n(!0),setTimeout(function(){Yn(!n),Gt(),rt(),xe(new Set),be([]),_e.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){$n(!1)},600)})})},50)}}),i(d,n({ref:He,onScroll:Pi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:qn?"hidden":"auto",borderTop:Wt&&qt?"none":"1.5px solid #EEF0F4"}},{children:i(d,n({sx:n({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},qn?{flex:1,minHeight:0}:{})},{children:t(d,n({ref:vi,sx:n({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},qn?{flex:1,overflow:"visible"}:{})},{children:[t("svg",n({ref:Se,style:{position:"absolute",top:0,left:0,width:ke.width||"100%",height:ke.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:de?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Ri&&i("g",{children:i("line",{x1:Ri.x1,y1:Ri.y,x2:Ri.x2,y2:Ri.y,stroke:Xt.badgeBorder,strokeWidth:"1.5"})}),yi.map(function(e){var o,r,l,u,c,a,s=e.x1+.5*(e.x2-e.x1),v=(e.y1+e.y2)/2;if("Not Defined"===e.style.label&&!e.hasCognitive)return null;if(e.isSubSection?te&&ve===e.subSectionKeyPath&&le:te&&ve===e.sectionIdx&&le)return null;if(!qn){var f=e.isSubSection?w(e.x1,e.y1,e.x2,e.y2):"M ".concat(e.x1," ").concat(e.y1," L ").concat(e.x2," ").concat(e.y2),g=bt[e.sectionIdx]||{title:"",content:""},x=St[e.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",g,x),e.isSubSection&&e.subSectionKeyPath){var m=e.subSectionKeyPath.includes(S)?e.subSectionKeyPath.split(S):[],y=m[2]||e.subSectionKeyPath,b=m[3]||y,R=y.split("-").map(Number),C=b.split("-").map(Number),I=null,B=null;R.length>0&&(I=bt[R[0]]),C.length>0&&(B=St[C[0]]);var T=(null==I?void 0:I.title)||"",_=(null==B?void 0:B.title)||"";console.log("Root Parent Titles:",T,_);for(var E=1;E<R.length;E++)(null==I?void 0:I.subsections)&&(I=I.subsections[R[E]]);for(E=1;E<C.length;E++)(null==B?void 0:B.subsections)&&(B=B.subsections[C[E]]);I&&(g=n(n({},I),{title:T||I.title})),console.log("Base Section for Subsection Badge:",g),B&&(x=n(n({},B),{title:_||B.title})),console.log("Ref Section for Subsection Badge:",x)}var F=!(null===(o=g.cognitiveData)||void 0===o?void 0:o.isMissingRationale)||Boolean(null===(l=null===(r=g.cognitiveData)||void 0===r?void 0:r.decisioning)||void 0===l?void 0:l.length),A=(null===(a=null===(c=null===(u=g.evaluationResult)||void 0===u?void 0:u.cognitive_decisioning)||void 0===c?void 0:c.decisioning_factors)||void 0===a?void 0:a.length)||!1,D=F||A;return t("g",{children:[i("path",{d:f,fill:"none",stroke:e.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",n({x:s-100,y:v-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(d,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(d,n({onClick:function(n){n.stopPropagation(),D&&(Je.open&&tt===e.id?ct():(lt(e.id),ri(oi(n.currentTarget,g,x,e.sectionIdx,e.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:e.style.badgeBg,color:e.style.badgeText,border:"1px solid ".concat(e.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:D?"pointer":"default"}},{children:[e.style.badgeText===N&&null==e.style.label?i(L,{color:e.style.badgeText}):0===e.style.label?"Same":e.style.label,i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),D&&i(p,{size:11,style:{transform:Je.open&&tt===e.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},e.id)}return null}),i(G,{connectedLines:ye,pathRefs:Te})]})),t(d,n({sx:n({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},qn?{flex:1,overflow:"visible"}:{})},{children:[i(d,n({ref:hi,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:i(v,n({title:gt,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:gt}))}))})),t(d,n({ref:Ke,onScroll:Pi,sx:n({p:"12px",display:"flex",flexDirection:"column"},qn?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:qe,style:{width:"100%",height:"0px",flexShrink:0}}),wt&&bt.map(function(e,o){var r,l,u=!e.title&&!e.content;if(qn&&u)return null;var c=e,a=Bi(o,"left"),s=qn?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!St[o],v=qn?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:o+1,f=he.has(o),p=y(c.evaluationResult,null==a?void 0:a.deviationLabel);return i(d,n({ref:Ht(o),sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:Ft.current[o],sx:n({width:"100%",display:"flex",flexDirection:"column",minWidth:0},f&&{borderRadius:"6px",outline:"2px solid ".concat((null==a?void 0:a.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(V,{section:e,idx:o,columnKey:"left",colRef:Ht("left-accordion-".concat(o)),mb:0,treeData:wn,proposedSections:bt,existingSections:St,deviationNumberRegistry:It,getSectionCompareStyle:Bi,getBadgeRef:Ot,connectedSections:he,openMoreFunctionsPopup:li,openSummaryPopup:Wi,deviationNodeIdToView:null==jn?void 0:jn.id,deviationTargetParentId:Gi,parentNodeId:(null===(l=null==wn?void 0:wn.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:qn?!!Zt["left-".concat(o)]:!!Zt[String(o)],onToggle:function(){Yi(),ii(o,"left")},navigation:e.id?Xi[e.id]:null,showOpenNodeRef:$i,resolvedMarkdownStyles:je,maintainRelativeOrder:qn,showDeviationBadges:Kn,renderSubSections:Qi,isProposingFix:On,proposingFixNodeId:zn,collisionKey:"".concat(te?"1":"0","-").concat(String(null!=ve?ve:""))})})),qn&&a&&t(d,n({ref:Dt.current[o],onClick:function(n){var t=qn?St.find(function(n){var e;return null===(e=c.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)})||{title:"",content:""}:St[o]||{title:"",content:""};li(n,e,s,t,o,a)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:a.badgeBg,color:a.badgeText,border:"1px solid ".concat(a.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(d,n({component:"span",onClick:function(n){var e,t,i;n.stopPropagation();var r=Mn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;console.log("LOG: Printing evaluationResult",r,c),Wi(n,String(o),s,r)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:s?"default":"pointer",borderRight:"1px solid ".concat(a.badgeBorder),"&:hover":s?{}:{bgColor:"".concat(a.badgeBorder,"22")}}},{children:[null!=v&&i(d,n({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(a.badgeBorder)}},{children:v})),i(d,n({component:"span",sx:{fontSize:"11px",px:.25}},{children:!Mn.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?"N/A"===p||"NA"===p?"N/A":0==p||null==p?"Same":"".concat(p):i(L,{color:a.badgeText})}))]})),i(d,n({component:"span",onClick:function(n){n.stopPropagation();var t=qn?St.find(function(n){var e;return(null===(e=c.refIndexes)||void 0===e?void 0:e.includes(n))||{title:"",content:""}}):St[o]||{title:"",content:""};li(n,e,s,t,o,a)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(a.badgeBorder,"22")}}},{children:i(g,{size:11,color:a.badgeText})}))]}))]}))}),"left-row-".concat(o))}),i("div",{ref:Ye,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(d,n({ref:fi,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(d,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(d,n({onClick:function(e){e.stopPropagation(),Je.open&&tt===Yt?ct():(lt(Yt),ri(oi(e.currentTarget,{title:"",content:"",evaluationResult:Kt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Yt,!0,n(n({},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!=Vt?Vt:i(L,{}),i(d,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(p,{size:11,style:{transform:Je.open&&tt===Yt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(d,n({sx:n({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},qn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Jn&&i(x,{sections:11}),i(d,n({ref:xi,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(v,n({title:ht,placement:"top"},{children:i(f,n({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ht}))}))})),t(d,n({ref:Oe,onScroll:Pi,sx:n({p:"12px",display:"flex",flexDirection:"column"},qn?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:ze,style:{width:"100%",height:"0px",flexShrink:0}}),wt&&St.map(function(e,o){var r,l=e,u=[],c=!1,a=null,s=-1;if(qn){u=bt.filter(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(l.selfIndex))&&n.selfIndex>=0}).map(function(n){return n.selfIndex+1}),s=bt.findIndex(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(l.selfIndex))&&n.selfIndex>=0});var v=bt.findIndex(function(n,e){var t;return he.has(e)&&(null===(t=n.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==v)&&(a=Bi(v))}else u=[o+1],(c=he.has(o))&&(a=Bi(o));var f=Bi(qn&&-1!==s?s:o);return i(d,n({ref:Nt.current[o],sx:{mb:1,width:"100%"}},{children:t(d,n({sx:{position:"relative",width:"100%"}},{children:[i(d,n({ref:At.current[o],sx:n({width:"100%",display:"flex"},c&&a&&{borderRadius:"6px",outline:"2px solid ".concat(a.badgeBorder),outlineOffset:"1px"})},{children:i(V,{section:e,idx:o,columnKey:"right",colRef:Ht("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==wn?void 0:wn.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:qn?!!Zt["right-".concat(o)]:!!Zt[String(o)],treeData:wn,proposedSections:bt,existingSections:St,deviationNumberRegistry:It,getBadgeRef:Ot,getSectionCompareStyle:Bi,connectedSections:he,openMoreFunctionsPopup:li,openSummaryPopup:Wi,deviationNodeIdToView:null==jn?void 0:jn.id,deviationTargetParentId:Gi,onToggle:function(){Yi(),ii(o,"right")},navigation:e.id?Xi[e.id]:null,showOpenNodeRef:$i,resolvedMarkdownStyles:je,maintainRelativeOrder:qn,showDeviationBadges:Kn,renderSubSections:Qi,isProposingFix:On,proposingFixNodeId:zn,collisionKey:"".concat(te?"1":"0","-").concat(String(null!=ve?ve:""))})})),qn&&f&&i(d,n({ref:Mt.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:f.badgeBg,color:f.badgeText,border:"1px solid ".concat(f.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),i("div",{ref:We,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{J as default};
|
|
1
|
+
import{__assign as n,__spreadArray as e}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as r,useMemo as l,useEffect as u,useCallback as c}from"react";import{Box as a,Snackbar as d,Alert as s,Tooltip as v,Typography as p}from"@mui/material";import{ChevronDown as f,EllipsisVertical as g}from"lucide-react";import{ButtonCognitiveIcon as h}from"../../assests/svg/ButtonCognitiveIcon.js";import m from"./OverlayComponent.js";import{safeStringify as x,extractDeviationScore as y,generateColorPalette as b,DEVIATION_BADGE_SEPARATOR as S,findKeyPathByNodeId as R,getFirstDeviationOutputValue as C,getFirstDeviationColor as I,hasValue as B,getBentArrowPath as w,smoothScrollTo as T,resetClauseHighlight as _,scrollAndHighlightClause as E}from"./CognitiveComparehelpers.js";import{SHARED_MARKDOWN_STYLES as F,DEFAULT_FIELD_CONFIG as D,DEFAULT_COMPARISON_CONFIG as A}from"./CognitiveCompareConfig.js";export{SHARED_MARKDOWN_STYLES}from"./CognitiveCompareConfig.js";import{EMPTY_SUMMARY_POPUP_STATE as M,DEFAULT_DEVIAION_COLOR as N,DEFAULT_COMPONENT_HEADER_TEXT as k}from"./CognitiveCompareConstants.js";import P from"./CognitivePopup.js";import j from"./MoreFunctionsPopup.js";import H from"./LoaderComponent.js";import L from"./components/ThreeDotsLoader.js";import{useCognitiveTreeData as O}from"./hooks/useCompareData.js";import{useComparePopups as z}from"./hooks/useComparePopups.js";import{useSectionRefs as W}from"./hooks/useSectionRefs.js";import{useAccordionState as q}from"./hooks/useAccordionState.js";import{useDeviationNavigation as Y}from"./hooks/useDeviationNavigation.js";import K from"./components/CompareHeader.js";import V from"./components/SectionAccordion.js";import X from"./components/SubSectionAccordion.js";import $ from"./components/CognitiveSummaryPopup.js";import J from"./components/connectedLines.js";var U=function(U){var G,Q,Z,nn,en,tn,on,rn,ln,un,cn,an,dn,sn,vn,pn,fn,gn,hn,mn,xn,yn,bn,Sn,Rn,Cn,In=U.componentHeaderText,Bn=void 0===In?k:In,wn=U.treeData,Tn=U.comparisonConfig,_n=U.leftColumnTitleText,En=U.rightColumnTitleText,Fn=U.markdownStyles,Dn=U.resetTrigger,An=U.displayConfig,Mn=void 0===An?{isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1}:An,Nn=U.popupConfig,kn=U.deviationData,Pn=void 0===kn?{}:kn,jn=U.deviationNodeIdToView,Hn=U.resetDeviationNodeId,Ln=U.isProposingFix,On=void 0!==Ln&&Ln,zn=U.proposingFixNodeId,Wn=o(Mn.maintainRelativeOrder),qn=Wn[0],Yn=Wn[1],Kn=!!qn||!!(null==Mn?void 0:Mn.showDeviationBadges),Vn=o(!1),Xn=Vn[0],$n=Vn[1],Jn=o(!1),Un=Jn[0],Gn=Jn[1],Qn=o(null),Zn=Qn[0],ne=Qn[1],ee=o(!1),te=ee[0],ie=ee[1],oe=o(null===(Q=null!==(G=null==wn?void 0:wn.newEvaluationResult)&&void 0!==G?G:null==Mn?void 0:Mn.enableDeviationSchemaBackwardCompatibility)||void 0===Q||Q)[0],re=o(!1),le=re[0],ue=re[1],ce=o(!1),ae=ce[0],de=ce[1],se=o(null),ve=se[0],pe=se[1],fe=r(!1),ge=o(new Set),he=ge[0],me=ge[1],xe=o([]),ye=xe[0],be=xe[1],Se=r(null),Re=r(null),Ce=r(null),Ie=r(new Set),Be=r(!1),we=r(null),Te=r({}),_e=r([]),Ee=r(!1),Fe=r(!1),De=r(null),Ae=r(function(){}),Me=l(function(){return(null==wn?void 0:wn.cognitive_decisioning)||{}},[wn]),Ne=o({width:0,height:0}),ke=Ne[0],Pe=Ne[1],je=l(function(){return n(n({},F),Fn)},[Fn]),He=r(null),Le=r(null),Oe=r(null),ze=r(null),We=r(null),qe=r(null),Ye=r(null),Ke=r(null),Ve=r(!1),Xe=r(null),$e=r(null),Je=z(He),Ue=Je.cognitivePopup,Ge=Je.setCognitivePopup,Qe=Je.moreFunctions,Ze=Je.setMoreFunctions,nt=Je.position,et=Je.setPosition,tt=Je.activeBadgeId,it=Je.summaryPopup,ot=Je.setSummaryPopup,rt=Je.closeSummaryPopup,lt=Je.setActiveBadgeId,ut=Je.popupRef,ct=Je.closeCognitivePopup,at=Je.closeMoreFunctionsPopup,dt=l(function(){var n,e,t,i,o,r,l;return{fields:null!==(n=null==Tn?void 0:Tn.fields)&&void 0!==n?n:D,thresholds:{high:null!==(t=null===(e=null==Tn?void 0:Tn.thresholds)||void 0===e?void 0:e.high)&&void 0!==t?t:A.thresholds.high,medium:null!==(o=null===(i=null==Tn?void 0:Tn.thresholds)||void 0===i?void 0:i.medium)&&void 0!==o?o:A.thresholds.medium,exact:null!==(l=null===(r=null==Tn?void 0:Tn.thresholds)||void 0===r?void 0:r.exact)&&void 0!==l?l:A.thresholds.exact}}},[Tn]),st=o(null),vt=st[0];st[1];var pt=null===(en=null===(Z=null==wn?void 0:wn.documents)||void 0===Z?void 0:Z[null===(nn=null==wn?void 0:wn.input_index_map)||void 0===nn?void 0:nn[0]])||void 0===en?void 0:en.title,ft=null===(rn=null===(tn=null==wn?void 0:wn.documents)||void 0===tn?void 0:tn[null===(on=null==wn?void 0:wn.input_index_map)||void 0===on?void 0:on[1]])||void 0===rn?void 0:rn.title,gt=x(_n||pt||"Uploaded Contract"),ht=x(En||ft||"Reference Template"),mt=O(wn,qn,Pn,dt,oe),xt=mt.activeProposed,yt=mt.existingRule,bt=mt.proposedSections,St=mt.existingSections,Rt=mt.visibleFields,Ct=mt.parentDeviationRecord,It=mt.deviationNumberRegistry,Bt=mt.parseError;u(function(){Bt&&ne("Failed to load comparison: ".concat(Bt))},[Bt]);var wt=bt.length>0||St.length>0,Tt=W(Rt.map(function(n){return n.key}),Math.max(bt.length,St.length)),_t=Tt.leftRefs,Et=Tt.rightRefs,Ft=Tt.sectionLeftRefs,Dt=Tt.sectionRightRefs,At=Tt.lhsBadgeRefs,Mt=Tt.rhsBadgeRefs,Nt=Tt.sectionRightRowRefs,kt=Tt.subSectionLeftRefs,Pt=Tt.subSectionRightRefs,jt=Tt.sectionRowRefs,Ht=Tt.getSectionRowRef,Lt=Tt.getSubSectionRef,Ot=Tt.getBadgeRef,zt=yt.analysis,Wt=x(null===(un=null===(ln=null==zt?void 0:zt.rule_difference_comparison)||void 0===ln?void 0:ln.summary)||void 0===un?void 0:un.overall_summary),qt=!!Wt.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Yt=null!==(cn=null==wn?void 0:wn.base_root_id)&&void 0!==cn?cn:"-1";null==wn||wn[Yt];var Kt=oe?null!==(bn=null!==(mn=Pn&&(null===(hn=null==Pn?void 0:Pn[Yt])||void 0===hn?void 0:hn.evaluation_result))&&void 0!==mn?mn:null===(yn=null===(xn=null==wn?void 0:wn.nodes)||void 0===xn?void 0:xn[Yt])||void 0===yn?void 0:yn.evaluation_result)&&void 0!==bn?bn:null:null!==(gn=null!==(sn=Pn&&(null===(dn=null===(an=null==Pn?void 0:Pn[Yt])||void 0===an?void 0:an.evaluation_result)||void 0===dn?void 0:dn[0]))&&void 0!==sn?sn:null===(fn=null===(pn=null===(vn=null==wn?void 0:wn.nodes)||void 0===vn?void 0:vn[Yt])||void 0===pn?void 0:pn.evaluation_result)||void 0===fn?void 0:fn[0])&&void 0!==gn?gn:null,Vt=y(Kt),Xt=b(null!==(Cn=null===(Rn=null===(Sn=null==Kt?void 0:Kt.evaluation_outputs)||void 0===Sn?void 0:Sn.metadata)||void 0===Rn?void 0:Rn.label_color)&&void 0!==Cn?Cn:""),$t=function(){Ie.current.forEach(function(n){_(n)}),Ie.current.clear()},Jt=c(function(){var n,e,t,i,o,r;$t(),ie(!1),Fe.current=!1,Re.current=null;var l=De.current,u=fi.current;if(null!==l)if("string"==typeof l&&l.includes(S)){var c=l.split(S);(a=(null===(n=kt.current[c[2]])||void 0===n?void 0:n.current)||(null===(e=Ft.current[Number(c[2])])||void 0===e?void 0:e.current))&&(a.style.paddingTop="0px")}else{var a;(a=null===(t=Ft.current[l])||void 0===t?void 0:t.current)&&(a.style.paddingTop="0px")}if(null!==u)if("string"==typeof u&&u.includes(S)){c=u.split(S);(d=(null===(i=Pt.current[c[3]])||void 0===i?void 0:i.current)||(null===(o=Dt.current[Number(c[3])])||void 0===o?void 0:o.current))&&(d.style.paddingTop="0px")}else{var d;(d=null===(r=Dt.current[u])||void 0===r?void 0:r.current)&&(d.style.paddingTop="0px")}pe(null),De.current=null,fi.current=null,ue(!1),Gn(!1),ze.current&&(ze.current.style.height="0px"),We.current&&(We.current.style.height="0px"),qe.current&&(qe.current.style.height="0px"),Ye.current&&(Ye.current.style.height="0px")},[]),Ut=c(function(){$t(),Jt(),me(new Set),be([]),_e.current=[],bi([]),Ci(null),ot(M),ct(),requestAnimationFrame(function(){var n;null===(n=Ae.current)||void 0===n||n.call(Ae)})},[]),Gt=r(Ut);u(function(){Gt.current=Ut},[Ut]),u(function(){Dn&&Gt.current()},[Dn]);var Qt=q({maintainRelativeOrder:!!qn,proposedSections:bt,existingSections:St,activeSideBySideSection:ve,connectedSections:he,resetSideBySide:Jt,setConnectedSections:me,setConnectedLines:be,cachedConnectedPositions:_e,svgContainerRef:Se,isAnimatingRef:Be,animationTimerRef:we,calculateLinesRef:Ae,sectionLeftRefs:Ft,sectionRightRefs:Dt,subSectionLeftRefs:kt,subSectionRightRefs:Pt}),Zt=Qt.expandedSections,ni=Qt.setExpandedSections,ei=Qt.expandedSubSections,ti=Qt.setExpandedSubSections,ii=Qt.toggleSection,oi=c(function(e,t,i,o,r,l,u){var c,a,d,s=x(null==t?void 0:t.id)||x(null==i?void 0:i.id)||"",v=(s?Me[s]:null)||(null==t?void 0:t.cognitiveData)||(null==i?void 0:i.cognitiveData)||{section_id:s,decisioning:[],gap:[],relevance_score:0},p=null!==(a=null===(c=jt.current[o])||void 0===c?void 0:c.current)&&void 0!==a?a:null;return{isLoading:null!==(d=null==Mn?void 0:Mn.isLoading)&&void 0!==d&&d,open:!0,sectionTitle:(null==t?void 0:t.displayTitle)?null==t?void 0:t.title:"no title",refSectionTitle:(null==i?void 0:i.displayTitle)?null==i?void 0:i.title:"no title",cognitiveData:v,anchorEl:e,sectionAnchorEl:p,badgeStyle:l||null,sectionIdx:o,docData:{documents:null==wn?void 0:wn.documents,input_index_map:null==wn?void 0:wn.input_index_map},deviationData:function(){var e,r,l=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||null,u=function(e){var t=function(n){if(!n||"object"!=typeof n)return null;var e=null==n?void 0:n.deviation_entries;if(e&&"object"==typeof e){var t=Object.keys(e).sort(function(n,e){return Number(n)-Number(e)})[0];if(t&&e[t])return e[t]}var i=Object.keys(n).filter(function(n){return/^\d+$/.test(n)}).sort(function(n,e){return Number(n)-Number(e)});if(i.length&&n[i[0]])return n[i[0]];var o=null==n?void 0:n.deviations;if(o&&"object"==typeof o){var r=Object.keys(o).sort(function(n,e){return Number(n)-Number(e)})[0];if(r&&o[r])return o[r]}return null}(e);return t?n(n({},e),{deviation_summary:(null==e?void 0:e.deviation_summary)||(null==t?void 0:t.deviation_summary),deviation_title:(null==e?void 0:e.deviation_title)||(null==t?void 0:t.deviation_title),deviation_impact:(null==e?void 0:e.deviation_impact)||(null==t?void 0:t.deviation_impact),deviation_explanation:(null==e?void 0:e.deviation_explanation)||(null==t?void 0:t.deviation_explanation),evaluation_outputs:(null==e?void 0:e.evaluation_outputs)||(null==t?void 0:t.evaluation_outputs),cognitive_decisioning:(null==e?void 0:e.cognitive_decisioning)||(null==t?void 0:t.cognitive_decisioning)}):e};if(!("string"==typeof o&&o.includes(S)))return u(l);var c=o.split(S)[1];if(!c)return l;var a=(null==t?void 0:t.evaluationResult)||(null==i?void 0:i.evaluationResult)||{},d=(null===(e=null==a?void 0:a.deviation_entries)||void 0===e?void 0:e[c])||(null===(r=null==a?void 0:a.deviations)||void 0===r?void 0:r[c])||null;return d?n(n(n({},a),d),{deviation_summary:(null==d?void 0:d.deviation_summary)||(null==a?void 0:a.deviation_summary),deviation_title:(null==d?void 0:d.deviation_title)||(null==a?void 0:a.deviation_title),deviation_impact:(null==d?void 0:d.deviation_impact)||(null==a?void 0:a.deviation_impact),deviation_explanation:(null==d?void 0:d.deviation_explanation)||(null==a?void 0:a.deviation_explanation),evaluation_outputs:(null==d?void 0:d.evaluation_outputs)||(null==a?void 0:a.evaluation_outputs),cognitive_decisioning:(null==d?void 0:d.cognitive_decisioning)||(null==a?void 0:a.cognitive_decisioning)}):u(l)}(),isOrphan:!!r}},[Me,wn]),ri=c(function(n){at(),et(null),Ge(n)},[at]),li=function(n,e,t,i,o,r){var l;if(n.stopPropagation(),Qe.open&&Qe.sectionIdx===o)at();else{var u=n.currentTarget,c="left";(null===(l=Oe.current)||void 0===l?void 0:l.contains(u))&&(c="right");$t(),Fe.current&&Jt(),me(new Set),be([]),_e.current=[],ct(),it.open?Yi():rt(),requestAnimationFrame(function(){var n=function(){var n,e,t,i;if("string"==typeof o&&o.includes(S)){var r=o.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===c?null===(n=Mt.current[l])||void 0===n?void 0:n.current:null===(e=At.current[l])||void 0===e?void 0:e.current}return"right"===c?null===(t=Mt.current[o])||void 0===t?void 0:t.current:null===(i=At.current[o])||void 0===i?void 0:i.current}()||u;Ze(oi(n,e,i,o,t,r))})}},ui=c(function(){null!==Qe.sectionIdx&&Qe.anchorEl?ri(n(n({},Qe),{open:!0})):at()},[Qe,at,ri]),ci=c(function(){var n=Qe.sectionIdx,e=Qe.isOrphan;at(),rt(),null!==n&&(e?ne("No counterpart exists to connect to."):($t(),Fe.current&&Jt(),be([]),_e.current=[],me(function(e){return e.has(n)?new Set:new Set([n])}),setTimeout(function(){Ae.current&&Ae.current()},50)))},[Qe.sectionIdx,Qe.isOrphan,at,rt,Jt]),ai=c(function(){var n=Ce.current;if(n){Ce.current=null;var e=bt.findIndex(function(e){return e.id===n}),t=St.findIndex(function(e){return e.id===n}),i=-1===e?R(bt,n):null,o=-1===t?R(St,n):null,r=-1!==e?e:i?Number(i.split("-")[0]):-1,l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=function(n,e,t,i){var o,r,l,u;return-1!==n?null!==(r=null===(o=t.current[n])||void 0===o?void 0:o.current)&&void 0!==r?r:null:e&&null!==(u=null===(l=i.current[e])||void 0===l?void 0:l.current)&&void 0!==u?u:null},c=function(n,e,t){void 0===t&&(t=30);var i=0,o=function(){var r=n();r&&0!==r.getBoundingClientRect().height?(Ie.current.add(r),E(r,e)):i++<t&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(qn)-1!==r&&Ke.current&&c(function(){return u(e,i,Ft,kt)},Ke.current),-1!==l&&Oe.current&&c(function(){return u(t,o,Dt,Pt)},Oe.current);else{var a=He.current;if(!a)return;c(function(){return-1!==r?u(e,i,Ft,kt):u(t,o,Dt,Pt)},a)}}},[bt,St,qn,Ft,Dt,kt,Pt,Ke,Oe,He]),di=c(function(e){if(e){$t(),Jt(),me(new Set),be([]),_e.current=[],rt(),ct();var t=bt.findIndex(function(n){return n.id===e}),i=St.findIndex(function(n){return n.id===e}),o=-1===t?R(bt,e):null,r=-1===i?R(St,e):null;if(-1!==t||o||-1!==i||r){var l=-1!==t?t:o?Number(o.split("-")[0]):-1,u=-1!==i?i:r?Number(r.split("-")[0]):-1;Ce.current=e,ni(function(e){var t,i=n({},e),o=!1;-1!==l&&(i[t=qn?"left-".concat(l):String(l)]||(i[t]=!0,o=!0));-1!==u&&(i[t=qn?"right-".concat(u):String(u)]||(i[t]=!0,o=!0));return o?i:e}),ti(function(e){var t=n({},e),i=!1,l=function(n){for(var e=n.split("-"),o=e[0],r=1;r<e.length;r++)o+="-".concat(e[r]),t[o]||(t[o]=!0,i=!0)};return o&&l(o),r&&l(r),i?t:e}),setTimeout(function(){requestAnimationFrame(function(){Ce.current===e&&si.current()})},50)}else console.warn('scrollToAndHighlightClause: nodeId "'.concat(e,'" not found'))}},[bt,St,qn,ni,ti,Jt,rt,ct]),si=r(ai);u(function(){si.current=ai},[ai]);var vi=r(null),pi=r(null),fi=r(null),gi=r(null),hi=r(null),mi=r(null),xi=o([]),yi=xi[0],bi=xi[1];r(null);var Si=o(null),Ri=Si[0],Ci=Si[1];u(function(){if(vt){var n=dt.fields.find(function(n){return n.analysisKey===vt||n.key===vt});if(n){var e=_t.current[n.key]||Et.current[n.key];(null==e?void 0:e.current)&&setTimeout(function(){return e.current.scrollIntoView({behavior:"smooth",block:"center"})},150)}}},[vt,dt.fields]);var Ii=c(function(n){var e,t,i,o,r,l,u,c,a,d=null===(e=null==zt?void 0:zt.rule_difference_comparison)||void 0===e?void 0:e.fields;if(!d||!d[n])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};var s=d[n],v=(null==s?void 0:s.relation)||(null===(i=null===(t=null==s?void 0:s.highlights)||void 0===t?void 0:t.ruleA_spans)||void 0===i?void 0:i.length)||(null===(r=null===(o=null==s?void 0:s.highlights)||void 0===o?void 0:o.ruleB_spans)||void 0===r?void 0:r.length)||(null==s?void 0:s.mappings)&&s.mappings.length>0;if(s.mappings){var p=s.mappings[0]||{};return{score:s.score,relation:p.relation||"",highlightsA:(null===(l=p.highlights)||void 0===l?void 0:l.ruleA_spans)||[],highlightsB:(null===(u=p.highlights)||void 0===u?void 0:u.ruleB_spans)||[],hasContent:!!v}}return{score:s.score,relation:s.relation||"",highlightsA:(null===(c=s.highlights)||void 0===c?void 0:c.ruleA_spans)||[],highlightsB:(null===(a=s.highlights)||void 0===a?void 0:a.ruleB_spans)||[],hasContent:!!v}},[zt]),Bi=c(function(e,t){var i,o,r;void 0===t&&(t="left");var l=null,u=null;if("left"===t)if(l=bt[e],qn&&l){var c=St.filter(function(n){var e;return null===(e=l.refIndexes)||void 0===e?void 0:e.includes(n.selfIndex)});u=c.find(function(n){return n.evaluationResult})||c[0]}else u=St[e];else if(u=St[e],qn&&u){var a=bt.filter(function(n){var e;return null===(e=n.refIndexes)||void 0===e?void 0:e.includes(u.selfIndex)});l=a.find(function(n){return n.evaluationResult})||a[0]}else l=bt[e];var d=(null==l?void 0:l.relation)&&"not_defined"!==l.relation,s=(null==u?void 0:u.relation)&&"not_defined"!==u.relation,v=!(!(null==l?void 0:l.cognitiveData)&&!(null==u?void 0:u.cognitiveData));if(!d&&!s&&!v)return n(n({},b(N)),{label:"Not Defined"});var p=null!==(o=null!==(i=null==l?void 0:l.evaluationResult)&&void 0!==i?i:null==u?void 0:u.evaluationResult)&&void 0!==o?o:null,f=C(p),g=I(p);return n(n({},b(g)),null!=p?{label:null!==(r=f)&&void 0!==r?r:""}:{label:null})},[bt,St,Me,dt,qn]),wi=c(function(e){for(var t,i,o,r,l,u=e.split("-").map(Number),c=bt[u[0]],a=St[u[0]],d=1;d<u.length;d++)(null==c?void 0:c.subsections)&&(c=c.subsections[u[d]]),(null==a?void 0:a.subsections)&&(a=a.subsections[u[d]]);if(!c&&!a)return null;var s=(null==c?void 0:c.relation)&&"not_defined"!==c.relation,v=(null==a?void 0:a.relation)&&"not_defined"!==a.relation,p=x(null==c?void 0:c.id)||x(null==a?void 0:a.id)||"",f=!(!(null==c?void 0:c.cognitiveData)&&!(null==a?void 0:a.cognitiveData));if(!s&&!v&&!f)return n(n({},b(N)),{label:"Not Defined"});null!==(i=null!==(t=null==c?void 0:c.cognitiveRelevanceScore)&&void 0!==t?t:null==a?void 0:a.cognitiveRelevanceScore)&&void 0!==i||p&&(null===(o=Me[p])||void 0===o||o.relevance_score);var g=null!==(l=null!==(r=null==c?void 0:c.evaluationResult)&&void 0!==r?r:null==a?void 0:a.evaluationResult)&&void 0!==l?l:null,h=C(g),m=I(g);return n(n({},b(m)),null!=g?{label:null!=h?h:""}:{label:null})},[bt,St,Me,dt]),Ti=c(function(e,t){var i,o,r,l,u,c,a,d,s,v,p,f,g,h,m,x,y;if(!e||null==t)return null;var S=null!==(a=null!==(u=null!==(o=null===(i=null==Pn?void 0:Pn[e])||void 0===i?void 0:i.evaluation_result)&&void 0!==o?o:null===(l=null===(r=null==wn?void 0:wn.nodes)||void 0===r?void 0:r[e])||void 0===l?void 0:l.evaluation_result)&&void 0!==u?u:null===(c=null==wn?void 0:wn[e])||void 0===c?void 0:c.evaluation_result)&&void 0!==a?a:null;if(!S||"object"!=typeof S)return null;var R=null!==(p=null!==(s=null===(d=null==S?void 0:S.deviations)||void 0===d?void 0:d[t])&&void 0!==s?s:null===(v=null==S?void 0:S.deviation_entries)||void 0===v?void 0:v[t])&&void 0!==p?p:null==S?void 0:S[t],C=null!==(y=null!==(h=null===(g=null===(f=null==R?void 0:R.evaluation_outputs)||void 0===f?void 0:f.metadata)||void 0===g?void 0:g.label_color)&&void 0!==h?h:null===(x=null===(m=null==S?void 0:S.evaluation_outputs)||void 0===m?void 0:m.metadata)||void 0===x?void 0:x.label_color)&&void 0!==y?y:N;return n(n({},b(C)),{label:null})},[Pn,wn]),_i=c(function(){$t(),ni({}),ti({}),Jt(),me(new Set),be([]),_e.current=[],rt(),ct(),at(),requestAnimationFrame(function(){Ae.current&&Ae.current()})},[ni,ti,Jt,rt,ct,at]),Ei=l(function(){return Object.values(Zt).some(Boolean)||Object.values(ei).some(Boolean)},[Zt,ei]),Fi=c(function(){var n,e,t,i,o,r,l,u,c,a,d,s,v,p,f,g,h,m,x,y,b,R,C;if(!Ve.current&&!Be.current){Ve.current=!0;try{if(!vi.current)return;var I=function(n){var e=n.split("-"),t=e[0];if(!Zt[t]&&!1===qn)return!1;if(qn&&!Zt["left-".concat(t)]&&!Zt["right-".concat(t)]&&!Zt[t])return!1;for(var i=t,o=1;o<e.length-1;o++)if(i+="-".concat(e[o]),!ei[i])return!1;return!0},T=vi.current.getBoundingClientRect();Pe({width:T.width,height:T.height});var _=[];if(Rt.forEach(function(n){var e,t,i=n.key,o=null===(e=_t.current[i])||void 0===e?void 0:e.current,r=null===(t=Et.current[i])||void 0===t?void 0:t.current;o&&r&&(o.style.height="auto",r.style.height="auto",o.style.minHeight="0px",r.style.minHeight="0px")}),!Be.current){for(var E=0;E<Math.max(bt.length,St.length);E++){var F=null===(n=Ft.current[E])||void 0===n?void 0:n.current,D=null===(e=Dt.current[E])||void 0===e?void 0:e.current;F&&(F.style.height="auto",F.style.minHeight="0px"),D&&(D.style.height="auto",D.style.minHeight="0px")}qn||Object.keys(kt.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=kt.current[n])||void 0===e?void 0:e.current,o=null===(t=Pt.current[n])||void 0===t?void 0:t.current;i&&o&&(i.style.height="auto",o.style.height="auto",i.style.minHeight="0px",o.style.minHeight="0px")}})}var A={};Rt.forEach(function(n){var e,t,i=n.key,o=null===(e=_t.current[i])||void 0===e?void 0:e.current,r=null===(t=Et.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect();A[i]=Math.max(l.height,u.height)}});var M={left:{},right:{}},N={};if(!Be.current)if(qn){if(te&&null!==ve)if("number"==typeof ve){var k=ve,P=bt[k],j=null===(o=Ft.current[k])||void 0===o?void 0:o.current;j&&P&&(P.refIndexes||[]).forEach(function(n){var e,t=St.findIndex(function(e){return e.selfIndex===n}),i=null===(e=Dt.current[t])||void 0===e?void 0:e.current;if(i&&(Zt["left-".concat(k)]||Zt["right-".concat(t)])){var o=Math.max(j.getBoundingClientRect().height,i.getBoundingClientRect().height);M.left[k]=Math.max(M.left[k]||0,o),M.right[t]=Math.max(M.right[t]||0,o)}})}else{var H=ve.split(S)[2];if(H){F=null===(r=kt.current[H])||void 0===r?void 0:r.current,D=null===(l=Pt.current[H])||void 0===l?void 0:l.current;if(F&&D){L=Math.max(F.getBoundingClientRect().height,D.getBoundingClientRect().height);N[H]=Math.max(N[H]||0,L)}}}}else{Object.keys(kt.current).forEach(function(n){var e,t;if(I(n)){var i=null===(e=kt.current[n])||void 0===e?void 0:e.current,o=null===(t=Pt.current[n])||void 0===t?void 0:t.current;if(i&&o&&null!==i.offsetParent&&null!==o.offsetParent){var r=i.getBoundingClientRect(),l=o.getBoundingClientRect(),u=Math.max(r.height,l.height);N[n]=u,i.style.minHeight="".concat(u,"px"),o.style.minHeight="".concat(u,"px")}}});for(E=0;E<Math.min(bt.length,St.length);E++){var F=null===(t=Ft.current[E])||void 0===t?void 0:t.current,D=null===(i=Dt.current[E])||void 0===i?void 0:i.current;if(F&&D){var L=Math.max(F.getBoundingClientRect().height,D.getBoundingClientRect().height);M.left[E]=L,M.right[E]=L}}}if(Rt.forEach(function(n){var e,t,i=n.key,o=null===(e=_t.current[i])||void 0===e?void 0:e.current,r=null===(t=Et.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=A[i];o.style.minHeight="".concat(l,"px"),r.style.minHeight="".concat(l,"px")}}),Be.current||(Object.entries(M.left).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=Ft.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),Object.entries(M.right).forEach(function(n){var e,t=n[0],i=n[1],o=null===(e=Dt.current[Number(t)])||void 0===e?void 0:e.current;o&&(o.style.minHeight="".concat(i,"px"))}),qn||Object.keys(N).forEach(function(n){var e,t,i=null===(e=kt.current[n])||void 0===e?void 0:e.current,o=null===(t=Pt.current[n])||void 0===t?void 0:t.current;if(i&&o&&N[n]){var r=N[n];i.style.minHeight="".concat(r,"px"),o.style.minHeight="".concat(r,"px")}})),qn)bt.forEach(function(n,e){var t;(null===(t=Ft.current[e])||void 0===t?void 0:t.current)&&(n.refIndexes||[]).forEach(function(n){var t,i,o,r,l,u,c,a,d,s,v=St.findIndex(function(e){return e.selfIndex===n});if(-1!==v){var p=null===(t=At.current[e])||void 0===t?void 0:t.current,f=null===(i=Mt.current[v])||void 0===i?void 0:i.current;if(p&&f){var g=p.getBoundingClientRect(),h=f.getBoundingClientRect(),m=g.right-T.left,x=h.left-T.left,y=g.top+g.height/2-T.top,b=h.top+h.height/2-T.top;if(te&&ve===e){var S=null!==(r=null===(o=Ke.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==r?r:0,R=null!==(u=null===(l=Oe.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==u?u:0,C=S+(null!==(a=null===(c=Ke.current)||void 0===c?void 0:c.clientHeight)&&void 0!==a?a:1/0),I=R+(null!==(s=null===(d=Oe.current)||void 0===d?void 0:d.clientHeight)&&void 0!==s?s:1/0),B=g.top+g.height/2,w=h.top+h.height/2,E=function(n,e,t){return Math.max(e,Math.min(t,n))};y=E(B,S,C)-T.top,b=E(w,R,I)-T.top}var F=Bi(e);F&&_.push({id:"line-".concat(e,"-").concat(v),x1:m,y1:y,x2:x,y2:b,style:F,sectionIdx:e,targetRightIdx:v})}}})});else{for(E=0;E<Math.min(bt.length,St.length);E++){var O=null===(u=Ft.current[E])||void 0===u?void 0:u.current,z=null===(c=Dt.current[E])||void 0===c?void 0:c.current;if(O&&z){var W=O.getBoundingClientRect(),q=z.getBoundingClientRect(),Y=Math.max(W.top,q.top)+18-T.top,K=(null===(a=St[E])||void 0===a?void 0:a.id)||"sec-".concat(E);(Z=Bi(E))&&_.push({id:K,x1:W.right-T.left,y1:Y,x2:q.left-T.left,y2:Y,style:Z,sectionIdx:E,hasCognitive:!!((null===(d=bt[E])||void 0===d?void 0:d.cognitiveData)||(null===(s=St[E])||void 0===s?void 0:s.cognitiveData)||K&&Me[K]),isSubSection:!1})}}Object.keys(kt.current).forEach(function(n){var e,t,i,o,r,l;if(I(n)){var u=null===(e=kt.current[n])||void 0===e?void 0:e.current,c=null===(t=Pt.current[n])||void 0===t?void 0:t.current;if(u&&c){for(var a=n.split("-").map(Number),d=bt[a[0]],s=St[a[0]],v=1;v<a.length;v++)(null==d?void 0:d.subsections)&&(d=d.subsections[a[v]]),(null==s?void 0:s.subsections)&&(s=s.subsections[a[v]]);var p=!!d&&((null===(i=d.displayTitle)||void 0===i||i)&&B(d.title)),f=!!d&&((null===(o=d.displayContent)||void 0===o||o)&&B(d.content)),g=!!s&&((null===(r=s.displayTitle)||void 0===r||r)&&B(s.title)),h=!!s&&((null===(l=s.displayContent)||void 0===l||l)&&B(s.content));if(p&&f||g&&h){var m=u.getBoundingClientRect(),x=c.getBoundingClientRect(),y=Math.max(m.top,x.top)+16-T.top,b=wi(n);b&&"Not Defined"!==b.label&&_.push({id:"subsec-".concat(n),x1:m.right-T.left,y1:y,x2:x.left-T.left,y2:y,style:b,sectionIdx:a[0],isSubSection:!0,subSectionKeyPath:n,hasCognitive:!(!(null==d?void 0:d.cognitiveData)&&!(null==s?void 0:s.cognitiveData))})}}}})}if(te&&"string"==typeof ve&&ve.includes(S)){var V=ve.split(S),X=V[0],$=V[1],J=V[2],U=(V[3],"".concat(X).concat(S).concat($)),G=null===(v=At.current[U])||void 0===v?void 0:v.current,Q=null===(p=Mt.current[U])||void 0===p?void 0:p.current;if(G&&Q){var Z,nn=G.getBoundingClientRect(),en=Q.getBoundingClientRect(),tn=nn.right-T.left,on=en.left-T.left,rn=nn.top+nn.height/2-T.top,ln=en.top+en.height/2-T.top;if(qn){var un=null!==(g=null===(f=Ke.current)||void 0===f?void 0:f.getBoundingClientRect().top)&&void 0!==g?g:0,cn=null!==(m=null===(h=Oe.current)||void 0===h?void 0:h.getBoundingClientRect().top)&&void 0!==m?m:0,an=un+(null!==(y=null===(x=Ke.current)||void 0===x?void 0:x.clientHeight)&&void 0!==y?y:1/0),dn=cn+(null!==(R=null===(b=Oe.current)||void 0===b?void 0:b.clientHeight)&&void 0!==R?R:1/0),sn=function(n,e,t){return Math.max(e,Math.min(t,n))};rn=sn(nn.top+nn.height/2,un,an)-T.top,ln=sn(en.top+en.height/2,cn,dn)-T.top}(Z=null!==(C=Ti(X,$))&&void 0!==C?C:wi(J))&&_.push({id:"line-subsec-".concat(U),x1:tn,y1:rn,x2:on,y2:ln,style:Z,sectionIdx:Number(J.split("-")[0]),isSubSection:!0,subSectionKeyPath:ve})}}if(bi(_),hi.current&&mi.current){var vn=hi.current.getBoundingClientRect(),pn=mi.current.getBoundingClientRect(),fn=(vn.top+vn.height/2-T.top+pn.top+pn.height/2-T.top)/2;Ci({x1:vn.right-T.left,x2:pn.left-T.left,y:fn})}else Ci(null);if(he.size>0){var gn=[],hn=Ke.current,mn=Oe.current;if(hn&&mn){var xn=[],yn=hn.getBoundingClientRect().top,bn=mn.getBoundingClientRect().top,Sn=yn+hn.clientHeight,Rn=bn+mn.clientHeight,Cn=hn.scrollTop,In=mn.scrollTop,Bn=T.top,wn=function(n,e,t){return Math.max(e,Math.min(t,n))};he.forEach(function(n){var e,t,i,o,r,l;if("string"==typeof n&&n.includes(S)){var u=n.split(S),c=u[0],a=u[1],d=u[2],s=(u[3],"".concat(c).concat(S).concat(a)),v=null===(e=At.current[s])||void 0===e?void 0:e.current,p=null===(t=Mt.current[s])||void 0===t?void 0:t.current;if(!v||!p)return;var f=v.getBoundingClientRect(),g=p.getBoundingClientRect(),h=null!==(i=Ti(c,a))&&void 0!==i?i:wi(d),m=(P=f.right-T.left)+.5*((j=g.left-T.left-0)-P),x=f.top+f.height/2,y=g.top+g.height/2,b=x-yn+Cn,R=y-bn+In,C="conn-subsec-".concat(s);xn.push({lhsScrollY:b,rhsScrollY:R,x1:P,x2:j,containerTop:Bn,leftIdx:n,rhsArrayIdx:n,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var I=wn(x,yn,Sn),B=wn(y,bn,Rn),_=I-Bn,E=B-Bn,F=y>=bn-4&&y<=Rn+4,D="";D=(H=x>=yn-4&&x<=Sn+4)&&F?w(P,_,j,E):H&&!F?"M ".concat(P,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(E):!H&&F?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(E," L ").concat(j,",").concat(E):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(E),gn.push({id:C,pathD:D,style:h,leftIdx:n,rhsArrayIdx:n})}else if(qn){var A=n,M=bt[A];if(!(null===(l=null==M?void 0:M.refIndexes)||void 0===l?void 0:l.length))return;M.refIndexes.forEach(function(n){var e,t,i=St.findIndex(function(e){return e.selfIndex===n});if(-1!==i){var o=null===(e=At.current[A])||void 0===e?void 0:e.current,r=null===(t=Mt.current[i])||void 0===t?void 0:t.current;if(o&&r){var l=o.getBoundingClientRect(),u=r.getBoundingClientRect(),c=Bi(A),a=l.right-T.left,d=u.left-T.left-0,s=a+.5*(d-a),v=l.top+l.height/2,p=u.top+u.height/2,f=v-yn+Cn,g=p-bn+In,h="conn-".concat(A,"-").concat(i);xn.push({lhsScrollY:f,rhsScrollY:g,x1:a,x2:d,containerTop:Bn,leftIdx:A,rhsArrayIdx:i,styleColor:(null==c?void 0:c.badgeBorder)||"#6366F1",styleId:h});var m=wn(v,yn,Sn),x=wn(p,bn,Rn),y=m-Bn,b=x-Bn,S=v>=yn-4&&v<=Sn+4,R=p>=bn-4&&p<=Rn+4,C="";C=S&&R?w(a,y,d,b):S&&!R?"M ".concat(a,",").concat(y," L ").concat(s,",").concat(y," L ").concat(s,",").concat(b):!S&&R?"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b," L ").concat(d,",").concat(b):"M ".concat(s,",").concat(y," L ").concat(s,",").concat(b),gn.push({id:h,pathD:C,style:c,leftIdx:A,rhsArrayIdx:i})}}})}else{var N=n,k=N;v=null===(o=At.current[N])||void 0===o?void 0:o.current,p=null===(r=Mt.current[k])||void 0===r?void 0:r.current;if(!v||!p)return;var P,j;f=v.getBoundingClientRect(),g=p.getBoundingClientRect(),h=Bi(N),m=(P=f.right-T.left)+.5*((j=g.left-T.left-0)-P),x=f.top+f.height/2,y=g.top+g.height/2,b=x-yn+Cn,R=y-bn+In,C="conn-".concat(N,"-").concat(k);xn.push({lhsScrollY:b,rhsScrollY:R,x1:P,x2:j,containerTop:Bn,leftIdx:N,rhsArrayIdx:k,styleColor:(null==h?void 0:h.badgeBorder)||"#6366F1",styleId:C});var H;I=wn(x,yn,Sn),B=wn(y,bn,Rn),_=I-Bn,E=B-Bn,F=y>=bn-4&&y<=Rn+4,D="";D=(H=x>=yn-4&&x<=Sn+4)&&F?w(P,_,j,E):H&&!F?"M ".concat(P,",").concat(_," L ").concat(m,",").concat(_," L ").concat(m,",").concat(E):!H&&F?"M ".concat(m,",").concat(_," L ").concat(m,",").concat(E," L ").concat(j,",").concat(E):"M ".concat(m,",").concat(_," L ").concat(m,",").concat(E),gn.push({id:C,pathD:D,style:h,leftIdx:N,rhsArrayIdx:k})}}),_e.current=xn}be(gn)}else be([]),_e.current=[]}catch(n){console.error("Line render safe fail: ",n)}finally{Ve.current=!1}}},[Rt,bt,St,Me,dt,Ii,Bi,Ti,qn,te,ve,he,Zt,ei]),Di=c(function(){var n,e,t,i,o,r,l,u,c,a,d,s,v,p,f=_e.current;if(f.length&&!Be.current){var g=null!==(e=null===(n=Ke.current)||void 0===n?void 0:n.scrollTop)&&void 0!==e?e:0,h=null!==(i=null===(t=Oe.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0,m=null!==(r=null===(o=Ke.current)||void 0===o?void 0:o.clientHeight)&&void 0!==r?r:1/0,x=null!==(u=null===(l=Oe.current)||void 0===l?void 0:l.clientHeight)&&void 0!==u?u:1/0,y=null!==(a=null===(c=Ke.current)||void 0===c?void 0:c.getBoundingClientRect().top)&&void 0!==a?a:0,b=null!==(s=null===(d=Oe.current)||void 0===d?void 0:d.getBoundingClientRect().top)&&void 0!==s?s:0,S=y+m,R=b+x,C=null!==(p=null===(v=vi.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==p?p:0,I=function(n,e,t){return Math.max(e,Math.min(t,n))};f.forEach(function(n){var e=n.lhsScrollY-g+y,t=n.rhsScrollY-h+b,i=Te.current[n.styleId+"-stroke"],o=Te.current[n.styleId+"-bg"];if(i||o){var r,l=I(e,y,S),u=I(t,b,R),c=l-C,a=u-C,d=e>=y-4&&e<=S+4,s=t>=b-4&&t<=R+4,v=n.x1+.5*(n.x2-n.x1);r=d&&s?w(n.x1,c,n.x2,a):d&&!s?"M ".concat(n.x1,",").concat(c," L ").concat(v,",").concat(c," L ").concat(v,",").concat(a):!d&&s?"M ".concat(v,",").concat(c," L ").concat(v,",").concat(a," L ").concat(n.x2,",").concat(a):"M ".concat(v,",").concat(c," L ").concat(v,",").concat(a),i&&(i.setAttribute("visibility","visible"),i.setAttribute("d",r)),o&&(o.setAttribute("visibility","visible"),o.setAttribute("d",r))}})}},[]);u(function(){Ae.current=Fi},[Fi]);var Ai=r(null),Mi=r(null),Ni=c(function(){_e.current.length>0&&!Be.current||(null!==Ai.current&&clearTimeout(Ai.current),Ai.current=setTimeout(function(){Ae.current(),Ai.current=null},50))},[]),ki=c(function(){de(!0),ue(!1),Re.current=null,null!==Mi.current&&clearTimeout(Mi.current),null!==Ai.current&&(clearTimeout(Ai.current),Ai.current=null),Mi.current=setTimeout(function(){var n,e,t,i,o,r,l,u,c,a,d;try{if(_e.current=[],Fe.current&&null!==De.current&&null!==fi.current){var s=De.current,v=fi.current,p="string"==typeof s&&s.includes(S),f=null,g=null,h=null,m=null;if(p){var x=s.split(S),y="".concat(x[0]).concat(S).concat(x[1]);f=(null===(n=At.current[y])||void 0===n?void 0:n.current)||null,g=(null===(e=Mt.current[y])||void 0===e?void 0:e.current)||null,h=(null===(t=kt.current[x[2]])||void 0===t?void 0:t.current)||(null===(i=Ft.current[Number(x[2])])||void 0===i?void 0:i.current)||null,m=(null===(o=Pt.current[x[3]])||void 0===o?void 0:o.current)||(null===(r=Dt.current[Number(x[3])])||void 0===r?void 0:r.current)||null}else f=(null===(l=jt.current[s])||void 0===l?void 0:l.current)||null,h=(null===(u=Ft.current[s])||void 0===u?void 0:u.current)||null,g=(null===(c=Nt.current[v])||void 0===c?void 0:c.current)||null,m=(null===(a=Dt.current[v])||void 0===a?void 0:a.current)||null;if(f&&g&&h&&m){if(h.style.paddingTop="0px",m.style.paddingTop="0px",!qn){var b=f.getBoundingClientRect(),R=g.getBoundingClientRect(),C=b.top-R.top;C>0?m.style.paddingTop="".concat(C,"px"):C<0&&(h.style.paddingTop="".concat(Math.abs(C),"px"))}var I=Ke.current,B=Oe.current;if(I&&B){var w=f.getBoundingClientRect().top-I.getBoundingClientRect().top+I.scrollTop,T=g.getBoundingClientRect().top-B.getBoundingClientRect().top+B.scrollTop-(w-I.scrollTop);Math.abs(B.scrollTop-T)>1&&(B.scrollTop=T)}}}null===(d=Ae.current)||void 0===d||d.call(Ae),Fe.current&&ue(!0)}catch(n){console.error("Safely caught error during resize calculation:",n)}finally{de(!1),Mi.current=null}},150)},[qn,bt,St]),Pi=c(function(n){if(null!==Xe.current&&$e.current&&Math.abs(n.currentTarget.scrollTop-Xe.current)<=2){var e=$e.current;Xe.current=null,$e.current=null,e()}fe.current||(qn||Ni(),Ee.current||(Ee.current=!0,requestAnimationFrame(function(){var n,e,t,i,o,r,l;if(Fe.current){var u=Ke.current,c=Oe.current;if(u&&c&&gi.current){if(!Re.current){var a=De.current,d=void 0;if("string"==typeof a&&a.includes(S)){var s=a.split(S),v="".concat(s[0]).concat(S).concat(s[1]);d=null===(n=At.current[v])||void 0===n?void 0:n.current}else d=null===(e=At.current[a])||void 0===e?void 0:e.current;if(d){var p=d.getBoundingClientRect();Re.current={badgeScreenY:p.top+p.height/2,initialScrollTop:u.scrollTop,leftTop:u.getBoundingClientRect().top,leftBottom:u.getBoundingClientRect().top+u.clientHeight,cTop:null!==(i=null===(t=vi.current)||void 0===t?void 0:t.getBoundingClientRect().top)&&void 0!==i?i:0}}}if(Re.current){var f=Re.current,g=u.scrollTop-f.initialScrollTop,h=f.badgeScreenY-g,m=((o=h,r=f.leftTop,l=f.leftBottom,Math.max(r,Math.min(l,o)))-f.cTop).toString(),x=h>=f.leftTop-4&&h<=f.leftBottom+4;gi.current.setAttribute("y1",m),gi.current.setAttribute("y2",m),gi.current.setAttribute("visibility",x?"visible":"hidden")}}}_e.current.length>0&&Di(),Ee.current=!1})))},[Di,qn,Ni]),ji=r(0),Hi=r(0),Li=r(0),Oi=r(function(){});r(null),u(function(){Oi.current=ki},[ki]),u(function(){var n=setTimeout(Ni,250),e=function(){return Oi.current()};return window.addEventListener("resize",e),function(){clearTimeout(n),null!==Ai.current&&clearTimeout(Ai.current),null!==Mi.current&&clearTimeout(Mi.current),window.removeEventListener("resize",e)}},[xt,yt,zt,Rt,Zt,ei,bt,St,dt,Ni,te,ve,le,he]),u(function(){var n=function(n,e,t,i,o){e.current=n.getBoundingClientRect().width;var r=new ResizeObserver(function(n){null!==t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){var r,l,u;t.current=null;var c=n[n.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-e.current)<1?o():(e.current=a,i())}})});return r.observe(n),r},e={current:null},t={current:null},i={current:null},o=[],r=[e,t,i];return Le.current&&o.push(n(Le.current,ji,e,function(){return Oi.current()},function(){})),He.current&&o.push(n(He.current,Hi,t,function(){return Oi.current()},function(){return Ae.current()})),vi.current&&o.push(n(vi.current,Li,i,function(){return Oi.current()},function(){return Ae.current()})),function(){o.forEach(function(n){return n.disconnect()}),r.forEach(function(n){null!==n.current&&(cancelAnimationFrame(n.current),n.current=null)})}},[]),u(function(){Fe.current=te},[te]),u(function(){De.current=ve},[ve]);var zi=c(function(n,e,t){var i,o,r=null===(i=null==t?void 0:t.toggleIfSame)||void 0===i||i,l=null==t?void 0:t.onReady,u=null!==(o=null==t?void 0:t.sourceSide)&&void 0!==o?o:"left";at(),null!=n&&(e?ne("No counterpart exists for this section."):($t(),te&&ve===n?r?Jt():null==l||l():(me(new Set([n])),be([]),_e.current=[],Gn(!0),fe.current=!0,pe(n),De.current=n,ie(!0),Fe.current=!0,ue(!1),ze.current&&(ze.current.style.height="0px"),We.current&&(We.current.style.height="0px"),qe.current&&(qe.current.style.height="0px"),Ye.current&&(Ye.current.style.height="0px"),requestAnimationFrame(function(){var e,t,i,o,r,c="string"==typeof n&&n.includes(S),a=null,d=null,s=null;if(c){var v=n.split(S),p="".concat(v[0]).concat(S).concat(v[1]);a=(null===(e=At.current[p])||void 0===e?void 0:e.current)||null,d=(null===(t=Mt.current[p])||void 0===t?void 0:t.current)||null,s=d?n:null}else if(a=(null===(i=jt.current[n])||void 0===i?void 0:i.current)||null,qn){var f=bt[n],g=(null==f?void 0:f.refIndexes)||[];if(g.length>0){var h=g[0],m=St.findIndex(function(n){return n.selfIndex===h});-1!==m&&(d=(null===(r=Nt.current[m])||void 0===r?void 0:r.current)||null,s=m)}}else d=(null===(o=Nt.current[n])||void 0===o?void 0:o.current)||null,s=d?n:null;fi.current=s;var x=Ke.current,y=Oe.current,b=function(){!function(){var e,t,i,o,r,l,u,a,d,v,p,f,g=null,h=null,m=null,x=null;if(c){var y=n.split(S),b="".concat(y[0]).concat(S).concat(y[1]);g=(null===(e=kt.current[y[2]])||void 0===e?void 0:e.current)||(null===(t=Ft.current[Number(y[2])])||void 0===t?void 0:t.current)||null,h=(null===(i=Pt.current[y[3]])||void 0===i?void 0:i.current)||(null===(o=Dt.current[Number(y[3])])||void 0===o?void 0:o.current)||null,m=(null===(r=At.current[b])||void 0===r?void 0:r.current)||g,x=(null===(l=Mt.current[b])||void 0===l?void 0:l.current)||h}else{var R=Number(n),C=null!==s?Number(s):R;g=(null===(u=Ft.current[R])||void 0===u?void 0:u.current)||null,h=(null===(a=Dt.current[C])||void 0===a?void 0:a.current)||null,m=(null===(d=At.current[R])||void 0===d?void 0:d.current)||(null===(v=jt.current[R])||void 0===v?void 0:v.current)||g,x=(null===(p=Mt.current[C])||void 0===p?void 0:p.current)||(null===(f=Nt.current[C])||void 0===f?void 0:f.current)||h}if(m&&x&&g&&h){g.style.paddingTop="0px",h.style.paddingTop="0px";var I=m.getBoundingClientRect(),B=x.getBoundingClientRect(),w=I.top-B.top;w>0?h.style.paddingTop="".concat(w,"px"):w<0&&(g.style.paddingTop="".concat(Math.abs(w),"px"))}}(),ue(!0),Ae.current&&Ae.current(),fe.current=!1,"right"===u&&y?y.dispatchEvent(new Event("scroll")):x&&x.dispatchEvent(new Event("scroll")),Gn(!1),null==l||l()};if(!a||!x)return fe.current=!1,Gn(!1),void(null==l||l());if(d&&y){if(!qn){var R=0;R="right"===u?d?d.getBoundingClientRect().top:0:a?a.getBoundingClientRect().top:0;var C=He.current,I=(null==C?void 0:C.getBoundingClientRect().top)||0,B=C?C.scrollTop+R-I-150:0;return C?void T(C,B,200,b):void b()}var w=a.getBoundingClientRect().top-x.getBoundingClientRect().top+x.scrollTop,_=d.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop,E=200;if("left"===u){var F=_-(w-x.scrollTop);F<0&&ze.current&&(ze.current.style.height="".concat(Math.abs(F),"px")),requestAnimationFrame(function(){var n,e=y.scrollHeight-y.clientHeight;if(F<0)n=0;else{if(F>e){var t=F-e;return We.current&&(We.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(y,F,E,b)})}n=F}T(y,n,E,b)})}else{var D=w-(_-y.scrollTop);D<0&&qe.current&&(qe.current.style.height="".concat(Math.abs(D),"px")),requestAnimationFrame(function(){var n,e=x.scrollHeight-x.clientHeight;if(D<0)n=0;else{if(D>e){var t=D-e;return Ye.current&&(Ye.current.style.height="".concat(t+150,"px")),void requestAnimationFrame(function(){T(x,D,E,b)})}n=D}T(x,n,E,b)})}}else b()}))))},[ve,at,St,te,qn,bt,Jt]),Wi=c(function(n,e,t,i,o){var r,l="string"==typeof i?x(i).trim():x(null==i?void 0:i.deviation_summary).trim(),u=n.currentTarget;ct();var c="left";(null===(r=Oe.current)||void 0===r?void 0:r.contains(u))&&(c="right");var a=function(){var n,t,i,o;if("string"==typeof e&&e.includes(S)){var r=e.split(S),l="".concat(r[0]).concat(S).concat(r[1]);return"right"===c?null===(n=Mt.current[l])||void 0===n?void 0:n.current:null===(t=At.current[l])||void 0===t?void 0:t.current}return"right"===c?null===(i=Mt.current[e])||void 0===i?void 0:i.current:null===(o=At.current[e])||void 0===o?void 0:o.current};if(t)return Jt(),me(new Set),be([]),_e.current=[],void(l&&requestAnimationFrame(function(){var n=a()||u;ot({open:!0,anchorEl:n,summary:i,displayImpact:o})}));zi(e,t,l?{toggleIfSame:!1,sourceSide:c,onReady:function(){var n=a()||u;ot({open:!0,anchorEl:n,summary:i,displayImpact:o})}}:{toggleIfSame:!1,sourceSide:c})},[zi,ct,ot,Jt]),qi=c(function(){var n,e=Qe.sectionIdx,t=Qe.isOrphan;if(rt(),null!=e){var i="left";Qe.anchorEl&&(null===(n=Oe.current)||void 0===n?void 0:n.contains(Qe.anchorEl))&&(i="right"),zi(e,t,{sourceSide:i})}},[zi,Qe.isOrphan,Qe.sectionIdx,Qe.anchorEl,rt]),Yi=c(function(){rt(),Jt(),me(new Set),be([]),_e.current=[]},[rt,Jt]),Ki=null!==Qe.sectionIdx&&he.has(Qe.sectionIdx),Vi=Y({proposedSections:bt,existingSections:St,parentDeviationRecord:Ct,expandedSections:Zt,maintainRelativeOrder:!!qn,scrollContainerRef:He,leftContainerRef:Ke,lhsBadgeRefs:At,rhsBadgeRefs:Mt}),Xi=Vi.showDeviationNavigation,$i=Vi.showOpenNodeRef,Ji=l(function(){var n;if(!jn)return null;var e=null===(n=null==jn?void 0:jn.id)||void 0===n?void 0:n.split(":")[0];for(var t in Ct){if((Ct[t]||[]).some(function(n){return n.id===e}))return t}return null},[jn,Ct]),Ui=r({id:null,triggerMs:null}),Gi=r(null);u(function(){var t;if(null==jn?void 0:jn.id){var i=Number(jn.trigger),o=Ui.current;if((null==o?void 0:o.triggerMs)!==i){if(!(jn.id.includes(":")&&/:\d+$/.test(jn.id)))return Ui.current={id:jn.id,triggerMs:i},void di(jn.id);var r=null===(t=null==jn?void 0:jn.id)||void 0===t?void 0:t.split(":"),l=r[0],u=r[1],c=null!=u?u:"0";Gi.current!==jn.id&&(rt(),ct(),Jt(),me(new Set),be([]),_e.current=[],Gi.current=jn.id);var a=!1,d=0,s=null,v=150,p=function(n,e){for(var t=function(n,i){if(!n)return null;if(n.id===e)return i;if(!Array.isArray(n.subsections))return null;for(var o=0;o<n.subsections.length;o++){var r=t(n.subsections[o],"".concat(i,"-").concat(o));if(r)return r}return null},i=0;i<n.length;i++){var o=t(n[i],String(i));if(o)return o}return null},f=function(){var t,o,r,u;if(!a){var g=function(){Ui.current={id:jn.id,triggerMs:i}},h=null,m=null;for(var x in Ct){var y=Ct[x].find(function(n){return n.id===l});if(y){h=x,m=y;break}}if(m&&h){var b=bt.findIndex(function(n){return n.id===h}),R=St.findIndex(function(n){return n.id===h}),C=-1===b&&-1!==R,I=p(bt,m.id),B=p(St,m.id);if(I&&!B&&!C){var w=I.split("-"),T=Number(w[0]);if(qn){var _=null===(o=null===(t=bt[T])||void 0===t?void 0:t.refIndexes)||void 0===o?void 0:o[0],E=St.findIndex(function(n){return n.selfIndex===_});-1!==E&&(T=E)}B=e([T],w.slice(1),!0).join("-")}if(I||B){var F=C||!I&&!!B,D=I?Number(I.split("-")[0]):b,A=B?Number(B.split("-")[0]):R;if(F){if(!(qn?!!Zt["right-".concat(A)]:!!Zt[String(A)])&&A>=0)return ii(A,"right"),d+=1,void(s=setTimeout(f,450))}else if(!(qn?!!Zt["left-".concat(D)]:!!Zt[String(D)])&&D>=0)return ii(D,"left"),d+=1,void(s=setTimeout(f,450));var M,N=I||"",k=B||"",P="".concat(m.id).concat(S).concat(c).concat(S).concat(N).concat(S).concat(k),j="".concat(m.id).concat(S).concat(c),H=null===(r=At.current[j])||void 0===r?void 0:r.current,L=null===(u=Mt.current[j])||void 0===u?void 0:u.current,O=F||!H&&!!L,z=O?L:H;if(M=qn?O?Oe.current:Ke.current:He.current,z&&M){var W=z.getBoundingClientRect();if(0===W.height)return void((d+=1)<2?s=setTimeout(f,v):g());var q=M.getBoundingClientRect(),Y=W.top-q.top+M.scrollTop-q.height/2+W.height/2+150,K=function(){var e,t,i,o,r;if(!a){g();var l=z instanceof Element?window.getComputedStyle(z).color:"";H&&(H.style.transition="box-shadow 300ms ease-in-out",H.style.boxShadow="0 0 10px ".concat(l)),L&&(L.style.transition="box-shadow 300ms ease-in-out",L.style.boxShadow="0 0 10px ".concat(l)),setTimeout(function(){H&&(H.style.boxShadow=""),L&&(L.style.boxShadow="")},2e3);var u=(null===(t=null===(e=m.evaluationResult)||void 0===e?void 0:e.deviations)||void 0===t?void 0:t[c])||m,d=(null===(i=m.evaluationResult)||void 0===i?void 0:i.evaluation_outputs)||m.evaluation_outputs;if(!(!!H&&!!L)){var s=O?(null===(o=Mt.current[j])||void 0===o?void 0:o.current)||L:(null===(r=At.current[j])||void 0===r?void 0:r.current)||H;return ot({open:!0,anchorEl:s,displayImpact:jn.displayImpact,summary:n(n({},u),{evaluation_outputs:d})}),void(null==Hn||Hn())}zi(P,!1,{toggleIfSame:!1,sourceSide:"left",onReady:function(){var e,t=(null===(e=At.current[j])||void 0===e?void 0:e.current)||H;console.log("Summary data",d,u),ot({open:!0,anchorEl:t,displayImpact:null==jn?void 0:jn.displayImpact,summary:n({},u)})}})}};Math.abs(M.scrollTop-Y)<=2?K():(Xe.current=Y,$e.current=K,M.scrollTo({top:Y,behavior:"smooth"}),s&&clearTimeout(s),s=setTimeout(function(){if($e.current){Xe.current=null;var n=$e.current;$e.current=null,n()}},800))}else(d+=1)<2?s=setTimeout(f,v):g()}else(d+=1)<2?s=setTimeout(f,v):g()}else(d+=1)<2?s=setTimeout(f,v):g()}};return s=setTimeout(f,v),function(){a=!0,s&&clearTimeout(s)}}}},[jn,Ct,bt,St,qn,Zt,ii,zi,ot,di]);var Qi=function(n){var e=n.section,t=n.keyPath,o=n.depth,r=void 0===o?0:o,l=n.columnKey,u=void 0===l?"left":l,c=n.parentNodeId;return i(X,{section:e,keyPath:t,depth:r,columnKey:u,parentNodeId:void 0===c?"":c,expandedSubSections:ei,setExpandedSubSections:ti,maintainRelativeOrder:qn||!1,proposedSections:bt,existingSections:St,treeData:wn,deviationNumberRegistry:It,connectedSections:he,activeSideBySideSection:ve,resolvedMarkdownStyles:je,getSubSectionRef:Lt,getSubSectionCompareStyle:wi,getBadgeRef:Ot,openMoreFunctionsPopup:li,openSummaryPopup:Wi,showDeviationBadges:Kn,resetSideBySide:Jt,setConnectedSections:me,setConnectedLines:be,cachedConnectedPositions:_e,isProposingFix:On,proposingFixNodeId:zn})};return t(a,n({ref:Le,sx:n(n({display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif'},qn?{}:{overflow:"visible"}),{position:"relative"})},{children:[Xn&&i(a,n({sx:{position:"absolute",inset:0,bgcolor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(10px)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px"}},{children:i(H,{})})),it.open&&i($,{open:it.open,anchorEl:it.anchorEl,containerEl:pi.current,clipTopEl:hi.current,scrollContainerEl:He.current,onClose:Yi,summary:it.summary,displayImpact:it.displayImpact}),i(j,{open:Qe.open,anchorEl:Qe.anchorEl,sectionTitle:Qe.sectionTitle,referenceSectionTitle:Qe.refSectionTitle,onClose:at,onOpenCognitiveCompare:ui,onOpenSideBySide:qi,onConnect:ci,isConnected:Ki,isOrphan:Qe.isOrphan}),Ue.open&&i(P,{open:Ue.open,popupRef:ut,position:nt,popupConfig:Nn,onClose:function(){et(null),Ge(function(e){return n(n({},e),{open:!1})}),lt(null)},markdownStyles:Fn,sectionTitle:Ue.sectionTitle,referenceSectionTitle:Ue.refSectionTitle,cognitiveData:Ue.cognitiveData,anchorEl:Ue.anchorEl,sectionAnchorEl:Ue.sectionAnchorEl,scrollContainerEl:He.current,badgeStyle:Ue.badgeStyle,docData:Ue.docData,deviationData:Ue.deviationData,isLoading:Ue.isLoading}),i(d,n({open:!!Zn,autoHideDuration:8e3,onClose:function(){return ne(null)},anchorOrigin:{vertical:"top",horizontal:"center"}},{children:i(s,n({onClose:function(){return ne(null)},severity:"error",sx:{width:"100%",whiteSpace:"pre-line"}},{children:Zn}))})),i(K,{componentHeaderText:Bn,displayConfig:Mn,maintainRelativeOrder:qn,onCollapseAll:_i,showCollapseAll:Ei,onToggleView:function(n){$n(!0),setTimeout(function(){Yn(!n),Jt(),rt(),me(new Set),be([]),_e.current=[],requestAnimationFrame(function(){requestAnimationFrame(function(){setTimeout(function(){$n(!1)},600)})})},50)}}),i(a,n({ref:He,onScroll:Pi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:qn?"hidden":"auto",borderTop:Wt&&qt?"none":"1.5px solid #EEF0F4"}},{children:i(a,n({sx:n({display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px"},qn?{flex:1,minHeight:0}:{})},{children:t(a,n({ref:vi,sx:n({display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"40px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0},qn?{flex:1,overflow:"visible"}:{})},{children:[t("svg",n({ref:Se,style:{position:"absolute",top:0,left:0,width:ke.width||"100%",height:ke.height||"100%",pointerEvents:"none",zIndex:10,overflow:"visible",opacity:ae?0:1,transition:"opacity 0.15s ease-in-out"}},{children:[Ri&&i("g",{children:i("line",{x1:Ri.x1,y1:Ri.y,x2:Ri.x2,y2:Ri.y,stroke:Xt.badgeBorder,strokeWidth:"1.5"})}),yi.map(function(e){var o,r,l,u,c,d,s=e.x1+.5*(e.x2-e.x1),v=(e.y1+e.y2)/2;if("Not Defined"===e.style.label&&!e.hasCognitive)return null;if(e.isSubSection?te&&ve===e.subSectionKeyPath&&le:te&&ve===e.sectionIdx&&le)return null;if(!qn){var p=e.isSubSection?w(e.x1,e.y1,e.x2,e.y2):"M ".concat(e.x1," ").concat(e.y1," L ").concat(e.x2," ").concat(e.y2),g=bt[e.sectionIdx]||{title:"",content:""},m=St[e.sectionIdx]||{title:"",content:""};if(console.log("Base and Ref Sections for Badge:",g,m),e.isSubSection&&e.subSectionKeyPath){var x=e.subSectionKeyPath.includes(S)?e.subSectionKeyPath.split(S):[],y=x[2]||e.subSectionKeyPath,b=x[3]||y,R=y.split("-").map(Number),C=b.split("-").map(Number),I=null,B=null;R.length>0&&(I=bt[R[0]]),C.length>0&&(B=St[C[0]]);var T=(null==I?void 0:I.title)||"",_=(null==B?void 0:B.title)||"";console.log("Root Parent Titles:",T,_);for(var E=1;E<R.length;E++)(null==I?void 0:I.subsections)&&(I=I.subsections[R[E]]);for(E=1;E<C.length;E++)(null==B?void 0:B.subsections)&&(B=B.subsections[C[E]]);I&&(g=n(n({},I),{title:T||I.title})),console.log("Base Section for Subsection Badge:",g),B&&(m=n(n({},B),{title:_||B.title})),console.log("Ref Section for Subsection Badge:",m)}var F=!(null===(o=g.cognitiveData)||void 0===o?void 0:o.isMissingRationale)||Boolean(null===(l=null===(r=g.cognitiveData)||void 0===r?void 0:r.decisioning)||void 0===l?void 0:l.length),D=(null===(d=null===(c=null===(u=g.evaluationResult)||void 0===u?void 0:u.cognitive_decisioning)||void 0===c?void 0:c.decisioning_factors)||void 0===d?void 0:d.length)||!1,A=F||D;return t("g",{children:[i("path",{d:p,fill:"none",stroke:e.style.badgeBorder||"#E2E8F0",strokeWidth:"1.5"}),i("foreignObject",n({x:s-100,y:v-14,width:"200",height:"28",style:{pointerEvents:"auto",overflow:"visible"}},{children:i(a,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:t(a,n({onClick:function(n){n.stopPropagation(),A&&(Ue.open&&tt===e.id?ct():(lt(e.id),ri(oi(n.currentTarget,g,m,e.sectionIdx,e.style))))},sx:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:e.style.badgeBg,color:e.style.badgeText,border:"1px solid ".concat(e.style.badgeBorder),borderRadius:"12px",px:1.5,py:.5,fontWeight:600,textAlign:"center",whiteSpace:"nowrap",cursor:A?"pointer":"default"}},{children:[e.style.badgeText===N&&null==e.style.label?i(L,{color:e.style.badgeText}):0===e.style.label?"Same":e.style.label,i(a,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),A&&i(f,{size:11,style:{transform:Ue.open&&tt===e.id?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))}))]},e.id)}return null}),i(J,{connectedLines:ye,pathRefs:Te})]})),t(a,n({sx:n({border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)"},qn?{flex:1,overflow:"visible"}:{})},{children:[i(a,n({ref:hi,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E7E7E9",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",minHeight:"40px",overflow:"hidden",minWidth:0}},{children:i(v,n({title:gt,placement:"top"},{children:i(p,n({sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:gt}))}))})),t(a,n({ref:Ke,onScroll:Pi,sx:n({p:"12px",display:"flex",flexDirection:"column"},qn?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-160px",pr:"172px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:qe,style:{width:"100%",height:"0px",flexShrink:0}}),wt&&bt.map(function(e,o){var r,l,u=!e.title&&!e.content;if(qn&&u)return null;var c=e,d=Bi(o,"left"),s=qn?!(null===(r=c.refIndexes)||void 0===r?void 0:r.length)||c.selfIndex<0:!St[o],v=qn?"number"==typeof c.selfIndex&&c.selfIndex>=0?c.selfIndex+1:null:o+1,p=he.has(o),f=y(c.evaluationResult,null==d?void 0:d.deviationLabel);return i(a,n({ref:Ht(o),sx:{mb:1,width:"100%"}},{children:t(a,n({sx:{position:"relative",width:"100%"}},{children:[i(a,n({ref:Ft.current[o],sx:n({width:"100%",display:"flex",flexDirection:"column",minWidth:0},p&&{borderRadius:"6px",outline:"2px solid ".concat((null==d?void 0:d.badgeBorder)||"#6366F1"),outlineOffset:"1px"})},{children:i(V,{section:e,idx:o,columnKey:"left",colRef:Ht("left-accordion-".concat(o)),mb:0,treeData:wn,proposedSections:bt,existingSections:St,deviationNumberRegistry:It,getSectionCompareStyle:Bi,getBadgeRef:Ot,connectedSections:he,openMoreFunctionsPopup:li,openSummaryPopup:Wi,deviationNodeIdToView:null==jn?void 0:jn.id,deviationTargetParentId:Ji,parentNodeId:(null===(l=null==wn?void 0:wn.input_index_map)||void 0===l?void 0:l[0])||"",isExpanded:qn?!!Zt["left-".concat(o)]:!!Zt[String(o)],onToggle:function(){Yi(),ii(o,"left")},navigation:e.id?Xi[e.id]:null,showOpenNodeRef:$i,resolvedMarkdownStyles:je,maintainRelativeOrder:qn,showDeviationBadges:Kn,renderSubSections:Qi,isProposingFix:On,proposingFixNodeId:zn,collisionKey:"".concat(te?"1":"0","-").concat(String(null!=ve?ve:""))})})),qn&&d&&t(a,n({ref:At.current[o],onClick:function(n){var e,t,i,r=Mn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Wi(n,String(o),s,r)},sx:{position:"absolute",top:"18px",right:0,transform:"translateY(-50%) translateX(calc(100% + 8px))",display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",bgcolor:d.badgeBg,color:d.badgeText,border:"1px solid ".concat(d.badgeBorder),borderRadius:"12px",px:1.2,py:.4,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",zIndex:20,boxShadow:"0 1px 3px rgba(0,0,0,0.07)"}},{children:[t(a,n({component:"span",onClick:function(n){var e,t,i;n.stopPropagation();var r=Mn.enableDeviationSchemaBackwardCompatibility?null!==(e=c.evaluationResult)&&void 0!==e?e:null:null!==(i=null===(t=c.evaluationResult)||void 0===t?void 0:t[0])&&void 0!==i?i:null;Wi(n,String(o),s,r)},sx:{display:"inline-flex",alignItems:"center",gap:"4px",px:.2,cursor:s?"default":"pointer",borderRight:"1px solid ".concat(d.badgeBorder),"&:hover":s?{}:{bgColor:"".concat(d.badgeBorder,"22")}}},{children:[null!=v&&i(a,n({component:"span",sx:{fontSize:"11px",fontWeight:700,pr:.5,borderRight:"1px solid ".concat(d.badgeBorder)}},{children:v})),i(a,n({component:"span",sx:{fontSize:"11px",px:.25}},{children:!Mn.isLoading||null!=c.evaluationResult&&null!=c.evaluationResult?"N/A"===f||"NA"===f?"N/A":0==f||null==f?"Same":"".concat(f):i(L,{color:d.badgeText})}))]})),i(a,n({component:"span",onClick:function(n){n.stopPropagation();var t=qn?St.find(function(n){var e;return(null===(e=c.refIndexes)||void 0===e?void 0:e.includes(n))||{title:"",content:""}}):St[o]||{title:"",content:""};li(n,e,s,t,o,d)},sx:{display:"inline-flex",alignItems:"center",px:.2,cursor:"pointer","&:hover":{bgcolor:"".concat(d.badgeBorder,"22")}}},{children:i(g,{size:11,color:d.badgeText})}))]}))]}))}),"left-row-".concat(o))}),i("div",{ref:Ye,style:{width:"100%",height:"0px",flexShrink:0}})]}))]})),i(a,n({ref:pi,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"}},{children:i(a,n({sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0}},{children:t(a,n({onClick:function(e){e.stopPropagation(),Ue.open&&tt===Yt?ct():(lt(Yt),ri(oi(e.currentTarget,{title:"",content:"",evaluationResult:Kt,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Yt,!0,n(n({},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!=Vt?Vt:i(L,{}),i(a,n({component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}}},{children:i(h,{})})),i(f,{size:11,style:{transform:Ue.open&&tt===Yt?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]}))}))})),t(a,n({sx:n({border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0},qn?{flex:1,overflow:"visible",minHeight:0}:{})},{children:[Un&&i(m,{sections:11}),i(a,n({ref:mi,sx:{p:"8px",bgcolor:"#F7F8FA",borderBottom:"1px solid #E3E6EA",borderRadius:"8px 8px 0 0",minHeight:"40px",display:"flex",alignItems:"center",overflowX:"hidden"}},{children:i(v,n({title:ht,placement:"top"},{children:i(p,n({sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"}},{children:ht}))}))})),t(a,n({ref:Oe,onScroll:Pi,sx:n({p:"12px",display:"flex",flexDirection:"column"},qn?{maxHeight:"calc(100vh - 150px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-120px",pl:"140px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{})},{children:[i("div",{ref:ze,style:{width:"100%",height:"0px",flexShrink:0}}),wt&&St.map(function(e,o){var r,l=e,u=[],c=!1,d=null,s=-1;if(qn){u=bt.filter(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(l.selfIndex))&&n.selfIndex>=0}).map(function(n){return n.selfIndex+1}),s=bt.findIndex(function(n){var e;return(null===(e=n.refIndexes)||void 0===e?void 0:e.includes(l.selfIndex))&&n.selfIndex>=0});var v=bt.findIndex(function(n,e){var t;return he.has(e)&&(null===(t=n.refIndexes)||void 0===t?void 0:t.includes(l.selfIndex))});(c=-1!==v)&&(d=Bi(v))}else u=[o+1],(c=he.has(o))&&(d=Bi(o));var p=Bi(qn&&-1!==s?s:o);return i(a,n({ref:Nt.current[o],sx:{mb:1,width:"100%"}},{children:t(a,n({sx:{position:"relative",width:"100%"}},{children:[i(a,n({ref:Dt.current[o],sx:n({width:"100%",display:"flex"},c&&d&&{borderRadius:"6px",outline:"2px solid ".concat(d.badgeBorder),outlineOffset:"1px"})},{children:i(V,{section:e,idx:o,columnKey:"right",colRef:Ht("right-accordion-".concat(o)),mb:0,parentNodeId:(null===(r=null==wn?void 0:wn.input_index_map)||void 0===r?void 0:r[1])||"",isExpanded:qn?!!Zt["right-".concat(o)]:!!Zt[String(o)],treeData:wn,proposedSections:bt,existingSections:St,deviationNumberRegistry:It,getBadgeRef:Ot,getSectionCompareStyle:Bi,connectedSections:he,openMoreFunctionsPopup:li,openSummaryPopup:Wi,deviationNodeIdToView:null==jn?void 0:jn.id,deviationTargetParentId:Ji,onToggle:function(){Yi(),ii(o,"right")},navigation:e.id?Xi[e.id]:null,showOpenNodeRef:$i,resolvedMarkdownStyles:je,maintainRelativeOrder:qn,showDeviationBadges:Kn,renderSubSections:Qi,isProposingFix:On,proposingFixNodeId:zn,collisionKey:"".concat(te?"1":"0","-").concat(String(null!=ve?ve:""))})})),qn&&p&&i(a,n({ref:Mt.current[o],"data-section-id":l.id,sx:{position:"absolute",top:"18px",left:0,transform:"translateY(-50%) translateX(calc(-100% - 8px))",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"11px",bgcolor:p.badgeBg,color:p.badgeText,border:"1px solid ".concat(p.badgeBorder),borderRadius:"10px",px:1,py:.3,fontWeight:700,whiteSpace:"nowrap",zIndex:20}},{children:u.length>0?u.join(", "):"-"}))]}))}),"right-row-".concat(o))}),i("div",{ref:We,style:{width:"100%",height:"0px",flexShrink:0}})]}))]}))]}))}))}))]}))};export{U as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
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};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompareConstants.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Popper as i,Paper as o,Box as r,Typography as l,IconButton as a,Accordion as d,AccordionSummary as c,AccordionDetails as s}from"@mui/material";import{Info as p,X as u,ChevronDown as f}from"lucide-react";import{useRef as m,useState as h,useMemo as x,useEffect as g}from"react";function v(v){var b,w,
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Popper as i,Paper as o,Box as r,Typography as l,IconButton as a,Accordion as d,AccordionSummary as c,AccordionDetails as s}from"@mui/material";import{Info as p,X as u,ChevronDown as f}from"lucide-react";import{useRef as m,useState as h,useMemo as x,useEffect as g}from"react";function v(v){var b,y,w,S=v.open,C=v.anchorEl,I=v.containerEl,z=v.clipTopEl,B=v.scrollContainerEl,R=v.onClose,F=v.summary;v.markdownStyles,v.isLoading;var W=v.displayImpact,E=m(null),H=m(null),k=h(null),A=k[0],_=k[1],L=h(null),M=L[0],P=L[1],O=h(null);O[0];var T=O[1],N=h(0),j=N[0],J=N[1],q="string"==typeof F?{deviation_summary:F}:null!=F?F:{},D=q.deviation_title,G=q.deviation_summary,V=q.deviation_impact,Y=q.evaluation_outputs,Z=!!String(V||"").trim(),K=(null===(b=null==Y?void 0:Y.metadata)||void 0===b?void 0:b.label_color)||"#6366F1",Q=null!==(y=null==I?void 0:I.getBoundingClientRect().width)&&void 0!==y?y:180,U=Math.max(148,Q+120),X=x(function(){if(!C||!I)return null;var e=C.getBoundingClientRect();if(0===e.width&&0===e.height)return null;var t=I.getBoundingClientRect();return{top:e.top,bottom:e.bottom,left:t.left+t.width/2}},[C,I]);g(function(){if(!S||!C||!I)return _(null),P(null),void T(null);var e=function(){null!==E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame(function(){var e,t,n=C.getBoundingClientRect(),i=null==z?void 0:z.getBoundingClientRect(),o=null==B?void 0:B.getBoundingClientRect();if(0===n.width&&0===n.height)_(null);else{var r=I.getBoundingClientRect();_({top:n.top,bottom:n.bottom,left:r.left+r.width/2})}P(null!==(e=null==i?void 0:i.bottom)&&void 0!==e?e:null),T(null!==(t=null==o?void 0:o.bottom)&&void 0!==t?t:null),H.current&&J(H.current.offsetHeight)})};return e(),window.addEventListener("scroll",e,{passive:!0,capture:!0}),window.addEventListener("resize",e),function(){null!==E.current&&cancelAnimationFrame(E.current),window.removeEventListener("scroll",e,{capture:!0}),window.removeEventListener("resize",e)}},[S,C,I,z,B]);var $=null!==(w=null!=A?A:X)&&void 0!==w?w:"hidden",ee="hidden"===$?"hidden":$.bottom+20,te=null!=M&&"number"==typeof ee&&ee<M?Math.min(j,M-ee):0,ne=x(function(){return"hidden"===$?{getBoundingClientRect:function(){return{width:0,height:0,top:0,bottom:0,left:0,right:0,x:0,y:0,toJSON:function(){}}}}:{getBoundingClientRect:function(){return{width:0,height:$.bottom-$.top,top:$.top,bottom:$.bottom,left:$.left,right:$.left,x:$.left,y:$.top,toJSON:function(){}}}}},[$]);return F?t(i,e({open:S,disablePortal:!0,popperOptions:{strategy:"fixed"},anchorEl:ne,placement:"bottom",modifiers:[{name:"offset",options:{offset:[0,20]}},{name:"preventOverflow",enabled:!0,options:{boundary:B||"clippingParents",tether:!1}},{name:"flip",enabled:!0,options:{boundary:B||"clippingParents",fallbackPlacements:["top"]}}],sx:{zIndex:21,visibility:"hidden"===$?"hidden":"visible",opacity:"hidden"===$?0:1,transition:"opacity 0.15s ease-in-out"}},{children:n(o,e({ref:H,sx:e(e({p:1.5,borderRadius:"12px",width:U,maxWidth:U},te>0&&{clipPath:"inset(".concat(te,"px 0px 0px 0px round 12px)")}),{transition:"transform 80ms linear",willChange:"transform",backfaceVisibility:"hidden",transform:"translateZ(0)",boxShadow:"0px 10px 24px rgba(15, 23, 42, 0.18)",border:"1px solid ".concat(K,"26"),borderTop:"3px solid ".concat(K),overflow:"hidden",bgcolor:"#fff"})},{children:[n(r,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75}},{children:[n(r,e({sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0}},{children:[t(p,{size:14,color:K}),t(l,e({sx:{fontSize:"11px",fontWeight:700,color:K,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.4px",lineHeight:1.2}},{children:"Summary"}))]})),t(a,e({size:"small",onClick:R,sx:{p:.25,ml:.5,color:"#64748B"}},{children:t(u,{size:14})}))]})),n(r,e({sx:{display:"flex",flexDirection:"column",gap:1.5,maxHeight:"300px",overflowY:"auto",pr:.5}},{children:[n(r,{children:[D&&t(l,e({sx:{fontSize:"12px",color:"#334155",fontFamily:'"Inter", sans-serif',lineHeight:1.6,fontWeight:700,overflowWrap:"anywhere"}},{children:D})),t(l,e({sx:{fontSize:"11px",color:"#334155",lineHeight:1.6,fontFamily:'"Inter", sans-serif',fontWeight:400,overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:G||"No summary available."}))]}),Z&&n(d,e({expanded:W,disableGutters:!0,elevation:0,sx:{backgroundColor:"".concat(K,"0A"),border:"1px solid ".concat(K,"33"),borderRadius:"4px",fontFamily:'"Inter", sans-serif',overflow:"hidden",flexShrink:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:0}}},{children:[t(c,e({expandIcon:t(f,{size:16,color:K}),sx:{minHeight:"10px",px:1.5,"& .MuiAccordionSummary-content":{py:"5px",my:0},"&.Mui-expanded":{minHeight:"10px",borderBottom:"1px solid ".concat(K,"1A")}}},{children:t(l,e({sx:{fontSize:"11px",fontWeight:700,color:K,fontFamily:'"Inter", sans-serif',textTransform:"uppercase",letterSpacing:"0.5px"}},{children:"Impact"}))})),t(s,e({sx:{p:1.5,backgroundColor:"#fff"}},{children:t(l,e({sx:{fontSize:"11px",color:"#475569",lineHeight:1.6,fontWeight:400,fontFamily:'"Inter", sans-serif',overflowWrap:"anywhere",whiteSpace:"pre-wrap"}},{children:String(V).replace("Impact -","").trim()}))}))]}))]}))]}))})):null}export{v as default};
|
|
2
2
|
//# sourceMappingURL=CognitiveSummaryPopup.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i}from"tslib";import{jsxs as n,jsx as e}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as d,AccordionSummary as r,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{hasValue as p,generateColorPalette as m,isMissingStr as
|
|
1
|
+
import{__assign as i}from"tslib";import{jsxs as n,jsx as e}from"react/jsx-runtime";import o,{useEffect as t}from"react";import{Box as l,Accordion as d,AccordionSummary as r,Tooltip as a,Typography as u,AccordionDetails as c}from"@mui/material";import{ChevronUp as s,ChevronDown as v}from"lucide-react";import{MemoizedMarkdown as f}from"../hooks/memoizedMarkdown.js";import{hasValue as p,generateColorPalette as m,isMissingStr as h,safeStringify as x,DEVIATION_BADGE_SEPARATOR as g}from"../CognitiveComparehelpers.js";import{DEFAULT_DEVIAION_COLOR as I}from"../CognitiveCompareConstants.js";var b=function(b){var y,w,_,F,S,R,C,k,B,A,M,W,O,N,T=b.section,P=b.idx,j=b.columnKey,D=b.colRef,E=b.mb,K=void 0===E?1:E,z=b.parentNodeId,V=void 0===z?"":z,G=b.isExpanded,X=b.onToggle,Y=b.navigation,H=b.showOpenNodeRef,q=b.resolvedMarkdownStyles,J=b.maintainRelativeOrder,L=b.showDeviationBadges,Q=void 0!==L&&L,U=b.renderSubSections,Z=b.treeData,$=b.proposedSections,ii=void 0===$?[]:$,ni=b.existingSections,ei=void 0===ni?[]:ni,oi=b.deviationNumberRegistry,ti=void 0===oi?{}:oi,li=b.getBadgeRef,di=b.openSummaryPopup,ri=b.getSectionCompareStyle,ai=b.connectedSections,ui=b.openMoreFunctionsPopup;b.deviationNodeIdToView,b.deviationTargetParentId;var ci=b.isProposingFix,si=b.proposingFixNodeId,vi=b.collisionKey,fi=(null===(y=T.displayTitle)||void 0===y||y)&&p(T.title),pi=T.change_history,mi=!!ci&&!!si&&"left"===j&&T.id===si&&p(pi),hi=mi?pi||"":T.content,xi=mi?T.content:void 0,gi=(null===(w=T.displayContent)||void 0===w||w)&&p(hi),Ii=!fi&&!gi,bi={current:1},yi=T.title;fi||(yi=gi?"No Title Found":"No Matching Section Found");var wi=T.evaluationResult;if(!wi&&"right"===j)if(J){var _i=null===(_=T.refIndexes)||void 0===_?void 0:_[0],Fi=ii.find(function(i){return i.selfIndex===_i});wi=null==Fi?void 0:Fi.evaluationResult}else wi=null===(F=ii[P])||void 0===F?void 0:F.evaluationResult;var Si=null===(S=null==Z?void 0:Z.input_index_map)||void 0===S?void 0:S[0],Ri=null===(R=null==Z?void 0:Z.input_index_map)||void 0===R?void 0:R[1],Ci="left"===j?Ri:Si,ki=function(i,n){return i.find(function(i){return(null==i?void 0:i.id)&&n&&i.id===n})},Bi="left"===j?T:ii[P],Ai="right"===j?T:ei[P];if(J)if("left"===j){var Mi=null===(C=T.refIndexes)||void 0===C?void 0:C[0],Wi=ei.findIndex(function(i){return i.selfIndex===Mi});Ai=-1!==Wi?ei[Wi]:ki(ei,T.id)}else{var Oi=null===(k=T.refIndexes)||void 0===k?void 0:k[0],Ni=ii.findIndex(function(i){return i.selfIndex===Oi});Bi=-1!==Ni?ii[Ni]:ki(ii,T.id)}var Ti="left"===j?!Ai:!Bi,Pi=wi||(null==Bi?void 0:Bi.evaluationResult)||(null==Ai?void 0:Ai.evaluationResult),ji=null!==(M=null===(A=null===(B=null==Pi?void 0:Pi.evaluation_outputs)||void 0===B?void 0:B.metadata)||void 0===A?void 0:A.label_color)&&void 0!==M?M:I,Di=m(ji).highlightBg,Ei=(null==Pi?void 0:Pi.deviations)||{},Ki=P+1,zi=T.id;if("right"===j&&J){var Vi=null===(W=T.refIndexes)||void 0===W?void 0:W[0],Gi=-1!==(Ni=ii.findIndex(function(i){return i.selfIndex===Vi}))?ii[Ni]:ki(ii,T.id);if(Gi){var Xi=ii.findIndex(function(i){return i.id===Gi.id});-1!==Xi&&(Ki=Xi+1),zi=Gi.id}}var Yi,Hi=[],qi=Object.entries(Ei).map(function(n){var e,o,t,l,d,r,a=n[0],u=n[1],c="".concat(zi).concat(g).concat(a),s=ti[c];if(null==s)return null;var v=u[V],f=h(v);if(f)v="";else if(!v)return null;Hi.push(v);var p=P,x=P;if(J)if("left"===j){var I=null===(e=T.refIndexes)||void 0===e?void 0:e[0],b=ei.findIndex(function(i){return i.selfIndex===I});if(-1!==b)x=b;else{var y=ei.findIndex(function(i){return i.id===T.id});x=-1!==y?y:P}}else{var w=null===(o=T.refIndexes)||void 0===o?void 0:o[0],_=ii.findIndex(function(i){return i.selfIndex===w});if(-1!==_)p=_;else p=-1!==(B=ii.findIndex(function(i){return i.id===T.id}))?B:P}var F="".concat(zi).concat(g).concat(a).concat(g).concat(p).concat(g).concat(x),S=u[Ci],R=Ti||h(S),C="".concat(Ki,".").concat(s),k=P;if("right"===j&&J){var B,A=null===(t=T.refIndexes)||void 0===t?void 0:t[0],M=ii.findIndex(function(i){return i.selfIndex===A});if(-1!==M)k=M;else-1!==(B=ii.findIndex(function(i){return i.id===T.id}))&&(k=B)}var W=ri?ri(k):null,O=(null==u?void 0:u.evaluation_outputs)||(null==Pi?void 0:Pi.evaluation_outputs),N=null!==(l=null==O?void 0:O.output_value)&&void 0!==l?l:null,D=null!==(r=null===(d=null==O?void 0:O.metadata)||void 0===d?void 0:d.label_color)&&void 0!==r?r:ji,E=m(D),K=W?i(i({},W),{badgeBg:E.badgeBg,badgeBorder:E.badgeBorder,badgeText:E.badgeText}):i({},E),z=(null==u?void 0:u.deviation_summary)?{deviation_summary:u.deviation_summary,deviation_title:(null==u?void 0:u.deviation_title)||(null==Pi?void 0:Pi.deviation_title),deviation_impact:(null==u?void 0:u.deviation_impact)||(null==Pi?void 0:Pi.deviation_impact),deviation_explanation:(null==u?void 0:u.deviation_explanation)||(null==Pi?void 0:Pi.deviation_explanation),evaluation_outputs:O,cognitive_decisioning:(null==u?void 0:u.cognitive_decisioning)||(null==Pi?void 0:Pi.cognitive_decisioning)}:null,G=0,X=hi||"";if(v&&X){var Y=X.split(/\n{2,}/),H=Y.findIndex(function(i){return i.includes(v)});if(-1!==H){var q=Object.entries(Ei).filter(function(i){i[0];var n=i[1][V];return n&&Y[H].includes(n)}).sort(function(i,n){return Y[H].indexOf(i[1][V])-Y[H].indexOf(n[1][V])});G=Math.max(0,q.findIndex(function(i){return i[0]===a}))}}return{id:c,actionId:F,label:C,highlight:v,side:j,style:K,stackIndex:G,score:N,isConnected:null==ai?void 0:ai.has(F),isOrphan:R,isMissingClause:f,badgeRef:li(j,c),onClick:function(i){i.stopPropagation(),ui&&ui(i,Bi||{id:"orphan-left",title:"",content:""},R,Ai||{id:"orphan-right",title:"",content:""},F,K)},onSummaryClick:function(i){i.stopPropagation(),di(i,F,R,z)}}}).filter(Boolean),Ji=Q?qi:[],Li=T.id&&j===(null==Y?void 0:Y.columnKey)?Y:null,Qi=o.useRef(!1);return t(function(){G||(Qi.current=!1)},[G]),n(l,i({ref:D,sx:{mb:K,width:"100%",display:"flex",flexDirection:"column",position:"relative",minWidth:0}},{children:[G&&(null==Li?void 0:Li.showAbove)&&e("div",i({style:{position:"sticky",top:0,height:"0px",cursor:"pointer"},onClick:function(){var i,n;return null===(n=null===(i=null==Li?void 0:Li.showAboveRef)||void 0===i?void 0:i.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e("div",i({style:i({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===j?"+":"-"," 130px))"),position:"absolute",paddingTop:"20px"},"left"===j?{right:"0px"}:{left:"0px"})},{children:e(s,{color:(null===(O=null==Li?void 0:Li.showAboveRef)||void 0===O?void 0:O.current)?window.getComputedStyle(Li.showAboveRef.current).color:void 0})}))})),n(d,i({disableGutters:!0,expanded:!Ii&&G,onChange:function(){Ii||(X(),H.current=T.id)},sx:{boxShadow:"none",border:Ii?"1px dashed #E2E8F0":"1px solid #E2E8F0",bgcolor:Ii?"#FAFAFA":"#FFFFFF",borderRadius:"6px",flexGrow:1,width:"100%",display:"flex",flexDirection:"column",minWidth:0,"&:before":{display:"none"},"& .MuiAccordion-heading":{position:"sticky",top:-12,zIndex:10,background:"#fff"}}},{children:[e(r,i({expandIcon:Ii?null:e(v,{size:16}),sx:{minHeight:"36px",flexShrink:0,cursor:Ii?"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:fi&&e(a,i({title:yi,placement:"top"},{children:e(u,i({component:"div",sx:{fontSize:"12px",color:Ii?"#94A3B8":"#19213D",fontWeight:Ii?400:700,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0}},{children:(Yi=yi,Yi?x(Yi).replace(/\\n/g,"\n").split(/(\*\*.*?\*\*)/g).map(function(i,n){return i.startsWith("**")&&i.endsWith("**")?e("strong",{children:i.slice(2,-2)},n):e(o.Fragment,{children:i},n)}):null)}))}))})),!Ii&&n(c,i({sx:{pt:0,pb:1.25,bgcolor:"#FFFFFF",flex:1,display:"flex",flexDirection:"column",minWidth:0}},{children:[gi&&e(f,{content:hi,overlayContent:xi,sxStyles:q,highlights:Hi,maintainRelativeOrder:J,highlightBg:Di,deviationBadges:Ji,collisionKey:vi}),(T.subsections||[]).map(function(i,n){return U({section:i,keyPath:"".concat(P,"-").concat(n),depth:0,columnKey:j,parentNodeId:V,devCounter:bi})})]}))]})),G&&(null==Li?void 0:Li.showBelow)&&e("div",i({style:{position:"sticky",bottom:0,height:"0px",cursor:"pointer"},onClick:function(){var i,n;return null===(n=null===(i=null==Li?void 0:Li.showBelowRef)||void 0===i?void 0:i.current)||void 0===n?void 0:n.scrollIntoView({behavior:"smooth",block:"center"})}},{children:e("div",i({style:i({transform:"translateY(-50%) translateX(calc(100% ".concat("left"===j?"+":"-"," 130px))"),position:"absolute",paddingBottom:"20px"},"left"===j?{right:"0px"}:{left:"0px"})},{children:e(v,{color:(null===(N=null==Li?void 0:Li.showBelowRef)||void 0===N?void 0:N.current)?window.getComputedStyle(Li.showBelowRef.current).color:void 0})}))}))]}),"".concat(j,"-sec-").concat(P))};export{b as default};
|
|
2
2
|
//# sourceMappingURL=SectionAccordion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as i}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{SpecialZoomLevel as r}from"@react-pdf-viewer/core";import a from"./PdfContainer.js";import l from"./PdfToolbar.js";import{pdfStyles as s}from"./PdfStyle.js";import{PdfHighlightControls as c}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import{useRef as u,useMemo as d,useEffect as g}from"react";import f from"../ScannedDocCitation/ScannedDocCitation.js";var h=function(e){switch(e){case"ActualSize":return r.ActualSize;case"PageFit":return r.PageFit;case"PageWidth":return r.PageWidth;default:return null!=e?e:r.PageWidth}},m=function(m){var v,p=m.pdfUrl,x=m.highlightText,C=m.highlightPages,P=m.highlightCordinatePages,w=m.highlightColor,T=void 0===w?"yellow":w,S=m.activeHighlightColor,y=void 0===S?"#f7dc51":S,A=m.jumpToPageValue,b=void 0===A?0:A,H=m.pdfName,I=m.onClose,j=m.customStyles,F=m.customClasses,z=m.customIcons,N=m.useCoordinates,_=m.fallbackPages,R=m.activeCitationIndex,V=m.onActiveCitationChange,W=m.headerAction,q=m.isZoomEnabled,D=void 0===q||q,E=m.showHighlightsAction,B=void 0===E||E,O=m.defaultScale,U=void 0===O?r.ActualSize:O,k=m.useRange,Z=void 0!==k&&k,J=m.rangeOfPages,K=void 0===J?null:J,L=m.showFullScreenAction,G=void 0===L||L,M=u(null),Q=d(function(){if(N)return new Set(P.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(C).forEach(function(t){t>0&&e.add(t-1)}),e},[C]),X=(v=x)&&0!==v.length?v.filter(function(e){return!v.some(function(t){return t!==e&&t.includes(e)})}):v,Y=c(X,N?{}:C,M,Q,N,N?P:[],T,y),$=Y.highlightIndex,ee=Y.cursorIndex,te=Y.setCursorIndex,ie=Y.orderedKeys,oe=Y.totalHighlights,ne=Y.getValidPosition,re=Y.tryJump,ae=Y.jumpToPage,le=Y.zoomTo,se=Y.plugins,ce=Y.controls,ue=Y.hideNonTargetHighlights,de=Y.deduplicateHighlights,ge=ne(ee);g(function(){void 0!==R&&R!==ee&&te(R)},[R]);var fe=e(e({},ce),{goToNext:function(){ce.goToNext(),V&&V(ee+1)},goToPrevious:function(){ce.goToPrevious(),V&&V(ee-1)}});if(!p)return o(f,{pages:_,activeCitationIndex:R,onActiveCitationChange:V,headerAction:W});return n("div",e({ref:M,className:(null==F?void 0:F.pdfViewerWrapper)||"",style:e(e(e({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},s.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==j?void 0:j.pdfViewer)},{children:[o(l,{highlightIndex:$,totalHighlights:oe,controls:fe,currentPosition:ge,pdfName:H,onClose:I,pdfUrl:p,viewerRef:M,customStyles:j,customClasses:F,customIcons:z,headerAction:W,isZoomEnabled:D,showHighlightsAction:B,showFullScreenAction:G}),o(a,{defaultScale:h(U),pdfUrl:p,plugins:se,customStyles:j,onLoad:function(){
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as i}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{SpecialZoomLevel as r}from"@react-pdf-viewer/core";import a from"./PdfContainer.js";import l from"./PdfToolbar.js";import{pdfStyles as s}from"./PdfStyle.js";import{PdfHighlightControls as c}from"./usePdfHighlight.js";import"@react-pdf-viewer/zoom/lib/styles/index.css";import"@react-pdf-viewer/page-navigation/lib/styles/index.css";import"@react-pdf-viewer/core/lib/styles/index.css";import"@react-pdf-viewer/search/lib/styles/index.css";import{useRef as u,useMemo as d,useEffect as g}from"react";import f from"../ScannedDocCitation/ScannedDocCitation.js";var h=function(e){switch(e){case"ActualSize":return r.ActualSize;case"PageFit":return r.PageFit;case"PageWidth":return r.PageWidth;default:return null!=e?e:r.PageWidth}},m=function(m){var v,p=m.pdfUrl,x=m.highlightText,C=m.highlightPages,P=m.highlightCordinatePages,w=m.highlightColor,T=void 0===w?"yellow":w,S=m.activeHighlightColor,y=void 0===S?"#f7dc51":S,A=m.jumpToPageValue,b=void 0===A?0:A,H=m.pdfName,I=m.onClose,j=m.customStyles,F=m.customClasses,z=m.customIcons,N=m.useCoordinates,_=m.fallbackPages,R=m.activeCitationIndex,V=m.onActiveCitationChange,W=m.headerAction,q=m.isZoomEnabled,D=void 0===q||q,E=m.showHighlightsAction,B=void 0===E||E,O=m.defaultScale,U=void 0===O?r.ActualSize:O,k=m.useRange,Z=void 0!==k&&k,J=m.rangeOfPages,K=void 0===J?null:J,L=m.showFullScreenAction,G=void 0===L||L,M=u(null),Q=d(function(){if(N)return new Set(P.map(function(e){return e.pageIndex}));var e=new Set;return Object.values(C).forEach(function(t){t>0&&e.add(t-1)}),e},[C]),X=(v=x)&&0!==v.length?v.filter(function(e){return!v.some(function(t){return t!==e&&t.includes(e)})}):v,Y=c(X,N?{}:C,M,Q,N,N?P:[],T,y),$=Y.highlightIndex,ee=Y.cursorIndex,te=Y.setCursorIndex,ie=Y.orderedKeys,oe=Y.totalHighlights,ne=Y.getValidPosition,re=Y.tryJump,ae=Y.jumpToPage,le=Y.zoomTo,se=Y.plugins,ce=Y.controls,ue=Y.hideNonTargetHighlights,de=Y.deduplicateHighlights,ge=ne(ee);g(function(){void 0!==R&&R!==ee&&te(R)},[R]);var fe=e(e({},ce),{goToNext:function(){ce.goToNext(),V&&V(ee+1)},goToPrevious:function(){ce.goToPrevious(),V&&V(ee-1)}});if(!p)return o(f,{pages:_,activeCitationIndex:R,onActiveCitationChange:V,headerAction:W});return n("div",e({ref:M,className:(null==F?void 0:F.pdfViewerWrapper)||"",style:e(e(e({height:"100%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},s.pdfViewer),{display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"#FAFAFA"}),null==j?void 0:j.pdfViewer)},{children:[o(l,{highlightIndex:$,totalHighlights:oe,controls:fe,currentPosition:ge,pdfName:H,onClose:I,pdfUrl:p,viewerRef:M,customStyles:j,customClasses:F,customIcons:z,headerAction:W,isZoomEnabled:D,showHighlightsAction:B,showFullScreenAction:G}),o(a,{defaultScale:h(U),pdfUrl:p,plugins:se,customStyles:j,onLoad:function(){if(le(r.ActualSize),b>0&&!Z){var e=b-1,o=ie[e],n=C[o],a=P[e];te(e),console.log(a,"cordinateTargetHighlight"),N&&a.pageIndex>0&&ae(a.pageIndex),n>0&&(setTimeout(function(){ue(Q),de(n-1)},1e3),N||ae(n-1))}else if(Z&&K&&2===K.length){t(void 0,void 0,void 0,function(){var e,t,o,n,r;return i(this,function(i){switch(i.label){case 0:e=K[0],t=K[1],o=e,i.label=1;case 1:return o<=t?(ae(n=o-1),[4,new Promise(function(e){return setTimeout(e,1e3)})]):[3,4];case 2:if(i.sent(),ue(Q),(r=de(n))&&r>0)return[3,4];i.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}else if(!N&&C){var l=ie.find(function(e){return C[e]>0});if(void 0!==l){var s=C[l]-1;ae(s),setTimeout(function(){ue(Q),de(s)},1e3)}}requestAnimationFrame(function(){re(),N||function(){if(M.current){var e=b-1,t=ie[e],i=C[t],o=i>0?i-1:0,n={};ie.forEach(function(e,t){var i=C[e];i>0&&(n[i]||(n[i]=[]),n[i].push(t))});var r=(n[i]||[]).indexOf(e),a=0,l=function(){var e,t;if(!(++a>40)){var i=null===(e=M.current)||void 0===e?void 0:e.querySelector(".rpv-core__inner-pages");if(i){var n=null===(t=M.current)||void 0===t?void 0:t.querySelector('[data-testid="core__page-layer-'.concat(o,'"]'));if(n){var s=i.getBoundingClientRect(),c=n.getBoundingClientRect();if(c.top<s.bottom&&c.bottom>s.top){var u=n.querySelectorAll(".rpv-search__highlight")[r];if(u){var d=u.getBoundingClientRect(),g=i.scrollTop+(d.top-s.top)-i.clientHeight/2+d.height/2;i.scrollTo({top:g,behavior:"smooth"})}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}else setTimeout(l,100)}};setTimeout(l,500)}}()})},onPageChange:function(e){var t=e.currentPage;Q.has(t)?(de(t),ue(Q)):ue(Q)}})]}))};export{m as default};
|
|
2
2
|
//# sourceMappingURL=PdfViewer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as e,__assign as t}from"tslib";import{jsx as r,Fragment as n}from"react/jsx-runtime";import{useState as o,useRef as i,useMemo as a}from"react";import{searchPlugin as l}from"@react-pdf-viewer/search";import{pageNavigationPlugin as u}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as c}from"@react-pdf-viewer/zoom";import{highlightPlugin as f}from"@react-pdf-viewer/highlight";var g=function(g,s,h,p,v,d,m,T){void 0===m&&(m="yellow"),void 0===T&&(T="#F6D739");var x=o(0),y=x[0],b=x[1],w=i(!1),_=o(0),S=_[0],I=_[1];i([]);var A=function(e){return e.replace(/[^\S\n]+/g," ").trim()},B=function(e){return(e||"").toLowerCase().replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'").replace(/[\u2013\u2014]/g,"-").replace(/-/g," ").replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},M=function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t},k=function(e){var t=B(e),r=t.replace(/\s+/g,""),n=new Set;return t&&n.add(t),r&&n.add(r),n},E=function(e){return e.replace(/\\([''])/g,"$1").replace(/\]\s*\n\s*\(/g,"](").replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/`([^`]+)`/g,"$1")},z=function(e){return e?E(e).split(/\n+/).map(M).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return A(function(e){return e.replace(/(^|\W)[*_]{1,3}([^*_]+)[*_]{1,3}(?=\W|$)/g,"$1$2")}(e))}).filter(Boolean):[]},j=Object.keys(s).map(Number).sort(function(e,t){return e-t}),q=a(function(){return v?d.length:v?0:Object.values(s).filter(function(e){return e>0}).length},[d,s]),C=function(r){if(h.current){var n=h.current.querySelector('[data-testid="search__highlights-'.concat(r,'"]'));if(n){var o=Array.from(n.querySelectorAll(".rpv-search__highlight"));if(0!==o.length){var i=Z.map(k),a=H.map(k);if(0!==i.length||0!==a.length){var l=o.map(function(e){var r=function(e){var t=e.getBoundingClientRect();if(t.height>0||t.width>0)return{top:t.top,left:t.left,right:t.right};var r=e.offsetTop,n=e.offsetLeft;return{top:r,left:n,right:n+e.offsetWidth}}(e),n=(e.textContent||"").trim(),o=(e.getAttribute("title")||"").trim();return t({el:e,text:n||o},r)}).filter(function(e){return e.text.length>0}).sort(function(e,t){return e.top-t.top||e.left-t.left});if(0!==l.length){var u=[],c=null,f=[],s=function(){if(c){var e=f.join(" ");c.title=B(e),c.title&&u.push(c),c=null,f=[]}};if(l.forEach(function(e){if(!c)return c={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},void(f=[e.text]);var t=Math.abs(e.top-c.lastTop)<=5,r=e.left<=c.lastRight+28;t&&r?(c.elements.push(e.el),c.lastTop=e.top,c.lastRight=Math.max(c.lastRight,e.right),f.push(e.text)):(s(),c={title:"",elements:[e.el],lastTop:e.top,lastRight:e.right},f=[e.text])}),s(),0!==u.length){for(var p=function(e,t){if(!e)return!1;if(t.has(e))return!0;for(var r=e.replace(/\s+/g,""),n=0,o=Array.from(t);n<o.length;n++){var i=o[n];if(i){var a=i.replace(/\s+/g,"");if(a===r)return!0;if(i.length>=8&&e.length>=5&&i.includes(e))return!0;if(a.length>=8&&r.length>=5&&a.includes(r))return!0;if(e.length>=10&&i.length>=8&&e.includes(i))return!0;if(r.length>=10&&a.length>=8&&r.includes(a))return!0}}return!1},v=0,d=new Set,m=function(e){if(!e||e.length<8)return null;for(var t=e.replace(/\s+/g,""),r=0;r<u.length;r++)for(var n="",o="",i=new Set,a=r;a<u.length&&a<r+20;a++){var l=u[a].title;if(n=n?"".concat(n," ").concat(l):l,o=o?"".concat(o).concat(l.replace(/\s+/g,"")):l.replace(/\s+/g,""),i.add(a),n.includes(e)||o.includes(t))return i;if(n.length>=15&&(e.includes(n)||t.includes(o)))return i;if(n.length>e.length+150)break}return null},T=0,x=Array.from(new Set(e(e([],Z,!0),H,!0).map(B).filter(function(e){return e.length>=8}))).sort(function(e,t){return t.length-e.length});T<x.length;T++){var y=m(x[T]);y&&y.size>0&&(y.forEach(function(e){return d.add(e)}),v=d.size)}if(0===v){var b=function(e){if(0===e.length)return null;for(var t=null,r=0,n=e;r<n.length;r++)for(var o=n[r],i=0,a=Array.from(o);i<a.length;i++){var l=a[i];if(l&&!(l.length<5))for(var c=l.replace(/\s+/g,""),f=0;f<u.length;f++)for(var g="",s="",h=new Set,p=f;p<u.length&&p<f+15;p++){var v=u[p].title;if(g=g?"".concat(g," ").concat(v):v,s=s?"".concat(s).concat(v.replace(/\s+/g,"")):v.replace(/\s+/g,""),h.add(p),g.includes(l)||s.includes(c)){var d=Math.max(0,g.length-l.length);(!t||d<t.extra)&&(t={blocks:new Set(h),extra:d});break}if(g.length>l.length+120)break}}return t?t.blocks:null}(i);b&&b.size>0&&(b.forEach(function(e){return d.add(e)}),v=d.size)}var w=function(e){if(e.length<2)return 40;for(var t=[],r=1;r<e.length;r++){var n=Math.abs(e[r].lastTop-e[r-1].lastTop);n>0&&t.push(n)}if(0===t.length)return 40;t.sort(function(e,t){return e-t});var o=t[Math.floor(t.length/2)],i=Math.round(2.25*o);return Math.min(60,Math.max(24,i))}(u),_=H.map(B).filter(function(e){return e.length>=8}),S=_.map(function(e){return e.split(/\s+/).filter(function(e){return e.length>=2})});if(0===v)for(var I=a,A=0;A<u.length;A++)for(var M=u[A].title,E=0;E<I.length;E++)if(p(M,I[E])){for(var z=0,j=new Set,q=E,C=A-1,R=A;R<u.length&&q<I.length;R++){if(p(u[R].title,I[q])){if(C>=0){var $=u[C].lastTop,F=u[R].lastTop;if(Math.abs(F-$)>w)break}z++,j.add(R),C=R,q++}else if(q>0&&p(u[R].title,I[q-1])){$=u[C].lastTop,F=u[R].lastTop;Math.abs(F-$)<=3&&(j.add(R),C=R)}if(R-C>6)break}z>v&&(v=z,d=j)}if(v<Math.min(3,_.length)&&_.length>0){var P=new Set;u.forEach(function(e,t){var r=e.title.split(/\s+/).filter(function(e){return e.length>=2});if(!(r.length<2))for(var n=new Set(r),o=0,i=S;o<i.length;o++){var a=i[o];if(!(a.length<2)){for(var l=0,u=0,c=a;u<c.length;u++){var f=c[u];n.has(f)&&l++}var g=l/a.length;if(l>=3||g>=.5){P.add(t);break}}}}),P.size>0&&(d=P,v=Math.max(v,P.size))}var O=new Set;if(L.forEach(function(e){var t=B(e);t&&(O.add(t),O.add(t.replace(/\s+/g,"")))}),0===v){var N=new Set;if(u.forEach(function(e,t){var r=e.title.replace(/\s+/g,"");if(O.has(e.title)||O.has(r))N.add(t);else for(var n=Array.from(O),o=0;o<n.length;o++){var i=n[o];if(i.length>=10&&i.includes(e.title)&&e.title.length>=5){N.add(t);break}}}),0===N.size)return 0;d=N}return u.forEach(function(e,t){var r=d.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(r,"]")),console.log("input->",g),console.log("processed sentences->",Z),console.log("processed lines->",H),console.log("Expected sentence count:",i.length),console.log("Expected line count:",a.length),console.log("Matched sequence length:",v),console.log("blocksToKeep",d,"size",d.size),console.groupEnd(),d.size}}}}}}},R=function(e){h.current&&h.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(function(e){e.style.display="none"})})},$=g.map(function(e){return function(e){return e?E(e).split(/\n{2,}/).map(function(e){return z(e).join(" ")}).map(function(e){return A(e)}).filter(Boolean):[]}(e)}).flat(),F=g.map(function(e){return z(e)}).flat(),P=$.some(function(e){return e.length>=3})?3:1,Z=$.filter(function(e){return e.length>=P}),H=F.filter(function(e){return e.length>=P}),O=H.flatMap(function(e){return function(e,t,r){void 0===t&&(t=6),void 0===r&&(r=4);var n=e.split(/\s+/).filter(Boolean);if(n.length<=t)return[];for(var o=[],i=0;i+t<=n.length;i+=r)o.push(n.slice(i,i+t).join(" "));return n.length>t&&(n.length-t)%r!==0&&o.push(n.slice(n.length-t).join(" ")),o}(e)}),L=Array.from(new Set(e(e(e([],Z,!0),H,!0),O,!0).flatMap(function(e){var t=A(e.replace(/[\u00A0\u2009\u202F]/g," ").replace(/\u00ad/g,"").replace(/[""]/g,'"').replace(/['']/g,"'"));if(!t)return[];var r=t.replace(/[\u2013\u2014]/g,"-"),n=A(r.replace(/(\w)-\s+(\w)/g,"$1$2")),o=A(r.replace(/-/g," ")),i=A(r.replace(/-/g,"")),a=A(t.replace(/[^\w\s]/g,"")),l=new Set([t,r,n,o,i,a]);return Array.from(l).filter(Boolean)}))).filter(function(e){var t=e.split(/\s+/).filter(Boolean);return!(e.length<P)&&(t.length>=3||e.length>=12)}),N=l({keyword:L}),D=u(),W=c(),K=N.jumpToMatch,J=D.jumpToPage,V=W.zoomTo,G=W.ZoomInButton,Q=W.ZoomOutButton,U=W.ZoomPopover,X=f({renderHighlights:function(e){return r(n,{children:d.map(function(e,r){return t(t({},e),{originalIndex:r})}).filter(function(t){return t.pageNumber?t.pageNumber-1===e.pageIndex:t.pageIndex===e.pageIndex}).map(function(e){var t=e.originalIndex,n=t===S;return r("div",{style:{position:"absolute",left:"".concat(e.left,"%"),top:"".concat(e.top,"%"),width:"".concat(e.width,"%"),height:"".concat(e.height,"%"),background:n?T:m,opacity:n?.7:.4,transition:"background 0.2s, opacity 0.2s"}},t)})})}}),Y=function(){if(!w.current)try{K(0),w.current=!0;var e=d[0];e&&v&&te(e.pageIndex,e.top)}catch(e){requestAnimationFrame(Y)}},ee=function(e,t){if(h.current&&h.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var o,i,a=null===(o=h.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(i=h.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.querySelectorAll(".rpv-search__highlight")[t];if(u){var c=a.getBoundingClientRect(),f=u.getBoundingClientRect(),g=a.scrollTop+(f.top-c.top)-a.clientHeight/2+f.height/2;a.scrollTo({top:g,behavior:"smooth"})}}}};setTimeout(n,300)}},te=function(e,t){if(h.current){var r=0,n=function(){var o,i;if(!(++r>60)){var a=null===(o=h.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){var l=null===(i=h.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.getBoundingClientRect();if(0!==u.height){var c=a.getBoundingClientRect(),f=t/100*u.height,g=u.top-c.top+f;a.scrollTo({top:a.scrollTop+g-40,behavior:"smooth"})}else setTimeout(n,100)}else setTimeout(n,100)}else setTimeout(n,100)}};setTimeout(n,100)}},re=a(function(){var e={};return j.forEach(function(t,r){var n=s[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[j,s]),ne=function(e){var t=s[j[e]];return(re[t]||[]).indexOf(e)},oe=function(e,t){if(h.current){var r=-1,n=0,o=function(){var i,a;if(!(++n>60)){var l=null===(i=h.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(l){if(l.scrollTop!==r)return r=l.scrollTop,void setTimeout(o,100);var u=null===(a=h.current)||void 0===a?void 0:a.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(u){var c=u.getBoundingClientRect();if(0!==c.height){var f=l.getBoundingClientRect(),g=t/100*c.height,s=c.top-f.top+g;l.scrollTo({top:l.scrollTop+s-40,behavior:"instant"})}else setTimeout(o,100)}else setTimeout(o,100)}else setTimeout(o,100)}};setTimeout(o,100)}};return{setHighlightIndex:b,highlightIndex:y,cursorIndex:S,setCursorIndex:I,orderedKeys:j,totalHighlights:q,getValidPosition:function(e){if(v)return e+1;if(!s)return 0;for(var t=0,r=0;r<=e;r++)s[j[r]]>0&&t++;return t},tryJump:Y,jumpToPage:J,zoomTo:V,hideNonTargetHighlights:R,deduplicateHighlights:C,scrollToCoord:te,plugins:[v?X:N,D,W],controls:{ZoomInButton:G,ZoomOutButton:Q,ZoomPopover:U,goToNext:function(){if(v&&d)for(var e=S+1;e<d.length;e++){var t=d[e],r=d[S];return I(e),J(t.pageIndex),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),oe(t.pageIndex,t.top)):te(t.pageIndex,t.top))}else{var n=function(e){var t=j[e];if(s[t]>0){var r=s[t]-1,n=ne(e);return I(e),J(s[t]-1),ee(r,n),setTimeout(function(){C(r)},500),1===Object.keys(s).length&&R(p),{value:void 0}}};for(e=S+1;e<j.length;e++){var o=n(e);if("object"==typeof o)return o.value}}},goToPrevious:function(){if(v&&d)for(var e=S-1;e>=0;e--){var t=d[e],r=d[S];return I(e),J(t.pageIndex),void(t.pageIndex!==r.pageIndex?(J(t.pageIndex),oe(t.pageIndex,t.top)):te(t.pageIndex,t.top))}else{var n=function(e){var t=j[e];if(s[t]>0){var r=s[t]-1,n=ne(e);return I(e),J(s[t]-1),ee(r,n),setTimeout(function(){C(r)},500),1===Object.keys(s).length&&R(p),{value:void 0}}};for(e=S-1;e>=0;e--){var o=n(e);if("object"==typeof o)return o.value}}}}}};export{g as PdfHighlightControls};
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as t,Fragment as r}from"react/jsx-runtime";import{useState as o,useRef as n,useMemo as i}from"react";import{searchPlugin as a}from"@react-pdf-viewer/search";import{pageNavigationPlugin as l}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as c}from"@react-pdf-viewer/zoom";import{highlightPlugin as u}from"@react-pdf-viewer/highlight";var s=function(s,p,g,f,v,h,d,m){void 0===d&&(d="yellow"),void 0===m&&(m="#F6D739");var T=o(0),y=T[0],x=T[1],_=n(!1),b=o(0),I=b[0],S=b[1];n([]);var q=function(e){if(!e)return[];return e.replace(/\\(['’])/g,"$1").replace(/\]\s*\n\s*\(/g,"](").split(/\n+/).map(function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t}).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return e.replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/[^\S\n]+/g," ").trim()}).flatMap(function(e){return e.split(/\n+/)}).flatMap(function(e){for(var t,r=[],o=/([*_]{1,3})([^*_]+)\1|([*_]{1,3})/g,n=0;null!==(t=o.exec(e));){var i=e.slice(n,t.index).trim();i&&r.push(i),t[2]&&r.push(t[2].trim()),n=t.index+t[0].length}var a=e.slice(n).trim();return a&&r.push(a),r.flatMap(function(e){return e.split(/[\u2013\u2014-]/g)}).flatMap(function(e){return e.split(/\n+/)}).map(function(e){return e.replace(/[*_]+/g,"").replace(/`([^`]+)`/g,"$1").replace(/[^\S\n]+/g," ").trim()})})},w=Object.keys(p).map(Number).sort(function(e,t){return e-t}),B=i(function(){return v?h.length:v?0:Object.values(p).filter(function(e){return e>0}).length},[h,p]),A=function(e){if(g.current){var t=g.current.querySelector('[data-testid="search__highlights-'.concat(e,'"]'));if(t){var r=Array.from(t.querySelectorAll(".rpv-search__highlight")),o=function(e){return(e||"").toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},n=M.map(o).filter(Boolean);if(0!==n.length){var i=[],a=null;r.forEach(function(e){var t=o(e.getAttribute("title")||e.textContent||""),r=parseFloat(e.style.top||"0");a?a.title===t&&Math.abs(a.lastTop-r)<=3?(a.elements.push(e),a.lastTop=r):(i.push(a),a={title:t,elements:[e],lastTop:r}):a={title:t,elements:[e],lastTop:r}}),a&&i.push(a);for(var l=0,c=new Set,u=0;u<i.length;u++)for(var p=i[u].title,f=0;f<n.length;f++)if(n[f]===p){for(var v=0,h=new Set,d=f,m=u-1,T=u;T<i.length&&d<n.length;T++){if(i[T].title===n[d]){if(m>=0){var y=i[m].lastTop,x=parseFloat(i[T].elements[0].style.top||"0");if(Math.abs(x-y)>15)break}v++,h.add(T),m=T,d++}else if(d>0&&i[T].title===n[d-1]){y=i[m].lastTop,x=parseFloat(i[T].elements[0].style.top||"0");Math.abs(x-y)<=3&&(h.add(T),m=T)}if(T-m>4)break}v>l&&(l=v,c=h)}return i.forEach(function(e,t){var r=c.has(t);e.elements.forEach(function(e){r?(e.classList.add("verified-match"),e.style.display=""):(e.style.display="none",e.classList.remove("verified-match"))})}),console.groupCollapsed("[debug: PDF ordered matching - Page ".concat(e,"]")),console.log("input->",s),console.log("processed text->",M),console.log("Expected sequence length:",n.length),console.log("Matched ordered sequence length:",l),console.log("blocksToKeep",c,"size",c.size),console.groupEnd(),c.size}}}},C=function(e){g.current&&g.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),o=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),n=t.querySelectorAll(".rpv-search__highlight");e.has(o)||n.forEach(function(e){e.style.display="none"})})},M=s.map(function(e){return q(e)}).flat(),j=a({keyword:M}),E=l(),F=c(),k=j.jumpToMatch,z=E.jumpToPage,P=F.zoomTo,Z=F.ZoomInButton,H=F.ZoomOutButton,O=F.ZoomPopover,R=u({renderHighlights:function(o){return t(r,{children:h.map(function(t,r){return e(e({},t),{originalIndex:r})}).filter(function(e){return e.pageNumber?e.pageNumber-1===o.pageIndex:e.pageIndex===o.pageIndex}).map(function(e){var r=e.originalIndex,o=r===I;return t("div",{style:{position:"absolute",left:"".concat(e.left,"%"),top:"".concat(e.top,"%"),width:"".concat(e.width,"%"),height:"".concat(e.height,"%"),background:o?m:d,opacity:o?.7:.4,transition:"background 0.2s, opacity 0.2s"}},r)})})}}),N=function(){if(!_.current)try{k(0),_.current=!0;var e=h[0];e&&v&&$(e.pageIndex,e.top)}catch(e){requestAnimationFrame(N)}},L=function(e,t){if(g.current&&g.current.querySelector(".rpv-core__viewer")){var r=-1,o=function(){var n,i,a=null===(n=g.current)||void 0===n?void 0:n.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(o,100);var l=null===(i=g.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var c=l.querySelectorAll(".rpv-search__highlight")[t];if(c){var u=a.getBoundingClientRect(),s=c.getBoundingClientRect(),p=a.scrollTop+(s.top-u.top)-a.clientHeight/2+s.height/2;a.scrollTo({top:p,behavior:"smooth"})}}}};setTimeout(o,300)}},$=function(e,t){if(g.current){var r=0,o=function(){var n,i;if(!(++r>60)){var a=null===(n=g.current)||void 0===n?void 0:n.querySelector(".rpv-core__inner-pages");if(a){var l=null===(i=g.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var c=l.getBoundingClientRect();if(0!==c.height){var u=a.getBoundingClientRect(),s=t/100*c.height,p=c.top-u.top+s;a.scrollTo({top:a.scrollTop+p-40,behavior:"smooth"})}else setTimeout(o,100)}else setTimeout(o,100)}else setTimeout(o,100)}};setTimeout(o,100)}},D=i(function(){var e={};return w.forEach(function(t,r){var o=p[t];o>0&&(e[o]||(e[o]=[]),e[o].push(r))}),e},[w,p]),K=function(e){var t=p[w[e]];return(D[t]||[]).indexOf(e)},J=function(e,t){if(g.current){var r=-1,o=0,n=function(){var i,a;if(!(++o>60)){var l=null===(i=g.current)||void 0===i?void 0:i.querySelector(".rpv-core__inner-pages");if(l){if(l.scrollTop!==r)return r=l.scrollTop,void setTimeout(n,100);var c=null===(a=g.current)||void 0===a?void 0:a.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(c){var u=c.getBoundingClientRect();if(0!==u.height){var s=l.getBoundingClientRect(),p=t/100*u.height,f=u.top-s.top+p;l.scrollTo({top:l.scrollTop+f-40,behavior:"instant"})}else setTimeout(n,100)}else setTimeout(n,100)}else setTimeout(n,100)}};setTimeout(n,100)}};return{setHighlightIndex:x,highlightIndex:y,cursorIndex:I,setCursorIndex:S,orderedKeys:w,totalHighlights:B,getValidPosition:function(e){if(v)return e+1;if(!p)return 0;for(var t=0,r=0;r<=e;r++)p[w[r]]>0&&t++;return t},tryJump:N,jumpToPage:z,zoomTo:P,hideNonTargetHighlights:C,deduplicateHighlights:A,scrollToCoord:$,plugins:[v?R:j,E,F],controls:{ZoomInButton:Z,ZoomOutButton:H,ZoomPopover:O,goToNext:function(){if(v&&h)for(var e=I+1;e<h.length;e++){var t=h[e],r=h[I];return S(e),z(t.pageIndex),void(t.pageIndex!==r.pageIndex?(z(t.pageIndex),J(t.pageIndex,t.top)):$(t.pageIndex,t.top))}else{var o=function(e){var t=w[e];if(p[t]>0){var r=p[t]-1,o=K(e);return S(e),z(p[t]-1),L(r,o),setTimeout(function(){A(r)},500),1===Object.keys(p).length&&C(f),{value:void 0}}};for(e=I+1;e<w.length;e++){var n=o(e);if("object"==typeof n)return n.value}}},goToPrevious:function(){if(v&&h)for(var e=I-1;e>=0;e--){var t=h[e],r=h[I];return S(e),z(t.pageIndex),void(t.pageIndex!==r.pageIndex?(z(t.pageIndex),J(t.pageIndex,t.top)):$(t.pageIndex,t.top))}else{var o=function(e){var t=w[e];if(p[t]>0){var r=p[t]-1,o=K(e);return S(e),z(p[t]-1),L(r,o),setTimeout(function(){A(r)},500),1===Object.keys(p).length&&C(f),{value:void 0}}};for(e=I-1;e>=0;e--){var n=o(e);if("object"==typeof n)return n.value}}}}}};export{s as PdfHighlightControls};
|
|
2
2
|
//# sourceMappingURL=usePdfHighlight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAKA,QAAA,MAAM,oBAAoB,+
|
|
1
|
+
{"version":3,"file":"CognitiveCompareTest.d.ts","sourceRoot":"","sources":["../../../src/CognitiveCompareTest.tsx"],"names":[],"mappings":"AAKA,QAAA,MAAM,oBAAoB,+CAqNzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAuCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAkBlC,QAAA,MAAM,gBAAgB,8PAsBnB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"CognitiveCompare.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompare.tsx"],"names":[],"mappings":"AAuCA,OAAO,EAEL,qBAAqB,EAMtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAkBlC,QAAA,MAAM,gBAAgB,8PAsBnB,qBAAqB,4CAglHvB,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitiveCompareConstants.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompareConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEzF,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,UAAU,KAAK,CAAC;AAG7B,eAAO,MAAM,qBAAqB,EAAE,QAAgC,CAAC;AACrE,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;AACnE,eAAO,MAAM,yBAAyB,EAAE,iBAavC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAC,
|
|
1
|
+
{"version":3,"file":"CognitiveCompareConstants.d.ts","sourceRoot":"","sources":["../../../../../src/features/CognitiveCompare/CognitiveCompareConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEzF,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,UAAU,KAAK,CAAC;AAG7B,eAAO,MAAM,qBAAqB,EAAE,QAAgC,CAAC;AACrE,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;AACnE,eAAO,MAAM,yBAAyB,EAAE,iBAavC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAC,iBAMtC,CAAA"}
|
|
@@ -106,6 +106,7 @@ export interface CognitiveCompareProps {
|
|
|
106
106
|
deviationNodeIdToView?: {
|
|
107
107
|
id: string;
|
|
108
108
|
trigger: number;
|
|
109
|
+
displayImpact?: boolean;
|
|
109
110
|
};
|
|
110
111
|
resetDeviationNodeId?: () => void;
|
|
111
112
|
resetTrigger?: number;
|
|
@@ -250,6 +251,7 @@ export type CognitiveSummaryPopupProps = {
|
|
|
250
251
|
scrollContainerEl?: HTMLElement | null;
|
|
251
252
|
markdownStyles?: React.CSSProperties & Record<string, any>;
|
|
252
253
|
isLoading?: boolean;
|
|
254
|
+
displayImpact?: boolean;
|
|
253
255
|
};
|
|
254
256
|
export type SummaryPopupState = {
|
|
255
257
|
open: boolean;
|
|
@@ -257,6 +259,7 @@ export type SummaryPopupState = {
|
|
|
257
259
|
summary: string | Record<string, any> | null;
|
|
258
260
|
markdownStyles?: React.CSSProperties & Record<string, any>;
|
|
259
261
|
isLoading?: boolean;
|
|
262
|
+
displayImpact?: boolean;
|
|
260
263
|
};
|
|
261
264
|
export type HighlightMatch = {
|
|
262
265
|
idx?: number;
|