@viswa-test/test-citation 0.0.390 → 0.0.391
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/CitationAnchor.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationAnchor.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationRenderer.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CitationRenderer.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CognitivePopup.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/CompareContext.js +1 -1
- package/dist/cjs/features/CognitiveCompare/CompareContext.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/cjs/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfToolbar.js.map +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.css.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/cjs/features/PdfViewer/PdfViewer.js.map +1 -1
- package/dist/cjs/features/PdfViewer/rotationManager.js +1 -1
- package/dist/cjs/features/PdfViewer/rotationManager.js.map +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/cjs/features/PdfViewer/usePdfHighlight.js.map +1 -1
- package/dist/cjs/features/PdfViewer/zoomStateManager.js +2 -0
- package/dist/cjs/features/PdfViewer/zoomStateManager.js.map +1 -0
- package/dist/cjs/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/CognitiveScoreBadge.js.map +1 -1
- package/dist/cjs/features/SegmentReviewComponents/reviewStepAdapters.js +1 -1
- package/dist/cjs/features/SegmentReviewComponents/reviewStepAdapters.js.map +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
- package/dist/features/CognitiveCompare/CitationAnchor.js.map +1 -1
- package/dist/features/CognitiveCompare/CitationRenderer.js +1 -1
- package/dist/features/CognitiveCompare/CitationRenderer.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompare.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompareConstants.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveCompareConstants.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js +1 -1
- package/dist/features/CognitiveCompare/CognitiveComparehelpers.js.map +1 -1
- package/dist/features/CognitiveCompare/CognitivePopup.js +1 -1
- package/dist/features/CognitiveCompare/CognitivePopup.js.map +1 -1
- package/dist/features/CognitiveCompare/CompareContext.js +1 -1
- package/dist/features/CognitiveCompare/CompareContext.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/GuidelinePanel.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/components/WebGptPanel.js.map +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js.map +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/LHSSectionRow.js.map +1 -1
- package/dist/features/CognitiveCompare/components/RHSSectionRow.js +1 -1
- package/dist/features/CognitiveCompare/components/RHSSectionRow.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SectionAccordion.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js +1 -1
- package/dist/features/CognitiveCompare/components/SubSectionAccordion.js.map +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
- package/dist/features/CognitiveCompare/components/SvgConnectors.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js +1 -1
- package/dist/features/CognitiveCompare/hooks/memoizedMarkdown.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useCompareData.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js.map +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js +1 -1
- package/dist/features/CognitiveCompare/hooks/useSideBySide.js.map +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js +1 -1
- package/dist/features/PdfViewer/PdfToolbar.js.map +1 -1
- package/dist/features/PdfViewer/PdfViewer.css.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js +1 -1
- package/dist/features/PdfViewer/PdfViewer.js.map +1 -1
- package/dist/features/PdfViewer/rotationManager.js +1 -1
- package/dist/features/PdfViewer/rotationManager.js.map +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js +1 -1
- package/dist/features/PdfViewer/usePdfHighlight.js.map +1 -1
- package/dist/features/PdfViewer/zoomStateManager.js +2 -0
- package/dist/features/PdfViewer/zoomStateManager.js.map +1 -0
- package/dist/features/SegmentReviewComponents/CognitiveScoreBadge.js +1 -1
- package/dist/features/SegmentReviewComponents/CognitiveScoreBadge.js.map +1 -1
- package/dist/features/SegmentReviewComponents/reviewStepAdapters.js +1 -1
- package/dist/features/SegmentReviewComponents/reviewStepAdapters.js.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts +0 -2
- package/dist/types/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts +1 -8
- package/dist/types/features/CognitiveCompare/CitationRenderer.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareConstants.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts +3 -12
- package/dist/types/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts +0 -12
- package/dist/types/features/CognitiveCompare/CognitiveComparehelpers.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CognitivePopup.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/CompareContext.d.ts +2 -9
- package/dist/types/features/CognitiveCompare/CompareContext.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/components/GuidelinePanel.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/components/WebGptPanel.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts +1 -14
- package/dist/types/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/LHSSectionRow.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/RHSSectionRow.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SubSectionAccordion.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts +3 -2
- package/dist/types/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts +1 -2
- package/dist/types/features/CognitiveCompare/hooks/memoizedMarkdown.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
- package/dist/types/features/CognitiveCompare/hooks/useSideBySide.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/PdfToolbar.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/PdfViewer.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/rotationManager.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/usePdfHighlight.d.ts +1 -2
- package/dist/types/features/PdfViewer/usePdfHighlight.d.ts.map +1 -1
- package/dist/types/features/PdfViewer/zoomStateManager.d.ts +21 -0
- package/dist/types/features/PdfViewer/zoomStateManager.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@mui/material"),o=require("lucide-react"),n=require("react"),i=require("../../assests/svg/PdfViewerIcons.js"),r=require("./CompareContext.js"),a=require("./CitationRendererInner.js");const s="90vh",l={border:"1px solid #D0D5DD",borderRadius:"6px",background:"#FFFFFF",color:"#344054",cursor:"pointer",fontSize:"12px",fontWeight:600,padding:"3px 8px"};exports.default=({href:d,children:c,citationType:p,citationReason:x,metaData:u,chevronUpComponent:g=null,chevronDownComponent:h=null,customStyle:b={},defaultState:f=!1,onFullscreenChange:m,onDemandCitationContext:C})=>{const y=r.useOptionalCompareContext(),v=y?.onDemandCitationConfig,j=y?.getOnDemandCitationCacheEntry,w=y?.fetchOnDemandCitationContext,F=y?.onDemandCitationCacheVersion,[D,k]=n.useState(f),[S,z]=n.useState(!1),R="string"==typeof c&&c?.split("\n")?.length>1?c.split("\n").join(" "):c,A="string"==typeof c?c:c[0];n.useEffect(()=>{if(m?.(S),S)return()=>{m?.(!1)}},[S,m]);const G=n.useMemo(()=>C&&j?j(C):void 0,[j,F,C]),I=!!v?.enabled&&!!C,B="success"===G?.status&&G.data&&"object"==typeof G.data&&Object.keys(G.data).length>0,E=n.useMemo(()=>({...u,citations:I?B?G?.data:{}:u?.citations}),[B,I,u,G?.data]),W=I&&(!G||"loading"===G.status)&&!B,q=I&&"error"===G?.status&&!B,P=I&&"success"===G?.status&&!B,O=!I||B,T=n.useCallback(()=>{v?.enabled&&C&&w&&("loading"===G?.status||"success"===G?.status&&B||w(C).catch(e=>{v.debug&&console.error("[CognitiveCompare:onDemandCitations] citation fetch failed",e)}))},[w,B,G?.status,v,C]),M=g??(U=b?.arrow??{},e.jsx(o.ChevronUp,{size:U?.fontSize??16,color:U?.color??"rgb(214, 51, 132)"}));var U;const H=h??(t=>e.jsx(o.ChevronDown,{size:t?.fontSize??16,color:t?.color??"rgb(214, 51, 132)"}))(b?.arrow??{}),L=t=>e.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),T()},style:{...l,...t},children:"Retry"}),V=e.jsxs("div",{style:{boxSizing:"border-box",border:S?"none":"1px solid #E4E7EC",borderRadius:S?0:"8px",overflow:"hidden",marginTop:S?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:S?"100%":void 0,backgroundColor:"#FAFAFA"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0},children:e.jsx("button",{onClick:()=>{z(e=>!e)},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"},children:S?e.jsx(i.DefaultFullScreenCloseIcon,{}):e.jsx(i.DefaultFullScreenIcon,{})})}),e.jsxs("div",{style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"},children:[W&&e.jsx("div",{style:{padding:"12px",fontSize:"13px",color:"#475467"},children:"Loading citation details..."}),q&&e.jsxs("div",{style:{padding:"12px",fontSize:"13px",color:"#B42318",display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{children:"Unable to load citation details. Please try again later."}),L({border:"1px solid #FDA29B",color:"#B42318"})]}),P&&e.jsxs("div",{style:{padding:"12px",fontSize:"13px",color:"#475467",display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{children:"Citation details are not available for this source."}),L()]}),O&&e.jsx(a.default,{href:d,children:c,metaData:E,citationTitle:A,citationType:p,citationReason:x,isFullscreen:S})]})]});return e.jsxs("span",{style:{display:"inline",...b.relativeWrapper||{}},children:[e.jsx("div",{style:{display:"inline",marginTop:0,...b.citationButtonWrapper||{}},children:e.jsxs("button",{type:"button",onClick:()=>{k(e=>{const t=!e;return t&&T(),t})},style:{display:u?.webGpt?"inline":"inline-flex",alignItems:u?.webGpt?void 0:"center",gap:u?.webGpt?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:u?.webGpt?600:700,color:u?.webGpt?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal",...b.citationButton||{}},children:[u?.webGpt&&e.jsx(o.Globe,{size:b.arrow?.fontSize??"1em",color:b.arrow?.color??"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),e.jsx("span",{children:R}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",marginLeft:u?.webGpt?"3px":void 0,verticalAlign:u?.webGpt?"-0.125em":void 0},children:D?M:H})]})}),D&&(S?e.jsx(t.Dialog,{open:S,onClose:()=>{z(!1),m?.(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:s,m:0,maxHeight:s,maxWidth:"95vw",overflow:"hidden",width:"95vw"}},children:V}):V)]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lucide-react"),i=require("react"),a=require("./ResizableSplitPane.js"),n=require("../PdfViewer/PdfViewer.js"),r=require("../../assests/svg/PdfViewerIcons.js"),o=require("react-markdown"),s=require("rehype-raw"),l=require("@mui/material"),c=require("./CognitiveCompareConfig.js");require("react-dom");var d=require("./CompareContext.js"),u=require("./Guidelines/utils/processGuidelinesMarkdown.js"),p=require("../GptWebCitation/GptWebCitation.js"),h=require("../GptWebCitation/types.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("./components/SubSectionAccordion.js"),require("./components/LHSSectionRow.js"),require("./components/RHSSectionRow.js");var m=g(o),x=g(s);const f=e=>(e?.extraMetaData||e)?.aiReasoningCitation?.gpt_citation?.[0]||null,b="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",_="sai.siddhartha@techolution.com",y="672e32f7a0e8fe2e8e50bcba",w="TNV Sai Siddhartha",C="90vh",j=`calc(${C} - 120px)`,v=()=>"function"==typeof globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.floor(16*Math.random());return("x"===e?t:t%4+8).toString(16)}),D=(e,t)=>{const i=(e=>e?.payloadCitationId||e?.extraMetaData?.payloadCitationId||"")(e)||t||v();return((e,t)=>{e&&"object"==typeof e&&(e.payloadCitationId=t,e.extraMetaData&&"object"==typeof e.extraMetaData&&(e.extraMetaData.payloadCitationId=t))})(e,i),i},F=({metaData:a,isFullscreen:n=!1})=>{const{gptWebCitationConfig:r}=d.useCompareContext(),o=i.useMemo(()=>(e=>({endpoint:e?.endpoint||b,userEmail:e?.userEmail||_,userId:e?.userId||y,userName:e?.userName||w,headers:e?.headers}))(r),[r]),s=a?.webGpt,l=i.useRef(null);l.current||(l.current=v());const c=i.useMemo(()=>((e,t,i)=>{const a=f(e),n=a?.customMetaData||{},r=n?.value||{},o=e?.webSearchAnswer||{},s=e?.extraMetaData||e||{};return{userEmail:e?.userEmail||o?.userEmail||t?.userEmail||"",userId:e?.userId||o?.userId||t?.userId||"",userName:e?.userName||o?.userName||t?.userName||"",citationId:D(e,i),citationUrl:r?.citationUrl||o?.citationUrl||"",content:s?.Reasoning||o?.enhanced_content||"",citationType:r?.citationType||"web",citatioNumber:n?.citation_number??a?.citation_number??Number(e?.reasoningId||0)}})(s,o,l.current||void 0),[s,o]),u=i.useMemo(()=>f(s),[s]),g=u?.customMetaData?.value||{},m=s?.extraMetaData||s||{},[x,C]=i.useState(),[F,S]=i.useState("pending"),[P,T]=i.useState(!0);i.useEffect(()=>{let e=!0;return(async()=>{if(o.endpoint&&c?.citationUrl&&c?.content){S("pending");try{const t=await fetch(o.endpoint,{method:"POST",headers:{"actor-id":c.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json",...o.headers||{}},body:JSON.stringify(c)});if(!t.ok)throw new Error(`Failed to fetch GPT web citation (${t.status})`);const i=await t.json();if(!e)return;C(i?.responseData||i?.result||i?.data||i),S("success")}catch(t){if(!e)return;console.error("Failed to load GPT web citation",t),S("error")}}else S("error")})(),()=>{e=!1}},[c,o]);const k=i.useMemo(()=>({item:{confidence_score:Number(m?.Confidence_score||0),text:g?.paraphrase||"Web citation reasoning",dataSource:g?.text||m?.Reasoning||"",paraphrase:g?.paraphrase||""},headerTitle:"GPT Web Citation",index:Number(c?.citatioNumber||1)-1,iconsConfig:{ChevronDownIcon:t.ChevronDown,ChevronUpIcon:t.ChevronUp,MaximizeIcon:t.Maximize2,CloseIcon:t.X}}),[g,c?.citatioNumber,m]),M=i.useMemo(()=>({...k,...n?{bodyHeight:j}:{}}),[k,n]);return e.jsx(p.default,{gptCitation:M,defaultCitationUrl:c?.citationUrl||"",citationType:h.CitationType.GPT_WEB,webCitationData:x,webCitationStatus:F,showWebCitation:P,onToggleCitationView:()=>T(e=>!e),iconsConfig:{MaximizeIcon:t.Maximize2,ExternalLinkIcon:t.ExternalLink},isFixedHeight:!0})},S=({href:t,metaData:r,citationTitle:o,citationType:s,citationReason:p,isFullscreen:h})=>{const{guidelinesData:g}=d.useCompareContext(),{citationNumber:f,phraseToHighlight:b,citationTypeFromHref:_}=(e=>{try{const{citationNumber:t,parsedUrl:i}=(e=>{const t=e.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(t)try{const i=e.indexOf("?"),a=i>=0?e.slice(i):"";return{citationNumber:t[1],parsedUrl:new URL(a||"./",window.location.origin)}}catch{return{citationNumber:t[1],parsedUrl:null}}try{const t=new URL(e,window.location.origin);return{citationNumber:t.searchParams.get("citationNumber")||t.searchParams.get("citation_number"),parsedUrl:t}}catch{return{citationNumber:null,parsedUrl:null}}})(e),a=i?.searchParams.get("phrase_to_highlight")||null;return{citationNumber:t,phraseToHighlight:a,citationTypeFromHref:i?.searchParams.get("citation_type")||null}}catch{return{citationNumber:null,phraseToHighlight:null,citationTypeFromHref:null}}})(t),y=s||_||void 0,w="il_rulebook_citation"===y?"rulebook_citation":y,C=f&&r?.citations?.[f]||{},j=r?.docData?.documents||{},v=r?.docData?.input_index_map||{},D=Object.keys(r?.citations||{}).length>0||Object.keys(r?.docData||{}).length>0,S=v?.[0],P=v?.[1],T=S?j[S]:null,k=P?j[P]:null,M=S?C[S]:null,N=P?C[P]:null,I=i.useMemo(()=>M&&T?e.jsx(n.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:T?.title,pdfUrl:T?.signed_url,highlightText:[M?.highlighted_text??""],highlightPages:{1:M?.custom_metadata?.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[M?.custom_metadata?.pdf_start_page_number,M?.custom_metadata?.pdf_end_page_number]}):null,[T?.title,T?.signed_url,M?.highlighted_text,M?.custom_metadata?.pdf_start_page_number,M?.custom_metadata?.pdf_end_page_number]),R=i.useMemo(()=>N&&k?e.jsx(n.default,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:k?.title,pdfUrl:k?.signed_url,jumpToPageValue:1,highlightText:[N?.highlighted_text??""],highlightPages:{1:N?.custom_metadata?.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[N?.custom_metadata?.pdf_start_page_number,N?.custom_metadata?.pdf_end_page_number]}):null,[k?.title,k?.signed_url,N?.highlighted_text,N?.custom_metadata?.pdf_start_page_number,N?.custom_metadata?.pdf_end_page_number]),G="dual_citation"===w,U=G&&!!r?.webGpt,E=i.useMemo(()=>{if(!I)return null;const t=U?e.jsx(F,{metaData:r,isFullscreen:h}):"rulebook_citation"===w?e.jsx(e.Fragment,{children:e.jsx(l.Box,{sx:{padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px",...c.SHARED_MARKDOWN_STYLES,overflow:"auto"},children:e.jsx(m.default,{rehypePlugins:[x.default],children:u.processGuidelinesMarkdown({guidelinesData:g,targetHighlights:[b],labelColor:"#FEF08A"})})})}):R;return t?e.jsx(a.default,{leftComponent:I,rightComponent:t,isFullscreen:h}):I},[I,R,w,U,r,h,g,b]);return r?.webGpt&&!D?e.jsx(F,{metaData:r,isFullscreen:h}):f?"rulebook_citation"===w?M?e.jsx("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:E}):e.jsx("div",{style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5},children:p||"Rulebook citation selected."}):G?M||N?e.jsx("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:E}):r?.webGpt?e.jsx(F,{metaData:r,isFullscreen:h}):e.jsx("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(o)?M||N?e.jsx("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:E}):e.jsx("div",{children:"Missing PDF Citation. Please try again later"}):e.jsx("div",{children:"No Citation Found. Please try again later"}):null};exports.default=({href:a,children:n,citationType:o,citationReason:s,metaData:c,chevronUpComponent:d=null,chevronDownComponent:u=null,customStyle:p={},defaultState:h=!1,onFullscreenChange:g})=>{const[m,x]=i.useState(h),[f,b]=i.useState(!1),_="string"==typeof n&&n?.split("\n")?.length>1?n.split("\n").join(" "):n;i.useEffect(()=>{if(g?.(f),f)return()=>{g?.(!1)}},[f,g]);const y="string"==typeof n?n:n[0],w=d??(j=p?.arrow??{},e.jsx(t.ChevronUp,{size:j?.fontSize??16,color:j?.color??"rgb(214, 51, 132)"}));var j;const v=u??(i=>e.jsx(t.ChevronDown,{size:i?.fontSize??16,color:i?.color??"rgb(214, 51, 132)"}))(p?.arrow??{}),D=e.jsxs("div",{style:{boxSizing:"border-box",border:f?"none":"1px solid #E4E7EC",borderRadius:f?0:"8px",overflow:"hidden",marginTop:f?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:f?"100%":void 0,backgroundColor:"#FAFAFA"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0},children:e.jsx("button",{onClick:()=>{b(e=>!e)},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"},children:f?e.jsx(r.DefaultFullScreenCloseIcon,{}):e.jsx(r.DefaultFullScreenIcon,{})})}),e.jsx("div",{style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"},children:e.jsx(S,{href:a,children:n,metaData:c,citationTitle:y,citationType:o,citationReason:s,isFullscreen:f})})]});return e.jsxs("span",{style:{display:"inline",...p.relativeWrapper||{}},children:[e.jsx("div",{style:{display:"inline",marginTop:0,...p.citationButtonWrapper||{}},children:e.jsxs("button",{type:"button",onClick:()=>x(e=>!e),style:{display:c?.webGpt?"inline":"inline-flex",alignItems:c?.webGpt?void 0:"center",gap:c?.webGpt?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:c?.webGpt?600:700,color:c?.webGpt?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal",...p.citationButton||{}},children:[c?.webGpt&&e.jsx(t.Globe,{size:p.arrow?.fontSize??"1em",color:p.arrow?.color??"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),e.jsx("span",{children:_}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",marginLeft:c?.webGpt?"3px":void 0,verticalAlign:c?.webGpt?"-0.125em":void 0},children:m?w:v})]})}),m&&(f?e.jsx(l.Dialog,{open:f,onClose:()=>b(!1),maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:C,m:0,maxHeight:C,maxWidth:"95vw",overflow:"hidden",width:"95vw"}},children:D}):D)]})};
|
|
2
2
|
//# sourceMappingURL=CitationAnchor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CitationAnchor.js","sources":["../../../../src/features/CognitiveCompare/CitationAnchor.tsx"],"sourcesContent":["import { Dialog } from \"@mui/material\";\nimport { ChevronDown, ChevronUp, Globe } from \"lucide-react\";\nimport React, {\n CSSProperties,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { DefaultFullScreenIcon, DefaultFullScreenCloseIcon } from \"../../assests/svg/PdfViewerIcons\";\nimport type { OnDemandCitationContext } from \"./CognitiveCompareTypes\";\nimport { useOptionalCompareContext } from \"./CompareContext\";\nimport CitationRendererInner from \"./CitationRendererInner\";\n\ninterface CitationAnchorProps {\n href: string;\n children: any;\n citationType?: string;\n citationReason?: string;\n chevronUpComponent?: React.ReactNode;\n chevronDownComponent?: React.ReactNode;\n customStyle?: {\n citationButtonWrapper?: CSSProperties;\n arrow?: CSSProperties;\n citationButton?: CSSProperties;\n expandableContent?: CSSProperties;\n bookHeader?: CSSProperties;\n relative?: CSSProperties;\n pageColor?: CSSProperties;\n highlightedText?: CSSProperties;\n expandedWrapper?: CSSProperties;\n expandableContainer?: CSSProperties;\n bookBodyContent?: CSSProperties;\n customScrollbarClass?: CSSProperties;\n relativeWrapper?: CSSProperties;\n };\n defaultState?: boolean;\n metaData?: any;\n onFullscreenChange?: (isFullscreen: boolean) => void;\n onDemandCitationContext?: OnDemandCitationContext;\n}\n\nconst CITATION_FULLSCREEN_DIALOG_HEIGHT = \"90vh\";\n\nconst retryButtonStyle: React.CSSProperties = {\n border: \"1px solid #D0D5DD\",\n borderRadius: \"6px\",\n background: \"#FFFFFF\",\n color: \"#344054\",\n cursor: \"pointer\",\n fontSize: \"12px\",\n fontWeight: 600,\n padding: \"3px 8px\",\n};\n\nconst CitationAnchor: React.FC<CitationAnchorProps> = ({\n href,\n children,\n citationType,\n citationReason,\n metaData,\n chevronUpComponent = null,\n chevronDownComponent = null,\n customStyle = {},\n defaultState = false,\n onFullscreenChange,\n onDemandCitationContext,\n}) => {\n const compareContext = useOptionalCompareContext();\n const onDemandCitationConfig = compareContext?.onDemandCitationConfig;\n const getOnDemandCitationCacheEntry = compareContext?.getOnDemandCitationCacheEntry;\n const fetchOnDemandCitationContext = compareContext?.fetchOnDemandCitationContext;\n const onDemandCitationCacheVersion = compareContext?.onDemandCitationCacheVersion;\n const [isExpanded, setIsExpanded] = useState(defaultState);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n const ChevronUpComponentDefault = (arrow: CSSProperties) => (\n <ChevronUp\n size={arrow?.fontSize ?? 16}\n color={arrow?.color ?? \"rgb(214, 51, 132)\"}\n />\n );\n\n const ChevronDownComponentDefault = (arrow: CSSProperties) => (\n <ChevronDown\n size={arrow?.fontSize ?? 16}\n color={arrow?.color ?? \"rgb(214, 51, 132)\"}\n />\n );\n\n const citationDisplayTitle =\n typeof children === \"string\" && children?.split(\"\\n\")?.length > 1\n ? children.split(\"\\n\").join(\" \")\n : children;\n const citationTitle = typeof children === \"string\" ? children : children[0];\n\n useEffect(() => {\n onFullscreenChange?.(isFullscreen);\n\n if (!isFullscreen) return;\n\n return () => {\n onFullscreenChange?.(false);\n };\n }, [isFullscreen, onFullscreenChange]);\n\n const onDemandCacheEntry = useMemo(\n () => onDemandCitationContext && getOnDemandCitationCacheEntry\n ? getOnDemandCitationCacheEntry(onDemandCitationContext)\n : undefined,\n [\n getOnDemandCitationCacheEntry,\n onDemandCitationCacheVersion,\n onDemandCitationContext,\n ],\n );\n const isOnDemandCitationEnabled =\n !!onDemandCitationConfig?.enabled &&\n !!onDemandCitationContext;\n const hasOnDemandCitationData =\n onDemandCacheEntry?.status === \"success\" &&\n onDemandCacheEntry.data &&\n typeof onDemandCacheEntry.data === \"object\" &&\n Object.keys(onDemandCacheEntry.data).length > 0;\n const effectiveMetaData = useMemo(\n () => ({\n ...metaData,\n citations: isOnDemandCitationEnabled\n ? (hasOnDemandCitationData ? onDemandCacheEntry?.data : {})\n : metaData?.citations,\n }),\n [\n hasOnDemandCitationData,\n isOnDemandCitationEnabled,\n metaData,\n onDemandCacheEntry?.data,\n ],\n );\n const shouldShowLoading =\n isOnDemandCitationEnabled &&\n (!onDemandCacheEntry || onDemandCacheEntry.status === \"loading\") &&\n !hasOnDemandCitationData;\n const shouldShowError =\n isOnDemandCitationEnabled &&\n onDemandCacheEntry?.status === \"error\" &&\n !hasOnDemandCitationData;\n const shouldShowMissing =\n isOnDemandCitationEnabled &&\n onDemandCacheEntry?.status === \"success\" &&\n !hasOnDemandCitationData;\n const shouldRenderCitationContent =\n !isOnDemandCitationEnabled || hasOnDemandCitationData;\n\n const requestOnDemandCitation = useCallback(() => {\n if (\n !onDemandCitationConfig?.enabled ||\n !onDemandCitationContext ||\n !fetchOnDemandCitationContext\n ) {\n return;\n }\n\n if (\n onDemandCacheEntry?.status === \"loading\" ||\n (onDemandCacheEntry?.status === \"success\" && hasOnDemandCitationData)\n ) {\n return;\n }\n\n fetchOnDemandCitationContext(onDemandCitationContext).catch((error) => {\n if (onDemandCitationConfig.debug) {\n console.error(\"[CognitiveCompare:onDemandCitations] citation fetch failed\", error);\n }\n });\n }, [\n fetchOnDemandCitationContext,\n hasOnDemandCitationData,\n onDemandCacheEntry?.status,\n onDemandCitationConfig,\n onDemandCitationContext,\n ]);\n\n const toggleCitation = () => {\n setIsExpanded((prev) => {\n const next = !prev;\n if (next) {\n requestOnDemandCitation();\n }\n return next;\n });\n };\n const chevronUpComponentResolved =\n chevronUpComponent ??\n ChevronUpComponentDefault(customStyle?.arrow ?? {});\n const chevronDownComponentResolved =\n chevronDownComponent ??\n ChevronDownComponentDefault(customStyle?.arrow ?? {});\n\n const handleFullscreen = () => {\n setIsFullscreen((prev) => !prev);\n };\n\n const renderRetryButton = (style?: React.CSSProperties) => (\n <button\n type=\"button\"\n onClick={(event) => {\n event.stopPropagation();\n requestOnDemandCitation();\n }}\n style={{ ...retryButtonStyle, ...style }}\n >\n Retry\n </button>\n );\n\n const citationPanel = (\n <div\n style={{\n boxSizing: \"border-box\",\n border: isFullscreen ? \"none\" : \"1px solid #E4E7EC\",\n borderRadius: isFullscreen ? 0 : \"8px\",\n overflow: \"hidden\",\n marginTop: isFullscreen ? 0 : \"8px\",\n display: \"flex\",\n flexDirection: \"column\",\n width: \"100%\",\n height: isFullscreen ? \"100%\" : undefined,\n backgroundColor: \"#FAFAFA\",\n }}\n >\n <div style={{\n display: \"flex\",\n justifyContent: \"flex-end\",\n padding: \"6px 10px\",\n borderBottom: \"1px solid #E4E7EC\",\n backgroundColor: \"#FFFFFF\",\n flexShrink: 0,\n }}>\n <button onClick={handleFullscreen}\n style={{ background: \"none\", border: \"none\", cursor: \"pointer\", padding: \"4px\", borderRadius: \"6px\", color: \"#475467\", marginRight: \"9px\" }}>\n {isFullscreen ? <DefaultFullScreenCloseIcon /> : <DefaultFullScreenIcon />}\n </button>\n </div>\n <div style={{ flex: 1, minHeight: 0, height: \"100%\", overflow: \"hidden\" }}>\n {shouldShowLoading && (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#475467\" }}>\n Loading citation details...\n </div>\n )}\n {shouldShowError && (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#B42318\", display: \"flex\", alignItems: \"center\", gap: \"8px\", flexWrap: \"wrap\" }}>\n <span>\n Unable to load citation details. Please try again later.\n </span>\n {renderRetryButton({\n border: \"1px solid #FDA29B\",\n color: \"#B42318\",\n })}\n </div>\n )}\n {shouldShowMissing && (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#475467\", display: \"flex\", alignItems: \"center\", gap: \"8px\", flexWrap: \"wrap\" }}>\n <span>Citation details are not available for this source.</span>\n {renderRetryButton()}\n </div>\n )}\n {shouldRenderCitationContent && (\n <CitationRendererInner\n href={href}\n children={children}\n metaData={effectiveMetaData}\n citationTitle={citationTitle}\n citationType={citationType}\n citationReason={citationReason}\n isFullscreen={isFullscreen}\n />\n )}\n </div>\n </div>\n );\n\n return (\n <span\n style={{\n display: \"inline\",\n ...(customStyle.relativeWrapper || {}),\n }}\n >\n <div\n style={{\n display: \"inline\",\n marginTop: 0,\n ...(customStyle.citationButtonWrapper || {}),\n }}\n >\n <button\n type=\"button\"\n onClick={toggleCitation}\n style={{\n display: metaData?.webGpt ? \"inline\" : \"inline-flex\",\n alignItems: metaData?.webGpt ? undefined : \"center\",\n gap: metaData?.webGpt ? undefined : \"3px\",\n fontFamily: '\"Inter\", sans-serif',\n backgroundColor: \"transparent\",\n padding: 0,\n margin: 0,\n fontSize: \"13px\",\n borderRadius: 9999,\n cursor: \"pointer\",\n fontWeight: (metaData?.webGpt) ? 600 : 700,\n color: (metaData?.webGpt) ? \"#6D28D9\" : \"rgb(214, 51, 132)\",\n border: \"none\",\n textDecoration: \"none\",\n wordBreak: \"break-word\",\n whiteSpace: \"normal\",\n ...(customStyle.citationButton || {}),\n }}\n >\n {metaData?.webGpt && (\n <Globe\n size={customStyle.arrow?.fontSize ?? \"1em\"}\n color={customStyle.arrow?.color ?? \"#6D28D9\"}\n style={{\n display: \"inline-block\",\n width: \"1em\",\n height: \"1em\",\n marginRight: \"3px\",\n verticalAlign: \"-0.125em\",\n flexShrink: 0,\n }}\n />\n )}\n <span>{citationDisplayTitle}</span>\n\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n marginLeft: metaData?.webGpt ? \"3px\" : undefined,\n verticalAlign: metaData?.webGpt ? \"-0.125em\" : undefined,\n }}\n >\n {isExpanded\n ? chevronUpComponentResolved\n : chevronDownComponentResolved}\n </span>\n </button>\n </div>\n {isExpanded && (\n isFullscreen ? (\n <Dialog\n open={isFullscreen}\n onClose={() => {\n setIsFullscreen(false);\n onFullscreenChange?.(false);\n }}\n maxWidth={false}\n BackdropProps={{\n sx: {\n backgroundColor: \"rgba(0, 0, 0, 0.6)\",\n backdropFilter: \"blur(4px)\",\n },\n }}\n PaperProps={{\n sx: {\n backgroundColor: \"#FAFAFA\",\n borderRadius: \"16px\",\n height: CITATION_FULLSCREEN_DIALOG_HEIGHT,\n m: 0,\n maxHeight: CITATION_FULLSCREEN_DIALOG_HEIGHT,\n maxWidth: \"95vw\",\n overflow: \"hidden\",\n width: \"95vw\",\n },\n }}\n >\n {citationPanel}\n </Dialog>\n ) : (\n citationPanel\n )\n )}\n </span>\n );\n};\n\nexport default CitationAnchor;\n"],"names":["CITATION_FULLSCREEN_DIALOG_HEIGHT","retryButtonStyle","border","borderRadius","background","color","cursor","fontSize","fontWeight","padding","href","children","citationType","citationReason","metaData","chevronUpComponent","chevronDownComponent","customStyle","defaultState","onFullscreenChange","onDemandCitationContext","compareContext","useOptionalCompareContext","onDemandCitationConfig","getOnDemandCitationCacheEntry","fetchOnDemandCitationContext","onDemandCitationCacheVersion","isExpanded","setIsExpanded","useState","isFullscreen","setIsFullscreen","citationDisplayTitle","split","length","join","citationTitle","useEffect","onDemandCacheEntry","useMemo","isOnDemandCitationEnabled","enabled","hasOnDemandCitationData","status","data","Object","keys","effectiveMetaData","citations","shouldShowLoading","shouldShowError","shouldShowMissing","shouldRenderCitationContent","requestOnDemandCitation","useCallback","catch","error","debug","console","chevronUpComponentResolved","arrow","jsx","ChevronUp","size","chevronDownComponentResolved","ChevronDown","ChevronDownComponentDefault","renderRetryButton","style","type","onClick","event","stopPropagation","citationPanel","jsxs","boxSizing","overflow","marginTop","display","flexDirection","width","height","backgroundColor","justifyContent","borderBottom","flexShrink","prev","marginRight","DefaultFullScreenCloseIcon","DefaultFullScreenIcon","flex","minHeight","alignItems","gap","flexWrap","CitationRendererInner","relativeWrapper","citationButtonWrapper","next","webGpt","fontFamily","margin","textDecoration","wordBreak","whiteSpace","citationButton","Globe","verticalAlign","marginLeft","Dialog","open","onClose","maxWidth","BackdropProps","sx","backdropFilter","PaperProps","m","maxHeight"],"mappings":"ySA0CA,MAAMA,EAAoC,OAEpCC,EAAwC,CAC1CC,OAAQ,oBACRC,aAAc,MACdC,WAAY,UACZC,MAAO,UACPC,OAAQ,UACRC,SAAU,OACVC,WAAY,IACZC,QAAS,2BAGyC,EAClDC,OACAC,WACAC,eACAC,iBACAC,WACAC,qBAAqB,KACrBC,uBAAuB,KACvBC,cAAc,CAAC,EACfC,gBAAe,EACfC,qBACAC,8BAEA,MAAMC,EAAiBC,EAAAA,4BACjBC,EAAyBF,GAAgBE,uBACzCC,EAAgCH,GAAgBG,8BAChDC,EAA+BJ,GAAgBI,6BAC/CC,EAA+BL,GAAgBK,8BAC9CC,EAAYC,GAAiBC,WAASX,IACtCY,EAAcC,GAAmBF,YAAS,GAgB3CG,EACkB,iBAAbrB,GAAyBA,GAAUsB,MAAM,OAAOC,OAAS,EAC1DvB,EAASsB,MAAM,MAAME,KAAK,KAC1BxB,EACJyB,EAAoC,iBAAbzB,EAAwBA,EAAWA,EAAS,GAEzE0B,EAAAA,UAAU,KAGN,GAFAlB,IAAqBW,GAEhBA,EAEL,MAAO,KACHX,KAAq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6B,EAAAA,IAAC,OAAA,CACGO,MAAO,CACHU,QAAS,cACTc,WAAY,SACZgB,WAAY9F,GAAUqF,OAAS,WAAQ,EACvCQ,cAAe7F,GAAUqF,OAAS,gBAAa,GAGlDxF,WACKgD,EACAK,SAIjBrC,IACGG,EACI+B,EAAAA,IAACgD,EAAAA,OAAA,CACGC,KAAMhF,EACNiF,QAAS,KACLhF,GAAgB,GAChBZ,KAAqB,IAEzB6F,UAAU,EACVC,cAAe,CACXC,GAAI,CACAhC,gBAAiB,qBACjBiC,eAAgB,cAGxBC,WAAY,CACRF,GAAI,CACAhC,gBAAiB,UACjB/E,aAAc,OACd8E,OAAQjF,EACRqH,EAAG,EACHC,UAAWtH,EACXgH,SAAU,OACVpC,SAAU,SACVI,MAAO,SAIdrE,SAAA8D,IAGLA"}
|
|
1
|
+
{"version":3,"file":"CitationAnchor.js","sources":["../../../../src/features/CognitiveCompare/CitationAnchor.tsx"],"sourcesContent":["// import PdfViewer from \"@e-llm-studio/citation/PdfViewer\";\nimport DOMPurify from \"dompurify\";\nimport { ChevronDown, ChevronUp, ExternalLink, Globe, Maximize2, X } from \"lucide-react\";\nimport React, {\n CSSProperties,\n useState,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport ResizableSplitPane from \"./ResizableSplitPane\";\nimport PdfViewer from \"../PdfViewer/PdfViewer\";\nimport { DefaultFullScreenIcon, DefaultFullScreenCloseIcon } from \"../../assests/svg/PdfViewerIcons\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeRaw from \"rehype-raw\";\nimport { Box, Dialog } from '@mui/material';\nimport { SHARED_MARKDOWN_STYLES } from \"./CognitiveCompare\";\nimport { useCompareContext } from \"./CompareContext\";\nimport { processGuidelinesMarkdown } from \"./Guidelines/utils/processGuidelinesMarkdown\";\nimport GptWebCitation from \"../GptWebCitation/GptWebCitation\";\nimport { CitationType, GptWebCitationStatus, IWebCitationApiResponse } from \"../GptWebCitation/types\";\nimport { GptWebCitationConfig } from \"./CognitiveCompareTypes\";\n\ninterface CitationAnchorProps {\n href: string;\n children: any;\n citationType?: string;\n citationReason?: string;\n chevronUpComponent?: React.ReactNode;\n chevronDownComponent?: React.ReactNode;\n customStyle?: {\n citationButtonWrapper?: CSSProperties;\n arrow?: CSSProperties;\n citationButton?: CSSProperties;\n expandableContent?: CSSProperties;\n bookHeader?: CSSProperties;\n relative?: CSSProperties;\n pageColor?: CSSProperties;\n highlightedText?: CSSProperties;\n expandedWrapper?: CSSProperties;\n expandableContainer?: CSSProperties;\n bookBodyContent?: CSSProperties;\n customScrollbarClass?: CSSProperties;\n relativeWrapper?: CSSProperties;\n };\n defaultState?: boolean;\n metaData?: any;\n onFullscreenChange?: (isFullscreen: boolean) => void;\n}\ninterface CitationRendererInnerProps {\n href: string;\n children: any;\n metaData: any;\n citationTitle: string;\n citationType?: string;\n citationReason?: string;\n isFullscreen: boolean\n}\n\nconst getFirstGptCitation = (webGptMeta: any) =>\n (webGptMeta?.extraMetaData || webGptMeta)?.aiReasoningCitation?.gpt_citation?.[0] || null;\n\nconst DEFAULT_GPT_WEB_CITATION_CONFIG: GptWebCitationConfig = {\n endpoint: \"https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation\",\n userEmail: \"sai.siddhartha@techolution.com\",\n userId: \"672e32f7a0e8fe2e8e50bcba\",\n userName: \"TNV Sai Siddhartha\",\n};\n\nconst CITATION_FULLSCREEN_DIALOG_HEIGHT = \"90vh\";\nconst CITATION_FULLSCREEN_GPT_BODY_HEIGHT = `calc(${CITATION_FULLSCREEN_DIALOG_HEIGHT} - 120px)`;\n\nconst resolveGptWebCitationConfig = (\n gptWebCitationConfig?: GptWebCitationConfig,\n): GptWebCitationConfig => ({\n endpoint: gptWebCitationConfig?.endpoint || DEFAULT_GPT_WEB_CITATION_CONFIG.endpoint,\n userEmail: gptWebCitationConfig?.userEmail || DEFAULT_GPT_WEB_CITATION_CONFIG.userEmail,\n userId: gptWebCitationConfig?.userId || DEFAULT_GPT_WEB_CITATION_CONFIG.userId,\n userName: gptWebCitationConfig?.userName || DEFAULT_GPT_WEB_CITATION_CONFIG.userName,\n headers: gptWebCitationConfig?.headers,\n});\n\nconst createCitationUuid = () => {\n if (typeof globalThis.crypto?.randomUUID === \"function\") {\n return globalThis.crypto.randomUUID();\n }\n\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (char) => {\n const random = Math.floor(Math.random() * 16);\n const value = char === \"x\" ? random : (random % 4) + 8;\n return value.toString(16);\n });\n};\n\nconst getStoredPayloadCitationId = (webGptMeta: any) =>\n webGptMeta?.payloadCitationId ||\n webGptMeta?.extraMetaData?.payloadCitationId ||\n \"\";\n\nconst attachPayloadCitationId = (webGptMeta: any, payloadCitationId: string) => {\n if (!webGptMeta || typeof webGptMeta !== \"object\") return;\n\n webGptMeta.payloadCitationId = payloadCitationId;\n\n if (webGptMeta.extraMetaData && typeof webGptMeta.extraMetaData === \"object\") {\n webGptMeta.extraMetaData.payloadCitationId = payloadCitationId;\n }\n};\n\nconst getOrCreatePayloadCitationId = (webGptMeta: any, generatedCitationId?: string) => {\n const payloadCitationId =\n getStoredPayloadCitationId(webGptMeta) ||\n generatedCitationId ||\n createCitationUuid();\n\n attachPayloadCitationId(webGptMeta, payloadCitationId);\n return payloadCitationId;\n};\n\nconst buildGptWebCitationPayload = (\n webGptMeta: any,\n gptWebCitationConfig?: GptWebCitationConfig,\n generatedCitationId?: string,\n) => {\n const gptCitation = getFirstGptCitation(webGptMeta);\n const customMetaData = gptCitation?.customMetaData || {};\n const citationValue = customMetaData?.value || {};\n const webSearchAnswer = webGptMeta?.webSearchAnswer || {};\n const extraMetaData = webGptMeta?.extraMetaData || webGptMeta || {};\n\n return {\n userEmail:\n webGptMeta?.userEmail ||\n webSearchAnswer?.userEmail ||\n gptWebCitationConfig?.userEmail ||\n \"\",\n userId:\n webGptMeta?.userId ||\n webSearchAnswer?.userId ||\n gptWebCitationConfig?.userId ||\n \"\",\n userName:\n webGptMeta?.userName ||\n webSearchAnswer?.userName ||\n gptWebCitationConfig?.userName ||\n \"\",\n citationId:\n getOrCreatePayloadCitationId(webGptMeta, generatedCitationId),\n citationUrl: citationValue?.citationUrl || webSearchAnswer?.citationUrl || \"\",\n content: extraMetaData?.Reasoning || webSearchAnswer?.enhanced_content || \"\",\n citationType: citationValue?.citationType || \"web\",\n citatioNumber:\n customMetaData?.citation_number ??\n gptCitation?.citation_number ??\n Number(webGptMeta?.reasoningId || 0),\n };\n};\n\nconst GptWebCitationPanel = ({\n metaData,\n isFullscreen = false,\n}: {\n metaData: any;\n isFullscreen?: boolean;\n}) => {\n const { gptWebCitationConfig } = useCompareContext();\n const resolvedGptWebCitationConfig = useMemo(\n () => resolveGptWebCitationConfig(gptWebCitationConfig),\n [gptWebCitationConfig],\n );\n const webGptMeta = metaData?.webGpt;\n const generatedCitationIdRef = useRef<string | null>(null);\n if (!generatedCitationIdRef.current) {\n generatedCitationIdRef.current = createCitationUuid();\n }\n\n const payload = useMemo(\n () => buildGptWebCitationPayload(\n webGptMeta,\n resolvedGptWebCitationConfig,\n generatedCitationIdRef.current || undefined,\n ),\n [webGptMeta, resolvedGptWebCitationConfig],\n );\n const firstGptCitation = useMemo(() => getFirstGptCitation(webGptMeta), [webGptMeta]);\n const citationValue = firstGptCitation?.customMetaData?.value || {};\n const extraMetaData = webGptMeta?.extraMetaData || webGptMeta || {};\n const [webCitationData, setWebCitationData] = useState<IWebCitationApiResponse | undefined>();\n const [webCitationStatus, setWebCitationStatus] = useState<GptWebCitationStatus>(\"pending\");\n const [showWebCitation, setShowWebCitation] = useState(true);\n\n useEffect(() => {\n let isMounted = true;\n\n const fetchGptWebCitation = async () => {\n if (!resolvedGptWebCitationConfig.endpoint || !payload?.citationUrl || !payload?.content) {\n setWebCitationStatus(\"error\");\n return;\n }\n\n setWebCitationStatus(\"pending\");\n\n try {\n const response = await fetch(resolvedGptWebCitationConfig.endpoint, {\n method: \"POST\",\n headers: {\n \"actor-id\": payload.userEmail,\n \"Accept\": \"application/json, text/plain, */*\",\n \"Content-Type\": \"application/json\",\n ...(resolvedGptWebCitationConfig.headers || {}),\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to fetch GPT web citation (${response.status})`);\n }\n\n const rawData = await response.json();\n const data =\n rawData?.responseData ||\n rawData?.result ||\n rawData?.data ||\n rawData;\n if (!isMounted) return;\n\n setWebCitationData(data);\n setWebCitationStatus(\"success\");\n } catch (error) {\n if (!isMounted) return;\n console.error(\"Failed to load GPT web citation\", error);\n setWebCitationStatus(\"error\");\n }\n };\n\n fetchGptWebCitation();\n\n return () => {\n isMounted = false;\n };\n }, [payload, resolvedGptWebCitationConfig]);\n\n const gptCitation = useMemo(\n () => ({\n item: {\n confidence_score: Number(extraMetaData?.Confidence_score || 0),\n text: citationValue?.paraphrase || \"Web citation reasoning\",\n dataSource: citationValue?.text || extraMetaData?.Reasoning || \"\",\n paraphrase: citationValue?.paraphrase || \"\",\n },\n headerTitle: \"GPT Web Citation\",\n index: Number(payload?.citatioNumber || 1) - 1,\n iconsConfig: {\n ChevronDownIcon: ChevronDown,\n ChevronUpIcon: ChevronUp,\n MaximizeIcon: Maximize2,\n CloseIcon: X,\n },\n }),\n [citationValue, payload?.citatioNumber, extraMetaData],\n );\n\n const resolvedGptCitation = useMemo(\n () => ({\n ...gptCitation,\n ...(isFullscreen ? { bodyHeight: CITATION_FULLSCREEN_GPT_BODY_HEIGHT } : {}),\n }),\n [gptCitation, isFullscreen],\n );\n\n return (\n <GptWebCitation\n gptCitation={resolvedGptCitation}\n defaultCitationUrl={payload?.citationUrl || \"\"}\n citationType={CitationType.GPT_WEB}\n webCitationData={webCitationData}\n webCitationStatus={webCitationStatus}\n showWebCitation={showWebCitation}\n onToggleCitationView={() => setShowWebCitation((current) => !current)}\n iconsConfig={{\n MaximizeIcon: Maximize2,\n ExternalLinkIcon: ExternalLink,\n }}\n isFixedHeight\n />\n );\n};\n\nconst CitationRendererInner: React.FC<CitationRendererInnerProps> = ({\n href,\n metaData,\n citationTitle,\n citationType,\n citationReason,\n isFullscreen\n}) => {\n const { guidelinesData } = useCompareContext();\n const pdfCitationTypes = [\"contract\", \"clause\"];\n\n const getCitationUrl = (url: string) => {\n const prefixedCitationMatch = url.match(/^(?:pdf_citation|deviation_summary)\\$(\\d+)/);\n if (prefixedCitationMatch) {\n try {\n const queryStartIndex = url.indexOf(\"?\");\n const search = queryStartIndex >= 0 ? url.slice(queryStartIndex) : \"\";\n return {\n citationNumber: prefixedCitationMatch[1],\n parsedUrl: new URL(search || \"./\", window.location.origin),\n };\n } catch {\n return {\n citationNumber: prefixedCitationMatch[1],\n parsedUrl: null,\n };\n }\n }\n\n try {\n const parsedUrl = new URL(url, window.location.origin);\n const citationNumber =\n parsedUrl.searchParams.get(\"citationNumber\") ||\n parsedUrl.searchParams.get(\"citation_number\");\n return {citationNumber, parsedUrl};\n } catch {\n return {citationNumber: null, parsedUrl: null};\n }\n };\n\n const getCitationDetailsFromHref = (url: string): { citationNumber: string | null; phraseToHighlight: string | null; citationTypeFromHref: string | null } => {\n try {\n const { citationNumber, parsedUrl } = getCitationUrl(url);\n const phraseToHighlight = parsedUrl?.searchParams.get(\"phrase_to_highlight\") || null;\n const citationTypeFromHref = parsedUrl?.searchParams.get(\"citation_type\") || null;\n return {citationNumber, phraseToHighlight, citationTypeFromHref};\n } catch {\n return {citationNumber: null, phraseToHighlight: null, citationTypeFromHref: null};\n }\n };\n\n const {citationNumber, phraseToHighlight, citationTypeFromHref} = getCitationDetailsFromHref(href);\n const resolvedCitationType = citationType || citationTypeFromHref || undefined;\n const normalizedCitationType =\n resolvedCitationType === \"il_rulebook_citation\" ? \"rulebook_citation\" : resolvedCitationType;\n const citationGroup = citationNumber ? (metaData?.citations?.[citationNumber] || {}) : {};\n const documents = metaData?.docData?.documents || {};\n const inputIndexMap = metaData?.docData?.input_index_map || {};\n const hasRegularCitationData =\n Object.keys(metaData?.citations || {}).length > 0 ||\n Object.keys(metaData?.docData || {}).length > 0;\n\n const leftUuid = inputIndexMap?.[\"0\"];\n const rightUuid = inputIndexMap?.[\"1\"];\n\n const leftDocument = leftUuid ? documents[leftUuid] : null;\n const rightDocument = rightUuid ? documents[rightUuid] : null;\n const leftCitation = leftUuid ? citationGroup[leftUuid] : null;\n const rightCitation = rightUuid ? citationGroup[rightUuid] : null;\n\n const leftComponent = useMemo(() => {\n if (!leftCitation || !leftDocument) return null;\n return (\n <PdfViewer\n defaultScale={'PageWidth'}\n showFullScreenAction={false}\n showHighlightsAction={false}\n pdfName={leftDocument?.title}\n pdfUrl={leftDocument?.signed_url}\n highlightText={[leftCitation?.highlighted_text ?? '']}\n highlightPages={{ 1: leftCitation?.custom_metadata?.pdf_start_page_number }}\n jumpToPageValue={1}\n highlightCordinatePages={[]}\n useCoordinates={false}\n useRange={true}\n rangeOfPages={[leftCitation?.custom_metadata?.pdf_start_page_number, leftCitation?.custom_metadata?.pdf_end_page_number]}\n />\n );\n }, [\n leftDocument?.title,\n leftDocument?.signed_url,\n leftCitation?.highlighted_text,\n leftCitation?.custom_metadata?.pdf_start_page_number,\n leftCitation?.custom_metadata?.pdf_end_page_number\n ]);\n\n const rightComponent = useMemo(() => {\n if (!rightCitation || !rightDocument) return null;\n return (\n <PdfViewer\n defaultScale={'PageWidth'}\n showFullScreenAction={false}\n showHighlightsAction={false}\n pdfName={rightDocument?.title}\n pdfUrl={rightDocument?.signed_url}\n jumpToPageValue={1}\n highlightText={[rightCitation?.highlighted_text ?? '']}\n highlightPages={{ 1: rightCitation?.custom_metadata?.pdf_start_page_number }}\n highlightCordinatePages={[]}\n useCoordinates={false}\n useRange={true}\n rangeOfPages={[rightCitation?.custom_metadata?.pdf_start_page_number, rightCitation?.custom_metadata?.pdf_end_page_number]}\n />\n );\n }, [\n rightDocument?.title,\n rightDocument?.signed_url,\n rightCitation?.highlighted_text,\n rightCitation?.custom_metadata?.pdf_start_page_number,\n rightCitation?.custom_metadata?.pdf_end_page_number\n ]);\n\n const isDualCitationType = normalizedCitationType === \"dual_citation\";\n const isDualWebGptCitation = isDualCitationType && !!metaData?.webGpt;\n\n const splitPaneComponent = useMemo(() => {\n if (!leftComponent) return null;\n\n const rightPane =\n isDualWebGptCitation ? (\n <GptWebCitationPanel metaData={metaData} isFullscreen={isFullscreen} />\n ) : normalizedCitationType === \"rulebook_citation\" ? (\n <>\n <Box sx={{\n padding: '0px 20px',\n backgroundColor: '#FFFFFF',\n borderRadius: '8px',\n ...SHARED_MARKDOWN_STYLES,\n overflow: 'auto'\n }}>\n <ReactMarkdown rehypePlugins={[rehypeRaw as any]}>\n {processGuidelinesMarkdown({\n guidelinesData, targetHighlights: [phraseToHighlight!], labelColor: \"#FEF08A\"})}\n </ReactMarkdown>\n </Box>\n </>\n ) : (\n rightComponent\n );\n\n if (!rightPane) return leftComponent;\n\n return (\n <ResizableSplitPane\n leftComponent={leftComponent}\n rightComponent={rightPane}\n isFullscreen={isFullscreen}\n />\n );\n}, [leftComponent, rightComponent, normalizedCitationType, isDualWebGptCitation, metaData, isFullscreen, guidelinesData, phraseToHighlight]);\n\n if (metaData?.webGpt && !hasRegularCitationData) {\n return <GptWebCitationPanel metaData={metaData} isFullscreen={isFullscreen} />;\n }\n\n if (!citationNumber) return null;\n\n if (normalizedCitationType === \"rulebook_citation\") {\n if (leftCitation) {\n return (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\" }}>\n {splitPaneComponent}\n </div>\n );\n }\n\n return (\n <div style={{ padding: \"12px\", fontSize: \"13px\", color: \"#344054\", lineHeight: 1.5 }}>\n {citationReason || \"Rulebook citation selected.\"}\n </div>\n );\n }\n\n if (isDualCitationType) {\n if (leftCitation || rightCitation) {\n return (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\" }}>\n {splitPaneComponent}\n </div>\n );\n }\n\n if (metaData?.webGpt) {\n return <GptWebCitationPanel metaData={metaData} isFullscreen={isFullscreen} />;\n }\n\n return <div>Missing PDF Citation. Please try again later</div>;\n }\n\n if (pdfCitationTypes.includes(citationTitle)) {\n if (leftCitation || rightCitation) {\n return (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\" }}>\n {splitPaneComponent}\n </div>\n );\n }\n\n return <div>Missing PDF Citation. Please try again later</div>;\n }\n\n return <div>No Citation Found. Please try again later</div>;\n};\n\n\nconst CitationAnchor: React.FC<CitationAnchorProps> = ({\n href,\n children,\n citationType,\n citationReason,\n metaData,\n chevronUpComponent = null,\n chevronDownComponent = null,\n customStyle = {},\n defaultState = false,\n onFullscreenChange,\n}) => {\n const ChevronUpComponentDefault = (arrow: CSSProperties) => {\n return (\n <ChevronUp\n size={arrow?.fontSize ?? 16}\n color={arrow?.color ?? \"rgb(214, 51, 132)\"}\n />\n );\n };\n\n const ChevronDownComponentDefault = (arrow: CSSProperties) => {\n return (\n <ChevronDown\n size={arrow?.fontSize ?? 16}\n color={arrow?.color ?? \"rgb(214, 51, 132)\"}\n />\n );\n };\n const [isExpanded, setIsExpanded] = useState(defaultState);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const citationDisplayTitle =\n typeof children === \"string\" && children?.split(\"\\n\")?.length > 1\n ? children.split(\"\\n\").join(\" \")\n : children;\n\n useEffect(() => {\n onFullscreenChange?.(isFullscreen);\n\n if (!isFullscreen) return;\n\n return () => {\n onFullscreenChange?.(false);\n };\n }, [isFullscreen, onFullscreenChange]);\n \n const citationTitle = typeof children === \"string\" ? children : children[0]\n\n const toggleCitation = () => setIsExpanded((prev) => !prev);\n const chevronUpComponentResolved =\n chevronUpComponent ??\n ChevronUpComponentDefault(customStyle?.arrow ?? {});\n const chevronDownComponentResolved =\n chevronDownComponent ??\n ChevronDownComponentDefault(customStyle?.arrow ?? {});\n\n const pdfCitationTypes = [\"contract\", \"clause\"];\n \nconst handleFullscreen = () => {\n setIsFullscreen((prev) => !prev);\n};\n // const jumpToPageRef = useRef<number>(item.pdf_highlight_details.pdf_page_number);\n // const highlightPagesIndexArray = {1: citationMetaData.pdf_highlight_details.pdf_page_number}\n // // const highlightTextArray = citationMetaData.pdf_highlight_details.pdf_highlight_text?.split('\\n')\n // const highlightTextArray = (() => {\n // const text = [citationMetaData.pdf_highlight_details.pdf_highlight_text ?? ''];\n // // console.log('textchecking old', text, processPdfHighlightText_Old(text[0]))\n // // console.log('textchecking new', text, processPdfHighlightText(\"payment in full for undisputed invoices shall be due within\\n**fourty-five (45) days** from invoice date unless stated otherwise in the respective SOW\"))\n // return text\n // })();\n\n const citationPanel = (\n <div\n style={{\n boxSizing: \"border-box\",\n border: isFullscreen ? \"none\" : \"1px solid #E4E7EC\",\n borderRadius: isFullscreen ? 0 : \"8px\",\n overflow: \"hidden\",\n marginTop: isFullscreen ? 0 : \"8px\",\n display: \"flex\",\n flexDirection: \"column\",\n width: \"100%\",\n height: isFullscreen ? \"100%\" : undefined,\n backgroundColor: \"#FAFAFA\",\n }}\n >\n <div style={{\n display: \"flex\",\n justifyContent: \"flex-end\",\n padding: \"6px 10px\",\n borderBottom: \"1px solid #E4E7EC\",\n backgroundColor: \"#FFFFFF\",\n flexShrink: 0,\n }}>\n <button onClick={handleFullscreen}\n style={{ background: \"none\", border: \"none\", cursor: \"pointer\", padding: \"4px\", borderRadius: \"6px\", color: \"#475467\", marginRight: \"9px\" }}>\n {isFullscreen ? <DefaultFullScreenCloseIcon /> : <DefaultFullScreenIcon />}\n </button>\n </div>\n <div style={{ flex: 1, minHeight: 0, height: \"100%\", overflow: \"hidden\" }}>\n <CitationRendererInner\n href={href}\n children={children}\n metaData={metaData}\n citationTitle={citationTitle}\n citationType={citationType}\n citationReason={citationReason}\n isFullscreen={isFullscreen}\n />\n </div>\n </div>\n );\n\n return (\n <span\n style={{\n display: \"inline\",\n ...(customStyle.relativeWrapper || {}),\n }}\n >\n <div\n style={{\n display: \"inline\",\n marginTop: 0,\n ...(customStyle.citationButtonWrapper || {}),\n }}\n >\n <button\n type=\"button\"\n onClick={toggleCitation}\n style={{\n display: metaData?.webGpt ? \"inline\" : \"inline-flex\",\n alignItems: metaData?.webGpt ? undefined : \"center\",\n gap: metaData?.webGpt ? undefined : \"3px\",\n fontFamily: '\"Inter\", sans-serif',\n backgroundColor: \"transparent\",\n padding: 0,\n margin: 0,\n fontSize: \"13px\",\n borderRadius: 9999,\n cursor: \"pointer\",\n fontWeight: (metaData?.webGpt) ? 600 : 700,\n color: (metaData?.webGpt) ? \"#6D28D9\" : \"rgb(214, 51, 132)\",\n border: \"none\",\n textDecoration: \"none\",\n wordBreak: \"break-word\",\n whiteSpace: \"normal\",\n ...(customStyle.citationButton || {}),\n }}\n >\n {metaData?.webGpt && (\n <Globe\n size={customStyle.arrow?.fontSize ?? \"1em\"}\n color={customStyle.arrow?.color ?? \"#6D28D9\"}\n style={{\n display: \"inline-block\",\n width: \"1em\",\n height: \"1em\",\n marginRight: \"3px\",\n verticalAlign: \"-0.125em\",\n flexShrink: 0,\n }}\n />\n )}\n <span>{citationDisplayTitle}</span>\n\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n marginLeft: metaData?.webGpt ? \"3px\" : undefined,\n verticalAlign: metaData?.webGpt ? \"-0.125em\" : undefined,\n }}\n >\n {isExpanded\n ? chevronUpComponentResolved\n : chevronDownComponentResolved}\n </span>\n {/* <span>\n <ChevronDownComponentDefault />\n </span> */}\n </button>\n </div>\n {isExpanded && (\n isFullscreen ? (\n <Dialog\n open={isFullscreen}\n onClose={() => setIsFullscreen(false)}\n maxWidth={false}\n BackdropProps={{\n sx: {\n backgroundColor: \"rgba(0, 0, 0, 0.6)\",\n backdropFilter: \"blur(4px)\",\n },\n }}\n PaperProps={{\n sx: {\n backgroundColor: \"#FAFAFA\",\n borderRadius: \"16px\",\n height: CITATION_FULLSCREEN_DIALOG_HEIGHT,\n m: 0,\n maxHeight: CITATION_FULLSCREEN_DIALOG_HEIGHT,\n maxWidth: \"95vw\",\n overflow: \"hidden\",\n width: \"95vw\",\n },\n }}\n >\n {citationPanel}\n </Dialog>\n ) : (\n citationPanel\n )\n )}\n </span>\n );\n};\n\nexport default CitationAnchor;\n"],"names":["getFirstGptCitation","webGptMeta","extraMetaData","aiReasoningCitation","gpt_citation","DEFAULT_GPT_WEB_CITATION_CONFIG","CITATION_FULLSCREEN_DIALOG_HEIGHT","CITATION_FULLSCREEN_GPT_BODY_HEIGHT","createCitationUuid","globalThis","crypto","randomUUID","replace","char","random","Math","floor","toString","getOrCreatePayloadCitationId","generatedCitationId","payloadCitationId","getStoredPayloadCitationId","attachPayloadCitationId","GptWebCitationPanel","metaData","isFullscreen","gptWebCitationConfig","useCompareContext","resolvedGptWebCitationConfig","useMemo","endpoint","userEmail","userId","userName","headers","resolveGptWebCitationConfig","webGpt","generatedCitationIdRef","useRef","current","payload","gptCitation","customMetaData","citationValue","value","webSearchAnswer","citationId","citationUrl","content","Reasoning","enhanced_content","citationType","citatioNumber","citation_number","Number","reasoningId","buildGptWebCitationPayload","firstGptCitation","webCitationData","setWebCitationData","useState","webCitationStatus","setWebCitationStatus","showWebCitation","setShowWebCitation","useEffect","isMounted","async","response","fetch","method","Accept","body","JSON","stringify","ok","Error","status","rawData","json","responseData","result","data","error","console","fetchGptWebCitation","item","confidence_score","Confidence_score","text","paraphrase","dataSource","headerTitle","index","iconsConfig","ChevronDownIcon","ChevronDown","ChevronUpIcon","ChevronUp","MaximizeIcon","Maximize2","CloseIcon","X","resolvedGptCitation","bodyHeight","jsx","GptWebCitation","defaultCitationUrl","CitationType","GPT_WEB","onToggleCitationView","ExternalLinkIcon","ExternalLink","isFixedHeight","CitationRendererInner","href","citationTitle","citationReason","guidelinesData","citationNumber","phraseToHighlight","citationTypeFromHref","url","parsedUrl","prefixedCitationMatch","match","queryStartIndex","indexOf","search","slice","URL","window","location","origin","searchParams","get","getCitationUrl","getCitationDetailsFromHref","resolvedCitationType","normalizedCitationType","citationGroup","citations","documents","docData","inputIndexMap","input_index_map","hasRegularCitationData","Object","keys","length","leftUuid","rightUuid","leftDocument","rightDocument","leftCitation","rightCitation","leftComponent","PdfViewer","defaultScale","showFullScreenAction","showHighlightsAction","pdfName","title","pdfUrl","signed_url","highlightText","highlighted_text","highlightPages","custom_metadata","pdf_start_page_number","jumpToPageValue","highlightCordinatePages","useCoordinates","useRange","rangeOfPages","pdf_end_page_number","rightComponent","isDualCitationType","isDualWebGptCitation","splitPaneComponent","rightPane","Fragment","children","Box","sx","padding","backgroundColor","borderRadius","SHARED_MARKDOWN_STYLES","overflow","ReactMarkdown","rehypePlugins","rehypeRaw","processGuidelinesMarkdown","targetHighlights","labelColor","ResizableSplitPane","style","height","display","flexDirection","fontSize","color","lineHeight","includes","chevronUpComponent","chevronDownComponent","customStyle","defaultState","onFullscreenChange","isExpanded","setIsExpanded","setIsFullscreen","citationDisplayTitle","split","join","chevronUpComponentResolved","arrow","size","chevronDownComponentResolved","ChevronDownComponentDefault","citationPanel","jsxs","boxSizing","border","marginTop","width","justifyContent","borderBottom","flexShrink","onClick","prev","background","cursor","marginRight","DefaultFullScreenCloseIcon","DefaultFullScreenIcon","flex","minHeight","relativeWrapper","citationButtonWrapper","type","alignItems","gap","fontFamily","margin","fontWeight","textDecoration","wordBreak","whiteSpace","citationButton","Globe","verticalAlign","marginLeft","Dialog","open","onClose","maxWidth","BackdropProps","backdropFilter","PaperProps","m","maxHeight"],"mappings":"ozBA2DA,MAAMA,EAAuBC,IACxBA,GAAYC,eAAiBD,IAAaE,qBAAqBC,eAAe,IAAM,KAEnFC,EACQ,sFADRA,EAES,iCAFTA,EAGM,2BAHNA,EAIQ,qBAGRC,EAAoC,OACpCC,EAAsC,QAAQD,aAY9CE,EAAqB,IACsB,mBAAlCC,WAAWC,QAAQC,WACnBF,WAAWC,OAAOC,aAGtB,uCAAuCC,QAAQ,QAAUC,IAC5D,MAAMC,EAASC,KAAKC,MAAsB,GAAhBD,KAAKD,UAExB,OADgB,MAATD,EAAeC,EAAUA,EAAS,EAAK,GACxCG,SAAS,MAmBxBC,EAA+B,CAACjB,EAAiBkB,KACnD,MAAMC,EAhByB,C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ACjByE,eAAgB,cAGxBC,WAAY,CACR5E,GAAI,CACAE,gBAAiB,UACjBC,aAAc,OACdW,OAAQhM,EACR+P,EAAG,EACHC,UAAWhQ,EACX2P,SAAU,OACVpE,SAAU,SACVqC,MAAO,SAId5C,SAAAuC,IAGLA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material"),n=require("react-markdown"),o=require("rehype-raw"),i=require("./CitationAnchor.js"),a=require("./Guidelines/utils/helper.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(n),l=s(o);const u=e=>e?`./dual-citation?citationNumber=${encodeURIComponent(e)}`:"";exports.default=function({content:n="",title:o="",citations:s={},styles:d={},docData:x={},deviationData:p=null,open:h,onCitationFullscreenChange:m}){const f=t.useMemo(()=>JSON.stringify(s||{}),[s]),y=t.useMemo(()=>s,[f]),g=t.useMemo(()=>JSON.stringify(x||{}),[x]),j=t.useMemo(()=>x,[g]),b=t.useMemo(()=>({citations:y,docData:j}),[y,j]),M=t.useMemo(()=>{const e=p?.web_search_answer,t=e?.extraMetaData||{};return Object.keys(t).reduce((e,t)=>{const r=((e,t)=>{if(!e||!t)return null;const r=e?.web_search_answer,n=r?.extraMetaData?.[t];return r&&n?{reasoningId:t,evaluation:e,webSearchAnswer:r,extraMetaData:n}:null})(p,t);return r&&(e[t]=r),e},{})},[p]),D=t.useMemo(()=>a.mergeRulebookCitationsIntoMatchingLinks(n),[n]),w=t.useMemo(()=>({a:({href:t="",children:r,type:n,reason:o,...a})=>{const s=a?.["data-cognitive-reasoning"],c=(l=a?.["dual-citation"],!0===l||"true"===l);var l;const d=c&&s?M[String(s)]:null;return e.jsx(i.default,{href:c?u(String(s||"")):t,children:r,citationType:c?"dual_citation":n,citationReason:o,metaData:{...b,...d?{webGpt:d}:{}},customStyle:d?{arrow:{color:"#6D28D9"}}:{},onFullscreenChange:m})}}),[b,M,m]);return e.jsxs(r.Box,{sx:{borderRadius:"8px",border:"1px solid #E4E7EC",bgcolor:"#FCFCFD"},children:[e.jsx(r.Box,{sx:{px:1.5,py:.75,borderBottom:"1px solid #EAECF0"},children:e.jsx(r.Typography,{sx:{fontSize:"15px",fontWeight:600,color:"#344054",lineHeight:1.25},children:o})}),e.jsx(r.Box,{sx:{px:1.5,py:1.1,display:"flex",flexDirection:"column",gap:.95},children:e.jsx(r.Box,{sx:{display:"flex",flexDirection:"column"},children:e.jsx(r.Typography,{component:"div",sx:{...d},children:e.jsx(c.default,{components:w,rehypePlugins:[l.default],children:D})})})})]})};
|
|
2
2
|
//# sourceMappingURL=CitationRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CitationRenderer.js","sources":["../../../../src/features/CognitiveCompare/CitationRenderer.tsx"],"sourcesContent":["import React, { useMemo } from 'react'\nimport { Box, Typography, IconButton } from \"@mui/material\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeRaw from \"rehype-raw\";\nimport CitationAnchor from './CitationAnchor';\nimport { mergeRulebookCitationsIntoMatchingLinks } from './Guidelines/utils/helper';\nimport { useOptionalCompareContext } from './CompareContext';\nimport {\n buildOnDemandCitationContexts,\n getOnDemandCitationLinkKey,\n} from './onDemandCitations';\n\ntype Props = {\n title?: string,\n content?: string,\n citations?: Record<string, any>,\n styles?: Record<string, any>\n docData?: Record<string, any> | null,\n deviationData?: Record<string, any> | null,\n open: boolean,\n onCitationFullscreenChange?: (isFullscreen: boolean) => void,\n tabKey?: \"deviation\" | \"association\",\n sectionTitle?: string,\n referenceSectionTitle?: string,\n sourceNodeId?: string,\n deviationKey?: string,\n baseContentId?: string,\n compareContentIds?: string[],\n}\n\nconst parseHref = (href: string) => {\n try {\n const baseUrl = typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\";\n return new URL(href, baseUrl);\n } catch {\n return null;\n }\n};\n\nconst isDualCitation = (value: unknown) => value === true || value === \"true\";\n\nconst buildDualCitationHref = (reasoningId: string) =>\n reasoningId ? `./dual-citation?citationNumber=${encodeURIComponent(reasoningId)}` : \"\";\n\nconst buildWebGptMetaForReasoning = (\n deviationData: Record<string, any> | null | undefined,\n reasoningId: string,\n) => {\n if (!deviationData || !reasoningId) return null;\n\n const webSearchAnswer = deviationData?.web_search_answer;\n const extraMetaData = webSearchAnswer?.extraMetaData?.[reasoningId];\n if (!webSearchAnswer || !extraMetaData) return null;\n\n return {\n reasoningId,\n evaluation: deviationData,\n webSearchAnswer,\n extraMetaData,\n };\n};\n\nfunction CitationRenderer({\n content = \"\",\n title = \"\",\n citations = {},\n styles = {},\n docData = {} as Record<string, any>,\n deviationData = null,\n open,\n onCitationFullscreenChange,\n tabKey,\n sectionTitle,\n referenceSectionTitle,\n sourceNodeId,\n deviationKey,\n baseContentId,\n compareContentIds,\n}: Props) {\n const compareContext = useOptionalCompareContext();\n const treeData = compareContext?.treeData;\n const onDemandCitationConfig = compareContext?.onDemandCitationConfig;\n // Stabilize citations and docData — they arrive as new object references\n // on every stream tick even when content hasn't changed, which would\n // remount CitationAnchor and reset its expanded state.\n const stableCitationsStr = useMemo(() => JSON.stringify(citations || {}), [citations]);\n const stableCitations = useMemo(\n () => citations,\n [stableCitationsStr]\n );\n\n const stableDocDataStr = useMemo(() => JSON.stringify(docData || {}), [docData]);\n const stableDocData = useMemo(\n () => docData,\n [stableDocDataStr]\n );\n\n const stableMetaData = useMemo(\n () => ({ citations: stableCitations, docData: stableDocData }),\n [stableCitations, stableDocData]\n );\n\n const onDemandContextByLinkKey = useMemo(() => {\n if (!onDemandCitationConfig?.enabled) return new Map<string, any>();\n\n const contexts = buildOnDemandCitationContexts({\n treeData,\n content,\n requestId: onDemandCitationConfig.requestId,\n tabKey,\n popupNodeId: sourceNodeId || (deviationData as any)?.nodeId,\n deviationKey,\n sectionTitle,\n referenceSectionTitle,\n docData: stableDocData,\n staticCitations: stableCitations,\n deviationData,\n cognitiveData: null,\n baseContentId,\n compareContentIds,\n });\n\n return contexts.reduce((acc, context) => {\n acc.set(getOnDemandCitationLinkKey(context.href), context);\n return acc;\n }, new Map<string, any>());\n }, [\n baseContentId,\n compareContentIds,\n content,\n deviationData,\n deviationKey,\n onDemandCitationConfig,\n referenceSectionTitle,\n sectionTitle,\n sourceNodeId,\n stableCitations,\n stableDocData,\n tabKey,\n treeData,\n ]);\n\n const webGptMetaByReasoningId = useMemo(() => {\n const webSearchAnswer = deviationData?.web_search_answer;\n const extraMetaData = webSearchAnswer?.extraMetaData || {};\n\n return Object.keys(extraMetaData).reduce((acc: Record<string, any>, reasoningId) => {\n const matchedExtraMetaData = buildWebGptMetaForReasoning(deviationData, reasoningId);\n if (matchedExtraMetaData) acc[reasoningId] = matchedExtraMetaData;\n return acc;\n }, {});\n }, [deviationData]);\n\n const processedContent = useMemo(\n () => mergeRulebookCitationsIntoMatchingLinks(content),\n [content]\n );\n\n const components = useMemo(() => {\n return {\n a: ({ href = \"\", children, type, reason, ...props }: any) => {\n const reasoningId = props?.[\"data-cognitive-reasoning\"];\n const shouldUseDualCitation = isDualCitation(props?.[\"dual-citation\"]);\n const matchedExtraMetaData =\n shouldUseDualCitation && reasoningId\n ? webGptMetaByReasoningId[String(reasoningId)]\n : null;\n return (\n <CitationAnchor\n href={shouldUseDualCitation ? buildDualCitationHref(String(reasoningId || \"\")) : href}\n children={children}\n citationType={shouldUseDualCitation ? \"dual_citation\" : type}\n citationReason={reason}\n onDemandCitationContext={\n shouldUseDualCitation\n ? undefined\n : onDemandContextByLinkKey.get(getOnDemandCitationLinkKey(href))\n }\n metaData={{\n ...stableMetaData,\n ...(matchedExtraMetaData ? { webGpt: matchedExtraMetaData } : {}),\n }}\n customStyle={\n matchedExtraMetaData ? \n {\n arrow: {\n color: \"#6D28D9\"\n }\n } : {}\n }\n onFullscreenChange={onCitationFullscreenChange}\n />\n );\n },\n };\n }, [onDemandContextByLinkKey, stableMetaData, webGptMetaByReasoningId, onCitationFullscreenChange]);\n\n return (\n <Box\n sx={{\n borderRadius: \"8px\",\n border: \"1px solid #E4E7EC\",\n bgcolor: \"#FCFCFD\",\n }}\n >\n <Box\n sx={{ px: 1.5, py: 0.75, borderBottom: \"1px solid #EAECF0\" }}\n >\n <Typography\n sx={{\n fontSize: \"15px\",\n fontWeight: 600,\n color: \"#344054\",\n lineHeight: 1.25,\n }}\n >\n {title}\n </Typography>\n </Box>\n <Box\n sx={{\n px: 1.5,\n py: 1.1,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 0.95,\n }}\n >\n <Box sx={{ display: \"flex\", flexDirection: \"column\" }}>\n <Typography\n component=\"div\"\n sx={{ ...styles }}\n >\n <ReactMarkdown components={components} rehypePlugins={[rehypeRaw as any]}>\n {processedContent}\n </ReactMarkdown>\n </Typography>\n </Box>\n </Box>\n </Box>\n )\n}\n\nexport default CitationRenderer\n"],"names":["buildDualCitationHref","reasoningId","encodeURIComponent","content","title","citations","styles","docData","deviationData","open","onCitationFullscreenChange","tabKey","sectionTitle","referenceSectionTitle","sourceNodeId","deviationKey","baseContentId","compareContentIds","compareContext","useOptionalCompareContext","treeData","onDemandCitationConfig","stableCitationsStr","useMemo","JSON","stringify","stableCitations","stableDocDataStr","stableDocData","stableMetaData","onDemandContextByLinkKey","enabled","Map","buildOnDemandCitationContexts","requestId","popupNodeId","nodeId","staticCitations","cognitiveData","reduce","acc","context","set","getOnDemandCitationLinkKey","href","webGptMetaByReasoningId","webSearchAnswer","web_search_answer","extraMetaData","Object","keys","matchedExtraMetaData","evaluation","buildWebGptMetaForReasoning","processedContent","mergeRulebookCitationsIntoMatchingLinks","components","a","children","type","reason","props","shouldUseDualCitation","value","String","jsx","CitationAnchor","citationType","citationReason","onDemandCitationContext","get","metaData","webGpt","customStyle","arrow","color","onFullscreenChange","jsxs","Box","sx","borderRadius","border","bgcolor","px","py","borderBottom","Typography","fontSize","fontWeight","lineHeight","display","flexDirection","gap","component","ReactMarkdown","rehypePlugins","rehypeRaw"],"mappings":"2eAuCA,MAEMA,EAAyBC,GAC3BA,EAAc,kCAAkCC,mBAAmBD,KAAiB,mBAoBxF,UAA0BE,QACtBA,EAAU,GAAAC,MACVA,EAAQ,GAAAC,UACRA,EAAY,CAAC,EAAAC,OACbA,EAAS,CAAC,EAAAC,QACVA,EAAU,CAAC,EAAAC,cACXA,EAAgB,KAAAC,KAChBA,EAAAC,2BACAA,EAAAC,OACAA,EAAAC,aACAA,EAAAC,sBACAA,EAAAC,aACAA,EAAAC,aACAA,EAAAC,cACAA,EAAAC,kBACAA,IAEA,MAAMC,EAAiBC,EAAAA,4BACjBC,EAAWF,GAAgBE,SAC3BC,EAAyBH,GAAgBG,uBAIzCC,EAAqBC,UAAQ,IAAMC,KAAKC,UAAUpB,GAAa,IAAK,CAACA,IACrEqB,EAAkBH,EAAAA,QACpB,IAAMlB,EACN,CAACiB,IAGCK,EAAmBJ,UAAQ,IAAMC,KAAKC,UAAUlB,GAAW,IAAK,CAACA,IACjEqB,EAAgBL,EAAAA,QAClB,IAAMhB,EACN,CAACoB,IAGCE,EAAiBN,EAAAA,QACnB,KAAA,CAASlB,UAAWqB,EAAiBnB,QAASqB,IAC9C,CAACF,EAAiBE,IAGhBE,EAA2BP,EAAAA,QAAQ,KACrC,IAAKF,GAAwBU,QAAS,WAAWC,IAmBjD,OAjBiBC,EAAAA,8BAA8B,CAC3Cb,WACAjB,UACA+B,UAAWb,EAAuBa,UAClCvB,SACAwB,YAAarB,GAAiBN,GAAuB4B,OACrDrB,eACAH,eACAC,wBACAN,QAASqB,EACTS,gBAAiBX,EACjBlB,gBACA8B,cAAe,KACftB,gBACAC,sBAGYsB,OAAO,CAACC,EAAKC,KACzBD,EAAIE,IAAIC,EAAAA,2BAA2BF,EAAQG,MAAOH,GAC3CD,GACJ,IAAAR,MACR,CACChB,EACAC,EACAd,EACAK,EACAO,EACAM,EACAR,EACAD,EACAE,EACAY,EAC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mE,EAAAA,KAACC,EAAAA,IAAA,CACGC,GAAI,CACAC,aAAc,MACdC,OAAQ,oBACRC,QAAS,WAGbxB,SAAA,CAAAO,EAAAA,IAACa,EAAAA,IAAA,CACGC,GAAI,CAAEI,GAAI,IAAKC,GAAI,IAAMC,aAAc,qBAEvC3B,SAAAO,EAAAA,IAACqB,EAAAA,WAAA,CACGP,GAAI,CACAQ,SAAU,OACVC,WAAY,IACZb,MAAO,UACPc,WAAY,MAGf/B,SAAAtD,MAGT6D,EAAAA,IAACa,EAAAA,IAAA,CACGC,GAAI,CACAI,GAAI,IACJC,GAAI,IACJM,QAAS,OACTC,cAAe,SACfC,IAAK,KAGTlC,SAAAO,EAAAA,IAACa,OAAIC,GAAI,CAAEW,QAAS,OAAQC,cAAe,UACvCjC,SAAAO,EAAAA,IAACqB,EAAAA,WAAA,CACGO,UAAU,MACVd,GAAI,IAAKzE,GAEToD,eAACoC,EAAc,QAAA,CAAAtC,aAAwBuC,cAAe,CAACC,WAClDtC,SACLJ,YAMxB"}
|
|
1
|
+
{"version":3,"file":"CitationRenderer.js","sources":["../../../../src/features/CognitiveCompare/CitationRenderer.tsx"],"sourcesContent":["import React, { useMemo } from 'react'\nimport { Box, Typography, IconButton } from \"@mui/material\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeRaw from \"rehype-raw\";\nimport CitationAnchor from './CitationAnchor';\nimport { mergeRulebookCitationsIntoMatchingLinks } from './Guidelines/utils/helper';\n\ntype Props = {\n title?: string,\n content?: string,\n citations?: Record<string, any>,\n styles?: Record<string, any>\n docData?: Record<string, any> | null,\n deviationData?: Record<string, any> | null,\n open: boolean,\n onCitationFullscreenChange?: (isFullscreen: boolean) => void,\n}\n\nconst parseHref = (href: string) => {\n try {\n const baseUrl = typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\";\n return new URL(href, baseUrl);\n } catch {\n return null;\n }\n};\n\nconst isDualCitation = (value: unknown) => value === true || value === \"true\";\n\nconst buildDualCitationHref = (reasoningId: string) =>\n reasoningId ? `./dual-citation?citationNumber=${encodeURIComponent(reasoningId)}` : \"\";\n\nconst buildWebGptMetaForReasoning = (\n deviationData: Record<string, any> | null | undefined,\n reasoningId: string,\n) => {\n if (!deviationData || !reasoningId) return null;\n\n const webSearchAnswer = deviationData?.web_search_answer;\n const extraMetaData = webSearchAnswer?.extraMetaData?.[reasoningId];\n if (!webSearchAnswer || !extraMetaData) return null;\n\n return {\n reasoningId,\n evaluation: deviationData,\n webSearchAnswer,\n extraMetaData,\n };\n};\n\nfunction CitationRenderer({\n content = \"\",\n title = \"\",\n citations = {},\n styles = {},\n docData = {} as Record<string, any>,\n deviationData = null,\n open,\n onCitationFullscreenChange,\n}: Props) {\n // Stabilize citations and docData — they arrive as new object references\n // on every stream tick even when content hasn't changed, which would\n // remount CitationAnchor and reset its expanded state.\n const stableCitationsStr = useMemo(() => JSON.stringify(citations || {}), [citations]);\n const stableCitations = useMemo(\n () => citations,\n [stableCitationsStr]\n );\n\n const stableDocDataStr = useMemo(() => JSON.stringify(docData || {}), [docData]);\n const stableDocData = useMemo(\n () => docData,\n [stableDocDataStr]\n );\n\n const stableMetaData = useMemo(\n () => ({ citations: stableCitations, docData: stableDocData }),\n [stableCitations, stableDocData]\n );\n\n const webGptMetaByReasoningId = useMemo(() => {\n const webSearchAnswer = deviationData?.web_search_answer;\n const extraMetaData = webSearchAnswer?.extraMetaData || {};\n\n return Object.keys(extraMetaData).reduce((acc: Record<string, any>, reasoningId) => {\n const matchedExtraMetaData = buildWebGptMetaForReasoning(deviationData, reasoningId);\n if (matchedExtraMetaData) acc[reasoningId] = matchedExtraMetaData;\n return acc;\n }, {});\n }, [deviationData]);\n\n const processedContent = useMemo(\n () => mergeRulebookCitationsIntoMatchingLinks(content),\n [content]\n );\n\n const components = useMemo(() => {\n return {\n a: ({ href = \"\", children, type, reason, ...props }: any) => {\n const reasoningId = props?.[\"data-cognitive-reasoning\"];\n const shouldUseDualCitation = isDualCitation(props?.[\"dual-citation\"]);\n const matchedExtraMetaData =\n shouldUseDualCitation && reasoningId\n ? webGptMetaByReasoningId[String(reasoningId)]\n : null;\n return (\n <CitationAnchor\n href={shouldUseDualCitation ? buildDualCitationHref(String(reasoningId || \"\")) : href}\n children={children}\n citationType={shouldUseDualCitation ? \"dual_citation\" : type}\n citationReason={reason}\n metaData={{\n ...stableMetaData,\n ...(matchedExtraMetaData ? { webGpt: matchedExtraMetaData } : {}),\n }}\n customStyle={\n matchedExtraMetaData ? \n {\n arrow: {\n color: \"#6D28D9\"\n }\n } : {}\n }\n onFullscreenChange={onCitationFullscreenChange}\n />\n );\n },\n };\n }, [stableMetaData, webGptMetaByReasoningId, onCitationFullscreenChange]);\n\n return (\n <Box\n sx={{\n borderRadius: \"8px\",\n border: \"1px solid #E4E7EC\",\n bgcolor: \"#FCFCFD\",\n }}\n >\n <Box\n sx={{ px: 1.5, py: 0.75, borderBottom: \"1px solid #EAECF0\" }}\n >\n <Typography\n sx={{\n fontSize: \"15px\",\n fontWeight: 600,\n color: \"#344054\",\n lineHeight: 1.25,\n }}\n >\n {title}\n </Typography>\n </Box>\n <Box\n sx={{\n px: 1.5,\n py: 1.1,\n display: \"flex\",\n flexDirection: \"column\",\n gap: 0.95,\n }}\n >\n <Box sx={{ display: \"flex\", flexDirection: \"column\" }}>\n <Typography\n component=\"div\"\n sx={{ ...styles }}\n >\n <ReactMarkdown components={components} rehypePlugins={[rehypeRaw as any]}>\n {processedContent}\n </ReactMarkdown>\n </Typography>\n </Box>\n </Box>\n </Box>\n )\n}\n\nexport default CitationRenderer\n"],"names":["buildDualCitationHref","reasoningId","encodeURIComponent","content","title","citations","styles","docData","deviationData","open","onCitationFullscreenChange","stableCitationsStr","useMemo","JSON","stringify","stableCitations","stableDocDataStr","stableDocData","stableMetaData","webGptMetaByReasoningId","webSearchAnswer","web_search_answer","extraMetaData","Object","keys","reduce","acc","matchedExtraMetaData","evaluation","buildWebGptMetaForReasoning","processedContent","mergeRulebookCitationsIntoMatchingLinks","components","a","href","children","type","reason","props","shouldUseDualCitation","value","String","jsx","CitationAnchor","citationType","citationReason","metaData","webGpt","customStyle","arrow","color","onFullscreenChange","jsxs","Box","sx","borderRadius","border","bgcolor","px","py","borderBottom","Typography","fontSize","fontWeight","lineHeight","display","flexDirection","gap","component","ReactMarkdown","rehypePlugins","rehypeRaw"],"mappings":"8WA2BA,MAEMA,EAAyBC,GAC3BA,EAAc,kCAAkCC,mBAAmBD,KAAiB,mBAoBxF,UAA0BE,QACtBA,EAAU,GAAAC,MACVA,EAAQ,GAAAC,UACRA,EAAY,CAAC,EAAAC,OACbA,EAAS,CAAC,EAAAC,QACVA,EAAU,CAAC,EAAAC,cACXA,EAAgB,KAAAC,KAChBA,EAAAC,2BACAA,IAKM,MAAAC,EAAqBC,UAAQ,IAAMC,KAAKC,UAAUT,GAAa,IAAK,CAACA,IACrEU,EAAkBH,EAAAA,QACpB,IAAMP,EACN,CAACM,IAGCK,EAAmBJ,UAAQ,IAAMC,KAAKC,UAAUP,GAAW,IAAK,CAACA,IACjEU,EAAgBL,EAAAA,QAClB,IAAML,EACN,CAACS,IAGCE,EAAiBN,EAAAA,QACnB,KAAA,CAASP,UAAWU,EAAiBR,QAASU,IAC9C,CAACF,EAAiBE,IAGhBE,EAA0BP,EAAAA,QAAQ,KACpC,MAAMQ,EAAkBZ,GAAea,kBACjCC,EAAgBF,GAAiBE,eAAiB,GAExD,OAAOC,OAAOC,KAAKF,GAAeG,OAAO,CAACC,EAA0BzB,KAC1D,MAAA0B,EArDkB,EAChCnB,EACAP,KAEA,IAAKO,IAAkBP,EAAoB,OAAA,KAE3C,MAAMmB,EAAkBZ,GAAea,kBACjCC,EAAgBF,GAAiBE,gBAAgBrB,GACvD,OAAKmB,GAAoBE,EAElB,CACHrB,cACA2B,WAAYpB,EACZY,kBACAE,iBAN2C,MA6CVO,CAA4BrB,EAAeP,GAEjE,OADH0B,IAA0BD,EAAAzB,GAAe0B,GACtCD,GACR,CAAE,IACN,CAAClB,IAEEsB,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AA,CAAArC,aAAwBsC,cAAe,CAACC,WAClDpC,SACLL,YAMxB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@mui/material"),i=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),s=require("./CognitiveComparehelpers.js"),l=require("./CognitiveCompareConfig.js"),c=require("./CognitiveCompareConstants.js"),a=require("./CognitivePopup.js"),u=require("./MoreFunctionsPopup.js"),d=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),p=require("./hooks/useCompareData.js"),g=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),R=require("./hooks/useOnDemandCitationCache.js"),x=require("./components/CompareHeader.js"),v=require("./components/SubSectionAccordion.js"),y=require("./components/LHSSectionRow.js"),b=require("./components/RHSSectionRow.js"),C=require("./components/CognitiveSummaryPopup.js"),E=require("./CompareContext.js"),A=require("./hooks/useStyles.js"),I=require("./hooks/useResizeHandler.js"),_=require("./hooks/useLinesCalculator.js"),T=require("./hooks/useSideBySide.js"),B=require("./components/SvgConnectors.js"),w=require("./Guidelines/components/GuidelinePanel.js"),D=require("./Guidelines/components/WebGptPanel.js"),O=require("./components/GuidelineSkeletonLoader.js"),j=require("./Guidelines/utils/guidelineTargets.js"),F=require("./Guidelines/utils/hasGptCitationObjects.js");exports.SHARED_MARKDOWN_STYLES=l.SHARED_MARKDOWN_STYLES,exports.default=({componentHeaderText:P=c.DEFAULT_COMPONENT_HEADER_TEXT,treeData:k,comparisonConfig:N,leftColumnTitleText:M,rightColumnTitleText:L,markdownStyles:q,resetTrigger:G,displayConfig:$={isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1},onMaintainRelativeOrderChange:V,popupConfig:H,deviationData:z={},deviationNodeIdToView:W,resetDeviationNodeId:K,isProposingFix:U=!1,proposingFixNodeId:Y,isRedlineFlow:J,badgeStyleOverride:X,guidelinesData:Q,isGuidelineMode:Z,gptWebCitationConfig:ee,onDemandCitationConfig:te})=>{const[ne,ie]=t.useState($.maintainRelativeOrder),oe=$?.expandLevels??0,re=!!$?.expandAllSections,se=!!ne||!!$?.showDeviationBadges,[le,ce]=t.useState(!1),[ae,ue]=t.useState(null),[de]=t.useState(k?.newEvaluationResult??$?.enableDeviationSchemaBackwardCompatibility??!0),[fe,pe]=t.useState(new Set),[ge,he]=t.useState([]),[me,Se]=t.useState(!1),[Re,xe]=t.useState(0),ve=t.useRef(null),ye=t.useRef(null),be=t.useRef(null),Ce=t.useRef(null),Ee=t.useRef(null),Ae=t.useRef(!1),Ie=t.useRef(null),_e=t.useRef({}),Te=t.useRef([]),Be=t.useRef(()=>{}),we=t.useRef(null),De=t.useRef(()=>{}),Oe=t.useMemo(()=>JSON.stringify(z||{}),[JSON.stringify(z)]),je=t.useMemo(()=>z||{},[Oe]),Fe=t.useMemo(()=>F.hasGptCitationObjects(je),[je]),Pe=t.useMemo(()=>k?.cognitive_decisioning||{},[k]),ke=t.useMemo(()=>({...l.SHARED_MARKDOWN_STYLES,...q}),[q]),Ne=t.useRef(null),Me=t.useRef(null),Le=t.useRef(null),qe=t.useRef(null),Ge=t.useRef(null),$e=t.useRef(null),Ve=t.useRef(null),He=t.useRef(null),ze=t.useRef(null),We=t.useRef(null),{cognitivePopup:Ke,setCognitivePopup:Ue,moreFunctions:Ye,setMoreFunctions:Je,position:Xe,setPosition:Qe,activeBadgeId:Ze,summaryPopup:et,setSummaryPopup:tt,closeSummaryPopup:nt,setActiveBadgeId:it,popupRef:ot,handleOpenCognitiveCompare:rt,openCognitivePopupFromState:st,closeCognitivePopup:lt,closeMoreFunctionsPopup:ct}=g.useComparePopups(Ne),at=t.useMemo(()=>({fields:N?.fields??l.DEFAULT_FIELD_CONFIG,thresholds:{high:N?.thresholds?.high??l.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:N?.thresholds?.medium??l.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:N?.thresholds?.exact??l.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}),[N]),[ut,dt]=t.useState(null),ft=k?.documents?.[k?.input_index_map?.[0]]?.title,pt=k?.documents?.[k?.input_index_map?.[1]]?.title,gt=s.safeStringify(M||ft||"Uploaded Contract"),ht=k?.documents?.[k?.input_index_map?.[0]]?.metadata?.file_name,mt=s.safeStringify(ht),St=k?.documents?.[k?.input_index_map?.[1]]?.metadata?.file_name,Rt=s.safeStringify(St),xt=s.safeStringify(L||pt||"Reference Template"),{isGuidelineMode:vt,activeProposed:yt,existingRule:bt,proposedSections:Ct,existingSections:Et,visibleFields:At,parentDeviationRecord:It,deviationNumberRegistry:_t,deviationParentRegistry:Tt,parseError:Bt}=p.useCognitiveTreeData(k,ne,je,at,de,Q,Z);t.useEffect(()=>{Bt&&ue(`Failed to load comparison: ${Bt}`)},[Bt]);const wt=Ct.length>0||Et.length>0,Dt=t.useMemo(()=>{if(!J)return"off";let e=0,t=0;const n=i=>{Array.isArray(i)&&i.forEach(i=>{const o=i?.content||"";s.hasMeaningfulRedlineTags(o)&&(e+=1,t+=String(o).length),i?.subsections?.length&&n(i.subsections)})};return n(Ct),n(Et),`${e}:${t}`},[J,Ct,Et]);t.useEffect(()=>{if(Ct.length||Et.length)if(re){const e={},t={},n=(n,i)=>{n.forEach((n,o)=>{const r=ne?`${i}-${o}`:String(o);e[r]=!0;const s=(e,n)=>{e?.forEach((e,i)=>{const o=`${n}-${i}`;t[o]=!0,e.subsections?.length&&s(e.subsections,o)})};n.subsections?.length&&s(n.subsections,String(o))})};n(Ct,"left"),n(Et,"right"),hn(e),Sn(t)}else if(oe>0){const e={},t={},n=(n,i,o)=>{n.forEach((n,r)=>{if(o>=1){const t=ne?`${i}-${r}`:String(r);e[t]=!0}const s=(e,n,i)=>{i>o||e?.forEach((e,o)=>{const r=`${n}-${o}`;t[r]=!0,e.subsections?.length&&s(e.subsections,r,i+1)})};n.subsections?.length&&o>=2&&s(n.subsections,String(r),2)})};n(Ct,"left",oe),n(Et,"right",oe),hn(e),Sn(t)}},[re,oe,Ct,Et,ne]);const{leftRefs:Ot,rightRefs:jt,sectionLeftRefs:Ft,sectionRightRefs:Pt,lhsBadgeRefs:kt,rhsBadgeRefs:Nt,sectionRightRowRefs:Mt,subSectionLeftRefs:Lt,subSectionRightRefs:qt,sectionRowRefs:Gt,getSectionRowRef:$t,getSubSectionRef:Vt,getBadgeRef:Ht}=h.useSectionRefs(At.map(({key:e})=>e),Math.max(Ct.length,Et.length)),{isSideBySide:zt,isArrowVisible:Wt,setIsSideBySide:Kt,setIsArrowVisible:Ut,isResizing:Yt,setIsResizing:Jt,isSideBySideLoading:Xt,setIsSideBySideLoading:Qt,activeSideBySideSection:Zt,setActiveSideBySideSection:en,scrollLock:tn,sideBySideCacheRef:nn,isSideBySideRef:on,activeSideBySideRightSectionRef:rn,activeSideBySideSectionRef:sn,sideBySideLineRef:ln,highlightedClauseRefs:cn,clearClauseHighlight:an,applyAlignmentPadding:un,resetSideBySide:dn,activateSideBySide:fn}=T.useSideBySide({isGuidelineMode:vt,maintainRelativeOrder:ne,proposedSections:Ct,existingSections:Et,leftContainerRef:He,rightContainerRef:Le,scrollContainerRef:Ne,sectionLeftRefs:Ft,sectionRightRefs:Pt,subSectionLeftRefs:Lt,subSectionRightRefs:qt,lhsBadgeRefs:kt,rhsBadgeRefs:Nt,sectionRowRefs:Gt,sectionRightRowRefs:Mt,rhsTopSpacerRef:qe,rhsBottomSpacerRef:Ge,lhsTopSpacerRef:$e,lhsBottomSpacerRef:Ve,calculateLinesRef:Be,setConnectedSections:pe,setConnectedLines:he,cachedConnectedPositions:Te,closeMoreFunctionsPopup:ct,setErrorToast:ue,moreFunctions:Ye,closeSummaryPopup:nt}),pn=t.useRef(fn);t.useEffect(()=>{pn.current=fn},[fn]);const{expandedSections:gn,setExpandedSections:hn,expandedSubSections:mn,setExpandedSubSections:Sn,handleSubSectionToggle:Rn,toggleSection:xn,forceExpandCrossWiredSections:vn}=m.useAccordionState({maintainRelativeOrder:!!ne,proposedSections:Ct,existingSections:Et,activeSideBySideSection:Zt,connectedSections:fe,resetSideBySide:dn,setConnectedSections:pe,setConnectedLines:he,cachedConnectedPositions:Te,svgContainerRef:ve,isAnimatingRef:Ae,animationTimerRef:Ie,calculateLinesRef:Be,sectionLeftRefs:Ft,sectionRightRefs:Pt,subSectionLeftRefs:Lt,subSectionRightRefs:qt}),yn=()=>{if(null==Zt)return;const e=Ft.current[Zt]?.current,t=Pt.current[Zt]?.current,n=Le.current;if(!e||!t||!n)return;const i=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.top-r.top,l=o.top-r.top-s;n.scrollBy({top:l,behavior:"smooth"})},bn=t.useCallback(e=>{e?.stopPropagation(),Se(e=>{const t=!e;return t&&requestAnimationFrame(()=>{yn()}),t})},[yn]);t.useEffect(()=>{J&&"off"!==Dt&&"0:0"!==Dt&&(nn.current=null,Te.current=[],requestAnimationFrame(()=>{Be.current?.()}))},[J,Dt]);const Cn=t.useMemo(()=>{const e=new Map,t=new Map;let n=1;if(ne)Ct.forEach(t=>{!t.title&&!t.content||t.id&&e.set(t.id,n++)}),Et.forEach(i=>{if(!i.id)return;if(!i.title&&!i.content)return;const o=Ct.filter(e=>e.refIndexes?.includes(i.selfIndex));if(o.length>0){const n=o.map(t=>e.get(t.id)).filter(Boolean);t.set(i.id,n.join(", "))}else t.set(i.id,String(n++))});else{const i=Math.max(Ct.length,Et.length);for(let o=0;o<i;o++){const i=Ct[o],r=Et[o];i?(e.set(i.id,n),r&&t.set(r.id,String(n)),n++):r&&t.set(r.id,String(n++))}}return{leftNums:e,rightNums:t}},[Ct,Et,ne]),En=bt.analysis,An=s.safeStringify(En?.rule_difference_comparison?.summary?.overall_summary),In=!!An.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),_n=k?.base_root_id??"-1",Tn=de?(z&&z?.[_n]?.evaluation_result)??k?.nodes?.[_n]?.evaluation_result??null:(z&&z?.[_n]?.evaluation_result?.[0])??k?.nodes?.[_n]?.evaluation_result?.[0]??null,Bn=s.extractDeviationScore(Tn);let wn=s.generateColorPalette(Tn?.evaluation_outputs?.metadata?.label_color??c.DEFAULT_DEVIAION_COLOR);if(X){const e=X(Bn);e&&(wn={...wn,badgeBg:e.bg,badgeText:e.text,badgeBorder:e.border})}const Dn=t.useRef(dn);t.useEffect(()=>{Dn.current=dn},[dn]);const On=t.useRef(lt);t.useEffect(()=>{On.current=lt},[lt]);const jn=t.useCallback((e,t,n,i,o,r)=>Vi.current(e,t,n,i,o,r),[]),Fn=t.useCallback((e,t,n,i,o)=>zi.current(e,t,n,i,o),[]),Pn=t.useCallback(()=>Wi.current(),[]),kn=t.useCallback((e,t)=>Ki.current(e,t),[]),Nn=t.useCallback(e=>Ui.current(e),[]),Mn=t.useCallback(e=>Yi.current(e),[]),Ln=t.useCallback(()=>Ji.current(),[]),qn=t.useCallback(()=>{an(),Dn.current?.(),Se(!1),pe(new Set),he([]),Te.current=[],si([]),ci(null),tt(c.EMPTY_SUMMARY_POPUP_STATE),On.current?.(),requestAnimationFrame(()=>{Be.current?.()})},[]),Gn=t.useRef(qn);t.useEffect(()=>{Gn.current=qn},[qn]),t.useEffect(()=>{G&&Gn.current()},[G]);const $n=t.useMemo(()=>({documents:k?.documents,input_index_map:k?.input_index_map}),[JSON.stringify(k?.documents),JSON.stringify(k?.input_index_map)]),[Vn,Hn]=t.useState(""),zn=s.safeStringify(pt),Wn=t.useRef(k);t.useEffect(()=>{Wn.current=k;const e=k?.input_index_map?.[0],t=k?.documents?.[e]?.title;Hn(t)},[k]);const Kn=t.useRef(Pe);t.useEffect(()=>{Kn.current=Pe},[Pe]);const Un=t.useCallback((e,t,n,i,o,r,l)=>{const c=s.safeStringify(t?.id)||s.safeStringify(n?.id)||"",a="string"==typeof i?i.split(s.DEVIATION_BADGE_SEPARATOR):[],u=a[0]||s.safeStringify(t?.nodeId)||s.safeStringify(n?.nodeId)||s.safeStringify(t?.id).split(s.DEVIATION_BADGE_SEPARATOR)[0]||s.safeStringify(n?.id).split(s.DEVIATION_BADGE_SEPARATOR)[0]||void 0,d=a.length>1&&void 0!==a[1]?a[1]:void 0,f=(c?Kn.current?.[c]:null)||t?.cognitiveData||n?.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},p=Gt.current[i]?.current??null,g=(()=>{const e=t?.evaluationResult||n?.evaluationResult||null,o=e=>{const t=(e=>{if(!e||"object"!=typeof e)return null;const t=e?.deviation_entries;if(t&&"object"==typeof t){const e=Object.keys(t).sort((e,t)=>Number(e)-Number(t))[0];if(e&&t[e])return t[e]}const n=Object.keys(e).filter(e=>/^\d+$/.test(e)).sort((e,t)=>Number(e)-Number(t));if(n.length&&e[n[0]])return e[n[0]];const i=e?.deviations;if(i&&"object"==typeof i){const e=Object.keys(i).sort((e,t)=>Number(e)-Number(t))[0];if(e&&i[e])return i[e]}return null})(e);return t?{...e,deviation_summary:e?.deviation_summary||t?.deviation_summary,deviation_title:e?.deviation_title||t?.deviation_title,deviation_impact:e?.deviation_impact||t?.deviation_impact,deviation_explanation:e?.deviation_explanation||t?.deviation_explanation,evaluation_outputs:e?.evaluation_outputs||t?.evaluation_outputs,cognitive_decisioning:e?.cognitive_decisioning||t?.cognitive_decisioning}:e};if(!("string"==typeof i&&i.includes(s.DEVIATION_BADGE_SEPARATOR)))return o(e);const r=i.split(s.DEVIATION_BADGE_SEPARATOR)[1];if(!r)return e;const l=t?.evaluationResult||n?.evaluationResult||{},c=l?.deviation_entries?.[r]||l?.deviations?.[r]||null;return c?{...l,...c,deviation_summary:c?.deviation_summary||l?.deviation_summary,deviation_title:c?.deviation_title||l?.deviation_title,deviation_impact:c?.deviation_impact||l?.deviation_impact,deviation_explanation:c?.deviation_explanation||l?.deviation_explanation,evaluation_outputs:c?.evaluation_outputs||l?.evaluation_outputs,cognitive_decisioning:c?.cognitive_decisioning||l?.cognitive_decisioning}:o(e)})(),h=(g?.cognitive_decisioning?.decisioning_factors?.length??0)>0||(g?.cognitive_decisioning?.gaps_in_decision?.length??0)>0,m=$?.isLoading??!1;let S=!0;if(vt){const e=g?.deviation_highlights;if(e&&"object"==typeof e){S=Object.values(e).some(e=>Array.isArray(e)&&e.length>0)}else S=!1}return{isLoading:m&&!h,open:!0,sectionTitle:t?.title?t?.title:"No Counterpart",refSectionTitle:n?.title?n?.title:"No Counterpart",cognitiveData:f,anchorEl:e,sectionAnchorEl:p,badgeStyle:r||null,sectionIdx:i,docData:$n,deviationData:g,isOrphan:!!o,hasGuidelineMatches:S,sourceNodeId:u,deviationKey:d,baseContentId:t?.contentId,compareContentIds:[...n?.contentId?[n.contentId]:[],...t?.refContentIds||[],...n?.refContentIds||[]].filter(Boolean)}},[$n,$?.isLoading,vt]),Yn=t.useCallback((e,t,n,i,o,r)=>{if(e.stopPropagation(),Ye.open&&Ye.sectionIdx===o)return void ct();const l=e.currentTarget;let c="left";Le.current?.contains(l)&&(c="right");an(),on.current&&dn(),pe(new Set),he([]),Te.current=[],lt(),et.open?Ai():nt(),requestAnimationFrame(()=>{const e=(()=>{if("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)){const e=o.split(s.DEVIATION_BADGE_SEPARATOR),t=`${e[0]}${s.DEVIATION_BADGE_SEPARATOR}${e[1]}`;return"right"===c?Nt.current[t]?.current:kt.current[t]?.current}return"right"===c?Nt.current[o]?.current:kt.current[o]?.current})()||l;Je(Un(e,t,i,o,n,r))})},[Ye.open,Ye.sectionIdx,ct,nt,Un]),Jn=t.useCallback(()=>{const e=Ye.sectionIdx;Ye.isOrphan,ct(),nt(),null!==e&&(vn(e),an(),on.current&&dn(),he([]),Te.current=[],vt&&null!==e&&xe(vi(e)),pe(t=>t.has(e)?new Set:new Set([e])),setTimeout(()=>{Be.current&&Be.current()},50))},[Ye.sectionIdx,Ye.isOrphan,ct,nt,dn]),Xn=t.useCallback(()=>{const e=Ee.current;if(!e)return;Ee.current=null;const t=Ct.findIndex(t=>t.id===e),n=Et.findIndex(t=>t.id===e),i=-1===t?s.findKeyPathByNodeId(Ct,e):null,o=-1===n?s.findKeyPathByNodeId(Et,e):null,r=-1!==t?t:i?Number(i.split("-")[0]):-1,l=-1!==n?n:o?Number(o.split("-")[0]):-1,c=(e,t,n,i)=>-1!==e?n.current[e]?.current??null:t?i.current[t]?.current??null:null,a=(e,t,n=30)=>{let i=0;const o=()=>{const r=e();r&&0!==r.getBoundingClientRect().height?(cn.current.add(r),s.scrollAndHighlightClause(r,t)):i++<n&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(ne)-1!==r&&He.current&&a(()=>c(t,i,Ft,Lt),He.current),-1!==l&&Le.current&&a(()=>c(n,o,Pt,qt),Le.current);else{const e=Ne.current;if(!e)return;a(()=>-1!==r?c(t,i,Ft,Lt):c(n,o,Pt,qt),e)}},[Ct,Et,ne,Ft,Pt,Lt,qt,He,Le,Ne]),Qn=t.useCallback(e=>{if(!e)return;an(),dn(),pe(new Set),he([]),Te.current=[],nt(),lt();const t=Ct.findIndex(t=>t.id===e),n=Et.findIndex(t=>t.id===e),i=-1===t?s.findKeyPathByNodeId(Ct,e):null,o=-1===n?s.findKeyPathByNodeId(Et,e):null;if(-1===t&&!i&&-1===n&&!o)return void console.warn(`scrollToAndHighlightClause: nodeId "${e}" not found`);const r=-1!==t?t:i?Number(i.split("-")[0]):-1,l=-1!==n?n:o?Number(o.split("-")[0]):-1;Ee.current=e,hn(e=>{const t={...e};let n=!1;if(-1!==r){const e=ne?`left-${r}`:String(r);t[e]||(t[e]=!0,n=!0)}if(-1!==l){const e=ne?`right-${l}`:String(l);t[e]||(t[e]=!0,n=!0)}return n?t:e}),Sn(e=>{const t={...e};let n=!1;const r=e=>{const i=e.split("-");let o=i[0];for(let e=1;e<i.length;e++)o+=`-${i[e]}`,t[o]||(t[o]=!0,n=!0)};return i&&r(i),o&&r(o),n?t:e}),setTimeout(()=>{requestAnimationFrame(()=>{Ee.current===e&&Zn.current()})},50)},[Ct,Et,ne,hn,Sn,dn,nt,lt]),Zn=t.useRef(Xn);t.useEffect(()=>{Zn.current=Xn},[Xn]);const ei=t.useRef(null);t.useEffect(()=>{if(ut){const e=at.fields.find(e=>e.analysisKey===ut||e.key===ut);if(e){const t=Ot.current[e.key]||jt.current[e.key];t?.current&&setTimeout(()=>t.current.scrollIntoView({behavior:"smooth",block:"center"}),150)}}},[ut,at.fields]);const ti=t.useCallback(e=>{const t=En?.rule_difference_comparison?.fields;if(!t||!t[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};const n=t[e],i=n?.relation||n?.highlights?.ruleA_spans?.length||n?.highlights?.ruleB_spans?.length||n?.mappings&&n.mappings.length>0;if(n.mappings){const e=n.mappings[0]||{};return{score:n.score,relation:e.relation||"",highlightsA:e.highlights?.ruleA_spans||[],highlightsB:e.highlights?.ruleB_spans||[],hasContent:!!i}}return{score:n.score,relation:n.relation||"",highlightsA:n.highlights?.ruleA_spans||[],highlightsB:n.highlights?.ruleB_spans||[],hasContent:!!i}},[En]),{getSectionCompareStyle:ni,getSubSectionCompareStyle:ii,getDeviationStyleByKey:oi}=A.useStyleHelpers({proposedSections:Ct,existingSections:Et,maintainRelativeOrder:ne,cognitiveMap:Pe,deviationData:je,treeData:k,resolvedComparisonConfig:at,badgeStyleOverride:X}),{lines:ri,setLines:si,overallConnector:li,setOverallConnector:ci,svgDimensions:ai,calculateLines:ui,calculateLinesDebounced:di,handleColumnScroll:fi}=_.useLinesCalculator({containerRef:ye,leftContainerRef:He,rightContainerRef:Le,svgContainerRef:ve,pathRefs:_e,leftHeaderRef:be,rightHeaderRef:Ce,proposedSections:Ct,existingSections:Et,visibleFields:At,leftRefs:Ot,rightRefs:jt,sectionLeftRefs:Ft,sectionRightRefs:Pt,subSectionLeftRefs:Lt,subSectionRightRefs:qt,lhsBadgeRefs:kt,rhsBadgeRefs:Nt,sectionRowRefs:Gt,expandedSections:gn,expandedSubSections:mn,connectedSections:fe,isSideBySide:zt,activeSideBySideSection:Zt,maintainRelativeOrder:ne,isGuidelineMode:vt,cognitiveMap:Pe,getSectionCompareStyle:ni,getSubSectionCompareStyle:ii,getDeviationStyleByKey:oi,isArrowVisible:Wt,isAnimatingRef:Ae,isSideBySideRef:on,sideBySideCacheRef:nn,sideBySideLineRef:ln,activeSideBySideSectionRef:sn,activeSideBySideRightSectionRef:rn,connectedLines:ge,setConnectedLines:he,cachedConnectedPositions:Te,calculateLinesRef:Be,resizeTimerRef:we,scrollLock:tn,scrollSyncLocked:me,handleResizeRef:De,activeProposed:yt,existingRule:bt,analysisData:En,pendingScrollTargetRef:ze,pendingScrollCallbackRef:We,resolvedComparisonConfig:at,getFieldData:ti});t.useEffect(()=>{et.anchorEl&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{Be.current?.()})})},[et.anchorEl,me]);const pi=t.useCallback(()=>{an(),Se(!1),hn({}),Sn({}),dn(),pe(new Set),he([]),Te.current=[],nt(),lt(),ct(),requestAnimationFrame(()=>{Be.current&&Be.current()})},[hn,Sn,dn,nt,lt,ct]);t.useEffect(()=>{zt||0!==fe.size||Se(!1)},[zt,fe]);const gi=t.useMemo(()=>Object.values(gn).some(Boolean)||Object.values(mn).some(Boolean),[gn,mn]),hi=t.useRef(null),mi=t.useRef(0),Si=t.useRef(0),Ri=t.useRef(0),{handleResize:xi}=I.useResizeHandler({timerRef:hi,ruleComponentRef:Me,scrollContainerRef:Ne,containerRef:ye,maintainRelativeOrder:ne,proposedSections:Ct,existingSections:Et,isSideBySideRef:on,activeSideBySideSectionRef:sn,activeSideBySideRightSectionRef:rn,sectionRowRefs:Gt,sectionRightRowRefs:Mt,sectionLeftRefs:Ft,sectionRightRefs:Pt,subSectionLeftRefs:Lt,subSectionRightRefs:qt,lhsBadgeRefs:kt,rhsBadgeRefs:Nt,leftContainerRef:He,rightContainerRef:Le,calculateLinesRef:Be,handleResizeRef:De,setIsResizing:Jt,setIsArrowVisible:Ut,sideBySideCacheRef:nn,cachedConnectedPositions:Te});t.useEffect(()=>{De.current=xi},[xi,De]),t.useEffect(()=>{const e=(e,t,n,i,o)=>{t.current=e.getBoundingClientRect().width;const r=new ResizeObserver(e=>{null!==n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{n.current=null;const r=e[e.length-1];if(!r)return;const s=r.borderBoxSize?.[0]?.inlineSize??r.contentRect.width;Math.abs(s-t.current)<1?o():(t.current=s,i())})});return r.observe(e),r},t={current:null},n={current:null},i={current:null},o=[],r=[t,n,i];return Me.current&&o.push(e(Me.current,mi,t,()=>De.current(),()=>{})),Ne.current&&o.push(e(Ne.current,Si,n,()=>De.current(),()=>Be.current())),ye.current&&o.push(e(ye.current,Ri,i,()=>De.current(),()=>Be.current())),()=>{o.forEach(e=>e.disconnect()),r.forEach(e=>{null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(()=>{on.current=zt},[zt]),t.useEffect(()=>{sn.current=Zt},[Zt]);const vi=t.useCallback(e=>{let t="",n="0";if("number"==typeof e)t=Ct[e]?.nodeId||Ct[e]?.id||"";else{const i=String(e).split(s.DEVIATION_BADGE_SEPARATOR);t=i[0],n=i[1]||"0"}const i=je?.[t]?.evaluation_result,o=Array.isArray(i)?i[parseInt(n,10)]:i?.[n];return!1===o?.evaluation_outputs?.guideline_flag?.rulebook_used&&F.hasGptCitationObjects(o)?1:0},[Ct,je]),yi=t.useCallback(()=>{dn(),pe(new Set),he([]),Te.current=[]},[dn]),bi=t.useCallback((e,t)=>{t!==Re&&(yi(),xe(t))},[Re,yi]);t.useEffect(()=>{Fe||0===Re||(yi(),xe(0))},[Re,Fe,yi]);const Ci=t.useCallback(e=>{const t=He.current,n=Le.current,i=j.getVisibleGuidelineTargets(n);if(!n)return;const o="string"==typeof e&&e.includes(s.DEVIATION_BADGE_SEPARATOR);let r=e;if(o){const t=e.split(s.DEVIATION_BADGE_SEPARATOR);t.length>=2&&(r=`${t[0]}${s.DEVIATION_BADGE_SEPARATOR}${t[1]}`)}const l=kt.current[r]?.current||kt.current[e]?.current;if(i.length>0&&l&&t&&n){const e=i[0];$e.current&&($e.current.style.height="0px"),qe.current&&(qe.current.style.height="0px"),Ve.current&&(Ve.current.style.height="0px"),Ge.current&&(Ge.current.style.height="0px"),requestAnimationFrame(()=>{const i=l.getBoundingClientRect(),o=e.getBoundingClientRect(),r=t.getBoundingClientRect(),s=n.getBoundingClientRect(),c=t.scrollTop+(i.top-r.top)+i.height/2,a=n.scrollTop+(o.top-s.top)+o.height/2,u=c-r.height/2,d=Math.max(0,u),f=t.scrollHeight-t.clientHeight,p=d>f?d-f:0,g=r.top+c-d;let h=s.top+a-g,m=0;h<0&&(m=Math.abs(h),h=0);const S=n.scrollHeight-n.clientHeight+m,R=h>S?h-S:0;Ve.current&&(Ve.current.style.height=`${p}px`),qe.current&&(qe.current.style.height=`${m}px`),Ge.current&&(Ge.current.style.height=`${R}px`),requestAnimationFrame(()=>{t.scrollTo({top:d,behavior:"smooth"}),n.scrollTo({top:h,behavior:"smooth"}),Be.current&&setTimeout(()=>Be.current(),50)})})}},[s.DEVIATION_BADGE_SEPARATOR]),Ei=t.useCallback(()=>{const e=Ye.sectionIdx,t=Ye.isOrphan;if(nt(),null==e)return;let n="left";Ye.anchorEl&&Le.current?.contains(Ye.anchorEl)&&(n="right"),vn(e),vt&&(xe(vi(e)),pe(new Set([e]))),fn(e,t,{sourceSide:n,onReady:()=>{vt&&setTimeout(()=>Ci(String(e)),150)}})},[fn,Ye.isOrphan,Ye.sectionIdx,Ye.anchorEl,nt,vn,vt,Ci,vi]),Ai=t.useCallback(()=>{nt(),dn(),pe(new Set),he([]),Te.current=[]},[nt,dn]),Ii=null!==Ye.sectionIdx&&fe.has(Ye.sectionIdx),{showDeviationNavigation:_i,showOpenNodeRef:Ti,adjustScrollForPopup:Bi}=S.useDeviationNavigation({proposedSections:Ct,existingSections:Et,parentDeviationRecord:It,expandedSections:gn,maintainRelativeOrder:!!ne,scrollContainerRef:Ne,leftContainerRef:He,rightContainerRef:Le,lhsBadgeRefs:kt,rhsBadgeRefs:Nt}),wi=t.useCallback((e,t,n,i,o)=>{const r="string"==typeof i?s.safeStringify(i).trim():s.safeStringify(i?.deviation_summary).trim(),l=e.currentTarget;lt();let c="left";Le.current?.contains(l)&&(c="right");const a=()=>{if("string"==typeof t&&t.includes(s.DEVIATION_BADGE_SEPARATOR)){const e=t.split(s.DEVIATION_BADGE_SEPARATOR),n=`${e[0]}${s.DEVIATION_BADGE_SEPARATOR}${e[1]}`;return"right"===c?Nt.current[n]?.current:kt.current[n]?.current}return"right"===c?Nt.current[t]?.current:kt.current[t]?.current};if(n&&!vt)return dn(),pe(new Set),he([]),Te.current=[],void(r&&(vn(t),requestAnimationFrame(()=>{const e=a()||l;if(e){e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"})}tt({open:!0,anchorEl:e,summary:i,displayImpact:o})})));vn(t),vt&&(xe(vi(t)),pe(new Set([t]))),r?setTimeout(()=>{fn(t,n,{toggleIfSame:!1,sourceSide:c,onReady:()=>{const e=a()||l;if(vt)setTimeout(()=>Ci(t),150);else if(e){const t=e.getBoundingClientRect();if(t.top>.8*window.innerHeight||t.top<100){const e=t.top-window.innerHeight/2;ne?(He.current?.scrollBy({top:e,behavior:"smooth"}),Le.current?.scrollBy({top:e,behavior:"smooth"})):Ne.current?.scrollBy({top:e,behavior:"smooth"})}}tt({open:!0,anchorEl:e,summary:i,displayImpact:o})}})},350):setTimeout(()=>{fn(t,n,{toggleIfSame:!1,sourceSide:c}),vt&&setTimeout(()=>Ci(t),150)},350)},[fn,lt,tt,dn,vn,vt,ne,Ci,je]),Di=t.useMemo(()=>{if(!W)return null;const e=W?.id?.split(":")[0];for(const t in It){if((It[t]||[]).some(t=>t.id===e))return t}return null},[W,It]),Oi=t.useRef({id:null,triggerMs:null}),ji=t.useRef(null);t.useEffect(()=>{if(!W?.id)return;const e=Number(W.trigger),t=Oi.current;if(t?.id===W.id&&t?.triggerMs===e)return;if(!(W.id.includes(":")&&/:\d+$/.test(W.id))){Oi.current={id:W.id,triggerMs:e},Qn(W.id);const t=Ct.findIndex(e=>e.id===W.id),n=Et.findIndex(e=>e.id===W.id);return void(-1===t&&-1===n||setTimeout(()=>{const e=-1!==t?t:n,i=-1===t;vt&&xe(vi(e)),pe(new Set([e])),pn.current(e,i,{sourceSide:i?"right":"left",onReady:()=>{vt&&setTimeout(()=>Ci(String(e)),150)}})},400))}const[n,i]=W.id.split(":"),o=i??"0",r=`${W.id}:${e}`;ji.current!==r&&(nt(),lt(),dn(),pe(new Set),he([]),Te.current=[],ji.current=r);let l=!1,c=0;let a=null,u=null,d=!1;const f=(e,t)=>{const n=(e,i)=>{if(!e)return null;if(t.includes(e.id)||t.includes(e.nodeId)||t.includes(e.contentId))return i;if(!Array.isArray(e.subsections))return null;for(let t=0;t<e.subsections.length;t++){const o=n(e.subsections[t],`${i}-${t}`);if(o)return o}return null};for(let t=0;t<e.length;t++){const i=n(e[t],String(t));if(i)return i}return null},p=()=>{if(l)return;const t=()=>{Oi.current={id:W.id,triggerMs:e}};let i=null,r=null;for(const e in It){const t=It[e].find(e=>e.id===n||e.nodeId===n||e.contentId===n||e.evaluationResult?.nodeId===n);if(t){i=e,r=t;break}}if(!r||!i)return c++,void(c<30&&(a=setTimeout(p,100)));const g=Array.from(new Set([n,r.id,r.nodeId,r.contentId,r.evaluationResult?.nodeId].filter(Boolean))),h=Ct.findIndex(e=>e.id===i),m=Et.findIndex(e=>e.id===i),S=-1===h&&-1!==m,R=f(Ct,g);let x=f(Et,g);if(R&&!x&&!S){const e=R.split("-");let t=Number(e[0]);if(ne){const e=Ct[t]?.refIndexes?.[0],n=Et.findIndex(t=>t.selfIndex===e);-1!==n&&(t=n)}x=[t,...e.slice(1)].join("-")}if(!R&&!x)return c++,void(c<30&&(a=setTimeout(p,100)));const v=R?Number(R.split("-")[0]):h,y=x?Number(x.split("-")[0]):m,b=y>=0?y:x?Number(x.split("-")[0]):-1,C=Ct[v],E=Et[b],A=C&&!C.title&&!C.content,I=E&&!E.title&&!E.content,_=S||(!R&&!!x||A&&!I);if(_){if(!(ne?!!Hi.current[`right-${y}`]:!!Hi.current[String(y)])&&y>=0)return xn(y,"right"),void(a=setTimeout(p,200))}else{if(!(ne?!!Hi.current[`left-${v}`]:!!Hi.current[String(v)])&&v>=0)return xn(v,"left"),void(a=setTimeout(p,200))}const T=R||"",B=x||"",w=g.map(e=>`${e}${s.DEVIATION_BADGE_SEPARATOR}${o}`),D=w[0],O=()=>{for(const e of w){const t=kt.current[e]?.current||null,n=Nt.current[e]?.current||null;if(t||n)return{refId:e,left:t,right:n}}return{refId:D,left:null,right:null}},j=e=>`${e}${s.DEVIATION_BADGE_SEPARATOR}${T}${s.DEVIATION_BADGE_SEPARATOR}${B}`;if(!d){vn(j(D)),d=!0,c=0;const e=()=>{const{left:e,right:t}=O();return _||!e&&!!t?t:e};return u?.(),void(a=setTimeout(()=>{l||(u=((e,t)=>{let n,i=0,o=null,r=null;const s=performance.now(),c=()=>{if(l)return;if(performance.now()-s>3e3)return void t();const a=e();if(!a||0===a.getBoundingClientRect().height)return void(n=requestAnimationFrame(c));const u=a.getBoundingClientRect(),d=u.top,f=u.height,p=null!==o&&Math.abs(d-o)<.5,g=null!==r&&Math.abs(f-r)<.5;if(p&&g){if(i++,i>=5)return void t()}else i=0;o=d,r=f,n=requestAnimationFrame(c)};return n=requestAnimationFrame(c),()=>cancelAnimationFrame(n)})(e,()=>{l||(u=null,p())}))},300))}const{refId:F,left:P,right:k}=O(),N=j(F);if(!P&&!k)return c++,void(c<30&&(a=setTimeout(p,100)));const M=_||!P&&!!k,L=M?k:P,q=ne?M?Le.current:He.current:Ne.current;if(!L||!q)return c++,void(c<30&&(a=setTimeout(p,100)));const G=L.getBoundingClientRect();if(0===G.height)return c++,void(c<30&&(a=setTimeout(p,100)));const $=q.getBoundingClientRect(),V=G.top-$.top+q.scrollTop-$.height/2+G.height/2,H=R?.includes("-")||x?.includes("-"),z=async()=>{if(l)return;t();const e=L instanceof Element?window.getComputedStyle(L).color:"";[P,k].forEach(t=>{t&&(t.style.transition="box-shadow 300ms ease-in-out",t.style.boxShadow=`0 0 10px ${e}`)}),setTimeout(()=>{[P,k].forEach(e=>{e&&(e.style.boxShadow="")})},2e3);const n=r.evaluationResult?.deviations?.[o]||r,i=r.evaluationResult?.evaluation_outputs||r.evaluation_outputs;if(!(!!P&&!!k)&&!vt){const e=M?Nt.current[H?F:y]?.current||k:kt.current[H?F:v]?.current||P;return Bi(e,()=>{tt({open:!0,anchorEl:e,displayImpact:W.displayImpact,summary:{...n,evaluation_outputs:i}})},{skipScroll:!0}),void K?.()}const c=(e,t)=>Promise.race([e,new Promise(e=>setTimeout(e,t))]);ne&&await Promise.all([He.current?c(s.waitForScrollIdle(He.current),600):Promise.resolve(),Le.current?c(s.waitForScrollIdle(Le.current),600):Promise.resolve()]),vt&&(xe(vi(N)),pe(new Set([N]))),pn.current(N,!1,{toggleIfSame:!1,sourceSide:S?"right":"left",onReady:()=>{t();const e=M?Nt.current[F]?.current||k:kt.current[F]?.current||P;if(vt)setTimeout(()=>Ci(N),150);else{const e=kt.current[F]?.current||P,t=Nt.current[F]?.current||k;e&&(e.style.scrollMarginTop="150px",e.scrollIntoView({behavior:"smooth",block:"start"})),t&&(t.style.scrollMarginTop="150px",t.scrollIntoView({behavior:"smooth",block:"start"}))}tt({open:!0,anchorEl:e,displayImpact:W.displayImpact,summary:{...n}}),K?.()}})};Math.abs(q.scrollTop-V)<=2?z():s.scrollAndWait(q,V,z)};return a=setTimeout(p,100),()=>{l=!0,a&&clearTimeout(a),u?.()}},[W?.id,W?.trigger,W?.displayImpact,It,Ct,Et,ne,tt,Qn,vt,vi,Ci]),t.useEffect(()=>{if(!et.open)return;const e=et.anchorEl;if(!e)return;if(e.isConnected)return;const t=t=>{for(const[n,i]of Object.entries(t))if(i.current?.textContent===e.textContent)return n;return null},n=e.dataset?.deviationRefId||t(kt.current)||t(Nt.current);if(!n)return;const i=Nt.current[n]?.current||kt.current[n]?.current;i&&i.isConnected&&tt(e=>({...e,anchorEl:i}))},[et.open,et.anchorEl,me,fe,gn]);const{open:Fi,sectionIdx:Pi,isOrphan:ki,badgeStyle:Ni,anchorEl:Mi,sectionAnchorEl:Li}=Ke;t.useEffect(()=>{if(!$.isStreamingEnabled)return;if(!Fi||null==Pi)return;if(Pi===_n)return;const e="string"==typeof Pi?Pi.split(s.DEVIATION_BADGE_SEPARATOR)[0]:null,t=(e,n)=>{if(!e||!Array.isArray(e))return null;for(const i of e){if(i.id===n)return i;if(i.subsections?.length){const e=t(i.subsections,n);if(e)return e}}return null},n=e&&"string"==typeof e?t(Ct,e):null,i=e&&"string"==typeof e?t(Et,e):null,o="number"==typeof Pi?Ct[Pi]||null:n||e&&(k?.nodes?.[e]||k?.[e])||null,r="number"==typeof Pi?Et[Pi]||null:i,l=Un(Mi,o,r,Pi,ki,Ni);Ue(e=>{if(!e.open)return e;return s.safeStringify(e.cognitiveData)===s.safeStringify(l.cognitiveData)&&s.safeStringify(e.deviationData)===s.safeStringify(l.deviationData)&&e.sectionTitle===l.sectionTitle&&e.refSectionTitle===l.refSectionTitle?e:{...e,...l,open:!0,anchorEl:e.anchorEl,sectionAnchorEl:e.sectionAnchorEl}})},[Fi,Pi,ki,Ni,Mi,Li,Ct,Et,Un]);const qi=t.useCallback(({section:t,keyPath:n,depth:i=0,columnKey:o="left",parentNodeId:r="",sectionOffset:s,rhsOrphanVisualIndexes:l})=>e.jsx(v.default,{section:t,keyPath:n,depth:i,columnKey:o,parentNodeId:r,sectionOffset:s,rhsOrphanVisualIndexes:l}),[]),Gi=t.useMemo(()=>Ct.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&ne?null:e.jsx(y.default,{section:t,idx:n},t?.layoutKey??t?.id??`left-row-${n}`)}),[Ct,ne]),$i=t.useMemo(()=>Et.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&ne?null:e.jsx(b.default,{section:t,idx:n},t?.layoutKey??t?.id??`right-row-${n}`)}),[Et,ne]),Vi=t.useRef(Yn);t.useEffect(()=>{Vi.current=Yn},[Yn]);const Hi=t.useRef(gn);t.useEffect(()=>{Hi.current=gn},[gn]);const zi=t.useRef(wi);t.useEffect(()=>{zi.current=wi},[wi]);const Wi=t.useRef(Ai);t.useEffect(()=>{Wi.current=Ai},[Ai]);const Ki=t.useRef(xn);t.useEffect(()=>{Ki.current=xn},[xn]);const Ui=t.useRef(Rn);t.useEffect(()=>{Ui.current=Rn},[Rn]);const Yi=t.useRef(qi);t.useEffect(()=>{Yi.current=qi},[qi]);const Ji=t.useRef(dn);t.useEffect(()=>{Ji.current=dn},[dn]);const{cacheVersion:Xi,getCacheKey:Qi,getCacheEntry:Zi,fetchCitationContext:eo,prefetchCitationContexts:to,abortCitationContexts:no}=R.useOnDemandCitationCache(te),io=t.useMemo(()=>({isGuidelineMode:vt,maintainRelativeOrder:!!ne,showDeviationBadges:se,isProposingFix:U,proposingFixNodeId:Y,isRedlineFlow:J,isSideBySide:zt,activeSideBySideSection:Zt,scrollSyncLocked:me,toggleScrollSyncLocked:bn,summaryPopupAnchorEl:et.anchorEl,connectedSections:fe,proposedSections:Ct,existingSections:Et,deviationNumberRegistry:_t,deviationParentRegistry:Tt,treeData:k,displayConfig:$,resolvedMarkdownStyles:ke,unifiedNumbering:Cn,expandedSections:gn,expandedSubSections:mn,setExpandedSubSections:Sn,getSectionCompareStyle:ni,getSubSectionCompareStyle:ii,getBadgeRef:Ht,getSectionRowRef:$t,getSubSectionRef:Vt,sectionLeftRefs:Ft,sectionRightRefs:Pt,sectionRowRefs:Gt,sectionRightRowRefs:Mt,subSectionLeftRefs:Lt,subSectionRightRefs:qt,lhsBadgeRefs:kt,rhsBadgeRefs:Nt,openMoreFunctionsPopup:jn,handleOpenSummaryPopup:Fn,openSummaryPopup:Fn,handleCloseSummaryPopup:Pn,toggleSection:kn,handleSubSectionToggle:Nn,renderSubSectionAccordion:Mn,resetSideBySide:Ln,setConnectedSections:pe,setConnectedLines:he,cachedConnectedPositions:Te,showDeviationNavigation:_i,showOpenNodeRef:Ti,deviationNodeIdToView:W?.id,deviationTargetParentId:Di,guidelinesData:Q,gptWebCitationConfig:ee,onDemandCitationConfig:te,onDemandCitationCacheVersion:Xi,getOnDemandCitationCacheKey:Qi,getOnDemandCitationCacheEntry:Zi,fetchOnDemandCitationContext:eo,prefetchOnDemandCitationContexts:to,abortOnDemandCitationContexts:no}),[vt,ne,se,U,Y,J,zt,Zt,me,bn,et.anchorEl,fe,Ct,Et,_t,$,ke,Cn,gn,mn,Sn,ni,ii,Ht,$t,Vt,_i,Ti,W,Di,Q,ee,te,Xi,Qi,Zi,eo,to,no]),oo=s.safeStringify(Ke.sectionTitle||mt||gt),ro=s.safeStringify(vt?Rt||xt||Ke.refSectionTitle:Ke.refSectionTitle||Rt||xt);return e.jsx(E.CompareContextProvider,{value:io,children:e.jsxs(n.Box,{ref:Me,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"},children:[le&&e.jsx(n.Box,{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:e.jsx(d.default,{})}),et.open&&e.jsx(C.default,{open:et.open,anchorEl:et.anchorEl,containerEl:ei.current,clipTopEl:be.current,scrollContainerEl:Ne.current,onClose:Ai,summary:et.summary,displayImpact:et.displayImpact,isScrollLocked:me}),e.jsx(u.default,{open:Ye.open,anchorEl:Ye.anchorEl,maintainRelativeOrder:!!ne,sectionTitle:Ye.sectionTitle,referenceSectionTitle:Ye.refSectionTitle,onClose:ct,onOpenCognitiveCompare:rt,onOpenSideBySide:Ei,onConnect:Jn,isConnected:Ii,isOrphan:!vt&&!!Ye.isOrphan,isGuidelineMode:vt,hasGuidelineMatches:Ye.hasGuidelineMatches}),Ke.open&&e.jsx(a.default,{open:Ke.open,popupRef:ot,position:Xe,popupConfig:H,onClose:()=>{Qe(null),Ue(e=>({...e,open:!1})),it(null)},markdownStyles:q,sectionTitle:oo,referenceSectionTitle:ro,cognitiveData:Ke.cognitiveData,anchorEl:Ke.anchorEl,sectionAnchorEl:Ke.sectionAnchorEl,scrollContainerEl:Ne.current,badgeStyle:Ke.badgeStyle,docData:Ke.docData,deviationData:Ke.deviationData,isLoading:Ke.isLoading,sourceNodeId:Ke.sourceNodeId,deviationKey:Ke.deviationKey,baseContentId:Ke.baseContentId,compareContentIds:Ke.compareContentIds}),e.jsx(n.Snackbar,{open:!!ae,autoHideDuration:8e3,onClose:()=>ue(null),anchorOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(n.Alert,{onClose:()=>ue(null),severity:"error",sx:{width:"100%",whiteSpace:"pre-line"},children:ae})}),e.jsx(x.default,{componentHeaderText:P,displayConfig:$,maintainRelativeOrder:ne,onCollapseAll:pi,showCollapseAll:gi,onToggleView:e=>{ce(!0),setTimeout(()=>{ie(!e),V?.(!e),Se(!1),dn(),nt(),pe(new Set),he([]),Te.current=[],requestAnimationFrame(()=>{requestAnimationFrame(()=>{setTimeout(()=>{ce(!1)},600)})})},50)}}),e.jsx(n.Box,{ref:Ne,onScroll:fi,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:ne?"stretch":"flex-start",bgcolor:"#FFFFFF",overflowY:ne?"visible":"auto",borderTop:An&&In?"none":"1.5px solid #EEF0F4"},children:e.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px",minHeight:0,...ne?{flex:1}:{}},children:e.jsxs(n.Box,{ref:ye,sx:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0,...ne?{flex:1,overflow:"visible"}:{}},children:[e.jsx(B.default,{svgContainerRef:ve,svgDimensions:ai,isResizing:Yt,overallConnector:li,rootDeviationStyle:wn,lines:ri,isSideBySide:zt,activeSideBySideSection:Zt,isArrowVisible:Wt,maintainRelativeOrder:ne,proposedSections:Ct,existingSections:Et,cognitivePopup:Ke,activeBadgeId:Ze,closeCognitivePopup:lt,setActiveBadgeId:it,openCognitivePopupFromState:st,buildSectionPopupState:Un,connectedLines:ge,isGuidelineMode:vt,pathRefs:_e}),e.jsxs(n.Box,{sx:{border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",...ne?{flex:1,overflow:"visible",minHeight:0}:{}},children:[e.jsx(n.Box,{ref:be,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:e.jsx(n.Tooltip,{title:gt,placement:"top",children:e.jsx(n.Typography,{sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:gt})})}),e.jsxs(n.Box,{ref:He,onScroll:fi,sx:{p:"12px",display:"flex",flexDirection:"column",...ne?{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e.jsx("div",{ref:$e,style:{width:"100%",height:"0px",flexShrink:0}}),wt&&Gi,e.jsx("div",{ref:Ve,style:{width:"100%",height:"0px",flexShrink:0}})]})]}),e.jsx(n.Box,{ref:ei,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"},children:e.jsx(n.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0},children:e.jsxs(n.Box,{onClick:e=>{e.stopPropagation(),Ke.open&&Ze===_n?lt():(it(_n),st(Un(e.currentTarget,{title:Vn,content:"",evaluationResult:Tn,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},{title:zn,content:""},_n,!0,{...wn,label:""})))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:wn.badgeBg,color:wn.badgeText,border:`1px solid ${wn.badgeBorder}`,fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"},children:[Bn??e.jsx(f.default,{}),e.jsx(n.Box,{component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}},children:e.jsx(o.ButtonCognitiveIcon,{})}),e.jsx(i.ChevronDown,{size:11,style:{transform:Ke.open&&Ze===_n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]})})}),e.jsxs(n.Box,{sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0,...ne?{flex:1,overflow:"visible",minHeight:0}:{}},children:[Xt&&e.jsx(r.default,{sections:11}),e.jsx(n.Box,{ref:Ce,sx:{p:"8px",bgcolor:vt?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",flexShrink:0},children:vt?e.jsxs(n.Tabs,{value:Re,onChange:bi,variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}},children:[e.jsx(n.Tab,{label:e.jsx(n.Tooltip,{title:xt,placement:"top",children:e.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Redline Guidelines"})})}),Fe&&e.jsx(n.Tab,{label:e.jsx(n.Tooltip,{title:"Web & GPT Sources",placement:"top",children:e.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Web & GPT Sources"})})})]}):e.jsx(n.Tooltip,{title:xt,placement:"top",children:e.jsx(n.Typography,{sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:xt})})}),e.jsxs(n.Box,{ref:Le,onScroll:fi,sx:{p:vt?"0px":"12px",display:"flex",flexDirection:"column",...ne?{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e.jsx("div",{ref:qe,style:{width:"100%",height:"0px",flexShrink:0}}),vt?Q?0!==Re&&Fe?e.jsx(D.default,{deviationData:z,connectedSections:fe,proposedSections:Ct}):e.jsx(w.default,{guidelinesData:Q,deviationData:z,connectedSections:fe,proposedSections:Ct}):e.jsx(O.GuidelineSkeleton,{}):wt&&$i,e.jsx("div",{ref:Ge,style:{width:"100%",height:"0px",flexShrink:0}})]})]})]})})})]})})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@mui/material"),i=require("lucide-react"),o=require("../../assests/svg/ButtonCognitiveIcon.js"),r=require("./OverlayComponent.js"),s=require("./CognitiveComparehelpers.js"),l=require("./CognitiveCompareConfig.js"),c=require("./CognitiveCompareConstants.js"),a=require("./CognitivePopup.js"),u=require("./MoreFunctionsPopup.js"),d=require("./LoaderComponent.js"),f=require("./components/ThreeDotsLoader.js"),p=require("./hooks/useCompareData.js"),g=require("./hooks/useComparePopups.js"),h=require("./hooks/useSectionRefs.js"),m=require("./hooks/useAccordionState.js"),S=require("./hooks/useDeviationNavigation.js"),x=require("./components/CompareHeader.js"),R=require("./components/SubSectionAccordion.js"),v=require("./components/LHSSectionRow.js"),y=require("./components/RHSSectionRow.js"),b=require("./components/CognitiveSummaryPopup.js"),C=require("./CompareContext.js"),E=require("./hooks/useStyles.js"),A=require("./hooks/useResizeHandler.js"),_=require("./hooks/useLinesCalculator.js"),T=require("./hooks/useSideBySide.js"),I=require("./components/SvgConnectors.js"),w=require("./Guidelines/components/GuidelinePanel.js"),B=require("./Guidelines/components/WebGptPanel.js");exports.SHARED_MARKDOWN_STYLES=l.SHARED_MARKDOWN_STYLES,exports.default=({componentHeaderText:D=c.DEFAULT_COMPONENT_HEADER_TEXT,treeData:O,comparisonConfig:F,leftColumnTitleText:j,rightColumnTitleText:P,markdownStyles:k,resetTrigger:N,displayConfig:M={isHeaderVisible:!0,isToggleVisible:!0,maintainRelativeOrder:!1,isLoading:!0,showDeviationBadges:!1,enableDeviationSchemaBackwardCompatibility:!1,displayEmailNotifier:!0,isStreamingEnabled:!1},deviationAnalysisStatus:L,onMaintainRelativeOrderChange:q,popupConfig:$,deviationData:H={},deviationNodeIdToView:G,resetDeviationNodeId:V,isProposingFix:W=!1,proposingFixNodeId:z,isRedlineFlow:K,badgeStyleOverride:U,guidelinesData:Y,gptWebCitationConfig:J})=>{const[X,Q]=t.useState(M.maintainRelativeOrder),Z=M?.expandLevels??0,ee=!!M?.expandAllSections,te=!!X||!!M?.showDeviationBadges,[ne,ie]=t.useState(!1),[oe,re]=t.useState(null),[se]=t.useState(O?.newEvaluationResult??M?.enableDeviationSchemaBackwardCompatibility??!0),[le,ce]=t.useState(new Set),[ae,ue]=t.useState([]),[de,fe]=t.useState(!1),[pe,ge]=t.useState(0),he=L??(M?.isLoading?"deviations_streaming":"complete"),me="mapping_ready"===he||"deviations_streaming"===he,Se=t.useRef(null),xe=t.useRef(null),Re=t.useRef(null),ve=t.useRef(null),ye=t.useRef(null),be=t.useRef(!1),Ce=t.useRef(null),Ee=t.useRef({}),Ae=t.useRef([]),_e=t.useRef(()=>{}),Te=t.useRef(null),Ie=t.useRef(()=>{}),we=t.useMemo(()=>JSON.stringify(H||{}),[JSON.stringify(H)]),Be=t.useMemo(()=>H||{},[we]),De=t.useMemo(()=>O?.cognitive_decisioning||{},[O]),Oe=t.useMemo(()=>({...l.SHARED_MARKDOWN_STYLES,...k}),[k]),Fe=t.useRef(null),je=t.useRef(null),Pe=t.useRef(null),ke=t.useRef(null),Ne=t.useRef(null),Me=t.useRef(null),Le=t.useRef(null),qe=t.useRef(null),$e=t.useRef(null),He=t.useRef(null),{cognitivePopup:Ge,setCognitivePopup:Ve,moreFunctions:We,setMoreFunctions:ze,position:Ke,setPosition:Ue,activeBadgeId:Ye,summaryPopup:Je,setSummaryPopup:Xe,closeSummaryPopup:Qe,setActiveBadgeId:Ze,popupRef:et,handleOpenCognitiveCompare:tt,openCognitivePopupFromState:nt,closeCognitivePopup:it,closeMoreFunctionsPopup:ot}=g.useComparePopups(Fe),rt=t.useMemo(()=>({fields:F?.fields??l.DEFAULT_FIELD_CONFIG,thresholds:{high:F?.thresholds?.high??l.DEFAULT_COMPARISON_CONFIG.thresholds.high,medium:F?.thresholds?.medium??l.DEFAULT_COMPARISON_CONFIG.thresholds.medium,exact:F?.thresholds?.exact??l.DEFAULT_COMPARISON_CONFIG.thresholds.exact}}),[F]),[st,lt]=t.useState(null),ct=O?.documents?.[O?.input_index_map?.[0]]?.title,at=O?.documents?.[O?.input_index_map?.[1]]?.title,ut=s.safeStringify(j||ct||"Uploaded Contract"),dt=O?.documents?.[O?.input_index_map?.[0]]?.metadata?.file_name,ft=s.safeStringify(dt),pt=O?.documents?.[O?.input_index_map?.[1]]?.metadata?.file_name,gt=s.safeStringify(pt),ht=s.safeStringify(P||at||"Reference Template"),{isGuidelineMode:mt,activeProposed:St,existingRule:xt,proposedSections:Rt,existingSections:vt,visibleFields:yt,parentDeviationRecord:bt,deviationNumberRegistry:Ct,deviationParentRegistry:Et,parseError:At}=p.useCognitiveTreeData(O,X,Be,rt,se,Y);t.useEffect(()=>{At&&re(`Failed to load comparison: ${At}`)},[At]);const _t=Rt.length>0||vt.length>0,Tt=t.useMemo(()=>{if(!K)return"off";let e=0,t=0;const n=i=>{Array.isArray(i)&&i.forEach(i=>{const o=i?.content||"";s.hasMeaningfulRedlineTags(o)&&(e+=1,t+=String(o).length),i?.subsections?.length&&n(i.subsections)})};return n(Rt),n(vt),`${e}:${t}`},[K,Rt,vt]);t.useEffect(()=>{if(Rt.length||vt.length)if(ee){const e={},t={},n=(n,i)=>{n.forEach((n,o)=>{const r=X?`${i}-${o}`:String(o);e[r]=!0;const s=(e,n)=>{e?.forEach((e,i)=>{const o=`${n}-${i}`;t[o]=!0,e.subsections?.length&&s(e.subsections,o)})};n.subsections?.length&&s(n.subsections,String(o))})};n(Rt,"left"),n(vt,"right"),dn(e),pn(t)}else if(Z>0){const e={},t={},n=(n,i,o)=>{n.forEach((n,r)=>{if(o>=1){const t=X?`${i}-${r}`:String(r);e[t]=!0}const s=(e,n,i)=>{i>o||e?.forEach((e,o)=>{const r=`${n}-${o}`;t[r]=!0,e.subsections?.length&&s(e.subsections,r,i+1)})};n.subsections?.length&&o>=2&&s(n.subsections,String(r),2)})};n(Rt,"left",Z),n(vt,"right",Z),dn(e),pn(t)}},[ee,Z,Rt,vt,X]);const{leftRefs:It,rightRefs:wt,sectionLeftRefs:Bt,sectionRightRefs:Dt,lhsBadgeRefs:Ot,rhsBadgeRefs:Ft,sectionRightRowRefs:jt,subSectionLeftRefs:Pt,subSectionRightRefs:kt,sectionRowRefs:Nt,getSectionRowRef:Mt,getSubSectionRef:Lt,getBadgeRef:qt}=h.useSectionRefs(yt.map(({key:e})=>e),Math.max(Rt.length,vt.length)),{isSideBySide:$t,isArrowVisible:Ht,setIsSideBySide:Gt,setIsArrowVisible:Vt,isResizing:Wt,setIsResizing:zt,isSideBySideLoading:Kt,setIsSideBySideLoading:Ut,activeSideBySideSection:Yt,setActiveSideBySideSection:Jt,scrollLock:Xt,sideBySideCacheRef:Qt,isSideBySideRef:Zt,activeSideBySideRightSectionRef:en,activeSideBySideSectionRef:tn,sideBySideLineRef:nn,highlightedClauseRefs:on,clearClauseHighlight:rn,applyAlignmentPadding:sn,resetSideBySide:ln,activateSideBySide:cn}=T.useSideBySide({isGuidelineMode:mt,maintainRelativeOrder:X,proposedSections:Rt,existingSections:vt,leftContainerRef:qe,rightContainerRef:Pe,scrollContainerRef:Fe,sectionLeftRefs:Bt,sectionRightRefs:Dt,subSectionLeftRefs:Pt,subSectionRightRefs:kt,lhsBadgeRefs:Ot,rhsBadgeRefs:Ft,sectionRowRefs:Nt,sectionRightRowRefs:jt,rhsTopSpacerRef:ke,rhsBottomSpacerRef:Ne,lhsTopSpacerRef:Me,lhsBottomSpacerRef:Le,calculateLinesRef:_e,setConnectedSections:ce,setConnectedLines:ue,cachedConnectedPositions:Ae,closeMoreFunctionsPopup:ot,setErrorToast:re,moreFunctions:We,closeSummaryPopup:Qe}),an=t.useRef(cn);t.useEffect(()=>{an.current=cn},[cn]);const{expandedSections:un,setExpandedSections:dn,expandedSubSections:fn,setExpandedSubSections:pn,handleSubSectionToggle:gn,toggleSection:hn,forceExpandCrossWiredSections:mn}=m.useAccordionState({maintainRelativeOrder:!!X,proposedSections:Rt,existingSections:vt,activeSideBySideSection:Yt,connectedSections:le,resetSideBySide:ln,setConnectedSections:ce,setConnectedLines:ue,cachedConnectedPositions:Ae,svgContainerRef:Se,isAnimatingRef:be,animationTimerRef:Ce,calculateLinesRef:_e,sectionLeftRefs:Bt,sectionRightRefs:Dt,subSectionLeftRefs:Pt,subSectionRightRefs:kt}),Sn=()=>{if(null==Yt)return;const e=Bt.current[Yt]?.current,t=Dt.current[Yt]?.current,n=Pe.current;if(!e||!t||!n)return;const i=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.top-r.top,l=o.top-r.top-s;n.scrollBy({top:l,behavior:"smooth"})},xn=t.useCallback(e=>{e?.stopPropagation(),fe(e=>{const t=!e;return t&&requestAnimationFrame(()=>{Sn()}),t})},[Sn]);t.useEffect(()=>{K&&"off"!==Tt&&"0:0"!==Tt&&(Qt.current=null,Ae.current=[],requestAnimationFrame(()=>{_e.current?.()}))},[K,Tt]);const Rn=t.useMemo(()=>{const e=new Map,t=new Map;let n=1;if(X)Rt.forEach(t=>{!t.title&&!t.content||t.id&&e.set(t.id,n++)}),vt.forEach(i=>{if(!i.id)return;if(!i.title&&!i.content)return;const o=Rt.filter(e=>e.refIndexes?.includes(i.selfIndex));if(o.length>0){const n=o.map(t=>e.get(t.id)).filter(Boolean);t.set(i.id,n.join(", "))}else t.set(i.id,String(n++))});else{const i=Math.max(Rt.length,vt.length);for(let o=0;o<i;o++){const i=Rt[o],r=vt[o];i?(e.set(i.id,n),r&&t.set(r.id,String(n)),n++):r&&t.set(r.id,String(n++))}}return{leftNums:e,rightNums:t}},[Rt,vt,X]),vn=xt.analysis,yn=s.safeStringify(vn?.rule_difference_comparison?.summary?.overall_summary),bn=!!yn.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/i),Cn=O?.base_root_id??"-1",En=se?(H&&H?.[Cn]?.evaluation_result)??O?.nodes?.[Cn]?.evaluation_result??null:(H&&H?.[Cn]?.evaluation_result?.[0])??O?.nodes?.[Cn]?.evaluation_result?.[0]??null,An=s.extractDeviationScore(En),_n=me&&null==En,Tn=_n?null:An??("complete"===he&&null==En?"Same":null);let In=s.generateColorPalette(En?.evaluation_outputs?.metadata?.label_color??c.DEFAULT_DEVIAION_COLOR);if(U){const e=U(An);e&&(In={...In,badgeBg:e.bg,badgeText:e.text,badgeBorder:e.border})}const wn=t.useRef(ln);t.useEffect(()=>{wn.current=ln},[ln]);const Bn=t.useRef(it);t.useEffect(()=>{Bn.current=it},[it]);const Dn=t.useCallback((e,t,n,i,o,r)=>Mi.current(e,t,n,i,o,r),[]),On=t.useCallback((e,t,n,i,o)=>qi.current(e,t,n,i,o),[]),Fn=t.useCallback(()=>$i.current(),[]),jn=t.useCallback((e,t)=>Hi.current(e,t),[]),Pn=t.useCallback(e=>Gi.current(e),[]),kn=t.useCallback(e=>Vi.current(e),[]),Nn=t.useCallback(()=>Wi.current(),[]),Mn=t.useCallback(()=>{rn(),wn.current?.(),fe(!1),ce(new Set),ue([]),Ae.current=[],ii([]),ri(null),Xe(c.EMPTY_SUMMARY_POPUP_STATE),Bn.current?.(),requestAnimationFrame(()=>{_e.current?.()})},[]),Ln=t.useRef(Mn);t.useEffect(()=>{Ln.current=Mn},[Mn]),t.useEffect(()=>{N&&Ln.current()},[N]);const qn=t.useMemo(()=>({documents:O?.documents,input_index_map:O?.input_index_map}),[JSON.stringify(O?.documents),JSON.stringify(O?.input_index_map)]),[$n,Hn]=t.useState(""),Gn=t.useRef(O);t.useEffect(()=>{Gn.current=O;const e=O?.input_index_map?.[0],t=O?.documents?.[e]?.title;Hn(t)},[O]);const Vn=t.useRef(De);t.useEffect(()=>{Vn.current=De},[De]);const Wn=t.useCallback((e,t,n,i,o,r,l)=>{const c=s.safeStringify(t?.id)||s.safeStringify(n?.id)||"",a=(c?Vn.current?.[c]:null)||t?.cognitiveData||n?.cognitiveData||{section_id:c,decisioning:[],gap:[],relevance_score:0},u=Nt.current[i]?.current??null,d=(()=>{const e=t?.evaluationResult||n?.evaluationResult||null,o=e=>{const t=(e=>{if(!e||"object"!=typeof e)return null;const t=e?.deviation_entries;if(t&&"object"==typeof t){const e=Object.keys(t).sort((e,t)=>Number(e)-Number(t))[0];if(e&&t[e])return t[e]}const n=Object.keys(e).filter(e=>/^\d+$/.test(e)).sort((e,t)=>Number(e)-Number(t));if(n.length&&e[n[0]])return e[n[0]];const i=e?.deviations;if(i&&"object"==typeof i){const e=Object.keys(i).sort((e,t)=>Number(e)-Number(t))[0];if(e&&i[e])return i[e]}return null})(e);return t?{...e,deviation_summary:e?.deviation_summary||t?.deviation_summary,deviation_title:e?.deviation_title||t?.deviation_title,deviation_impact:e?.deviation_impact||t?.deviation_impact,deviation_explanation:e?.deviation_explanation||t?.deviation_explanation,evaluation_outputs:e?.evaluation_outputs||t?.evaluation_outputs,cognitive_decisioning:e?.cognitive_decisioning||t?.cognitive_decisioning}:e};if(!("string"==typeof i&&i.includes(s.DEVIATION_BADGE_SEPARATOR)))return o(e);const r=i.split(s.DEVIATION_BADGE_SEPARATOR)[1];if(!r)return e;const l=t?.evaluationResult||n?.evaluationResult||{},c=l?.deviation_entries?.[r]||l?.deviations?.[r]||null;return c?{...l,...c,deviation_summary:c?.deviation_summary||l?.deviation_summary,deviation_title:c?.deviation_title||l?.deviation_title,deviation_impact:c?.deviation_impact||l?.deviation_impact,deviation_explanation:c?.deviation_explanation||l?.deviation_explanation,evaluation_outputs:c?.evaluation_outputs||l?.evaluation_outputs,cognitive_decisioning:c?.cognitive_decisioning||l?.cognitive_decisioning}:o(e)})(),f=(d?.cognitive_decisioning?.decisioning_factors?.length??0)>0||(d?.cognitive_decisioning?.gaps_in_decision?.length??0)>0,p=me;let g=!0;if(mt){const e=d?.deviation_highlights;if(e&&"object"==typeof e){g=Object.values(e).some(e=>Array.isArray(e)&&e.length>0)}else g=!1}return{isLoading:p&&!f,open:!0,sectionTitle:t?.title?t?.title:"No Counterpart",refSectionTitle:n?.title?n?.title:"No Counterpart",cognitiveData:a,anchorEl:e,sectionAnchorEl:u,badgeStyle:r||null,sectionIdx:i,docData:qn,deviationData:d,isOrphan:!!o,hasGuidelineMatches:g}},[qn,me,mt]),zn=t.useCallback((e,t,n,i,o,r)=>{if(e.stopPropagation(),We.open&&We.sectionIdx===o)return void ot();const l=e.currentTarget;let c="left";Pe.current?.contains(l)&&(c="right");rn(),Zt.current&&ln(),ce(new Set),ue([]),Ae.current=[],it(),Je.open?vi():Qe(),requestAnimationFrame(()=>{const e=(()=>{if("string"==typeof o&&o.includes(s.DEVIATION_BADGE_SEPARATOR)){const e=o.split(s.DEVIATION_BADGE_SEPARATOR),t=`${e[0]}${s.DEVIATION_BADGE_SEPARATOR}${e[1]}`;return"right"===c?Ft.current[t]?.current:Ot.current[t]?.current}return"right"===c?Ft.current[o]?.current:Ot.current[o]?.current})()||l;ze(Wn(e,t,i,o,n,r))})},[We.open,We.sectionIdx,ot,Qe,Wn]),Kn=t.useCallback(()=>{const e=We.sectionIdx;We.isOrphan,ot(),Qe(),null!==e&&(mn(e),rn(),Zt.current&&ln(),ue([]),Ae.current=[],mt&&null!==e&&ge(Si(e)),ce(t=>t.has(e)?new Set:new Set([e])),setTimeout(()=>{_e.current&&_e.current()},50))},[We.sectionIdx,We.isOrphan,ot,Qe,ln]),Un=t.useCallback(()=>{const e=ye.current;if(!e)return;ye.current=null;const t=Rt.findIndex(t=>t.id===e),n=vt.findIndex(t=>t.id===e),i=-1===t?s.findKeyPathByNodeId(Rt,e):null,o=-1===n?s.findKeyPathByNodeId(vt,e):null,r=-1!==t?t:i?Number(i.split("-")[0]):-1,l=-1!==n?n:o?Number(o.split("-")[0]):-1,c=(e,t,n,i)=>-1!==e?n.current[e]?.current??null:t?i.current[t]?.current??null:null,a=(e,t,n=30)=>{let i=0;const o=()=>{const r=e();r&&0!==r.getBoundingClientRect().height?(on.current.add(r),s.scrollAndHighlightClause(r,t)):i++<n&&requestAnimationFrame(o)};requestAnimationFrame(o)};if(X)-1!==r&&qe.current&&a(()=>c(t,i,Bt,Pt),qe.current),-1!==l&&Pe.current&&a(()=>c(n,o,Dt,kt),Pe.current);else{const e=Fe.current;if(!e)return;a(()=>-1!==r?c(t,i,Bt,Pt):c(n,o,Dt,kt),e)}},[Rt,vt,X,Bt,Dt,Pt,kt,qe,Pe,Fe]),Yn=t.useCallback(e=>{if(!e)return;rn(),ln(),ce(new Set),ue([]),Ae.current=[],Qe(),it();const t=Rt.findIndex(t=>t.id===e),n=vt.findIndex(t=>t.id===e),i=-1===t?s.findKeyPathByNodeId(Rt,e):null,o=-1===n?s.findKeyPathByNodeId(vt,e):null;if(-1===t&&!i&&-1===n&&!o)return void console.warn(`scrollToAndHighlightClause: nodeId "${e}" not found`);const r=-1!==t?t:i?Number(i.split("-")[0]):-1,l=-1!==n?n:o?Number(o.split("-")[0]):-1;ye.current=e,dn(e=>{const t={...e};let n=!1;if(-1!==r){const e=X?`left-${r}`:String(r);t[e]||(t[e]=!0,n=!0)}if(-1!==l){const e=X?`right-${l}`:String(l);t[e]||(t[e]=!0,n=!0)}return n?t:e}),pn(e=>{const t={...e};let n=!1;const r=e=>{const i=e.split("-");let o=i[0];for(let e=1;e<i.length;e++)o+=`-${i[e]}`,t[o]||(t[o]=!0,n=!0)};return i&&r(i),o&&r(o),n?t:e}),setTimeout(()=>{requestAnimationFrame(()=>{ye.current===e&&Jn.current()})},50)},[Rt,vt,X,dn,pn,ln,Qe,it]),Jn=t.useRef(Un);t.useEffect(()=>{Jn.current=Un},[Un]);const Xn=t.useRef(null);t.useEffect(()=>{if(st){const e=rt.fields.find(e=>e.analysisKey===st||e.key===st);if(e){const t=It.current[e.key]||wt.current[e.key];t?.current&&setTimeout(()=>t.current.scrollIntoView({behavior:"smooth",block:"center"}),150)}}},[st,rt.fields]);const Qn=t.useCallback(e=>{const t=vn?.rule_difference_comparison?.fields;if(!t||!t[e])return{score:0,relation:"",highlightsA:[],highlightsB:[],hasContent:!1};const n=t[e],i=n?.relation||n?.highlights?.ruleA_spans?.length||n?.highlights?.ruleB_spans?.length||n?.mappings&&n.mappings.length>0;if(n.mappings){const e=n.mappings[0]||{};return{score:n.score,relation:e.relation||"",highlightsA:e.highlights?.ruleA_spans||[],highlightsB:e.highlights?.ruleB_spans||[],hasContent:!!i}}return{score:n.score,relation:n.relation||"",highlightsA:n.highlights?.ruleA_spans||[],highlightsB:n.highlights?.ruleB_spans||[],hasContent:!!i}},[vn]),{getSectionCompareStyle:Zn,getSubSectionCompareStyle:ei,getDeviationStyleByKey:ti}=E.useStyleHelpers({proposedSections:Rt,existingSections:vt,maintainRelativeOrder:X,cognitiveMap:De,deviationData:Be,treeData:O,resolvedComparisonConfig:rt,badgeStyleOverride:U}),{lines:ni,setLines:ii,overallConnector:oi,setOverallConnector:ri,svgDimensions:si,calculateLines:li,calculateLinesDebounced:ci,handleColumnScroll:ai}=_.useLinesCalculator({containerRef:xe,leftContainerRef:qe,rightContainerRef:Pe,svgContainerRef:Se,pathRefs:Ee,leftHeaderRef:Re,rightHeaderRef:ve,proposedSections:Rt,existingSections:vt,visibleFields:yt,leftRefs:It,rightRefs:wt,sectionLeftRefs:Bt,sectionRightRefs:Dt,subSectionLeftRefs:Pt,subSectionRightRefs:kt,lhsBadgeRefs:Ot,rhsBadgeRefs:Ft,sectionRowRefs:Nt,expandedSections:un,expandedSubSections:fn,connectedSections:le,isSideBySide:$t,activeSideBySideSection:Yt,maintainRelativeOrder:X,isGuidelineMode:mt,cognitiveMap:De,getSectionCompareStyle:Zn,getSubSectionCompareStyle:ei,getDeviationStyleByKey:ti,isArrowVisible:Ht,isAnimatingRef:be,isSideBySideRef:Zt,sideBySideCacheRef:Qt,sideBySideLineRef:nn,activeSideBySideSectionRef:tn,activeSideBySideRightSectionRef:en,connectedLines:ae,setConnectedLines:ue,cachedConnectedPositions:Ae,calculateLinesRef:_e,resizeTimerRef:Te,scrollLock:Xt,scrollSyncLocked:de,handleResizeRef:Ie,activeProposed:St,existingRule:xt,analysisData:vn,pendingScrollTargetRef:$e,pendingScrollCallbackRef:He,resolvedComparisonConfig:rt,getFieldData:Qn});t.useEffect(()=>{Je.anchorEl&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{_e.current?.()})})},[Je.anchorEl,de]);const ui=t.useCallback(()=>{rn(),fe(!1),dn({}),pn({}),ln(),ce(new Set),ue([]),Ae.current=[],Qe(),it(),ot(),requestAnimationFrame(()=>{_e.current&&_e.current()})},[dn,pn,ln,Qe,it,ot]);t.useEffect(()=>{$t||0!==le.size||fe(!1)},[$t,le]);const di=t.useMemo(()=>Object.values(un).some(Boolean)||Object.values(fn).some(Boolean),[un,fn]),fi=t.useRef(null),pi=t.useRef(0),gi=t.useRef(0),hi=t.useRef(0),{handleResize:mi}=A.useResizeHandler({timerRef:fi,ruleComponentRef:je,scrollContainerRef:Fe,containerRef:xe,maintainRelativeOrder:X,proposedSections:Rt,existingSections:vt,isSideBySideRef:Zt,activeSideBySideSectionRef:tn,activeSideBySideRightSectionRef:en,sectionRowRefs:Nt,sectionRightRowRefs:jt,sectionLeftRefs:Bt,sectionRightRefs:Dt,subSectionLeftRefs:Pt,subSectionRightRefs:kt,lhsBadgeRefs:Ot,rhsBadgeRefs:Ft,leftContainerRef:qe,rightContainerRef:Pe,calculateLinesRef:_e,handleResizeRef:Ie,setIsResizing:zt,setIsArrowVisible:Vt,sideBySideCacheRef:Qt,cachedConnectedPositions:Ae});t.useEffect(()=>{Ie.current=mi},[mi,Ie]),t.useEffect(()=>{const e=(e,t,n,i,o)=>{t.current=e.getBoundingClientRect().width;const r=new ResizeObserver(e=>{null!==n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{n.current=null;const r=e[e.length-1];if(!r)return;const s=r.borderBoxSize?.[0]?.inlineSize??r.contentRect.width;Math.abs(s-t.current)<1?o():(t.current=s,i())})});return r.observe(e),r},t={current:null},n={current:null},i={current:null},o=[],r=[t,n,i];return je.current&&o.push(e(je.current,pi,t,()=>Ie.current(),()=>{})),Fe.current&&o.push(e(Fe.current,gi,n,()=>Ie.current(),()=>_e.current())),xe.current&&o.push(e(xe.current,hi,i,()=>Ie.current(),()=>_e.current())),()=>{o.forEach(e=>e.disconnect()),r.forEach(e=>{null!==e.current&&(cancelAnimationFrame(e.current),e.current=null)})}},[]),t.useEffect(()=>{Zt.current=$t},[$t]),t.useEffect(()=>{tn.current=Yt},[Yt]);const Si=t.useCallback(e=>{let t="",n="0";if("number"==typeof e)t=Rt[e]?.nodeId||Rt[e]?.id||"";else{const i=String(e).split(s.DEVIATION_BADGE_SEPARATOR);t=i[0],n=i[1]||"0"}const i=Be?.[t]?.evaluation_result,o=Array.isArray(i)?i[parseInt(n,10)]:i?.[n];return!1===o?.evaluation_outputs?.guideline_flag?.rulebook_used?1:0},[Rt,Be]),xi=t.useCallback(e=>{const t=document.querySelectorAll('[id^="guideline-target-"], [data-web-gpt-active="true"]'),n=qe.current,i=Pe.current,o="string"==typeof e&&e.includes(s.DEVIATION_BADGE_SEPARATOR);let r=e;if(o){const t=e.split(s.DEVIATION_BADGE_SEPARATOR);t.length>=2&&(r=`${t[0]}${s.DEVIATION_BADGE_SEPARATOR}${t[1]}`)}const l=Ot.current[r]?.current||Ot.current[e]?.current;if(t.length>0&&l&&n&&i){const e=t[0];Me.current&&(Me.current.style.height="0px"),ke.current&&(ke.current.style.height="0px"),Le.current&&(Le.current.style.height="0px"),Ne.current&&(Ne.current.style.height="0px"),requestAnimationFrame(()=>{const t=l.getBoundingClientRect(),o=e.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.getBoundingClientRect(),c=n.scrollTop+(t.top-r.top)+t.height/2,a=i.scrollTop+(o.top-s.top)+o.height/2,u=c-r.height/2,d=Math.max(0,u),f=n.scrollHeight-n.clientHeight,p=d>f?d-f:0,g=r.top+c-d;let h=s.top+a-g,m=0;h<0&&(m=Math.abs(h),h=0);const S=i.scrollHeight-i.clientHeight+m,x=h>S?h-S:0;Le.current&&(Le.current.style.height=`${p}px`),ke.current&&(ke.current.style.height=`${m}px`),Ne.current&&(Ne.current.style.height=`${x}px`),requestAnimationFrame(()=>{n.scrollTo({top:d,behavior:"smooth"}),i.scrollTo({top:h,behavior:"smooth"}),_e.current&&setTimeout(()=>_e.current(),50)})})}},[s.DEVIATION_BADGE_SEPARATOR]),Ri=t.useCallback(()=>{const e=We.sectionIdx,t=We.isOrphan;if(Qe(),null==e)return;let n="left";We.anchorEl&&Pe.current?.contains(We.anchorEl)&&(n="right"),mn(e),mt&&(ge(Si(e)),ce(new Set([e]))),cn(e,t,{sourceSide:n,onReady:()=>{mt&&setTimeout(()=>xi(String(e)),150)}})},[cn,We.isOrphan,We.sectionIdx,We.anchorEl,Qe,mn,mt,xi,Si]),vi=t.useCallback(()=>{Qe(),ln(),ce(new Set),ue([]),Ae.current=[]},[Qe,ln]),yi=null!==We.sectionIdx&&le.has(We.sectionIdx),{showDeviationNavigation:bi,showOpenNodeRef:Ci,adjustScrollForPopup:Ei}=S.useDeviationNavigation({proposedSections:Rt,existingSections:vt,parentDeviationRecord:bt,expandedSections:un,maintainRelativeOrder:!!X,scrollContainerRef:Fe,leftContainerRef:qe,rightContainerRef:Pe,lhsBadgeRefs:Ot,rhsBadgeRefs:Ft}),Ai=t.useCallback((e,t,n,i,o)=>{const r="string"==typeof i?s.safeStringify(i).trim():s.safeStringify(i?.deviation_summary).trim(),l=e.currentTarget;it();let c="left";Pe.current?.contains(l)&&(c="right");const a=()=>{if("string"==typeof t&&t.includes(s.DEVIATION_BADGE_SEPARATOR)){const e=t.split(s.DEVIATION_BADGE_SEPARATOR),n=`${e[0]}${s.DEVIATION_BADGE_SEPARATOR}${e[1]}`;return"right"===c?Ft.current[n]?.current:Ot.current[n]?.current}return"right"===c?Ft.current[t]?.current:Ot.current[t]?.current};if(n&&!mt)return ln(),ce(new Set),ue([]),Ae.current=[],void(r&&(mn(t),requestAnimationFrame(()=>{const e=a()||l;if(e){e.getBoundingClientRect().top>.8*window.innerHeight&&e.scrollIntoView({behavior:"smooth",block:"center"})}Xe({open:!0,anchorEl:e,summary:i,displayImpact:o})})));mn(t),mt&&(ge(Si(t)),ce(new Set([t]))),r?setTimeout(()=>{cn(t,n,{toggleIfSame:!1,sourceSide:c,onReady:()=>{const e=a()||l;if(mt)setTimeout(()=>xi(t),150);else if(e){const t=e.getBoundingClientRect();if(t.top>.8*window.innerHeight||t.top<100){const e=t.top-window.innerHeight/2;X?(qe.current?.scrollBy({top:e,behavior:"smooth"}),Pe.current?.scrollBy({top:e,behavior:"smooth"})):Fe.current?.scrollBy({top:e,behavior:"smooth"})}}Xe({open:!0,anchorEl:e,summary:i,displayImpact:o})}})},350):setTimeout(()=>{cn(t,n,{toggleIfSame:!1,sourceSide:c}),mt&&setTimeout(()=>xi(t),150)},350)},[cn,it,Xe,ln,mn,mt,X,xi,Be]),_i=t.useMemo(()=>{if(!G)return null;const e=G?.id?.split(":")[0];for(const t in bt){if((bt[t]||[]).some(t=>t.id===e))return t}return null},[G,bt]),Ti=t.useRef({id:null,triggerMs:null}),Ii=t.useRef(null);t.useEffect(()=>{if(!G?.id)return;const e=Number(G.trigger),t=Ti.current;if(t?.id===G.id&&t?.triggerMs===e)return;if(!(G.id.includes(":")&&/:\d+$/.test(G.id))){Ti.current={id:G.id,triggerMs:e},Yn(G.id);const t=Rt.findIndex(e=>e.id===G.id),n=vt.findIndex(e=>e.id===G.id);return void(-1===t&&-1===n||setTimeout(()=>{const e=-1!==t?t:n,i=-1===t;mt&&ge(Si(e)),ce(new Set([e])),an.current(e,i,{sourceSide:i?"right":"left",onReady:()=>{mt&&setTimeout(()=>xi(String(e)),150)}})},400))}const[n,i]=G.id.split(":"),o=i??"0",r=`${G.id}:${e}`;Ii.current!==r&&(Qe(),it(),ln(),ce(new Set),ue([]),Ae.current=[],Ii.current=r);let l=!1,c=0;let a=null,u=null,d=!1;const f=(e,t)=>{const n=(e,i)=>{if(!e)return null;if(t.includes(e.id)||t.includes(e.nodeId)||t.includes(e.contentId))return i;if(!Array.isArray(e.subsections))return null;for(let t=0;t<e.subsections.length;t++){const o=n(e.subsections[t],`${i}-${t}`);if(o)return o}return null};for(let t=0;t<e.length;t++){const i=n(e[t],String(t));if(i)return i}return null},p=()=>{if(l)return;const t=()=>{Ti.current={id:G.id,triggerMs:e}};let i=null,r=null;for(const e in bt){const t=bt[e].find(e=>e.id===n||e.nodeId===n||e.contentId===n||e.evaluationResult?.nodeId===n);if(t){i=e,r=t;break}}if(!r||!i)return c++,void(c<30&&(a=setTimeout(p,100)));const g=Array.from(new Set([n,r.id,r.nodeId,r.contentId,r.evaluationResult?.nodeId].filter(Boolean))),h=Rt.findIndex(e=>e.id===i),m=vt.findIndex(e=>e.id===i),S=-1===h&&-1!==m,x=f(Rt,g);let R=f(vt,g);if(x&&!R&&!S){const e=x.split("-");let t=Number(e[0]);if(X){const e=Rt[t]?.refIndexes?.[0],n=vt.findIndex(t=>t.selfIndex===e);-1!==n&&(t=n)}R=[t,...e.slice(1)].join("-")}if(!x&&!R)return c++,void(c<30&&(a=setTimeout(p,100)));const v=x?Number(x.split("-")[0]):h,y=R?Number(R.split("-")[0]):m,b=y>=0?y:R?Number(R.split("-")[0]):-1,C=Rt[v],E=vt[b],A=C&&!C.title&&!C.content,_=E&&!E.title&&!E.content,T=S||(!x&&!!R||A&&!_);if(T){if(!(X?!!Li.current[`right-${y}`]:!!Li.current[String(y)])&&y>=0)return hn(y,"right"),void(a=setTimeout(p,200))}else{if(!(X?!!Li.current[`left-${v}`]:!!Li.current[String(v)])&&v>=0)return hn(v,"left"),void(a=setTimeout(p,200))}const I=x||"",w=R||"",B=g.map(e=>`${e}${s.DEVIATION_BADGE_SEPARATOR}${o}`),D=B[0],O=()=>{for(const e of B){const t=Ot.current[e]?.current||null,n=Ft.current[e]?.current||null;if(t||n)return{refId:e,left:t,right:n}}return{refId:D,left:null,right:null}},F=e=>`${e}${s.DEVIATION_BADGE_SEPARATOR}${I}${s.DEVIATION_BADGE_SEPARATOR}${w}`;if(!d){mn(F(D)),d=!0,c=0;const e=()=>{const{left:e,right:t}=O();return T||!e&&!!t?t:e};return u?.(),void(a=setTimeout(()=>{l||(u=((e,t)=>{let n,i=0,o=null,r=null;const s=performance.now(),c=()=>{if(l)return;if(performance.now()-s>3e3)return void t();const a=e();if(!a||0===a.getBoundingClientRect().height)return void(n=requestAnimationFrame(c));const u=a.getBoundingClientRect(),d=u.top,f=u.height,p=null!==o&&Math.abs(d-o)<.5,g=null!==r&&Math.abs(f-r)<.5;if(p&&g){if(i++,i>=5)return void t()}else i=0;o=d,r=f,n=requestAnimationFrame(c)};return n=requestAnimationFrame(c),()=>cancelAnimationFrame(n)})(e,()=>{l||(u=null,p())}))},300))}const{refId:j,left:P,right:k}=O(),N=F(j);if(!P&&!k)return c++,void(c<30&&(a=setTimeout(p,100)));const M=T||!P&&!!k,L=M?k:P,q=X?M?Pe.current:qe.current:Fe.current;if(!L||!q)return c++,void(c<30&&(a=setTimeout(p,100)));const $=L.getBoundingClientRect();if(0===$.height)return c++,void(c<30&&(a=setTimeout(p,100)));const H=q.getBoundingClientRect(),W=$.top-H.top+q.scrollTop-H.height/2+$.height/2,z=x?.includes("-")||R?.includes("-"),K=async()=>{if(l)return;t();const e=L instanceof Element?window.getComputedStyle(L).color:"";[P,k].forEach(t=>{t&&(t.style.transition="box-shadow 300ms ease-in-out",t.style.boxShadow=`0 0 10px ${e}`)}),setTimeout(()=>{[P,k].forEach(e=>{e&&(e.style.boxShadow="")})},2e3);const n=r.evaluationResult?.deviations?.[o]||r,i=r.evaluationResult?.evaluation_outputs||r.evaluation_outputs;if(!(!!P&&!!k)&&!mt){const e=M?Ft.current[z?j:y]?.current||k:Ot.current[z?j:v]?.current||P;return Ei(e,()=>{Xe({open:!0,anchorEl:e,displayImpact:G.displayImpact,summary:{...n,evaluation_outputs:i}})},{skipScroll:!0}),void V?.()}const c=(e,t)=>Promise.race([e,new Promise(e=>setTimeout(e,t))]);X&&await Promise.all([qe.current?c(s.waitForScrollIdle(qe.current),600):Promise.resolve(),Pe.current?c(s.waitForScrollIdle(Pe.current),600):Promise.resolve()]),mt&&(ge(Si(N)),ce(new Set([N]))),an.current(N,!1,{toggleIfSame:!1,sourceSide:S?"right":"left",onReady:()=>{t();const e=M?Ft.current[j]?.current||k:Ot.current[j]?.current||P;if(mt)setTimeout(()=>xi(N),150);else{const e=Ot.current[j]?.current||P,t=Ft.current[j]?.current||k;e&&(e.style.scrollMarginTop="150px",e.scrollIntoView({behavior:"smooth",block:"start"})),t&&(t.style.scrollMarginTop="150px",t.scrollIntoView({behavior:"smooth",block:"start"}))}Xe({open:!0,anchorEl:e,displayImpact:G.displayImpact,summary:{...n}}),V?.()}})};Math.abs(q.scrollTop-W)<=2?K():s.scrollAndWait(q,W,K)};return a=setTimeout(p,100),()=>{l=!0,a&&clearTimeout(a),u?.()}},[G?.id,G?.trigger,G?.displayImpact,bt,Rt,vt,X,Xe,Yn,mt,Si,xi]),t.useEffect(()=>{if(!Je.open)return;const e=Je.anchorEl;if(!e)return;if(e.isConnected)return;const t=t=>{for(const[n,i]of Object.entries(t))if(i.current?.textContent===e.textContent)return n;return null},n=e.dataset?.deviationRefId||t(Ot.current)||t(Ft.current);if(!n)return;const i=Ft.current[n]?.current||Ot.current[n]?.current;i&&i.isConnected&&Xe(e=>({...e,anchorEl:i}))},[Je.open,Je.anchorEl,de,le,un]);const{open:wi,sectionIdx:Bi,isOrphan:Di,badgeStyle:Oi,anchorEl:Fi,sectionAnchorEl:ji}=Ge;t.useEffect(()=>{if(!M.isStreamingEnabled)return;if(!wi||null==Bi)return;if(Bi===Cn)return;const e="string"==typeof Bi?Bi.split(s.DEVIATION_BADGE_SEPARATOR)[0]:null,t=(e,n)=>{if(!e||!Array.isArray(e))return null;for(const i of e){if(i.id===n)return i;if(i.subsections?.length){const e=t(i.subsections,n);if(e)return e}}return null},n=e&&"string"==typeof e?t(Rt,e):null,i=e&&"string"==typeof e?t(vt,e):null,o="number"==typeof Bi?Rt[Bi]||null:n||e&&(O?.nodes?.[e]||O?.[e])||null,r="number"==typeof Bi?vt[Bi]||null:i,l=Wn(Fi,o,r,Bi,Di,Oi);Ve(e=>{if(!e.open)return e;return s.safeStringify(e.cognitiveData)===s.safeStringify(l.cognitiveData)&&s.safeStringify(e.deviationData)===s.safeStringify(l.deviationData)&&e.sectionTitle===l.sectionTitle&&e.refSectionTitle===l.refSectionTitle?e:{...e,...l,open:!0,anchorEl:e.anchorEl,sectionAnchorEl:e.sectionAnchorEl}})},[wi,Bi,Di,Oi,Fi,ji,Rt,vt,Wn]);const Pi=t.useCallback(({section:t,keyPath:n,depth:i=0,columnKey:o="left",parentNodeId:r="",sectionOffset:s,rhsOrphanVisualIndexes:l})=>e.jsx(R.default,{section:t,keyPath:n,depth:i,columnKey:o,parentNodeId:r,sectionOffset:s,rhsOrphanVisualIndexes:l}),[]),ki=t.useMemo(()=>Rt.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&X?null:e.jsx(v.default,{section:t,idx:n},t?.layoutKey??t?.id??`left-row-${n}`)}),[Rt,X]),Ni=t.useMemo(()=>vt.map((t,n)=>{const i=!t?.title&&!t?.content,o=!t?.refIndexes||0===t.refIndexes.length;return i&&o&&X?null:e.jsx(y.default,{section:t,idx:n},t?.layoutKey??t?.id??`right-row-${n}`)}),[vt,X]),Mi=t.useRef(zn);t.useEffect(()=>{Mi.current=zn},[zn]);const Li=t.useRef(un);t.useEffect(()=>{Li.current=un},[un]);const qi=t.useRef(Ai);t.useEffect(()=>{qi.current=Ai},[Ai]);const $i=t.useRef(vi);t.useEffect(()=>{$i.current=vi},[vi]);const Hi=t.useRef(hn);t.useEffect(()=>{Hi.current=hn},[hn]);const Gi=t.useRef(gn);t.useEffect(()=>{Gi.current=gn},[gn]);const Vi=t.useRef(Pi);t.useEffect(()=>{Vi.current=Pi},[Pi]);const Wi=t.useRef(ln);t.useEffect(()=>{Wi.current=ln},[ln]);const zi=t.useMemo(()=>({isGuidelineMode:mt,maintainRelativeOrder:!!X,showDeviationBadges:te,isProposingFix:W,proposingFixNodeId:z,isRedlineFlow:K,isSideBySide:$t,activeSideBySideSection:Yt,scrollSyncLocked:de,toggleScrollSyncLocked:xn,summaryPopupAnchorEl:Je.anchorEl,connectedSections:le,proposedSections:Rt,existingSections:vt,deviationNumberRegistry:Ct,deviationParentRegistry:Et,treeData:O,displayConfig:M,deviationAnalysisStatus:he,resolvedMarkdownStyles:Oe,unifiedNumbering:Rn,expandedSections:un,expandedSubSections:fn,setExpandedSubSections:pn,getSectionCompareStyle:Zn,getSubSectionCompareStyle:ei,getBadgeRef:qt,getSectionRowRef:Mt,getSubSectionRef:Lt,sectionLeftRefs:Bt,sectionRightRefs:Dt,sectionRowRefs:Nt,sectionRightRowRefs:jt,subSectionLeftRefs:Pt,subSectionRightRefs:kt,lhsBadgeRefs:Ot,rhsBadgeRefs:Ft,openMoreFunctionsPopup:Dn,handleOpenSummaryPopup:On,openSummaryPopup:On,handleCloseSummaryPopup:Fn,toggleSection:jn,handleSubSectionToggle:Pn,renderSubSectionAccordion:kn,resetSideBySide:Nn,setConnectedSections:ce,setConnectedLines:ue,cachedConnectedPositions:Ae,showDeviationNavigation:bi,showOpenNodeRef:Ci,deviationNodeIdToView:G?.id,deviationTargetParentId:_i,guidelinesData:Y,gptWebCitationConfig:J}),[mt,X,te,W,z,K,$t,Yt,de,xn,Je.anchorEl,le,Rt,vt,Ct,M,he,Oe,Rn,un,fn,pn,Zn,ei,qt,Mt,Lt,bi,Ci,G,_i,Y,J]),Ki=s.safeStringify(Ge.sectionTitle||ft||ut),Ui=s.safeStringify(mt?gt||ht||Ge.refSectionTitle:Ge.refSectionTitle||gt||ht);return e.jsx(C.CompareContextProvider,{value:zi,children:e.jsxs(n.Box,{ref:je,sx:{display:"flex",flexDirection:"column",height:"100%",bgcolor:"#F6F7F9B2",fontFamily:'"Plus Jakarta Sans", sans-serif',overflow:"visible",position:"relative"},children:[ne&&e.jsx(n.Box,{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:e.jsx(d.default,{})}),Je.open&&e.jsx(b.default,{open:Je.open,anchorEl:Je.anchorEl,containerEl:Xn.current,clipTopEl:Re.current,scrollContainerEl:Fe.current,onClose:vi,summary:Je.summary,displayImpact:Je.displayImpact,isScrollLocked:de}),e.jsx(u.default,{open:We.open,anchorEl:We.anchorEl,maintainRelativeOrder:!!X,sectionTitle:We.sectionTitle,referenceSectionTitle:We.refSectionTitle,onClose:ot,onOpenCognitiveCompare:tt,onOpenSideBySide:Ri,onConnect:Kn,isConnected:yi,isOrphan:!mt&&!!We.isOrphan,isGuidelineMode:mt,hasGuidelineMatches:We.hasGuidelineMatches}),Ge.open&&e.jsx(a.default,{open:Ge.open,popupRef:et,position:Ke,popupConfig:$,onClose:()=>{Ue(null),Ve(e=>({...e,open:!1})),Ze(null)},markdownStyles:k,sectionTitle:Ki,referenceSectionTitle:Ui,cognitiveData:Ge.cognitiveData,anchorEl:Ge.anchorEl,sectionAnchorEl:Ge.sectionAnchorEl,scrollContainerEl:Fe.current,badgeStyle:Ge.badgeStyle,docData:Ge.docData,deviationData:Ge.deviationData,isLoading:Ge.isLoading}),e.jsx(n.Snackbar,{open:!!oe,autoHideDuration:8e3,onClose:()=>re(null),anchorOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(n.Alert,{onClose:()=>re(null),severity:"error",sx:{width:"100%",whiteSpace:"pre-line"},children:oe})}),e.jsx(x.default,{componentHeaderText:D,displayConfig:M,maintainRelativeOrder:X,onCollapseAll:ui,showCollapseAll:di,onToggleView:e=>{ie(!0),setTimeout(()=>{Q(!e),q?.(!e),fe(!1),ln(),Qe(),ce(new Set),ue([]),Ae.current=[],requestAnimationFrame(()=>{requestAnimationFrame(()=>{setTimeout(()=>{ie(!1)},600)})})},50)}}),e.jsx(n.Box,{ref:Fe,onScroll:ai,sx:{flex:1,minHeight:0,pt:1.5,pb:1,px:3,display:"flex",justifyContent:"center",alignItems:"flex-start",bgcolor:"#FFFFFF",overflowY:X?"visible":"auto",borderTop:yn&&bn?"none":"1.5px solid #EEF0F4"},children:e.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",width:"100%",maxWidth:"1200px",...X?{flex:1}:{}},children:e.jsxs(n.Box,{ref:xe,sx:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 180px minmax(0, 1fr)",gap:"100px",maxWidth:"1200px",width:"100%",position:"relative",minHeight:0,...X?{flex:1,overflow:"visible"}:{}},children:[e.jsx(I.default,{svgContainerRef:Se,svgDimensions:si,isResizing:Wt,overallConnector:oi,rootDeviationStyle:In,lines:ni,isSideBySide:$t,activeSideBySideSection:Yt,isArrowVisible:Ht,maintainRelativeOrder:X,proposedSections:Rt,existingSections:vt,cognitivePopup:Ge,activeBadgeId:Ye,closeCognitivePopup:it,setActiveBadgeId:Ze,openCognitivePopupFromState:nt,buildSectionPopupState:Wn,connectedLines:ae,isGuidelineMode:mt,deviationAnalysisStatus:he,pathRefs:Ee}),e.jsxs(n.Box,{sx:{border:"1px solid #E7E7E9",borderRadius:"8px",bgcolor:"#FFFFFF",display:"flex",flexDirection:"column",position:"relative",zIndex:2,filter:"drop-shadow(0px 2px 4px #F2F2F2)",...X?{flex:1,overflow:"visible"}:{}},children:[e.jsx(n.Box,{ref:Re,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:e.jsx(n.Tooltip,{title:ut,placement:"top",children:e.jsx(n.Typography,{sx:{fontSize:"16px",fontWeight:500,color:"#19213D",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:ut})})}),e.jsxs(n.Box,{ref:qe,onScroll:ai,sx:{p:"12px",display:"flex",flexDirection:"column",...X?{maxHeight:"calc(100vh - 250px)",flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,mr:"-180px",pr:"192px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e.jsx("div",{ref:Me,style:{width:"100%",height:"0px",flexShrink:0}}),_t&&ki,e.jsx("div",{ref:Le,style:{width:"100%",height:"0px",flexShrink:0}})]})]}),e.jsx(n.Box,{ref:Xn,sx:{width:"180px",display:"flex",flexDirection:"column",alignItems:"center",pt:"15px",gap:0,zIndex:20,pointerEvents:"none"},children:e.jsx(n.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",mt:0},children:e.jsxs(n.Box,{onClick:e=>{e.stopPropagation(),Ge.open&&Ye===Cn?it():(Ze(Cn),nt(Wn(e.currentTarget,{title:$n,content:"",evaluationResult:En,cognitiveData:{section_id:"",decisioning:[],gap:[],relevance_score:0,isMissingRationale:!0}},null,Cn,!0,{...In,label:""})))},sx:{display:"inline-flex",alignItems:"center",gap:"5px",px:1.5,py:"5px",top:"-8px",borderRadius:"20px",bgcolor:In.badgeBg,color:In.badgeText,border:`1px solid ${In.badgeBorder}`,fontSize:"12px",fontWeight:600,whiteSpace:"nowrap",position:"relative",zIndex:1,pointerEvents:"auto",cursor:"pointer"},children:[_n?e.jsx(n.Tooltip,{title:"Deviation data generation in progress",placement:"top",arrow:!0,children:e.jsx(n.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center"},children:e.jsx(f.default,{color:In.badgeText})})}):Tn??e.jsx(f.default,{color:In.badgeText}),e.jsx(n.Box,{component:"span",sx:{width:14,height:14,display:"flex",alignItems:"center","& svg":{width:"14px",height:"14px"}},children:e.jsx(o.ButtonCognitiveIcon,{})}),e.jsx(i.ChevronDown,{size:11,style:{transform:Ge.open&&Ye===Cn?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.25s ease"}})]})})}),e.jsxs(n.Box,{sx:{border:"1px solid #E3E6EA",borderRadius:"8px",bgcolor:"#FFFFFF",boxShadow:"0px 1px 4px #F7F4FE",position:"relative",zIndex:2,display:"flex",flexDirection:"column",minWidth:0,...X?{flex:1,overflow:"visible",minHeight:0}:{}},children:[Kt&&e.jsx(r.default,{sections:11}),e.jsx(n.Box,{ref:ve,sx:{p:"8px",bgcolor:mt?"#F1F3F5":"#F7F8FA",borderBottom:"1px solid #D7DCE2",borderRadius:"8px 8px 0 0",display:"flex",alignItems:"center",...X?{maxHeight:"calc(100vh - 250px)",overflowY:"auto",overflowX:"hidden",minHeight:0,...mt?{"&::-webkit-scrollbar":{width:"6px",display:"block"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#CBD5E1",borderRadius:"10px"},"&::-webkit-scrollbar-thumb:hover":{background:"#94A3B8"},scrollbarWidth:"thin",scrollbarColor:"#CBD5E1 transparent"}:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}}:{}},children:mt?e.jsxs(n.Tabs,{value:pe,onChange:(e,t)=>ge(t),variant:"fullWidth",TabIndicatorProps:{sx:{display:"none"}},sx:{width:"100%",minHeight:"36px","& .MuiTab-root":{minHeight:"36px",px:1,py:0,borderRadius:"8px",fontSize:"14px",lineHeight:1,fontWeight:500,textTransform:"none",color:"#374151",minWidth:0,transition:"background-color 160ms ease, box-shadow 160ms ease"},"& .Mui-selected":{color:"#374151",bgcolor:"#FFFFFF"}},children:[e.jsx(n.Tab,{label:e.jsx(n.Tooltip,{title:ht,placement:"top",children:e.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Redline Guidelines"})})}),e.jsx(n.Tab,{label:e.jsx(n.Tooltip,{title:"Web & GPT Sources",placement:"top",children:e.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",width:"100%"},children:"Web & GPT Sources"})})})]}):e.jsx(n.Tooltip,{title:ht,placement:"top",children:e.jsx(n.Typography,{sx:{fontSize:"16px",fontWeight:500,color:"#5928ED",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,textAlign:"center",display:"block"},children:ht})})}),e.jsxs(n.Box,{ref:Pe,onScroll:ai,sx:{p:mt?"0px":"12px",display:"flex",flexDirection:"column",...X?{maxHeight:"calc(100vh - 250px)",...!mt&&{flex:1},overflowY:"auto",overflowX:"hidden",minHeight:0,ml:"-150px",pl:"165px","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}:{}},children:[e.jsx("div",{ref:ke,style:{width:"100%",height:"0px",flexShrink:0}}),mt?0===pe?e.jsx(w.default,{guidelinesData:Y,deviationData:H,connectedSections:le,proposedSections:Rt}):e.jsx(B.default,{deviationData:H,connectedSections:le,proposedSections:Rt}):_t&&Ni,e.jsx("div",{ref:Ne,style:{width:"100%",height:"0px",flexShrink:0}})]})]})]})})})]})})};
|
|
2
2
|
//# sourceMappingURL=CognitiveCompare.js.map
|